diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-05-07 13:37:19 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-05-07 13:37:19 +0300 |
commit | 6f5c5d212df15586e3aab33fbea64ac665b7c3f4 (patch) | |
tree | 85f8248c8a94f88de7d9c102668e09a3a22a9ec9 | |
parent | 0791273b7440635339a87d25e1b433747d59bc64 (diff) | |
download | egawk-6f5c5d212df15586e3aab33fbea64ac665b7c3f4.tar.gz egawk-6f5c5d212df15586e3aab33fbea64ac665b7c3f4.tar.bz2 egawk-6f5c5d212df15586e3aab33fbea64ac665b7c3f4.zip |
Really sync from GNULIB this time.
-rw-r--r-- | support/ChangeLog | 5 | ||||
-rw-r--r-- | support/cdefs.h | 30 | ||||
-rw-r--r-- | support/libc-config.h | 18 | ||||
-rw-r--r-- | support/malloc/dynarray-skeleton.c | 33 | ||||
-rw-r--r-- | support/regex_internal.h | 4 |
5 files changed, 49 insertions, 41 deletions
diff --git a/support/ChangeLog b/support/ChangeLog index e13bf9da..af1695d7 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,8 @@ +2021-05-07 Arnold D. Robbins <arnold@skeeve.com> + + * cdefs.h, libc-config.h, malloc/dynarray-skeleton.c, + regex_internal.h: Update from GNULIB. + 2021-05-05 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (EXTRA_DIST): Move some files to ... diff --git a/support/cdefs.h b/support/cdefs.h index 6f12c79d..b883b256 100644 --- a/support/cdefs.h +++ b/support/cdefs.h @@ -259,10 +259,12 @@ # define __attribute_const__ /* Ignore */ #endif -#if defined __STDC_VERSION__ && 201710L < __STDC_VERSION__ -# define __attribute_maybe_unused__ [[__maybe_unused__]] -#elif __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__) +#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__) # define __attribute_maybe_unused__ __attribute__ ((__unused__)) +/* Once the next version of the C standard comes out, we can + do something like the following here: + #elif defined __STDC_VERSION__ && 202???L <= __STDC_VERSION__ + # define __attribute_maybe_unused__ [[__maybe_unused__]] */ #else # define __attribute_maybe_unused__ /* Ignore */ #endif @@ -320,16 +322,18 @@ #endif /* The nonnull function attribute marks pointer parameters that - must not be NULL. */ -#ifndef __nonnull + must not be NULL. This has the name __nonnull in glibc, + and __attribute_nonnull__ in files shared with Gnulib to avoid + collision with a different __nonnull in DragonFlyBSD 5.9. */ +#ifndef __attribute_nonnull__ # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__) -# define __nonnull(params) __attribute__ ((__nonnull__ params)) +# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params)) # else -# define __nonnull(params) +# define __attribute_nonnull__(params) # endif -#elif !defined __GLIBC__ -# undef __nonnull -# define __nonnull(params) _GL_ATTRIBUTE_NONNULL (params) +#endif +#ifndef __nonnull +# define __nonnull(params) __attribute_nonnull__ (params) #endif /* If fortification mode, we warn about unused results of certain @@ -485,9 +489,9 @@ [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] #endif -/* The #ifndef lets Gnulib avoid including these on non-glibc - platforms, where the includes typically do not exist. */ -#ifndef __WORDSIZE +/* Gnulib avoids including these, as they don't work on non-glibc or + older glibc platforms. */ +#ifndef __GNULIB_CDEFS # include <bits/wordsize.h> # include <bits/long-double.h> #endif diff --git a/support/libc-config.h b/support/libc-config.h index fcdafcb9..fabca2fa 100644 --- a/support/libc-config.h +++ b/support/libc-config.h @@ -33,9 +33,9 @@ #include <config.h> /* On glibc this includes <features.h> and <sys/cdefs.h> and #defines - _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 it - includes <sys/cdefs.h> which defines __nonnull. Elsewhere it - is harmless. */ + _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and + DragonFlyBSD 5.9 it includes <sys/cdefs.h> which defines __nonnull. + Elsewhere it is harmless. */ #include <errno.h> /* From glibc <errno.h>. */ @@ -71,7 +71,7 @@ # endif #endif -#ifndef __attribute_maybe_unused__ +#ifndef __attribute_nonnull__ /* <sys/cdefs.h> either does not exist, or is too old for Gnulib. Prepare to include <cdefs.h>, which is Gnulib's version of a more-recent glibc <sys/cdefs.h>. */ @@ -80,13 +80,9 @@ # ifndef _FEATURES_H # define _FEATURES_H 1 # endif -/* Define __WORDSIZE so that <cdefs.h> does not attempt to include - nonexistent files. Make it a syntax error, since Gnulib does not - use __WORDSIZE now, and if Gnulib uses it later the syntax error - will let us know that __WORDSIZE needs configuring. */ -# ifndef __WORDSIZE -# define __WORDSIZE %%% -# endif +/* Define __GNULIB_CDEFS so that <cdefs.h> does not attempt to include + nonexistent files. */ +# define __GNULIB_CDEFS /* Undef the macros unconditionally defined by our copy of glibc <sys/cdefs.h>, so that they do not clash with any system-defined versions. */ diff --git a/support/malloc/dynarray-skeleton.c b/support/malloc/dynarray-skeleton.c index 5b9f37bd..48210e32 100644 --- a/support/malloc/dynarray-skeleton.c +++ b/support/malloc/dynarray-skeleton.c @@ -192,7 +192,7 @@ DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list) /* Initialize a dynamic array object. This must be called before any use of the object. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static void DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list) { @@ -202,7 +202,7 @@ DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list) } /* Deallocate the dynamic array and its elements. */ -__attribute_maybe_unused__ __nonnull ((1)) +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) static void DYNARRAY_FREE (struct DYNARRAY_STRUCT *list) { @@ -213,7 +213,7 @@ DYNARRAY_FREE (struct DYNARRAY_STRUCT *list) } /* Return true if the dynamic array is in an error state. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static inline bool DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list) { @@ -222,7 +222,7 @@ DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list) /* Mark the dynamic array as failed. All elements are deallocated as a side effect. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static void DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list) { @@ -236,7 +236,7 @@ DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list) /* Return the number of elements which have been added to the dynamic array. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static inline size_t DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list) { @@ -245,7 +245,7 @@ DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list) /* Return a pointer to the array element at INDEX. Terminate the process if INDEX is out of bounds. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static inline DYNARRAY_ELEMENT * DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index) { @@ -257,7 +257,7 @@ DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index) /* Return a pointer to the first array element, if any. For a zero-length array, the pointer can be NULL even though the dynamic array has not entered the failure state. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static inline DYNARRAY_ELEMENT * DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list) { @@ -267,7 +267,7 @@ DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list) /* Return a pointer one element past the last array element. For a zero-length array, the pointer can be NULL even though the dynamic array has not entered the failure state. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static inline DYNARRAY_ELEMENT * DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list) { @@ -294,7 +294,7 @@ DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item) /* Add ITEM at the end of the array, enlarging it by one element. Mark *LIST as failed if the dynamic array allocation size cannot be increased. */ -__nonnull ((1)) +__attribute_nonnull__ ((1)) static inline void DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item) { @@ -348,7 +348,8 @@ DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list) /* Allocate a place for a new element in *LIST and return a pointer to it. The pointer can be NULL if the dynamic array cannot be enlarged due to a memory allocation failure. */ -__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1)) +__attribute_maybe_unused__ __attribute_warn_unused_result__ +__attribute_nonnull__ ((1)) static /* Avoid inlining with the larger initialization code. */ #if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE)) @@ -372,7 +373,7 @@ DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list) existing size, new elements are added (which can be initialized). Otherwise, the list is truncated, and elements are freed. Return false on memory allocation failure (and mark *LIST as failed). */ -__attribute_maybe_unused__ __nonnull ((1)) +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) static bool DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size) { @@ -417,7 +418,7 @@ DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size) } /* Remove the last element of LIST if it is present. */ -__attribute_maybe_unused__ __nonnull ((1)) +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) static void DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list) { @@ -434,7 +435,7 @@ DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list) /* Remove all elements from the list. The elements are freed, but the list itself is not. */ -__attribute_maybe_unused__ __nonnull ((1)) +__attribute_maybe_unused__ __attribute_nonnull__ ((1)) static void DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list) { @@ -452,7 +453,8 @@ DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list) stored in *RESULT if LIST refers to an empty list. On success, the pointer in *RESULT is heap-allocated and must be deallocated using free. */ -__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1, 2)) +__attribute_maybe_unused__ __attribute_warn_unused_result__ +__attribute_nonnull__ ((1, 2)) static bool DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, DYNARRAY_FINAL_TYPE *result) @@ -483,7 +485,8 @@ DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, have a sentinel at the end). If LENGTHP is not NULL, the array length is written to *LENGTHP. *LIST is re-initialized and can be reused. */ -__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1)) +__attribute_maybe_unused__ __attribute_warn_unused_result__ +__attribute_nonnull__ ((1)) static DYNARRAY_ELEMENT * DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp) { diff --git a/support/regex_internal.h b/support/regex_internal.h index 4b0a3efb..1245e782 100644 --- a/support/regex_internal.h +++ b/support/regex_internal.h @@ -53,14 +53,14 @@ # define lock_fini(lock) ((void) 0) # define lock_lock(lock) __libc_lock_lock (lock) # define lock_unlock(lock) __libc_lock_unlock (lock) -#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO +#elif defined GNULIB_LOCK && !defined GNULIB_REGEX_SINGLE_THREAD # include "glthread/lock.h" # define lock_define(name) gl_lock_define (, name) # define lock_init(lock) glthread_lock_init (&(lock)) # define lock_fini(lock) glthread_lock_destroy (&(lock)) # define lock_lock(lock) glthread_lock_lock (&(lock)) # define lock_unlock(lock) glthread_lock_unlock (&(lock)) -#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO +#elif defined GNULIB_PTHREAD && !defined GNULIB_REGEX_SINGLE_THREAD # include <pthread.h> # define lock_define(name) pthread_mutex_t name; # define lock_init(lock) pthread_mutex_init (&(lock), 0) |