diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-01-08 11:44:19 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-01-08 12:02:03 -0800 |
commit | 921d2ea19b5eb70293bf110070f04064fd5c9193 (patch) | |
tree | 107c6c0c56355ac3878f09ec3e124c0d97ffb937 /lib/dynarray.h | |
parent | bdae9a5d4b2cedfaef23f8c55982ba5432dd69e3 (diff) | |
download | gnulib-921d2ea19b5eb70293bf110070f04064fd5c9193.tar.gz |
dynarray: new module
* config/srclist.txt: Mention the new files.
* lib/cdefs.h (__attribute_maybe_unused__): New macro,
like Gnulib’s _GL_ATTRIBUTE_MAYBE_UNUSED but with glibc
naming conventions.
* lib/libc-config.h: Use it instead of __glibc_likely.
* lib/dynarray.h, modules/dynarray: New files.
* lib/malloc/dynarray-skeleton.c, lib/malloc/dynarray.h:
* lib/malloc/dynarray_at_failure.c:
* lib/malloc/dynarray_emplace_enlarge.c:
* lib/malloc/dynarray_finalize.c, lib/malloc/dynarray_resize.c:
* lib/malloc/dynarray_resize_clear.c, modules/dynarray:
New files, from glibc with the following changes needed for
portability to compilers that are not recent-enough GCC.
* lib/malloc/dynarray_at_failure.c: Include stdlib.h, for abort.
(__libc_dynarray_at_failure) [!_LIBC]: Simply abort.
* lib/malloc/dynarray_emplace_enlarge.c:
* lib/malloc/dynarray_resize.c:
Include intprops.h, and use INT_MULTIPLY_WRAPV instead
of __builtin_mul_overflow.
* lib/malloc/dynarray.h (__libc_dynarray_at_failure):
Use _Noreturn instead of __attribute__ ((noreturn)).
* lib/malloc/dynarray_resize_clear.c: Do not include stdlib.h;
it’s not needed.
(__libc_dynarray_resize_clear): Do not do arithmetic on void *.
* lib/malloc/dynarray-skeleton.c (struct DYNARRAY_STRUCT):
Do not use anonymous unions, as they are not in C99. All uses changed.
Use __nonnull (X) instead of __attribute__ ((nonnull X)),
and __attribute_maybe_unused__ instead of __attribute__ ((unused)).
Diffstat (limited to 'lib/dynarray.h')
-rw-r--r-- | lib/dynarray.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/dynarray.h b/lib/dynarray.h new file mode 100644 index 0000000000..6da3e87e55 --- /dev/null +++ b/lib/dynarray.h @@ -0,0 +1,31 @@ +/* Type-safe arrays which grow dynamically. + Copyright 2021 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Paul Eggert, 2021. */ + +#ifndef _GL_DYNARRAY_H +#define _GL_DYNARRAY_H + +#include <libc-config.h> + +#define __libc_dynarray_at_failure gl_dynarray_at_failure +#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge +#define __libc_dynarray_finalize gl_dynarray_finalize +#define __libc_dynarray_resize_clear gl_dynarray_resize_clear +#define __libc_dynarray_resize gl_dynarray_resize +#include <malloc/dynarray.h> + +#endif /* _GL_DYNARRAY_H */ |