[MLton-commit] r4681

Stephen Weeks MLton@mlton.org
Thu, 13 Jul 2006 12:19:18 -0700


Fixed a bug in the include files for the C codegen.  There was a
mismatch in the type of returnToC in c-main.h, which had it as bool,
and c-chunk.h, which had it as int.  I made it an int and moved an
extern declaration into c-common.h to avoid this problem in the
future.

This bug caused a segfault on Solaris when attempting to call from C
to SML -- the trampoline never saw that returnToC had been set to
TRUE (presumably due to the type mismatch), and continued to run
forever.


----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
U   mlton/branches/on-20050822-x86_64-branch/include/c-common.h
U   mlton/branches/on-20050822-x86_64-branch/include/c-main.h

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h	2006-07-12 02:06:00 UTC (rev 4680)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-chunk.h	2006-07-13 19:19:16 UTC (rev 4681)
@@ -27,11 +27,6 @@
 #define DEBUG_CCODEGEN FALSE
 #endif
 
-extern struct cont (*nextChunks []) (void);
-extern int nextFun;
-extern int returnToC;
-extern struct GC_state gcState;
-
 #define GCState ((Pointer)&gcState)
 #define ExnStack *(Word32*)(GCState + ExnStackOffset)
 #define FrontierMem *(Pointer*)(GCState + FrontierOffset)

Modified: mlton/branches/on-20050822-x86_64-branch/include/c-common.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-common.h	2006-07-12 02:06:00 UTC (rev 4680)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-common.h	2006-07-13 19:19:16 UTC (rev 4681)
@@ -17,6 +17,11 @@
         void *nextChunk;
 };
 
+extern int nextFun;
+extern int returnToC;
+extern struct cont (*nextChunks []) (void);
+extern struct GC_state gcState;
+
 #define ChunkName(n) Chunk ## n
 
 #define DeclareChunk(n)                         \

Modified: mlton/branches/on-20050822-x86_64-branch/include/c-main.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/include/c-main.h	2006-07-12 02:06:00 UTC (rev 4680)
+++ mlton/branches/on-20050822-x86_64-branch/include/c-main.h	2006-07-13 19:19:16 UTC (rev 4681)
@@ -19,7 +19,7 @@
 #define Main(al, mg, mfs, mmc, pk, ps, mc, ml)                          \
 /* Globals */                                                           \
 int nextFun;                                                            \
-bool returnToC;                                                         \
+int returnToC;                                                          \
 void MLton_callFromC () {                                               \
         struct cont cont;                                               \
         GC_state s;                                                     \