Prechádzať zdrojové kódy

- minor gcc-3.0 makefile fixes
- f_malloc status clean-up

Andrei Pelinescu-Onciul 23 rokov pred
rodič
commit
bf0fab3f8c
5 zmenil súbory, kde vykonal 21 pridanie a 9 odobranie
  1. 2 2
      Makefile.defs
  2. 1 1
      fastlock.h
  3. 2 1
      main.c
  4. 15 4
      mem/f_malloc.c
  5. 1 1
      test/th-uri-2.cfg

+ 2 - 2
Makefile.defs

@@ -9,7 +9,7 @@
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL = 6
-EXTRAVERSION = -3
+EXTRAVERSION = -4
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s)
@@ -101,7 +101,7 @@ ifeq ($(mode), release)
 			#-Wmissing-prototypes \
 	
 ifneq (,$(findstring 3.0, $(CC_VER)))
-	CFLAGS=-minline-all-stringops -malign-double \
+	CFLAGS+=-minline-all-stringops -malign-double \
 				-march=athlon \
 				#-mcpu=athlon
 endif

+ 1 - 1
fastlock.h

@@ -67,7 +67,7 @@ inline static void release_lock(fl_lock_t* lock)
 	asm volatile(
 		" movb $0, (%0)" : /*no output*/ : "r"(lock): "memory"
 		/*" xchg %b0, %1" : "=q" (val), "=m" (*lock) : "0" (val) : "memory"*/
-	); /* hmm, maybe lock; movb $0, [%1] would be faster ???*/
+	); 
 #elif defined __sparc
 	asm volatile(
 			"membar #LoadStore | #StoreStore \n\t" /*is this really needed?*/

+ 2 - 1
main.c

@@ -329,7 +329,8 @@ int main_loop()
 						pids[i+1]=pid; /*should be in shared mem.*/
 				}
 			}
-			close(udp_sock); /*parent*/
+			/*parent*/
+			/*close(udp_sock)*/; /*if it's closed=>sendto invalid fd errors?*/
 		}
 	}
 	/*this is the main process*/

+ 15 - 4
mem/f_malloc.c

@@ -26,6 +26,11 @@
 						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+\
+							F_MALLOC_OPTIMIZE_FACTOR-1)\
+					)
+
 
 /* computes hash number for big buckets*/
 inline static int big_hash_idx(int s)
@@ -247,6 +252,7 @@ void fm_status(struct fm_block* qm)
 	struct fm_frag* f;
 	int i,j;
 	int h;
+	int size;
 
 	LOG(L_INFO, "fm_status (%x):\n", qm);
 	if (!qm) return;
@@ -271,10 +277,15 @@ void fm_status(struct fm_block* qm)
 	}
 */
 	LOG(L_INFO, "dumping free list:\n");
-	for(h=0,i=0;h<F_HASH_SIZE;h++){
+	for(h=0,i=0,size=0;h<F_HASH_SIZE;h++){
 		
-		for (f=qm->free_hash[h],j=0; f; f=f->u.nxt_free, i++, j++)
-			if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j);
+		for (f=qm->free_hash[h],j=0; f; size+=f->size,f=f->u.nxt_free,i++,j++);
+		if (j) LOG(L_INFO, "hash = %3d fragments no.: %5d,\n\t\t"
+							" bucket size: %9d - %9d (first %9d)\n",
+							h, j, UN_HASH(h),
+							((h<F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)*UN_HASH(h),
+							qm->free_hash[h]->size
+				);
 		/*
 		{
 			LOG(L_INFO, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
@@ -288,7 +299,7 @@ void fm_status(struct fm_block* qm)
 		}
 	*/
 	}
-	LOG(L_INFO, "	Total: %6d fragments\n", i);
+	LOG(L_INFO, "TOTAL: %6d free fragments = %6d free bytes\n", i, size);
 	LOG(L_INFO, "-----------------------------\n");
 }
 

+ 1 - 1
test/th-uri-2.cfg

@@ -11,7 +11,7 @@
 debug=3          # debug level (cmd line: -dddddddddd)
 #fork=yes          # (cmd. line: -D)
 fork=yes
-fork=no
+#fork=no
 log_stderror=yes # (cmd line: -E)
 #log_stderror=no	# (cmd line: -E)