1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
|