Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
From b9cad55931ffc8450cc04eeb2d6ac72ff7ccb60e Mon Sep 17 00:00:00 2001 From: ragge <ragge@bruno.local> Date: Sat, 16 Feb 2008 15:32:28 +0100 Subject: [PATCH] Make shotgun compile on OpenBSD. Initial fixes, some ugly stuff. The Makefile should probably be tidied for different platforms, somehow. Shotgun crashes when compiling kernel/core/compiler.rb --- shotgun/lib/Makefile | 16 +++++++++--- shotgun/lib/ffi_util.c | 2 +- shotgun/lib/state.h | 2 +- shotgun/lib/subtend/PortableUContext.h | 38 ++++++++++++++++++--------- shotgun/lib/subtend/PortableUContext_asm.S | 6 ++++ 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/shotgun/lib/Makefile b/shotgun/lib/Makefile index 95a095f..afed93c 100644 --- a/shotgun/lib/Makefile +++ b/shotgun/lib/Makefile @@ -38,11 +38,19 @@ endif # Darwin doesn't need -lcrypt or -lrt # BSD does not need -lrt -ifneq ($(UNAME),Darwin) - LIBS+= -lcrypt -ifneq ($(findstring BSD,$(UNAME)),BSD) - LIBS+= -lrt +#ifneq ($(UNAME),Darwin) +# LIBS+= -lcrypt +#ifneq ($(findstring BSD,$(UNAME)),BSD) +# LIBS+= -lrt +#endif +#endif + +ifeq ($(UNAME),Linux) + LIBS+= -lrt -lcrypt endif + +ifeq ($(UNAME),FreeBSD) + LIBS+= -lcrypt endif # BSD needs special PThread handling diff --git a/shotgun/lib/ffi_util.c b/shotgun/lib/ffi_util.c index b85b859..90b6baf 100644 --- a/shotgun/lib/ffi_util.c +++ b/shotgun/lib/ffi_util.c @@ -1,7 +1,7 @@ +#include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <netinet/in.h> -#include <sys/types.h> #include <netdb.h> #include <errno.h> #include <time.h> diff --git a/shotgun/lib/state.h b/shotgun/lib/state.h index 04720ac..b70133e 100644 --- a/shotgun/lib/state.h +++ b/shotgun/lib/state.h @@ -1,7 +1,7 @@ #ifndef RBS_STATE_H #define RBS_STATE_H -#include <ucontext.h> +/*#include <ucontext.h>*/ #include <hashtable.h> #include <ptr_array.h> diff --git a/shotgun/lib/subtend/PortableUContext.h b/shotgun/lib/subtend/PortableUContext.h index a0d8d8c..21cbba3 100644 --- a/shotgun/lib/subtend/PortableUContext.h +++ b/shotgun/lib/subtend/PortableUContext.h @@ -6,7 +6,7 @@ #define HAS_UCONTEXT 1 #endif -#if defined(__FreeBSD__) || (defined(__APPLE__) && !__DARWIN_UNIX03) +#if defined(__FreeBSD__) || (defined(__APPLE__) && __DARWIN_UNIX03) #include <stdarg.h> #include <errno.h> @@ -51,18 +51,7 @@ extern void makecontext(ucontext_t*, void(*)(), int, ...); # define NEEDSWAPCONTEXT #endif -#if defined(__OpenBSD__) -# define mcontext libthread_mcontext -# define mcontext_t libthread_mcontext_t -# define ucontext libthread_ucontext -# define ucontext_t libthread_ucontext_t -# if defined __i386__ -# include "PortableUContext386.h" -# else -# include "PortableUContextPPC.h" -# endif -extern pid_t rfork_thread(int, void*, int(*)(void*), void*); -#endif + #if 0 && defined(__sun__) # define mcontext libthread_mcontext @@ -86,7 +75,30 @@ void setmcontext(const mcontext_t*); #define NEEDSWAPCONTEXT #endif +#endif +#if defined(__OpenBSD__) +#include <sys/types.h> +#include <sys/time.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <inttypes.h> + +# define mcontext libthread_mcontext +# define mcontext_t libthread_mcontext_t +# define ucontext libthread_ucontext +# define ucontext_t libthread_ucontext_t +# if defined(__i386__) +# include "PortableUContext386.h" +# define NEEDX86MAKECONTEXT +# define NEEDXSWAPCONTEXT +# else +# include "PortableUContextPPC.h" +# endif +extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif + + #endif diff --git a/shotgun/lib/subtend/PortableUContext_asm.S b/shotgun/lib/subtend/PortableUContext_asm.S index 8b04330..117d4b5 100644 --- a/shotgun/lib/subtend/PortableUContext_asm.S +++ b/shotgun/lib/subtend/PortableUContext_asm.S @@ -31,6 +31,12 @@ This software was developed as part of a project at MIT. #define GET getmcontext #endif +#if defined(__OpenBSD__) && defined(__i386__) +#define NEEDX86CONTEXT 1 +#define SET setmcontext +#define GET getmcontext +#endif + #if defined(__APPLE__) #include "sys/cdefs.h" #endif -- 1.5.3.7
From the Design Piracy series on my blog: