Browse code

- more than 4Gb memory support (ser -m 5192 will work and use 5Gb of memory)

Andrei Pelinescu-Onciul authored on 10/11/2004 21:51:24
Showing 11 changed files
... ...
@@ -50,7 +50,7 @@ MAIN_NAME=ser
50 50
 VERSION = 0
51 51
 PATCHLEVEL = 8
52 52
 SUBLEVEL =   99
53
-EXTRAVERSION = -dev13
53
+EXTRAVERSION = -dev14
54 54
 
55 55
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
56 56
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -116,7 +116,7 @@ extern int mcast_ttl;
116 116
 extern int cfg_errors;
117 117
 extern unsigned int msg_no;
118 118
 
119
-extern unsigned int shm_mem_size;
119
+extern unsigned long shm_mem_size;
120 120
 
121 121
 /* FIFO server config */
122 122
 char extern *fifo; /* FIFO name */
... ...
@@ -322,7 +322,7 @@ int process_no = 0;
322 322
 int cfg_errors=0;
323 323
 
324 324
 /* shared memory (in MB) */
325
-unsigned int shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
325
+unsigned long shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
326 326
 
327 327
 /* export command-line to anywhere else */
328 328
 int my_argc;
... ...
@@ -1120,7 +1120,7 @@ int main(int argc, char** argv)
1120 1120
 										optarg);
1121 1121
 						goto error;
1122 1122
 					};
1123
-					LOG(L_INFO, "ser: shared memory allocated: %d MByte\n",
1123
+					LOG(L_INFO, "ser: shared memory: %ld bytes\n",
1124 1124
 									shm_mem_size );
1125 1125
 					break;
1126 1126
 
... ...
@@ -32,6 +32,7 @@
32 32
  *  2004-07-19  fragments book keeping code and support for 64 bits
33 33
  *               memory blocks (64 bits machine & size >=2^32) 
34 34
  *              GET_HASH s/</<=/ (avoids waste of 1 hash cell)   (andrei)
35
+ *  2004-11-10  support for > 4Gb mem., switched to long (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -66,12 +67,14 @@
66 67
 
67 68
 
68 69
 	/* finds the hash value for s, s=ROUNDTO multiple*/
69
-#define GET_HASH(s)   ( ((s)<=F_MALLOC_OPTIMIZE)?(s)/ROUNDTO: \
70
-						F_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
71
-							F_MALLOC_OPTIMIZE_FACTOR+1 )
72
-
73
-#define UN_HASH(h)	( ((h)<=(F_MALLOC_OPTIMIZE/ROUNDTO))?(h)*ROUNDTO: \
74
-						1<<((h)-F_MALLOC_OPTIMIZE/ROUNDTO+\
70
+#define GET_HASH(s)   ( ((unsigned long)(s)<=F_MALLOC_OPTIMIZE)?\
71
+							(unsigned long)(s)/ROUNDTO: \
72
+							F_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
73
+								F_MALLOC_OPTIMIZE_FACTOR+1 )
74
+
75
+#define UN_HASH(h)	( ((unsigned long)(h)<=(F_MALLOC_OPTIMIZE/ROUNDTO))?\
76
+						(unsigned long)(h)*ROUNDTO: \
77
+						1UL<<((unsigned long)(h)-F_MALLOC_OPTIMIZE/ROUNDTO+\
75 78
 							F_MALLOC_OPTIMIZE_FACTOR-1)\
76 79
 					)
77 80
 
... ...
@@ -88,9 +91,9 @@
88 91
 
89 92
 
90 93
 /* computes hash number for big buckets*/
91
-inline static int big_hash_idx(unsigned long s)
94
+inline static unsigned long big_hash_idx(unsigned long s)
92 95
 {
93
-	int idx;
96
+	unsigned long idx;
94 97
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
95 98
 	 * index= i such that 2^i > s >= 2^(i-1)
96 99
 	 *
... ...
@@ -135,13 +138,15 @@ static inline void fm_insert_free(struct fm_block* qm, struct fm_frag* frag)
135 138
  /* size should be already rounded-up */
136 139
 static inline
137 140
 #ifdef DBG_F_MALLOC 
138
-void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size,
141
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
142
+					unsigned long size,
139 143
 					char* file, char* func, unsigned int line)
140 144
 #else
141
-void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
145
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
146
+					unsigned long size)
142 147
 #endif
143 148
 {
144
-	unsigned int rest;
149
+	unsigned long rest;
145 150
 	struct fm_frag* n;
146 151
 	
147 152
 	rest=frag->size-size;
... ...
@@ -174,12 +179,12 @@ void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
174 179
 
175 180
 
176 181
 /* init malloc and return a fm_block*/
177
-struct fm_block* fm_malloc_init(char* address, unsigned int size)
182
+struct fm_block* fm_malloc_init(char* address, unsigned long size)
178 183
 {
179 184
 	char* start;
180 185
 	char* end;
181 186
 	struct fm_block* qm;
182
-	unsigned int init_overhead;
187
+	unsigned long init_overhead;
183 188
 	
184 189
 	/* make address and size multiple of 8*/
185 190
 	start=(char*)ROUNDUP((unsigned long) address);
... ...
@@ -228,10 +233,10 @@ struct fm_block* fm_malloc_init(char* address, unsigned int size)
228 233
 
229 234
 
230 235
 #ifdef DBG_F_MALLOC
231
-void* fm_malloc(struct fm_block* qm, unsigned int size, char* file, char* func,
232
-					unsigned int line)
236
+void* fm_malloc(struct fm_block* qm, unsigned long size,
237
+					char* file, char* func, unsigned int line)
233 238
 #else
234
-void* fm_malloc(struct fm_block* qm, unsigned int size)
239
+void* fm_malloc(struct fm_block* qm, unsigned long size)
235 240
 #endif
236 241
 {
237 242
 	struct fm_frag** f;
... ...
@@ -239,7 +244,7 @@ void* fm_malloc(struct fm_block* qm, unsigned int size)
239 244
 	int hash;
240 245
 	
241 246
 #ifdef DBG_F_MALLOC
242
-	DBG("fm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
247
+	DBG("fm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
243 248
 			line);
244 249
 #endif
245 250
 	/*size must be a multiple of 8*/
... ...
@@ -280,7 +285,7 @@ found:
280 285
 	frag->func=func;
281 286
 	frag->line=line;
282 287
 	frag->check=ST_CHECK_PATTERN;
283
-	DBG("fm_malloc(%p, %d) returns address %p \n", qm, size,
288
+	DBG("fm_malloc(%p, %lu) returns address %p \n", qm, size,
284 289
 		(char*)frag+sizeof(struct fm_frag));
285 290
 #else
286 291
 	fm_split_frag(qm, frag, size);
... ...
@@ -299,7 +304,7 @@ void fm_free(struct fm_block* qm, void* p)
299 304
 #endif
300 305
 {
301 306
 	struct fm_frag* f;
302
-	unsigned int size;
307
+	unsigned long size;
303 308
 
304 309
 #ifdef DBG_F_MALLOC
305 310
 	DBG("fm_free(%p, %p), called from %s: %s(%d)\n", qm, p, file, func, line);
... ...
@@ -332,22 +337,22 @@ void fm_free(struct fm_block* qm, void* p)
332 337
 
333 338
 
334 339
 #ifdef DBG_F_MALLOC
335
-void* fm_realloc(struct fm_block* qm, void* p, unsigned int size,
340
+void* fm_realloc(struct fm_block* qm, void* p, unsigned long size,
336 341
 					char* file, char* func, unsigned int line)
337 342
 #else
338
-void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
343
+void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
339 344
 #endif
340 345
 {
341 346
 	struct fm_frag *f;
342 347
 	struct fm_frag **pf;
343
-	unsigned int diff;
344
-	unsigned int orig_size;
348
+	unsigned long diff;
349
+	unsigned long orig_size;
345 350
 	struct fm_frag *n;
346 351
 	void *ptr;
347 352
 	int hash;
348 353
 	
349 354
 #ifdef DBG_F_MALLOC
350
-	DBG("fm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
355
+	DBG("fm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size,
351 356
 			file, func, line);
352 357
 	if ((p)&&(p>(void*)qm->last_frag || p<(void*)qm->first_frag)){
353 358
 		LOG(L_CRIT, "BUG: fm_free: bad pointer %p (out of memory block!) - "
... ...
@@ -380,7 +385,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
380 385
 	if (f->size > size){
381 386
 		/* shrink */
382 387
 #ifdef DBG_F_MALLOC
383
-		DBG("fm_realloc: shrinking from %ld to %d\n", f->size, size);
388
+		DBG("fm_realloc: shrinking from %lu to %lu\n", f->size, size);
384 389
 		fm_split_frag(qm, f, size, file, "frag. from fm_realloc", line);
385 390
 		qm->real_used-=(orig_size-f->size);
386 391
 		qm->used-=(orig_size-f->size);
... ...
@@ -390,7 +395,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
390 395
 	}else if (f->size<size){
391 396
 		/* grow */
392 397
 #ifdef DBG_F_MALLOC
393
-		DBG("fm_realloc: growing from %ld to %d\n", f->size, size);
398
+		DBG("fm_realloc: growing from %lu to %lu\n", f->size, size);
394 399
 #endif
395 400
 		diff=size-f->size;
396 401
 		n=FRAG_NEXT(f);
... ...
@@ -449,7 +454,8 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
449 454
 	}else{
450 455
 		/* do nothing */
451 456
 #ifdef DBG_F_MALLOC
452
-		DBG("fm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
457
+		DBG("fm_realloc: doing nothing, same size: %lu - %lu\n", 
458
+				f->size, size);
453 459
 #endif
454 460
 	}
455 461
 #ifdef DBG_F_MALLOC
... ...
@@ -466,16 +472,16 @@ void fm_status(struct fm_block* qm)
466 472
 	int i,j;
467 473
 	int h;
468 474
 	int unused;
469
-	long size;
475
+	unsigned long size;
470 476
 
471 477
 	LOG(memlog, "fm_status (%p):\n", qm);
472 478
 	if (!qm) return;
473 479
 
474 480
 	LOG(memlog, " heap size= %ld\n", qm->size);
475 481
 #ifdef DBG_F_MALLOC
476
-	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
482
+	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
477 483
 			qm->used, qm->real_used, qm->size-qm->real_used);
478
-	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
484
+	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
479 485
 #endif
480 486
 	/*
481 487
 	LOG(memlog, "dumping all fragments:\n");
... ...
@@ -499,16 +505,16 @@ void fm_status(struct fm_block* qm)
499 505
 				unused++;
500 506
 #ifdef DBG_FM_MALLOC
501 507
 				LOG(memlog, "unused fragm.: hash = %3d, fragment %x,"
502
-							" address %x size %d, created from %s: %s(%d)\n",
508
+							" address %x size %lu, created from %s: %s(%d)\n",
503 509
 						    h, f, (char*)f+sizeof(struct fm_frag), f->size,
504 510
 							f->file, f->func, f->line);
505 511
 #endif
506 512
 			};
507 513
 		}
508 514
 		if (j) LOG(memlog, "hash = %3d fragments no.: %5d, unused: %5d\n\t\t"
509
-							" bucket size: %9ld - %9ld (first %9ld)\n",
510
-							h, j, unused, (long)UN_HASH(h),
511
-						(long)((h<=F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
515
+							" bucket size: %9lu - %9lu (first %9lu)\n",
516
+							h, j, unused, UN_HASH(h),
517
+						((h<=F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)* UN_HASH(h),
512 518
 							qm->free_hash[h].first->size
513 519
 				);
514 520
 		if (j!=qm->free_hash[h].no){
... ...
@@ -528,7 +534,7 @@ void fm_status(struct fm_block* qm)
528 534
 		}
529 535
 	*/
530 536
 	}
531
-	LOG(memlog, "TOTAL: %6d free fragments = %6ld free bytes\n", i, size);
537
+	LOG(memlog, "TOTAL: %6d free fragments = %6lu free bytes\n", i, size);
532 538
 	LOG(memlog, "-----------------------------\n");
533 539
 }
534 540
 
... ...
@@ -32,6 +32,7 @@
32 32
  *               long longs will be 64 bit aligned) (andrei)
33 33
  *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
34 34
  *               for the future de-fragmentation support (andrei)
35
+ *  2004-11-10  support for > 4Gb mem., switched to long (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -53,14 +54,14 @@
53 54
                       sizeof(fm_frag) must be multiple of ROUNDTO !*/
54 55
 #endif
55 56
 #else /* DBG_F_MALLOC */
56
-	#define ROUNDTO 8
57
+	#define ROUNDTO 8UL
57 58
 #endif
58 59
 #define MIN_FRAG_SIZE	ROUNDTO
59 60
 
60 61
 
61 62
 
62
-#define F_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
63
-#define F_MALLOC_OPTIMIZE  (1<<F_MALLOC_OPTIMIZE_FACTOR)
63
+#define F_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
64
+#define F_MALLOC_OPTIMIZE  (1UL<<F_MALLOC_OPTIMIZE_FACTOR)
64 65
 								/* size to optimize for,
65 66
 									(most allocs <= this size),
66 67
 									must be 2^k */
... ...
@@ -108,13 +109,13 @@ struct fm_block{
108 109
 
109 110
 
110 111
 
111
-struct fm_block* fm_malloc_init(char* address, unsigned int size);
112
+struct fm_block* fm_malloc_init(char* address, unsigned long size);
112 113
 
113 114
 #ifdef DBG_F_MALLOC
114
-void* fm_malloc(struct fm_block*, unsigned int size, char* file, char* func, 
115
-					unsigned int line);
115
+void* fm_malloc(struct fm_block*, unsigned long size,
116
+					char* file, char* func, unsigned int line);
116 117
 #else
117
-void* fm_malloc(struct fm_block*, unsigned int size);
118
+void* fm_malloc(struct fm_block*, unsigned long size);
118 119
 #endif
119 120
 
120 121
 #ifdef DBG_F_MALLOC
... ...
@@ -125,10 +126,10 @@ void  fm_free(struct fm_block*, void* p);
125 126
 #endif
126 127
 
127 128
 #ifdef DBG_F_MALLOC
128
-void*  fm_realloc(struct fm_block*, void* p, unsigned int size, 
129
+void*  fm_realloc(struct fm_block*, void* p, unsigned long size, 
129 130
 					char* file, char* func, unsigned int line);
130 131
 #else
131
-void*  fm_realloc(struct fm_block*, void* p, unsigned int size);
132
+void*  fm_realloc(struct fm_block*, void* p, unsigned long size);
132 133
 #endif
133 134
 
134 135
 void  fm_status(struct fm_block*);
... ...
@@ -90,7 +90,7 @@ int init_shm_mallocs()
90 90
 #ifdef SHM_MEM
91 91
 	if (shm_mem_init()<0) {
92 92
 		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
93
-		 fprintf(stderr, "Too much shared memory demanded: %d\n",
93
+		 fprintf(stderr, "Too much shared memory demanded: %ld\n",
94 94
 			shm_mem_size );
95 95
 		return -1;
96 96
 	}
... ...
@@ -33,6 +33,7 @@
33 33
  *  2004-07-19  fragments book keeping code and support for 64 bits
34 34
  *               memory blocks (64 bits machine & size>=2^32) (andrei)
35 35
  *              GET_HASH s/</<=/ (avoids waste of 1 hash cell) (andrei)
36
+ *  2004-11-10  support for > 4Gb mem., switched to long (andrei)
36 37
  */
37 38
 
38 39
 
... ...
@@ -80,13 +81,15 @@
80 81
 
81 82
 
82 83
 	/* finds the hash value for s, s=ROUNDTO multiple*/
83
-#define GET_HASH(s)   ( ((s)<=QM_MALLOC_OPTIMIZE)?(s)/ROUNDTO: \
84
-						QM_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
85
-							QM_MALLOC_OPTIMIZE_FACTOR+1 )
86
-
87
-#define UN_HASH(h)	( ((h)<=(QM_MALLOC_OPTIMIZE/ROUNDTO))?(h)*ROUNDTO: \
88
-						1<<((h)-QM_MALLOC_OPTIMIZE/ROUNDTO+\
89
-							QM_MALLOC_OPTIMIZE_FACTOR-1)\
84
+#define GET_HASH(s)   ( ((unsigned long)(s)<=QM_MALLOC_OPTIMIZE)?\
85
+							(unsigned long)(s)/ROUNDTO: \
86
+							QM_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
87
+								QM_MALLOC_OPTIMIZE_FACTOR+1 )
88
+
89
+#define UN_HASH(h)	( ((unsigned long)(h)<=(QM_MALLOC_OPTIMIZE/ROUNDTO))?\
90
+							(unsigned long)(h)*ROUNDTO: \
91
+							1UL<<((h)-QM_MALLOC_OPTIMIZE/ROUNDTO+\
92
+								QM_MALLOC_OPTIMIZE_FACTOR-1)\
90 93
 					)
91 94
 
92 95
 
... ...
@@ -104,7 +107,7 @@
104 107
 
105 108
 
106 109
 /* computes hash number for big buckets*/
107
-inline static int big_hash_idx(unsigned long s)
110
+inline static unsigned long big_hash_idx(unsigned long s)
108 111
 {
109 112
 	int idx;
110 113
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
... ...
@@ -180,7 +183,7 @@ static inline void qm_insert_free(struct qm_block* qm, struct qm_frag* frag)
180 183
 
181 184
 
182 185
 /* init malloc and return a qm_block*/
183
-struct qm_block* qm_malloc_init(char* address, unsigned int size)
186
+struct qm_block* qm_malloc_init(char* address, unsigned long size)
184 187
 {
185 188
 	char* start;
186 189
 	char* end;
... ...
@@ -190,11 +193,11 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
190 193
 	
191 194
 	/* make address and size multiple of 8*/
192 195
 	start=(char*)ROUNDUP((unsigned long) address);
193
-	DBG("qm_malloc_init: QM_OPTIMIZE=%ld, /ROUNDTO=%ld\n",
196
+	DBG("qm_malloc_init: QM_OPTIMIZE=%lu, /ROUNDTO=%lu\n",
194 197
 			QM_MALLOC_OPTIMIZE, QM_MALLOC_OPTIMIZE/ROUNDTO);
195
-	DBG("qm_malloc_init: QM_HASH_SIZE=%ld, qm_block size=%d\n",
196
-			QM_HASH_SIZE, (int)sizeof(struct qm_block));
197
-	DBG("qm_malloc_init(%p, %d), start=%p\n", address, size, start);
198
+	DBG("qm_malloc_init: QM_HASH_SIZE=%lu, qm_block size=%lu\n",
199
+			QM_HASH_SIZE, (long)sizeof(struct qm_block));
200
+	DBG("qm_malloc_init(%p, %lu), start=%p\n", address, size, start);
198 201
 	if (size<start-address) return 0;
199 202
 	size-=(start-address);
200 203
 	if (size <(MIN_FRAG_SIZE+FRAG_OVERHEAD)) return 0;
... ...
@@ -202,7 +205,7 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
202 205
 	
203 206
 	init_overhead=ROUNDUP(sizeof(struct qm_block))+sizeof(struct qm_frag)+
204 207
 		sizeof(struct qm_frag_end);
205
-	DBG("qm_malloc_init: size= %d, init_overhead=%ld\n", size, init_overhead);
208
+	DBG("qm_malloc_init: size= %lu, init_overhead=%lu\n", size, init_overhead);
206 209
 	
207 210
 	if (size < init_overhead)
208 211
 	{
... ...
@@ -266,12 +269,12 @@ static inline void qm_detach_free(struct qm_block* qm, struct qm_frag* frag)
266 269
 
267 270
 #ifdef DBG_QM_MALLOC
268 271
 static inline struct qm_frag* qm_find_free(struct qm_block* qm, 
269
-											unsigned int size,
272
+											unsigned long size,
270 273
 											int *h,
271 274
 											unsigned int *count)
272 275
 #else
273 276
 static inline struct qm_frag* qm_find_free(struct qm_block* qm, 
274
-											unsigned int size,
277
+											unsigned long size,
275 278
 											int* h)
276 279
 #endif
277 280
 {
... ...
@@ -297,13 +300,13 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm,
297 300
  * new_size < size & rounded-up already!*/
298 301
 static inline
299 302
 #ifdef DBG_QM_MALLOC
300
-int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size,
303
+int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned long new_size,
301 304
 				char* file, char* func, unsigned int line)
302 305
 #else
303
-int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size)
306
+int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned long new_size)
304 307
 #endif
305 308
 {
306
-	unsigned int rest;
309
+	unsigned long rest;
307 310
 	struct qm_frag* n;
308 311
 	struct qm_frag_end* end;
309 312
 	
... ...
@@ -344,10 +347,10 @@ int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size)
344 347
 
345 348
 
346 349
 #ifdef DBG_QM_MALLOC
347
-void* qm_malloc(struct qm_block* qm, unsigned int size, char* file, char* func,
348
-					unsigned int line)
350
+void* qm_malloc(struct qm_block* qm, unsigned long size,
351
+					char* file, char* func, unsigned int line)
349 352
 #else
350
-void* qm_malloc(struct qm_block* qm, unsigned int size)
353
+void* qm_malloc(struct qm_block* qm, unsigned long size)
351 354
 #endif
352 355
 {
353 356
 	struct qm_frag* f;
... ...
@@ -357,7 +360,7 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
357 360
 	unsigned int list_cntr;
358 361
 
359 362
 	list_cntr = 0;
360
-	DBG("qm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
363
+	DBG("qm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
361 364
 			line);
362 365
 #endif
363 366
 	/*size must be a multiple of 8*/
... ...
@@ -396,8 +399,8 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
396 399
 		f->check=ST_CHECK_PATTERN;
397 400
 		/*  FRAG_END(f)->check1=END_CHECK_PATTERN1;
398 401
 			FRAG_END(f)->check2=END_CHECK_PATTERN2;*/
399
-		DBG("qm_malloc(%p, %d) returns address %p frag. %p (size=%ld) on %d -th"
400
-				" hit\n",
402
+		DBG("qm_malloc(%p, %lu) returns address %p frag. %p (size=%lu) on %d"
403
+				" -th hit\n",
401 404
 			 qm, size, (char*)f+sizeof(struct qm_frag), f, f->size, list_cntr );
402 405
 #endif
403 406
 		return (char*)f+sizeof(struct qm_frag);
... ...
@@ -492,21 +495,21 @@ void qm_free(struct qm_block* qm, void* p)
492 495
 
493 496
 
494 497
 #ifdef DBG_QM_MALLOC
495
-void* qm_realloc(struct qm_block* qm, void* p, unsigned int size,
498
+void* qm_realloc(struct qm_block* qm, void* p, unsigned long size,
496 499
 					char* file, char* func, unsigned int line)
497 500
 #else
498
-void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
501
+void* qm_realloc(struct qm_block* qm, void* p, unsigned long size)
499 502
 #endif
500 503
 {
501 504
 	struct qm_frag* f;
502
-	unsigned int diff;
503
-	unsigned int orig_size;
505
+	unsigned long diff;
506
+	unsigned long orig_size;
504 507
 	struct qm_frag* n;
505 508
 	void* ptr;
506 509
 	
507 510
 	
508 511
 #ifdef DBG_QM_MALLOC
509
-	DBG("qm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
512
+	DBG("qm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size,
510 513
 			file, func, line);
511 514
 	if ((p)&&(p>(void*)qm->last_frag_end || p<(void*)qm->first_frag)){
512 515
 		LOG(L_CRIT, "BUG: qm_free: bad pointer %p (out of memory block!) - "
... ...
@@ -546,7 +549,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
546 549
 	if (f->size > size){
547 550
 		/* shrink */
548 551
 #ifdef DBG_QM_MALLOC
549
-		DBG("qm_realloc: shrinking from %ld to %d\n", f->size, size);
552
+		DBG("qm_realloc: shrinking from %lu to %lu\n", f->size, size);
550 553
 		if(split_frag(qm, f, size, file, "fragm. from qm_realloc", line)!=0){
551 554
 		DBG("qm_realloc : shrinked successful\n");
552 555
 #else
... ...
@@ -560,7 +563,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
560 563
 	}else if (f->size < size){
561 564
 		/* grow */
562 565
 #ifdef DBG_QM_MALLOC
563
-		DBG("qm_realloc: growing from %ld to %d\n", f->size, size);
566
+		DBG("qm_realloc: growing from %lu to %lu\n", f->size, size);
564 567
 #endif
565 568
 			orig_size=f->size;
566 569
 			diff=size-f->size;
... ...
@@ -605,7 +608,8 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
605 608
 	}else{
606 609
 		/* do nothing */
607 610
 #ifdef DBG_QM_MALLOC
608
-		DBG("qm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
611
+		DBG("qm_realloc: doing nothing, same size: %lu - %lu\n",
612
+				f->size, size);
609 613
 #endif
610 614
 	}
611 615
 #ifdef DBG_QM_MALLOC
... ...
@@ -627,16 +631,16 @@ void qm_status(struct qm_block* qm)
627 631
 	LOG(memlog, "qm_status (%p):\n", qm);
628 632
 	if (!qm) return;
629 633
 
630
-	LOG(memlog, " heap size= %ld\n", qm->size);
631
-	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
634
+	LOG(memlog, " heap size= %lu\n", qm->size);
635
+	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
632 636
 			qm->used, qm->real_used, qm->size-qm->real_used);
633
-	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
637
+	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
634 638
 	
635 639
 	LOG(memlog, "dumping all alloc'ed. fragments:\n");
636 640
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
637 641
 			,i++){
638 642
 		if (! f->u.is_free){
639
-			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%ld used=%d\n",
643
+			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%lu used=%d\n",
640 644
 				i, 
641 645
 				(f->u.is_free)?'a':'N',
642 646
 				(char*)f+sizeof(struct qm_frag), f, f->size, FRAG_WAS_USED(f));
... ...
@@ -665,9 +669,9 @@ void qm_status(struct qm_block* qm)
665 669
 		}
666 670
 
667 671
 		if (j) LOG(memlog, "hash= %3d. fragments no.: %5d, unused: %5d\n"
668
-					"\t\t bucket size: %9ld - %9ld (first %9ld)\n",
669
-					h, j, unused, (long)UN_HASH(h),
670
-					(long)((h<=QM_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
672
+					"\t\t bucket size: %9lu - %9ld (first %9lu)\n",
673
+					h, j, unused, UN_HASH(h),
674
+					((h<=QM_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
671 675
 					qm->free_hash[h].head.u.nxt_free->size
672 676
 				);
673 677
 		if (j!=qm->free_hash[h].no){
... ...
@@ -32,6 +32,7 @@
32 32
  *               long longs will be 64 bit aligned) (andrei)
33 33
  *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
34 34
  *               for the future de-fragmentation support (andrei)
35
+ *  2004-11-10  support for > 4Gb mem. (switched to long) (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -52,7 +53,7 @@
52 53
 										 debugging*/
53 54
 #endif 
54 55
 #else /* DBG_QM_MALLOC */
55
-	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
56
+	#define ROUNDTO		16UL /* size we round to, must be = 2^n  and also
56 57
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
57 58
 							 must be multiple of ROUNDTO!
58 59
 						   */
... ...
@@ -61,8 +62,8 @@
61 62
 
62 63
 
63 64
 
64
-#define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
65
-#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
65
+#define QM_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
66
+#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1UL<<QM_MALLOC_OPTIMIZE_FACTOR))
66 67
 								/* size to optimize for,
67 68
 									(most allocs <= this size),
68 69
 									must be 2^k */
... ...
@@ -124,13 +125,13 @@ struct qm_block{
124 125
 
125 126
 
126 127
 
127
-struct qm_block* qm_malloc_init(char* address, unsigned int size);
128
+struct qm_block* qm_malloc_init(char* address, unsigned long size);
128 129
 
129 130
 #ifdef DBG_QM_MALLOC
130
-void* qm_malloc(struct qm_block*, unsigned int size, char* file, char* func, 
131
+void* qm_malloc(struct qm_block*, unsigned long size, char* file, char* func, 
131 132
 					unsigned int line);
132 133
 #else
133
-void* qm_malloc(struct qm_block*, unsigned int size);
134
+void* qm_malloc(struct qm_block*, unsigned long size);
134 135
 #endif
135 136
 
136 137
 #ifdef DBG_QM_MALLOC
... ...
@@ -140,10 +141,10 @@ void  qm_free(struct qm_block*, void* p, char* file, char* func,
140 141
 void  qm_free(struct qm_block*, void* p);
141 142
 #endif
142 143
 #ifdef DBG_QM_MALLOC
143
-void* qm_realloc(struct qm_block*, void* p, unsigned int size,
144
+void* qm_realloc(struct qm_block*, void* p, unsigned long size,
144 145
 				char* file, char* func, unsigned int line);
145 146
 #else
146
-void* qm_realloc(struct qm_block*, void* p, unsigned int size);
147
+void* qm_realloc(struct qm_block*, void* p, unsigned long size);
147 148
 #endif
148 149
 
149 150
 void  qm_status(struct qm_block*);
... ...
@@ -178,7 +178,7 @@ int shm_getmem()
178 178
 
179 179
 
180 180
 
181
-int shm_mem_init_mallocs(void* mempool, int pool_size)
181
+int shm_mem_init_mallocs(void* mempool, unsigned long pool_size)
182 182
 {
183 183
 	/* init it for malloc*/
184 184
 	shm_block=shm_malloc_init(mempool, pool_size);
... ...
@@ -91,8 +91,9 @@
91 91
 
92 92
 int shm_mem_init(); /* calls shm_getmem & shm_mem_init_mallocs */
93 93
 int shm_getmem();   /* allocates the memory (mmap or sysv shmap) */
94
-int shm_mem_init_mallocs(void* mempool, int size); /* initialized the mallocs
95
-													  & the lock */
94
+int shm_mem_init_mallocs(void* mempool, unsigned long size); /* initialize
95
+																the mallocs
96
+																& the lock */
96 97
 void shm_mem_destroy();
97 98
 
98 99
 
... ...
@@ -47,7 +47,7 @@ int log_stderr=1;
47 47
 int debug=0;
48 48
 int pids[1];
49 49
 int process_no=0;
50
-int shm_mem_size=0;
50
+long shm_mem_size=0;
51 51
 char mem_pool[1024*1024];
52 52
 struct qm_block* mem_block;
53 53