This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] malloc: unifdef -m -UPER_THREAD -U_LIBC


From: Joern Engel <joern@purestorage.org>

Both got in the way of functional changes.

JIRA: PURE-27597
---
 tpc/malloc2.13/arena.h  | 304 +-----------------------------------------------
 tpc/malloc2.13/hooks.h  |  16 ---
 tpc/malloc2.13/malloc.c | 109 +----------------
 3 files changed, 4 insertions(+), 425 deletions(-)

diff --git a/tpc/malloc2.13/arena.h b/tpc/malloc2.13/arena.h
index c854de12910c..118563003c8d 100644
--- a/tpc/malloc2.13/arena.h
+++ b/tpc/malloc2.13/arena.h
@@ -78,10 +78,6 @@ extern int sanity_check_heap_info_alignment[(sizeof (heap_info)
 
 static tsd_key_t arena_key;
 static mutex_t list_lock;
-#ifdef PER_THREAD
-static size_t narenas;
-static struct malloc_state * free_list;
-#endif
 
 #if THREAD_STATS
 static int stat_n_heaps;
@@ -117,21 +113,12 @@ static int __malloc_initialized = -1;
 	ptr = (struct malloc_state *)tsd_getspecific(arena_key, vptr); \
 } while(0)
 
-#ifdef PER_THREAD
-#define arena_lock(ptr, size) do { \
-	if(ptr) \
-		(void)mutex_lock(&ptr->mutex); \
-	else \
-		ptr = arena_get2(ptr, (size)); \
-} while(0)
-#else
 #define arena_lock(ptr, size) do { \
 	if(ptr && !mutex_trylock(&ptr->mutex)) { \
 		THREAD_STAT(++(ptr->stat_lock_direct)); \
 	} else \
 		ptr = arena_get2(ptr, (size)); \
 } while(0)
-#endif
 
 /* find the heap and corresponding arena for a given ptr */
 
@@ -149,10 +136,8 @@ static int __malloc_initialized = -1;
 
 static __malloc_ptr_t (*save_malloc_hook) (size_t __size,
 					   __const __malloc_ptr_t);
-# if !defined _LIBC || (defined SHARED && !USE___THREAD)
 static __malloc_ptr_t (*save_memalign_hook) (size_t __align, size_t __size,
 					     __const __malloc_ptr_t);
-# endif
 static void           (*save_free_hook) (__malloc_ptr_t __ptr,
 					 __const __malloc_ptr_t);
 static Void_t*        save_arena;
@@ -308,22 +293,13 @@ ptmalloc_unlock_all2 (void)
 
   if(__malloc_initialized < 1)
     return;
-#if defined _LIBC || defined MALLOC_HOOKS
+#if defined MALLOC_HOOKS
   tsd_setspecific(arena_key, save_arena);
   dlmalloc_hook = save_malloc_hook;
   dlfree_hook = save_free_hook;
 #endif
-#ifdef PER_THREAD
-  free_list = NULL;
-#endif
   for(ar_ptr = &main_arena;;) {
     mutex_init(&ar_ptr->mutex);
-#ifdef PER_THREAD
-    if (ar_ptr != save_arena) {
-      ar_ptr->next_free = free_list;
-      free_list = ar_ptr;
-    }
-#endif
     ar_ptr = ar_ptr->next;
     if(ar_ptr == &main_arena) break;
   }
@@ -340,41 +316,6 @@ ptmalloc_unlock_all2 (void)
 #endif /* !defined NO_THREADS */
 
 /* Initialization routine. */
-#ifdef _LIBC
-#include <string.h>
-extern char **_environ;
-
-static char *
-internal_function
-next_env_entry (char ***position)
-{
-  char **current = *position;
-  char *result = NULL;
-
-  while (*current != NULL)
-    {
-      if (__builtin_expect ((*current)[0] == 'M', 0)
-	  && (*current)[1] == 'A'
-	  && (*current)[2] == 'L'
-	  && (*current)[3] == 'L'
-	  && (*current)[4] == 'O'
-	  && (*current)[5] == 'C'
-	  && (*current)[6] == '_')
-	{
-	  result = &(*current)[7];
-
-	  /* Save current position for next visit.  */
-	  *position = ++current;
-
-	  break;
-	}
-
-      ++current;
-    }
-
-  return result;
-}
-#endif /* _LIBC */
 
 /* Set up basic state so that _int_malloc et al can work.  */
 static void
@@ -387,54 +328,9 @@ ptmalloc_init_minimal (void)
   mp_.mmap_threshold = DEFAULT_MMAP_THRESHOLD;
   mp_.trim_threshold = DEFAULT_TRIM_THRESHOLD;
   mp_.pagesize       = malloc_getpagesize;
-#ifdef PER_THREAD
-# define NARENAS_FROM_NCORES(n) ((n) * (sizeof(long) == 4 ? 2 : 8))
-  mp_.arena_test     = NARENAS_FROM_NCORES (1);
-  narenas = 1;
-#endif
-}
-
-
-#ifdef _LIBC
-# ifdef SHARED
-static void *
-__failing_morecore (ptrdiff_t d)
-{
-  return (void *) MORECORE_FAILURE;
 }
 
-extern struct dl_open_hook *_dl_open_hook;
-libc_hidden_proto (_dl_open_hook);
-# endif
 
-# if defined SHARED && !USE___THREAD
-/* This is called by __pthread_initialize_minimal when it needs to use
-   malloc to set up the TLS state.  We cannot do the full work of
-   ptmalloc_init (below) until __pthread_initialize_minimal has finished,
-   so it has to switch to using the special startup-time hooks while doing
-   those allocations.  */
-void
-__libc_malloc_pthread_startup (bool first_time)
-{
-  if (first_time)
-    {
-      ptmalloc_init_minimal ();
-      save_malloc_hook = dlmalloc_hook;
-      save_memalign_hook = dlmemalign_hook;
-      save_free_hook = dlfree_hook;
-      dlmalloc_hook = malloc_starter;
-      dlmemalign_hook = memalign_starter;
-      dlfree_hook = free_starter;
-    }
-  else
-    {
-      dlmalloc_hook = save_malloc_hook;
-      dlmemalign_hook = save_memalign_hook;
-      dlfree_hook = save_free_hook;
-    }
-}
-# endif
-#endif
 
 static void ptmalloc_init(void)
 {
@@ -445,21 +341,9 @@ static void ptmalloc_init(void)
 		return;
 	__malloc_initialized = 0;
 
-#ifdef _LIBC
-#if defined SHARED && !USE___THREAD
-	/* ptmalloc_init_minimal may already have been called via
-	   __libc_malloc_pthread_startup, above.  */
-	if (mp_.pagesize == 0)
-#endif
-#endif
 		ptmalloc_init_minimal();
 
 #ifndef NO_THREADS
-#if defined _LIBC
-	/* We know __pthread_initialize_minimal has already been called,
-	   and that is enough.  */
-#define NO_STARTER
-#endif
 #ifndef NO_STARTER
 	/* With some threads implementations, creating thread-specific data
 	   or initializing a mutex may call malloc() itself.  Provide a
@@ -470,25 +354,11 @@ static void ptmalloc_init(void)
 	dlmalloc_hook = malloc_starter;
 	dlmemalign_hook = memalign_starter;
 	dlfree_hook = free_starter;
-#ifdef _LIBC
-	/* Initialize the pthreads interface. */
-	if (__pthread_initialize != NULL)
-		__pthread_initialize();
-#endif				/* !defined _LIBC */
 #endif				/* !defined NO_STARTER */
 #endif				/* !defined NO_THREADS */
 	mutex_init(&main_arena.mutex);
 	main_arena.next = &main_arena;
 
-#if defined _LIBC && defined SHARED
-	/* In case this libc copy is in a non-default namespace, never use brk.
-	   Likewise if dlopened from statically linked program.  */
-	Dl_info di;
-	struct link_map *l;
-
-	if (_dl_open_hook != NULL || (_dl_addr(ptmalloc_init, &di, &l, NULL) != 0 && l->l_ns != LM_ID_BASE))
-		__morecore = __failing_morecore;
-#endif
 
 	mutex_init(&list_lock);
 	tsd_key_create(&arena_key, NULL);
@@ -503,67 +373,6 @@ static void ptmalloc_init(void)
 #undef NO_STARTER
 #endif
 #endif
-#ifdef _LIBC
-	secure = __libc_enable_secure;
-	s = NULL;
-	if (__builtin_expect(_environ != NULL, 1)) {
-		char **runp = _environ;
-		char *envline;
-
-		while (__builtin_expect((envline = next_env_entry(&runp)) != NULL, 0)) {
-			size_t len = strcspn(envline, "=");
-
-			if (envline[len] != '=')
-				/* This is a "MALLOC_" variable at the end of the string
-				   without a '=' character.  Ignore it since otherwise we
-				   will access invalid memory below.  */
-				continue;
-
-			switch (len) {
-			case 6:
-				if (memcmp(envline, "CHECK_", 6) == 0)
-					s = &envline[7];
-				break;
-			case 8:
-				if (!secure) {
-					if (memcmp(envline, "TOP_PAD_", 8) == 0)
-						mALLOPt(M_TOP_PAD, atoi(&envline[9]));
-					else if (memcmp(envline, "PERTURB_", 8) == 0)
-						mALLOPt(M_PERTURB, atoi(&envline[9]));
-				}
-				break;
-			case 9:
-				if (!secure) {
-					if (memcmp(envline, "MMAP_MAX_", 9) == 0)
-						mALLOPt(M_MMAP_MAX, atoi(&envline[10]));
-#ifdef PER_THREAD
-					else if (memcmp(envline, "ARENA_MAX", 9) == 0)
-						mALLOPt(M_ARENA_MAX, atoi(&envline[10]));
-#endif
-				}
-				break;
-#ifdef PER_THREAD
-			case 10:
-				if (!secure) {
-					if (memcmp(envline, "ARENA_TEST", 10) == 0)
-						mALLOPt(M_ARENA_TEST, atoi(&envline[11]));
-				}
-				break;
-#endif
-			case 15:
-				if (!secure) {
-					if (memcmp(envline, "TRIM_THRESHOLD_", 15) == 0)
-						mALLOPt(M_TRIM_THRESHOLD, atoi(&envline[16]));
-					else if (memcmp(envline, "MMAP_THRESHOLD_", 15) == 0)
-						mALLOPt(M_MMAP_THRESHOLD, atoi(&envline[16]));
-				}
-				break;
-			default:
-				break;
-			}
-		}
-	}
-#else
 	if (!secure) {
 		if ((s = getenv("MALLOC_TRIM_THRESHOLD_")))
 			mALLOPt(M_TRIM_THRESHOLD, atoi(s));
@@ -577,7 +386,6 @@ static void ptmalloc_init(void)
 			mALLOPt(M_MMAP_MAX, atoi(s));
 	}
 	s = getenv("MALLOC_CHECK_");
-#endif
 	if (s && s[0]) {
 		mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0'));
 		if (check_action != 0)
@@ -863,20 +671,12 @@ static struct malloc_state *_int_new_arena(size_t size)
 	mutex_init(&a->mutex);
 	(void)mutex_lock(&a->mutex);
 
-#ifdef PER_THREAD
-	(void)mutex_lock(&list_lock);
-#endif
 
 	/* Add the new arena to the global list.  */
 	a->next = main_arena.next;
 	atomic_write_barrier();
 	main_arena.next = a;
 
-#ifdef PER_THREAD
-	++narenas;
-
-	(void)mutex_unlock(&list_lock);
-#endif
 
 	THREAD_STAT(++(a->stat_lock_loop));
 
@@ -884,94 +684,11 @@ static struct malloc_state *_int_new_arena(size_t size)
 }
 
 
-#ifdef PER_THREAD
-static struct malloc_state *
-get_free_list (void)
-{
-  struct malloc_state * result = free_list;
-  if (result != NULL)
-    {
-      (void)mutex_lock(&list_lock);
-      result = free_list;
-      if (result != NULL)
-	free_list = result->next_free;
-      (void)mutex_unlock(&list_lock);
-
-      if (result != NULL)
-	{
-	  (void)mutex_lock(&result->mutex);
-	  tsd_setspecific(arena_key, (Void_t *)result);
-	  THREAD_STAT(++(result->stat_lock_loop));
-	}
-    }
-
-  return result;
-}
-
-
-static struct malloc_state *
-reused_arena (void)
-{
-  if (narenas <= mp_.arena_test)
-    return NULL;
-
-  static int narenas_limit;
-  if (narenas_limit == 0)
-    {
-      if (mp_.arena_max != 0)
-	narenas_limit = mp_.arena_max;
-      else
-	{
-	  int n  = __get_nprocs ();
-
-	  if (n >= 1)
-	    narenas_limit = NARENAS_FROM_NCORES (n);
-	  else
-	    /* We have no information about the system.  Assume two
-	       cores.  */
-	    narenas_limit = NARENAS_FROM_NCORES (2);
-	}
-    }
-
-  if (narenas < narenas_limit)
-    return NULL;
-
-  struct malloc_state * result;
-  static struct malloc_state * next_to_use;
-  if (next_to_use == NULL)
-    next_to_use = &main_arena;
-
-  result = next_to_use;
-  do
-    {
-      if (!mutex_trylock(&result->mutex))
-	goto out;
-
-      result = result->next;
-    }
-  while (result != next_to_use);
-
-  /* No arena available.  Wait for the next in line.  */
-  (void)mutex_lock(&result->mutex);
-
- out:
-  tsd_setspecific(arena_key, (Void_t *)result);
-  THREAD_STAT(++(result->stat_lock_loop));
-  next_to_use = result->next;
-
-  return result;
-}
-#endif
 
 static struct malloc_state *internal_function arena_get2(struct malloc_state *a_tsd, size_t size)
 {
 	struct malloc_state *a;
 
-#ifdef PER_THREAD
-	if ((a = get_free_list()) == NULL && (a = reused_arena()) == NULL)
-		/* Nothing immediately available, so generate a new arena.  */
-		a = _int_new_arena(size);
-#else
 	if (!a_tsd)
 		a = a_tsd = &main_arena;
 	else {
@@ -1015,29 +732,10 @@ static struct malloc_state *internal_function arena_get2(struct malloc_state *a_
 	/* Nothing immediately available, so generate a new arena.  */
 	a = _int_new_arena(size);
 	(void)mutex_unlock(&list_lock);
-#endif
 
 	return a;
 }
 
-#ifdef PER_THREAD
-static void __attribute__ ((section ("__libc_thread_freeres_fn")))
-arena_thread_freeres (void)
-{
-  Void_t *vptr = NULL;
-  struct malloc_state * a = tsd_getspecific(arena_key, vptr);
-  tsd_setspecific(arena_key, NULL);
-
-  if (a != NULL)
-    {
-      (void)mutex_lock(&list_lock);
-      a->next_free = free_list;
-      free_list = a;
-      (void)mutex_unlock(&list_lock);
-    }
-}
-text_set_element (__libc_thread_subfreeres, arena_thread_freeres);
-#endif
 
 
 /*
diff --git a/tpc/malloc2.13/hooks.h b/tpc/malloc2.13/hooks.h
index 48f54f915275..209544da5377 100644
--- a/tpc/malloc2.13/hooks.h
+++ b/tpc/malloc2.13/hooks.h
@@ -367,12 +367,6 @@ memalign_check(size_t alignment, size_t bytes, const Void_t *caller)
 
 #ifndef NO_THREADS
 
-# ifdef _LIBC
-#  if USE___THREAD || !defined SHARED
-    /* These routines are never needed in this configuration.  */
-#   define NO_STARTER
-#  endif
-# endif
 
 # ifdef NO_STARTER
 #  undef NO_STARTER
@@ -512,11 +506,6 @@ public_gET_STATe(void)
   ms->max_mmapped_mem = mp_.max_mmapped_mem;
   ms->using_malloc_checking = using_malloc_checking;
   ms->max_fast = get_max_fast();
-#ifdef PER_THREAD
-  ms->arena_test = mp_.arena_test;
-  ms->arena_max = mp_.arena_max;
-  ms->narenas = narenas;
-#endif
   (void)mutex_unlock(&main_arena.mutex);
   return (Void_t*)ms;
 }
@@ -616,11 +605,6 @@ public_sET_STATe(Void_t* msptr)
     }
   }
   if (ms->version >= 4) {
-#ifdef PER_THREAD
-    mp_.arena_test = ms->arena_test;
-    mp_.arena_max = ms->arena_max;
-    narenas = ms->narenas;
-#endif
   }
   check_malloc_state(&main_arena);
 
diff --git a/tpc/malloc2.13/malloc.c b/tpc/malloc2.13/malloc.c
index c9644c382e05..a420ef278e68 100644
--- a/tpc/malloc2.13/malloc.c
+++ b/tpc/malloc2.13/malloc.c
@@ -248,14 +248,6 @@ __declspec(dllexport) void malloc2_13_bogus_symbol()
 
 #include <malloc-machine.h>
 
-#ifdef _LIBC
-#ifdef ATOMIC_FASTBINS
-#include <atomic.h>
-#endif
-#include <_itoa.h>
-#include <bits/wordsize.h>
-#include <sys/sysinfo.h>
-#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -460,39 +452,6 @@ extern "C" {
 #define public_gET_STATe dlget_state
 #define public_sET_STATe dlset_state
 #else /* USE_DL_PREFIX */
-#if defined(_LIBC)
-
-/* Special defines for the GNU C library.  */
-#define public_cALLOc    __libc_calloc
-#define public_fREe      __libc_free
-#define public_cFREe     __libc_cfree
-#define public_mALLOc    __libc_malloc
-#define public_mEMALIGn  __libc_memalign
-#define public_rEALLOc   __libc_realloc
-#define public_vALLOc    __libc_valloc
-#define public_pVALLOc   __libc_pvalloc
-#define public_mALLINFo  __libc_mallinfo
-#define public_mALLOPt   __libc_mallopt
-#define public_mTRIm     __malloc_trim
-#define public_mSTATs    __malloc_stats
-#define public_mUSABLe   __malloc_usable_size
-#define public_iCALLOc   __libc_independent_calloc
-#define public_iCOMALLOc __libc_independent_comalloc
-#define public_gET_STATe __malloc_get_state
-#define public_sET_STATe __malloc_set_state
-#define malloc_getpagesize __getpagesize()
-#define open             __open
-#define mmap             __mmap
-#define munmap           __munmap
-#define mremap           __mremap
-#define mprotect         __mprotect
-#define MORECORE         (*__morecore)
-#define MORECORE_FAILURE 0
-
-Void_t * __default_morecore (ptrdiff_t);
-Void_t *(*__morecore)(ptrdiff_t) = __default_morecore;
-
-#else /* !_LIBC */
 #define public_cALLOc    calloc
 #define public_fREe      free
 #define public_cFREe     cfree
@@ -511,14 +470,11 @@ Void_t *(*__morecore)(ptrdiff_t) = __default_morecore;
 #define public_gET_STATe malloc_get_state
 #define public_sET_STATe malloc_set_state
 
-#endif /* _LIBC */
 #endif /* USE_DL_PREFIX */
 
-#ifndef _LIBC
 #define __builtin_expect(expr, val)	(expr)
 
 #define fwrite(buf, size, count, fp) _IO_fwrite (buf, size, count, fp)
-#endif
 
 /*
   HAVE_MEMCPY should be defined if you are not otherwise using
@@ -546,16 +502,12 @@ Void_t *(*__morecore)(ptrdiff_t) = __default_morecore;
 
 
 
-#ifdef _LIBC
-# include <string.h>
-#else
 #ifdef WIN32
 /* On Win32 memset and memcpy are already declared in windows.h */
 #else
 void* memset(void*, int, size_t);
 void* memcpy(void*, const void*, size_t);
 #endif
-#endif
 
 
 /* Force a value to be in a register and stop the compiler referring
@@ -930,7 +882,6 @@ int      public_mALLOPt(int, int);
 */
 struct mallinfo public_mALLINFo(void);
 
-#ifndef _LIBC
 /*
   independent_calloc(size_t n_elements, size_t element_size, Void_t* chunks[]);
 
@@ -1046,7 +997,6 @@ Void_t** public_iCALLOc(size_t, size_t, Void_t**);
 */
 Void_t** public_iCOMALLOc(size_t, size_t*, Void_t**);
 
-#endif /* _LIBC */
 
 
 /*
@@ -1147,7 +1097,7 @@ Void_t*  public_gET_STATe(void);
 */
 int      public_sET_STATe(Void_t*);
 
-#if defined(_LIBC) || defined(PURE_HACK)
+#if defined(PURE_HACK)
 /*
   posix_memalign(void **memptr, size_t alignment, size_t size);
 
@@ -1493,10 +1443,8 @@ static Void_t*  _int_memalign(struct malloc_state *, size_t, size_t);
 static Void_t*  _int_valloc(struct malloc_state *, size_t);
 static Void_t*  _int_pvalloc(struct malloc_state *, size_t);
 /*static Void_t*  cALLOc(size_t, size_t);*/
-#ifndef _LIBC
 static Void_t** _int_icalloc(struct malloc_state *, size_t, size_t, Void_t**);
 static Void_t** _int_icomalloc(struct malloc_state *, size_t, size_t*, Void_t**);
-#endif
 static int      mTRIm(struct malloc_state *, size_t);
 static size_t   mUSABLe(Void_t*);
 static void     mSTATs(void);
@@ -1518,12 +1466,6 @@ static Void_t*   realloc_check(Void_t* oldmem, size_t bytes,
 static Void_t*   memalign_check(size_t alignment, size_t bytes,
 				const Void_t *caller);
 #ifndef NO_THREADS
-# ifdef _LIBC
-#  if USE___THREAD || !defined SHARED
-    /* These routines are never needed in this configuration.  */
-#   define NO_STARTER
-#  endif
-# endif
 # ifdef NO_STARTER
 #  undef NO_STARTER
 # else
@@ -2238,10 +2180,6 @@ struct malloc_state {
 	/* Linked list */
 	struct malloc_state *next;
 
-#ifdef PER_THREAD
-	/* Linked list for free arenas.  */
-	struct malloc_state *next_free;
-#endif
 
 	/* Memory allocated from the system in this arena.  */
 	INTERNAL_SIZE_T system_mem;
@@ -2253,10 +2191,6 @@ struct malloc_par {
   unsigned long    trim_threshold;
   INTERNAL_SIZE_T  top_pad;
   INTERNAL_SIZE_T  mmap_threshold;
-#ifdef PER_THREAD
-  INTERNAL_SIZE_T  arena_test;
-  INTERNAL_SIZE_T  arena_max;
-#endif
 
   /* Memory map support */
   int              n_mmaps;
@@ -2294,11 +2228,6 @@ static struct malloc_state main_arena;
 static struct malloc_par mp_;
 
 
-#ifdef PER_THREAD
-/*  Non public mallopt parameters.  */
-#define M_ARENA_TEST -7
-#define M_ARENA_MAX  -8
-#endif
 
 
 /* Maximum size of memory handled in fastbins.  */
@@ -2343,9 +2272,7 @@ static void malloc_init_state(struct malloc_state * av)
 static Void_t*  sYSMALLOc(INTERNAL_SIZE_T, struct malloc_state *);
 static int      sYSTRIm(size_t, struct malloc_state *);
 static void     malloc_consolidate(struct malloc_state *);
-#ifndef _LIBC
 static Void_t** iALLOc(struct malloc_state *, size_t, size_t*, int, Void_t**);
-#endif
 
 
 /* -------------- Early definitions for debugging hooks ---------------- */
@@ -2353,13 +2280,7 @@ static Void_t** iALLOc(struct malloc_state *, size_t, size_t*, int, Void_t**);
 /* Define and initialize the hook variables.  These weak definitions must
    appear before any use of the variables in a function (arena.c uses one).  */
 #ifndef weak_variable
-#ifndef _LIBC
 #define weak_variable /**/
-#else
-/* In GNU libc we want the hook variables to be weak definitions to
-   avoid a problem with Emacs.  */
-#define weak_variable weak_function
-#endif
 #endif
 
 /* Forward declarations.  */
@@ -3555,7 +3476,7 @@ public_rEALLOc(Void_t* oldmem, size_t bytes)
   (void)mutex_lock(&ar_ptr->mutex);
 #endif
 
-#if !defined NO_THREADS && !defined PER_THREAD
+#if !defined NO_THREADS
   /* As in malloc(), remember this arena for the next allocation. */
   tsd_setspecific(arena_key, (Void_t *)ar_ptr);
 #endif
@@ -3801,7 +3722,6 @@ Void_t *public_cALLOc(size_t n, size_t elem_size)
 	return mem;
 }
 
-#ifndef _LIBC
 
 Void_t**
 public_iCALLOc(size_t n, size_t elem_size, Void_t** chunks)
@@ -3839,7 +3759,6 @@ public_cFREe(Void_t* m)
   public_fREe(m);
 }
 
-#endif /* _LIBC */
 
 int
 public_mTRIm(size_t s)
@@ -5214,7 +5133,6 @@ _int_memalign(struct malloc_state * av, size_t alignment, size_t bytes)
   return chunk2mem(p);
 }
 
-#ifndef _LIBC
 /*
   ------------------------- independent_calloc -------------------------
 */
@@ -5363,7 +5281,6 @@ iALLOc(struct malloc_state * av, size_t n_elements, size_t* sizes, int opts, Voi
 
   return marray;
 }
-#endif /* _LIBC */
 
 
 /*
@@ -5546,11 +5463,6 @@ void mSTATs()
 
   if(__malloc_initialized < 0)
     ptmalloc_init ();
-#ifdef _LIBC
-  _IO_flockfile (stderr);
-  int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
-  ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
-#endif
   for (i=0, ar_ptr = &main_arena;; i++) {
     (void)mutex_lock(&ar_ptr->mutex);
     mi = mALLINFo(ar_ptr);
@@ -5589,10 +5501,6 @@ void mSTATs()
   fprintf(stderr, "locked total     = %10ld\n",
 	  stat_lock_direct + stat_lock_loop + stat_lock_wait);
 #endif
-#ifdef _LIBC
-  ((_IO_FILE *) stderr)->_flags2 |= old_flags2;
-  _IO_funlockfile (stderr);
-#endif
 }
 
 
@@ -5652,17 +5560,6 @@ int mALLOPt(int param_number, int value)
     perturb_byte = value;
     break;
 
-#ifdef PER_THREAD
-  case M_ARENA_TEST:
-    if (value > 0)
-      mp_.arena_test = value;
-    break;
-
-  case M_ARENA_MAX:
-    if (value > 0)
-      mp_.arena_max = value;
-    break;
-#endif
   }
   (void)mutex_unlock(&av->mutex);
   return res;
@@ -5841,7 +5738,7 @@ malloc_printerr(int action, const char *str, void *ptr)
 }
 #endif
 
-#if defined(_LIBC) || defined(PURE_HACK)
+#if defined(PURE_HACK)
 # include <sys/param.h>
 
 /* We need a wrapper function for one of the additions of POSIX.  */
-- 
2.7.0.rc3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]