summaryrefslogtreecommitdiff
path: root/pr/include/md/_netbsd.h
diff options
context:
space:
mode:
Diffstat (limited to 'pr/include/md/_netbsd.h')
-rw-r--r--pr/include/md/_netbsd.h115
1 files changed, 87 insertions, 28 deletions
diff --git a/pr/include/md/_netbsd.h b/pr/include/md/_netbsd.h
index 49aca74b..8edc6ab9 100644
--- a/pr/include/md/_netbsd.h
+++ b/pr/include/md/_netbsd.h
@@ -20,6 +20,7 @@
#define nspr_netbsd_defs_h___
#include <sys/syscall.h>
+#include <sys/param.h> /* for __NetBSD_Version__ */
#define PR_LINKER_ARCH "netbsd"
#define _PR_SI_SYSNAME "NetBSD"
@@ -39,7 +40,11 @@
#define _PR_SI_ARCHITECTURE "arm32"
#endif
+#if defined(__ELF__)
+#define PR_DLL_SUFFIX ".so"
+#else
#define PR_DLL_SUFFIX ".so.1.0"
+#endif
#define _PR_VMBASE 0x30000000
#define _PR_STACK_VMBASE 0x50000000
@@ -52,6 +57,8 @@
#define _PR_HAVE_SOCKADDR_LEN
#define _PR_NO_LARGE_FILES
#define _PR_STAT_HAS_ST_ATIMESPEC
+#define _PR_POLL_AVAILABLE
+#define _PR_USE_POLL
#define _PR_HAVE_SYSV_SEMAPHORES
#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
@@ -64,40 +71,89 @@
#define CONTEXT(_th) ((_th)->md.context)
-#if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || defined(__powerpc__)
-#define JB_SP_INDEX 2
-#elif defined(__mips__)
-#define JB_SP_INDEX 4
-#elif defined(__alpha__)
-#define JB_SP_INDEX 34
-#elif defined(__arm32__)
/*
- * On the arm32, the jmpbuf regs underwent a name change after NetBSD 1.3.
- */
-#ifdef JMPBUF_REG_R13
-#define JB_SP_INDEX JMPBUF_REG_R13
-#else
-#define JB_SP_INDEX _JB_REG_R13
+** Initialize a thread context to run "_main()" when started
+*/
+#ifdef __i386__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[2] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[0] = (int) _main; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[2]
#endif
-#else
-#error "Need to define SP index in jmp_buf here"
+#ifdef __sparc__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[2] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[3] = (int) _main; \
+ CONTEXT(_thread)[4] = (int) _main + 4; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[2]
+#endif
+#ifdef __powerpc__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[3] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[4] = (int) _main; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[3]
+#endif
+#ifdef __m68k__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[2] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[5] = (int) _main; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[2]
+#endif
+#ifdef __mips__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[32] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[2] = (int) _main; \
+ CONTEXT(_thread)[28] = (int) _main; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[32]
+#endif
+#ifdef __arm32__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[23] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[24] = (int) _main; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[23]
+#endif
+#ifdef __alpha__
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
+{ \
+ sigsetjmp(CONTEXT(_thread), 1); \
+ CONTEXT(_thread)[34] = (unsigned char*) ((_sp) - 128); \
+ CONTEXT(_thread)[2] = (long) _main; \
+ CONTEXT(_thread)[30] = (long) _main; \
+ CONTEXT(_thread)[31] = (long) _main; \
+ *status = PR_TRUE; \
+}
+#define _MD_GET_SP(_thread) CONTEXT(_thread)[34]
+#endif
+#ifndef _MD_INIT_CONTEXT
+#error "Need to define _MD_INIT_CONTEXT for this platform"
#endif
-#define _MD_GET_SP(_th) (_th)->md.context[JB_SP_INDEX]
#define PR_NUM_GCREGS _JBLEN
-/*
-** Initialize a thread context to run "_main()" when started
-*/
-#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
-{ \
- *status = PR_TRUE; \
- if (sigsetjmp(CONTEXT(_thread), 1)) { \
- _main(); \
- } \
- _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \
-}
-
#define _MD_SWITCH_CONTEXT(_thread) \
if (!sigsetjmp(CONTEXT(_thread), 1)) { \
(_thread)->md.errcode = errno; \
@@ -210,7 +266,10 @@ struct _MDCPU {
* unwrapped version.
*/
#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
+#if defined(_PR_POLL_AVAILABLE)
+#include <poll.h>
#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
+#endif
#if NetBSD1_3 == 1L
typedef unsigned int nfds_t;