diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2007-02-08 14:35:52 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2007-02-08 14:35:52 +0300 |
commit | 0bce6570f0a3060f0ae83c74b512acd9be0ebad6 (patch) | |
tree | 0fbbb3e4c20a69d53cfc98ae7dbd1ff6110795f0 | |
parent | d4c6243390c1486d3e86d618e218f5360557589c (diff) |
* cygmalloc.h (__set_ENOMEM): Declare.
(MALLOC_FAILURE_ACTION): Call __set_ENOMEM.
* malloc_wrapper.cc (malloc) Remove setting errno here.
(realloc): Ditto.
(calloc): Ditto.
(memalign): Ditto.
(valloc): Ditto.
(posix_memalign): Save and restore errno.
-rw-r--r-- | winsup/cygwin/ChangeLog | 12 | ||||
-rw-r--r-- | winsup/cygwin/cygmalloc.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/malloc_wrapper.cc | 18 |
3 files changed, 22 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 94ac756aa..46ebb1c7b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2007-02-08 Christopher Faylor <me@cgf.cx> + Corinna Vinschen <corinna@vinschen.de> + + * cygmalloc.h (__set_ENOMEM): Declare. + (MALLOC_FAILURE_ACTION): Call __set_ENOMEM. + * malloc_wrapper.cc (malloc) Remove setting errno here. + (realloc): Ditto. + (calloc): Ditto. + (memalign): Ditto. + (valloc): Ditto. + (posix_memalign): Save and restore errno. + 2007-02-07 Corinna Vinschen <corinna@vinschen.de> * cygmalloc.h (MALLOC_FAILURE_ACTION): Move to correct #if branch. diff --git a/winsup/cygwin/cygmalloc.h b/winsup/cygwin/cygmalloc.h index 5d38724a2..5c2a29a3b 100644 --- a/winsup/cygwin/cygmalloc.h +++ b/winsup/cygwin/cygmalloc.h @@ -23,7 +23,8 @@ int dlmallopt (int p, int v) __attribute__ ((regparm (2))); void dlmalloc_stats (); #ifndef __INSIDE_CYGWIN__ -# define MALLOC_FAILURE_ACTION +extern "C" void __set_ENOMEM (); +# define MALLOC_FAILURE_ACTION __set_ENOMEM () # define USE_DL_PREFIX 1 #else # define __malloc_lock() mallock.acquire () diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc index 086c43d36..dce4a77dc 100644 --- a/winsup/cygwin/malloc_wrapper.cc +++ b/winsup/cygwin/malloc_wrapper.cc @@ -70,8 +70,6 @@ malloc (size_t size) __malloc_unlock (); } malloc_printf ("(%d) = %x, called by %p", size, res, __builtin_return_address (0)); - if (!res) - set_errno (ENOMEM); return res; } @@ -88,8 +86,6 @@ realloc (void *p, size_t size) __malloc_unlock (); } malloc_printf ("(%x, %d) = %x, called by %x", p, size, res, __builtin_return_address (0)); - if (!res) - set_errno (ENOMEM); return res; } @@ -106,14 +102,14 @@ calloc (size_t nmemb, size_t size) __malloc_unlock (); } malloc_printf ("(%d, %d) = %x, called by %x", nmemb, size, res, __builtin_return_address (0)); - if (!res) - set_errno (ENOMEM); return res; } extern "C" int posix_memalign (void **memptr, size_t alignment, size_t bytes) { + save_errno save; + void *res; if (!use_internal_malloc) return ENOSYS; @@ -143,8 +139,6 @@ memalign (size_t alignment, size_t bytes) __malloc_lock (); res = dlmemalign (alignment, bytes); __malloc_unlock (); - if (!res) - set_errno (ENOMEM); } return res; @@ -164,8 +158,6 @@ valloc (size_t bytes) __malloc_lock (); res = dlvalloc (bytes); __malloc_unlock (); - if (!res) - set_errno (ENOMEM); } return res; @@ -299,3 +291,9 @@ malloc_init () } #endif } + +extern "C" void +__set_ENOMEM () +{ + set_errno (ENOMEM); +} |