Changeset 9
- Timestamp:
- 03/11/06 18:57:05 (7 years ago)
- Files:
-
- trunk/Makefile.am (modified) (2 diffs)
- trunk/misc.c (modified) (2 diffs)
- trunk/sol_compat.h (modified) (3 diffs)
- trunk/umem_fail.c (modified) (1 diff)
- trunk/umem_test.c (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Makefile.am
r6 r9 1 1 lib_LTLIBRARIES = libumem.la 2 noinst_PROGRAMS = umem_test 3 4 umem_test_SOURCES = umem_test.c 5 umem_test_LDADD = -lumem -lpthread -ldl 6 2 7 libumem_la_SOURCES = init_lib.c \ 3 8 umem_agent_support.c \ … … 7 12 vmem_mmap.c \ 8 13 vmem_sbrk.c \ 9 envvar.o \ 10 getpcstack.o \ 11 malloc.o \ 12 misc.o \ 13 vmem_base.o \ 14 umem.o \ 15 vmem.o 14 envvar.c \ 15 getpcstack.c \ 16 misc.c \ 17 vmem_base.c \ 18 umem.c \ 19 vmem.c 20 21 # malloc.c \ 16 22 17 23 # XXX: Standalone version? trunk/misc.c
r2 r9 50 50 #include <umem_impl.h> 51 51 #include "misc.h" 52 53 #ifdef ECELERITY 52 54 #include "util.h" 55 #endif 53 56 54 57 #define UMEM_ERRFD 2 /* goes to standard error */ … … 81 84 82 85 looped = 0; 86 #ifdef ECELERITY 83 87 mem_printf(serious ? DCRITICAL : DINFO, "umem: %s", error_str); 88 #endif 84 89 85 90 (void) mutex_lock(&umem_error_lock); trunk/sol_compat.h
r6 r9 12 12 #include <pthread.h> 13 13 14 #define INLINE inline 15 #define THR_RETURN void * 16 #define THR_API 14 #ifdef _WIN32 15 # define THR_RETURN DWORD 16 # define THR_API WINAPI 17 # define INLINE __inline 18 #else 19 # define THR_RETURN void * 20 # define THR_API 21 # define INLINE inline 22 #endif 17 23 18 24 #if defined(__MACH__) || defined(_WIN32) … … 99 105 #endif 100 106 101 /*#include "ec_atomic.h"*/ 107 #ifdef ECELERITY 108 # include "ec_atomic.h" 109 #else 110 # ifdef _WIN32 111 # define ec_atomic_inc(a) InterlockedIncrement(a) 112 # define ec_atomic_inc64(a) InterlockedIncrement64(a) 113 # elif (defined(__i386__) || defined(__x86_64__)) && defined(__GNUC__) 114 static INLINE uint_t ec_atomic_cas(uint_t *mem, uint_t with, uint_t cmp) 115 { 116 uint_t prev; 117 asm volatile ("lock; cmpxchgl %1, %2" 118 : "=a" (prev) 119 : "r" (with), "m" (*(mem)), "0" (cmp) 120 : "memory"); 121 return prev; 122 } 123 # endif 124 125 # ifndef ec_atomic_inc 126 static INLINE uint_t ec_atomic_inc(uint_t *mem) 127 { 128 register uint_t last; 129 do { 130 last = *mem; 131 } while (ec_atomic_cas(mem, last+1, last) != last); 132 return ++last; 133 } 134 # endif 135 # ifndef ec_atomic_inc64 136 /* yeah, it's not great. It's only used to bump failed allocation 137 * counts, so it is not critical right now. */ 138 # define ec_atomic_inc64(a) (*a)++ 139 # endif 140 141 #endif 102 142 103 143 #define P2PHASE(x, align) ((x) & ((align) - 1)) … … 140 180 #endif 141 181 182 #ifndef MIN 183 # define MIN(a,b) ((a) < (b) ? (a) : (b)) 142 184 #endif 185 #ifndef MAX 186 # define MAX(a,b) ((a) > (b) ? (a) : (b)) 187 #endif 188 189 190 #endif trunk/umem_fail.c
r6 r9 127 127 umem_error_enter("\n"); 128 128 129 #ifdef ECELERITY 129 130 va_start(va, format); 130 /*ec_debug_vprintf(DCRITICAL, DMEM, format, va);*/ 131 fvprintf(stderr, format, va); 131 ec_debug_vprintf(DCRITICAL, DMEM, format, va); 132 132 va_end(va); 133 #endif 133 134 134 135 print_stacktrace();
