1999-12-18 Ulrich Drepper <drepper@cygnus.com>
+ * misc/sys/cdefs.h: Define __attribute_malloc__ according to
+ available gcc version.
+ * string/string.h: Mark strdup, __strdup, and strndup with
+ __attribute_malloc__.
+ * stdlib/stdlib.h: Make malloc, calloc, realloc, and valloc with
+ __attribute_malloc__.
+ * malloc/malloc.h: Make malloc, calloc, realloc, valloc, pvallc,
+ __morecore, and __default_morecore with __attribute_malloc__.
+ Provide default definition for __attribute_malloc__.
+ * libio/stdio.h: Make tempnam with __attribute_malloc__.
+
* include/unistd.h: Declare __libc_open64, __libc_lseek64,
__libc_pread, __libc_pread64, __libc_pwrite, and __libc_pwrite64.
* io/Versions: Export __libc_open64 and __libc_lseek64.
extern int __access (__const char *__name, int __type);
extern int __euidaccess (__const char *__name, int __type);
extern int __libc_open64 (const char *file, int oflag, ...);
+extern int __libc_open (const char *file, int oflag, ...);
extern __off64_t __lseek64 (int __fd, __off64_t __offset, int __whence);
extern __off64_t __libc_lseek64 (int __fd, __off64_t __offset, int __whence);
extern ssize_t __pread (int __fd, void *__buf, size_t __nbytes,
__off_t __offset);
extern ssize_t __libc_pwrite64 (int __fd, __const void *__buf, size_t __n,
__off64_t __offset);
+extern ssize_t __libc_read (int __fd, void *__buf, size_t __n);
+extern ssize_t __libc_write (int __fd, __const void *__buf, size_t __n);
extern int __pipe (int __pipedes[2]);
extern unsigned int __sleep (unsigned int __seconds);
extern int __chown (__const char *__file,
If not and if DIR is not NULL, that value is checked. If that fails,
P_tmpdir is tried and finally "/tmp". The storage for the filename
is allocated by `malloc'. */
-extern char *tempnam (__const char *__dir, __const char *__pfx) __THROW;
+extern char *tempnam (__const char *__dir, __const char *__pfx)
+ __THROW __attribute_malloc__;
#endif
/* Used by GNU libc internals. */
# define __malloc_size_t size_t
# define __malloc_ptrdiff_t ptrdiff_t
+#else
+# define __attribute_malloc__
#endif
#ifdef __GNUC__
#endif
/* Allocate SIZE bytes of memory. */
-extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size));
+extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
-extern __malloc_ptr_t calloc __MALLOC_P ((size_t __nmemb, size_t __size));
+extern __malloc_ptr_t calloc __MALLOC_P ((size_t __nmemb, size_t __size))
+ __attribute_malloc__;
/* Re-allocate the previously allocated block in __ptr, making the new
block SIZE bytes long. */
-extern __malloc_ptr_t realloc __MALLOC_P ((__malloc_ptr_t __ptr, size_t __size));
+extern __malloc_ptr_t realloc __MALLOC_P ((__malloc_ptr_t __ptr,
+ size_t __size))
+ __attribute_malloc__;
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free __MALLOC_P ((__malloc_ptr_t __ptr));
extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size));
/* Allocate SIZE bytes on a page boundary. */
-extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size));
+extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
__size to nearest pagesize. */
-extern __malloc_ptr_t pvalloc __MALLOC_P ((size_t __size));
+extern __malloc_ptr_t pvalloc __MALLOC_P ((size_t __size))
+ __attribute_malloc__;
/* Underlying allocation function; successive calls should return
contiguous pieces of memory. */
-extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
+extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size))
+ __attribute_malloc__;
/* Default value of `__morecore'. */
-extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size));
+extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size))
+ __attribute_malloc__;
/* SVID2/XPG mallinfo structure */
struct mallinfo {
they are omitted for compilers that don't understand it. */
#if !defined __GNUC__ || __GNUC__ < 2
-# define __attribute__(xyz) /* Ignore. */
+# define __attribute__(xyz) /* Ignore */
+
+/* At some point during the gcc 2.96 development the `malloc' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+# if __GNUC_PREREQ (2,96)
+# define __attribute_malloc__ __attribute__ ((__malloc__))
+# else
+# define __attribute_malloc__ /* Ignore */
+# endif
#endif
#ifndef __malloc_and_calloc_defined
#define __malloc_and_calloc_defined
/* Allocate SIZE bytes of memory. */
-extern void *malloc (size_t __size) __THROW;
+extern void *malloc (size_t __size) __THROW __attribute_malloc__;
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
-extern void *calloc (size_t __nmemb, size_t __size) __THROW;
+extern void *calloc (size_t __nmemb, size_t __size)
+ __THROW __attribute_malloc__;
#endif
#ifndef __need_malloc_and_calloc
/* Re-allocate the previously allocated block
in PTR, making the new block SIZE bytes long. */
-extern void *realloc (void *__ptr, size_t __size) __THROW;
+extern void *realloc (void *__ptr, size_t __size) __THROW __attribute_malloc__;
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free (void *__ptr) __THROW;
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
-extern void *valloc (size_t __size) __THROW;
+extern void *valloc (size_t __size) __THROW __attribute_malloc__;
#endif
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Duplicate S, returning an identical malloc'd string. */
-extern char *__strdup (__const char *__s) __THROW;
-extern char *strdup (__const char *__s) __THROW;
+extern char *__strdup (__const char *__s) __THROW __attribute_malloc__;
+extern char *strdup (__const char *__s) __THROW __attribute_malloc__;
#endif
/* Return a malloc'd copy of at most N bytes of STRING. The
resultant string is terminated even if no null terminator
appears before STRING[N]. */
#if defined __USE_GNU
-extern char *strndup (__const char *__string, size_t __n) __THROW;
+extern char *strndup (__const char *__string, size_t __n)
+ __THROW __attribute_malloc__;
#endif
#if defined __USE_GNU && defined __GNUC__