From 8c573cab6819c69142389d36b978b3c683771afe Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 12:40:09 -0500 Subject: libthread: use mmap to allocate OpenBSD stacks Should fix faults on OpenBSD. Fixes #218. Fixes #226. --- src/libthread/threadimpl.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libthread/threadimpl.h') diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 76ca57e5..6671f23c 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -209,3 +209,5 @@ extern void _threadsetupdaemonize(void); extern void _threaddodaemonize(char*); extern void _threadpexit(void); extern void _threaddaemonize(void); +extern void *_threadstkalloc(int); +extern void _threadstkfree(void*, int); -- cgit v1.2.3 From 8dcb18f71b1917713d4743ab10968c527acdc62e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:25:33 -0500 Subject: libthread: rm FreeBSD 4 code Pretty sure FreeBSD 4 is gone now. :-) --- src/libthread/threadimpl.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/libthread/threadimpl.h') diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 6671f23c..e26ffe6b 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -15,15 +15,6 @@ #include "libc.h" #include "thread.h" -#if defined(__FreeBSD__) && __FreeBSD__ < 5 -extern int getmcontext(mcontext_t*); -extern void setmcontext(mcontext_t*); -#define setcontext(u) setmcontext(&(u)->uc_mcontext) -#define getcontext(u) getmcontext(&(u)->uc_mcontext) -extern int swapcontext(ucontext_t*, ucontext_t*); -extern void makecontext(ucontext_t*, void(*)(), int, ...); -#endif - #if defined(__APPLE__) /* * OS X before 10.5 (Leopard) does not provide -- cgit v1.2.3 From c181e39eeab0eb8cad274b7b22ce5343bd55630d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:01:30 -0500 Subject: libthread: rm unused sparc-ucontext.h More dead code. --- src/libthread/threadimpl.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/libthread/threadimpl.h') diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index e26ffe6b..5b6d74cc 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -55,20 +55,6 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif -/* THIS DOES NOT WORK! Don't do this! -(At least, not on Solaris. Maybe this is right for Linux, -in which case it should say if defined(__linux__) && defined(__sun__), -but surely the latter would be defined(__sparc__). - -#if defined(__sun__) -# define mcontext libthread_mcontext -# define mcontext_t libthread_mcontext_t -# define ucontext libthread_ucontext -# define ucontext_t libthread_ucontext_t -# include "sparc-ucontext.h" -#endif -*/ - #if defined(__arm__) int mygetmcontext(ulong*); void mysetmcontext(const ulong*); -- cgit v1.2.3 From 41b3e8b9893a8561af7e85ca98444bc284b4013d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 22:39:22 -0500 Subject: libthread: use consistent stack calculation code in makecontext Also reduce duplication: makecontext is per-arch not per-os-arch. May fix #353. --- src/libthread/threadimpl.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libthread/threadimpl.h') diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 5b6d74cc..cceb1b8e 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -188,3 +188,6 @@ extern void _threadpexit(void); extern void _threaddaemonize(void); extern void *_threadstkalloc(int); extern void _threadstkfree(void*, int); + +#define USPALIGN(ucp, align) \ + (void*)((((uintptr)(ucp)->uc_stack.ss_sp+(ucp)->uc_stack.ss_size)-(align))&~((align)-1)) -- cgit v1.2.3