aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-12-19 08:08:59 +0000
committerUlrich Drepper <drepper@redhat.com>1999-12-19 08:08:59 +0000
commite9e9b245b98b8aeb8b8e898dce2b8c0f771602d6 (patch)
tree8cedb8e3ff9898a02990d88802319f68e99ac268
parent778c59c850879b2ffc7a396cecfa5a5ad68a40e6 (diff)
downloadglibc-e9e9b245b98b8aeb8b8e898dce2b8c0f771602d6.tar
glibc-e9e9b245b98b8aeb8b8e898dce2b8c0f771602d6.tar.gz
glibc-e9e9b245b98b8aeb8b8e898dce2b8c0f771602d6.tar.bz2
glibc-e9e9b245b98b8aeb8b8e898dce2b8c0f771602d6.zip
Update.
* 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__.
-rw-r--r--ChangeLog11
-rw-r--r--include/unistd.h3
-rw-r--r--libio/stdio.h3
-rw-r--r--malloc/malloc.h22
-rw-r--r--misc/sys/cdefs.h11
-rw-r--r--stdlib/stdlib.h9
-rw-r--r--string/string.h7
7 files changed, 50 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ebe9e7d07..32beebedea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
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.
diff --git a/include/unistd.h b/include/unistd.h
index 642f1d29ce..d8fc6cc651 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -5,6 +5,7 @@
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,
@@ -19,6 +20,8 @@ extern ssize_t __libc_pwrite (int __fd, __const void *__buf, size_t __n,
__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,
diff --git a/libio/stdio.h b/libio/stdio.h
index e78c33ba8b..00b7d879d6 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -156,7 +156,8 @@ extern char *tmpnam_r (char *__s) __THROW;
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
diff --git a/malloc/malloc.h b/malloc/malloc.h
index 4f02b5a093..78deff0738 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -55,6 +55,8 @@
/* Used by GNU libc internals. */
# define __malloc_size_t size_t
# define __malloc_ptrdiff_t ptrdiff_t
+#else
+# define __attribute_malloc__
#endif
#ifdef __GNUC__
@@ -114,14 +116,17 @@ extern void ptmalloc_init __MALLOC_P ((void));
#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));
@@ -133,18 +138,21 @@ extern void cfree __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 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 84e24b0b62..7db057560d 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -136,7 +136,16 @@
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
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index ac4baba14a..3448553e11 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -469,15 +469,16 @@ extern int lcong48_r (unsigned short int __param[7],
#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;
@@ -492,7 +493,7 @@ extern void cfree (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
diff --git a/string/string.h b/string/string.h
index 4a8ba402f8..58d0e7162e 100644
--- a/string/string.h
+++ b/string/string.h
@@ -112,15 +112,16 @@ extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
#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__