/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
/* process.c - manage lwp context switches be means of setjmp/longjmp. */
#include <afsconfig.h>
+#include <afs/param.h>
-/*
- * We must include at least one system header on Linux prior to including
- * afs/param.h, or the __GLIBC__ and __GLIBC_MINOR__ macros will not yet be
- * defined and we won't know whether we're using ucontext.
- */
-#include <stdio.h>
-#include <assert.h>
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <roken.h>
-#include <afs/param.h>
+#include <assert.h>
#include "lwp.h"
-#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
+#if defined(AFS_S390_LINUX20_ENV)
extern int PRE_Block; /* used in lwp.c and process.s */
#else
extern char PRE_Block; /* used in lwp.c and process.s */
#if defined(USE_UCONTEXT) && defined(HAVE_UCONTEXT_H)
+# if defined(AFS_LINUX20_ENV) || defined(AFS_XBSD_ENV)
+# define AFS_UCONTEXT_NOSTACK
+# endif
+
afs_int32
savecontext(void (*ep) (void), struct lwp_context *savearea, char *newsp)
{
-#if defined(AFS_LINUX20_ENV)
+# ifdef AFS_UCONTEXT_NOSTACK
/* getcontext does not export stack info */
int stackvar;
-#endif
+# endif
PRE_Block = 1;
savearea->state = 0;
getcontext(&savearea->ucontext);
-#if defined(AFS_LINUX20_ENV)
+# ifdef AFS_UCONTEXT_NOSTACK
savearea->topstack = (char *)&stackvar;
-#else
+# else
savearea->topstack = savearea->ucontext.uc_stack.ss_sp;
-#endif
+# endif
switch (savearea->state) {
case 0:
if (newsp) {
# else
# define LWP_SP JB_SP
# endif
-#elif defined(AFS_HPUX_ENV) || defined(AFS_PARISC_LINUX24_ENV)
+#elif defined(AFS_HPUX_ENV)
#define LWP_SP 1
#elif defined(AFS_LINUX20_ENV)
#if defined(AFS_PPC_LINUX20_ENV) || defined(AFS_PPC64_LINUX20_ENV)
#elif defined(AFS_ALPHA_LINUX20_ENV)
#define LWP_SP 8
#define LWP_FP 7
-#elif defined(AFS_PARISC_LINUX24_ENV)
-#define LWP_SP 19
#else
#error Unsupported linux LWP system type.
#endif
typedef __uint64_t jmp_buf_type;
#endif
#else
-#if defined(AFS_ALPHA_LINUX20_ENV) || defined(AFS_PPC64_LINUX20_ENV)
+#if defined(AFS_ALPHA_LINUX20_ENV) || defined(AFS_PPC64_LINUX20_ENV)
typedef long jmp_buf_type;
#else
typedef int jmp_buf_type;
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 3)
#if defined(AFS_SPARC64_LINUX24_ENV) || defined(AFS_SPARC_LINUX24_ENV)
-/* technically we should use POINTER_GUARD
+/* technically we should use POINTER_GUARD
* ( == offsetof (tcbhead_t, pointer_guard) )
* instead of 0x18
*/
#undef ptr_mangle
static int ptr_mangle(int p)
-{
+{
register char *tls_ptr __asm__("%g7");
return p ^ *(int*)(tls_ptr + 0x18);
}