Browse Source

core: pkg size can be set via compile option

- new makefile option PKG_MEM_SIZE that can be used to specify the size
  in MB for PKG memory, e.g., make PKG_MEM_SIZE=8 cfg
- easier way to set the pkg size without messing with c code and defines
  in config.h
- pkg size is printed by -V command line option
Daniel-Constantin Mierla 15 years ago
parent
commit
bdc85a8cdf
3 changed files with 9 additions and 3 deletions
  1. 3 0
      Makefile.defs
  2. 4 1
      config.h
  3. 2 2
      main.c

+ 3 - 0
Makefile.defs

@@ -666,6 +666,9 @@ ifeq ($(MEMDBG), 1)
 else
 	C_DEFS+= -DF_MALLOC
 endif
+ifneq ($(PKG_MEM_SIZE),)
+	C_DEFS+= -DPKG_MEM_SIZE=$(PKG_MEM_SIZE)
+endif
 ifeq ($(CORE_TLS), 1)
 	C_DEFS+= -DUSE_TLS -DCORE_TLS
 endif

+ 4 - 1
config.h

@@ -140,7 +140,10 @@
 
 #define SRV_MAX_PREFIX_LEN SRV_TLS_PREFIX_LEN
 
-#define PKG_MEM_POOL_SIZE 4*1024*1024		/*!< used only if PKG_MALLOC is defined*/
+#ifndef PKG_MEM_SIZE
+#define PKG_MEM_SIZE 4
+#endif
+#define PKG_MEM_POOL_SIZE PKG_MEM_SIZE*1024*1024	/*!< used only if PKG_MALLOC is defined*/
 
 #define SHM_MEM_SIZE 32				/*!< used if SH_MEM is defined*/
 

+ 2 - 2
main.c

@@ -265,9 +265,9 @@ void print_ct_constants()
 #endif
 */
 	printf("MAX_RECV_BUFFER_SIZE %d, MAX_LISTEN %d,"
-			" MAX_URI_SIZE %d, BUF_SIZE %d\n",
+			" MAX_URI_SIZE %d, BUF_SIZE %d, PKG_SIZE %uMB\n",
 		MAX_RECV_BUFFER_SIZE, MAX_LISTEN, MAX_URI_SIZE,
-		BUF_SIZE );
+		BUF_SIZE, PKG_MEM_SIZE);
 #ifdef USE_TCP
 	printf("poll method support: %s.\n", poll_support);
 #endif