*** empty log message ***
[bpt/guile.git] / libguile / arbiters.c
index d1be6d1..faa0f46 100644 (file)
 
 \f
 
-#include <stdio.h>
-#include "_scm.h"
-#include "smob.h"
-#include "genio.h"
+#include "libguile/_scm.h"
+#include "libguile/ports.h"
+#include "libguile/smob.h"
 
-#include "validate.h"
-#include "arbiters.h"
+#include "libguile/validate.h"
+#include "libguile/arbiters.h"
 
 \f
 /* {Arbiters}
  * SCM_DEFER_INTS). 
  */
 
-static long scm_tc16_arbiter;
+static scm_bits_t scm_tc16_arbiter;
 
 
-#define SCM_ARB_LOCKED(arb) ((SCM_UNPACK_CAR (arb)) & (1L << 16))
-#define SCM_LOCK_ARB(arb) SCM_SETCAR (arb, (SCM) (scm_tc16_arbiter | (1L << 16)));
-#define SCM_UNLOCK_ARB(arb) SCM_SETCAR (arb, (SCM) scm_tc16_arbiter);
+#define SCM_ARB_LOCKED(arb)  ((SCM_CELL_WORD_0 (arb)) & (1L << 16))
+#define SCM_LOCK_ARB(arb)    (SCM_SET_CELL_WORD_0 ((arb), scm_tc16_arbiter | (1L << 16)));
+#define SCM_UNLOCK_ARB(arb)  (SCM_SET_CELL_WORD_0 ((arb), scm_tc16_arbiter));
 
 static int 
-prinarb (SCM exp, SCM port, scm_print_state *pstate)
+arbiter_print (SCM exp, SCM port, scm_print_state *pstate)
 {
   scm_puts ("#<arbiter ", port);
   if (SCM_ARB_LOCKED (exp))
     scm_puts ("locked ", port);
-  scm_iprin1 (SCM_CDR (exp), port, pstate);
+  scm_iprin1 (SCM_PACK (SCM_SMOB_DATA (exp)), port, pstate);
   scm_putc ('>', port);
   return !0;
 }
 
 SCM_DEFINE (scm_make_arbiter, "make-arbiter", 1, 0, 0, 
-           (SCM name),
-"Returns an object of type arbiter and name name. Its state is initially unlocked.\n"
-"Arbiters are a way to achieve process synchronization.")
+           (SCM name),
+           "Return an object of type arbiter and name @var{name}. Its\n"
+           "state is initially unlocked.  Arbiters are a way to achieve\n"
+           "process synchronization.")
 #define FUNC_NAME s_scm_make_arbiter
 {
-  SCM_RETURN_NEWSMOB (scm_tc16_arbiter, name);
+  SCM_RETURN_NEWSMOB (scm_tc16_arbiter, SCM_UNPACK (name));
 }
 #undef FUNC_NAME
 
 SCM_DEFINE (scm_try_arbiter, "try-arbiter", 1, 0, 0, 
-           (SCM arb),
-"Returns #t and locks arbiter if arbiter was unlocked. Otherwise, returns #f.")
+           (SCM arb),
+           "Return @code{#t} and lock the arbiter @var{arb} if the arbiter\n"
+           "was unlocked. Otherwise, return @code{#f}.")
 #define FUNC_NAME s_scm_try_arbiter
 {
-  SCM_VALIDATE_SMOB (1,arb,arbiter);
+  SCM_VALIDATE_SMOB (1, arb, arbiter);
   SCM_DEFER_INTS;
   if (SCM_ARB_LOCKED(arb))
     arb = SCM_BOOL_F;
@@ -109,12 +110,13 @@ SCM_DEFINE (scm_try_arbiter, "try-arbiter", 1, 0, 0,
 
 
 SCM_DEFINE (scm_release_arbiter, "release-arbiter", 1, 0, 0, 
-           (SCM arb),
-"Returns #t and unlocks arbiter if arbiter was locked. Otherwise, returns #f.")
+           (SCM arb),
+           "Return @code{#t} and unlock the arbiter @var{arb} if the\n"
+           "arbiter was locked. Otherwise, return @code{#f}.")
 #define FUNC_NAME s_scm_release_arbiter
 {
-  SCM_VALIDATE_SMOB (1,arb,arbiter);
-  if (! SCM_ARB_LOCKED(arb))
+  SCM_VALIDATE_SMOB (1, arb, arbiter);
+  if (!SCM_ARB_LOCKED(arb))
     return SCM_BOOL_F;
   SCM_UNLOCK_ARB (arb);
   return SCM_BOOL_T;
@@ -126,7 +128,16 @@ SCM_DEFINE (scm_release_arbiter, "release-arbiter", 1, 0, 0,
 void
 scm_init_arbiters ()
 {
-  scm_tc16_arbiter = scm_make_smob_type_mfpe ("arbiter", 0,
-                                              scm_markcdr, NULL, prinarb, NULL);
-#include "arbiters.x"
+  scm_tc16_arbiter = scm_make_smob_type ("arbiter", 0);
+  scm_set_smob_mark (scm_tc16_arbiter, scm_markcdr);
+  scm_set_smob_print (scm_tc16_arbiter, arbiter_print);
+#ifndef SCM_MAGIC_SNARFER
+#include "libguile/arbiters.x"
+#endif
 }
+
+/*
+  Local Variables:
+  c-file-style: "gnu"
+  End:
+*/