* Makefile.in: Add support for new malloc.o and renamed malloc_wrapper.o. Use

-fomit-frame-pointer for malloc.o compilation.
* malloc_wrapper.cc: New file.  Rename from malloc.cc.  Add support for more
malloc functions.  Eliminate export_* calls.  Just use straight malloc names.
Remove unused argument from malloc lock functions.
* cygwin.din: Just export straight malloc names.  Add malloc_stats,
malloc_trim, malloc_usable_size, mallopt, memalign, valloc.
* dcrt0.cc (__cygwin_user): Eliminate export_* malloc entries.
* fork.cc (fork_parent): Remove unused argument from malloc_lock argument.
* malloc.cc: New file.  Doug Lea's malloc v2.7.1.
* cygmalloc.h: New file.
* include/cygwin/version.h: Bump API_MINOR.
* sync.h (muto::acquire): Use appropriate number for regparm attribute.
(muto::reset): Ditto.
(muto::release): Ditto.
This commit is contained in:
Christopher Faylor 2002-08-16 19:41:39 +00:00
parent 775275aac7
commit c7e2187a60
10 changed files with 5661 additions and 31 deletions

View File

@ -1,3 +1,23 @@
2002-08-16 Christopher Faylor <cgf@redhat.com>
* Makefile.in: Add support for new malloc.o and renamed
malloc_wrapper.o. Use -fomit-frame-pointer for malloc.o compilation.
* malloc_wrapper.cc: New file. Rename from malloc.cc. Add support for
more malloc functions. Eliminate export_* calls. Just use straight
malloc names. Remove unused argument from malloc lock functions.
* cygwin.din: Just export straight malloc names. Add malloc_stats,
malloc_trim, malloc_usable_size, mallopt, memalign, valloc.
* dcrt0.cc (__cygwin_user): Eliminate export_* malloc entries.
* fork.cc (fork_parent): Remove unused argument from malloc_lock
argument.
* malloc.cc: New file. Doug Lea's malloc v2.7.1.
* cygmalloc.h: New file.
* include/cygwin/version.h: Bump API_MINOR.
* sync.h (muto::acquire): Use appropriate number for regparm attribute.
(muto::reset): Ditto.
(muto::release): Ditto.
2002-08-16 Pavel Tsekov <ptsekov@gmx.net> 2002-08-16 Pavel Tsekov <ptsekov@gmx.net>
* exceptions.cc (interrupt_setup): Ensure that the previous signal mask * exceptions.cc (interrupt_setup): Ensure that the previous signal mask

View File

@ -129,13 +129,13 @@ DLL_OFILES:=assert.o autoload.o cygheap.o cygserver_client.o \
fhandler_socket.o fhandler_tape.o fhandler_termios.o fhandler_tty.o \ fhandler_socket.o fhandler_tape.o fhandler_termios.o fhandler_tty.o \
fhandler_virtual.o fhandler_windows.o fhandler_zero.o fnmatch.o fork.o \ fhandler_virtual.o fhandler_windows.o fhandler_zero.o fnmatch.o fork.o \
glob.o grp.o heap.o init.o ioctl.o ipc.o localtime.o malloc.o \ glob.o grp.o heap.o init.o ioctl.o ipc.o localtime.o malloc.o \
miscfuncs.o mmap.o net.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o \ malloc_wrapper.o miscfuncs.o mmap.o net.o ntea.o passwd.o path.o \
pthread.o regcomp.o regerror.o regexec.o regfree.o registry.o \ pinfo.o pipe.o poll.o pthread.o regcomp.o regerror.o regexec.o \
resource.o scandir.o sched.o sec_acl.o sec_helper.o security.o \ regfree.o registry.o resource.o scandir.o sched.o sec_acl.o \
select.o shared.o shm.o shortcut.o signal.o sigproc.o smallprint.o \ sec_helper.o security.o select.o shared.o shm.o shortcut.o signal.o \
spawn.o strace.o strsep.o sync.o syscalls.o sysconf.o syslog.o \ sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o syscalls.o \
termios.o thread.o times.o tty.o uinfo.o uname.o v8_regexp.o \ sysconf.o syslog.o termios.o thread.o times.o tty.o uinfo.o uname.o \
v8_regerror.o v8_regsub.o wait.o wincap.o window.o \ v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
$(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS) $(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
GMON_OFILES:=gmon.o mcount.o profil.o GMON_OFILES:=gmon.o mcount.o profil.o
@ -311,6 +311,9 @@ winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
$(COMPILE_CXX) -o version.o version.cc && \ $(COMPILE_CXX) -o version.o version.cc && \
touch $@ touch $@
malloc.o: malloc.cc
$(COMPILE_CXX) -fomit-frame-pointer -o $@ $<
cygrun.exe : cygrun.o $(LIB_NAME) $(w32api_lib)/libuser32.a \ cygrun.exe : cygrun.o $(LIB_NAME) $(w32api_lib)/libuser32.a \
$(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a $(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a
$(CC) -nodefaultlibs -o $@ $^ -lgcc -lcygwin $(CC) -nodefaultlibs -o $@ $^ -lgcc -lcygwin

28
winsup/cygwin/cygmalloc.h Normal file
View File

@ -0,0 +1,28 @@
/* cygmalloc.h: cygwin DLL malloc stuff
Copyright 2002 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
extern "C" void dlfree (void *p) __attribute__ ((regparm (1)));
extern "C" void *dlmalloc (unsigned size) __attribute__ ((regparm (1)));
extern "C" void *dlrealloc (void *p, unsigned size) __attribute__ ((regparm (2)));
extern "C" void *dlcalloc (size_t nmemb, size_t size) __attribute__ ((regparm (2)));
extern "C" void *dlmemalign (size_t alignment, size_t bytes) __attribute__ ((regparm (2)));
extern "C" void *dlvalloc (size_t bytes) __attribute__ ((regparm (1)));
extern "C" size_t dlmalloc_usable_size (void *p) __attribute__ ((regparm (1)));
extern "C" int dlmalloc_trim (size_t) __attribute__ ((regparm (1)));
extern "C" int dlmallopt (int p, int v) __attribute__ ((regparm (2)));
extern "C" void dlmalloc_stats ();
#ifndef __INSIDE_CYGWIN__
# define USE_DL_PREFIX
#else
# define __malloc_lock() mallock->acquire ()
# define __malloc_unlock() mallock->release ()
extern muto *mallock;
#endif

View File

@ -84,8 +84,8 @@ cabs
_cabs = cabs _cabs = cabs
cabsf cabsf
_cabsf = cabsf _cabsf = cabsf
calloc = export_calloc calloc
_calloc = export_calloc _calloc = calloc
cbrt cbrt
_cbrt = cbrt _cbrt = cbrt
cbrtf cbrtf
@ -296,8 +296,8 @@ fputs
_fputs = fputs _fputs = fputs
fread fread
_fread = fread _fread = fread
free = export_free free
_free = export_free _free = free
freopen freopen
_freopen = freopen _freopen = freopen
frexp frexp
@ -535,8 +535,12 @@ lseek64
lstat = cygwin_lstat lstat = cygwin_lstat
_lstat = cygwin_lstat _lstat = cygwin_lstat
lstat64 lstat64
malloc = export_malloc malloc
_malloc = export_malloc _malloc = malloc
malloc_stats
malloc_trim
malloc_usable_size
mallopt
matherr matherr
_matherr = matherr _matherr = matherr
mblen mblen
@ -545,6 +549,7 @@ mbstowcs
_mbstowcs = mbstowcs _mbstowcs = mbstowcs
mbtowc mbtowc
_mbtowc = mbtowc _mbtowc = mbtowc
memalign
memchr memchr
_memchr = memchr _memchr = memchr
memcmp memcmp
@ -626,8 +631,8 @@ readlink
_readlink = readlink _readlink = readlink
readv readv
_readv = readv _readv = readv
realloc = export_realloc realloc
_realloc = export_realloc _realloc = realloc
posix_regcomp posix_regcomp
posix_regerror posix_regerror
posix_regexec posix_regexec
@ -917,6 +922,7 @@ utimes
_utimes = utimes _utimes = utimes
utmpname utmpname
_utmpname = utmpname _utmpname = utmpname
valloc
vfiprintf vfiprintf
_vfiprintf = vfiprintf _vfiprintf = vfiprintf
vfork vfork

View File

@ -80,11 +80,6 @@ char NO_COPY almost_null[1];
extern "C" extern "C"
{ {
void *export_malloc (unsigned int);
void export_free (void *);
void *export_realloc (void *, unsigned int);
void *export_calloc (unsigned int, unsigned int);
/* This is an exported copy of environ which can be used by DLLs /* This is an exported copy of environ which can be used by DLLs
which use cygwin.dll. */ which use cygwin.dll. */
char **__cygwin_environ; char **__cygwin_environ;
@ -97,12 +92,12 @@ extern "C"
/* dll_major */ CYGWIN_VERSION_DLL_MAJOR, /* dll_major */ CYGWIN_VERSION_DLL_MAJOR,
/* dll_major */ CYGWIN_VERSION_DLL_MINOR, /* dll_major */ CYGWIN_VERSION_DLL_MINOR,
/* impure_ptr_ptr */ NULL, /* envptr */ NULL, /* impure_ptr_ptr */ NULL, /* envptr */ NULL,
/* malloc */ export_malloc, /* free */ export_free, /* malloc */ malloc, /* free */ free,
/* realloc */ export_realloc, /* realloc */ realloc,
/* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL, /* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL,
/* dtors */ NULL, /* data_start */ NULL, /* data_end */ NULL, /* dtors */ NULL, /* data_start */ NULL, /* data_end */ NULL,
/* bss_start */ NULL, /* bss_end */ NULL, /* bss_start */ NULL, /* bss_end */ NULL,
/* calloc */ export_calloc, /* calloc */ calloc,
/* premain */ {NULL, NULL, NULL, NULL}, /* premain */ {NULL, NULL, NULL, NULL},
/* run_ctors_p */ 0, /* run_ctors_p */ 0,
/* unused */ {0, 0, 0, 0, 0, 0, 0}, /* unused */ {0, 0, 0, 0, 0, 0, 0},

View File

@ -27,6 +27,8 @@ details. */
#include "perthread.h" #include "perthread.h"
#include "perprocess.h" #include "perprocess.h"
#include "dll_init.h" #include "dll_init.h"
#include "sync.h"
#include "cygmalloc.h"
#ifdef DEBUGGING #ifdef DEBUGGING
static int npid; static int npid;
@ -456,7 +458,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf); PSECURITY_ATTRIBUTES sec_attribs = sec_user_nih (sa_buf);
syscall_printf ("CreateProcess (%s, %s, 0, 0, 1, %x, 0, 0, %p, %p)", syscall_printf ("CreateProcess (%s, %s, 0, 0, 1, %x, 0, 0, %p, %p)",
myself->progname, myself->progname, c_flags, &si, &pi); myself->progname, myself->progname, c_flags, &si, &pi);
__malloc_lock (_reent_clib ()); __malloc_lock ();
void *newheap; void *newheap;
newheap = cygheap_setup_for_child (&ch,cygheap->fdtab.need_fixup_before ()); newheap = cygheap_setup_for_child (&ch,cygheap->fdtab.need_fixup_before ());
rc = CreateProcess (myself->progname, /* image to run */ rc = CreateProcess (myself->progname, /* image to run */
@ -555,7 +557,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
dll_data_start, dll_data_end, dll_data_start, dll_data_end,
dll_bss_start, dll_bss_end, NULL); dll_bss_start, dll_bss_end, NULL);
__malloc_unlock (_reent_clib ()); __malloc_unlock ();
MALLOC_CHECK; MALLOC_CHECK;
if (!rc) if (!rc)
goto cleanup; goto cleanup;

View File

@ -155,12 +155,14 @@ details. */
55: Export fcloseall, fcloseall_r. 55: Export fcloseall, fcloseall_r.
56: Make ntsec on by default. 56: Make ntsec on by default.
57: Export setgroups. 57: Export setgroups.
58: Export memalign, valloc, malloc_trim, malloc_usable_size, mallopt,
malloc_stats
*/ */
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0 #define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 57 #define CYGWIN_VERSION_API_MINOR 58
/* There is also a compatibity version number associated with the /* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible shared memory regions. It is incremented when incompatible

5574
winsup/cygwin/malloc.cc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -29,14 +29,14 @@ public:
#if 0 /* FIXME: See comment in sync.cc */ #if 0 /* FIXME: See comment in sync.cc */
~muto () ~muto ()
#endif #endif
int acquire (DWORD ms = INFINITE) __attribute__ ((regparm (1))); /* Acquire the lock. */ int acquire (DWORD ms = INFINITE) __attribute__ ((regparm (2))); /* Acquire the lock. */
int release (); /* Release the lock. */ int release () __attribute__ ((regparm (1))); /* Release the lock. */
/* Return true if caller thread owns the lock. */ /* Return true if caller thread owns the lock. */
int ismine () {return tid == GetCurrentThreadId ();} int ismine () {return tid == GetCurrentThreadId ();}
DWORD owner () {return tid;} DWORD owner () {return tid;}
int unstable () {return !tid && (sync || waiters >= 0);} int unstable () {return !tid && (sync || waiters >= 0);}
void reset (); void reset () __attribute__ ((regparm (1)));
}; };
extern muto muto_start; extern muto muto_start;

View File

@ -232,8 +232,8 @@ extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/; extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
extern void multiple_cygwin_problem (const char *, unsigned, unsigned); extern void multiple_cygwin_problem (const char *, unsigned, unsigned);
extern "C" void __malloc_lock (struct _reent *); extern "C" void __malloc_lock ();
extern "C" void __malloc_unlock (struct _reent *); extern "C" void __malloc_unlock ();
class path_conv; class path_conv;
int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow, int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow,