2
0
Эх сурвалжийг харах

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

Andrei Pelinescu-Onciul 21 жил өмнө
parent
commit
c082177a92
11 өөрчлөгдсөн 114 нэмэгдсэн , 101 устгасан
  1. 1 1
      Makefile.defs
  2. 1 1
      globals.h
  3. 2 2
      main.c
  4. 41 35
      mem/f_malloc.c
  5. 10 9
      mem/f_malloc.h
  6. 1 1
      mem/mem.c
  7. 44 40
      mem/q_malloc.c
  8. 9 8
      mem/q_malloc.h
  9. 1 1
      mem/shm_mem.c
  10. 3 2
      mem/shm_mem.h
  11. 1 1
      test/dns_query.c

+ 1 - 1
Makefile.defs

@@ -50,7 +50,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL =   99
-EXTRAVERSION = -dev13
+EXTRAVERSION = -dev14
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 1 - 1
globals.h

@@ -116,7 +116,7 @@ extern int mcast_ttl;
 extern int cfg_errors;
 extern unsigned int msg_no;
 
-extern unsigned int shm_mem_size;
+extern unsigned long shm_mem_size;
 
 /* FIFO server config */
 char extern *fifo; /* FIFO name */

+ 2 - 2
main.c

@@ -322,7 +322,7 @@ int process_no = 0;
 int cfg_errors=0;
 
 /* shared memory (in MB) */
-unsigned int shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
+unsigned long shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
 
 /* export command-line to anywhere else */
 int my_argc;
@@ -1120,7 +1120,7 @@ int main(int argc, char** argv)
 										optarg);
 						goto error;
 					};
-					LOG(L_INFO, "ser: shared memory allocated: %d MByte\n",
+					LOG(L_INFO, "ser: shared memory: %ld bytes\n",
 									shm_mem_size );
 					break;
 

+ 41 - 35
mem/f_malloc.c

@@ -32,6 +32,7 @@
  *  2004-07-19  fragments book keeping code and support for 64 bits
  *               memory blocks (64 bits machine & size >=2^32) 
  *              GET_HASH s/</<=/ (avoids waste of 1 hash cell)   (andrei)
+ *  2004-11-10  support for > 4Gb mem., switched to long (andrei)
  */
 
 
@@ -66,12 +67,14 @@
 
 
 	/* finds the hash value for s, s=ROUNDTO multiple*/
-#define GET_HASH(s)   ( ((s)<=F_MALLOC_OPTIMIZE)?(s)/ROUNDTO: \
-						F_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
-							F_MALLOC_OPTIMIZE_FACTOR+1 )
-
-#define UN_HASH(h)	( ((h)<=(F_MALLOC_OPTIMIZE/ROUNDTO))?(h)*ROUNDTO: \
-						1<<((h)-F_MALLOC_OPTIMIZE/ROUNDTO+\
+#define GET_HASH(s)   ( ((unsigned long)(s)<=F_MALLOC_OPTIMIZE)?\
+							(unsigned long)(s)/ROUNDTO: \
+							F_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
+								F_MALLOC_OPTIMIZE_FACTOR+1 )
+
+#define UN_HASH(h)	( ((unsigned long)(h)<=(F_MALLOC_OPTIMIZE/ROUNDTO))?\
+						(unsigned long)(h)*ROUNDTO: \
+						1UL<<((unsigned long)(h)-F_MALLOC_OPTIMIZE/ROUNDTO+\
 							F_MALLOC_OPTIMIZE_FACTOR-1)\
 					)
 
@@ -88,9 +91,9 @@
 
 
 /* computes hash number for big buckets*/
-inline static int big_hash_idx(unsigned long s)
+inline static unsigned long big_hash_idx(unsigned long s)
 {
-	int idx;
+	unsigned long idx;
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
 	 * index= i such that 2^i > s >= 2^(i-1)
 	 *
@@ -135,13 +138,15 @@ static inline void fm_insert_free(struct fm_block* qm, struct fm_frag* frag)
  /* size should be already rounded-up */
 static inline
 #ifdef DBG_F_MALLOC 
-void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size,
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
+					unsigned long size,
 					char* file, char* func, unsigned int line)
 #else
-void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
+void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
+					unsigned long size)
 #endif
 {
-	unsigned int rest;
+	unsigned long rest;
 	struct fm_frag* n;
 	
 	rest=frag->size-size;
@@ -174,12 +179,12 @@ void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,unsigned int size)
 
 
 /* init malloc and return a fm_block*/
-struct fm_block* fm_malloc_init(char* address, unsigned int size)
+struct fm_block* fm_malloc_init(char* address, unsigned long size)
 {
 	char* start;
 	char* end;
 	struct fm_block* qm;
-	unsigned int init_overhead;
+	unsigned long init_overhead;
 	
 	/* make address and size multiple of 8*/
 	start=(char*)ROUNDUP((unsigned long) address);
@@ -228,10 +233,10 @@ struct fm_block* fm_malloc_init(char* address, unsigned int size)
 
 
 #ifdef DBG_F_MALLOC
-void* fm_malloc(struct fm_block* qm, unsigned int size, char* file, char* func,
-					unsigned int line)
+void* fm_malloc(struct fm_block* qm, unsigned long size,
+					char* file, char* func, unsigned int line)
 #else
-void* fm_malloc(struct fm_block* qm, unsigned int size)
+void* fm_malloc(struct fm_block* qm, unsigned long size)
 #endif
 {
 	struct fm_frag** f;
@@ -239,7 +244,7 @@ void* fm_malloc(struct fm_block* qm, unsigned int size)
 	int hash;
 	
 #ifdef DBG_F_MALLOC
-	DBG("fm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
+	DBG("fm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
 			line);
 #endif
 	/*size must be a multiple of 8*/
@@ -280,7 +285,7 @@ found:
 	frag->func=func;
 	frag->line=line;
 	frag->check=ST_CHECK_PATTERN;
-	DBG("fm_malloc(%p, %d) returns address %p \n", qm, size,
+	DBG("fm_malloc(%p, %lu) returns address %p \n", qm, size,
 		(char*)frag+sizeof(struct fm_frag));
 #else
 	fm_split_frag(qm, frag, size);
@@ -299,7 +304,7 @@ void fm_free(struct fm_block* qm, void* p)
 #endif
 {
 	struct fm_frag* f;
-	unsigned int size;
+	unsigned long size;
 
 #ifdef DBG_F_MALLOC
 	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)
 
 
 #ifdef DBG_F_MALLOC
-void* fm_realloc(struct fm_block* qm, void* p, unsigned int size,
+void* fm_realloc(struct fm_block* qm, void* p, unsigned long size,
 					char* file, char* func, unsigned int line)
 #else
-void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
+void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
 #endif
 {
 	struct fm_frag *f;
 	struct fm_frag **pf;
-	unsigned int diff;
-	unsigned int orig_size;
+	unsigned long diff;
+	unsigned long orig_size;
 	struct fm_frag *n;
 	void *ptr;
 	int hash;
 	
 #ifdef DBG_F_MALLOC
-	DBG("fm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
+	DBG("fm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size,
 			file, func, line);
 	if ((p)&&(p>(void*)qm->last_frag || p<(void*)qm->first_frag)){
 		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)
 	if (f->size > size){
 		/* shrink */
 #ifdef DBG_F_MALLOC
-		DBG("fm_realloc: shrinking from %ld to %d\n", f->size, size);
+		DBG("fm_realloc: shrinking from %lu to %lu\n", f->size, size);
 		fm_split_frag(qm, f, size, file, "frag. from fm_realloc", line);
 		qm->real_used-=(orig_size-f->size);
 		qm->used-=(orig_size-f->size);
@@ -390,7 +395,7 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
 	}else if (f->size<size){
 		/* grow */
 #ifdef DBG_F_MALLOC
-		DBG("fm_realloc: growing from %ld to %d\n", f->size, size);
+		DBG("fm_realloc: growing from %lu to %lu\n", f->size, size);
 #endif
 		diff=size-f->size;
 		n=FRAG_NEXT(f);
@@ -449,7 +454,8 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned int size)
 	}else{
 		/* do nothing */
 #ifdef DBG_F_MALLOC
-		DBG("fm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
+		DBG("fm_realloc: doing nothing, same size: %lu - %lu\n", 
+				f->size, size);
 #endif
 	}
 #ifdef DBG_F_MALLOC
@@ -466,16 +472,16 @@ void fm_status(struct fm_block* qm)
 	int i,j;
 	int h;
 	int unused;
-	long size;
+	unsigned long size;
 
 	LOG(memlog, "fm_status (%p):\n", qm);
 	if (!qm) return;
 
 	LOG(memlog, " heap size= %ld\n", qm->size);
 #ifdef DBG_F_MALLOC
-	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
+	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
 			qm->used, qm->real_used, qm->size-qm->real_used);
-	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
+	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
 #endif
 	/*
 	LOG(memlog, "dumping all fragments:\n");
@@ -499,16 +505,16 @@ void fm_status(struct fm_block* qm)
 				unused++;
 #ifdef DBG_FM_MALLOC
 				LOG(memlog, "unused fragm.: hash = %3d, fragment %x,"
-							" address %x size %d, created from %s: %s(%d)\n",
+							" address %x size %lu, created from %s: %s(%d)\n",
 						    h, f, (char*)f+sizeof(struct fm_frag), f->size,
 							f->file, f->func, f->line);
 #endif
 			};
 		}
 		if (j) LOG(memlog, "hash = %3d fragments no.: %5d, unused: %5d\n\t\t"
-							" bucket size: %9ld - %9ld (first %9ld)\n",
-							h, j, unused, (long)UN_HASH(h),
-						(long)((h<=F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
+							" bucket size: %9lu - %9lu (first %9lu)\n",
+							h, j, unused, UN_HASH(h),
+						((h<=F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)* UN_HASH(h),
 							qm->free_hash[h].first->size
 				);
 		if (j!=qm->free_hash[h].no){
@@ -528,7 +534,7 @@ void fm_status(struct fm_block* qm)
 		}
 	*/
 	}
-	LOG(memlog, "TOTAL: %6d free fragments = %6ld free bytes\n", i, size);
+	LOG(memlog, "TOTAL: %6d free fragments = %6lu free bytes\n", i, size);
 	LOG(memlog, "-----------------------------\n");
 }
 

+ 10 - 9
mem/f_malloc.h

@@ -32,6 +32,7 @@
  *               long longs will be 64 bit aligned) (andrei)
  *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
  *               for the future de-fragmentation support (andrei)
+ *  2004-11-10  support for > 4Gb mem., switched to long (andrei)
  */
 
 
@@ -53,14 +54,14 @@
                       sizeof(fm_frag) must be multiple of ROUNDTO !*/
 #endif
 #else /* DBG_F_MALLOC */
-	#define ROUNDTO 8
+	#define ROUNDTO 8UL
 #endif
 #define MIN_FRAG_SIZE	ROUNDTO
 
 
 
-#define F_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
-#define F_MALLOC_OPTIMIZE  (1<<F_MALLOC_OPTIMIZE_FACTOR)
+#define F_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
+#define F_MALLOC_OPTIMIZE  (1UL<<F_MALLOC_OPTIMIZE_FACTOR)
 								/* size to optimize for,
 									(most allocs <= this size),
 									must be 2^k */
@@ -108,13 +109,13 @@ struct fm_block{
 
 
 
-struct fm_block* fm_malloc_init(char* address, unsigned int size);
+struct fm_block* fm_malloc_init(char* address, unsigned long size);
 
 #ifdef DBG_F_MALLOC
-void* fm_malloc(struct fm_block*, unsigned int size, char* file, char* func, 
-					unsigned int line);
+void* fm_malloc(struct fm_block*, unsigned long size,
+					char* file, char* func, unsigned int line);
 #else
-void* fm_malloc(struct fm_block*, unsigned int size);
+void* fm_malloc(struct fm_block*, unsigned long size);
 #endif
 
 #ifdef DBG_F_MALLOC
@@ -125,10 +126,10 @@ void  fm_free(struct fm_block*, void* p);
 #endif
 
 #ifdef DBG_F_MALLOC
-void*  fm_realloc(struct fm_block*, void* p, unsigned int size, 
+void*  fm_realloc(struct fm_block*, void* p, unsigned long size, 
 					char* file, char* func, unsigned int line);
 #else
-void*  fm_realloc(struct fm_block*, void* p, unsigned int size);
+void*  fm_realloc(struct fm_block*, void* p, unsigned long size);
 #endif
 
 void  fm_status(struct fm_block*);

+ 1 - 1
mem/mem.c

@@ -90,7 +90,7 @@ int init_shm_mallocs()
 #ifdef SHM_MEM
 	if (shm_mem_init()<0) {
 		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
-		 fprintf(stderr, "Too much shared memory demanded: %d\n",
+		 fprintf(stderr, "Too much shared memory demanded: %ld\n",
 			shm_mem_size );
 		return -1;
 	}

+ 44 - 40
mem/q_malloc.c

@@ -33,6 +33,7 @@
  *  2004-07-19  fragments book keeping code and support for 64 bits
  *               memory blocks (64 bits machine & size>=2^32) (andrei)
  *              GET_HASH s/</<=/ (avoids waste of 1 hash cell) (andrei)
+ *  2004-11-10  support for > 4Gb mem., switched to long (andrei)
  */
 
 
@@ -80,13 +81,15 @@
 
 
 	/* finds the hash value for s, s=ROUNDTO multiple*/
-#define GET_HASH(s)   ( ((s)<=QM_MALLOC_OPTIMIZE)?(s)/ROUNDTO: \
-						QM_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
-							QM_MALLOC_OPTIMIZE_FACTOR+1 )
-
-#define UN_HASH(h)	( ((h)<=(QM_MALLOC_OPTIMIZE/ROUNDTO))?(h)*ROUNDTO: \
-						1<<((h)-QM_MALLOC_OPTIMIZE/ROUNDTO+\
-							QM_MALLOC_OPTIMIZE_FACTOR-1)\
+#define GET_HASH(s)   ( ((unsigned long)(s)<=QM_MALLOC_OPTIMIZE)?\
+							(unsigned long)(s)/ROUNDTO: \
+							QM_MALLOC_OPTIMIZE/ROUNDTO+big_hash_idx((s))- \
+								QM_MALLOC_OPTIMIZE_FACTOR+1 )
+
+#define UN_HASH(h)	( ((unsigned long)(h)<=(QM_MALLOC_OPTIMIZE/ROUNDTO))?\
+							(unsigned long)(h)*ROUNDTO: \
+							1UL<<((h)-QM_MALLOC_OPTIMIZE/ROUNDTO+\
+								QM_MALLOC_OPTIMIZE_FACTOR-1)\
 					)
 
 
@@ -104,7 +107,7 @@
 
 
 /* computes hash number for big buckets*/
-inline static int big_hash_idx(unsigned long s)
+inline static unsigned long big_hash_idx(unsigned long s)
 {
 	int idx;
 	/* 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)
 
 
 /* init malloc and return a qm_block*/
-struct qm_block* qm_malloc_init(char* address, unsigned int size)
+struct qm_block* qm_malloc_init(char* address, unsigned long size)
 {
 	char* start;
 	char* end;
@@ -190,11 +193,11 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
 	
 	/* make address and size multiple of 8*/
 	start=(char*)ROUNDUP((unsigned long) address);
-	DBG("qm_malloc_init: QM_OPTIMIZE=%ld, /ROUNDTO=%ld\n",
+	DBG("qm_malloc_init: QM_OPTIMIZE=%lu, /ROUNDTO=%lu\n",
 			QM_MALLOC_OPTIMIZE, QM_MALLOC_OPTIMIZE/ROUNDTO);
-	DBG("qm_malloc_init: QM_HASH_SIZE=%ld, qm_block size=%d\n",
-			QM_HASH_SIZE, (int)sizeof(struct qm_block));
-	DBG("qm_malloc_init(%p, %d), start=%p\n", address, size, start);
+	DBG("qm_malloc_init: QM_HASH_SIZE=%lu, qm_block size=%lu\n",
+			QM_HASH_SIZE, (long)sizeof(struct qm_block));
+	DBG("qm_malloc_init(%p, %lu), start=%p\n", address, size, start);
 	if (size<start-address) return 0;
 	size-=(start-address);
 	if (size <(MIN_FRAG_SIZE+FRAG_OVERHEAD)) return 0;
@@ -202,7 +205,7 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
 	
 	init_overhead=ROUNDUP(sizeof(struct qm_block))+sizeof(struct qm_frag)+
 		sizeof(struct qm_frag_end);
-	DBG("qm_malloc_init: size= %d, init_overhead=%ld\n", size, init_overhead);
+	DBG("qm_malloc_init: size= %lu, init_overhead=%lu\n", size, init_overhead);
 	
 	if (size < init_overhead)
 	{
@@ -266,12 +269,12 @@ static inline void qm_detach_free(struct qm_block* qm, struct qm_frag* frag)
 
 #ifdef DBG_QM_MALLOC
 static inline struct qm_frag* qm_find_free(struct qm_block* qm, 
-											unsigned int size,
+											unsigned long size,
 											int *h,
 											unsigned int *count)
 #else
 static inline struct qm_frag* qm_find_free(struct qm_block* qm, 
-											unsigned int size,
+											unsigned long size,
 											int* h)
 #endif
 {
@@ -297,13 +300,13 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm,
  * new_size < size & rounded-up already!*/
 static inline
 #ifdef DBG_QM_MALLOC
-int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size,
+int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned long new_size,
 				char* file, char* func, unsigned int line)
 #else
-int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size)
+int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned long new_size)
 #endif
 {
-	unsigned int rest;
+	unsigned long rest;
 	struct qm_frag* n;
 	struct qm_frag_end* end;
 	
@@ -344,10 +347,10 @@ int split_frag(struct qm_block* qm, struct qm_frag* f, unsigned int new_size)
 
 
 #ifdef DBG_QM_MALLOC
-void* qm_malloc(struct qm_block* qm, unsigned int size, char* file, char* func,
-					unsigned int line)
+void* qm_malloc(struct qm_block* qm, unsigned long size,
+					char* file, char* func, unsigned int line)
 #else
-void* qm_malloc(struct qm_block* qm, unsigned int size)
+void* qm_malloc(struct qm_block* qm, unsigned long size)
 #endif
 {
 	struct qm_frag* f;
@@ -357,7 +360,7 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
 	unsigned int list_cntr;
 
 	list_cntr = 0;
-	DBG("qm_malloc(%p, %d) called from %s: %s(%d)\n", qm, size, file, func,
+	DBG("qm_malloc(%p, %lu) called from %s: %s(%d)\n", qm, size, file, func,
 			line);
 #endif
 	/*size must be a multiple of 8*/
@@ -396,8 +399,8 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
 		f->check=ST_CHECK_PATTERN;
 		/*  FRAG_END(f)->check1=END_CHECK_PATTERN1;
 			FRAG_END(f)->check2=END_CHECK_PATTERN2;*/
-		DBG("qm_malloc(%p, %d) returns address %p frag. %p (size=%ld) on %d -th"
-				" hit\n",
+		DBG("qm_malloc(%p, %lu) returns address %p frag. %p (size=%lu) on %d"
+				" -th hit\n",
 			 qm, size, (char*)f+sizeof(struct qm_frag), f, f->size, list_cntr );
 #endif
 		return (char*)f+sizeof(struct qm_frag);
@@ -492,21 +495,21 @@ void qm_free(struct qm_block* qm, void* p)
 
 
 #ifdef DBG_QM_MALLOC
-void* qm_realloc(struct qm_block* qm, void* p, unsigned int size,
+void* qm_realloc(struct qm_block* qm, void* p, unsigned long size,
 					char* file, char* func, unsigned int line)
 #else
-void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
+void* qm_realloc(struct qm_block* qm, void* p, unsigned long size)
 #endif
 {
 	struct qm_frag* f;
-	unsigned int diff;
-	unsigned int orig_size;
+	unsigned long diff;
+	unsigned long orig_size;
 	struct qm_frag* n;
 	void* ptr;
 	
 	
 #ifdef DBG_QM_MALLOC
-	DBG("qm_realloc(%p, %p, %d) called from %s: %s(%d)\n", qm, p, size,
+	DBG("qm_realloc(%p, %p, %lu) called from %s: %s(%d)\n", qm, p, size,
 			file, func, line);
 	if ((p)&&(p>(void*)qm->last_frag_end || p<(void*)qm->first_frag)){
 		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)
 	if (f->size > size){
 		/* shrink */
 #ifdef DBG_QM_MALLOC
-		DBG("qm_realloc: shrinking from %ld to %d\n", f->size, size);
+		DBG("qm_realloc: shrinking from %lu to %lu\n", f->size, size);
 		if(split_frag(qm, f, size, file, "fragm. from qm_realloc", line)!=0){
 		DBG("qm_realloc : shrinked successful\n");
 #else
@@ -560,7 +563,7 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
 	}else if (f->size < size){
 		/* grow */
 #ifdef DBG_QM_MALLOC
-		DBG("qm_realloc: growing from %ld to %d\n", f->size, size);
+		DBG("qm_realloc: growing from %lu to %lu\n", f->size, size);
 #endif
 			orig_size=f->size;
 			diff=size-f->size;
@@ -605,7 +608,8 @@ void* qm_realloc(struct qm_block* qm, void* p, unsigned int size)
 	}else{
 		/* do nothing */
 #ifdef DBG_QM_MALLOC
-		DBG("qm_realloc: doing nothing, same size: %ld - %d\n", f->size, size);
+		DBG("qm_realloc: doing nothing, same size: %lu - %lu\n",
+				f->size, size);
 #endif
 	}
 #ifdef DBG_QM_MALLOC
@@ -627,16 +631,16 @@ void qm_status(struct qm_block* qm)
 	LOG(memlog, "qm_status (%p):\n", qm);
 	if (!qm) return;
 
-	LOG(memlog, " heap size= %ld\n", qm->size);
-	LOG(memlog, " used= %ld, used+overhead=%ld, free=%ld\n",
+	LOG(memlog, " heap size= %lu\n", qm->size);
+	LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
 			qm->used, qm->real_used, qm->size-qm->real_used);
-	LOG(memlog, " max used (+overhead)= %ld\n", qm->max_real_used);
+	LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
 	
 	LOG(memlog, "dumping all alloc'ed. fragments:\n");
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
 			,i++){
 		if (! f->u.is_free){
-			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%ld used=%d\n",
+			LOG(memlog, "    %3d. %c  address=%p frag=%p size=%lu used=%d\n",
 				i, 
 				(f->u.is_free)?'a':'N',
 				(char*)f+sizeof(struct qm_frag), f, f->size, FRAG_WAS_USED(f));
@@ -665,9 +669,9 @@ void qm_status(struct qm_block* qm)
 		}
 
 		if (j) LOG(memlog, "hash= %3d. fragments no.: %5d, unused: %5d\n"
-					"\t\t bucket size: %9ld - %9ld (first %9ld)\n",
-					h, j, unused, (long)UN_HASH(h),
-					(long)((h<=QM_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
+					"\t\t bucket size: %9lu - %9ld (first %9lu)\n",
+					h, j, unused, UN_HASH(h),
+					((h<=QM_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
 					qm->free_hash[h].head.u.nxt_free->size
 				);
 		if (j!=qm->free_hash[h].no){

+ 9 - 8
mem/q_malloc.h

@@ -32,6 +32,7 @@
  *               long longs will be 64 bit aligned) (andrei)
  *  2004-07-19  support for 64 bit (2^64 mem. block) and more info
  *               for the future de-fragmentation support (andrei)
+ *  2004-11-10  support for > 4Gb mem. (switched to long) (andrei)
  */
 
 
@@ -52,7 +53,7 @@
 										 debugging*/
 #endif 
 #else /* DBG_QM_MALLOC */
-	#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
+	#define ROUNDTO		16UL /* size we round to, must be = 2^n  and also
 							 sizeof(qm_frag)+sizeof(qm_frag_end)
 							 must be multiple of ROUNDTO!
 						   */
@@ -61,8 +62,8 @@
 
 
 
-#define QM_MALLOC_OPTIMIZE_FACTOR 11 /*used below */
-#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1<<QM_MALLOC_OPTIMIZE_FACTOR))
+#define QM_MALLOC_OPTIMIZE_FACTOR 11UL /*used below */
+#define QM_MALLOC_OPTIMIZE  ((unsigned long)(1UL<<QM_MALLOC_OPTIMIZE_FACTOR))
 								/* size to optimize for,
 									(most allocs <= this size),
 									must be 2^k */
@@ -124,13 +125,13 @@ struct qm_block{
 
 
 
-struct qm_block* qm_malloc_init(char* address, unsigned int size);
+struct qm_block* qm_malloc_init(char* address, unsigned long size);
 
 #ifdef DBG_QM_MALLOC
-void* qm_malloc(struct qm_block*, unsigned int size, char* file, char* func, 
+void* qm_malloc(struct qm_block*, unsigned long size, char* file, char* func, 
 					unsigned int line);
 #else
-void* qm_malloc(struct qm_block*, unsigned int size);
+void* qm_malloc(struct qm_block*, unsigned long size);
 #endif
 
 #ifdef DBG_QM_MALLOC
@@ -140,10 +141,10 @@ void  qm_free(struct qm_block*, void* p, char* file, char* func,
 void  qm_free(struct qm_block*, void* p);
 #endif
 #ifdef DBG_QM_MALLOC
-void* qm_realloc(struct qm_block*, void* p, unsigned int size,
+void* qm_realloc(struct qm_block*, void* p, unsigned long size,
 				char* file, char* func, unsigned int line);
 #else
-void* qm_realloc(struct qm_block*, void* p, unsigned int size);
+void* qm_realloc(struct qm_block*, void* p, unsigned long size);
 #endif
 
 void  qm_status(struct qm_block*);

+ 1 - 1
mem/shm_mem.c

@@ -178,7 +178,7 @@ int shm_getmem()
 
 
 
-int shm_mem_init_mallocs(void* mempool, int pool_size)
+int shm_mem_init_mallocs(void* mempool, unsigned long pool_size)
 {
 	/* init it for malloc*/
 	shm_block=shm_malloc_init(mempool, pool_size);

+ 3 - 2
mem/shm_mem.h

@@ -91,8 +91,9 @@
 
 int shm_mem_init(); /* calls shm_getmem & shm_mem_init_mallocs */
 int shm_getmem();   /* allocates the memory (mmap or sysv shmap) */
-int shm_mem_init_mallocs(void* mempool, int size); /* initialized the mallocs
-													  & the lock */
+int shm_mem_init_mallocs(void* mempool, unsigned long size); /* initialize
+																the mallocs
+																& the lock */
 void shm_mem_destroy();
 
 

+ 1 - 1
test/dns_query.c

@@ -47,7 +47,7 @@ int log_stderr=1;
 int debug=0;
 int pids[1];
 int process_no=0;
-int shm_mem_size=0;
+long shm_mem_size=0;
 char mem_pool[1024*1024];
 struct qm_block* mem_block;