* libc/include/malloc.h: On cygwin, define malloc _r functions as wrapper

macros to standard malloc functions.
* libc/include/stdlib.h: Ditto.
* configure.host: Always define MALLOC_PROVIDED on cygwin.
This commit is contained in:
Christopher Faylor 2002-08-26 04:33:46 +00:00
parent 7200557403
commit 2e2b268ce6
4 changed files with 104 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2002-08-26 Christopher Faylor <cgf@redhat.com>
* libc/include/malloc.h: On cygwin, define malloc _r functions as
wrapper macros to standard malloc functions.
* libc/include/stdlib.h: Ditto.
* configure.host: Always define MALLOC_PROVIDED on cygwin.
2002-08-22 Thomas Fitzsimmons <fitzsim@redhat.com> 2002-08-22 Thomas Fitzsimmons <fitzsim@redhat.com>
* libc/include/langinfo.h: New file. * libc/include/langinfo.h: New file.

View File

@ -413,11 +413,7 @@ esac
case "${host}" in case "${host}" in
*-*-cygwin*) *-*-cygwin*)
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL" newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
# CYGWIN provides its own malloc if --enable-malloc-debugging is set
if [ "x${malloc_debugging}" = "xyes" ] ; then
newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
fi
syscall_dir=syscalls syscall_dir=syscalls
;; ;;
# RTEMS supplies its own versions of some routines: # RTEMS supplies its own versions of some routines:

View File

@ -35,48 +35,113 @@ struct mallinfo {
/* The routines. */ /* The routines. */
extern _PTR malloc _PARAMS ((size_t)); extern _PTR malloc _PARAMS ((size_t));
#ifdef __CYGWIN__
#undef _malloc_r
#define _malloc_r(r, s) malloc (s)
#else
extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t)); extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t));
#endif
extern _VOID free _PARAMS ((_PTR)); extern _VOID free _PARAMS ((_PTR));
#ifdef __CYGWIN__
#undef _free_r
#define _free_r(r, p) free (p)
#else
extern _VOID _free_r _PARAMS ((struct _reent *, _PTR)); extern _VOID _free_r _PARAMS ((struct _reent *, _PTR));
#endif
extern _PTR realloc _PARAMS ((_PTR, size_t)); extern _PTR realloc _PARAMS ((_PTR, size_t));
#ifdef __CYGWIN__
#undef _realloc_r
#define _realloc_r(r, p, s) realloc (p, s)
#else
extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t)); extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t));
#endif
extern _PTR calloc _PARAMS ((size_t, size_t)); extern _PTR calloc _PARAMS ((size_t, size_t));
#ifdef __CYGWIN__
#undef _calloc_r
#define _calloc_r(r, s1, s2) calloc (s1, s2);
#else
extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t)); extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t));
#endif
extern _PTR memalign _PARAMS ((size_t, size_t)); extern _PTR memalign _PARAMS ((size_t, size_t));
#ifdef __CYGWIN__
#undef _memalign_r
#define _memalign_r(r, s1, s2) memalign (s1, s2);
#else
extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t)); extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t));
#endif
extern struct mallinfo mallinfo _PARAMS ((void)); extern struct mallinfo mallinfo _PARAMS ((void));
#ifdef __CYGWIN__
#undef _mallinfo_r
#define _mallinfo_r(r) mallinfo ()
#else
extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *)); extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *));
#endif
extern void malloc_stats _PARAMS ((void)); extern void malloc_stats _PARAMS ((void));
#ifdef __CYGWIN__
#undef _malloc_stats_r
#define _malloc_stats_r(r) malloc_stats ()
#else
extern void _malloc_stats_r _PARAMS ((struct _reent *)); extern void _malloc_stats_r _PARAMS ((struct _reent *));
#endif
extern int mallopt _PARAMS ((int, int)); extern int mallopt _PARAMS ((int, int));
#ifdef __CYGWIN__
#undef _mallopt_r
#define _mallopt_r(i1, i2) mallopt (i1, i2)
#else
extern int _mallopt_r _PARAMS ((struct _reent *, int, int)); extern int _mallopt_r _PARAMS ((struct _reent *, int, int));
#endif
extern size_t malloc_usable_size _PARAMS ((_PTR)); extern size_t malloc_usable_size _PARAMS ((_PTR));
#ifdef __CYGWIN__
#undef _malloc_usable_size_r
#define _malloc_usable_size_r(r, p) malloc_usable_size (p)
#else
extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR)); extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR));
#endif
/* These aren't too useful on an embedded system, but we define them /* These aren't too useful on an embedded system, but we define them
anyhow. */ anyhow. */
extern _PTR valloc _PARAMS ((size_t)); extern _PTR valloc _PARAMS ((size_t));
#ifdef __CYGWIN__
#undef _valloc_r
#define _valloc_r(r, s) valloc (s)
#else
extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t)); extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t));
#endif
extern _PTR pvalloc _PARAMS ((size_t)); extern _PTR pvalloc _PARAMS ((size_t));
#ifdef __CYGWIN__
#undef _pvalloc_r
#define _pvalloc_r(r, s) pvalloc (s)
#else
extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t)); extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t));
#endif
extern int malloc_trim _PARAMS ((size_t)); extern int malloc_trim _PARAMS ((size_t));
#ifdef __CYGWIN__
#undef _malloc_trim_r
#define _malloc_trim_r(r, s) malloc_trim (s)
#else
extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t)); extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t));
#endif
/* A compatibility routine for an earlier version of the allocator. */ /* A compatibility routine for an earlier version of the allocator. */
extern _VOID mstats _PARAMS ((char *)); extern _VOID mstats _PARAMS ((char *));
#ifdef __CYGWIN__
#undef _mstats_r
#define _mstats_r(r, p) mstats (p)
#else
extern _VOID _mstats_r _PARAMS ((struct _reent *, char *)); extern _VOID _mstats_r _PARAMS ((struct _reent *, char *));
#endif
/* SVID2/XPG mallopt options */ /* SVID2/XPG mallopt options */

View File

@ -166,15 +166,46 @@ int _EXFUN(unlockpt,(int));
#endif /* ! __STRICT_ANSI__ */ #endif /* ! __STRICT_ANSI__ */
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**));
#ifndef __CYGWIN__
_PTR _EXFUN(_malloc_r,(struct _reent *, size_t)); _PTR _EXFUN(_malloc_r,(struct _reent *, size_t));
_PTR _EXFUN(_calloc_r,(struct _reent *, size_t, size_t)); _PTR _EXFUN(_calloc_r,(struct _reent *, size_t, size_t));
_VOID _EXFUN(_free_r,(struct _reent *, _PTR)); _VOID _EXFUN(_free_r,(struct _reent *, _PTR));
_PTR _EXFUN(_realloc_r,(struct _reent *, _PTR, size_t)); _PTR _EXFUN(_realloc_r,(struct _reent *, _PTR, size_t));
_VOID _EXFUN(_mstats_r,(struct _reent *, char *)); _VOID _EXFUN(_mstats_r,(struct _reent *, char *));
#endif
int _EXFUN(_system_r,(struct _reent *, const char *)); int _EXFUN(_system_r,(struct _reent *, const char *));
_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
#ifdef __CYGWIN__
#undef _malloc_r
#define _malloc_r(r, s) malloc (s)
#undef _free_r
#define _free_r(r, p) free (p)
#undef _realloc_r
#define _realloc_r(r, p, s) realloc (p, s)
#undef _calloc_r
#define _calloc_r(r, s1, s2) calloc (s1, s2);
#undef _memalign_r
#define _memalign_r(r, s1, s2) memalign (s1, s2);
#undef _mallinfo_r
#define _mallinfo_r(r) mallinfo ()
#undef _malloc_stats_r
#define _malloc_stats_r(r) malloc_stats ()
#undef _mallopt_r
#define _mallopt_r(i1, i2) mallopt (i1, i2)
#undef _malloc_usable_size_r
#define _malloc_usable_size_r(r, p) malloc_usable_size (p)
#undef _valloc_r
#define _valloc_r(r, s) valloc (s)
#undef _pvalloc_r
#define _pvalloc_r(r, s) pvalloc (s)
#undef _malloc_trim_r
#define _malloc_trim_r(r, s) malloc_trim (s)
#undef _mstats_r
#define _mstats_r(r, p) mstats (p)
#endif
_END_STD_C _END_STD_C
#endif /* _STDLIB_H_ */ #endif /* _STDLIB_H_ */