Ticket #29307: mdk-guile2-support.patch

File mdk-guile2-support.patch, 7.4 KB (added by aconchillo@…, 8 years ago)

mdk Guile 2 support

  • configure.ac

    From 0e34011e6c2d0a23c3b22a93bf2595ee11d92e0d Mon Sep 17 00:00:00 2001
    From: Aleix Conchillo Flaque <aconchillo@gmail.com>
    Date: Thu, 26 Jul 2012 18:21:40 -0700
    Subject: [PATCH] add support for guile 2.0
    
    ---
     configure.ac                        |   12 ++------
     mixguile/mixguile_cmd_dispatcher.c  |    2 +-
     mixguile/xmixguile_cmd_dispatcher.c |   55 ++++++++++++++++++-----------------
     mixguile/xmixguile_cmd_dispatcher.h |    2 +-
     4 files changed, 33 insertions(+), 38 deletions(-)
    
    diff --git a/configure.ac b/configure.ac
    index 179297d..01b8fee 100644
    a b AC_ARG_WITH(guile, 
    9090esac], [wguile=true])
    9191
    9292if test x$wguile = xtrue; then
    93 dnl  AC_CHECK_HEADER(guile/gh.h,,wguile=false)
    94   AC_MSG_CHECKING(for Guile)
    95   guile-config link > /dev/null || {
    96     AC_MSG_RESULT(no)
    97     wguile=false
    98   }
     93  PKG_CHECK_MODULES(GUILE,guile-2.0 >= 2.0,[wguile=true],[wguile=false])
    9994fi
    10095
    10196if test x$wguile = xtrue; then
    102   GUILE_CFLAGS="`guile-config compile`"
    103   GUILE_LDFLAGS="`guile-config link`"
    104   LIBS="$LIBS $GUILE_LDFLAGS"
     97  LIBS="$LIBS $GUILE_LIBS"
    10598  AM_CFLAGS="$AM_CFLAGS $GUILE_CFLAGS"
    10699  AC_SUBST(MAKE_GUILE)
    107   AC_MSG_RESULT(yes)
    108100fi
    109101
    110102AM_CONDITIONAL(MAKE_GUILE, test x$wguile = xtrue)
  • mixguile/mixguile_cmd_dispatcher.c

    diff --git a/mixguile/mixguile_cmd_dispatcher.c b/mixguile/mixguile_cmd_dispatcher.c
    index b302f39..a226423 100644
    a b  
    2424#include <fcntl.h>
    2525#include <errno.h>
    2626
    27 #include <guile/gh.h>
     27#include <libguile.h>
    2828#include "mixguile.h"
    2929#include "xmixguile_cmd_dispatcher.h"
    3030
  • mixguile/xmixguile_cmd_dispatcher.c

    diff --git a/mixguile/xmixguile_cmd_dispatcher.c b/mixguile/xmixguile_cmd_dispatcher.c
    index d6baf47..bbc411d 100644
    a b  
    2222#include <string.h>
    2323
    2424#include <mixlib/mix.h>
    25 #include <guile/gh.h>
     25#include <libguile.h>
    2626
    2727#include "xmixguile_cmd_dispatcher.h"
    2828
     
    3030static mixguile_cmd_dispatcher_t *dispatcher_;
    3131static mix_vm_cmd_dispatcher_t *vm_dispatcher_;
    3232static mix_vm_t *vm_;
     33static SCM mutex_;
    3334
    3435/* register a NULL-terminated list of scm commands */
    3536void
    register_cmd_dispatcher_ (mixguile_cmd_dispatcher_t *dis) 
    5657  dispatcher_ = dis;
    5758  vm_dispatcher_ = mixguile_cmd_dispatcher_get_vm_dispatcher (dis);
    5859  vm_ = (mix_vm_t *) mix_vm_cmd_dispatcher_get_vm (vm_dispatcher_);
     60  mutex_ = scm_make_mutex ();
    5961}
    6062
    6163/* commands */
    mixvm_cmd_ (SCM cmd, SCM arg) 
    6567  char *com = NULL, *argu = NULL;
    6668  gboolean result;
    6769
    68   SCM_ASSERT (SCM_STRINGP (cmd) || SCM_SYMBOLP (cmd),
    69               cmd, SCM_ARG1, "mixvm-cmd");
    70   SCM_ASSERT (SCM_STRINGP (arg) || SCM_SYMBOLP (arg),
    71               arg, SCM_ARG2, "mixvm-cmd");
     70  SCM_ASSERT (scm_is_string (cmd) || scm_is_symbol (cmd),
     71              cmd, SCM_ARG1, "mixvm-cmd");
     72  SCM_ASSERT (scm_is_string (arg) || scm_is_symbol (arg),
     73              arg, SCM_ARG2, "mixvm-cmd");
    7274
    73   SCM_DEFER_INTS;
     75  scm_lock_mutex (mutex_);
    7476  com =  scm_to_locale_string (cmd);
    7577  argu = scm_to_locale_string (arg);
    7678  result = mix_vm_cmd_dispatcher_dispatch (vm_dispatcher_,
    mixvm_cmd_ (SCM cmd, SCM arg) 
    7981  g_free (com);
    8082  g_free (argu);
    8183
    82   SCM_ALLOW_INTS;
     84  scm_unlock_mutex (mutex_);
    8385
    8486  return SCM_UNSPECIFIED;
    8587}
    mix_reg_ (SCM reg) 
    116118  char *regis;
    117119  long val = MIX_WORD_MAX + 1;
    118120
    119   SCM_ASSERT (SCM_STRINGP (reg) || SCM_SYMBOLP (reg), reg, SCM_ARG1, "mix-reg");
     121  SCM_ASSERT (scm_is_string (reg) || scm_is_symbol (reg),
     122              reg, SCM_ARG1, "mix-reg");
    120123
    121   SCM_DEFER_INTS;
     124  scm_lock_mutex (mutex_);
    122125  if (SCM_SYMBOLP (reg)) reg = scm_symbol_to_string (reg);
    123126  regis = scm_to_locale_string (reg);
    124127  switch (regis[0])
    mix_reg_ (SCM reg) 
    140143    }
    141144  g_free (regis);
    142145
    143   SCM_ALLOW_INTS;
     146  scm_unlock_mutex (mutex_);
    144147
    145148  SCM_ASSERT (val <= MIX_WORD_MAX, reg, SCM_ARG1, "mix-reg");
    146149
    mix_set_reg_ (SCM reg, SCM value) 
    154157  long val;
    155158  gboolean result = TRUE;
    156159
    157   SCM_ASSERT (SCM_STRINGP (reg) || SCM_SYMBOLP (reg), reg, SCM_ARG1,
    158               "mix-set-reg!");
    159   SCM_ASSERT (SCM_NUMBERP (value), value, SCM_ARG2, "mix-set-reg!");
     160  SCM_ASSERT (scm_is_string (reg) || scm_is_symbol (reg),
     161              reg, SCM_ARG1, "mix-set-reg!");
     162  SCM_ASSERT (scm_is_number (value), value, SCM_ARG2, "mix-set-reg!");
    160163
    161   SCM_DEFER_INTS;
     164  scm_lock_mutex (mutex_);
    162165  if (SCM_SYMBOLP (reg)) reg = scm_symbol_to_string (reg);
    163166  regis = scm_to_locale_string (reg);
    164167  val = scm_to_long (value);
    mix_set_reg_ (SCM reg, SCM value) 
    182185    }
    183186  g_free (regis);
    184187
    185   SCM_ALLOW_INTS;
     188  scm_unlock_mutex (mutex_);
    186189
    187190  SCM_ASSERT (result, reg, SCM_ARG1, "mix-set-reg!");
    188191
    mix_set_cmp_ (SCM value) 
    256259  gchar *val = NULL;
    257260  mix_cmpflag_t result = -1;
    258261
    259   SCM_ASSERT (SCM_STRINGP (value) || SCM_SYMBOLP (value), value, SCM_ARG1,
    260               "mix-set-cmp!");
     262  SCM_ASSERT (scm_is_string (value) || scm_is_symbol (value),
     263              value, SCM_ARG1, "mix-set-cmp!");
    261264
    262   SCM_DEFER_INTS;
     265  scm_lock_mutex (mutex_);
    263266  val = scm_to_locale_string (value);
    264267  if (strlen (val) == 1)
    265268    {
    mix_set_cmp_ (SCM value) 
    272275        }
    273276    }
    274277  g_free (val);
    275   SCM_ALLOW_INTS;
     278  scm_unlock_mutex (mutex_);
    276279  SCM_ASSERT (result != -1, value, SCM_ARG1, "mix-set-cmp!");
    277280  mix_vm_set_cmpflag (vm_, result);
    278281  return SCM_BOOL_T;
    mix_add_hook_ (SCM cmd, SCM function, gboolean pre) 
    456459  mix_vm_command_t command;
    457460  const gchar *fun = pre? "mix-add-pre-hook" : "mix-add-post-hook";
    458461
    459   SCM_ASSERT (SCM_STRINGP (cmd) || SCM_SYMBOLP (cmd), cmd, SCM_ARG1, fun);
     462  SCM_ASSERT (scm_is_string (cmd) || scm_is_symbol (cmd), cmd, SCM_ARG1, fun);
    460463  SCM_ASSERT (scm_is_true (scm_procedure_p (function)), function, SCM_ARG2, fun);
    461   SCM_DEFER_INTS;
     464  scm_lock_mutex (mutex_);
    462465  cmdstr = scm_to_locale_string (cmd);
    463466  command = mix_vm_command_from_string (cmdstr);
    464467  g_free (cmdstr);
    465   SCM_ALLOW_INTS;
     468  scm_unlock_mutex (mutex_);
    466469  SCM_ASSERT (command != MIX_CMD_INVALID, cmd, SCM_ARG1, fun);
    467   SCM_DEFER_INTS;
     470  scm_lock_mutex (mutex_);
    468471  if (pre)
    469472    mix_vm_cmd_dispatcher_pre_hook (vm_dispatcher_, command, scm_hook_,
    470473                                    (gpointer) define_hook_procedure_ (function));
    471474  else
    472475    mix_vm_cmd_dispatcher_post_hook (vm_dispatcher_, command, scm_hook_,
    473476                                     (gpointer) define_hook_procedure_ (function));
    474   SCM_ALLOW_INTS;
     477  scm_unlock_mutex (mutex_);
    475478  return SCM_BOOL_T;
    476479}
    477480
    mix_add_global_hook_ (SCM function, gboolean pre) 
    482485    pre? "mix-add-global-pre-hook" : "mix-add-global-post-hook";
    483486
    484487  SCM_ASSERT (scm_is_true (scm_procedure_p (function)), function, SCM_ARG1, fun);
    485   SCM_DEFER_INTS;
     488  scm_lock_mutex (mutex_);
    486489  if (pre)
    487490    mix_vm_cmd_dispatcher_global_pre_hook (vm_dispatcher_, scm_global_hook_,
    488491                                           (gpointer) define_hook_procedure_ (function));
    489492  else
    490493    mix_vm_cmd_dispatcher_global_post_hook (vm_dispatcher_, scm_global_hook_,
    491494                                            (gpointer) define_hook_procedure_ (function));
    492   SCM_ALLOW_INTS;
     495  scm_unlock_mutex (mutex_);
    493496  return SCM_BOOL_T;
    494497}
    495498
  • mixguile/xmixguile_cmd_dispatcher.h

    diff --git a/mixguile/xmixguile_cmd_dispatcher.h b/mixguile/xmixguile_cmd_dispatcher.h
    index f6d987a..4298267 100644
    a b  
    2626#include <stdlib.h>
    2727#include <stdio.h>
    2828
    29 #include <guile/gh.h>
     29#include <libguile.h>
    3030#include "mixguile_cmd_dispatcher.h"
    3131
    3232/* the cmd dispatcher type */