Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-02-07 20:22:40 +0300
committerCorinna Vinschen <corinna@vinschen.de>2007-02-07 20:22:40 +0300
commit59e3b6ca7dc10603d1e692928a236fe5a0523200 (patch)
tree17949dbe48d690e650c7b3cefa903f711e49477d /winsup/cygwin/malloc_wrapper.cc
parent0e37a2e6e5f9bd3922f050da2a09b0e9d1dc5afd (diff)
* cygmalloc.h (MALLOC_FAILURE_ACTION): Define empty.
* cygwin.din (posix_madvise): Export. (posix_memalign): Export. * fhandler.cc (fhandler_base::fpathconf): Return useful values in _PC_VDISABLE, _PC_SYNC_IO and _PC_SYMLINK_MAX cases. * malloc_wrapper.cc (malloc): Set errno here since it's not set in dlmalloc.c anymore. (realloc): Ditto. (calloc): Ditto. (memalign): Ditto. (valloc): Ditto. (posix_memalign): New function. * mmap.cc (posix_madvise): New function. * sysconf.cc (get_open_max): New function. (get_page_size): Ditto. (get_nproc_values): Ditto. (get_avphys): Ditto. (sc_type): New type. (sca): New array to map _SC_xxx options to sysconf return values. (sysconf): Reimplement using sca array. * include/limits.h: Add all missing values as defined by SUSv3. * include/pthread.h (PTHREAD_DESTRUCTOR_ITERATIONS): Move definition to sys/limits.h. (PTHREAD_KEYS_MAX): Ditto. * include/semaphore.h (SEM_VALUE_MAX): Ditto. * include/cygwin/stdlib.h (posix_memalign): Declare. * include/cygwin/version.h: Bump API minor number. * include/sys/mman.h: Add posix_madvise flags. (posix_madvise): Declare. * include/sys/termios.h (_POSIX_VDISABLE): Move definition to sys/limits.h.
Diffstat (limited to 'winsup/cygwin/malloc_wrapper.cc')
-rw-r--r--winsup/cygwin/malloc_wrapper.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 90689ffee..086c43d36 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -1,7 +1,7 @@
/* malloc_wrapper.cc
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
- Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ 2006, 2007 Red Hat, Inc.
Originally written by Steve Chamberlain of Cygnus Support
sac@cygnus.com
@@ -70,6 +70,8 @@ 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;
}
@@ -86,6 +88,8 @@ 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;
}
@@ -102,9 +106,29 @@ 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)
+{
+ void *res;
+ if (!use_internal_malloc)
+ return ENOSYS;
+ if ((alignment & (alignment - 1)) != 0)
+ return EINVAL;
+ __malloc_lock ();
+ res = dlmemalign (alignment, bytes);
+ __malloc_unlock ();
+ if (!res)
+ return ENOMEM;
+ if (memptr)
+ *memptr = res;
+ return 0;
+}
+
extern "C" void *
memalign (size_t alignment, size_t bytes)
{
@@ -119,6 +143,8 @@ memalign (size_t alignment, size_t bytes)
__malloc_lock ();
res = dlmemalign (alignment, bytes);
__malloc_unlock ();
+ if (!res)
+ set_errno (ENOMEM);
}
return res;
@@ -138,6 +164,8 @@ valloc (size_t bytes)
__malloc_lock ();
res = dlvalloc (bytes);
__malloc_unlock ();
+ if (!res)
+ set_errno (ENOMEM);
}
return res;