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] |
Hi, Alle martedì 15 gennaio 2013, Roland McGrath ha scritto: > > - HAVE_MREMAP 0 unless linux defined > > + HAVE_MREMAP 0 unless linux or __ASSUME_MREMAP > > defined > > Just simplify the condition to __ASSUME_MREMAP. > We don't want anything like #ifdef linux in libc internals. OK. > But, I'm not really convinced that kernel-features.h is the right way > to do this. We have malloc-sysdep.h now, so that could just define > HAVE_MREMAP directly. I see, malloc-sysdep.h seems a better fit then, assuming it is fine using it outside of malloc itself. > I do think it would be nice to have a single > place define it rather than having both HAVE_REMAP for malloc and > _G_HAVE_MREMAP for libio. Yes, that is what my patch does. Attached there is a new version of it, updated after your feedback. > But I never liked the use of > kernel-features.h outside linux-specific files. OTOH, it is the > status quo that it is used in a few generic files already. So > perhaps using it a little more is not so bad. I guess this would warrant an own discussion. -- Pino Toscano
Add and use HAVE_MREMAP for mremap usage Introduce a HAVE_MREMAP symbol to advertize mremap availability, and use it also to replace _G_HAVE_MREMAP. 2013-01-15 Pino Toscano <toscano.pino@tiscali.it> * sysdeps/unix/sysv/linux/malloc-sysdep.h (HAVE_MREMAP): New define. * malloc/malloc.c: Include <unistd.h> and <malloc-sysdep.h>. [!HAVE_MREMAP]: Remove [defined linux] case. * malloc/arena.c: Do not include <malloc-sysdep.h>. * libio/fileops.c [_LIBC]: Include <malloc-sysdep.h>. (mmap_remap_check) [defined _G_HAVE_MREMAP]: Change condition to [defined HAVE_MREMAP]. * sysdeps/unix/sysv/linux/_G_config.h (_G_HAVE_MREMAP): Remove. --- a/libio/fileops.c +++ b/libio/fileops.c @@ -46,6 +46,7 @@ # include <shlib-compat.h> # include <not-cancel.h> # include <kernel-features.h> +# include <malloc-sysdep.h> #endif #ifndef errno extern int errno; @@ -650,7 +651,7 @@ mmap_remap_check (_IO_FILE *fp) { /* The file added some pages. We need to remap it. */ void *p; -#ifdef _G_HAVE_MREMAP +#ifdef HAVE_MREMAP p = __mremap (fp->_IO_buf_base, ROUNDED (fp->_IO_buf_end - fp->_IO_buf_base), ROUNDED (st.st_size), MREMAP_MAYMOVE); --- a/malloc/arena.c +++ b/malloc/arena.c @@ -19,9 +19,6 @@ #include <stdbool.h> -/* Get the implementation for check_may_shrink_heap. */ -#include <malloc-sysdep.h> - /* Compile-time constants. */ #define HEAP_MIN_SIZE (32*1024) --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -168,7 +168,7 @@ Compilation Environment options: - HAVE_MREMAP 0 unless linux defined + HAVE_MREMAP 0 Changing default word sizes: @@ -214,8 +214,10 @@ #include <stddef.h> /* for size_t */ #include <stdlib.h> /* for getenv(), abort() */ +#include <unistd.h> /* for __libc_enable_secure */ #include <malloc-machine.h> +#include <malloc-sysdep.h> #include <atomic.h> #include <_itoa.h> @@ -490,19 +492,13 @@ void *(*__morecore)(ptrdiff_t) = __defau /* Define HAVE_MREMAP to make realloc() use mremap() to re-allocate - large blocks. This is currently only possible on Linux with - kernel versions newer than 1.3.77. + large blocks. */ #ifndef HAVE_MREMAP -#ifdef linux -#define HAVE_MREMAP 1 -#else #define HAVE_MREMAP 0 #endif -#endif /* HAVE_MREMAP */ - /* This version of malloc supports the standard SVID/XPG mallinfo --- a/sysdeps/unix/sysv/linux/_G_config.h +++ b/sysdeps/unix/sysv/linux/_G_config.h @@ -46,7 +46,6 @@ typedef union #define _G_va_list __gnuc_va_list #define _G_HAVE_MMAP 1 -#define _G_HAVE_MREMAP 1 #define _G_IO_IO_FILE_VERSION 0x20001 --- a/sysdeps/unix/sysv/linux/malloc-sysdep.h +++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h @@ -55,3 +55,5 @@ check_may_shrink_heap (void) return may_shrink_heap; } + +#define HAVE_MREMAP 1
Attachment:
signature.asc
Description: This is a digitally signed message part.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |