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 66
 
67 67
 
68 68
 	/* 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+\
69
+#define GET_HASH(s)   ( ((unsigned long)(s)<=F_MALLOC_OPTIMIZE)?\
70
+							(unsigned long)(s)/ROUNDTO: \
71
+							F_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
72
+								F_MALLOC_OPTIMIZE_FACTOR+1 )
73
+
74
+#define UN_HASH(h)	( ((unsigned long)(h)<=(F_MALLOC_OPTIMIZE/ROUNDTO))?\
75
+						(unsigned long)(h)*ROUNDTO: \
76
+						1UL<<((unsigned long)(h)-F_MALLOC_OPTIMIZE/ROUNDTO+\
75 77
 							F_MALLOC_OPTIMIZE_FACTOR-1)\
76 78
 					)
77 79
 
... ...
@@ -88,9 +91,9 @@
88 88
 
89 89
 
90 90
 /* computes hash number for big buckets*/
91
-inline static int big_hash_idx(unsigned long s)
91
+inline static unsigned long big_hash_idx(unsigned long s)
92 92
 {
93
-	int idx;
93
+	unsigned long idx;
94 94
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
95 95
 	 * index= i such that 2^i > s >= 2^(i-1)
96 96
 	 *
... ...
@@ -135,13 +138,15 @@ static inline void fm_insert_free(struct fm_block* qm, struct fm_frag* frag)
135 135
  /* size should be already rounded-up */
136 136
 static inline
137 137
 #ifdef DBG_F_MALLOC 
138
-void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size,
138
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
139
+					unsigned long size,
139 140
 					char* file, char* func, unsigned int line)
140 141
 #else
141
-void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
142
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
143
+					unsigned long size)
142 144
 #endif
143 145
 {
144
-	unsigned int rest;
146
+	unsigned long rest;
145 147
 	struct fm_frag* n;
146 148
 	
147 149
 	rest=frag->size-size;
... ...
@@ -174,12 +179,12 @@ void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
174 174
 
175 175
 
176 176
 /* init malloc and return a fm_block*/
177
-struct fm_block* fm_malloc_init(char* address, unsigned int size)
177
+struct fm_block* fm_malloc_init(char* address, unsigned long size)
178 178
 {
179 179
 	char* start;
180 180
 	char* end;
181 181
 	struct fm_block* qm;
182
-	unsigned int init_overhead;
182
+	unsigned long init_overhead;
183 183
 	
184 184
 	/* make address and size multiple of 8*/
185 185
 	start=(char*)ROUNDUP((unsigned long) address);
... ...
@@ -228,10 +233,10 @@ struct fm_block* fm_malloc_init(char* address, unsigned int size)
228 228
 
229 229
 
230 230
 #ifdef DBG_F_MALLOC
231
-void* fm_malloc(struct fm_block* qm, unsigned int size, char* file, char* func,
232
-					unsigned int line)
231
+void* fm_malloc(struct fm_block* qm, unsigned long size,
232
+					char* file, char* func, unsigned int line)
233 233
 #else
234
-void* fm_malloc(struct fm_block* qm, unsigned int size)
234
+void* fm_malloc(struct fm_block* qm, unsigned long size)
235 235
 #endif
236 236
 {
237 237
 	struct fm_frag** f;
... ...
@@ -239,7 +244,7 @@ void* fm_malloc(struct fm_block* qm, unsigned int size)
239 239
 	int hash;
240 240
 	
241 241
 #ifdef DBG_F_MALLOC
242
-	DBG("fm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
242
+	DBG("fm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
243 243
 			line);
244 244
 #endif
245 245
 	/*size must be a multiple of 8*/
... ...
@@ -280,7 +285,7 @@ found:
280 280
 	frag->func=func;
281 281
 	frag->line=line;
282 282
 	frag->check=ST_CHECK_PATTERN;
283
-	DBG("fm_malloc(%p, %d) returns address %p \n", qm, size,
283
+	DBG("fm_malloc(%p, %lu) returns address %p \n", qm, size,
284 284
 		(char*)frag+sizeof(struct fm_frag));
285 285
 #else
286 286
 	fm_split_frag(qm, frag, size);
... ...
@@ -299,7 +304,7 @@ void fm_free(struct fm_block* qm, void* p)
299 299
 #endif
300 300
 {
301 301
 	struct fm_frag* f;
302
-	unsigned int size;
302
+	unsigned long size;
303 303
 
304 304
 #ifdef DBG_F_MALLOC
305 305
 	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 332
 
333 333
 
334 334
 #ifdef DBG_F_MALLOC
335
-void* fm_realloc(struct fm_block* qm, void* p, unsigned int size,
335
+void* fm_realloc(struct fm_block* qm, void* p, unsigned long size,
336 336
 					char* file, char* func, unsigned int line)
337 337
 #else
338
-void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
338
+void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
339 339
 #endif
340 340
 {
341 341
 	struct fm_frag *f;
342 342
 	struct fm_frag **pf;
343
-	unsigned int diff;
344
-	unsigned int orig_size;
343
+	unsigned long diff;
344
+	unsigned long orig_size;
345 345
 	struct fm_frag *n;
346 346
 	void *ptr;
347 347
 	int hash;
348 348
 	
349 349
 #ifdef DBG_F_MALLOC
350
-	DBG("fm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
350
+	DBG("fm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size,
351 351
 			file, func, line);
352 352
 	if ((p)&&(p>(void*)qm->last_frag || p<(void*)qm->first_frag)){
353 353
 		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 380
 	if (f->size > size){
381 381
 		/* shrink */
382 382
 #ifdef DBG_F_MALLOC
383
-		DBG("fm_realloc: shrinking from %ld to %d\n", f->size, size);
383
+		DBG("fm_realloc: shrinking from %lu to %lu\n", f->size, size);
384 384
 		fm_split_frag(qm, f, size, file, "frag. from fm_realloc", line);
385 385
 		qm->real_used-=(orig_size-f->size);
386 386
 		qm->used-=(orig_size-f->size);
... ...
@@ -390,7 +395,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
390 390
 	}else if (f->size<size){
391 391
 		/* grow */
392 392
 #ifdef DBG_F_MALLOC
393
-		DBG("fm_realloc: growing from %ld to %d\n", f->size, size);
393
+		DBG("fm_realloc: growing from %lu to %lu\n", f->size, size);
394 394
 #endif
395 395
 		diff=size-f->size;
396 396
 		n=FRAG_NEXT(f);
... ...
@@ -449,7 +454,8 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
449 449
 	}else{
450 450
 		/* do nothing */
451 451
 #ifdef DBG_F_MALLOC
452
-		DBG("fm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
452
+		DBG("fm_realloc: doing nothing, same size: %lu - %lu\n", 
453
+				f->size, size);
453 454
 #endif
454 455
 	}
455 456
 #ifdef DBG_F_MALLOC
... ...
@@ -466,16 +472,16 @@ void fm_status(struct fm_block* qm)
466 466
 	int i,j;
467 467
 	int h;
468 468
 	int unused;
469
-	long size;
469
+	unsigned long size;
470 470
 
471 471
 	LOG(memlog, "fm_status (%p):\n", qm);
472 472
 	if (!qm) return;
473 473
 
474 474
 	LOG(memlog, " heap size= %ld\n", qm->size);
475 475
 #ifdef DBG_F_MALLOC
476
-	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
476
+	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
477 477
 			qm->used, qm->real_used, qm->size-qm->real_used);
478
-	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
478
+	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
479 479
 #endif
480 480
 	/*
481 481
 	LOG(memlog, "dumping all fragments:\n");
... ...
@@ -499,16 +505,16 @@ void fm_status(struct fm_block* qm)
499 499
 				unused++;
500 500
 #ifdef DBG_FM_MALLOC
501 501
 				LOG(memlog, "unused fragm.: hash = %3d, fragment %x,"
502
-							" address %x size %d, created from %s: %s(%d)\n",
502
+							" address %x size %lu, created from %s: %s(%d)\n",
503 503
 						    h, f, (char*)f+sizeof(struct fm_frag), f->size,
504 504
 							f->file, f->func, f->line);
505 505
 #endif
506 506
 			};
507 507
 		}
508 508
 		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),
509
+							" bucket size: %9lu - %9lu (first %9lu)\n",
510
+							h, j, unused, UN_HASH(h),
511
+						((h<=F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)* UN_HASH(h),
512 512
 							qm->free_hash[h].first->size
513 513
 				);
514 514
 		if (j!=qm->free_hash[h].no){
... ...
@@ -528,7 +534,7 @@ void fm_status(struct fm_block* qm)
528 528
 		}
529 529
 	*/
530 530
 	}
531
-	LOG(memlog, "TOTAL: %6d free fragments = %6ld free bytes\n", i, size);
531
+	LOG(memlog, "TOTAL: %6d free fragments = %6lu free bytes\n", i, size);
532 532
 	LOG(memlog, "-----------------------------\n");
533 533
 }
534 534
 
... ...
@@ -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 53
                       sizeof(fm_frag) must be multiple of ROUNDTO !*/
54 54
 #endif
55 55
 #else /* DBG_F_MALLOC */
56
-	#define ROUNDTO 8
56
+	#define ROUNDTO 8UL
57 57
 #endif
58 58
 #define MIN_FRAG_SIZE	ROUNDTO
59 59
 
60 60
 
61 61
 
62
-#define F_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
63
-#define F_MALLOC_OPTIMIZE  (1<<F_MALLOC_OPTIMIZE_FACTOR)
62
+#define F_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
63
+#define F_MALLOC_OPTIMIZE  (1UL<<F_MALLOC_OPTIMIZE_FACTOR)
64 64
 								/* size to optimize for,
65 65
 									(most allocs <= this size),
66 66
 									must be 2^k */
... ...
@@ -108,13 +109,13 @@ struct fm_block{
108 108
 
109 109
 
110 110
 
111
-struct fm_block* fm_malloc_init(char* address, unsigned int size);
111
+struct fm_block* fm_malloc_init(char* address, unsigned long size);
112 112
 
113 113
 #ifdef DBG_F_MALLOC
114
-void* fm_malloc(struct fm_block*, unsigned int size, char* file, char* func, 
115
-					unsigned int line);
114
+void* fm_malloc(struct fm_block*, unsigned long size,
115
+					char* file, char* func, unsigned int line);
116 116
 #else
117
-void* fm_malloc(struct fm_block*, unsigned int size);
117
+void* fm_malloc(struct fm_block*, unsigned long size);
118 118
 #endif
119 119
 
120 120
 #ifdef DBG_F_MALLOC
... ...
@@ -125,10 +126,10 @@ void  fm_free(struct fm_block*, void* p);
125 125
 #endif
126 126
 
127 127
 #ifdef DBG_F_MALLOC
128
-void*  fm_realloc(struct fm_block*, void* p, unsigned int size, 
128
+void*  fm_realloc(struct fm_block*, void* p, unsigned long size, 
129 129
 					char* file, char* func, unsigned int line);
130 130
 #else
131
-void*  fm_realloc(struct fm_block*, void* p, unsigned int size);
131
+void*  fm_realloc(struct fm_block*, void* p, unsigned long size);
132 132
 #endif
133 133
 
134 134
 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 80
 
81 81
 
82 82
 	/* 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)\
83
+#define GET_HASH(s)   ( ((unsigned long)(s)<=QM_MALLOC_OPTIMIZE)?\
84
+							(unsigned long)(s)/ROUNDTO: \
85
+							QM_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
86
+								QM_MALLOC_OPTIMIZE_FACTOR+1 )
87
+
88
+#define UN_HASH(h)	( ((unsigned long)(h)<=(QM_MALLOC_OPTIMIZE/ROUNDTO))?\
89
+							(unsigned long)(h)*ROUNDTO: \
90
+							1UL<<((h)-QM_MALLOC_OPTIMIZE/ROUNDTO+\
91
+								QM_MALLOC_OPTIMIZE_FACTOR-1)\
90 92
 					)
91 93
 
92 94
 
... ...
@@ -104,7 +107,7 @@
104 104
 
105 105
 
106 106
 /* computes hash number for big buckets*/
107
-inline static int big_hash_idx(unsigned long s)
107
+inline static unsigned long big_hash_idx(unsigned long s)
108 108
 {
109 109
 	int idx;
110 110
 	/* 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 180
 
181 181
 
182 182
 /* init malloc and return a qm_block*/
183
-struct qm_block* qm_malloc_init(char* address, unsigned int size)
183
+struct qm_block* qm_malloc_init(char* address, unsigned long size)
184 184
 {
185 185
 	char* start;
186 186
 	char* end;
... ...
@@ -190,11 +193,11 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
190 190
 	
191 191
 	/* make address and size multiple of 8*/
192 192
 	start=(char*)ROUNDUP((unsigned long) address);
193
-	DBG("qm_malloc_init: QM_OPTIMIZE=%ld, /ROUNDTO=%ld\n",
193
+	DBG("qm_malloc_init: QM_OPTIMIZE=%lu, /ROUNDTO=%lu\n",
194 194
 			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);
195
+	DBG("qm_malloc_init: QM_HASH_SIZE=%lu, qm_block size=%lu\n",
196
+			QM_HASH_SIZE, (long)sizeof(struct qm_block));
197
+	DBG("qm_malloc_init(%p, %lu), start=%p\n", address, size, start);
198 198
 	if (size<start-address) return 0;
199 199
 	size-=(start-address);
200 200
 	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 202
 	
203 203
 	init_overhead=ROUNDUP(sizeof(struct qm_block))+sizeof(struct qm_frag)+
204 204
 		sizeof(struct qm_frag_end);
205
-	DBG("qm_malloc_init: size= %d, init_overhead=%ld\n", size, init_overhead);
205
+	DBG("qm_malloc_init: size= %lu, init_overhead=%lu\n", size, init_overhead);
206 206
 	
207 207
 	if (size < init_overhead)
208 208
 	{
... ...
@@ -266,12 +269,12 @@ static inline void qm_detach_free(struct qm_block* qm, struct qm_frag* frag)
266 266
 
267 267
 #ifdef DBG_QM_MALLOC
268 268
 static inline struct qm_frag* qm_find_free(struct qm_block* qm, 
269
-											unsigned int size,
269
+											unsigned long size,
270 270
 											int *h,
271 271
 											unsigned int *count)
272 272
 #else
273 273
 static inline struct qm_frag* qm_find_free(struct qm_block* qm, 
274
-											unsigned int size,
274
+											unsigned long size,
275 275
 											int* h)
276 276
 #endif
277 277
 {
... ...
@@ -297,13 +300,13 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm,
297 297
  * new_size < size & rounded-up already!*/
298 298
 static inline
299 299
 #ifdef DBG_QM_MALLOC
300
-int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size,
300
+int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned long new_size,
301 301
 				char* file, char* func, unsigned int line)
302 302
 #else
303
-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)
304 304
 #endif
305 305
 {
306
-	unsigned int rest;
306
+	unsigned long rest;
307 307
 	struct qm_frag* n;
308 308
 	struct qm_frag_end* end;
309 309
 	
... ...
@@ -344,10 +347,10 @@ int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size)
344 344
 
345 345
 
346 346
 #ifdef DBG_QM_MALLOC
347
-void* qm_malloc(struct qm_block* qm, unsigned int size, char* file, char* func,
348
-					unsigned int line)
347
+void* qm_malloc(struct qm_block* qm, unsigned long size,
348
+					char* file, char* func, unsigned int line)
349 349
 #else
350
-void* qm_malloc(struct qm_block* qm, unsigned int size)
350
+void* qm_malloc(struct qm_block* qm, unsigned long size)
351 351
 #endif
352 352
 {
353 353
 	struct qm_frag* f;
... ...
@@ -357,7 +360,7 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
357 357
 	unsigned int list_cntr;
358 358
 
359 359
 	list_cntr = 0;
360
-	DBG("qm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
360
+	DBG("qm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
361 361
 			line);
362 362
 #endif
363 363
 	/*size must be a multiple of 8*/
... ...
@@ -396,8 +399,8 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
396 396
 		f->check=ST_CHECK_PATTERN;
397 397
 		/*  FRAG_END(f)->check1=END_CHECK_PATTERN1;
398 398
 			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",
399
+		DBG("qm_malloc(%p, %lu) returns address %p frag. %p (size=%lu) on %d"
400
+				" -th hit\n",
401 401
 			 qm, size, (char*)f+sizeof(struct qm_frag), f, f->size, list_cntr );
402 402
 #endif
403 403
 		return (char*)f+sizeof(struct qm_frag);
... ...
@@ -492,21 +495,21 @@ void qm_free(struct qm_block* qm, void* p)
492 492
 
493 493
 
494 494
 #ifdef DBG_QM_MALLOC
495
-void* qm_realloc(struct qm_block* qm, void* p, unsigned int size,
495
+void* qm_realloc(struct qm_block* qm, void* p, unsigned long size,
496 496
 					char* file, char* func, unsigned int line)
497 497
 #else
498
-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)
499 499
 #endif
500 500
 {
501 501
 	struct qm_frag* f;
502
-	unsigned int diff;
503
-	unsigned int orig_size;
502
+	unsigned long diff;
503
+	unsigned long orig_size;
504 504
 	struct qm_frag* n;
505 505
 	void* ptr;
506 506
 	
507 507
 	
508 508
 #ifdef DBG_QM_MALLOC
509
-	DBG("qm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
509
+	DBG("qm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size,
510 510
 			file, func, line);
511 511
 	if ((p)&&(p>(void*)qm->last_frag_end || p<(void*)qm->first_frag)){
512 512
 		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 546
 	if (f->size > size){
547 547
 		/* shrink */
548 548
 #ifdef DBG_QM_MALLOC
549
-		DBG("qm_realloc: shrinking from %ld to %d\n", f->size, size);
549
+		DBG("qm_realloc: shrinking from %lu to %lu\n", f->size, size);
550 550
 		if(split_frag(qm, f, size, file, "fragm. from qm_realloc", line)!=0){
551 551
 		DBG("qm_realloc : shrinked successful\n");
552 552
 #else
... ...
@@ -560,7 +563,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
560 560
 	}else if (f->size < size){
561 561
 		/* grow */
562 562
 #ifdef DBG_QM_MALLOC
563
-		DBG("qm_realloc: growing from %ld to %d\n", f->size, size);
563
+		DBG("qm_realloc: growing from %lu to %lu\n", f->size, size);
564 564
 #endif
565 565
 			orig_size=f->size;
566 566
 			diff=size-f->size;
... ...
@@ -605,7 +608,8 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
605 605
 	}else{
606 606
 		/* do nothing */
607 607
 #ifdef DBG_QM_MALLOC
608
-		DBG("qm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
608
+		DBG("qm_realloc: doing nothing, same size: %lu - %lu\n",
609
+				f->size, size);
609 610
 #endif
610 611
 	}
611 612
 #ifdef DBG_QM_MALLOC
... ...
@@ -627,16 +631,16 @@ void qm_status(struct qm_block* qm)
627 627
 	LOG(memlog, "qm_status (%p):\n", qm);
628 628
 	if (!qm) return;
629 629
 
630
-	LOG(memlog, " heap size= %ld\n", qm->size);
631
-	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
630
+	LOG(memlog, " heap size= %lu\n", qm->size);
631
+	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
632 632
 			qm->used, qm->real_used, qm->size-qm->real_used);
633
-	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
633
+	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
634 634
 	
635 635
 	LOG(memlog, "dumping all alloc'ed. fragments:\n");
636 636
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
637 637
 			,i++){
638 638
 		if (! f->u.is_free){
639
-			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%ld used=%d\n",
639
+			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%lu used=%d\n",
640 640
 				i, 
641 641
 				(f->u.is_free)?'a':'N',
642 642
 				(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 665
 		}
666 666
 
667 667
 		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),
668
+					"\t\t bucket size: %9lu - %9ld (first %9lu)\n",
669
+					h, j, unused, UN_HASH(h),
670
+					((h<=QM_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
671 671
 					qm->free_hash[h].head.u.nxt_free->size
672 672
 				);
673 673
 		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 52
 										 debugging*/
53 53
 #endif 
54 54
 #else /* DBG_QM_MALLOC */
55
-	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
55
+	#define ROUNDTO		16UL /* size we round to, must be = 2^n  and also
56 56
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
57 57
 							 must be multiple of ROUNDTO!
58 58
 						   */
... ...
@@ -61,8 +62,8 @@
61 61
 
62 62
 
63 63
 
64
-#define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
65
-#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
64
+#define QM_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
65
+#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1UL<<QM_MALLOC_OPTIMIZE_FACTOR))
66 66
 								/* size to optimize for,
67 67
 									(most allocs <= this size),
68 68
 									must be 2^k */
... ...
@@ -124,13 +125,13 @@ struct qm_block{
124 124
 
125 125
 
126 126
 
127
-struct qm_block* qm_malloc_init(char* address, unsigned int size);
127
+struct qm_block* qm_malloc_init(char* address, unsigned long size);
128 128
 
129 129
 #ifdef DBG_QM_MALLOC
130
-void* qm_malloc(struct qm_block*, unsigned int size, char* file, char* func, 
130
+void* qm_malloc(struct qm_block*, unsigned long size, char* file, char* func, 
131 131
 					unsigned int line);
132 132
 #else
133
-void* qm_malloc(struct qm_block*, unsigned int size);
133
+void* qm_malloc(struct qm_block*, unsigned long size);
134 134
 #endif
135 135
 
136 136
 #ifdef DBG_QM_MALLOC
... ...
@@ -140,10 +141,10 @@ void  qm_free(struct qm_block*, void* p, char* file, char* func,
140 140
 void  qm_free(struct qm_block*, void* p);
141 141
 #endif
142 142
 #ifdef DBG_QM_MALLOC
143
-void* qm_realloc(struct qm_block*, void* p, unsigned int size,
143
+void* qm_realloc(struct qm_block*, void* p, unsigned long size,
144 144
 				char* file, char* func, unsigned int line);
145 145
 #else
146
-void* qm_realloc(struct qm_block*, void* p, unsigned int size);
146
+void* qm_realloc(struct qm_block*, void* p, unsigned long size);
147 147
 #endif
148 148
 
149 149
 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