id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,lang,patch,platform
648,[PATCH] src/gc/system.c compile on HPUX,rrauenza,Infinoid,"I'm not sure what to do with this code -- it looked incomplete to begin with -- why is getcontext() called and nothing done with it?  And how do I test it?

Anyway, it wouldn't compile on HPUX and I realized the \_\_ia64\_\_ section must be for a linux on ia64 compile.  So I reimplemented the code using inline assembly (I was also getting an undefined symbol for the flush_reg_store() function supposedly implemented in assembly somewhere else) and a more robust way of getting the bottom of the rsestack.  

I also added couple of headers to gc_private.h for the pstat call and the inline assembly.

The inline assembly won't work under gcc.   HP C defines \_\_HP\_cc if we want to have a separate gcc implementation.  (I had to escape the underscores here!)


{{{
Index: src/gc/system.c
===================================================================
--- src/gc/system.c     (revision 38492)
+++ src/gc/system.c     (working copy)
@@ -93,6 +93,34 @@
 
 #elif defined(__ia64__)
 
+
+#if defined(__hpux)
+       /* This is untested, but should be functionally equivalent to the ia64 
+          code below, which must be IA64 Linux code?  It did not compile on HPUX. */
+        ucontext_t ucp;
+        void *current_regstore_top;
+
+        getcontext(&ucp);
+        _Asm_flushrs();
+
+#if defined(_LP64)
+        current_regstore_top = (void*)(uint64_t)_Asm_mov_from_ar(_AREG_BSP);
+#else
+        current_regstore_top = (void*)(uint32_t)_Asm_mov_from_ar(_AREG_BSP);
+#endif
+
+        size_t base = 0;
+        struct pst_vm_status buf;
+        int i = 0;
+
+        while(pstat_getprocvm (&buf, sizeof(buf), 0, i++) == 1) {
+           if (buf.pst_type == PS_RSESTACK) {
+              base = (size_t)buf.pst_vaddr;
+              break;
+           }
+        }
+
+#else /* is this code for ia64 linux?  This doesn't seem portable.  Is this better? http://www.mail-archive.com/guile-devel@gnu.org/msg01299.html */
         /* On IA64 systems, we use the function getcontext() to get the current
            processor context. This function is located in <ucontext.h>, included
            above. */
@@ -110,8 +138,13 @@
            is separate from the normal system stack. The register backing
            stack starts at memory address 0x80000FFF80000000 and ends at
            current_regstore_top. */
-        trace_mem_block(interp, 0x80000fff80000000,
+        size_t base = 0x80000fff80000000;
+
+#endif
+
+        trace_mem_block(interp, base, 
                 (size_t)current_regstore_top);
+
 #else
 
 #  ifdef PARROT_HAS_HEADER_SETJMP
Index: src/gc/gc_private.h
===================================================================
--- src/gc/gc_private.h (revision 38492)
+++ src/gc/gc_private.h (working copy)
@@ -29,8 +29,13 @@
 extern void *flush_reg_store(void);
 #  define BACKING_STORE_BASE 0x80000fff80000000
 
+#ifdef __hpux
+#include <sys/pstat.h>
+#include <ia64/sys/inline.h>
 #endif
 
+#endif
+
 /* We're using this here to add an additional pointer to a PObj without
    having to actually add an entire pointer to every PObj-alike structure
    in Parrot. Astute observers may notice that if the PObj is comprised of
}}}

",bug,closed,normal,,none,1.1.0,medium,fixed,,,,applied,
