where it belongs. Code looks fishy. Untested.
(initcontext, startpoint): Internal linkage.
#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)
}
}
+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
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
#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)
#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)