1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
2000-05-11  Jan Hubicka  <jh@suse.cz>

	* misc/sys/cdefs.h: Add support for pure attribute.

	* include/string.h: Add __attribute_pure__ to various functions.
	* string/string.h: Likewise.
This commit is contained in:
Andreas Jaeger
2000-05-12 07:01:25 +00:00
parent b227a3a6ad
commit ca5a4c3c9f
4 changed files with 72 additions and 35 deletions

View File

@ -1,3 +1,10 @@
2000-05-11 Jan Hubicka <jh@suse.cz>
* misc/sys/cdefs.h: Add support for pure attribute.
* include/string.h: Add __attribute_pure__ to various functions.
* string/string.h: Likewise.
2000-05-10 Jakub Jelinek <jakub@redhat.com> 2000-05-10 Jakub Jelinek <jakub@redhat.com>
* elf/dl-reloc.c (_dl_reloc_bad_type): Sync messages with plt * elf/dl-reloc.c (_dl_reloc_bad_type): Sync messages with plt

View File

@ -5,23 +5,29 @@
extern void *__memccpy (void *__dest, __const void *__src, extern void *__memccpy (void *__dest, __const void *__src,
int __c, size_t __n); int __c, size_t __n);
extern size_t __strnlen (__const char *__string, size_t __maxlen); extern size_t __strnlen (__const char *__string, size_t __maxlen)
__attribute_pure__;
extern char *__strsep (char **__stringp, __const char *__delim); extern char *__strsep (char **__stringp, __const char *__delim);
extern int __strverscmp (__const char *__s1, __const char *__s2); extern int __strverscmp (__const char *__s1, __const char *__s2)
__attribute_pure__;
extern int __strncasecmp (__const char *__s1, __const char *__s2, extern int __strncasecmp (__const char *__s1, __const char *__s2,
size_t __n); size_t __n)
__attribute_pure__;
extern char *__strndup (__const char *__string, size_t __n) extern char *__strndup (__const char *__string, size_t __n)
__attribute_malloc__; __attribute_malloc__;
extern void *__rawmemchr (__const void *__s, int __c); extern void *__rawmemchr (__const void *__s, int __c)
__attribute_pure__;
extern char *__strchrnul (__const char *__s, int __c); extern char *__strchrnul (__const char *__s, int __c)
__attribute_pure__;
extern void *__memrchr (__const void *__s, int __c, size_t __n); extern void *__memrchr (__const void *__s, int __c, size_t __n)
__attribute_pure__;
/* Now the real definitions. We do this here since some of the functions /* Now the real definitions. We do this here since some of the functions
above are defined as macros in the headers. */ above are defined as macros in the headers. */

View File

@ -123,6 +123,15 @@
# define __attribute_malloc__ /* Ignore */ # define __attribute_malloc__ /* Ignore */
#endif #endif
/* At some point during the gcc 2.96 development the `pure' 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_pure__ __attribute__ ((__pure__))
#else
# define __attribute_pure__ /* Ignore */
#endif
/* It is possible to compile containing GCC extensions even if GCC is /* It is possible to compile containing GCC extensions even if GCC is
run in pedantic mode if the uses are carefully marked using the run in pedantic mode if the uses are carefully marked using the
`__extension__' keyword. But this is not generally available before `__extension__' keyword. But this is not generally available before

View File

@ -55,18 +55,20 @@ extern void *memset (void *__s, int __c, size_t __n) __THROW;
/* Compare N bytes of S1 and S2. */ /* Compare N bytes of S1 and S2. */
extern int memcmp (__const void *__s1, __const void *__s2, size_t __n) extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
__THROW; __THROW __attribute_pure__;
/* Search N bytes of S for C. */ /* Search N bytes of S for C. */
extern void *memchr (__const void *__s, int __c, size_t __n) __THROW; extern void *memchr (__const void *__s, int __c, size_t __n)
__THROW __attribute_pure__;
#ifdef __USE_GNU #ifdef __USE_GNU
/* Search in S for C. This is similar to `memchr' but there is no /* Search in S for C. This is similar to `memchr' but there is no
length limit. */ length limit. */
extern void *rawmemchr (__const void *__s, int __c) __THROW; extern void *rawmemchr (__const void *__s, int __c) __THROW __attribute_pure__;
/* Search N bytes of S for the final occurrence of C. */ /* Search N bytes of S for the final occurrence of C. */
extern void *memrchr (__const void *__s, int __c, size_t __n) __THROW; extern void *memrchr (__const void *__s, int __c, size_t __n)
__THROW __attribute_pure__;
#endif #endif
@ -85,13 +87,15 @@ extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
size_t __n) __THROW; size_t __n) __THROW;
/* Compare S1 and S2. */ /* Compare S1 and S2. */
extern int strcmp (__const char *__s1, __const char *__s2) __THROW; extern int strcmp (__const char *__s1, __const char *__s2)
__THROW __attribute_pure__;
/* Compare N characters of S1 and S2. */ /* Compare N characters of S1 and S2. */
extern int strncmp (__const char *__s1, __const char *__s2, size_t __n) extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
__THROW; __THROW __attribute_pure__;
/* Compare the collated forms of S1 and S2. */ /* Compare the collated forms of S1 and S2. */
extern int strcoll (__const char *__s1, __const char *__s2) __THROW; extern int strcoll (__const char *__s1, __const char *__s2)
__THROW __attribute_pure__;
/* Put a transformation of SRC into no more than N bytes of DEST. */ /* Put a transformation of SRC into no more than N bytes of DEST. */
extern size_t strxfrm (char *__restrict __dest, extern size_t strxfrm (char *__restrict __dest,
__const char *__restrict __src, size_t __n) __THROW; __const char *__restrict __src, size_t __n) __THROW;
@ -104,7 +108,7 @@ extern size_t strxfrm (char *__restrict __dest,
/* Compare the collated forms of S1 and S2 using rules from L. */ /* Compare the collated forms of S1 and S2 using rules from L. */
extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l) extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
__THROW; __THROW __attribute_pure__;
/* Put a transformation of SRC into no more than N bytes of DEST. */ /* Put a transformation of SRC into no more than N bytes of DEST. */
extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n, extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
__locale_t __l) __THROW; __locale_t __l) __THROW;
@ -148,33 +152,37 @@ extern char *strndup (__const char *__string, size_t __n)
#endif #endif
/* Find the first occurrence of C in S. */ /* Find the first occurrence of C in S. */
extern char *strchr (__const char *__s, int __c) __THROW; extern char *strchr (__const char *__s, int __c) __THROW __attribute_pure__;
/* Find the last occurrence of C in S. */ /* Find the last occurrence of C in S. */
extern char *strrchr (__const char *__s, int __c) __THROW; extern char *strrchr (__const char *__s, int __c) __THROW __attribute_pure__;
#ifdef __USE_GNU #ifdef __USE_GNU
/* This funciton is similar to `strchr'. But it returns a pointer to /* This funciton is similar to `strchr'. But it returns a pointer to
the closing NUL byte in case C is not found in S. */ the closing NUL byte in case C is not found in S. */
extern char *strchrnul (__const char *__s, int __c) __THROW; extern char *strchrnul (__const char *__s, int __c) __THROW __attribute_pure__;
#endif #endif
/* Return the length of the initial segment of S which /* Return the length of the initial segment of S which
consists entirely of characters not in REJECT. */ consists entirely of characters not in REJECT. */
extern size_t strcspn (__const char *__s, __const char *__reject) __THROW; extern size_t strcspn (__const char *__s, __const char *__reject)
__THROW __attribute_pure__;
/* Return the length of the initial segment of S which /* Return the length of the initial segment of S which
consists entirely of characters in ACCEPT. */ consists entirely of characters in ACCEPT. */
extern size_t strspn (__const char *__s, __const char *__accept) __THROW; extern size_t strspn (__const char *__s, __const char *__accept)
__THROW __attribute_pure__;
/* Find the first occurrence in S of any character in ACCEPT. */ /* Find the first occurrence in S of any character in ACCEPT. */
extern char *strpbrk (__const char *__s, __const char *__accept) __THROW; extern char *strpbrk (__const char *__s, __const char *__accept)
__THROW __attribute_pure__;
/* Find the first occurrence of NEEDLE in HAYSTACK. */ /* Find the first occurrence of NEEDLE in HAYSTACK. */
extern char *strstr (__const char *__haystack, __const char *__needle) __THROW; extern char *strstr (__const char *__haystack, __const char *__needle)
__THROW __attribute_pure__;
#ifdef __USE_GNU #ifdef __USE_GNU
/* Similar to `strstr' but this function ignores the case of both strings. */ /* Similar to `strstr' but this function ignores the case of both strings. */
extern char *__strcasestr (__const char *__haystack, __const char *__needle) extern char *__strcasestr (__const char *__haystack, __const char *__needle)
__THROW; __THROW __attribute_pure__;
extern char *strcasestr (__const char *__haystack, __const char *__needle) extern char *strcasestr (__const char *__haystack, __const char *__needle)
__THROW; __THROW __attribute_pure__;
#endif #endif
/* Divide S into tokens separated by characters in DELIM. */ /* Divide S into tokens separated by characters in DELIM. */
@ -196,7 +204,8 @@ extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
NEEDLE is NEEDLELEN bytes long; NEEDLE is NEEDLELEN bytes long;
HAYSTACK is HAYSTACKLEN bytes long. */ HAYSTACK is HAYSTACKLEN bytes long. */
extern void *memmem (__const void *__haystack, size_t __haystacklen, extern void *memmem (__const void *__haystack, size_t __haystacklen,
__const void *__needle, size_t __needlelen) __THROW; __const void *__needle, size_t __needlelen)
__THROW __attribute_pure__;
/* Copy N bytes of SRC to DEST, return pointer to bytes after the /* Copy N bytes of SRC to DEST, return pointer to bytes after the
last written byte. */ last written byte. */
@ -208,12 +217,13 @@ extern void *mempcpy (void *__restrict __dest,
/* Return the length of S. */ /* Return the length of S. */
extern size_t strlen (__const char *__s) __THROW; extern size_t strlen (__const char *__s) __THROW __attribute_pure__;
#ifdef __USE_GNU #ifdef __USE_GNU
/* Find the length of STRING, but scan at most MAXLEN characters. /* Find the length of STRING, but scan at most MAXLEN characters.
If no '\0' terminator is found in that many characters, return MAXLEN. */ If no '\0' terminator is found in that many characters, return MAXLEN. */
extern size_t strnlen (__const char *__string, size_t __maxlen) __THROW; extern size_t strnlen (__const char *__string, size_t __maxlen)
__THROW __attribute_pure__;
#endif #endif
@ -238,13 +248,14 @@ extern void bcopy (__const void *__src, void *__dest, size_t __n) __THROW;
extern void bzero (void *__s, size_t __n) __THROW; extern void bzero (void *__s, size_t __n) __THROW;
/* Compare N bytes of S1 and S2 (same as memcmp). */ /* Compare N bytes of S1 and S2 (same as memcmp). */
extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) __THROW; extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
__THROW __attribute_pure__;
/* Find the first occurrence of C in S (same as strchr). */ /* Find the first occurrence of C in S (same as strchr). */
extern char *index (__const char *__s, int __c) __THROW; extern char *index (__const char *__s, int __c) __THROW __attribute_pure__;
/* Find the last occurrence of C in S (same as strrchr). */ /* Find the last occurrence of C in S (same as strrchr). */
extern char *rindex (__const char *__s, int __c) __THROW; extern char *rindex (__const char *__s, int __c) __THROW __attribute_pure__;
/* Return the position of the first bit set in I, or 0 if none are set. /* Return the position of the first bit set in I, or 0 if none are set.
The least-significant bit is position 1, the most-significant 32. */ The least-significant bit is position 1, the most-significant 32. */
@ -262,22 +273,25 @@ __extension__ extern int ffsll (long long int __ll)
# endif # endif
/* Compare S1 and S2, ignoring case. */ /* Compare S1 and S2, ignoring case. */
extern int __strcasecmp (__const char *__s1, __const char *__s2) __THROW; extern int __strcasecmp (__const char *__s1, __const char *__s2)
extern int strcasecmp (__const char *__s1, __const char *__s2) __THROW; __THROW __attribute_pure__;
extern int strcasecmp (__const char *__s1, __const char *__s2)
__THROW __attribute_pure__;
/* Compare no more than N chars of S1 and S2, ignoring case. */ /* Compare no more than N chars of S1 and S2, ignoring case. */
extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
__THROW; __THROW __attribute_pure__;
#endif /* Use BSD. */ #endif /* Use BSD. */
#ifdef __USE_GNU #ifdef __USE_GNU
/* Again versions of a few functions which use the given locale instead /* Again versions of a few functions which use the given locale instead
of the global one. */ of the global one. */
extern int __strcasecmp_l (__const char *__s1, __const char *__s2, extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
__locale_t __loc) __THROW; __locale_t __loc) __THROW __attribute_pure__;
extern int __strncasecmp_l (__const char *__s1, __const char *__s2, extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
size_t __n, __locale_t __loc) __THROW; size_t __n, __locale_t __loc)
__THROW __attribute_pure__;
#endif #endif
#ifdef __USE_BSD #ifdef __USE_BSD
@ -289,7 +303,8 @@ extern char *strsep (char **__restrict __stringp,
#ifdef __USE_GNU #ifdef __USE_GNU
/* Compare S1 and S2 as strings holding name & indices/version numbers. */ /* Compare S1 and S2 as strings holding name & indices/version numbers. */
extern int strverscmp (__const char *__s1, __const char *__s2) __THROW; extern int strverscmp (__const char *__s1, __const char *__s2)
__THROW __attribute_pure__;
/* Return a string describing the meaning of the signal number in SIG. */ /* Return a string describing the meaning of the signal number in SIG. */
extern char *strsignal (int __sig) __THROW; extern char *strsignal (int __sig) __THROW;