1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

* async.[ch]: unexpose low-level async access macros (thanks to

Dirk Herrmann).

* validate.h: move async validation macros to async.c (nobody else
needs them anyway), and rename them.
This commit is contained in:
Michael Livshin 2000-04-05 15:28:28 +00:00
parent 843e4e9d17
commit e94e3f21d6
4 changed files with 43 additions and 37 deletions

View file

@ -1,3 +1,11 @@
2000-04-05 Michael Livshin <mlivshin@bigfoot.com>
* async.[ch]: unexpose low-level async access macros (thanks to
Dirk Herrmann).
* validate.h: move async validation macros to async.c (nobody else
needs them anyway), and rename them.
2000-04-04 Michael Livshin <mlivshin@bigfoot.com> 2000-04-04 Michael Livshin <mlivshin@bigfoot.com>
* async.h: kill the scm_async_t struct. having a heap cell * async.h: kill the scm_async_t struct. having a heap cell

View file

@ -110,7 +110,19 @@ static unsigned int scm_desired_switch_rate = 0;
int scm_asyncs_pending_p = 0; int scm_asyncs_pending_p = 0;
#endif #endif
static long scm_tc16_async; static long tc16_async;
/* cmm: this has SCM_ prefix because SCM_MAKE_VALIDATE expects it.
this is ugly. */
#define SCM_ASYNCP(X) (SCM_NIMP(X) && (tc16_async == SCM_GCTYP16 (X)))
#define VALIDATE_ASYNC(pos,a) SCM_MAKE_VALIDATE(pos, a, ASYNCP)
#define ASYNC_GOT_IT(X) (SCM_CELL_WORD_0 (X) >> 16)
#define SET_ASYNC_GOT_IT(X, V) (SCM_SET_CELL_WORD_0 (X, (SCM_CELL_WORD_0 (X) & ((1 << 16) - 1)) | ((V) << 16)))
#define ASYNC_THUNK(X) SCM_CELL_OBJECT_1 (X)
@ -123,7 +135,7 @@ scm_asyncs_pending ()
while (pos != SCM_EOL) while (pos != SCM_EOL)
{ {
SCM a = SCM_CAR (pos); SCM a = SCM_CAR (pos);
if (SCM_ASYNC_GOT_IT (a)) if (ASYNC_GOT_IT (a))
return 1; return 1;
pos = SCM_CDR (pos); pos = SCM_CDR (pos);
} }
@ -218,8 +230,7 @@ scm_async_click ()
/* /*
if (owe_tick) if (owe_tick)
scm_async_mark (system_signal_asyncs[SCM_SIG_ORD(SCM_TICK_SIGNAL)]); scm_async_mark (system_signal_asyncs[SCM_SIG_ORD(SCM_TICK_SIGNAL)]); */
*/
SCM_DEFER_INTS; SCM_DEFER_INTS;
if (scm_tick_rate && scm_switch_rate) if (scm_tick_rate && scm_switch_rate)
@ -283,7 +294,7 @@ scm_async_click ()
static SCM static SCM
mark_async (SCM obj) mark_async (SCM obj)
{ {
return SCM_ASYNC_THUNK (obj); return ASYNC_THUNK (obj);
} }
@ -293,7 +304,7 @@ SCM_DEFINE (scm_async, "async", 1, 0, 0,
"") "")
#define FUNC_NAME s_scm_async #define FUNC_NAME s_scm_async
{ {
SCM_RETURN_NEWSMOB (scm_tc16_async, SCM_UNPACK (thunk)); SCM_RETURN_NEWSMOB (tc16_async, SCM_UNPACK (thunk));
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -319,11 +330,11 @@ SCM_DEFINE (scm_async_mark, "async-mark", 1, 0, 0,
"") "")
#define FUNC_NAME s_scm_async_mark #define FUNC_NAME s_scm_async_mark
{ {
SCM_VALIDATE_ASYNC (1,a); VALIDATE_ASYNC (1, a);
#ifdef GUILE_OLD_ASYNC_CLICK #ifdef GUILE_OLD_ASYNC_CLICK
SCM_SET_ASYNC_GOT_IT (a, 1); SET_ASYNC_GOT_IT (a, 1);
#else #else
SCM_SET_ASYNC_GOT_IT (a, scm_asyncs_pending_p = 1); SET_ASYNC_GOT_IT (a, scm_asyncs_pending_p = 1);
#endif #endif
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
} }
@ -335,14 +346,14 @@ SCM_DEFINE (scm_system_async_mark, "system-async-mark", 1, 0, 0,
"") "")
#define FUNC_NAME s_scm_system_async_mark #define FUNC_NAME s_scm_system_async_mark
{ {
SCM_VALIDATE_ASYNC (1, a); VALIDATE_ASYNC (1, a);
SCM_REDEFER_INTS; SCM_REDEFER_INTS;
#ifdef GUILE_OLD_ASYNC_CLICK #ifdef GUILE_OLD_ASYNC_CLICK
SCM_SET_ASYNC_GOT_IT (a, 1); SET_ASYNC_GOT_IT (a, 1);
scm_async_rate = 1 + scm_async_rate - scm_async_clock; scm_async_rate = 1 + scm_async_rate - scm_async_clock;
scm_async_clock = 1; scm_async_clock = 1;
#else #else
SCM_SET_ASYNC_GOT_IT (a, scm_asyncs_pending_p = 1); SET_ASYNC_GOT_IT (a, scm_asyncs_pending_p = 1);
#endif #endif
SCM_REALLOW_INTS; SCM_REALLOW_INTS;
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
@ -366,12 +377,12 @@ SCM_DEFINE (scm_run_asyncs, "run-asyncs", 1, 0, 0,
SCM a; SCM a;
SCM_VALIDATE_CONS (1, list_of_a); SCM_VALIDATE_CONS (1, list_of_a);
a = SCM_CAR (list_of_a); a = SCM_CAR (list_of_a);
SCM_VALIDATE_ASYNC (SCM_ARG1,a); VALIDATE_ASYNC (SCM_ARG1, a);
scm_mask_ints = 1; scm_mask_ints = 1;
if (SCM_ASYNC_GOT_IT (a)) if (ASYNC_GOT_IT (a))
{ {
SCM_SET_ASYNC_GOT_IT (a, 0); SET_ASYNC_GOT_IT (a, 0);
scm_apply (SCM_ASYNC_THUNK (a), SCM_EOL, SCM_EOL); scm_apply (ASYNC_THUNK (a), SCM_EOL, SCM_EOL);
} }
scm_mask_ints = 0; scm_mask_ints = 0;
list_of_a = SCM_CDR (list_of_a); list_of_a = SCM_CDR (list_of_a);
@ -481,7 +492,7 @@ void
scm_init_async () scm_init_async ()
{ {
SCM a_thunk; SCM a_thunk;
scm_tc16_async = scm_make_smob_type_mfpe ("async", 0, tc16_async = scm_make_smob_type_mfpe ("async", 0,
mark_async, NULL, NULL, NULL); mark_async, NULL, NULL, NULL);
scm_gc_vcell = scm_sysintern ("gc-thunk", SCM_BOOL_F); scm_gc_vcell = scm_sysintern ("gc-thunk", SCM_BOOL_F);
a_thunk = scm_make_gsubr ("%gc-thunk", 0, 0, 0, scm_sys_gc_async_thunk); a_thunk = scm_make_gsubr ("%gc-thunk", 0, 0, 0, scm_sys_gc_async_thunk);

View file

@ -50,13 +50,6 @@
#include "libguile/__scm.h" #include "libguile/__scm.h"
#define SCM_ASYNCP(X) (SCM_NIMP(X) && (scm_tc16_async == SCM_GCTYP16 (X)))
#define SCM_ASYNC_GOT_IT(X) (SCM_CELL_WORD_0 (X) >> 16)
#define SCM_SET_ASYNC_GOT_IT(X, V) (SCM_SET_CELL_WORD_0 (X, (SCM_CELL_WORD_0 (X) & ((1 << 16) - 1)) | ((V) << 16)))
#define SCM_ASYNC_THUNK(X) SCM_CELL_OBJECT_1 (X)
extern unsigned int scm_mask_ints; extern unsigned int scm_mask_ints;

View file

@ -1,16 +1,16 @@
/* $Id: validate.h,v 1.3 2000-04-03 08:47:51 dirk Exp $ */ /* $Id: validate.h,v 1.4 2000-04-05 15:28:28 cmm Exp $ */
/* Copyright (C) 1999 Free Software Foundation, Inc. /* Copyright (C) 1999 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to * along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
@ -98,7 +98,7 @@
#define SCM_VALIDATE_BOOL_COPY(pos,flag,cvar) \ #define SCM_VALIDATE_BOOL_COPY(pos,flag,cvar) \
do { SCM_ASSERT(SCM_BOOLP(flag), flag, pos, FUNC_NAME); \ do { SCM_ASSERT(SCM_BOOLP(flag), flag, pos, FUNC_NAME); \
cvar = (SCM_TRUE_P (flag))? 1: 0; } while (0) cvar = SCM_TRUE_P (flag) ? 1 : 0; } while (0)
#define SCM_VALIDATE_CHAR(pos,scm) SCM_MAKE_VALIDATE(pos,scm,ICHRP) #define SCM_VALIDATE_CHAR(pos,scm) SCM_MAKE_VALIDATE(pos,scm,ICHRP)
@ -210,12 +210,6 @@
#define SCM_VALIDATE_SMOB(pos,obj,type) \ #define SCM_VALIDATE_SMOB(pos,obj,type) \
do { SCM_ASSERT ((SCM_NIMP(obj) && SCM_TYP16 (obj) == scm_tc16_ ## type), obj, pos, FUNC_NAME); } while (0) do { SCM_ASSERT ((SCM_NIMP(obj) && SCM_TYP16 (obj) == scm_tc16_ ## type), obj, pos, FUNC_NAME); } while (0)
#define SCM_VALIDATE_ASYNC(pos,a) SCM_MAKE_VALIDATE(pos,a,ASYNCP)
#define SCM_VALIDATE_ASYNC_COPY(pos,a,cvar) \
do { SCM_ASSERT (SCM_ASYNCP (a), a, pos, FUNC_NAME); \
cvar = SCM_ASYNC(a); } while (0)
#define SCM_VALIDATE_THREAD(pos,a) SCM_MAKE_VALIDATE(pos,a,THREADP) #define SCM_VALIDATE_THREAD(pos,a) SCM_MAKE_VALIDATE(pos,a,THREADP)
#define SCM_VALIDATE_THUNK(pos,thunk) \ #define SCM_VALIDATE_THUNK(pos,thunk) \
@ -230,7 +224,7 @@
#define SCM_VALIDATE_CLOSURE(pos,obj) SCM_MAKE_VALIDATE(pos,obj,CLOSUREP) #define SCM_VALIDATE_CLOSURE(pos,obj) SCM_MAKE_VALIDATE(pos,obj,CLOSUREP)
#define SCM_VALIDATE_PROC(pos,proc) \ #define SCM_VALIDATE_PROC(pos,proc) \
do { SCM_ASSERT ( SCM_TRUE_P (scm_procedure_p(proc)), proc, pos, FUNC_NAME); } while (0) do { SCM_ASSERT (SCM_TRUE_P (scm_procedure_p (proc)), proc, pos, FUNC_NAME); } while (0)
#define SCM_VALIDATE_NULLORCONS(pos,env) \ #define SCM_VALIDATE_NULLORCONS(pos,env) \
do { SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); } while (0) do { SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); } while (0)
@ -278,7 +272,7 @@
#define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos,v) \ #define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos,v) \
do { SCM_ASSERT ((SCM_VECTORP (v) || \ do { SCM_ASSERT ((SCM_VECTORP (v) || \
(SCM_NIMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \ (SCM_NIMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \
v, pos, FUNC_NAME); } while (0) v, pos, FUNC_NAME); } while (0)
#define SCM_VALIDATE_STRUCT(pos,v) SCM_MAKE_VALIDATE(pos,v,STRUCTP) #define SCM_VALIDATE_STRUCT(pos,v) SCM_MAKE_VALIDATE(pos,v,STRUCTP)