Kaynağa Gözat

- 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 23 yıl önce
ebeveyn
işleme
e61f4ba3df
8 değiştirilmiş dosya ile 37 ekleme ve 20 silme
  1. 17 11
      Makefile.defs
  2. 1 1
      Makefile.rules
  3. 3 0
      data_lump.c
  4. 6 3
      fastlock.h
  5. 0 1
      modules/tm/h_table.h
  6. 2 1
      modules/tm/t_hooks.c
  7. 6 1
      sr_module.c
  8. 2 2
      test/test2.cfg

+ 17 - 11
Makefile.defs

@@ -7,7 +7,7 @@
 #version number
 VERSION = 0
 PATCHLEVEL = 8
-SUBLEVEL =   10-pre4
+SUBLEVEL =   10-pre5
 EXTRAVERSION = 
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
@@ -178,7 +178,7 @@ ifneq (,$(findstring gcc, $(CC_LONGVER)))
 	CC_VER=$(CC) $(shell $(CC) --version|head -1| \
 				 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/')
 	# sun sed is a little brain damaged => this complicated expression
-	MKDEP=$(CC) -MM $(DEFS)
+	MKDEP=$(CC) -MM 
 	#transform gcc version into 2.9x or 3.0
 	CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
 				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
@@ -191,7 +191,7 @@ ifneq (, $(findstring Sun, $(CC_LONGVER)))
 	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -1| \
 					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
 	CC_VER=$(CC) $(CC_SHORTVER)
-	MKDEP=$(CC) -xM1 $(DEFS)
+	MKDEP=$(CC) -xM1 
 endif
 
 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
@@ -201,7 +201,7 @@ ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
 					sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
 	CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
 	CC_VER=$(CC) $(CC_FULLVER)
-	MKDEP=$(CC) -MM $(DEFS)
+	MKDEP=$(CC) -MM 
 endif
 
 
@@ -210,7 +210,7 @@ ifeq (,$(CC_NAME))
 	CC_NAME=$(CC)
 	CC_SHORTVER=unknown
 	CC_VER=unknown
-	MKDEP=gcc -MM $(DEFS)
+	MKDEP=gcc -MM 
 $(warning	Unknown compiler $(CC)\; supported compilers: \
 			gcc, sun cc, intel icc )
 endif
@@ -265,7 +265,7 @@ ifeq	($(ARCH), i386)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
 				#common stuff
-				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
+				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
 					-Wall   \
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
@@ -309,7 +309,7 @@ ifeq	($(ARCH), sparc)
 			#if gcc
 ifeq		($(CC_NAME), gcc)
 				#common stuff
-				CFLAGS=-O9 -funroll-loops  $(PROFILE) -Winline\
+				CFLAGS=-O9 -funroll-loops  $(PROFILE) \
 					-Wall\
 					#-Wcast-align \
 					#-Wmissing-prototypes 
@@ -353,7 +353,7 @@ ifeq	($(ARCH), arm)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
 				#common stuff
-				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
+				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
 					-Wall   \
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
@@ -415,7 +415,7 @@ endif
 	# -andrei
 else	#mode,release
 ifeq	($(CC_NAME), gcc)
-		CFLAGS=-g -Wcast-align -Winline $(PROFILE)
+		CFLAGS=-g -Wcast-align $(PROFILE)
 ifeq		($(ARCH), sparc)
 			CFLAGS+= -mcpu=ultrasparc 
 endif
@@ -467,6 +467,9 @@ LIBS= -lfl -ldl -lresolv
 ifneq ($(OS), solaris)
 	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN
 endif
+ifneq ($(OS), openbsd)
+	DEFS+=-DHAVE_SCHED_YIELD
+endif
 
 
 #os specific stuff
@@ -501,9 +504,12 @@ ifeq ($(OS), freebsd)
 endif
 
 ifeq ($(OS), openbsd)
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DDLSYM_PREFIX='"_"'
+	# (symbols on openbsd are prefixed by "_")
 	YACC=yacc
-	LIBS= -lfl  -lc_r
+	# no sched_yield on openbsd unless linking with c_r (not recommended)
+	LIBS= -lfl 
+	LDFLAGS=        # openbsd ld doesn't like -O2 or -E
 endif
 	
 ifeq ($(OS), netbsd)

+ 1 - 1
Makefile.rules

@@ -18,7 +18,7 @@
 	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
 
 %.d: %.c $(ALLDEP)
-	@set -e; $(MKDEP) $< \
+	@set -e; $(MKDEP) $(DEFS) $< \
 	|  sed 's#\($*\)\.o[ :]*#\1.o $@ : #g' > $@; \
 	[ -s $@ ] || rm -f $@
 

+ 3 - 0
data_lump.c

@@ -39,6 +39,9 @@
 #include <dmalloc.h>
 #endif
 
+/* WARNING: all lump add/insert operations excpect a pkg_malloc'ed char* 
+ * pointer the will be DEALLOCATED when the sip_msg is destroyed! */
+
 
 /* adds a header to the end
  * returns  pointer on success, 0 on error */

+ 6 - 3
fastlock.h

@@ -35,10 +35,13 @@
 #ifndef fastlock_h
 #define fastlock_h
 
-
+#ifdef HAVE_SCHED_YIELD
 #include <sched.h>
-
-
+#else
+#include <unistd.h>
+	/* fake sched_yield */
+	#define sched_yield()	sleep(0)
+#endif
 
 
 typedef  volatile int fl_lock_t;

+ 0 - 1
modules/tm/h_table.h

@@ -32,7 +32,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <pthread.h>
 
 #include "../../parser/msg_parser.h"
 #include "../../types.h"

+ 2 - 1
modules/tm/t_hooks.c

@@ -31,7 +31,8 @@
 #include "../../error.h"
 #include "t_hooks.h"
 
-static struct tm_callback_s* callback_array[ TMCB_END ] = { 0, 0 } ;
+/* strange things happen if callback_array is static on openbsd */
+struct tm_callback_s* callback_array[ TMCB_END ] = { 0, 0 } ;
 static int callback_id=0;
 
 /* register a callback function 'f' of type 'cbt'; will be called

+ 6 - 1
sr_module.c

@@ -167,7 +167,12 @@ int load_module(char* path)
 	struct sr_module* t;
 	
 #ifndef RTLD_NOW
+/* for openbsd */
 #define RTLD_NOW DL_LAZY
+#endif
+#ifndef DLSYM_PREFIX
+/* define it to null */
+#define DLSYM_PREFIX
 #endif
 	handle=dlopen(path, RTLD_NOW); /* resolve all symbols now */
 	if (handle==0){
@@ -184,7 +189,7 @@ int load_module(char* path)
 		}
 	}
 	/* launch register */
-	exp = (struct module_exports*)dlsym(handle, "exports");
+	exp = (struct module_exports*)dlsym(handle, DLSYM_PREFIX "exports");
 	if ( (error =(char*)dlerror())!=0 ){
 		LOG(L_ERR, "ERROR: load_module: %s\n", error);
 		goto error1;

+ 2 - 2
test/test2.cfg

@@ -2,8 +2,8 @@ debug=9          # debug level (cmd line: -dddddddddd)
 check_via=yes     # (cmd. line: -v)
 dns=on           # (cmd. line: -r)
 rev_dns=yes      # (cmd. line: -R)
-fork=no          # (cmd. line: -D)
-log_stderror=yes # (cmd line: -E)
+#fork=no          # (cmd. line: -D)
+#log_stderror=yes # (cmd line: -E)
 # for more info: sip_router -h
 
 #modules