Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
malloc: Remove NO_THREADS
No functional change.  It was not possible to build without
threading support before.
  • Loading branch information
Florian Weimer committed Feb 19, 2016
1 parent ca135f8 commit 59eda02
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2016-02-19 Florian Weimer <fweimer@redhat.com>

* sysdeps/generic/malloc-machine.h: Assume mutex_init is always
available. Do not define NO_THREADS.
* malloc/malloc.c: Do not check NO_THREADS.
* malloc/arena.c: Likewise.

2016-02-19 Florian Weimer <fweimer@redhat.com> 2016-02-19 Florian Weimer <fweimer@redhat.com>


* malloc/malloc.c (__libc_mallinfo): Update comment. * malloc/malloc.c (__libc_mallinfo): Update comment.
Expand Down
3 changes: 0 additions & 3 deletions malloc/arena.c
Expand Up @@ -127,8 +127,6 @@ int __malloc_initialized = -1;


/**************************************************************************/ /**************************************************************************/


#ifndef NO_THREADS

/* atfork support. */ /* atfork support. */


static void *(*save_malloc_hook)(size_t __size, const void *); static void *(*save_malloc_hook)(size_t __size, const void *);
Expand Down Expand Up @@ -327,7 +325,6 @@ ptmalloc_unlock_all2 (void)


# define ptmalloc_unlock_all2 ptmalloc_unlock_all # define ptmalloc_unlock_all2 ptmalloc_unlock_all
# endif # endif
#endif /* !NO_THREADS */


/* Initialization routine. */ /* Initialization routine. */
#include <string.h> #include <string.h>
Expand Down
2 changes: 0 additions & 2 deletions malloc/malloc.c
Expand Up @@ -1073,10 +1073,8 @@ static void* realloc_check(void* oldmem, size_t bytes,
const void *caller); const void *caller);
static void* memalign_check(size_t alignment, size_t bytes, static void* memalign_check(size_t alignment, size_t bytes,
const void *caller); const void *caller);
#ifndef NO_THREADS
static void* malloc_atfork(size_t sz, const void *caller); static void* malloc_atfork(size_t sz, const void *caller);
static void free_atfork(void* mem, const void *caller); static void free_atfork(void* mem, const void *caller);
#endif


/* ------------------ MMAP support ------------------ */ /* ------------------ MMAP support ------------------ */


Expand Down
19 changes: 0 additions & 19 deletions sysdeps/generic/malloc-machine.h
Expand Up @@ -22,25 +22,6 @@


#include <atomic.h> #include <atomic.h>


#ifndef mutex_init /* No threads, provide dummy macros */

# define NO_THREADS

/* The mutex functions used to do absolutely nothing, i.e. lock,
trylock and unlock would always just return 0. However, even
without any concurrently active threads, a mutex can be used
legitimately as an `in use' flag. To make the code that is
protected by a mutex async-signal safe, these macros would have to
be based on atomic test-and-set operations, for example. */
typedef int mutex_t;

# define mutex_init(m) (*(m) = 0)
# define mutex_lock(m) ({ *(m) = 1; 0; })
# define mutex_trylock(m) (*(m) ? 1 : ((*(m) = 1), 0))
# define mutex_unlock(m) (*(m) = 0)

#endif /* !defined mutex_init */

#ifndef atomic_full_barrier #ifndef atomic_full_barrier
# define atomic_full_barrier() __asm ("" ::: "memory") # define atomic_full_barrier() __asm ("" ::: "memory")
#endif #endif
Expand Down

0 comments on commit 59eda02

Please sign in to comment.