[uim-commit] r1471 - in branches/r5rs: sigscheme uim
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Sep 11 11:17:15 PDT 2005
Author: yamaken
Date: 2005-09-11 11:17:12 -0700 (Sun, 11 Sep 2005)
New Revision: 1471
Modified:
branches/r5rs/sigscheme/datas.c
branches/r5rs/sigscheme/io.c
branches/r5rs/sigscheme/main.c
branches/r5rs/sigscheme/sigscheme.c
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/sigscheme/storage-protection.c
branches/r5rs/uim/uim-scm.c
Log:
* This commit revises the stack protection API of SCM_GCC4_READY_GC,
and the functions that using it are rewritten as follows.
- a_stack_protected_func:
* Remove obsoleted SCM_GCC4_READY_GC codes
* Split off the main code to a_stack_protected_func_internal
* Rewrite as stack protection gate to a_stack_protected_func_internal
* Support new SCM_GCC4_READY_GC API by SCM_GC_CALL_PROTECTED_FUNC
- a_stack_protected_func_internal:
* New static function
* Split off the main code from a_stack_protected_func
* Declare by SCM_GC_PROTECTED_FUNC_DECL
* sigscheme/sigscheme.h
- (SCM_GC_PROTECTED_FUNC, SCM_DECLARE_GC_PROTECTED_FUNC_BODY,
SCM_DEFINE_GC_PROTECTED_FUNC_BODY, SCM_DEFINE_GC_PROTECTED_FUNC0,
SCM_DEFINE_GC_PROTECTED_FUNC1, SCM_DEFINE_GC_PROTECTED_FUNC2,
SCM_DEFINE_GC_PROTECTED_FUNC3, SCM_DEFINE_GC_PROTECTED_FUNC4,
SCM_DEFINE_GC_PROTECTED_FUNC5, SigScm_GC_CallProtectedFunc0,
SigScm_GC_CallProtectedFunc1, SigScm_GC_CallProtectedFunc2,
SigScm_GC_CallProtectedFunc3, SigScm_GC_CallProtectedFunc4,
SigScm_GC_CallProtectedFunc5): Removed
- (SCM_GC_PROTECTED_FUNC_T, SCM_GC_PROTECTED_FUNC_DECL,
SCM_GC_CALL_PROTECTED_FUNC, SCM_GC_CALL_PROTECTED_VOID_FUNC,
SCM_GC_CALL_PROTECTED_FUNC_INTERNAL): New macro
- (SigScm_GC_ProtectStack, SigScm_GC_UnprotectStack,
SigScm_GC_EnsureUninlinedFunc): New function for SCM_GCC4_READY_GC
* sigscheme/storage-protection.c
- (SCM_GC_CALL_PROTECTED_FUNC): Moved to sigscheme.h
- (gc_protect_stack): Rename to SigScm_GC_ProtectStack
- (SigScm_GC_ProtectStack):
* Renamed from gc_protect_stack
* Make exported
- (gc_unprotect_stack): Rename to SigScm_GC_UnprotectStack
- (SigScm_GC_UnprotectStack):
* Renamed from gc_unprotect_stack
* Make exported
- (SigScm_GC_EnsureUninlinedFunc): New function
- (SigScm_GC_CallProtectedFunc0, SigScm_GC_CallProtectedFunc1,
SigScm_GC_CallProtectedFunc2, SigScm_GC_CallProtectedFunc3,
SigScm_GC_CallProtectedFunc4, SigScm_GC_CallProtectedFunc5):
Removed
* sigscheme/io.c
- (SigScm_load): Follow the SCM_GCC4_READY_GC revision as written
above
- (SigScm_load_internal): New static function
- (ScmOp_require): Remove stack protection codes it's unnecessary
here. It should be performed in SigScm_require() as proper
responsibility separation
* sigscheme/datas.c
- (SigScm_eval_c_string): Follow the SCM_GCC4_READY_GC revision as
written above
- (SigScm_eval_c_string_internal): New static function
* sigscheme/sigscheme.c
- (SigScm_Initialize): Follow the SCM_GCC4_READY_GC revision as
written above
- (SigScm_Initialize_internal): New static function
* sigscheme/main.c
- (repl): Follow the SCM_GCC4_READY_GC revision as
a_stack_protected_func_internal written above
- (main): Add SCM_GC_CALL_PROTECTED_VOID_FUNC for repl() when
SCM_GCC4_READY_GC
* uim/uim-scm.c
- (uim_scm_require_file): Follow the specification change of
ScmOp_require()
Modified: branches/r5rs/sigscheme/datas.c
===================================================================
--- branches/r5rs/sigscheme/datas.c 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/sigscheme/datas.c 2005-09-11 18:17:12 UTC (rev 1471)
@@ -184,6 +184,12 @@
static void finalize_protected_var(void);
+#if SCM_GCC4_READY_GC
+static SCM_GC_PROTECTED_FUNC_DECL(ScmObj, Scm_eval_c_string_internal, (const char *exp));
+#else
+static ScmObj Scm_eval_c_string_internal(const char *exp);
+#endif
+
/*=======================================
Function Implementations
=======================================*/
@@ -872,22 +878,33 @@
return sym;
}
-#if SCM_GCC4_READY_GC
-SCM_DEFINE_GC_PROTECTED_FUNC1(, ScmObj, Scm_eval_c_string, const char *, exp)
-{
-#else
ScmObj Scm_eval_c_string(const char *exp)
{
+#if !SCM_GCC4_READY_GC
ScmObj stack_start = NULL;
-#endif /* SCM_GCC4_READY_GC */
- ScmObj str_port = SCM_NULL;
+#endif
ScmObj ret = SCM_NULL;
-#if !SCM_GCC4_READY_GC
+#if SCM_GCC4_READY_GC
+ SCM_GC_CALL_PROTECTED_FUNC(ret, Scm_eval_c_string_internal, (exp));
+#else
/* start protecting stack */
SigScm_GC_ProtectStack(&stack_start);
+
+ ret = Scm_eval_c_string_internal(exp);
+
+ /* now no need to protect stack */
+ SigScm_GC_UnprotectStack(&stack_start);
#endif
+ return ret;
+}
+
+ScmObj Scm_eval_c_string_internal(const char *exp)
+{
+ ScmObj str_port = SCM_NULL;
+ ScmObj ret = SCM_NULL;
+
str_port = Scm_NewStringPort(exp);
ret = SigScm_Read(str_port);
@@ -897,11 +914,6 @@
scm_return_value = ret;
#endif
-#if !SCM_GCC4_READY_GC
- /* now no need to protect stack */
- SigScm_GC_UnprotectStack(&stack_start);
-#endif
-
return ret;
}
Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/sigscheme/io.c 2005-09-11 18:17:12 UTC (rev 1471)
@@ -63,6 +63,11 @@
/*=======================================
File Local Function Declarations
=======================================*/
+#if SCM_GCC4_READY_GC
+static SCM_GC_PROTECTED_FUNC_DECL(ScmObj, SigScm_load_internal, (const char *c_filename));
+#else
+static ScmObj SigScm_load_internal(const char *c_filename);
+#endif /* SCM_GCC4_READY_GC */
static char* create_valid_path(const char *c_filename);
#if SCM_USE_NONSTD_FEATURES
static ScmObj create_loaded_str(ScmObj filename);
@@ -411,23 +416,34 @@
/*===========================================================================
R5RS : 6.6 Input and Output : 6.6.4 System Interface
===========================================================================*/
-#if SCM_GCC4_READY_GC
-SCM_DEFINE_GC_PROTECTED_FUNC1(, ScmObj, SigScm_load, const char *, filename)
+ScmObj SigScm_load(const char *c_filename)
{
-#else
-ScmObj SigScm_load(const char *filename)
-{
- ScmObj stack_start = NULL;
-#endif /* SCM_GCC4_READY_GC */
- ScmObj port = SCM_NULL;
- ScmObj s_expression = SCM_NULL;
- char *filepath = create_valid_path(filename);
-
#if !SCM_GCC4_READY_GC
+ ScmObj stack_start = NULL;
+#endif
+ ScmObj succeeded = SCM_FALSE;
+
+#if SCM_GCC4_READY_GC
+ SCM_GC_CALL_PROTECTED_FUNC(succeeded, SigScm_load_internal, (c_filename));
+#else
/* start protecting stack */
SigScm_GC_ProtectStack(&stack_start);
+
+ succeeded = SigScm_load_internal(c_filename);
+
+ /* now no need to protect stack */
+ SigScm_GC_UnprotectStack(&stack_start);
#endif
+ return succeeded;
+}
+
+static ScmObj SigScm_load_internal(const char *c_filename)
+{
+ ScmObj port = SCM_NULL;
+ ScmObj s_expression = SCM_NULL;
+ char *filepath = create_valid_path(c_filename);
+
/* sanity check */
/*
TODO : FIXME! Kazuki Ohta <mover at hct.zaq.ne.jp>
@@ -452,11 +468,6 @@
/* close port */
ScmOp_close_input_port(port);
-#if !SCM_GCC4_READY_GC
- /* now no need to protect stack */
- SigScm_GC_UnprotectStack(&stack_start);
-#endif
-
/* free str */
free(filepath);
@@ -506,7 +517,7 @@
ScmObj ScmOp_load(ScmObj filename)
{
char *c_filename = SCM_STRING_STR(filename);
- SigScm_load(c_filename);
+ SigScm_load_internal(c_filename);
#if SCM_STRICT_R5RS
return SCM_UNDEF;
@@ -517,30 +528,21 @@
}
#if SCM_USE_NONSTD_FEATURES
+/* FIXME: add ScmObj SigScm_require(const char *c_filename) */
+
/*
* TODO:
* - return the status which indicates succeeded or not
* - provide SIOD compatible behavior about return value when SCM_COMPAT_SIOD
* is true
*/
-#if SCM_GCC4_READY_GC
-SCM_DEFINE_GC_PROTECTED_FUNC1(, ScmObj, ScmOp_require, ScmObj, filename)
-{
-#else
ScmObj ScmOp_require(ScmObj filename)
{
- ScmObj stack_start = NULL;
-#endif /* SCM_GCC4_READY_GC */
ScmObj loaded_str = SCM_NULL;
if (!STRINGP(filename))
SigScm_ErrorObj("require : string required but got ", filename);
-#if !SCM_GCC4_READY_GC
- /* start protecting stack */
- SigScm_GC_ProtectStack(&stack_start);
-#endif
-
/* construct loaded_str */
loaded_str = create_loaded_str(filename);
@@ -552,11 +554,6 @@
SCM_SYMBOL_VCELL(SigScm_features) = CONS(loaded_str, SCM_SYMBOL_VCELL(SigScm_features));
}
-#if !SCM_GCC4_READY_GC
- /* now no need to protect stack */
- SigScm_GC_UnprotectStack(&stack_start);
-#endif
-
return SCM_TRUE;
}
Modified: branches/r5rs/sigscheme/main.c
===================================================================
--- branches/r5rs/sigscheme/main.c 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/sigscheme/main.c 2005-09-11 18:17:12 UTC (rev 1471)
@@ -53,16 +53,21 @@
/*=======================================
File Local Function Declarations
=======================================*/
+#if SCM_GCC4_READY_GC
+static SCM_GC_PROTECTED_FUNC_DECL(void , repl, (void));
+#else
+static void repl(void);
+#endif
+/*=======================================
+ Function Implementations
+=======================================*/
/* Very simple repl, please rewrite. */
-#if SCM_GCC4_READY_GC
-SCM_DEFINE_GC_PROTECTED_FUNC0(static, void *, repl)
-{
-#else
static void repl(void)
{
+#if !SCM_GCC4_READY_GC
ScmObj stack_start = NULL;
-#endif /* SCM_GCC4_READY_GC */
+#endif
ScmObj stdin_port = SCM_NULL;
ScmObj stdout_port = SCM_NULL;
ScmObj s_exp = SCM_NULL;
@@ -95,17 +100,12 @@
ScmOp_close_input_port(stdin_port);
ScmOp_close_input_port(stdout_port);
-#if SCM_GCC4_READY_GC
- return NULL;
-#else
+#if !SCM_GCC4_READY_GC
/* now no need to protect stack */
SigScm_GC_UnprotectStack(&stack_start);
#endif
}
-/*=======================================
- Function Implementations
-=======================================*/
int main(int argc, char **argv)
{
char *filename = argv[1];
@@ -113,10 +113,14 @@
SigScm_Initialize();
if (argc < 2) {
- repl();
- /* SigScm_Error("usage : sscm <filename>\n"); */
+#if SCM_GCC4_READY_GC
+ SCM_GC_CALL_PROTECTED_VOID_FUNC(repl, ());
+#else
+ repl();
+#endif
+ /* SigScm_Error("usage : sscm <filename>\n"); */
} else {
- SigScm_load(filename);
+ SigScm_load(filename);
}
SigScm_Finalize();
Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/sigscheme/sigscheme.c 2005-09-11 18:17:12 UTC (rev 1471)
@@ -56,6 +56,12 @@
/*=======================================
File Local Function Declarations
=======================================*/
+#if SCM_GCC4_READY_GC
+static SCM_GC_PROTECTED_FUNC_DECL(void, SigScm_Initialize_internal, (void));
+#else
+static void SigScm_Initialize_internal(void);
+#endif
+
static void Scm_RegisterFunc(const char *name, enum ScmFuncTypeCode type, ScmFuncType func);
ScmObj SigScm_null, SigScm_true, SigScm_false, SigScm_eof;
@@ -72,17 +78,21 @@
/*=======================================
Function Implementations
=======================================*/
+void SigScm_Initialize(void)
+{
#if SCM_GCC4_READY_GC
-SCM_DEFINE_GC_PROTECTED_FUNC0(, void *, SigScm_Initialize)
-{
+ SCM_GC_CALL_PROTECTED_VOID_FUNC(SigScm_Initialize_internal, ());
#else
-void SigScm_Initialize(void)
-{
ScmObj stack_start = NULL;
SigScm_GC_ProtectStack(&stack_start);
-#endif /* SCM_GCC4_READY_GC */
+ SigScm_Initialize_internal();
+ SigScm_GC_UnprotectStack(&stack_start);
+#endif
+}
+static void SigScm_Initialize_internal(void)
+{
/*=======================================================================
Etc Variable Initialization
=======================================================================*/
@@ -380,12 +390,6 @@
/* datas.c */
scm_return_value = SCM_NULL;
#endif
-
-#if SCM_GCC4_READY_GC
- return NULL;
-#else
- SigScm_GC_UnprotectStack(&stack_start);
-#endif
}
void SigScm_Finalize()
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-09-11 18:17:12 UTC (rev 1471)
@@ -128,100 +128,38 @@
SCM_SYMBOL_VCELL(Scm_Intern(sym))))
/*
- * Function Definition With Automatic Stack Protection
+ * Function Invocation With Stack Protection
*
- * Users should use SCM_DEFINE_GC_PROTECTED_FUNCn only.
+ * Users should only use SCM_GC_PROTECTED_FUNC_DECL(),
+ * SCM_GC_CALL_PROTECTED_FUNC() and SCM_GC_CALL_PROTECTED_VOID_FUNC().
*/
#if SCM_GCC4_READY_GC
-#define SCM_GC_PROTECTED_FUNC(func) SigScm_GC_ProtectedFunc_##func
+#define SCM_GC_PROTECTED_FUNC_T(func) SigScm_GC_ProtectedType__##func
-#define SCM_DECLARE_GC_PROTECTED_FUNC_BODY(ret_type, func, args) \
- ret_type SCM_GC_PROTECTED_FUNC(func) args SCM_NOINLINE;
+#define SCM_GC_PROTECTED_FUNC_DECL(ret_type, func, args) \
+ ret_type func args SCM_NOINLINE; \
+ typedef ret_type (*SCM_GC_PROTECTED_FUNC_T(func)) args
-#define SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, args) \
- ret_type \
- SCM_GC_PROTECTED_FUNC(func) args
+#define SCM_GC_CALL_PROTECTED_FUNC(ret, func, args) \
+ SCM_GC_CALL_PROTECTED_FUNC_INTERNAL(ret = , func, args)
-#define SCM_DEFINE_GC_PROTECTED_FUNC0(sclass, ret_type, func) \
- SCM_DECLARE_GC_PROTECTED_FUNC_BODY(ret_type, func, (void)) \
- sclass ret_type \
- func(void) \
- { \
- ScmGCFunc0 body = (ScmGCFunc0)SCM_GC_PROTECTED_FUNC(func); \
- SigScm_GC_CallProtectedFunc0(body); \
- return (ret_type)SigScm_GC_CallProtectedFunc0(body); \
- } \
- SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, (void))
+#define SCM_GC_CALL_PROTECTED_VOID_FUNC(func, args) \
+ SCM_GC_CALL_PROTECTED_FUNC_INTERNAL(, func, args)
-#define SCM_DEFINE_GC_PROTECTED_FUNC1(sclass, ret_type, func, \
- arg0_type, arg0) \
- SCM_DECLARE_GC_PROTECTED_FUNC_BODY(ret_type, func, (arg0_type arg0)) \
- sclass ret_type \
- func(arg0_type arg0) \
- { \
- ScmGCFunc1 body = (ScmGCFunc1)SCM_GC_PROTECTED_FUNC(func); \
- return (ret_type)SigScm_GC_CallProtectedFunc1(body, (void *)arg0); \
- } \
- SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, (arg0_type arg0))
+#define SCM_GC_CALL_PROTECTED_FUNC_INTERNAL(exp_ret, func, args) \
+ do { \
+ SCM_GC_PROTECTED_FUNC_T(func) fp; \
+ ScmObj *stack_start; \
+ \
+ stack_start = SigScm_GC_ProtectStack(); \
+ fp = (SCM_GC_PROTECTED_FUNC_T(func)) \
+ SigScm_GC_EnsureUninlinedFunc((ScmCFunc)&func); \
+ exp_ret (*fp)args; \
+ SigScm_GC_UnprotectStack(stack_start); \
+ \
+ } while (/* CONSTCOND */ 0)
-#define SCM_DEFINE_GC_PROTECTED_FUNC2(sclass, ret_type, func, \
- arg0_type, arg0, arg1_type, arg1) \
- sclass ret_type \
- func(arg0_type arg0, arg1_type arg1) \
- { \
- ScmGCFunc2 body = (ScmGCFunc2)SCM_GC_PROTECTED_FUNC(func); \
- return (ret_type)SigScm_GC_CallProtectedFunc2(body, arg0, arg1); \
- } \
- SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, (arg0_type arg0, \
- arg1_type arg1))
-
-#define SCM_DEFINE_GC_PROTECTED_FUNC3(sclass, ret_type, func, \
- arg0_type, arg0, arg1_type, arg1, \
- arg2_type, arg2) \
- sclass ret_type \
- func(arg0_type arg0, arg1_type arg1, arg2_type arg2) \
- { \
- ScmGCFunc3 body = (ScmGCFunc3)SCM_GC_PROTECTED_FUNC(func); \
- return (ret_type)SigScm_GC_CallProtectedFunc3(body, arg0, arg1, \
- arg2); \
- } \
- SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, (arg0_type arg0, \
- arg1_type arg1, \
- arg2_type arg2))
-
-#define SCM_DEFINE_GC_PROTECTED_FUNC4(sclass, ret_type, func, \
- arg0_type, arg0, arg1_type, arg1, \
- arg2_type, arg2, arg3_type, arg3) \
- sclass ret_type \
- func(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3) \
- { \
- ScmGCFunc4 body = (ScmGCFunc4)SCM_GC_PROTECTED_FUNC(func); \
- return (ret_type)SigScm_GC_CallProtectedFunc4(body, arg0, arg1, \
- arg2, arg3); \
- } \
- SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, (arg0_type arg0, \
- arg1_type arg1, \
- arg2_type arg2, \
- arg3_type arg3))
-
-#define SCM_DEFINE_GC_PROTECTED_FUNC5(sclass, ret_type, func, \
- arg0_type, arg0, arg1_type, arg1, \
- arg2_type, arg2, arg3_type, arg3, \
- arg4_type, arg4) \
- sclass ret_type \
- func(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, \
- arg4_type arg4) \
- { \
- ScmGCFunc5 body = (ScmGCFunc5)SCM_GC_PROTECTED_FUNC(func); \
- return (ret_type)SigScm_GC_CallProtectedFunc5(body, arg0, arg1, \
- arg2, arg3, arg4); \
- } \
- SCM_DEFINE_GC_PROTECTED_FUNC_BODY(ret_type, func, (arg0_type arg0, \
- arg1_type arg1, \
- arg2_type arg2, \
- arg3_type arg3, \
- arg4_type arg4))
#endif /* SCM_GCC4_READY_GC */
/*=======================================
@@ -231,11 +169,7 @@
SigScheme : Core Functions
===========================================================================*/
/* sigscheme.c */
-#if SCM_GCC4_READY_GC
-void *SigScm_Initialize(void);
-#else
void SigScm_Initialize(void);
-#endif
void SigScm_Finalize(void);
void Scm_RegisterFunc0(const char *name, ScmFuncType0 func);
void Scm_RegisterFunc1(const char *name, ScmFuncType1 func);
@@ -283,23 +217,12 @@
/* storage-protection.c */
#if SCM_GCC4_READY_GC
/*
- * Ordinary programs does not need calling these functions directly. Use
- * SCM_DEFINE_GC_PROTECTED_FUNCn() instead.
+ * Ordinary programs should not call these functions directly. Use
+ * SCM_GC_CALL_PROTECTED_*FUNC() instead.
*/
-void *SigScm_GC_CallProtectedFunc0(ScmGCFunc0 func) SCM_NOINLINE;
-void *SigScm_GC_CallProtectedFunc1(ScmGCFunc1 func,
- void *arg0) SCM_NOINLINE;
-void *SigScm_GC_CallProtectedFunc2(ScmGCFunc2 func,
- void *arg0, void *arg1) SCM_NOINLINE;
-void *SigScm_GC_CallProtectedFunc3(ScmGCFunc3 func,
- void *arg0, void *arg1,
- void *arg2) SCM_NOINLINE;
-void *SigScm_GC_CallProtectedFunc4(ScmGCFunc4 func,
- void *arg0, void *arg1,
- void *arg2, void *arg3) SCM_NOINLINE;
-void *SigScm_GC_CallProtectedFunc5(ScmGCFunc5 func,
- void *arg0, void *arg1, void *arg2,
- void *arg3, void *arg4) SCM_NOINLINE;
+ScmObj *SigScm_GC_ProtectStack(void) SCM_NOINLINE;
+void SigScm_GC_UnprotectStack(ScmObj *stack_start) SCM_NOINLINE;
+ScmCFunc SigScm_GC_EnsureUninlinedFunc(ScmCFunc func) SCM_NOINLINE;
#endif /* SCM_GCC4_READY_GC */
/* eval.c */
@@ -479,6 +402,7 @@
ScmObj SigScm_load(const char *c_filename);
ScmObj ScmOp_load(ScmObj filename);
#if SCM_USE_NONSTD_FEATURES
+/* FIXME: add ScmObj SigScm_require(const char *c_filename); */
ScmObj ScmOp_require(ScmObj filename);
ScmObj ScmOp_provide(ScmObj feature);
ScmObj ScmOp_providedp(ScmObj feature);
Modified: branches/r5rs/sigscheme/storage-protection.c
===================================================================
--- branches/r5rs/sigscheme/storage-protection.c 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/sigscheme/storage-protection.c 2005-09-11 18:17:12 UTC (rev 1471)
@@ -32,6 +32,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* =========================================================================*/
+/* CAUTION: following description is obsoleted. It will be rewritten soon. */
+
/*
* **** THE FUNCTIONS OF THIS FILE MUST NOT BE INLINED INTO CALLER ****
*
@@ -189,8 +191,6 @@
* -- YamaKen 2005-09-07
*/
-#if SCM_GCC4_READY_GC
-
/*=======================================
System Include
=======================================*/
@@ -208,17 +208,6 @@
/*=======================================
File Local Macro Declarations
=======================================*/
-#define SCM_GC_CALL_PROTECTED_FUNC(func_invocation) \
- do { \
- void *ret = NULL; \
- ScmObj *stack_start; \
- \
- stack_start = gc_protect_stack(); \
- ret = (func_invocation); \
- gc_unprotect_stack(stack_start); \
- \
- return ret; \
- } while (/* CONSTCOND */ 0)
/*=======================================
Variable Declarations
@@ -227,8 +216,6 @@
/*=======================================
File Local Function Declarations
=======================================*/
-static ScmObj *gc_protect_stack(void);
-static void gc_unprotect_stack(ScmObj *stack_start);
/*=======================================
Extern Function Declarations
@@ -237,7 +224,8 @@
/*=======================================
Function Implementations
=======================================*/
-static ScmObj *gc_protect_stack(void)
+#if SCM_GCC4_READY_GC
+ScmObj *SigScm_GC_ProtectStack(void)
{
ScmObj stack_start = NULL;
@@ -248,43 +236,14 @@
return &stack_start;
}
-static void gc_unprotect_stack(ScmObj *stack_start)
+void SigScm_GC_UnprotectStack(ScmObj *stack_start)
{
if (scm_stack_start_pointer == stack_start)
scm_stack_start_pointer = NULL;
}
-void *SigScm_GC_CallProtectedFunc0(ScmGCFunc0 func)
+ScmCFunc SigScm_GC_EnsureUninlinedFunc(ScmCFunc func)
{
- SCM_GC_CALL_PROTECTED_FUNC(func());
+ return func;
}
-
-void *SigScm_GC_CallProtectedFunc1(ScmGCFunc1 func, void *arg0)
-{
- SCM_GC_CALL_PROTECTED_FUNC(func(arg0));
-}
-
-void *SigScm_GC_CallProtectedFunc2(ScmGCFunc2 func, void *arg0, void *arg1)
-{
- SCM_GC_CALL_PROTECTED_FUNC(func(arg0, arg1));
-}
-
-void *SigScm_GC_CallProtectedFunc3(ScmGCFunc3 func, void *arg0, void *arg1,
- void *arg2)
-{
- SCM_GC_CALL_PROTECTED_FUNC(func(arg0, arg1, arg2));
-}
-
-void *SigScm_GC_CallProtectedFunc4(ScmGCFunc4 func, void *arg0, void *arg1,
- void *arg2, void *arg3)
-{
- SCM_GC_CALL_PROTECTED_FUNC(func(arg0, arg1, arg2, arg3));
-}
-
-void *SigScm_GC_CallProtectedFunc5(ScmGCFunc5 func, void *arg0, void *arg1,
- void *arg2, void *arg3, void *arg4)
-{
- SCM_GC_CALL_PROTECTED_FUNC(func(arg0, arg1, arg2, arg3, arg4));
-}
-
#endif /* SCM_GCC4_READY_GC */
Modified: branches/r5rs/uim/uim-scm.c
===================================================================
--- branches/r5rs/uim/uim-scm.c 2005-09-11 15:27:01 UTC (rev 1470)
+++ branches/r5rs/uim/uim-scm.c 2005-09-11 18:17:12 UTC (rev 1471)
@@ -457,12 +457,19 @@
uim_bool
uim_scm_require_file(const char *fn)
{
+ uim_lisp stack_start;
+
if (!fn)
return UIM_FALSE;
+ /*
+ * FIXME: Replace with SigScm_require() which contains the stack protection
+ */
+ uim_scm_gc_protect_stack(&stack_start);
ScmOp_require(Scm_NewStringCopying(fn));
+ uim_scm_gc_unprotect_stack(&stack_start);
- /* TODO: fixme */
+ /* FIXME */
return UIM_TRUE;
}
More information about the uim-commit
mailing list