Browse code

- openbsd (3.2) support [ changes in fastlock.h, ser_module.c, tm/t_hooks.c, Makefiles ] - texops replace/search_append bugs fixed

Andrei Pelinescu-Onciul authored on 11/11/2002 21:34:53
Showing 8 changed files
... ...
@@ -7,7 +7,7 @@
7 7
 #version number
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10
-SUBLEVEL =   10-pre4
10
+SUBLEVEL =   10-pre5
11 11
 EXTRAVERSION = 
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
... ...
@@ -178,7 +178,7 @@ ifneq (,$(findstring gcc, $(CC_LONGVER)))
178 178
 	CC_VER=$(CC) $(shell $(CC) --version|head -1| \
179 179
 				 sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/' -e 's/[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
180 180
 	# sun sed is a little brain damaged => this complicated expression
181
-	MKDEP=$(CC) -MM $(DEFS)
181
+	MKDEP=$(CC) -MM 
182 182
 	#transform gcc version into 2.9x or 3.0
183 183
 	CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
184 184
 				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
... ...
@@ -191,7 +191,7 @@ ifneq (, $(findstring Sun, $(CC_LONGVER)))
191 191
 	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -1| \
192 192
 					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
193 193
 	CC_VER=$(CC) $(CC_SHORTVER)
194
-	MKDEP=$(CC) -xM1 $(DEFS)
194
+	MKDEP=$(CC) -xM1 
195 195
 endif
196 196
 
197 197
 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
... ...
@@ -201,7 +201,7 @@ ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
201 201
 					sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
202 202
 	CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
203 203
 	CC_VER=$(CC) $(CC_FULLVER)
204
-	MKDEP=$(CC) -MM $(DEFS)
204
+	MKDEP=$(CC) -MM 
205 205
 endif
206 206
 
207 207
 
... ...
@@ -210,7 +210,7 @@ ifeq (,$(CC_NAME))
210 210
 	CC_NAME=$(CC)
211 211
 	CC_SHORTVER=unknown
212 212
 	CC_VER=unknown
213
-	MKDEP=gcc -MM $(DEFS)
213
+	MKDEP=gcc -MM 
214 214
 $(warning	Unknown compiler $(CC)\; supported compilers: \
215 215
 			gcc, sun cc, intel icc )
216 216
 endif
... ...
@@ -265,7 +265,7 @@ ifeq	($(ARCH), i386)
265 265
 		# if gcc 
266 266
 ifeq		($(CC_NAME), gcc)
267 267
 				#common stuff
268
-				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
268
+				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
269 269
 					-Wall   \
270 270
 			#if gcc 3.0
271 271
 ifeq			($(CC_SHORTVER), 3.0)
... ...
@@ -309,7 +309,7 @@ ifeq	($(ARCH), sparc)
309 309
 			#if gcc
310 310
 ifeq		($(CC_NAME), gcc)
311 311
 				#common stuff
312
-				CFLAGS=-O9 -funroll-loops  $(PROFILE) -Winline\
312
+				CFLAGS=-O9 -funroll-loops  $(PROFILE) \
313 313
 					-Wall\
314 314
 					#-Wcast-align \
315 315
 					#-Wmissing-prototypes 
... ...
@@ -353,7 +353,7 @@ ifeq	($(ARCH), arm)
353 353
 		# if gcc 
354 354
 ifeq		($(CC_NAME), gcc)
355 355
 				#common stuff
356
-				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
356
+				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
357 357
 					-Wall   \
358 358
 			#if gcc 3.0
359 359
 ifeq			($(CC_SHORTVER), 3.0)
... ...
@@ -415,7 +415,7 @@ endif
415 415
 	# -andrei
416 416
 else	#mode,release
417 417
 ifeq	($(CC_NAME), gcc)
418
-		CFLAGS=-g -Wcast-align -Winline $(PROFILE)
418
+		CFLAGS=-g -Wcast-align $(PROFILE)
419 419
 ifeq		($(ARCH), sparc)
420 420
 			CFLAGS+= -mcpu=ultrasparc 
421 421
 endif
... ...
@@ -467,6 +467,9 @@ LIBS= -lfl -ldl -lresolv
467 467
 ifneq ($(OS), solaris)
468 468
 	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN
469 469
 endif
470
+ifneq ($(OS), openbsd)
471
+	DEFS+=-DHAVE_SCHED_YIELD
472
+endif
470 473
 
471 474
 
472 475
 #os specific stuff
... ...
@@ -501,9 +504,12 @@ ifeq ($(OS), freebsd)
501 501
 endif
502 502
 
503 503
 ifeq ($(OS), openbsd)
504
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN
504
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DDLSYM_PREFIX='"_"'
505
+	# (symbols on openbsd are prefixed by "_")
505 506
 	YACC=yacc
506
-	LIBS= -lfl  -lc_r
507
+	# no sched_yield on openbsd unless linking with c_r (not recommended)
508
+	LIBS= -lfl 
509
+	LDFLAGS=        # openbsd ld doesn't like -O2 or -E
507 510
 endif
508 511
 	
509 512
 ifeq ($(OS), netbsd)
... ...
@@ -18,7 +18,7 @@
18 18
 	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
19 19
 
20 20
 %.d: %.c $(ALLDEP)
21
-	@set -e; $(MKDEP) $< \
21
+	@set -e; $(MKDEP) $(DEFS) $< \
22 22
 	|  sed 's#\($*\)\.o[ :]*#\1.o $@ : #g' > $@; \
23 23
 	[ -s $@ ] || rm -f $@
24 24
 
... ...
@@ -39,6 +39,9 @@
39 39
 #include <dmalloc.h>
40 40
 #endif
41 41
 
42
+/* WARNING: all lump add/insert operations excpect a pkg_malloc'ed char* 
43
+ * pointer the will be DEALLOCATED when the sip_msg is destroyed! */
44
+
42 45
 
43 46
 /* adds a header to the end
44 47
  * returns  pointer on success, 0 on error */
... ...
@@ -35,10 +35,13 @@
35 35
 #ifndef fastlock_h
36 36
 #define fastlock_h
37 37
 
38
-
38
+#ifdef HAVE_SCHED_YIELD
39 39
 #include <sched.h>
40
-
41
-
40
+#else
41
+#include <unistd.h>
42
+	/* fake sched_yield */
43
+	#define sched_yield()	sleep(0)
44
+#endif
42 45
 
43 46
 
44 47
 typedef  volatile int fl_lock_t;
... ...
@@ -32,7 +32,6 @@
32 32
 
33 33
 #include <stdio.h>
34 34
 #include <stdlib.h>
35
-#include <pthread.h>
36 35
 
37 36
 #include "../../parser/msg_parser.h"
38 37
 #include "../../types.h"
... ...
@@ -31,7 +31,8 @@
31 31
 #include "../../error.h"
32 32
 #include "t_hooks.h"
33 33
 
34
-static struct tm_callback_s* callback_array[ TMCB_END ] = { 0, 0 } ;
34
+/* strange things happen if callback_array is static on openbsd */
35
+struct tm_callback_s* callback_array[ TMCB_END ] = { 0, 0 } ;
35 36
 static int callback_id=0;
36 37
 
37 38
 /* register a callback function 'f' of type 'cbt'; will be called
... ...
@@ -167,8 +167,13 @@ int load_module(char* path)
167 167
 	struct sr_module* t;
168 168
 	
169 169
 #ifndef RTLD_NOW
170
+/* for openbsd */
170 171
 #define RTLD_NOW DL_LAZY
171 172
 #endif
173
+#ifndef DLSYM_PREFIX
174
+/* define it to null */
175
+#define DLSYM_PREFIX
176
+#endif
172 177
 	handle=dlopen(path, RTLD_NOW); /* resolve all symbols now */
173 178
 	if (handle==0){
174 179
 		LOG(L_ERR, "ERROR: load_module: could not open module <%s>: %s\n",
... ...
@@ -184,7 +189,7 @@ int load_module(char* path)
184 184
 		}
185 185
 	}
186 186
 	/* launch register */
187
-	exp = (struct module_exports*)dlsym(handle, "exports");
187
+	exp = (struct module_exports*)dlsym(handle, DLSYM_PREFIX "exports");
188 188
 	if ( (error =(char*)dlerror())!=0 ){
189 189
 		LOG(L_ERR, "ERROR: load_module: %s\n", error);
190 190
 		goto error1;
... ...
@@ -2,8 +2,8 @@ debug=9          # debug level (cmd line: -dddddddddd)
2 2
 check_via=yes     # (cmd. line: -v)
3 3
 dns=on           # (cmd. line: -r)
4 4
 rev_dns=yes      # (cmd. line: -R)
5
-fork=no          # (cmd. line: -D)
6
-log_stderror=yes # (cmd line: -E)
5
+#fork=no          # (cmd. line: -D)
6
+#log_stderror=yes # (cmd line: -E)
7 7
 # for more info: sip_router -h
8 8
 
9 9
 #modules