At 22:58 on 10/23/2002 EDT, Erik Lechak <[EMAIL PROTECTED]> wrote:

> I fix the errors then It gets all wierd on the def PARROT_STACK_DIR.  So 
> I tried to figure out that problem.
> 
> Anyways, I am on Win XP using VC++.  I look in Config.pm and I see this 
> '#define PARROT_STACK_DIR'.  It's not defined to anything, but the code 
> tries to do math with it.  What is this?

It's supposed to be either 1 or -1, determined at build time via config/
auto/stackdir.pl.

Evidently, that didn't work right.

I've got a patch which switches this detection to happen at run-time 
instead of at build-time.   This is going to be necessary for miniparrot 
(which has no "Configure" step) anyway.

Can you try applying this patch and see if it addresses your issue?

With the current state of the tinderbox, i'd rather not commit it just yet.

--Josh


Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.239
diff -u -r1.239 MANIFEST
--- MANIFEST	23 Oct 2002 05:33:39 -0000	1.239
+++ MANIFEST	24 Oct 2002 03:19:15 -0000
@@ -58,10 +58,6 @@
 config/auto/pack.pl
 config/auto/sizes.pl
 config/auto/sizes/test_c.in
-config/auto/stackdir.pl
-config/auto/stackdir/test0_c.in
-config/auto/stackdir/test1_c.in
-config/auto/stackdir/test2_c.in
 config/gen/config_h.pl
 config/gen/config_h/config_h.in
 config/gen/config_pm.pl
Index: dod.c
===================================================================
RCS file: /cvs/public/parrot/dod.c,v
retrieving revision 1.24
diff -u -r1.24 dod.c
--- dod.c	23 Oct 2002 05:27:01 -0000	1.24
+++ dod.c	24 Oct 2002 03:19:17 -0000
@@ -21,6 +21,17 @@
 
 static size_t find_common_mask(size_t val1, size_t val2);
 
+static int PARROT_STACK_DIR;
+
+void
+dod_init(void)
+{
+    int local_variable = 1;
+   
+    PARROT_STACK_DIR = probe_stack_direction(&local_variable);
+}
+
+
 PMC *
 mark_used(PMC *used_pmc, PMC *current_end_of_list)
 {
@@ -478,7 +489,7 @@
         return last;
     
     for (cur_var_ptr = lo_var_ptr;
-        (ptrdiff_t)(cur_var_ptr * PARROT_STACK_DIR) < 
+        (ptrdiff_t)(cur_var_ptr * PARROT_STACK_DIR) <
             (ptrdiff_t)(hi_var_ptr * PARROT_STACK_DIR);
         cur_var_ptr = (size_t)( (ptrdiff_t)cur_var_ptr + 
             PARROT_STACK_DIR * PARROT_PTR_ALIGNMENT )
Index: global_setup.c
===================================================================
RCS file: /cvs/public/parrot/global_setup.c,v
retrieving revision 1.36
diff -u -r1.36 global_setup.c
--- global_setup.c	5 Sep 2002 17:56:58 -0000	1.36
+++ global_setup.c	24 Oct 2002 03:19:17 -0000
@@ -22,8 +22,13 @@
 init_world(void)
 {
     PMC* key;
-    string_init();              /* Set up the string subsystem */
-
+   
+    /* Set up the string subsystem */
+    string_init();
+  
+    /* set up the dod subsystem */
+    dod_init();                
+   
     /* Call base vtable class constructor methods */
     Parrot_initialize_core_pmcs();
 
Index: config/gen/config_h/config_h.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/config_h/config_h.in,v
retrieving revision 1.9
diff -u -r1.9 config_h.in
--- config/gen/config_h/config_h.in	11 Oct 2002 01:46:37 -0000	1.9
+++ config/gen/config_h/config_h.in	24 Oct 2002 03:19:19 -0000
@@ -42,7 +42,6 @@
 #define PARROT_BYTEORDER        ${byteorder}
 #define PARROT_BIGENDIAN        ${bigendian}
 #define PARROT_PTR_ALIGNMENT    ${ptr_alignment}
-#define PARROT_STACK_DIR        ${stackdir}
 
 typedef Parrot_Int INTVAL;
 typedef Parrot_UInt UINTVAL;
Index: config/gen/makefiles/root.in
===================================================================
RCS file: /cvs/public/parrot/config/gen/makefiles/root.in,v
retrieving revision 1.46
diff -u -r1.46 root.in
--- config/gen/makefiles/root.in	21 Oct 2002 08:47:06 -0000	1.46
+++ config/gen/makefiles/root.in	24 Oct 2002 03:19:20 -0000
@@ -74,7 +74,7 @@
 $(INC)/interp_guts.h $(INC)/rx.h $(INC)/rxstacks.h $(INC)/intlist.h \
 $(INC)/embed.h $(INC)/warnings.h $(INC)/misc.h $(INC)/pmc.h \
 $(INC)/key.h $(INC)/hash.h $(INC)/smallobject.h $(INC)/headers.h $(INC)/dod.h \
-$(INC)/method_util.h $(INC)/list.h
+$(INC)/method_util.h $(INC)/list.h $(INC)/stackdir.h
 
 ALL_H_FILES = $(GENERAL_H_FILES)
 
@@ -100,7 +100,7 @@
 	 embed$(O) warnings$(O)  ${cg_o} \
 	 packout$(O) byteorder$(O) debug$(O) smallobject$(O) \
 	 headers$(O) dod$(O) method_util$(O) \
-	 misc$(O) spf_render$(O) spf_vtable$(O)
+	 misc$(O) spf_render$(O) spf_vtable$(O) stackdir$(O)
 
 O_FILES = $(INTERP_O_FILES) \
 	      $(IO_O_FILES) \
@@ -323,6 +323,8 @@
 ###############################################################################
 
 global_setup$(O) : $(GENERAL_H_FILES)
+
+stackdir$(O) : $(GENERAL_H_FILES)
 
 pmc$(O) : $(GENERAL_H_FILES)
 
Index: include/parrot/dod.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/dod.h,v
retrieving revision 1.4
diff -u -r1.4 dod.h
--- include/parrot/dod.h	21 Oct 2002 08:47:14 -0000	1.4
+++ include/parrot/dod.h	24 Oct 2002 03:19:24 -0000
@@ -17,6 +17,8 @@
 
 #include "parrot/parrot.h"
 
+void dod_init(void);
+
 void Parrot_do_dod_run(struct Parrot_Interp *);
 PMC *trace_system_stack(struct Parrot_Interp *, PMC *);
 
Index: include/parrot/parrot.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/parrot.h,v
retrieving revision 1.52
diff -u -r1.52 parrot.h
--- include/parrot/parrot.h	21 Oct 2002 08:47:14 -0000	1.52
+++ include/parrot/parrot.h	24 Oct 2002 03:19:24 -0000
@@ -201,6 +201,7 @@
 #include "parrot/debug.h"
 #include "parrot/sub.h"
 #include "parrot/key.h"
+#include "parrot/stackdir.h"
 #endif
 
 /*
Index: lib/Parrot/Configure/RunSteps.pm
===================================================================
RCS file: /cvs/public/parrot/lib/Parrot/Configure/RunSteps.pm,v
retrieving revision 1.13
diff -u -r1.13 RunSteps.pm
--- lib/Parrot/Configure/RunSteps.pm	23 Oct 2002 05:33:40 -0000	1.13
+++ lib/Parrot/Configure/RunSteps.pm	24 Oct 2002 03:19:26 -0000
@@ -19,7 +19,6 @@
 	auto/alignptrs.pl
 	auto/headers.pl
 	auto/sizes.pl
-	auto/stackdir.pl
 	auto/byteorder.pl
 	auto/pack.pl
 	auto/format.pl
--- /dev/null	2002-10-13 16:37:32.000000000 -0400
+++ include/parrot/stackdir.h	2002-10-23 23:11:41.000000000 -0400
@@ -0,0 +1,30 @@
+/* misc.h
+ *  Copyright: (When this is determined...it will go here)
+ *  CVS Info
+ *     $Id$
+ *  Overview:
+ *     This function is used to probe the direction of stack growth 
+ *     at run-time.   This is particularly useful when building a miniparrot,
+ *     where it is not possible to do compile-time probing.
+ */
+
+#if !defined(PARROT_STACKDIR_H_GUARD)
+#define PARROT_STACKDIR_H_GUARD
+
+#  ifdef PARROT_IN_CORE
+
+int probe_stack_direction(int *parent_local_variable);
+
+#  endif
+
+#endif
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
--- /dev/null   2002-10-13 16:37:32.000000000 -0400
+++ stackdir.c  2002-10-23 23:11:26.000000000 -0400
@@ -0,0 +1,44 @@
+/* stackdir.c
+ *  Copyright: (When this is determined...it will go here)
+ *  CVS Info
+ *     $Id$
+ *  Overview:
+ *     This function is used to probe the direction of stack growth 
+ *     at run-time.   This is particularly useful when building a miniparrot,
+ *     where it is not possible to do compile-time probing.
+ *  Data Structure and Algorithms:
+ *    The defined function is passed a pointer to an integer on the calling
+ *    function's stack, and checks for the difference in that pointer to 
+ *    one of its own.
+ * 
+ *    NOTE: It is vital that this function not be called from within the
+ *          same object file as it is defined.   If it is, the compiler
+ *          could choose to in-line it, removing the function call which
+ *          we depend upon.   That is the reason for this separate .c file.
+ *    
+ *  History:
+ *     This is derived from the compile-time probes in config/auto/stackdir
+ */
+
+#include <parrot/parrot.h>
+
+int
+probe_stack_direction(int *parent_local_variable) {
+   int stack_bottom = 1;
+   
+   if ((parent_local_variable - &stack_bottom) > 0)
+     return -1;
+   else 
+     return 1;
+}
+
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+*/

Reply via email to