]> git.pond.sub.org Git - empserver/commitdiff
(lwpSave, lwpReschedule) [hpc]: Move machine-dependent code to arch.c,
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 5 Dec 2005 21:38:03 +0000 (21:38 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 5 Dec 2005 21:38:03 +0000 (21:38 +0000)
where it belongs.  Code looks fishy.  Untested.
(initcontext, startpoint): Internal linkage.

src/lib/lwp/arch.c
src/lib/lwp/lwp.c
src/lib/lwp/lwpint.h

index ad0fdc919407ce1972f6cae67e2e8b3e1da1a0e4..c4e2ea485279a1d376b9d93718406624cf5850ba 100644 (file)
@@ -70,8 +70,8 @@ lwpInitContext(struct lwpProc *newp, stack_t *spp)
 #elif defined(hpc)
 
 static struct lwpProc *tempcontext;
-struct lwpProc *initcontext = NULL;
-int startpoint;
+static struct lwpProc *initcontext = NULL;
+static int startpoint;
 
 static void
 startcontext(void)
@@ -117,6 +117,25 @@ lwpInitContext(struct lwpProc *newp, void *sp)
     }
 }
 
+int
+lwpSave(jmp_buf jb)
+{
+    int endpoint;
+
+    endpoint = &endpoint;
+    if (initcontext == NULL || endpoint < startpoint)
+       return setjmp(jb, 1);
+
+    LwpCurrent->size = endpoint - startpoint;
+    LwpCurrent->sbtm = realloc(LwpCurrent->sbtm, LwpCurrent->size);
+    memcpy(LwpCurrent->sbtm, startpoint, LwpCurrent->size);
+    if (setjmp(jb, 1)) {
+       memcpy(startpoint, LwpCurrent->sbtm, LwpCurrent->size);
+       return 1;
+    }
+    return 0;
+}
+
 #elif defined(hpux)
 
 void
index 9136cda48a3e03d6c202e3220d1d3bdf95ca7726..19f611b6238b9f675175dc1f9b0fb4f14519f9ac 100644 (file)
@@ -129,26 +129,7 @@ lwpReschedule(void)
     BOUNDS_CHECKING_OFF;
 #endif
 
-#if defined(hpc)
-    {
-       int endpoint;
-
-       endpoint = &endpoint;
-       if (initcontext == NULL || endpoint < startpoint) {
-           i = lwpSave(LwpCurrent->context);
-       } else {
-           LwpCurrent->size = endpoint - startpoint;
-           LwpCurrent->sbtm = realloc(LwpCurrent->sbtm, LwpCurrent->size);
-           memcpy(LwpCurrent->sbtm, startpoint, LwpCurrent->size);
-           if (i = lwpSave(LwpCurrent->context)) {
-               memcpy(startpoint, LwpCurrent->sbtm, LwpCurrent->size);
-               i = 1;
-           }
-       }
-    }
-#else
     i = lwpSave(LwpCurrent->context);
-#endif
 #ifdef BOUNDS_CHECK
     BOUNDS_CHECKING_ON;
 #endif
index da253dd9004b3b17c4e6294df4a9ef292a794671..4e3e64cdcc943ef4ca23f88ef1f84d15de251828 100644 (file)
@@ -39,7 +39,10 @@ void lwpInitContext(volatile struct lwpProc * volatile, void *);
 #else
 void lwpInitContext(struct lwpProc *, void *);
 #endif
-#if (defined(hpux) && !defined(hpc)) || defined(AIX32) || defined(ALPHA)
+#if defined(hpc)
+int lwpSave(jmp_buf);
+#define lwpRestore(x)  longjmp(x, 1)
+#elif defined(hpux) || defined(AIX32) || defined(ALPHA)
 int lwpSave(jmp_buf);
 void lwpRestore(jmp_buf);
 #elif defined(SUN4)
@@ -51,11 +54,6 @@ void lwpRestore(jmp_buf);
 #endif
 #endif /* !UCONTEXT */
 
-#ifdef hpc
-extern struct lwpProc *initcontext;
-extern int startpoint;
-#endif
-
 #ifdef AIX32
 /* AIX needs 12 extra bytes above the stack; we add it here */
 #define        LWP_EXTRASTACK  3*sizeof(long)