Author: yamakenz
Date: Tue Jul 17 22:06:24 2007
New Revision: 4734

Modified:
   sigscheme-trunk/QALog
   sigscheme-trunk/src/gcroots/gcroots.c
   sigscheme-trunk/src/gcroots/gcroots.h

Log:
* src/gcroots/gcroots.h
  - (GCROOTS_VERSION_MINOR, GCROOTS_VERSION_PATCHLEVEL, GCROOTS_API_REVISION):
    Update to libgcroots 0.2.0
  - (GCROOTS_is_protected_context, GCROOTS_is_protected): New function decl
* src/gcroots/gcroots.c
  - (l_findee, l_found): New static variables
  - (GCROOTS_init): Add static variables initialization
  - (GCROOTS_is_protected_context, GCROOTS_is_protected): New function
  - (find_obj): New static function
* QALog
  - Update


Modified: sigscheme-trunk/QALog
==============================================================================
--- sigscheme-trunk/QALog       (original)
+++ sigscheme-trunk/QALog       Tue Jul 17 22:06:24 2007
@@ -597,23 +597,23 @@
 
 file:              gcroots.h
 category:          core
-spec by eyes:      [EMAIL PROTECTED]
+spec by eyes:      [EMAIL PROTECTED], [EMAIL PROTECTED]
 spec by tests:     
-general review:    [EMAIL PROTECTED]
-64-bit by eyes:    [EMAIL PROTECTED]
+general review:    [EMAIL PROTECTED], [EMAIL PROTECTED]
+64-bit by eyes:    [EMAIL PROTECTED], [EMAIL PROTECTED]
 64-bit by tests:   
-coding style:      [EMAIL PROTECTED]
+coding style:      [EMAIL PROTECTED], [EMAIL PROTECTED]
 normal case tests: [EMAIL PROTECTED]
 corner case tests: 
 
 file:              gcroots.c
 category:          core
-spec by eyes:      [EMAIL PROTECTED]
+spec by eyes:      [EMAIL PROTECTED], [EMAIL PROTECTED]
 spec by tests:     
-general review:    [EMAIL PROTECTED]
-64-bit by eyes:    [EMAIL PROTECTED]
+general review:    [EMAIL PROTECTED], [EMAIL PROTECTED]
+64-bit by eyes:    [EMAIL PROTECTED], [EMAIL PROTECTED]
 64-bit by tests:   
-coding style:      [EMAIL PROTECTED]
+coding style:      [EMAIL PROTECTED], [EMAIL PROTECTED]
 normal case tests: [EMAIL PROTECTED]
 corner case tests: 
 
@@ -1093,6 +1093,11 @@
 
 Log
 ---
+2007-07-18  YamaKen <yamaken AT bp.iij4u.or.jp>
+        * gcroots.h
+        * gcroots.c
+          - QA done again @r4734
+
 2007-07-13  YamaKen <yamaken AT bp.iij4u.or.jp>
         * module-srfi55.c
         * srfi-55.scm

Modified: sigscheme-trunk/src/gcroots/gcroots.c
==============================================================================
--- sigscheme-trunk/src/gcroots/gcroots.c       (original)
+++ sigscheme-trunk/src/gcroots/gcroots.c       Tue Jul 17 22:06:24 2007
@@ -60,11 +60,21 @@
 /*=======================================
   Variable Definitions
 =======================================*/
+SCM_GLOBAL_VARS_BEGIN(static_gcroots);
+#define static
+static void *l_findee;
+static int l_found;
+#undef static
+SCM_GLOBAL_VARS_END(static_gcroots);
+#define l_findee SCM_GLOBAL_VAR(static_gcroots, l_findee)
+#define l_found  SCM_GLOBAL_VAR(static_gcroots, l_found)
+SCM_DEFINE_STATIC_VARS(static_gcroots);
 
 /*=======================================
   File Local Function Declarations
 =======================================*/
 static void mark_internal(GCROOTS_context *ctx);
+static void find_obj(void *start, void *end, int is_certain, int is_aligned);
 
 /*=======================================
   Function Definitions
@@ -80,6 +90,8 @@
     /* scan_entire_system_stack is not supported by this implementation */
     SCM_ASSERT(!scan_entire_system_stack);
 
+    SCM_GLOBAL_VARS_INIT(static_gcroots);
+
     ctx = (*allocator)(sizeof(GCROOTS_context));
     if (ctx) {
         ctx->mark = marker;
@@ -150,4 +162,51 @@
     void *stack_top; /* approx */
 
     (*ctx->mark)(ctx->stack_base, &stack_top, scm_false, scm_false);
+}
+
+int
+GCROOTS_is_protected_context(GCROOTS_context *ctx)
+{
+    assert(ctx);
+
+    return (ctx->stack_base) ? scm_true : scm_false;
+}
+
+int
+GCROOTS_is_protected(GCROOTS_context *ctx, void *obj)
+{
+    GCROOTS_context tmp_ctx;
+
+    assert(ctx);
+
+    if (!GCROOTS_is_protected_context(ctx))
+      return scm_false;
+
+    tmp_ctx = *ctx;
+    tmp_ctx.mark = find_obj; /* not actually a mark function */
+    l_findee = obj;
+    l_found = scm_false;
+    GCROOTS_mark(&tmp_ctx);
+
+    return l_found;
+}
+
+static void
+find_obj(void *start, void *end, int is_certain, int is_aligned)
+{
+    void **p;
+    int offset;
+
+    offset = 0;
+    do {
+        for (p = (void **)start + offset; p < (void **)end; p++) {
+            if (*p == l_findee) {
+                l_found = scm_true;
+                return;
+            }
+        }
+        offset += ALIGNOF_VOID_P;
+    } while (!is_aligned
+             && SIZEOF_VOID_P != ALIGNOF_VOID_P
+             && offset % SIZEOF_VOID_P);
 }

Modified: sigscheme-trunk/src/gcroots/gcroots.h
==============================================================================
--- sigscheme-trunk/src/gcroots/gcroots.h       (original)
+++ sigscheme-trunk/src/gcroots/gcroots.h       Tue Jul 17 22:06:24 2007
@@ -44,9 +44,9 @@
 #endif
 
 #define GCROOTS_VERSION_MAJOR      (0)
-#define GCROOTS_VERSION_MINOR      (1)
-#define GCROOTS_VERSION_PATCHLEVEL (1)
-#define GCROOTS_API_REVISION       (0)
+#define GCROOTS_VERSION_MINOR      (2)
+#define GCROOTS_VERSION_PATCHLEVEL (0)
+#define GCROOTS_API_REVISION       (1)
 
 #define GCROOTS_VERSION_REQUIRE(major, minor, patchlevel)                    \
   ((major) < GCROOTS_VERSION_MAJOR                                           \
@@ -54,6 +54,7 @@
    || ((major) == GCROOTS_VERSION_MAJOR && (minor) == GCROOTS_VERSION_MINOR  \
        && (patchlevel) <= GCROOTS_VERSION_PATCHLEVEL))
 
+
 typedef struct _GCROOTS_context GCROOTS_context;
 
 typedef void (*GCROOTS_mark_proc)(void *start, void *end,
@@ -61,7 +62,7 @@
 typedef void *(*GCROOTS_user_proc)(void *arg);
 typedef void *(*GCROOTS_context_alloc_proc)(size_t ctx_size);
 
-
+/* may return NULL */
 SCM_EXPORT GCROOTS_context *GCROOTS_init(GCROOTS_context_alloc_proc allocator,
                                          GCROOTS_mark_proc marker,
                                          int scan_entire_system_stack);
@@ -72,6 +73,8 @@
                                                   void *arg);
 SCM_EXPORT void GCROOTS_mark(GCROOTS_context *ctx);
 
+SCM_EXPORT int GCROOTS_is_protected_context(GCROOTS_context *ctx);
+SCM_EXPORT int GCROOTS_is_protected(GCROOTS_context *ctx, void *obj);
 
 #ifdef __cplusplus
 }

Reply via email to