Changeset 56
- Timestamp:
- 04/30/10 21:27:09 (3 years ago)
- Files:
-
- trunk/init_lib.c (modified) (3 diffs)
- trunk/umem.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/init_lib.c
r49 r56 57 57 #ifdef _WIN32 58 58 vmem_backend = VMEM_BACKEND_MMAP; 59 (void) vmem_sbrk_arena(NULL, NULL); 59 60 #else 60 # if 061 # if defined(sun) 61 62 void *handle = dlopen("libmapmalloc.so.1", RTLD_NOLOAD); 62 63 63 64 if (handle != NULL) { 64 #endif65 65 log_message("sbrk backend disabled\n"); 66 66 vmem_backend = VMEM_BACKEND_MMAP; 67 #if 068 67 } 69 #endif 70 #endif 68 # else 69 if (vmem_backend == 0) { 70 /* prefer mmap, as sbrk() seems to have problems wither working 71 * with other allocators or has some Solaris specific assumptions. */ 72 vmem_backend = VMEM_BACKEND_MMAP; 73 } 74 # endif 71 75 72 76 if ((vmem_backend & VMEM_BACKEND_MMAP) != 0) { … … 74 78 (void) vmem_mmap_arena(NULL, NULL); 75 79 } else { 76 #ifndef _WIN3277 80 vmem_backend = VMEM_BACKEND_SBRK; 78 81 (void) vmem_sbrk_arena(NULL, NULL); 82 } 79 83 #endif 80 }81 84 } 82 85 … … 105 108 * version of libumem, read /proc/stat into a static buffer. 106 109 */ 107 static char proc_stat[8192]; 108 int fd; 109 int ncpus = 1; 110 static int ncpus = 0; 110 111 111 fd = open("/proc/stat", O_RDONLY); 112 if (fd >= 0) { 113 const ssize_t n = read(fd, proc_stat, sizeof(proc_stat) - 1); 114 if (n >= 0) { 115 const char *cur; 116 const char *next; 112 if (ncpus == 0) { 113 char proc_stat[8192]; 114 int fd; 117 115 118 proc_stat[n] = '\0'; 119 cur = proc_stat; 120 while (*cur && (next = strstr(cur + 3, "cpu"))) { 121 cur = next; 116 ncpus = 1; 117 fd = open("/proc/stat", O_RDONLY); 118 if (fd >= 0) { 119 const ssize_t n = read(fd, proc_stat, sizeof(proc_stat) - 1); 120 if (n >= 0) { 121 const char *cur; 122 const char *next; 123 124 proc_stat[n] = '\0'; 125 cur = proc_stat; 126 while (*cur && (next = strstr(cur + 3, "cpu"))) { 127 cur = next; 128 } 129 130 if (*cur) 131 ncpus = atoi(cur + 3) + 1; 122 132 } 123 133 124 if (*cur) 125 ncpus = atoi(cur + 3) + 1; 134 close(fd); 126 135 } 127 128 close(fd);129 136 } 130 137 trunk/umem.c
r52 r56 622 622 caddr_t umem_max_stack; 623 623 624 #ifndef UMEM_STANDALONE 625 static pthread_once_t umem_forkhandler_once = PTHREAD_ONCE_INIT; 626 #endif 624 627 625 628 /* … … 2908 2911 /* Standalone doesn't fork */ 2909 2912 #else 2910 umem_forkhandler_init(); /* register the fork handler */ 2913 /* register the fork handler */ 2914 (void) pthread_once(&umem_forkhandler_once, umem_forkhandler_init); 2911 2915 #endif 2912 2916
