changed several variables to be with _ so that swapglobal skips them.
authorGengbin Zheng <gzheng@illinois.edu>
Fri, 28 Jan 2011 17:49:41 +0000 (11:49 -0600)
committerGengbin Zheng <gzheng@illinois.edu>
Fri, 28 Jan 2011 17:49:41 +0000 (11:49 -0600)
src/conv-core/memory-gnu.c
src/conv-core/memory-gnuold.c
src/conv-core/memory.c

index 3abed472b3c9e70d3fdc9eedae98cf6835e45208..ac1c447986beb9bcfdcf76eb111c0f5cc5668a14 100644 (file)
@@ -20,9 +20,15 @@ This is slightly hacked as:
 #define memalign mm_memalign
 #define valloc   mm_valloc
 
-extern CMK_TYPEDEF_UINT8 memory_allocated;
-extern CMK_TYPEDEF_UINT8 memory_allocated_max;
-extern CMK_TYPEDEF_UINT8 memory_allocated_min;
+extern CMK_TYPEDEF_UINT8 _memory_allocated;
+extern CMK_TYPEDEF_UINT8 _memory_allocated_max;
+extern CMK_TYPEDEF_UINT8 _memory_allocated_min;
+
+#define UPDATE_MEMUSAGE  \
+  if(_memory_allocated > _memory_allocated_max) \
+    _memory_allocated_max=_memory_allocated; \
+  if(_memory_allocated < _memory_allocated_min) \
+    _memory_allocated_min=_memory_allocated;
 
 #define HAVE_MMAP CMK_HAS_MMAP
 #ifndef __USE_GNU
@@ -3335,12 +3341,9 @@ public_mALLOc(size_t bytes)
         ar_ptr == arena_for_chunk(mem2chunk(victim)));
 
   if (victim!=NULL) {
-  memory_allocated += chunksize(mem2chunk(victim));
+  _memory_allocated += chunksize(mem2chunk(victim));
   
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
   }
 
   return victim;
@@ -3363,7 +3366,7 @@ public_fREe(Void_t* mem)
     return;
 
   p = mem2chunk(mem);
-  memory_allocated -= chunksize(p);
+  _memory_allocated -= chunksize(p);
 
 #if HAVE_MMAP
   if (chunk_is_mmapped(p))                       /* release mmapped memory. */
@@ -3417,13 +3420,10 @@ public_rEALLOc(Void_t* oldmem, size_t bytes)
 
   checked_request2size(bytes, nb);
 
-  memory_allocated -= oldsize;
-  memory_allocated += nb;
+  _memory_allocated -= oldsize;
+  _memory_allocated += nb;
    
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
   
 #if HAVE_MMAP
   if (chunk_is_mmapped(oldp))
@@ -3514,12 +3514,9 @@ public_mEMALIGn(size_t alignment, size_t bytes)
   }
   assert(!p || chunk_is_mmapped(mem2chunk(p)) ||
         ar_ptr == arena_for_chunk(mem2chunk(p)));
-  memory_allocated += chunksize(mem2chunk(p));
+  _memory_allocated += chunksize(mem2chunk(p));
 
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
   
   return p;
 }
@@ -3537,12 +3534,9 @@ public_vALLOc(size_t bytes)
     return 0;
   p = _int_valloc(ar_ptr, bytes);
   (void)mutex_unlock(&ar_ptr->mutex);
-  memory_allocated += chunksize(mem2chunk(p));
+  _memory_allocated += chunksize(mem2chunk(p));
 
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
 
   return p;
 }
@@ -3558,12 +3552,9 @@ public_pVALLOc(size_t bytes)
   arena_get(ar_ptr, bytes + 2*mp_.pagesize + MINSIZE);
   p = _int_pvalloc(ar_ptr, bytes);
   (void)mutex_unlock(&ar_ptr->mutex);
-  memory_allocated += chunksize(mem2chunk(p));
+  _memory_allocated += chunksize(mem2chunk(p));
 
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
   
   return p;
 }
@@ -3652,12 +3643,9 @@ public_cALLOc(size_t n, size_t elem_size)
     if (mem == 0) return 0;
   }
   p = mem2chunk(mem);
-  memory_allocated += chunksize(p);
+  _memory_allocated += chunksize(p);
 
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
 
   /* Two optional cases in which clearing not necessary */
 #if HAVE_MMAP
@@ -3718,11 +3706,10 @@ public_iCALLOc(size_t n, size_t elem_size, Void_t** chunks)
 
   m = _int_icalloc(ar_ptr, n, elem_size, chunks);
   (void)mutex_unlock(&ar_ptr->mutex);
-  memory_allocated += chunksize(mem2chunk(m));
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  _memory_allocated += chunksize(mem2chunk(m));
+
+  UPDATE_MEMUSAGE
+
   return m;
 }
 
@@ -3738,12 +3725,9 @@ public_iCOMALLOc(size_t n, size_t sizes[], Void_t** chunks)
 
   m = _int_icomalloc(ar_ptr, n, sizes, chunks);
   (void)mutex_unlock(&ar_ptr->mutex);
-  memory_allocated += chunksize(mem2chunk(m));
+  _memory_allocated += chunksize(mem2chunk(m));
   
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  UPDATE_MEMUSAGE
   
   return m;
 }
index a649b3d614c57d724dc272362c646b3e337b84e1..026922f516ee7cac33f3480b3426fbc6c05255c2 100644 (file)
@@ -14,9 +14,9 @@
 #define valloc   mm_valloc
 #define MM_LINK static
 
-extern CMK_TYPEDEF_UINT8 memory_allocated;
-extern CMK_TYPEDEF_UINT8 memory_allocated_max;
-extern CMK_TYPEDEF_UINT8 memory_allocated_min;
+extern CMK_TYPEDEF_UINT8 _memory_allocated;
+extern CMK_TYPEDEF_UINT8 _memory_allocated_max;
+extern CMK_TYPEDEF_UINT8 _memory_allocated_min;
 
 #undef sun /* I don't care if it's a sun, dangit.  No special treatment. */
 #undef BSD /* I don't care if it's BSD.  Same thing. */
@@ -925,12 +925,12 @@ MM_LINK Void_t* malloc(bytes) size_t bytes;
   mchunkptr rl = returns;                /* local for speed/simplicity */
   size_t nb = request2size(bytes)    ;   /* padded request size; */
 
-  memory_allocated += nb;
+  _memory_allocated += nb;
 
-  if(memory_allocated > memory_allocated_max)
-    memory_allocated_max=memory_allocated;
-  if(memory_allocated < memory_allocated_min)
-    memory_allocated_min=memory_allocated;
+  if(_memory_allocated > _memory_allocated_max)
+    _memory_allocated_max=_memory_allocated;
+  if(_memory_allocated < _memory_allocated_min)
+    _memory_allocated_min=_memory_allocated;
 
   if (rl != 0)
   {
@@ -1167,7 +1167,7 @@ MM_LINK void free(mem) Void_t* mem;
   if (mem != 0)
   {
     mchunkptr p = mem2chunk(mem);
-    memory_allocated -= p->size;
+    _memory_allocated -= p->size;
     returnlink(p);
   }
 }
index 645be0ebfdb9c4713a4224cfe5c8b7cefeedd5f5..51f9aeb7ce50866436eda5a9187ed75e411d8308 100644 (file)
@@ -161,9 +161,9 @@ void initialize_memory_wrapper_cfree(void *ptr) {
 #endif
 #endif
 
-CMK_TYPEDEF_UINT8 memory_allocated = 0;
-CMK_TYPEDEF_UINT8 memory_allocated_max = 0; /* High-Water Mark */
-CMK_TYPEDEF_UINT8 memory_allocated_min = 0; /* Low-Water Mark */
+CMK_TYPEDEF_UINT8 _memory_allocated = 0;
+CMK_TYPEDEF_UINT8 _memory_allocated_max = 0; /* High-Water Mark */
+CMK_TYPEDEF_UINT8 _memory_allocated_min = 0; /* Low-Water Mark */
 
 /*Rank of the processor that's currently holding the CmiMemLock,
 or -1 if nobody has it.  Only set when malloc might be reentered.
@@ -659,27 +659,27 @@ void free_reentrant(void *mem)
 /** Return number of bytes currently allocated, if possible. */
 CMK_TYPEDEF_UINT8 CmiMemoryUsage()
 {
-  return memory_allocated;
+  return _memory_allocated;
 }
 
 /** Return number of maximum number of bytes allocated since the last call to CmiResetMaxMemory(), if possible. */
 CMK_TYPEDEF_UINT8 CmiMaxMemoryUsage()
 {
-  return memory_allocated_max;
+  return _memory_allocated_max;
 }
 
 /** Reset the mechanism that records the highest seen (high watermark) memory usage. */
 void CmiResetMaxMemory() {
-  memory_allocated_max=memory_allocated;
+  _memory_allocated_max=_memory_allocated;
 }
 
 CMK_TYPEDEF_UINT8 CmiMinMemoryUsage()
 {
-  return memory_allocated_min;
+  return _memory_allocated_min;
 }
 
 void CmiResetMinMemory() {
-  memory_allocated_min=memory_allocated;
+  _memory_allocated_min=_memory_allocated;
 }
 
 #endif /* ! CMK_MEMORY_BUILD_BUILTIN*/