Browse code

-x86_64 experimental support -various 64 bit warning fixes

Andrei Pelinescu-Onciul authored on 28/09/2004 18:10:08
Showing 12 changed files
... ...
@@ -33,6 +33,7 @@
33 33
 #  2003-11-24  openbsd 3.4 (elf) fixes (andrei)
34 34
 #  2004-07-27  darwin (mac os x) port  (andrei)
35 35
 #  2004-09-12  mips2 & cobalt support introduced (andrei)
36
+#  2004-09-28  x86_64 support introduced (andrei)
36 37
 
37 38
 
38 39
 # check if already included/exported
... ...
@@ -49,7 +50,7 @@ MAIN_NAME=ser
49 49
 VERSION = 0
50 50
 PATCHLEVEL = 8
51 51
 SUBLEVEL =   99
52
-EXTRAVERSION = -dev6
52
+EXTRAVERSION = -dev7
53 53
 
54 54
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
55 55
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -385,6 +386,10 @@ ifeq ($(ARCH), i386)
385 385
 	use_fast_lock=yes
386 386
 endif
387 387
 
388
+ifeq ($(ARCH), x86_64)
389
+	use_fast_lock=yes
390
+endif
391
+
388 392
 ifeq ($(ARCH), sparc64)
389 393
 ifeq 	($(CC_NAME), gcc)
390 394
 	use_fast_lock=yes
... ...
@@ -462,6 +467,49 @@ endif		#CC_NAME, icc
462 462
 endif		#CC_NAME, gcc
463 463
 endif	#ARCH, i386
464 464
 
465
+#x86_64
466
+ifeq	($(ARCH), x86_64)
467
+		# if gcc 
468
+ifeq		($(CC_NAME), gcc)
469
+				#common stuff
470
+				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
471
+					-Wall   \
472
+			#if gcc 3.0
473
+ifeq			($(CC_SHORTVER), 3.0)
474
+					CPU ?= athlon64
475
+					CFLAGS+=-minline-all-stringops \
476
+							-falign-loops \
477
+							-mcpu=$(CPU) \
478
+							#-mcpu=athlon
479
+else
480
+ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
481
+$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
482
+					for better results)
483
+					
484
+					CFLAGS+=-m486 \
485
+							-malign-loops=4
486
+else
487
+				#really old version
488
+$(warning			You are using an old and unsupported gcc \
489
+					 version  ($(CC_SHORTVER)), compile at your own risk!)
490
+
491
+endif			# CC_SHORTVER, 2.9x
492
+endif			# CC_SHORTVER, 3.0
493
+
494
+else		# CC_NAME, gcc
495
+ifeq		($(CC_NAME), icc)
496
+			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
497
+					 -tpp6 -xK  #-openmp  #optimize for PIII 
498
+				# -prefetch doesn't seem to work
499
+				#( ty to inline acroos files, unroll loops,prefetch,
500
+				# optimize for PIII, use PIII instructions & vect.,
501
+				# mutlithread loops)
502
+else
503
+				#other compilers
504
+$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
505
+endif		#CC_NAME, icc
506
+endif		#CC_NAME, gcc
507
+endif	#ARCH, x86_64
465 508
 
466 509
 	#if sparc
467 510
 ifeq	($(ARCH), sparc64)
... ...
@@ -1494,7 +1494,8 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
1494 1494
 			if (str2q(&q, $5, strlen($5)) < 0) {
1495 1495
 				yyerror("bad argument, q value expected");
1496 1496
 			}
1497
-			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, (void *)q); } 
1497
+			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, 
1498
+							(void *)(long)q); } 
1498 1499
 		}
1499 1500
 	
1500 1501
 		| APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action( APPEND_BRANCH_T,
... ...
@@ -451,7 +451,7 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
451 451
 	}
452 452
 parse_error:
453 453
 	LOG(L_ERR,"ERROR:get_avps: parse error in \"%.*s\" at char [%d][%c] "
454
-		"offset %d\n",line.len,line.s,*c,*c,c-line.s);
454
+		"offset %d\n",line.len,line.s,*c,*c, (unsigned)(c-line.s));
455 455
 	double_log("Broken AVP(attr|op|val) in DB command");
456 456
 error:
457 457
 	for(;*nr;(*nr)--)
... ...
@@ -65,7 +65,7 @@ inline static int tsl(fl_lock_t* lock)
65 65
 {
66 66
 	int val;
67 67
 
68
-#ifdef __CPU_i386
68
+#if defined(__CPU_i386) || defined(__CPU_x86_64)
69 69
 
70 70
 #ifdef NOSMP
71 71
 	val=0;
... ...
@@ -154,7 +154,7 @@ inline static void get_lock(fl_lock_t* lock)
154 154
 
155 155
 inline static void release_lock(fl_lock_t* lock)
156 156
 {
157
-#ifdef __CPU_i386
157
+#if defined(__CPU_i386) || defined(__CPU_x86_64)
158 158
 	char val;
159 159
 	val=0;
160 160
 	asm volatile(
... ...
@@ -345,7 +345,7 @@ static int fifo_check(int fd, char* fname)
345 345
 	/* check if hard-linked */
346 346
 	if (fst.st_nlink>1){
347 347
 		LOG(L_ERR, "ERROR: security: fifo_check: %s is hard-linked %d times\n",
348
-				fname, fst.st_nlink);
348
+				fname, (unsigned)fst.st_nlink);
349 349
 		return -1;
350 350
 	}
351 351
 	
... ...
@@ -88,7 +88,7 @@
88 88
 
89 89
 
90 90
 /* computes hash number for big buckets*/
91
-inline static int big_hash_idx(int s)
91
+inline static int big_hash_idx(unsigned long s)
92 92
 {
93 93
 	int idx;
94 94
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
... ...
@@ -96,7 +96,7 @@ inline static int big_hash_idx(int s)
96 96
 	 *
97 97
 	 * => index = number of the first non null bit in s*/
98 98
 	idx=sizeof(long)*8-1;
99
-	for (; !(s&(1<<(sizeof(long)*8-1))) ; s<<=1, idx--);
99
+	for (; !(s&(1UL<<(sizeof(long)*8-1))) ; s<<=1, idx--);
100 100
 	return idx;
101 101
 }
102 102
 
... ...
@@ -104,7 +104,7 @@
104 104
 
105 105
 
106 106
 /* computes hash number for big buckets*/
107
-inline static int big_hash_idx(int s)
107
+inline static int big_hash_idx(unsigned long s)
108 108
 {
109 109
 	int idx;
110 110
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
... ...
@@ -112,7 +112,7 @@ inline static int big_hash_idx(int s)
112 112
 	 *
113 113
 	 * => index = number of the first non null bit in s*/
114 114
 	idx=sizeof(long)*8-1;
115
-	for (; !(s&(1<<(sizeof(long)*8-1))) ; s<<=1, idx--);
115
+	for (; !(s&(1UL<<(sizeof(long)*8-1))) ; s<<=1, idx--);
116 116
 	return idx;
117 117
 }
118 118
 
... ...
@@ -68,7 +68,7 @@
68 68
 									must be 2^k */
69 69
 
70 70
 #define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
71
-		(sizeof(long)-QM_MALLOC_OPTIMIZE_FACTOR)+1))
71
+		(sizeof(long)*8-QM_MALLOC_OPTIMIZE_FACTOR)+1))
72 72
 
73 73
 /* hash structure:
74 74
  * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with
... ...
@@ -205,7 +205,7 @@ again:
205 205
 		*fd=*((int*) CMSG_DATA(cmsg));
206 206
 	}else{
207 207
 		LOG(L_ERR, "ERROR: receive_fd: no descriptor passed, cmsg=%p,"
208
-				"len=%d\n", cmsg, cmsg->cmsg_len);
208
+				"len=%d\n", cmsg, (unsigned)cmsg->cmsg_len);
209 209
 		*fd=-1;
210 210
 		/* it's not really an error */
211 211
 	}
... ...
@@ -895,7 +895,7 @@ int tcp_init(struct socket_info* sock_info)
895 895
 	if (bind(sock_info->socket, &addr->s, sockaddru_len(*addr))==-1){
896 896
 		LOG(L_ERR, "ERROR: tcp_init: bind(%x, %p, %d) on %s: %s\n",
897 897
 				sock_info->socket, &addr->s, 
898
-				sockaddru_len(*addr),
898
+				(unsigned)sockaddru_len(*addr),
899 899
 				sock_info->address_str.s,
900 900
 				strerror(errno));
901 901
 		goto error;
... ...
@@ -903,7 +903,7 @@ int tcp_init(struct socket_info* sock_info)
903 903
 	if (listen(sock_info->socket, 10)==-1){
904 904
 		LOG(L_ERR, "ERROR: tcp_init: listen(%x, %p, %d) on %s: %s\n",
905 905
 				sock_info->socket, &addr->s, 
906
-				sockaddru_len(*addr),
906
+				(unsigned)sockaddru_len(*addr),
907 907
 				sock_info->address_str.s,
908 908
 				strerror(errno));
909 909
 		goto error;
... ...
@@ -349,7 +349,7 @@ int udp_init(struct socket_info* sock_info)
349 349
 	if (bind(sock_info->socket,  &addr->s, sockaddru_len(*addr))==-1){
350 350
 		LOG(L_ERR, "ERROR: udp_init: bind(%x, %p, %d) on %s: %s\n",
351 351
 				sock_info->socket, &addr->s, 
352
-				sockaddru_len(*addr),
352
+				(unsigned)sockaddru_len(*addr),
353 353
 				sock_info->address_str.s,
354 354
 				strerror(errno));
355 355
 	#ifdef USE_IPV6
... ...
@@ -189,7 +189,7 @@
189 189
 
190 190
 
191 191
 #define SER_COMPILE_FLAGS \
192
-	EXTRA_DEBUG_STR STATS_STR USE_IPV6_STR USE_TCP_STR USE_TLS_STR \
192
+	STATS_STR EXTRA_DEBUG_STR USE_IPV6_STR USE_TCP_STR USE_TLS_STR \
193 193
 	DISABLE_NAGLE_STR USE_MCAST_STR NO_DEBUG_STR NO_LOG_STR DNS_IP_HACK_STR \
194 194
 	SHM_MEM_STR SHM_MMAP_STR PKG_MALLOC_STR VQ_MALLOC_STR F_MALLOC_STR \
195 195
 	USE_SHM_MEM_STR DBG_QM_MALLOC_STR DBG_F_MALLOC_STR DEBUG_DMALLOC_STR \