+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.
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 ()
__malloc_unlock ();
}
malloc_printf ("(%d) = %x, called by %p", size, res, __builtin_return_address (0));
- if (!res)
- set_errno (ENOMEM);
return res;
}
__malloc_unlock ();
}
malloc_printf ("(%x, %d) = %x, called by %x", p, size, res, __builtin_return_address (0));
- if (!res)
- set_errno (ENOMEM);
return res;
}
__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;
__malloc_lock ();
res = dlmemalign (alignment, bytes);
__malloc_unlock ();
- if (!res)
- set_errno (ENOMEM);
}
return res;
__malloc_lock ();
res = dlvalloc (bytes);
__malloc_unlock ();
- if (!res)
- set_errno (ENOMEM);
}
return res;
}
#endif
}
+
+extern "C" void
+__set_ENOMEM ()
+{
+ set_errno (ENOMEM);
+}