From fb4dfa0c81812d64197d65f8c0c7e57467e09280 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 23 Aug 2000 07:23:46 +0000 Subject: Add some pure attributes. --- dirent/dirent.h | 18 ++++++++++++------ include/dirent.h | 6 ++++-- include/wchar.h | 12 ++++++++---- stdlib/stdlib.h | 15 ++++++++------- wcsmbs/wchar.h | 38 ++++++++++++++++++++++---------------- 5 files changed, 54 insertions(+), 35 deletions(-) diff --git a/dirent/dirent.h b/dirent/dirent.h index 0888e46dc7..dcbeab6946 100644 --- a/dirent/dirent.h +++ b/dirent/dirent.h @@ -252,11 +252,13 @@ extern int scandir64 (__const char *__restrict __dir, /* Function to compare two `struct dirent's alphabetically. */ # ifndef __USE_FILE_OFFSET64 -extern int alphasort (__const void *__e1, __const void *__e2) __THROW; +extern int alphasort (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__; # else # ifdef __REDIRECT extern int __REDIRECT (alphasort, - (__const void *__e1, __const void *__e2) __THROW, + (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__, alphasort64); # else # define alphasort alphasort64 @@ -264,17 +266,20 @@ extern int __REDIRECT (alphasort, # endif # if defined __USE_GNU && defined __USE_LARGEFILE64 -extern int alphasort64 (__const void *__e1, __const void *__e2) __THROW; +extern int alphasort64 (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__; # endif # ifdef __USE_GNU /* Function to compare two `struct dirent's by name & version. */ # ifndef __USE_FILE_OFFSET64 -extern int versionsort (__const void *__e1, __const void *__e2) __THROW; +extern int versionsort (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__; # else # ifdef __REDIRECT extern int __REDIRECT (versionsort, - (__const void *__e1, __const void *__e2) __THROW, + (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__, versionsort64); # else # define versionsort versionsort64 @@ -282,7 +287,8 @@ extern int __REDIRECT (versionsort, # endif # ifdef __USE_LARGEFILE64 -extern int versionsort64 (__const void *__e1, __const void *__e2) __THROW; +extern int versionsort64 (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__; # endif # endif diff --git a/include/dirent.h b/include/dirent.h index 4bffb06a39..d0ca3f2ffb 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -18,6 +18,8 @@ extern __ssize_t __getdents (int __fd, char *__buf, size_t __nbytes) internal_function; extern __ssize_t __getdents64 (int __fd, char *__buf, size_t __nbytes) internal_function; -extern int __alphasort64 (const void *a, const void *b); -extern int __versionsort64 (const void *a, const void *b); +extern int __alphasort64 (const void *a, const void *b) + __attribute_pure__; +extern int __versionsort64 (const void *a, const void *b) + __attribute_pure__; #endif diff --git a/include/wchar.h b/include/wchar.h index 7187d76c05..ee12563e99 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -3,10 +3,13 @@ # ifdef _WCHAR_H /* Now define the internal interfaces. */ -extern int __wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2); +extern int __wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) + __attribute_pure__; extern int __wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2, - size_t __n); -extern size_t __wcsnlen (__const wchar_t *__s, size_t __maxlen); + size_t __n) + __attribute_pure__; +extern size_t __wcsnlen (__const wchar_t *__s, size_t __maxlen) + __attribute_pure__; extern wint_t __btowc (int __c); extern int __mbsinit (__const __mbstate_t *__ps); extern size_t __mbrtowc (wchar_t *__restrict __pwc, @@ -37,7 +40,8 @@ extern wchar_t *__wmempcpy (wchar_t *__restrict __s1, size_t __n); extern wchar_t *__wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n); -extern wchar_t *__wcschrnul (__const wchar_t *__s, wchar_t __wc); +extern wchar_t *__wcschrnul (__const wchar_t *__s, wchar_t __wc) + __attribute_pure__; extern int __vfwscanf (FILE *__restrict __s, __const wchar_t *__restrict __format, diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index bdf618f152..4b8b4674c2 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -134,15 +134,16 @@ extern size_t __ctype_get_mb_cur_max (void) __THROW; /* Convert a string to a floating-point number. */ -extern double atof (__const char *__nptr) __THROW; +extern double atof (__const char *__nptr) __THROW __attribute_pure__; /* Convert a string to an integer. */ -extern int atoi (__const char *__nptr) __THROW; +extern int atoi (__const char *__nptr) __THROW __attribute_pure__; /* Convert a string to a long integer. */ -extern long int atol (__const char *__nptr) __THROW; +extern long int atol (__const char *__nptr) __THROW __attribute_pure__; #if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_MISC) -/* These functions will part of the standard C library in ISO C99. */ -__extension__ extern long long int atoll (__const char *__nptr) __THROW; +/* Convert a string to a long long integer. */ +__extension__ extern long long int atoll (__const char *__nptr) + __THROW __attribute_pure__; #endif /* Convert a string to a floating-point number. */ @@ -384,7 +385,7 @@ atoll (__const char *__nptr) __THROW extern char *l64a (long int __n) __THROW; /* Read a number from a string S in base 64 as above. */ -extern long int a64l (__const char *__s) __THROW; +extern long int a64l (__const char *__s) __THROW __attribute_pure__; # include /* we need int32_t... */ @@ -552,7 +553,7 @@ extern void *valloc (size_t __size) __THROW __attribute_malloc__; #ifdef __USE_XOPEN2K /* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */ extern int posix_memalign (void **memptr, size_t alignment, size_t size) - __THROW; + __THROW __attribute_malloc__; #endif /* Abort execution and generate a core-dump. */ diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index 6ffe38b02f..d33b0ea76b 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -119,10 +119,11 @@ extern wchar_t *wcsncat (wchar_t *__restrict __dest, __THROW; /* Compare S1 and S2. */ -extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW; +extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2) + __THROW __attribute_pure__; /* Compare N wide-characters of S1 and S2. */ extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n) - __THROW; + __THROW __attribute_pure__; #ifdef __USE_GNU /* Compare S1 and S2, ignoring case. */ @@ -167,39 +168,42 @@ extern size_t __wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, size_t __n, __locale_t __loc) __THROW; /* Duplicate S, returning an identical malloc'd string. */ -extern wchar_t *wcsdup (__const wchar_t *__s) __THROW; +extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__; #endif /* Find the first occurrence of WC in WCS. */ -extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc) __THROW; +extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; /* Find the last occurrence of WC in WCS. */ -extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc) __THROW; +extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; #ifdef __USE_GNU /* This funciton is similar to `wcschr'. But it returns a pointer to the closing NUL wide character in case C is not found in S. */ -extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc) __THROW; +extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc) + __THROW __attribute_pure__; #endif /* Return the length of the initial segmet of WCS which consists entirely of wide characters not in REJECT. */ extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject) - __THROW; + __THROW __attribute_pure__; /* Return the length of the initial segmet of WCS which consists entirely of wide characters in ACCEPT. */ extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept) - __THROW; + __THROW __attribute_pure__; /* Find the first occurrence in WCS of any character in ACCEPT. */ extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept) - __THROW; + __THROW __attribute_pure__; /* Find the first occurrence of NEEDLE in HAYSTACK. */ extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle) - __THROW; + __THROW __attribute_pure__; #ifdef __USE_XOPEN /* Another name for `wcsstr' from XPG4. */ extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle) - __THROW; + __THROW __attribute_pure__; #endif /* Divide WCS into tokens separated by characters in DELIM. */ @@ -208,22 +212,24 @@ extern wchar_t *wcstok (wchar_t *__restrict __s, wchar_t **__restrict __ptr) __THROW; /* Return the number of wide characters in S. */ -extern size_t __wcslen (__const wchar_t *__s) __THROW; -extern size_t wcslen (__const wchar_t *__s) __THROW; +extern size_t __wcslen (__const wchar_t *__s) __THROW __attribute_pure__; +extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__; #ifdef __USE_GNU /* Return the number of wide characters in S, but at most MAXLEN. */ -extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen) __THROW; +extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen) + __THROW __attribute_pure__; #endif /* Search N wide characters of S for C. */ extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n) - __THROW; + __THROW __attribute_pure__; /* Compare N wide characters of S1 and S2. */ extern int wmemcmp (__const wchar_t *__restrict __s1, - __const wchar_t *__restrict __s2, size_t __n) __THROW; + __const wchar_t *__restrict __s2, size_t __n) + __THROW __attribute_pure__; /* Copy N wide characters of SRC to DEST. */ extern wchar_t *wmemcpy (wchar_t *__restrict __s1, -- cgit v1.2.3