summaryrefslogtreecommitdiffstats
path: root/gl
diff options
context:
space:
mode:
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am1421
-rw-r--r--gl/_Noreturn.h41
-rw-r--r--gl/af_alg.c188
-rw-r--r--gl/af_alg.h2
-rw-r--r--gl/alloca.in.h2
-rw-r--r--gl/arg-nonnull.h2
-rw-r--r--gl/arpa_inet.c20
-rw-r--r--gl/arpa_inet.in.h65
-rw-r--r--gl/asnprintf.c6
-rw-r--r--gl/asprintf.c6
-rw-r--r--gl/assert.in.h2
-rw-r--r--gl/attribute.h165
-rw-r--r--gl/base64.c112
-rw-r--r--gl/base64.h54
-rw-r--r--gl/basename-lgpl.c11
-rw-r--r--gl/basename-lgpl.h7
-rw-r--r--gl/basename.c2
-rw-r--r--gl/btowc.c10
-rw-r--r--gl/byteswap.c20
-rw-r--r--gl/byteswap.in.h106
-rw-r--r--gl/c++defs.h70
-rw-r--r--gl/c-ctype.c20
-rw-r--r--gl/c-ctype.h366
-rw-r--r--gl/c32is-impl.h105
-rw-r--r--gl/c32isalnum.c26
-rw-r--r--gl/c32isalpha.c26
-rw-r--r--gl/c32isblank.c26
-rw-r--r--gl/c32iscntrl.c26
-rw-r--r--gl/c32isdigit.c26
-rw-r--r--gl/c32isgraph.c26
-rw-r--r--gl/c32islower.c26
-rw-r--r--gl/c32isprint.c26
-rw-r--r--gl/c32ispunct.c26
-rw-r--r--gl/c32isspace.c26
-rw-r--r--gl/c32isupper.c26
-rw-r--r--gl/c32isxdigit.c26
-rw-r--r--gl/c32to-impl.h103
-rw-r--r--gl/c32tolower.c26
-rw-r--r--gl/c32width.c102
-rw-r--r--gl/calloc.c19
-rw-r--r--gl/cdefs.h60
-rw-r--r--gl/cloexec.c2
-rw-r--r--gl/cloexec.h12
-rw-r--r--gl/close.c2
-rw-r--r--gl/dirname-lgpl.c7
-rw-r--r--gl/dirname.c2
-rw-r--r--gl/dirname.h8
-rw-r--r--gl/dup2.c68
-rw-r--r--gl/dynarray.h2
-rw-r--r--gl/errno.in.h29
-rw-r--r--gl/error.c182
-rw-r--r--gl/error.h66
-rw-r--r--gl/error.in.h261
-rw-r--r--gl/exitfail.c2
-rw-r--r--gl/exitfail.h12
-rw-r--r--gl/fcntl.c186
-rw-r--r--gl/fcntl.in.h103
-rw-r--r--gl/fd-hook.c2
-rw-r--r--gl/fd-hook.h2
-rw-r--r--gl/fflush.c17
-rw-r--r--gl/filename.h2
-rw-r--r--gl/float+.h2
-rw-r--r--gl/float.c98
-rw-r--r--gl/float.in.h236
-rw-r--r--gl/floor.c2
-rw-r--r--gl/floorf.c2
-rw-r--r--gl/fopen.c51
-rw-r--r--gl/fpurge.c10
-rw-r--r--gl/freading.c12
-rw-r--r--gl/freading.h7
-rw-r--r--gl/free.c8
-rw-r--r--gl/fseek.c2
-rw-r--r--gl/fseeko.c28
-rw-r--r--gl/fseterr.c80
-rw-r--r--gl/fseterr.h55
-rw-r--r--gl/fstat.c11
-rw-r--r--gl/fsusage.c21
-rw-r--r--gl/fsusage.h16
-rw-r--r--gl/ftell.c2
-rw-r--r--gl/ftello.c15
-rw-r--r--gl/gai_strerror.c9
-rw-r--r--gl/getaddrinfo.c105
-rw-r--r--gl/getdelim.c115
-rw-r--r--gl/getdtablesize.c13
-rw-r--r--gl/gethostname.c6
-rw-r--r--gl/getline.c2
-rw-r--r--gl/getloadavg.c268
-rw-r--r--gl/getopt-cdefs.in.h18
-rw-r--r--gl/getopt-core.h2
-rw-r--r--gl/getopt-ext.h2
-rw-r--r--gl/getopt-pfx-core.h14
-rw-r--r--gl/getopt-pfx-ext.h4
-rw-r--r--gl/getopt.c102
-rw-r--r--gl/getopt.in.h7
-rw-r--r--gl/getopt1.c9
-rw-r--r--gl/getopt_int.h2
-rw-r--r--gl/getprogname.c88
-rw-r--r--gl/getprogname.h20
-rw-r--r--gl/gettext.h120
-rw-r--r--gl/gl_openssl.h12
-rw-r--r--gl/glthread/lock.c112
-rw-r--r--gl/glthread/lock.h163
-rw-r--r--gl/glthread/once.c80
-rw-r--r--gl/glthread/once.h272
-rw-r--r--gl/glthread/threadlib.c2
-rw-r--r--gl/hard-locale.c16
-rw-r--r--gl/hard-locale.h18
-rw-r--r--gl/ialloc.c5
-rw-r--r--gl/ialloc.h33
-rw-r--r--gl/idpriv-droptemp.c22
-rw-r--r--gl/idpriv.h2
-rw-r--r--gl/idx.h12
-rw-r--r--gl/inet_ntop.c46
-rw-r--r--gl/inet_pton.c265
-rw-r--r--gl/intprops-internal.h46
-rw-r--r--gl/intprops.h14
-rw-r--r--gl/inttypes.in.h53
-rw-r--r--gl/iswblank.c26
-rw-r--r--gl/iswctype-impl.h22
-rw-r--r--gl/iswctype.c36
-rw-r--r--gl/iswdigit.c26
-rw-r--r--gl/iswpunct.c33
-rw-r--r--gl/iswxdigit.c33
-rw-r--r--gl/itold.c2
-rw-r--r--gl/langinfo.in.h68
-rw-r--r--gl/lc-charset-dispatch.c2
-rw-r--r--gl/lc-charset-dispatch.h2
-rw-r--r--gl/libc-config.h29
-rw-r--r--gl/limits.in.h44
-rw-r--r--gl/localcharset.c69
-rw-r--r--gl/localcharset.h48
-rw-r--r--gl/locale.in.h190
-rw-r--r--gl/localeconv.c47
-rw-r--r--gl/lseek.c2
-rw-r--r--gl/lstat.c97
-rw-r--r--gl/m4/00gnulib.m414
-rw-r--r--gl/m4/__inline.m48
-rw-r--r--gl/m4/absolute-header.m48
-rw-r--r--gl/m4/af_alg.m46
-rw-r--r--gl/m4/alloca.m46
-rw-r--r--gl/m4/arpa_inet_h.m410
-rw-r--r--gl/m4/assert_h.m488
-rw-r--r--gl/m4/base64.m46
-rw-r--r--gl/m4/btowc.m4103
-rw-r--r--gl/m4/build-to-host.m4274
-rw-r--r--gl/m4/builtin-expect.m412
-rw-r--r--gl/m4/byteswap.m435
-rw-r--r--gl/m4/c-bool.m424
-rw-r--r--gl/m4/c32rtomb.m4187
-rw-r--r--gl/m4/calloc.m481
-rw-r--r--gl/m4/close.m48
-rw-r--r--gl/m4/codeset.m46
-rw-r--r--gl/m4/double-slash-root.m46
-rw-r--r--gl/m4/dup2.m48
-rw-r--r--gl/m4/eealloc.m431
-rw-r--r--gl/m4/environ.m46
-rw-r--r--gl/m4/errno_h.m469
-rw-r--r--gl/m4/error.m424
-rw-r--r--gl/m4/error_h.m4129
-rw-r--r--gl/m4/exponentd.m410
-rw-r--r--gl/m4/extensions-aix.m426
-rw-r--r--gl/m4/extensions.m425
-rw-r--r--gl/m4/extern-inline.m425
-rw-r--r--gl/m4/fclose.m4100
-rw-r--r--gl/m4/fcntl-o.m498
-rw-r--r--gl/m4/fcntl.m48
-rw-r--r--gl/m4/fcntl_h.m413
-rw-r--r--gl/m4/fflush.m424
-rw-r--r--gl/m4/float_h.m442
-rw-r--r--gl/m4/floorf.m430
-rw-r--r--gl/m4/fopen.m425
-rw-r--r--gl/m4/fpurge.m497
-rw-r--r--gl/m4/freading.m411
-rw-r--r--gl/m4/free.m416
-rw-r--r--gl/m4/fseek.m46
-rw-r--r--gl/m4/fseeko.m410
-rw-r--r--gl/m4/fseterr.m415
-rw-r--r--gl/m4/fstat.m410
-rw-r--r--gl/m4/fstypename.m415
-rw-r--r--gl/m4/fsusage.m459
-rw-r--r--gl/m4/ftell.m46
-rw-r--r--gl/m4/ftello.m435
-rw-r--r--gl/m4/getaddrinfo.m465
-rw-r--r--gl/m4/getdelim.m458
-rw-r--r--gl/m4/getdtablesize.m46
-rw-r--r--gl/m4/gethostname.m410
-rw-r--r--gl/m4/getline.m467
-rw-r--r--gl/m4/getloadavg.m441
-rw-r--r--gl/m4/getopt.m430
-rw-r--r--gl/m4/getprogname.m440
-rw-r--r--gl/m4/gettext_h.m421
-rw-r--r--gl/m4/gl-openssl.m422
-rw-r--r--gl/m4/gnulib-cache.m42
-rw-r--r--gl/m4/gnulib-common.m4894
-rw-r--r--gl/m4/gnulib-comp.m4630
-rw-r--r--gl/m4/gnulib-i18n.m461
-rw-r--r--gl/m4/gnulib-tool.m49
-rw-r--r--gl/m4/hostent.m410
-rw-r--r--gl/m4/idpriv.m46
-rw-r--r--gl/m4/include_next.m414
-rw-r--r--gl/m4/inet_ntop.m413
-rw-r--r--gl/m4/inet_pton.m473
-rw-r--r--gl/m4/intmax_t.m46
-rw-r--r--gl/m4/inttypes.m410
-rw-r--r--gl/m4/inttypes_h.m46
-rw-r--r--gl/m4/iswblank.m440
-rw-r--r--gl/m4/iswctype.m415
-rw-r--r--gl/m4/iswdigit.m4122
-rw-r--r--gl/m4/iswpunct.m450
-rw-r--r--gl/m4/iswxdigit.m4112
-rw-r--r--gl/m4/langinfo_h.m450
-rw-r--r--gl/m4/largefile.m4235
-rw-r--r--gl/m4/libunistring-base.m4204
-rw-r--r--gl/m4/limits-h.m432
-rw-r--r--gl/m4/localcharset.m46
-rw-r--r--gl/m4/locale-en.m4138
-rw-r--r--gl/m4/locale-fr.m4161
-rw-r--r--gl/m4/locale-ja.m427
-rw-r--r--gl/m4/locale-zh.m435
-rw-r--r--gl/m4/locale_h.m463
-rw-r--r--gl/m4/localeconv.m443
-rw-r--r--gl/m4/lock.m410
-rw-r--r--gl/m4/lseek.m446
-rw-r--r--gl/m4/lstat.m482
-rw-r--r--gl/m4/malloc.m4193
-rw-r--r--gl/m4/malloca.m48
-rw-r--r--gl/m4/math_h.m4103
-rw-r--r--gl/m4/mbchar.m415
-rw-r--r--gl/m4/mbiter.m416
-rw-r--r--gl/m4/mbrtoc32.m4326
-rw-r--r--gl/m4/mbrtowc.m4215
-rw-r--r--gl/m4/mbsinit.m48
-rw-r--r--gl/m4/mbstate_t.m46
-rw-r--r--gl/m4/mbtowc.m411
-rw-r--r--gl/m4/memchr.m449
-rw-r--r--gl/m4/minmax.m46
-rw-r--r--gl/m4/mktime.m437
-rw-r--r--gl/m4/mmap-anon.m423
-rw-r--r--gl/m4/mode_t.m46
-rw-r--r--gl/m4/mountlist.m443
-rw-r--r--gl/m4/msvc-inval.m46
-rw-r--r--gl/m4/msvc-nothrow.m46
-rw-r--r--gl/m4/multiarch.m46
-rw-r--r--gl/m4/musl.m422
-rw-r--r--gl/m4/netdb_h.m46
-rw-r--r--gl/m4/netinet_in_h.m46
-rw-r--r--gl/m4/nl_langinfo.m448
-rw-r--r--gl/m4/nocrash.m46
-rw-r--r--gl/m4/off64_t.m432
-rw-r--r--gl/m4/off_t.m46
-rw-r--r--gl/m4/once.m414
-rw-r--r--gl/m4/open-cloexec.m49
-rw-r--r--gl/m4/open-slash.m46
-rw-r--r--gl/m4/open.m411
-rw-r--r--gl/m4/pathmax.m46
-rw-r--r--gl/m4/pid_t.m46
-rw-r--r--gl/m4/printf.m41098
-rw-r--r--gl/m4/pthread-once.m483
-rw-r--r--gl/m4/pthread-spin.m472
-rw-r--r--gl/m4/pthread_h.m4293
-rw-r--r--gl/m4/pthread_rwlock_rdlock.m446
-rw-r--r--gl/m4/realloc.m4153
-rw-r--r--gl/m4/reallocarray.m422
-rw-r--r--gl/m4/regex.m445
-rw-r--r--gl/m4/sched_h.m4102
-rw-r--r--gl/m4/servent.m410
-rw-r--r--gl/m4/setenv.m425
-rw-r--r--gl/m4/setlocale_null.m453
-rw-r--r--gl/m4/sha256.m46
-rw-r--r--gl/m4/size_max.m46
-rw-r--r--gl/m4/snprintf.m46
-rw-r--r--gl/m4/socketlib.m420
-rw-r--r--gl/m4/sockets.m46
-rw-r--r--gl/m4/socklen.m48
-rw-r--r--gl/m4/sockpfaf.m416
-rw-r--r--gl/m4/ssize_t.m432
-rw-r--r--gl/m4/stat-time.m416
-rw-r--r--gl/m4/stat.m424
-rw-r--r--gl/m4/std-gnu11.m430
-rw-r--r--gl/m4/stdalign.m4208
-rw-r--r--gl/m4/stdckdint_h.m4136
-rw-r--r--gl/m4/stddef_h.m469
-rw-r--r--gl/m4/stdint.m427
-rw-r--r--gl/m4/stdint_h.m46
-rw-r--r--gl/m4/stdio_h.m452
-rw-r--r--gl/m4/stdlib_h.m488
-rw-r--r--gl/m4/strcasecmp.m467
-rw-r--r--gl/m4/strcasestr.m412
-rw-r--r--gl/m4/strerror.m434
-rw-r--r--gl/m4/string_h.m436
-rw-r--r--gl/m4/stringeq.m425
-rw-r--r--gl/m4/strings_h.m427
-rw-r--r--gl/m4/strncasecmp.m4 (renamed from gl/m4/strcase.m4)33
-rw-r--r--gl/m4/strncpy.m494
-rw-r--r--gl/m4/strsep.m46
-rw-r--r--gl/m4/strstr.m412
-rw-r--r--gl/m4/sys_cdefs_h.m426
-rw-r--r--gl/m4/sys_socket_h.m460
-rw-r--r--gl/m4/sys_stat_h.m46
-rw-r--r--gl/m4/sys_types_h.m417
-rw-r--r--gl/m4/sys_uio_h.m46
-rw-r--r--gl/m4/threadlib.m4436
-rw-r--r--gl/m4/time_h.m456
-rw-r--r--gl/m4/time_r.m413
-rw-r--r--gl/m4/timegm.m412
-rw-r--r--gl/m4/uchar_h.m4279
-rw-r--r--gl/m4/ungetc.m426
-rw-r--r--gl/m4/unicase_h.m445
-rw-r--r--gl/m4/unictype_h.m4179
-rw-r--r--gl/m4/uninorm_h.m447
-rw-r--r--gl/m4/unistd_h.m414
-rw-r--r--gl/m4/unitypes_h.m426
-rw-r--r--gl/m4/unlocked-io.m415
-rw-r--r--gl/m4/vararrays.m415
-rw-r--r--gl/m4/vasnprintf.m4275
-rw-r--r--gl/m4/vasprintf.m46
-rw-r--r--gl/m4/visibility.m414
-rw-r--r--gl/m4/vsnprintf.m46
-rw-r--r--gl/m4/warn-on-use.m410
-rw-r--r--gl/m4/wchar_h.m433
-rw-r--r--gl/m4/wchar_t.m424
-rw-r--r--gl/m4/wcrtomb.m432
-rw-r--r--gl/m4/wctype.m453
-rw-r--r--gl/m4/wctype_h.m410
-rw-r--r--gl/m4/wcwidth.m4116
-rw-r--r--gl/m4/wint_t.m46
-rw-r--r--gl/m4/xalloc.m46
-rw-r--r--gl/m4/xsize.m46
-rw-r--r--gl/m4/zzgnulib.m46
-rw-r--r--gl/malloc.c13
-rw-r--r--gl/malloc/dynarray-skeleton.c2
-rw-r--r--gl/malloc/dynarray.h2
-rw-r--r--gl/malloc/dynarray_at_failure.c2
-rw-r--r--gl/malloc/dynarray_emplace_enlarge.c6
-rw-r--r--gl/malloc/dynarray_finalize.c2
-rw-r--r--gl/malloc/dynarray_resize.c6
-rw-r--r--gl/malloc/dynarray_resize_clear.c2
-rw-r--r--gl/malloca.c43
-rw-r--r--gl/malloca.h35
-rw-r--r--gl/math.c6
-rw-r--r--gl/math.in.h1050
-rw-r--r--gl/mbchar.c22
-rw-r--r--gl/mbchar.h388
-rw-r--r--gl/mbiterf.c20
-rw-r--r--gl/mbiterf.h214
-rw-r--r--gl/mbrtoc32.c288
-rw-r--r--gl/mbrtowc-impl-utf8.h2
-rw-r--r--gl/mbrtowc-impl.h29
-rw-r--r--gl/mbrtowc.c17
-rw-r--r--gl/mbsinit.c4
-rw-r--r--gl/mbsnlen.c60
-rw-r--r--gl/mbszero.c23
-rw-r--r--gl/mbtowc-impl.h9
-rw-r--r--gl/mbtowc-lock.c19
-rw-r--r--gl/mbtowc-lock.h21
-rw-r--r--gl/mbtowc.c2
-rw-r--r--gl/memchr.c174
-rw-r--r--gl/memchr.valgrind2
-rw-r--r--gl/minmax.h11
-rw-r--r--gl/mktime-internal.h16
-rw-r--r--gl/mktime.c182
-rw-r--r--gl/mountlist.c648
-rw-r--r--gl/mountlist.h26
-rw-r--r--gl/msvc-inval.c2
-rw-r--r--gl/msvc-inval.h11
-rw-r--r--gl/msvc-nothrow.c2
-rw-r--r--gl/msvc-nothrow.h15
-rw-r--r--gl/netdb.in.h46
-rw-r--r--gl/netinet_in.in.h2
-rw-r--r--gl/nl_langinfo-lock.c19
-rw-r--r--gl/nl_langinfo.c157
-rw-r--r--gl/open.c127
-rw-r--r--gl/pathmax.h7
-rw-r--r--gl/printf-args.c144
-rw-r--r--gl/printf-args.h72
-rw-r--r--gl/printf-parse.c516
-rw-r--r--gl/printf-parse.h10
-rw-r--r--gl/pthread-once.c148
-rw-r--r--gl/pthread.in.h1981
-rw-r--r--gl/realloc.c75
-rw-r--r--gl/reallocarray.c4
-rw-r--r--gl/regcomp.c69
-rw-r--r--gl/regex.c7
-rw-r--r--gl/regex.h51
-rw-r--r--gl/regex_internal.c9
-rw-r--r--gl/regex_internal.h32
-rw-r--r--gl/regexec.c20
-rw-r--r--gl/sched.in.h110
-rw-r--r--gl/setenv.c123
-rw-r--r--gl/setlocale-lock.c19
-rw-r--r--gl/setlocale_null-unlocked.c145
-rw-r--r--gl/setlocale_null.c183
-rw-r--r--gl/setlocale_null.h30
-rw-r--r--gl/sha256-stream.c17
-rw-r--r--gl/sha256.c19
-rw-r--r--gl/sha256.h23
-rw-r--r--gl/size_max.h7
-rw-r--r--gl/snprintf.c41
-rw-r--r--gl/sockets.c21
-rw-r--r--gl/sockets.h18
-rw-r--r--gl/stat-time.c5
-rw-r--r--gl/stat-time.h84
-rw-r--r--gl/stat-w32.c7
-rw-r--r--gl/stat-w32.h2
-rw-r--r--gl/stat.c18
-rw-r--r--gl/stdalign.in.h137
-rw-r--r--gl/stdckdint.in.h41
-rw-r--r--gl/stddef.in.h131
-rw-r--r--gl/stdint.in.h32
-rw-r--r--gl/stdio-consolesafe.c202
-rw-r--r--gl/stdio-impl.h116
-rw-r--r--gl/stdio-read.c13
-rw-r--r--gl/stdio-write.c19
-rw-r--r--gl/stdio.in.h793
-rw-r--r--gl/stdlib.c21
-rw-r--r--gl/stdlib.in.h817
-rw-r--r--gl/str-two-way.h283
-rw-r--r--gl/strcasecmp.c41
-rw-r--r--gl/strcasestr.c45
-rw-r--r--gl/streq.h16
-rw-r--r--gl/strerror-override.c7
-rw-r--r--gl/strerror-override.h74
-rw-r--r--gl/strerror.c11
-rw-r--r--gl/string.c19
-rw-r--r--gl/string.in.h715
-rw-r--r--gl/strings.in.h154
-rw-r--r--gl/stripslash.c8
-rw-r--r--gl/strncasecmp.c41
-rw-r--r--gl/strncpy.c38
-rw-r--r--gl/strsep.c5
-rw-r--r--gl/strstr.c32
-rw-r--r--gl/sys-limits.h6
-rw-r--r--gl/sys_socket.c6
-rw-r--r--gl/sys_socket.in.h158
-rw-r--r--gl/sys_stat.in.h163
-rw-r--r--gl/sys_types.in.h34
-rw-r--r--gl/sys_uio.in.h2
-rw-r--r--gl/time.in.h251
-rw-r--r--gl/time_r.c7
-rw-r--r--gl/timegm.c5
-rw-r--r--gl/uchar.in.h909
-rw-r--r--gl/unicase.in.h471
-rw-r--r--gl/unicase/.dirstamp0
-rw-r--r--gl/unicase/simple-mapping.h39
-rw-r--r--gl/unicase/tolower.c27
-rw-r--r--gl/unicase/tolower.h759
-rw-r--r--gl/unictype.in.h1147
-rw-r--r--gl/unictype/.dirstamp0
-rw-r--r--gl/unictype/bitmap.h48
-rw-r--r--gl/unictype/ctype_alnum.c32
-rw-r--r--gl/unictype/ctype_alnum.h889
-rw-r--r--gl/unictype/ctype_alpha.c32
-rw-r--r--gl/unictype/ctype_alpha.h889
-rw-r--r--gl/unictype/ctype_blank.c32
-rw-r--r--gl/unictype/ctype_blank.h184
-rw-r--r--gl/unictype/ctype_cntrl.c32
-rw-r--r--gl/unictype/ctype_cntrl.h176
-rw-r--r--gl/unictype/ctype_digit.c32
-rw-r--r--gl/unictype/ctype_digit.h172
-rw-r--r--gl/unictype/ctype_graph.c32
-rw-r--r--gl/unictype/ctype_graph.h1194
-rw-r--r--gl/unictype/ctype_lower.c32
-rw-r--r--gl/unictype/ctype_lower.h371
-rw-r--r--gl/unictype/ctype_print.c32
-rw-r--r--gl/unictype/ctype_print.h1194
-rw-r--r--gl/unictype/ctype_punct.c32
-rw-r--r--gl/unictype/ctype_punct.h874
-rw-r--r--gl/unictype/ctype_space.c32
-rw-r--r--gl/unictype/ctype_space.h184
-rw-r--r--gl/unictype/ctype_upper.c32
-rw-r--r--gl/unictype/ctype_upper.h367
-rw-r--r--gl/unictype/ctype_xdigit.c32
-rw-r--r--gl/unictype/ctype_xdigit.h172
-rw-r--r--gl/uninorm.in.h255
-rw-r--r--gl/unistd.c6
-rw-r--r--gl/unistd.in.h642
-rw-r--r--gl/unitypes.in.h71
-rw-r--r--gl/uniwidth.in.h72
-rw-r--r--gl/uniwidth/.dirstamp0
-rw-r--r--gl/uniwidth/cjk.h37
-rw-r--r--gl/uniwidth/width.c95
-rw-r--r--gl/uniwidth/width0.h504
-rw-r--r--gl/uniwidth/width2.h541
-rw-r--r--gl/unlocked-io.h16
-rw-r--r--gl/unsetenv.c39
-rw-r--r--gl/vasnprintf.c3483
-rw-r--r--gl/vasnprintf.h7
-rw-r--r--gl/vasprintf.c14
-rw-r--r--gl/verify.h99
-rw-r--r--gl/vsnprintf.c41
-rw-r--r--gl/vsnzprintf.c62
-rw-r--r--gl/w32sock.h2
-rw-r--r--gl/warn-on-use.h14
-rw-r--r--gl/wchar.in.h703
-rw-r--r--gl/wcrtomb.c8
-rw-r--r--gl/wctype-h.c6
-rw-r--r--gl/wctype-impl.h96
-rw-r--r--gl/wctype.c25
-rw-r--r--gl/wctype.in.h133
-rw-r--r--gl/wcwidth.c73
-rw-r--r--gl/windows-initguard.h2
-rw-r--r--gl/windows-mutex.c26
-rw-r--r--gl/windows-mutex.h3
-rw-r--r--gl/windows-once.c51
-rw-r--r--gl/windows-once.h7
-rw-r--r--gl/windows-recmutex.c2
-rw-r--r--gl/windows-recmutex.h2
-rw-r--r--gl/windows-rwlock.c24
-rw-r--r--gl/windows-rwlock.h2
-rw-r--r--gl/xalloc-die.c6
-rw-r--r--gl/xalloc-oversized.h14
-rw-r--r--gl/xalloc.h14
-rw-r--r--gl/xmalloc.c36
-rw-r--r--gl/xsize.c5
-rw-r--r--gl/xsize.h38
515 files changed, 40958 insertions, 8526 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index dcebd4aa..6f50b0c5 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1,6 +1,6 @@
1## DO NOT EDIT! GENERATED AUTOMATICALLY! 1## DO NOT EDIT! GENERATED AUTOMATICALLY!
2## Process this file with automake to produce Makefile.in. 2## Process this file with automake to produce Makefile.in.
3# Copyright (C) 2002-2023 Free Software Foundation, Inc. 3# Copyright (C) 2002-2026 Free Software Foundation, Inc.
4# 4#
5# This file is free software; you can redistribute it and/or modify 5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
@@ -59,9 +59,11 @@
59AUTOMAKE_OPTIONS = 1.14 gnits subdir-objects 59AUTOMAKE_OPTIONS = 1.14 gnits subdir-objects
60 60
61SUBDIRS = 61SUBDIRS =
62TESTS_ENVIRONMENT =
62noinst_HEADERS = 63noinst_HEADERS =
63noinst_LIBRARIES = 64noinst_LIBRARIES =
64noinst_LTLIBRARIES = 65noinst_LTLIBRARIES =
66pkgdata_DATA =
65EXTRA_DIST = 67EXTRA_DIST =
66BUILT_SOURCES = 68BUILT_SOURCES =
67SUFFIXES = 69SUFFIXES =
@@ -79,9 +81,9 @@ AM_CFLAGS =
79noinst_LIBRARIES += libgnu.a 81noinst_LIBRARIES += libgnu.a
80 82
81libgnu_a_SOURCES = 83libgnu_a_SOURCES =
82libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS) 84libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS) $(GL_CFLAG_ALLOW_WARNINGS)
83libgnu_a_LIBADD = $(gl_LIBOBJS) 85libgnu_a_LIBADD = $(gl_libgnu_LIBOBJS)
84libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 86libgnu_a_DEPENDENCIES = $(gl_libgnu_LIBOBJS)
85EXTRA_libgnu_a_SOURCES = 87EXTRA_libgnu_a_SOURCES =
86 88
87## begin gnulib module absolute-header 89## begin gnulib module absolute-header
@@ -115,9 +117,10 @@ EXTRA_DIST += alloca.in.h
115 117
116## end gnulib module alloca-opt 118## end gnulib module alloca-opt
117 119
118## begin gnulib module arpa_inet 120## begin gnulib module arpa_inet-h
119 121
120BUILT_SOURCES += arpa/inet.h 122BUILT_SOURCES += arpa/inet.h
123libgnu_a_SOURCES += arpa_inet.c
121 124
122# We need the following in order to create <arpa/inet.h> when the system 125# We need the following in order to create <arpa/inet.h> when the system
123# doesn't have one. 126# doesn't have one.
@@ -134,8 +137,12 @@ arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON
134 -e 's/@''GNULIB_INET_NTOP''@/$(GL_GNULIB_INET_NTOP)/g' \ 137 -e 's/@''GNULIB_INET_NTOP''@/$(GL_GNULIB_INET_NTOP)/g' \
135 -e 's/@''GNULIB_INET_PTON''@/$(GL_GNULIB_INET_PTON)/g' \ 138 -e 's/@''GNULIB_INET_PTON''@/$(GL_GNULIB_INET_PTON)/g' \
136 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ 139 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
140 -e 's|@''HAVE_DECL_HTONL''@|$(HAVE_DECL_HTONL)|g' \
141 -e 's|@''HAVE_DECL_HTONS''@|$(HAVE_DECL_HTONS)|g' \
137 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ 142 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
138 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ 143 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
144 -e 's|@''HAVE_DECL_NTOHL''@|$(HAVE_DECL_NTOHL)|g' \
145 -e 's|@''HAVE_DECL_NTOHS''@|$(HAVE_DECL_NTOHS)|g' \
139 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \ 146 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \
140 -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|g' \ 147 -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|g' \
141 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 148 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -148,7 +155,7 @@ MOSTLYCLEANDIRS += arpa
148 155
149EXTRA_DIST += arpa_inet.in.h 156EXTRA_DIST += arpa_inet.in.h
150 157
151## end gnulib module arpa_inet 158## end gnulib module arpa_inet-h
152 159
153## begin gnulib module assert-h 160## begin gnulib module assert-h
154 161
@@ -220,6 +227,7 @@ if GL_GENERATE_BYTESWAP_H
220byteswap.h: byteswap.in.h $(top_builddir)/config.status 227byteswap.h: byteswap.in.h $(top_builddir)/config.status
221 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h 228 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h
222 $(AM_V_at)mv $@-t $@ 229 $(AM_V_at)mv $@-t $@
230libgnu_a_SOURCES += byteswap.c
223else 231else
224byteswap.h: $(top_builddir)/config.status 232byteswap.h: $(top_builddir)/config.status
225 rm -f $@ 233 rm -f $@
@@ -230,6 +238,122 @@ EXTRA_DIST += byteswap.in.h
230 238
231## end gnulib module byteswap 239## end gnulib module byteswap
232 240
241## begin gnulib module c-ctype
242
243libgnu_a_SOURCES += c-ctype.h c-ctype.c
244
245## end gnulib module c-ctype
246
247## begin gnulib module c32isalnum
248
249libgnu_a_SOURCES += c32isalnum.c
250
251EXTRA_DIST += c32is-impl.h
252
253## end gnulib module c32isalnum
254
255## begin gnulib module c32isalpha
256
257libgnu_a_SOURCES += c32isalpha.c
258
259EXTRA_DIST += c32is-impl.h
260
261## end gnulib module c32isalpha
262
263## begin gnulib module c32isblank
264
265libgnu_a_SOURCES += c32isblank.c
266
267EXTRA_DIST += c32is-impl.h
268
269## end gnulib module c32isblank
270
271## begin gnulib module c32iscntrl
272
273libgnu_a_SOURCES += c32iscntrl.c
274
275EXTRA_DIST += c32is-impl.h
276
277## end gnulib module c32iscntrl
278
279## begin gnulib module c32isdigit
280
281libgnu_a_SOURCES += c32isdigit.c
282
283EXTRA_DIST += c32is-impl.h
284
285## end gnulib module c32isdigit
286
287## begin gnulib module c32isgraph
288
289libgnu_a_SOURCES += c32isgraph.c
290
291EXTRA_DIST += c32is-impl.h
292
293## end gnulib module c32isgraph
294
295## begin gnulib module c32islower
296
297libgnu_a_SOURCES += c32islower.c
298
299EXTRA_DIST += c32is-impl.h
300
301## end gnulib module c32islower
302
303## begin gnulib module c32isprint
304
305libgnu_a_SOURCES += c32isprint.c
306
307EXTRA_DIST += c32is-impl.h
308
309## end gnulib module c32isprint
310
311## begin gnulib module c32ispunct
312
313libgnu_a_SOURCES += c32ispunct.c
314
315EXTRA_DIST += c32is-impl.h
316
317## end gnulib module c32ispunct
318
319## begin gnulib module c32isspace
320
321libgnu_a_SOURCES += c32isspace.c
322
323EXTRA_DIST += c32is-impl.h
324
325## end gnulib module c32isspace
326
327## begin gnulib module c32isupper
328
329libgnu_a_SOURCES += c32isupper.c
330
331EXTRA_DIST += c32is-impl.h
332
333## end gnulib module c32isupper
334
335## begin gnulib module c32isxdigit
336
337libgnu_a_SOURCES += c32isxdigit.c
338
339EXTRA_DIST += c32is-impl.h
340
341## end gnulib module c32isxdigit
342
343## begin gnulib module c32tolower
344
345libgnu_a_SOURCES += c32tolower.c
346
347EXTRA_DIST += c32to-impl.h
348
349## end gnulib module c32tolower
350
351## begin gnulib module c32width
352
353libgnu_a_SOURCES += c32width.c
354
355## end gnulib module c32width
356
233## begin gnulib module calloc-gnu 357## begin gnulib module calloc-gnu
234 358
235 359
@@ -312,7 +436,7 @@ endif
312 436
313## end gnulib module dup2 437## end gnulib module dup2
314 438
315## begin gnulib module errno 439## begin gnulib module errno-h
316 440
317BUILT_SOURCES += $(ERRNO_H) 441BUILT_SOURCES += $(ERRNO_H)
318 442
@@ -326,12 +450,6 @@ errno.h: errno.in.h $(top_builddir)/config.status
326 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 450 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
327 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 451 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
328 -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ 452 -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
329 -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
330 -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
331 -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
332 -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
333 -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
334 -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
335 $(srcdir)/errno.in.h > $@-t 453 $(srcdir)/errno.in.h > $@-t
336 $(AM_V_at)mv $@-t $@ 454 $(AM_V_at)mv $@-t $@
337else 455else
@@ -342,7 +460,7 @@ MOSTLYCLEANFILES += errno.h errno.h-t
342 460
343EXTRA_DIST += errno.in.h 461EXTRA_DIST += errno.in.h
344 462
345## end gnulib module errno 463## end gnulib module errno-h
346 464
347## begin gnulib module error 465## begin gnulib module error
348 466
@@ -350,10 +468,32 @@ if GL_COND_OBJ_ERROR
350libgnu_a_SOURCES += error.c 468libgnu_a_SOURCES += error.c
351endif 469endif
352 470
353EXTRA_DIST += error.h
354
355## end gnulib module error 471## end gnulib module error
356 472
473## begin gnulib module error-h
474
475BUILT_SOURCES += error.h
476
477# We need the following in order to override <error.h>.
478error.h: error.in.h $(top_builddir)/config.status $(CXXDEFS_H)
479 $(gl_V_at)$(SED_HEADER_STDOUT) \
480 -e 's|@''GUARD_PREFIX''@|GL|g' \
481 -e 's|@''HAVE_ERROR_H''@|$(HAVE_ERROR_H)|g' \
482 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
483 -e 's|@''NEXT_ERROR_H''@|$(NEXT_ERROR_H)|g' \
484 -e 's|@''HAVE_ERROR''@|$(HAVE_ERROR)|g' \
485 -e 's|@''HAVE_ERROR_AT_LINE''@|$(HAVE_ERROR_AT_LINE)|g' \
486 -e 's|@''REPLACE_ERROR''@|$(REPLACE_ERROR)|g' \
487 -e 's|@''REPLACE_ERROR_AT_LINE''@|$(REPLACE_ERROR_AT_LINE)|g' \
488 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
489 $(srcdir)/error.in.h > $@-t
490 $(AM_V_at)mv $@-t $@
491MOSTLYCLEANFILES += error.h error.h-t
492
493EXTRA_DIST += error.in.h
494
495## end gnulib module error-h
496
357## begin gnulib module exitfail 497## begin gnulib module exitfail
358 498
359libgnu_a_SOURCES += exitfail.c 499libgnu_a_SOURCES += exitfail.c
@@ -388,10 +528,12 @@ fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
388 -e 's/@''GNULIB_NONBLOCKING''@/$(GL_GNULIB_NONBLOCKING)/g' \ 528 -e 's/@''GNULIB_NONBLOCKING''@/$(GL_GNULIB_NONBLOCKING)/g' \
389 -e 's/@''GNULIB_OPEN''@/$(GL_GNULIB_OPEN)/g' \ 529 -e 's/@''GNULIB_OPEN''@/$(GL_GNULIB_OPEN)/g' \
390 -e 's/@''GNULIB_OPENAT''@/$(GL_GNULIB_OPENAT)/g' \ 530 -e 's/@''GNULIB_OPENAT''@/$(GL_GNULIB_OPENAT)/g' \
531 -e 's/@''GNULIB_OPENAT2''@/$(GL_GNULIB_OPENAT2)/g' \
391 -e 's/@''GNULIB_MDA_CREAT''@/$(GL_GNULIB_MDA_CREAT)/g' \ 532 -e 's/@''GNULIB_MDA_CREAT''@/$(GL_GNULIB_MDA_CREAT)/g' \
392 -e 's/@''GNULIB_MDA_OPEN''@/$(GL_GNULIB_MDA_OPEN)/g' \ 533 -e 's/@''GNULIB_MDA_OPEN''@/$(GL_GNULIB_MDA_OPEN)/g' \
393 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \ 534 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
394 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ 535 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
536 -e 's|@''HAVE_OPENAT2''@|$(HAVE_OPENAT2)|g' \
395 -e 's|@''REPLACE_CREAT''@|$(REPLACE_CREAT)|g' \ 537 -e 's|@''REPLACE_CREAT''@|$(REPLACE_CREAT)|g' \
396 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \ 538 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
397 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ 539 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
@@ -432,7 +574,7 @@ EXTRA_DIST += filename.h
432 574
433## end gnulib module filename 575## end gnulib module filename
434 576
435## begin gnulib module float 577## begin gnulib module float-h
436 578
437BUILT_SOURCES += $(FLOAT_H) 579BUILT_SOURCES += $(FLOAT_H)
438 580
@@ -464,7 +606,7 @@ endif
464 606
465EXTRA_DIST += float.in.h 607EXTRA_DIST += float.in.h
466 608
467## end gnulib module float 609## end gnulib module float-h
468 610
469## begin gnulib module floorf 611## begin gnulib module floorf
470 612
@@ -540,6 +682,16 @@ EXTRA_DIST += stdio-impl.h
540 682
541## end gnulib module fseeko 683## end gnulib module fseeko
542 684
685## begin gnulib module fseterr
686
687if GL_COND_OBJ_FSETERR
688libgnu_a_SOURCES += fseterr.c
689endif
690
691EXTRA_DIST += fseterr.h stdio-impl.h
692
693## end gnulib module fseterr
694
543## begin gnulib module fstat 695## begin gnulib module fstat
544 696
545if GL_COND_OBJ_FSTAT 697if GL_COND_OBJ_FSTAT
@@ -595,6 +747,7 @@ SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G
595SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t' 747SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t'
596 748
597# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that 749# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that
750# is its recipe's first line if and only if @NMD@ lines are absent.
598gl_V_at = $(AM_V_GEN) 751gl_V_at = $(AM_V_GEN)
599 752
600## end gnulib module gen-header 753## end gnulib module gen-header
@@ -698,7 +851,11 @@ EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h get
698 851
699## begin gnulib module getprogname 852## begin gnulib module getprogname
700 853
701libgnu_a_SOURCES += getprogname.h getprogname.c 854if GL_COND_OBJ_GETPROGNAME
855libgnu_a_SOURCES += getprogname.c
856endif
857
858EXTRA_DIST += getprogname.h
702 859
703## end gnulib module getprogname 860## end gnulib module getprogname
704 861
@@ -779,6 +936,14 @@ endif
779 936
780## end gnulib module inet_ntop 937## end gnulib module inet_ntop
781 938
939## begin gnulib module inet_pton
940
941if GL_COND_OBJ_INET_PTON
942libgnu_a_SOURCES += inet_pton.c
943endif
944
945## end gnulib module inet_pton
946
782## begin gnulib module intprops 947## begin gnulib module intprops
783 948
784 949
@@ -786,7 +951,7 @@ EXTRA_DIST += intprops-internal.h intprops.h
786 951
787## end gnulib module intprops 952## end gnulib module intprops
788 953
789## begin gnulib module inttypes-incomplete 954## begin gnulib module inttypes-h-incomplete
790 955
791BUILT_SOURCES += inttypes.h 956BUILT_SOURCES += inttypes.h
792 957
@@ -810,6 +975,8 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
810 -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \ 975 -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
811 -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \ 976 -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
812 -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \ 977 -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \
978 -e 's/@''REPLACE_IMAXABS''@/$(REPLACE_IMAXABS)/g' \
979 -e 's/@''REPLACE_IMAXDIV''@/$(REPLACE_IMAXDIV)/g' \
813 -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \ 980 -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
814 -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \ 981 -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
815 -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \ 982 -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
@@ -825,9 +992,51 @@ MOSTLYCLEANFILES += inttypes.h inttypes.h-t
825 992
826EXTRA_DIST += inttypes.in.h 993EXTRA_DIST += inttypes.in.h
827 994
828## end gnulib module inttypes-incomplete 995## end gnulib module inttypes-h-incomplete
996
997## begin gnulib module iswblank
998
999if GL_COND_OBJ_ISWBLANK
1000libgnu_a_SOURCES += iswblank.c
1001endif
1002
1003## end gnulib module iswblank
1004
1005## begin gnulib module iswctype
1006
1007if GL_COND_OBJ_ISWCTYPE
1008libgnu_a_SOURCES += iswctype.c
1009endif
1010
1011EXTRA_DIST += iswctype-impl.h
1012
1013## end gnulib module iswctype
1014
1015## begin gnulib module iswdigit
1016
1017if GL_COND_OBJ_ISWDIGIT
1018libgnu_a_SOURCES += iswdigit.c
1019endif
1020
1021## end gnulib module iswdigit
1022
1023## begin gnulib module iswpunct
1024
1025if GL_COND_OBJ_ISWPUNCT
1026libgnu_a_SOURCES += iswpunct.c
1027endif
1028
1029## end gnulib module iswpunct
829 1030
830## begin gnulib module langinfo 1031## begin gnulib module iswxdigit
1032
1033if GL_COND_OBJ_ISWXDIGIT
1034libgnu_a_SOURCES += iswxdigit.c
1035endif
1036
1037## end gnulib module iswxdigit
1038
1039## begin gnulib module langinfo-h
831 1040
832BUILT_SOURCES += langinfo.h 1041BUILT_SOURCES += langinfo.h
833 1042
@@ -843,10 +1052,9 @@ langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
843 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ 1052 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
844 -e 's/@''GNULIB_NL_LANGINFO''@/$(GL_GNULIB_NL_LANGINFO)/g' \ 1053 -e 's/@''GNULIB_NL_LANGINFO''@/$(GL_GNULIB_NL_LANGINFO)/g' \
845 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ 1054 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
846 -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
847 -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \ 1055 -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
1056 -e 's|@''HAVE_LANGINFO_ABALTMON''@|$(HAVE_LANGINFO_ABALTMON)|g' \
848 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ 1057 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
849 -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
850 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ 1058 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
851 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ 1059 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
852 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1060 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -857,7 +1065,7 @@ MOSTLYCLEANFILES += langinfo.h langinfo.h-t
857 1065
858EXTRA_DIST += langinfo.in.h 1066EXTRA_DIST += langinfo.in.h
859 1067
860## end gnulib module langinfo 1068## end gnulib module langinfo-h
861 1069
862## begin gnulib module libc-config 1070## begin gnulib module libc-config
863 1071
@@ -900,7 +1108,7 @@ EXTRA_DIST += localcharset.h
900 1108
901## end gnulib module localcharset 1109## end gnulib module localcharset
902 1110
903## begin gnulib module locale 1111## begin gnulib module locale-h
904 1112
905BUILT_SOURCES += locale.h 1113BUILT_SOURCES += locale.h
906 1114
@@ -913,20 +1121,28 @@ locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
913 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1121 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
914 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1122 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
915 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ 1123 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
1124 -e 's|@''HAVE_LOCALE_T''@|$(HAVE_LOCALE_T)|g' \
1125 -e 's|@''HAVE_WINDOWS_LOCALE_T''@|$(HAVE_WINDOWS_LOCALE_T)|g' \
916 -e 's/@''GNULIB_LOCALECONV''@/$(GL_GNULIB_LOCALECONV)/g' \ 1126 -e 's/@''GNULIB_LOCALECONV''@/$(GL_GNULIB_LOCALECONV)/g' \
917 -e 's/@''GNULIB_SETLOCALE''@/$(GL_GNULIB_SETLOCALE)/g' \ 1127 -e 's/@''GNULIB_SETLOCALE''@/$(GL_GNULIB_SETLOCALE)/g' \
918 -e 's/@''GNULIB_SETLOCALE_NULL''@/$(GL_GNULIB_SETLOCALE_NULL)/g' \ 1128 -e 's/@''GNULIB_SETLOCALE_NULL''@/$(GL_GNULIB_SETLOCALE_NULL)/g' \
1129 -e 's/@''GNULIB_NEWLOCALE''@/$(GL_GNULIB_NEWLOCALE)/g' \
919 -e 's/@''GNULIB_DUPLOCALE''@/$(GL_GNULIB_DUPLOCALE)/g' \ 1130 -e 's/@''GNULIB_DUPLOCALE''@/$(GL_GNULIB_DUPLOCALE)/g' \
920 -e 's/@''GNULIB_LOCALENAME''@/$(GL_GNULIB_LOCALENAME)/g' \ 1131 -e 's/@''GNULIB_FREELOCALE''@/$(GL_GNULIB_FREELOCALE)/g' \
1132 -e 's/@''GNULIB_GETLOCALENAME_L''@/$(GL_GNULIB_GETLOCALENAME_L)/g' \
1133 -e 's/@''GNULIB_GETLOCALENAME_L_UNSAFE''@/$(GL_GNULIB_GETLOCALENAME_L_UNSAFE)/g' \
1134 -e 's/@''GNULIB_LOCALENAME_UNSAFE''@/$(GL_GNULIB_LOCALENAME_UNSAFE)/g' \
921 -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \ 1135 -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \
922 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ 1136 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
923 -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \ 1137 -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \
1138 -e 's|@''HAVE_GETLOCALENAME_L''@|$(HAVE_GETLOCALENAME_L)|g' \
924 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ 1139 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
925 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \ 1140 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
926 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \ 1141 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
927 -e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \ 1142 -e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \
928 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ 1143 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
929 -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \ 1144 -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
1145 -e 's|@''REPLACE_GETLOCALENAME_L''@|$(REPLACE_GETLOCALENAME_L)|g' \
930 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \ 1146 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
931 -e 's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|g' \ 1147 -e 's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|g' \
932 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1148 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -938,7 +1154,7 @@ MOSTLYCLEANFILES += locale.h locale.h-t
938 1154
939EXTRA_DIST += locale.in.h 1155EXTRA_DIST += locale.in.h
940 1156
941## end gnulib module locale 1157## end gnulib module locale-h
942 1158
943## begin gnulib module localeconv 1159## begin gnulib module localeconv
944 1160
@@ -962,6 +1178,14 @@ endif
962 1178
963## end gnulib module lseek 1179## end gnulib module lseek
964 1180
1181## begin gnulib module lstat
1182
1183if GL_COND_OBJ_LSTAT
1184libgnu_a_SOURCES += lstat.c
1185endif
1186
1187## end gnulib module lstat
1188
965## begin gnulib module malloc-gnu 1189## begin gnulib module malloc-gnu
966 1190
967 1191
@@ -988,7 +1212,7 @@ EXTRA_DIST += malloca.h
988 1212
989## end gnulib module malloca 1213## end gnulib module malloca
990 1214
991## begin gnulib module math 1215## begin gnulib module math-h
992 1216
993BUILT_SOURCES += math.h 1217BUILT_SOURCES += math.h
994libgnu_a_SOURCES += math.c 1218libgnu_a_SOURCES += math.c
@@ -1043,19 +1267,27 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1043 -e 's/@''GNULIB_FREXPF''@/$(GL_GNULIB_FREXPF)/g' \ 1267 -e 's/@''GNULIB_FREXPF''@/$(GL_GNULIB_FREXPF)/g' \
1044 -e 's/@''GNULIB_FREXP''@/$(GL_GNULIB_FREXP)/g' \ 1268 -e 's/@''GNULIB_FREXP''@/$(GL_GNULIB_FREXP)/g' \
1045 -e 's/@''GNULIB_FREXPL''@/$(GL_GNULIB_FREXPL)/g' \ 1269 -e 's/@''GNULIB_FREXPL''@/$(GL_GNULIB_FREXPL)/g' \
1270 -e 's/@''GNULIB_GETPAYLOAD''@/$(GL_GNULIB_GETPAYLOAD)/g' \
1271 -e 's/@''GNULIB_GETPAYLOADF''@/$(GL_GNULIB_GETPAYLOADF)/g' \
1272 -e 's/@''GNULIB_GETPAYLOADL''@/$(GL_GNULIB_GETPAYLOADL)/g' \
1046 -e 's/@''GNULIB_HYPOT''@/$(GL_GNULIB_HYPOT)/g' \ 1273 -e 's/@''GNULIB_HYPOT''@/$(GL_GNULIB_HYPOT)/g' \
1047 -e 's/@''GNULIB_HYPOTF''@/$(GL_GNULIB_HYPOTF)/g' \ 1274 -e 's/@''GNULIB_HYPOTF''@/$(GL_GNULIB_HYPOTF)/g' \
1048 -e 's/@''GNULIB_HYPOTL''@/$(GL_GNULIB_HYPOTL)/g' \ 1275 -e 's/@''GNULIB_HYPOTL''@/$(GL_GNULIB_HYPOTL)/g' \
1049 < $(srcdir)/math.in.h | \ 1276 < $(srcdir)/math.in.h > $@-t1
1050 sed -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \ 1277 $(AM_V_at)sed \
1278 -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \
1051 -e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \ 1279 -e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \
1052 -e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \ 1280 -e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \
1053 -e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \ 1281 -e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \
1282 -e 's/@''GNULIB_ISFINITE_NO_CXX''@/$(GL_GNULIB_ISFINITE_NO_CXX)/g' \
1054 -e 's/@''GNULIB_ISINF''@/$(GL_GNULIB_ISINF)/g' \ 1283 -e 's/@''GNULIB_ISINF''@/$(GL_GNULIB_ISINF)/g' \
1284 -e 's/@''GNULIB_ISINF_NO_CXX''@/$(GL_GNULIB_ISINF_NO_CXX)/g' \
1055 -e 's/@''GNULIB_ISNAN''@/$(GL_GNULIB_ISNAN)/g' \ 1285 -e 's/@''GNULIB_ISNAN''@/$(GL_GNULIB_ISNAN)/g' \
1286 -e 's/@''GNULIB_ISNAN_NO_CXX''@/$(GL_GNULIB_ISNAN_NO_CXX)/g' \
1056 -e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \ 1287 -e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \
1057 -e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \ 1288 -e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \
1058 -e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \ 1289 -e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \
1290 -e 's/@''GNULIB_LDEXP''@/$(GL_GNULIB_LDEXP)/g' \
1059 -e 's/@''GNULIB_LDEXPF''@/$(GL_GNULIB_LDEXPF)/g' \ 1291 -e 's/@''GNULIB_LDEXPF''@/$(GL_GNULIB_LDEXPF)/g' \
1060 -e 's/@''GNULIB_LDEXPL''@/$(GL_GNULIB_LDEXPL)/g' \ 1292 -e 's/@''GNULIB_LDEXPL''@/$(GL_GNULIB_LDEXPL)/g' \
1061 -e 's/@''GNULIB_LOG''@/$(GL_GNULIB_LOG)/g' \ 1293 -e 's/@''GNULIB_LOG''@/$(GL_GNULIB_LOG)/g' \
@@ -1073,6 +1305,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1073 -e 's/@''GNULIB_LOGB''@/$(GL_GNULIB_LOGB)/g' \ 1305 -e 's/@''GNULIB_LOGB''@/$(GL_GNULIB_LOGB)/g' \
1074 -e 's/@''GNULIB_LOGBF''@/$(GL_GNULIB_LOGBF)/g' \ 1306 -e 's/@''GNULIB_LOGBF''@/$(GL_GNULIB_LOGBF)/g' \
1075 -e 's/@''GNULIB_LOGBL''@/$(GL_GNULIB_LOGBL)/g' \ 1307 -e 's/@''GNULIB_LOGBL''@/$(GL_GNULIB_LOGBL)/g' \
1308 -e 's/@''GNULIB_LOGP1''@/$(GL_GNULIB_LOGP1)/g' \
1309 -e 's/@''GNULIB_LOGP1F''@/$(GL_GNULIB_LOGP1F)/g' \
1310 -e 's/@''GNULIB_LOGP1L''@/$(GL_GNULIB_LOGP1L)/g' \
1076 -e 's/@''GNULIB_MODF''@/$(GL_GNULIB_MODF)/g' \ 1311 -e 's/@''GNULIB_MODF''@/$(GL_GNULIB_MODF)/g' \
1077 -e 's/@''GNULIB_MODFF''@/$(GL_GNULIB_MODFF)/g' \ 1312 -e 's/@''GNULIB_MODFF''@/$(GL_GNULIB_MODFF)/g' \
1078 -e 's/@''GNULIB_MODFL''@/$(GL_GNULIB_MODFL)/g' \ 1313 -e 's/@''GNULIB_MODFL''@/$(GL_GNULIB_MODFL)/g' \
@@ -1086,7 +1321,14 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1086 -e 's/@''GNULIB_ROUND''@/$(GL_GNULIB_ROUND)/g' \ 1321 -e 's/@''GNULIB_ROUND''@/$(GL_GNULIB_ROUND)/g' \
1087 -e 's/@''GNULIB_ROUNDF''@/$(GL_GNULIB_ROUNDF)/g' \ 1322 -e 's/@''GNULIB_ROUNDF''@/$(GL_GNULIB_ROUNDF)/g' \
1088 -e 's/@''GNULIB_ROUNDL''@/$(GL_GNULIB_ROUNDL)/g' \ 1323 -e 's/@''GNULIB_ROUNDL''@/$(GL_GNULIB_ROUNDL)/g' \
1324 -e 's/@''GNULIB_SETPAYLOAD''@/$(GL_GNULIB_SETPAYLOAD)/g' \
1325 -e 's/@''GNULIB_SETPAYLOADF''@/$(GL_GNULIB_SETPAYLOADF)/g' \
1326 -e 's/@''GNULIB_SETPAYLOADL''@/$(GL_GNULIB_SETPAYLOADL)/g' \
1327 -e 's/@''GNULIB_SETPAYLOADSIG''@/$(GL_GNULIB_SETPAYLOADSIG)/g' \
1328 -e 's/@''GNULIB_SETPAYLOADSIGF''@/$(GL_GNULIB_SETPAYLOADSIGF)/g' \
1329 -e 's/@''GNULIB_SETPAYLOADSIGL''@/$(GL_GNULIB_SETPAYLOADSIGL)/g' \
1089 -e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \ 1330 -e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \
1331 -e 's/@''GNULIB_SIGNBIT_NO_CXX''@/$(GL_GNULIB_SIGNBIT_NO_CXX)/g' \
1090 -e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \ 1332 -e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \
1091 -e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \ 1333 -e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \
1092 -e 's/@''GNULIB_SINHF''@/$(GL_GNULIB_SINHF)/g' \ 1334 -e 's/@''GNULIB_SINHF''@/$(GL_GNULIB_SINHF)/g' \
@@ -1098,14 +1340,21 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1098 -e 's/@''GNULIB_TRUNC''@/$(GL_GNULIB_TRUNC)/g' \ 1340 -e 's/@''GNULIB_TRUNC''@/$(GL_GNULIB_TRUNC)/g' \
1099 -e 's/@''GNULIB_TRUNCF''@/$(GL_GNULIB_TRUNCF)/g' \ 1341 -e 's/@''GNULIB_TRUNCF''@/$(GL_GNULIB_TRUNCF)/g' \
1100 -e 's/@''GNULIB_TRUNCL''@/$(GL_GNULIB_TRUNCL)/g' \ 1342 -e 's/@''GNULIB_TRUNCL''@/$(GL_GNULIB_TRUNCL)/g' \
1343 -e 's/@''GNULIB_TOTALORDER''@/$(GL_GNULIB_TOTALORDER)/g' \
1344 -e 's/@''GNULIB_TOTALORDERF''@/$(GL_GNULIB_TOTALORDERF)/g' \
1345 -e 's/@''GNULIB_TOTALORDERL''@/$(GL_GNULIB_TOTALORDERL)/g' \
1346 -e 's/@''GNULIB_TOTALORDERMAG''@/$(GL_GNULIB_TOTALORDERMAG)/g' \
1347 -e 's/@''GNULIB_TOTALORDERMAGF''@/$(GL_GNULIB_TOTALORDERMAGF)/g' \
1348 -e 's/@''GNULIB_TOTALORDERMAGL''@/$(GL_GNULIB_TOTALORDERMAGL)/g' \
1101 -e 's/@''GNULIB_MDA_J0''@/$(GL_GNULIB_MDA_J0)/g' \ 1349 -e 's/@''GNULIB_MDA_J0''@/$(GL_GNULIB_MDA_J0)/g' \
1102 -e 's/@''GNULIB_MDA_J1''@/$(GL_GNULIB_MDA_J1)/g' \ 1350 -e 's/@''GNULIB_MDA_J1''@/$(GL_GNULIB_MDA_J1)/g' \
1103 -e 's/@''GNULIB_MDA_JN''@/$(GL_GNULIB_MDA_JN)/g' \ 1351 -e 's/@''GNULIB_MDA_JN''@/$(GL_GNULIB_MDA_JN)/g' \
1104 -e 's/@''GNULIB_MDA_Y0''@/$(GL_GNULIB_MDA_Y0)/g' \ 1352 -e 's/@''GNULIB_MDA_Y0''@/$(GL_GNULIB_MDA_Y0)/g' \
1105 -e 's/@''GNULIB_MDA_Y1''@/$(GL_GNULIB_MDA_Y1)/g' \ 1353 -e 's/@''GNULIB_MDA_Y1''@/$(GL_GNULIB_MDA_Y1)/g' \
1106 -e 's/@''GNULIB_MDA_YN''@/$(GL_GNULIB_MDA_YN)/g' \ 1354 -e 's/@''GNULIB_MDA_YN''@/$(GL_GNULIB_MDA_YN)/g' \
1107 | \ 1355 < $@-t1 > $@-t2
1108 sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ 1356 $(AM_V_at)sed \
1357 -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \
1109 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ 1358 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
1110 -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \ 1359 -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \
1111 -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \ 1360 -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
@@ -1116,14 +1365,19 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1116 -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \ 1365 -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \
1117 -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \ 1366 -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \
1118 -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \ 1367 -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \
1368 -e 's|@''HAVE_COPYSIGNF''@|$(HAVE_COPYSIGNF)|g' \
1119 -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \ 1369 -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \
1120 -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \ 1370 -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
1121 -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \ 1371 -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
1122 -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \ 1372 -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \
1123 -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \ 1373 -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
1124 -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \ 1374 -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
1375 -e 's|@''HAVE_EXP2''@|$(HAVE_EXP2)|g' \
1376 -e 's|@''HAVE_EXP2F''@|$(HAVE_EXP2F)|g' \
1377 -e 's|@''HAVE_EXP2L''@|$(HAVE_EXP2L)|g' \
1125 -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \ 1378 -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \
1126 -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \ 1379 -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \
1380 -e 's|@''HAVE_EXPM1L''@|$(HAVE_EXPM1L)|g' \
1127 -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \ 1381 -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
1128 -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \ 1382 -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \
1129 -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \ 1383 -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \
@@ -1132,6 +1386,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1132 -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \ 1386 -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \
1133 -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \ 1387 -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \
1134 -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \ 1388 -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \
1389 -e 's|@''HAVE_GETPAYLOAD''@|$(HAVE_GETPAYLOAD)|g' \
1390 -e 's|@''HAVE_GETPAYLOADF''@|$(HAVE_GETPAYLOADF)|g' \
1391 -e 's|@''HAVE_GETPAYLOADL''@|$(HAVE_GETPAYLOADL)|g' \
1135 -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \ 1392 -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \
1136 -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \ 1393 -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \
1137 -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \ 1394 -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \
@@ -1148,15 +1405,32 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1148 -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \ 1405 -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \
1149 -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \ 1406 -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \
1150 -e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \ 1407 -e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \
1408 -e 's|@''HAVE_LOG2''@|$(HAVE_LOG2)|g' \
1409 -e 's|@''HAVE_LOG2F''@|$(HAVE_LOG2F)|g' \
1410 -e 's|@''HAVE_LOG2L''@|$(HAVE_LOG2L)|g' \
1151 -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \ 1411 -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \
1152 -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \ 1412 -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \
1413 -e 's|@''HAVE_LOGP1''@|$(HAVE_LOGP1)|g' \
1414 -e 's|@''HAVE_LOGP1F''@|$(HAVE_LOGP1F)|g' \
1415 -e 's|@''HAVE_LOGP1L''@|$(HAVE_LOGP1L)|g' \
1153 -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ 1416 -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
1154 -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ 1417 -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \
1155 -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ 1418 -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
1156 -e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \ 1419 -e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \
1157 -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \ 1420 -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \
1421 -e 's|@''HAVE_REMAINDERL''@|$(HAVE_REMAINDERL)|g' \
1158 -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \ 1422 -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
1423 -e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \
1159 -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \ 1424 -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \
1425 -e 's|@''HAVE_ROUND''@|$(HAVE_ROUND)|g' \
1426 -e 's|@''HAVE_ROUNDF''@|$(HAVE_ROUNDF)|g' \
1427 -e 's|@''HAVE_ROUNDL''@|$(HAVE_ROUNDL)|g' \
1428 -e 's|@''HAVE_SETPAYLOAD''@|$(HAVE_SETPAYLOAD)|g' \
1429 -e 's|@''HAVE_SETPAYLOADF''@|$(HAVE_SETPAYLOADF)|g' \
1430 -e 's|@''HAVE_SETPAYLOADL''@|$(HAVE_SETPAYLOADL)|g' \
1431 -e 's|@''HAVE_SETPAYLOADSIG''@|$(HAVE_SETPAYLOADSIG)|g' \
1432 -e 's|@''HAVE_SETPAYLOADSIGF''@|$(HAVE_SETPAYLOADSIGF)|g' \
1433 -e 's|@''HAVE_SETPAYLOADSIGL''@|$(HAVE_SETPAYLOADSIGL)|g' \
1160 -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ 1434 -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \
1161 -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ 1435 -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
1162 -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \ 1436 -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \
@@ -1165,44 +1439,37 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1165 -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ 1439 -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \
1166 -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ 1440 -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
1167 -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \ 1441 -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \
1442 -e 's|@''HAVE_TOTALORDER''@|$(HAVE_TOTALORDER)|g' \
1443 -e 's|@''HAVE_TOTALORDERF''@|$(HAVE_TOTALORDERF)|g' \
1444 -e 's|@''HAVE_TOTALORDERL''@|$(HAVE_TOTALORDERL)|g' \
1445 -e 's|@''HAVE_TOTALORDERMAG''@|$(HAVE_TOTALORDERMAG)|g' \
1446 -e 's|@''HAVE_TOTALORDERMAGF''@|$(HAVE_TOTALORDERMAGF)|g' \
1447 -e 's|@''HAVE_TOTALORDERMAGL''@|$(HAVE_TOTALORDERMAGL)|g' \
1448 < $@-t2 > $@-t3
1449 $(AM_V_at)sed \
1168 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ 1450 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
1169 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ 1451 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
1170 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ 1452 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
1171 -e 's|@''HAVE_DECL_CBRTF''@|$(HAVE_DECL_CBRTF)|g' \
1172 -e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \
1173 -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \ 1453 -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \
1174 -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \ 1454 -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \
1175 -e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \
1176 -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ 1455 -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \
1177 -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ 1456 -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \
1178 -e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \
1179 -e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \
1180 -e 's|@''HAVE_DECL_EXP2L''@|$(HAVE_DECL_EXP2L)|g' \
1181 -e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \
1182 -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ 1457 -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \
1183 -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \ 1458 -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \
1184 -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ 1459 -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \
1185 -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ 1460 -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \
1186 -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ 1461 -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \
1187 -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \ 1462 -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \
1188 -e 's|@''HAVE_DECL_LOG2''@|$(HAVE_DECL_LOG2)|g' \
1189 -e 's|@''HAVE_DECL_LOG2F''@|$(HAVE_DECL_LOG2F)|g' \
1190 -e 's|@''HAVE_DECL_LOG2L''@|$(HAVE_DECL_LOG2L)|g' \
1191 -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ 1463 -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \
1192 -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \
1193 -e 's|@''HAVE_DECL_REMAINDERL''@|$(HAVE_DECL_REMAINDERL)|g' \
1194 -e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \
1195 -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \
1196 -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \
1197 -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \
1198 -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ 1464 -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \
1199 -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ 1465 -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \
1200 -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ 1466 -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
1201 -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ 1467 -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \
1202 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ 1468 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
1203 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ 1469 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
1204 | \ 1470 < $@-t3 > $@-t4
1205 sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \ 1471 $(AM_V_at)sed \
1472 -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \
1206 -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \ 1473 -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \
1207 -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \ 1474 -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \
1208 -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \ 1475 -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \
@@ -1233,6 +1500,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1233 -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \ 1500 -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \
1234 -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ 1501 -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
1235 -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ 1502 -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
1503 -e 's|@''REPLACE_GETPAYLOAD''@|$(REPLACE_GETPAYLOAD)|g' \
1504 -e 's|@''REPLACE_GETPAYLOADF''@|$(REPLACE_GETPAYLOADF)|g' \
1505 -e 's|@''REPLACE_GETPAYLOADL''@|$(REPLACE_GETPAYLOADL)|g' \
1236 -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \ 1506 -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
1237 -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \ 1507 -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \
1238 -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \ 1508 -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \
@@ -1244,6 +1514,9 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1244 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ 1514 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
1245 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ 1515 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
1246 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ 1516 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
1517 < $@-t4 > $@-t5
1518 $(AM_V_at)sed \
1519 -e 's|@''REPLACE_LDEXP''@|$(REPLACE_LDEXP)|g' \
1247 -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ 1520 -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
1248 -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ 1521 -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \
1249 -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ 1522 -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \
@@ -1275,23 +1548,57 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
1275 -e 's|@''REPLACE_SIGNBIT_USING_BUILTINS''@|$(REPLACE_SIGNBIT_USING_BUILTINS)|g' \ 1548 -e 's|@''REPLACE_SIGNBIT_USING_BUILTINS''@|$(REPLACE_SIGNBIT_USING_BUILTINS)|g' \
1276 -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \ 1549 -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \
1277 -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \ 1550 -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \
1551 -e 's|@''REPLACE_SINL''@|$(REPLACE_SINL)|g' \
1278 -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \ 1552 -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \
1279 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ 1553 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
1280 -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \ 1554 -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \
1281 -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \ 1555 -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \
1556 -e 's|@''REPLACE_TOTALORDER''@|$(REPLACE_TOTALORDER)|g' \
1557 -e 's|@''REPLACE_TOTALORDERF''@|$(REPLACE_TOTALORDERF)|g' \
1558 -e 's|@''REPLACE_TOTALORDERL''@|$(REPLACE_TOTALORDERL)|g' \
1559 -e 's|@''REPLACE_TOTALORDERMAG''@|$(REPLACE_TOTALORDERMAG)|g' \
1560 -e 's|@''REPLACE_TOTALORDERMAGF''@|$(REPLACE_TOTALORDERMAGF)|g' \
1561 -e 's|@''REPLACE_TOTALORDERMAGL''@|$(REPLACE_TOTALORDERMAGL)|g' \
1282 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ 1562 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
1283 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ 1563 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \
1284 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ 1564 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
1285 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1565 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1286 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1566 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1287 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 1567 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1288 > $@-t 1568 < $@-t5 > $@-t6
1289 $(AM_V_at)mv $@-t $@ 1569 $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3 $@-t4 $@-t5
1290MOSTLYCLEANFILES += math.h math.h-t 1570 $(AM_V_at)mv $@-t6 $@
1571MOSTLYCLEANFILES += math.h math.h-t1 math.h-t2 math.h-t3 math.h-t4 math.h-t5 math.h-t6
1291 1572
1292EXTRA_DIST += math.in.h 1573EXTRA_DIST += math.in.h
1293 1574
1294## end gnulib module math 1575## end gnulib module math-h
1576
1577## begin gnulib module mbchar
1578
1579libgnu_a_SOURCES += mbchar.c
1580
1581EXTRA_DIST += mbchar.h
1582
1583## end gnulib module mbchar
1584
1585## begin gnulib module mbiterf
1586
1587libgnu_a_SOURCES += mbiterf.h mbiterf.c
1588
1589## end gnulib module mbiterf
1590
1591## begin gnulib module mbrtoc32
1592
1593if GL_COND_OBJ_MBRTOC32
1594libgnu_a_SOURCES += mbrtoc32.c
1595endif
1596
1597EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbtowc-lock.c mbtowc-lock.h windows-initguard.h
1598
1599EXTRA_libgnu_a_SOURCES += lc-charset-dispatch.c mbtowc-lock.c
1600
1601## end gnulib module mbrtoc32
1295 1602
1296## begin gnulib module mbrtowc 1603## begin gnulib module mbrtowc
1297 1604
@@ -1313,6 +1620,18 @@ endif
1313 1620
1314## end gnulib module mbsinit 1621## end gnulib module mbsinit
1315 1622
1623## begin gnulib module mbsnlen
1624
1625libgnu_a_SOURCES += mbsnlen.c
1626
1627## end gnulib module mbsnlen
1628
1629## begin gnulib module mbszero
1630
1631libgnu_a_SOURCES += mbszero.c
1632
1633## end gnulib module mbszero
1634
1316## begin gnulib module mbtowc 1635## begin gnulib module mbtowc
1317 1636
1318if GL_COND_OBJ_MBTOWC 1637if GL_COND_OBJ_MBTOWC
@@ -1359,9 +1678,7 @@ EXTRA_libgnu_a_SOURCES += mktime.c
1359 1678
1360## begin gnulib module mountlist 1679## begin gnulib module mountlist
1361 1680
1362if GL_COND_OBJ_MOUNTLIST
1363libgnu_a_SOURCES += mountlist.c 1681libgnu_a_SOURCES += mountlist.c
1364endif
1365 1682
1366EXTRA_DIST += mountlist.h 1683EXTRA_DIST += mountlist.h
1367 1684
@@ -1387,7 +1704,7 @@ EXTRA_DIST += msvc-nothrow.h
1387 1704
1388## end gnulib module msvc-nothrow 1705## end gnulib module msvc-nothrow
1389 1706
1390## begin gnulib module netdb 1707## begin gnulib module netdb-h
1391 1708
1392BUILT_SOURCES += netdb.h 1709BUILT_SOURCES += netdb.h
1393 1710
@@ -1418,9 +1735,9 @@ MOSTLYCLEANFILES += netdb.h netdb.h-t
1418 1735
1419EXTRA_DIST += netdb.in.h 1736EXTRA_DIST += netdb.in.h
1420 1737
1421## end gnulib module netdb 1738## end gnulib module netdb-h
1422 1739
1423## begin gnulib module netinet_in 1740## begin gnulib module netinet_in-h
1424 1741
1425BUILT_SOURCES += $(NETINET_IN_H) 1742BUILT_SOURCES += $(NETINET_IN_H)
1426 1743
@@ -1447,7 +1764,7 @@ MOSTLYCLEANDIRS += netinet
1447 1764
1448EXTRA_DIST += netinet_in.in.h 1765EXTRA_DIST += netinet_in.in.h
1449 1766
1450## end gnulib module netinet_in 1767## end gnulib module netinet_in-h
1451 1768
1452## begin gnulib module nl_langinfo 1769## begin gnulib module nl_langinfo
1453 1770
@@ -1462,6 +1779,12 @@ EXTRA_DIST += windows-initguard.h
1462 1779
1463## end gnulib module nl_langinfo 1780## end gnulib module nl_langinfo
1464 1781
1782## begin gnulib module once
1783
1784libgnu_a_SOURCES += glthread/once.h glthread/once.c
1785
1786## end gnulib module once
1787
1465## begin gnulib module open 1788## begin gnulib module open
1466 1789
1467if GL_COND_OBJ_OPEN 1790if GL_COND_OBJ_OPEN
@@ -1477,21 +1800,168 @@ EXTRA_DIST += pathmax.h
1477 1800
1478## end gnulib module pathmax 1801## end gnulib module pathmax
1479 1802
1480## begin gnulib module realloc-gnu 1803## begin gnulib module pthread-h
1804
1805BUILT_SOURCES += pthread.h
1481 1806
1807# We need the following in order to create <pthread.h> when the system
1808# doesn't have one that works with the given compiler.
1809pthread.h: pthread.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1810 $(gl_V_at)$(SED_HEADER_STDOUT) \
1811 -e 's|@''GUARD_PREFIX''@|GL|g' \
1812 -e 's|@''HAVE_PTHREAD_H''@|$(HAVE_PTHREAD_H)|g' \
1813 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1814 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1815 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1816 -e 's|@''NEXT_PTHREAD_H''@|$(NEXT_PTHREAD_H)|g' \
1817 -e 's/@''GNULIB_PTHREAD_THREAD''@/$(GL_GNULIB_PTHREAD_THREAD)/g' \
1818 -e 's/@''GNULIB_PTHREAD_ONCE''@/$(GL_GNULIB_PTHREAD_ONCE)/g' \
1819 -e 's/@''GNULIB_PTHREAD_MUTEX''@/$(GL_GNULIB_PTHREAD_MUTEX)/g' \
1820 -e 's/@''GNULIB_PTHREAD_RWLOCK''@/$(GL_GNULIB_PTHREAD_RWLOCK)/g' \
1821 -e 's/@''GNULIB_PTHREAD_COND''@/$(GL_GNULIB_PTHREAD_COND)/g' \
1822 -e 's/@''GNULIB_PTHREAD_TSS''@/$(GL_GNULIB_PTHREAD_TSS)/g' \
1823 -e 's/@''GNULIB_PTHREAD_SPIN''@/$(GL_GNULIB_PTHREAD_SPIN)/g' \
1824 -e 's/@''GNULIB_PTHREAD_MUTEX_TIMEDLOCK''@/$(GL_GNULIB_PTHREAD_MUTEX_TIMEDLOCK)/g' \
1825 -e 's|@''HAVE_PTHREAD_T''@|$(HAVE_PTHREAD_T)|g' \
1826 -e 's|@''HAVE_PTHREAD_SPINLOCK_T''@|$(HAVE_PTHREAD_SPINLOCK_T)|g' \
1827 -e 's|@''HAVE_PTHREAD_CREATE_DETACHED''@|$(HAVE_PTHREAD_CREATE_DETACHED)|g' \
1828 -e 's|@''HAVE_PTHREAD_MUTEX_RECURSIVE''@|$(HAVE_PTHREAD_MUTEX_RECURSIVE)|g' \
1829 -e 's|@''HAVE_PTHREAD_MUTEX_ROBUST''@|$(HAVE_PTHREAD_MUTEX_ROBUST)|g' \
1830 -e 's|@''HAVE_PTHREAD_PROCESS_SHARED''@|$(HAVE_PTHREAD_PROCESS_SHARED)|g' \
1831 -e 's|@''HAVE_PTHREAD_CREATE''@|$(HAVE_PTHREAD_CREATE)|g' \
1832 -e 's|@''HAVE_PTHREAD_ATTR_INIT''@|$(HAVE_PTHREAD_ATTR_INIT)|g' \
1833 -e 's|@''HAVE_PTHREAD_ATTR_GETDETACHSTATE''@|$(HAVE_PTHREAD_ATTR_GETDETACHSTATE)|g' \
1834 -e 's|@''HAVE_PTHREAD_ATTR_SETDETACHSTATE''@|$(HAVE_PTHREAD_ATTR_SETDETACHSTATE)|g' \
1835 -e 's|@''HAVE_PTHREAD_ATTR_DESTROY''@|$(HAVE_PTHREAD_ATTR_DESTROY)|g' \
1836 -e 's|@''HAVE_PTHREAD_SELF''@|$(HAVE_PTHREAD_SELF)|g' \
1837 -e 's|@''HAVE_PTHREAD_EQUAL''@|$(HAVE_PTHREAD_EQUAL)|g' \
1838 -e 's|@''HAVE_PTHREAD_DETACH''@|$(HAVE_PTHREAD_DETACH)|g' \
1839 -e 's|@''HAVE_PTHREAD_JOIN''@|$(HAVE_PTHREAD_JOIN)|g' \
1840 -e 's|@''HAVE_PTHREAD_EXIT''@|$(HAVE_PTHREAD_EXIT)|g' \
1841 < $(srcdir)/pthread.in.h > $@-t1
1842 $(AM_V_at)sed \
1843 -e 's|@''HAVE_PTHREAD_ONCE''@|$(HAVE_PTHREAD_ONCE)|g' \
1844 -e 's|@''HAVE_PTHREAD_MUTEX_INIT''@|$(HAVE_PTHREAD_MUTEX_INIT)|g' \
1845 -e 's|@''HAVE_PTHREAD_MUTEXATTR_INIT''@|$(HAVE_PTHREAD_MUTEXATTR_INIT)|g' \
1846 -e 's|@''HAVE_PTHREAD_MUTEXATTR_GETTYPE''@|$(HAVE_PTHREAD_MUTEXATTR_GETTYPE)|g' \
1847 -e 's|@''HAVE_PTHREAD_MUTEXATTR_SETTYPE''@|$(HAVE_PTHREAD_MUTEXATTR_SETTYPE)|g' \
1848 -e 's|@''HAVE_PTHREAD_MUTEXATTR_GETROBUST''@|$(HAVE_PTHREAD_MUTEXATTR_GETROBUST)|g' \
1849 -e 's|@''HAVE_PTHREAD_MUTEXATTR_SETROBUST''@|$(HAVE_PTHREAD_MUTEXATTR_SETROBUST)|g' \
1850 -e 's|@''HAVE_PTHREAD_MUTEXATTR_DESTROY''@|$(HAVE_PTHREAD_MUTEXATTR_DESTROY)|g' \
1851 -e 's|@''HAVE_PTHREAD_MUTEX_LOCK''@|$(HAVE_PTHREAD_MUTEX_LOCK)|g' \
1852 -e 's|@''HAVE_PTHREAD_MUTEX_TRYLOCK''@|$(HAVE_PTHREAD_MUTEX_TRYLOCK)|g' \
1853 -e 's|@''HAVE_PTHREAD_MUTEX_TIMEDLOCK''@|$(HAVE_PTHREAD_MUTEX_TIMEDLOCK)|g' \
1854 -e 's|@''HAVE_PTHREAD_MUTEX_UNLOCK''@|$(HAVE_PTHREAD_MUTEX_UNLOCK)|g' \
1855 -e 's|@''HAVE_PTHREAD_MUTEX_DESTROY''@|$(HAVE_PTHREAD_MUTEX_DESTROY)|g' \
1856 -e 's|@''HAVE_PTHREAD_RWLOCK_INIT''@|$(HAVE_PTHREAD_RWLOCK_INIT)|g' \
1857 -e 's|@''HAVE_PTHREAD_RWLOCKATTR_INIT''@|$(HAVE_PTHREAD_RWLOCKATTR_INIT)|g' \
1858 -e 's|@''HAVE_PTHREAD_RWLOCKATTR_DESTROY''@|$(HAVE_PTHREAD_RWLOCKATTR_DESTROY)|g' \
1859 -e 's|@''HAVE_PTHREAD_RWLOCK_RDLOCK''@|$(HAVE_PTHREAD_RWLOCK_RDLOCK)|g' \
1860 -e 's|@''HAVE_PTHREAD_RWLOCK_WRLOCK''@|$(HAVE_PTHREAD_RWLOCK_WRLOCK)|g' \
1861 -e 's|@''HAVE_PTHREAD_RWLOCK_TRYRDLOCK''@|$(HAVE_PTHREAD_RWLOCK_TRYRDLOCK)|g' \
1862 -e 's|@''HAVE_PTHREAD_RWLOCK_TRYWRLOCK''@|$(HAVE_PTHREAD_RWLOCK_TRYWRLOCK)|g' \
1863 -e 's|@''HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK''@|$(HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK)|g' \
1864 -e 's|@''HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK''@|$(HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK)|g' \
1865 -e 's|@''HAVE_PTHREAD_RWLOCK_UNLOCK''@|$(HAVE_PTHREAD_RWLOCK_UNLOCK)|g' \
1866 -e 's|@''HAVE_PTHREAD_RWLOCK_DESTROY''@|$(HAVE_PTHREAD_RWLOCK_DESTROY)|g' \
1867 -e 's|@''HAVE_PTHREAD_COND_INIT''@|$(HAVE_PTHREAD_COND_INIT)|g' \
1868 -e 's|@''HAVE_PTHREAD_CONDATTR_INIT''@|$(HAVE_PTHREAD_CONDATTR_INIT)|g' \
1869 -e 's|@''HAVE_PTHREAD_CONDATTR_DESTROY''@|$(HAVE_PTHREAD_CONDATTR_DESTROY)|g' \
1870 -e 's|@''HAVE_PTHREAD_COND_WAIT''@|$(HAVE_PTHREAD_COND_WAIT)|g' \
1871 -e 's|@''HAVE_PTHREAD_COND_TIMEDWAIT''@|$(HAVE_PTHREAD_COND_TIMEDWAIT)|g' \
1872 -e 's|@''HAVE_PTHREAD_COND_SIGNAL''@|$(HAVE_PTHREAD_COND_SIGNAL)|g' \
1873 -e 's|@''HAVE_PTHREAD_COND_BROADCAST''@|$(HAVE_PTHREAD_COND_BROADCAST)|g' \
1874 -e 's|@''HAVE_PTHREAD_COND_DESTROY''@|$(HAVE_PTHREAD_COND_DESTROY)|g' \
1875 -e 's|@''HAVE_PTHREAD_KEY_CREATE''@|$(HAVE_PTHREAD_KEY_CREATE)|g' \
1876 -e 's|@''HAVE_PTHREAD_SETSPECIFIC''@|$(HAVE_PTHREAD_SETSPECIFIC)|g' \
1877 -e 's|@''HAVE_PTHREAD_GETSPECIFIC''@|$(HAVE_PTHREAD_GETSPECIFIC)|g' \
1878 -e 's|@''HAVE_PTHREAD_KEY_DELETE''@|$(HAVE_PTHREAD_KEY_DELETE)|g' \
1879 -e 's|@''HAVE_PTHREAD_SPIN_INIT''@|$(HAVE_PTHREAD_SPIN_INIT)|g' \
1880 -e 's|@''HAVE_PTHREAD_SPIN_LOCK''@|$(HAVE_PTHREAD_SPIN_LOCK)|g' \
1881 -e 's|@''HAVE_PTHREAD_SPIN_TRYLOCK''@|$(HAVE_PTHREAD_SPIN_TRYLOCK)|g' \
1882 -e 's|@''HAVE_PTHREAD_SPIN_UNLOCK''@|$(HAVE_PTHREAD_SPIN_UNLOCK)|g' \
1883 -e 's|@''HAVE_PTHREAD_SPIN_DESTROY''@|$(HAVE_PTHREAD_SPIN_DESTROY)|g' \
1884 < $@-t1 > $@-t2
1885 $(AM_V_at)sed \
1886 -e 's|@''REPLACE_PTHREAD_CREATE''@|$(REPLACE_PTHREAD_CREATE)|g' \
1887 -e 's|@''REPLACE_PTHREAD_ATTR_INIT''@|$(REPLACE_PTHREAD_ATTR_INIT)|g' \
1888 -e 's|@''REPLACE_PTHREAD_ATTR_GETDETACHSTATE''@|$(REPLACE_PTHREAD_ATTR_GETDETACHSTATE)|g' \
1889 -e 's|@''REPLACE_PTHREAD_ATTR_SETDETACHSTATE''@|$(REPLACE_PTHREAD_ATTR_SETDETACHSTATE)|g' \
1890 -e 's|@''REPLACE_PTHREAD_ATTR_DESTROY''@|$(REPLACE_PTHREAD_ATTR_DESTROY)|g' \
1891 -e 's|@''REPLACE_PTHREAD_SELF''@|$(REPLACE_PTHREAD_SELF)|g' \
1892 -e 's|@''REPLACE_PTHREAD_EQUAL''@|$(REPLACE_PTHREAD_EQUAL)|g' \
1893 -e 's|@''REPLACE_PTHREAD_DETACH''@|$(REPLACE_PTHREAD_DETACH)|g' \
1894 -e 's|@''REPLACE_PTHREAD_JOIN''@|$(REPLACE_PTHREAD_JOIN)|g' \
1895 -e 's|@''REPLACE_PTHREAD_EXIT''@|$(REPLACE_PTHREAD_EXIT)|g' \
1896 -e 's|@''REPLACE_PTHREAD_ONCE''@|$(REPLACE_PTHREAD_ONCE)|g' \
1897 -e 's|@''REPLACE_PTHREAD_MUTEX_INIT''@|$(REPLACE_PTHREAD_MUTEX_INIT)|g' \
1898 -e 's|@''REPLACE_PTHREAD_MUTEXATTR_INIT''@|$(REPLACE_PTHREAD_MUTEXATTR_INIT)|g' \
1899 -e 's|@''REPLACE_PTHREAD_MUTEXATTR_GETTYPE''@|$(REPLACE_PTHREAD_MUTEXATTR_GETTYPE)|g' \
1900 -e 's|@''REPLACE_PTHREAD_MUTEXATTR_SETTYPE''@|$(REPLACE_PTHREAD_MUTEXATTR_SETTYPE)|g' \
1901 -e 's|@''REPLACE_PTHREAD_MUTEXATTR_GETROBUST''@|$(REPLACE_PTHREAD_MUTEXATTR_GETROBUST)|g' \
1902 -e 's|@''REPLACE_PTHREAD_MUTEXATTR_SETROBUST''@|$(REPLACE_PTHREAD_MUTEXATTR_SETROBUST)|g' \
1903 -e 's|@''REPLACE_PTHREAD_MUTEXATTR_DESTROY''@|$(REPLACE_PTHREAD_MUTEXATTR_DESTROY)|g' \
1904 -e 's|@''REPLACE_PTHREAD_MUTEX_LOCK''@|$(REPLACE_PTHREAD_MUTEX_LOCK)|g' \
1905 -e 's|@''REPLACE_PTHREAD_MUTEX_TRYLOCK''@|$(REPLACE_PTHREAD_MUTEX_TRYLOCK)|g' \
1906 -e 's|@''REPLACE_PTHREAD_MUTEX_TIMEDLOCK''@|$(REPLACE_PTHREAD_MUTEX_TIMEDLOCK)|g' \
1907 -e 's|@''REPLACE_PTHREAD_MUTEX_UNLOCK''@|$(REPLACE_PTHREAD_MUTEX_UNLOCK)|g' \
1908 -e 's|@''REPLACE_PTHREAD_MUTEX_DESTROY''@|$(REPLACE_PTHREAD_MUTEX_DESTROY)|g' \
1909 -e 's|@''REPLACE_PTHREAD_RWLOCK_INIT''@|$(REPLACE_PTHREAD_RWLOCK_INIT)|g' \
1910 -e 's|@''REPLACE_PTHREAD_RWLOCKATTR_INIT''@|$(REPLACE_PTHREAD_RWLOCKATTR_INIT)|g' \
1911 -e 's|@''REPLACE_PTHREAD_RWLOCKATTR_DESTROY''@|$(REPLACE_PTHREAD_RWLOCKATTR_DESTROY)|g' \
1912 -e 's|@''REPLACE_PTHREAD_RWLOCK_RDLOCK''@|$(REPLACE_PTHREAD_RWLOCK_RDLOCK)|g' \
1913 -e 's|@''REPLACE_PTHREAD_RWLOCK_WRLOCK''@|$(REPLACE_PTHREAD_RWLOCK_WRLOCK)|g' \
1914 -e 's|@''REPLACE_PTHREAD_RWLOCK_TRYRDLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TRYRDLOCK)|g' \
1915 -e 's|@''REPLACE_PTHREAD_RWLOCK_TRYWRLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TRYWRLOCK)|g' \
1916 -e 's|@''REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK)|g' \
1917 -e 's|@''REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK''@|$(REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK)|g' \
1918 -e 's|@''REPLACE_PTHREAD_RWLOCK_UNLOCK''@|$(REPLACE_PTHREAD_RWLOCK_UNLOCK)|g' \
1919 -e 's|@''REPLACE_PTHREAD_RWLOCK_DESTROY''@|$(REPLACE_PTHREAD_RWLOCK_DESTROY)|g' \
1920 < $@-t2 > $@-t3
1921 $(AM_V_at)sed \
1922 -e 's|@''REPLACE_PTHREAD_COND_INIT''@|$(REPLACE_PTHREAD_COND_INIT)|g' \
1923 -e 's|@''REPLACE_PTHREAD_CONDATTR_INIT''@|$(REPLACE_PTHREAD_CONDATTR_INIT)|g' \
1924 -e 's|@''REPLACE_PTHREAD_CONDATTR_DESTROY''@|$(REPLACE_PTHREAD_CONDATTR_DESTROY)|g' \
1925 -e 's|@''REPLACE_PTHREAD_COND_WAIT''@|$(REPLACE_PTHREAD_COND_WAIT)|g' \
1926 -e 's|@''REPLACE_PTHREAD_COND_TIMEDWAIT''@|$(REPLACE_PTHREAD_COND_TIMEDWAIT)|g' \
1927 -e 's|@''REPLACE_PTHREAD_COND_SIGNAL''@|$(REPLACE_PTHREAD_COND_SIGNAL)|g' \
1928 -e 's|@''REPLACE_PTHREAD_COND_BROADCAST''@|$(REPLACE_PTHREAD_COND_BROADCAST)|g' \
1929 -e 's|@''REPLACE_PTHREAD_COND_DESTROY''@|$(REPLACE_PTHREAD_COND_DESTROY)|g' \
1930 -e 's|@''REPLACE_PTHREAD_KEY_CREATE''@|$(REPLACE_PTHREAD_KEY_CREATE)|g' \
1931 -e 's|@''REPLACE_PTHREAD_SETSPECIFIC''@|$(REPLACE_PTHREAD_SETSPECIFIC)|g' \
1932 -e 's|@''REPLACE_PTHREAD_GETSPECIFIC''@|$(REPLACE_PTHREAD_GETSPECIFIC)|g' \
1933 -e 's|@''REPLACE_PTHREAD_KEY_DELETE''@|$(REPLACE_PTHREAD_KEY_DELETE)|g' \
1934 -e 's|@''REPLACE_PTHREAD_SPIN_INIT''@|$(REPLACE_PTHREAD_SPIN_INIT)|g' \
1935 -e 's|@''REPLACE_PTHREAD_SPIN_LOCK''@|$(REPLACE_PTHREAD_SPIN_LOCK)|g' \
1936 -e 's|@''REPLACE_PTHREAD_SPIN_TRYLOCK''@|$(REPLACE_PTHREAD_SPIN_TRYLOCK)|g' \
1937 -e 's|@''REPLACE_PTHREAD_SPIN_UNLOCK''@|$(REPLACE_PTHREAD_SPIN_UNLOCK)|g' \
1938 -e 's|@''REPLACE_PTHREAD_SPIN_DESTROY''@|$(REPLACE_PTHREAD_SPIN_DESTROY)|g' \
1939 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1940 -e '/definition of _Noreturn/r $(_NORETURN_H)' \
1941 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1942 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1943 < $@-t3 > $@-t4
1944 $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3
1945 $(AM_V_at)mv $@-t4 $@
1946MOSTLYCLEANFILES += pthread.h pthread.h-t1 pthread.h-t2 pthread.h-t3 pthread.h-t4
1482 1947
1483EXTRA_DIST += realloc.c 1948EXTRA_DIST += pthread.in.h
1484 1949
1485EXTRA_libgnu_a_SOURCES += realloc.c 1950## end gnulib module pthread-h
1486 1951
1487## end gnulib module realloc-gnu 1952## begin gnulib module pthread-once
1488 1953
1489## begin gnulib module realloc-posix 1954if GL_COND_OBJ_PTHREAD_ONCE
1955libgnu_a_SOURCES += pthread-once.c
1956endif
1490 1957
1958## end gnulib module pthread-once
1491 1959
1492EXTRA_DIST += realloc.c 1960## begin gnulib module realloc-posix
1493 1961
1494EXTRA_libgnu_a_SOURCES += realloc.c 1962if GL_COND_OBJ_REALLOC_POSIX
1963libgnu_a_SOURCES += realloc.c
1964endif
1495 1965
1496## end gnulib module realloc-posix 1966## end gnulib module realloc-posix
1497 1967
@@ -1515,6 +1985,35 @@ EXTRA_libgnu_a_SOURCES += regcomp.c regex_internal.c regexec.c
1515 1985
1516## end gnulib module regex 1986## end gnulib module regex
1517 1987
1988## begin gnulib module sched-h
1989
1990BUILT_SOURCES += sched.h
1991
1992# We need the following in order to create a replacement for <sched.h> when
1993# the system doesn't have one.
1994sched.h: sched.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
1995 $(gl_V_at)$(SED_HEADER_STDOUT) \
1996 -e 's|@''GUARD_PREFIX''@|GL|g' \
1997 -e 's|@''HAVE_SCHED_H''@|$(HAVE_SCHED_H)|g' \
1998 -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
1999 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2000 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2001 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2002 -e 's|@''NEXT_SCHED_H''@|$(NEXT_SCHED_H)|g' \
2003 -e 's|@''HAVE_STRUCT_SCHED_PARAM''@|$(HAVE_STRUCT_SCHED_PARAM)|g' \
2004 -e 's/@''GNULIB_SCHED_YIELD''@/$(GL_GNULIB_SCHED_YIELD)/g' \
2005 -e 's|@''HAVE_SCHED_YIELD''@|$(HAVE_SCHED_YIELD)|g' \
2006 -e 's|@''REPLACE_SCHED_YIELD''@|$(REPLACE_SCHED_YIELD)|g' \
2007 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2008 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2009 $(srcdir)/sched.in.h > $@-t
2010 $(AM_V_at)mv $@-t $@
2011MOSTLYCLEANFILES += sched.h sched.h-t
2012
2013EXTRA_DIST += sched.in.h
2014
2015## end gnulib module sched-h
2016
1518## begin gnulib module setenv 2017## begin gnulib module setenv
1519 2018
1520if GL_COND_OBJ_SETENV 2019if GL_COND_OBJ_SETENV
@@ -1534,6 +2033,14 @@ EXTRA_DIST += setlocale_null.h windows-initguard.h
1534 2033
1535## end gnulib module setlocale-null 2034## end gnulib module setlocale-null
1536 2035
2036## begin gnulib module setlocale-null-unlocked
2037
2038libgnu_a_SOURCES += setlocale_null-unlocked.c
2039
2040EXTRA_DIST += setlocale_null.h
2041
2042## end gnulib module setlocale-null-unlocked
2043
1537## begin gnulib module size_max 2044## begin gnulib module size_max
1538 2045
1539libgnu_a_SOURCES += size_max.h 2046libgnu_a_SOURCES += size_max.h
@@ -1625,27 +2132,7 @@ EXTRA_DIST += stat-time.h
1625 2132
1626## end gnulib module stat-time 2133## end gnulib module stat-time
1627 2134
1628## begin gnulib module stdalign 2135## begin gnulib module stdckdint-h
1629
1630BUILT_SOURCES += $(STDALIGN_H)
1631
1632# We need the following in order to create <stdalign.h> when the system
1633# doesn't have one that works.
1634if GL_GENERATE_STDALIGN_H
1635stdalign.h: stdalign.in.h $(top_builddir)/config.status
1636 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/stdalign.in.h
1637 $(AM_V_at)mv $@-t $@
1638else
1639stdalign.h: $(top_builddir)/config.status
1640 rm -f $@
1641endif
1642MOSTLYCLEANFILES += stdalign.h stdalign.h-t
1643
1644EXTRA_DIST += stdalign.in.h
1645
1646## end gnulib module stdalign
1647
1648## begin gnulib module stdckdint
1649 2136
1650BUILT_SOURCES += $(STDCKDINT_H) 2137BUILT_SOURCES += $(STDCKDINT_H)
1651 2138
@@ -1654,6 +2141,15 @@ BUILT_SOURCES += $(STDCKDINT_H)
1654if GL_GENERATE_STDCKDINT_H 2141if GL_GENERATE_STDCKDINT_H
1655stdckdint.h: stdckdint.in.h $(top_builddir)/config.status 2142stdckdint.h: stdckdint.in.h $(top_builddir)/config.status
1656 $(gl_V_at)$(SED_HEADER_STDOUT) \ 2143 $(gl_V_at)$(SED_HEADER_STDOUT) \
2144 -e 's|@''GUARD_PREFIX''@|GL|g' \
2145 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2146 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2147 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2148 -e 's|@''NEXT_STDCKDINT_H''@|$(NEXT_STDCKDINT_H)|g' \
2149 -e 's|@''HAVE_C_STDCKDINT_H''@|$(HAVE_C_STDCKDINT_H)|g' \
2150 -e 's|@''HAVE_WORKING_C_STDCKDINT_H''@|$(HAVE_WORKING_C_STDCKDINT_H)|g' \
2151 -e 's|@''HAVE_CXX_STDCKDINT_H''@|$(HAVE_CXX_STDCKDINT_H)|g' \
2152 -e 's|@''HAVE_WORKING_CXX_STDCKDINT_H''@|$(HAVE_WORKING_CXX_STDCKDINT_H)|g' \
1657 $(srcdir)/stdckdint.in.h > $@-t 2153 $(srcdir)/stdckdint.in.h > $@-t
1658 $(AM_V_at)mv $@-t $@ 2154 $(AM_V_at)mv $@-t $@
1659else 2155else
@@ -1664,9 +2160,9 @@ MOSTLYCLEANFILES += stdckdint.h stdckdint.h-t
1664 2160
1665EXTRA_DIST += intprops-internal.h stdckdint.in.h 2161EXTRA_DIST += intprops-internal.h stdckdint.in.h
1666 2162
1667## end gnulib module stdckdint 2163## end gnulib module stdckdint-h
1668 2164
1669## begin gnulib module stddef 2165## begin gnulib module stddef-h
1670 2166
1671BUILT_SOURCES += $(STDDEF_H) 2167BUILT_SOURCES += $(STDDEF_H)
1672 2168
@@ -1680,9 +2176,11 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
1680 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2176 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1681 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2177 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1682 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ 2178 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
1683 -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \ 2179 -e 's|@''NULLPTR_T_NEEDS_STDDEF''@|$(NULLPTR_T_NEEDS_STDDEF)|g' \
1684 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ 2180 -e 's|@''STDDEF_NOT_IDEMPOTENT''@|$(STDDEF_NOT_IDEMPOTENT)|g' \
1685 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ 2181 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
2182 -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
2183 -e 's|@''HAVE_C_UNREACHABLE''@|$(HAVE_C_UNREACHABLE)|g' \
1686 $(srcdir)/stddef.in.h > $@-t 2184 $(srcdir)/stddef.in.h > $@-t
1687 $(AM_V_at)mv $@-t $@ 2185 $(AM_V_at)mv $@-t $@
1688else 2186else
@@ -1693,9 +2191,9 @@ MOSTLYCLEANFILES += stddef.h stddef.h-t
1693 2191
1694EXTRA_DIST += stddef.in.h 2192EXTRA_DIST += stddef.in.h
1695 2193
1696## end gnulib module stddef 2194## end gnulib module stddef-h
1697 2195
1698## begin gnulib module stdint 2196## begin gnulib module stdint-h
1699 2197
1700BUILT_SOURCES += $(STDINT_H) 2198BUILT_SOURCES += $(STDINT_H)
1701 2199
@@ -1741,9 +2239,9 @@ MOSTLYCLEANFILES += stdint.h stdint.h-t
1741 2239
1742EXTRA_DIST += stdint.in.h 2240EXTRA_DIST += stdint.in.h
1743 2241
1744## end gnulib module stdint 2242## end gnulib module stdint-h
1745 2243
1746## begin gnulib module stdio 2244## begin gnulib module stdio-h
1747 2245
1748BUILT_SOURCES += stdio.h 2246BUILT_SOURCES += stdio.h
1749 2247
@@ -1757,6 +2255,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1757 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2255 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1758 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ 2256 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
1759 -e 's/@''GNULIB_DPRINTF''@/$(GL_GNULIB_DPRINTF)/g' \ 2257 -e 's/@''GNULIB_DPRINTF''@/$(GL_GNULIB_DPRINTF)/g' \
2258 -e 's/@''GNULIB_DZPRINTF''@/$(GL_GNULIB_DZPRINTF)/g' \
1760 -e 's/@''GNULIB_FCLOSE''@/$(GL_GNULIB_FCLOSE)/g' \ 2259 -e 's/@''GNULIB_FCLOSE''@/$(GL_GNULIB_FCLOSE)/g' \
1761 -e 's/@''GNULIB_FDOPEN''@/$(GL_GNULIB_FDOPEN)/g' \ 2260 -e 's/@''GNULIB_FDOPEN''@/$(GL_GNULIB_FDOPEN)/g' \
1762 -e 's/@''GNULIB_FFLUSH''@/$(GL_GNULIB_FFLUSH)/g' \ 2261 -e 's/@''GNULIB_FFLUSH''@/$(GL_GNULIB_FFLUSH)/g' \
@@ -1777,12 +2276,14 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1777 -e 's/@''GNULIB_FTELL''@/$(GL_GNULIB_FTELL)/g' \ 2276 -e 's/@''GNULIB_FTELL''@/$(GL_GNULIB_FTELL)/g' \
1778 -e 's/@''GNULIB_FTELLO''@/$(GL_GNULIB_FTELLO)/g' \ 2277 -e 's/@''GNULIB_FTELLO''@/$(GL_GNULIB_FTELLO)/g' \
1779 -e 's/@''GNULIB_FWRITE''@/$(GL_GNULIB_FWRITE)/g' \ 2278 -e 's/@''GNULIB_FWRITE''@/$(GL_GNULIB_FWRITE)/g' \
2279 -e 's/@''GNULIB_FZPRINTF''@/$(GL_GNULIB_FZPRINTF)/g' \
1780 -e 's/@''GNULIB_GETC''@/$(GL_GNULIB_GETC)/g' \ 2280 -e 's/@''GNULIB_GETC''@/$(GL_GNULIB_GETC)/g' \
1781 -e 's/@''GNULIB_GETCHAR''@/$(GL_GNULIB_GETCHAR)/g' \ 2281 -e 's/@''GNULIB_GETCHAR''@/$(GL_GNULIB_GETCHAR)/g' \
1782 -e 's/@''GNULIB_GETDELIM''@/$(GL_GNULIB_GETDELIM)/g' \ 2282 -e 's/@''GNULIB_GETDELIM''@/$(GL_GNULIB_GETDELIM)/g' \
1783 -e 's/@''GNULIB_GETLINE''@/$(GL_GNULIB_GETLINE)/g' \ 2283 -e 's/@''GNULIB_GETLINE''@/$(GL_GNULIB_GETLINE)/g' \
1784 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GL_GNULIB_OBSTACK_PRINTF)/g' \ 2284 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GL_GNULIB_OBSTACK_PRINTF)/g' \
1785 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GL_GNULIB_OBSTACK_PRINTF_POSIX)/g' \ 2285 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GL_GNULIB_OBSTACK_PRINTF_POSIX)/g' \
2286 -e 's/@''GNULIB_OBSTACK_ZPRINTF''@/$(GL_GNULIB_OBSTACK_ZPRINTF)/g' \
1786 -e 's/@''GNULIB_PCLOSE''@/$(GL_GNULIB_PCLOSE)/g' \ 2287 -e 's/@''GNULIB_PCLOSE''@/$(GL_GNULIB_PCLOSE)/g' \
1787 -e 's/@''GNULIB_PERROR''@/$(GL_GNULIB_PERROR)/g' \ 2288 -e 's/@''GNULIB_PERROR''@/$(GL_GNULIB_PERROR)/g' \
1788 -e 's/@''GNULIB_POPEN''@/$(GL_GNULIB_POPEN)/g' \ 2289 -e 's/@''GNULIB_POPEN''@/$(GL_GNULIB_POPEN)/g' \
@@ -1796,34 +2297,46 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1796 -e 's/@''GNULIB_RENAMEAT''@/$(GL_GNULIB_RENAMEAT)/g' \ 2297 -e 's/@''GNULIB_RENAMEAT''@/$(GL_GNULIB_RENAMEAT)/g' \
1797 -e 's/@''GNULIB_SCANF''@/$(GL_GNULIB_SCANF)/g' \ 2298 -e 's/@''GNULIB_SCANF''@/$(GL_GNULIB_SCANF)/g' \
1798 -e 's/@''GNULIB_SNPRINTF''@/$(GL_GNULIB_SNPRINTF)/g' \ 2299 -e 's/@''GNULIB_SNPRINTF''@/$(GL_GNULIB_SNPRINTF)/g' \
2300 -e 's/@''GNULIB_SNZPRINTF''@/$(GL_GNULIB_SNZPRINTF)/g' \
1799 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GL_GNULIB_SPRINTF_POSIX)/g' \ 2301 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GL_GNULIB_SPRINTF_POSIX)/g' \
1800 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GL_GNULIB_STDIO_H_NONBLOCKING)/g' \ 2302 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GL_GNULIB_STDIO_H_NONBLOCKING)/g' \
1801 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GL_GNULIB_STDIO_H_SIGPIPE)/g' \ 2303 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GL_GNULIB_STDIO_H_SIGPIPE)/g' \
2304 -e 's/@''GNULIB_SZPRINTF''@/$(GL_GNULIB_SZPRINTF)/g' \
1802 -e 's/@''GNULIB_TMPFILE''@/$(GL_GNULIB_TMPFILE)/g' \ 2305 -e 's/@''GNULIB_TMPFILE''@/$(GL_GNULIB_TMPFILE)/g' \
1803 -e 's/@''GNULIB_VASPRINTF''@/$(GL_GNULIB_VASPRINTF)/g' \ 2306 -e 's/@''GNULIB_VASPRINTF''@/$(GL_GNULIB_VASPRINTF)/g' \
2307 -e 's/@''GNULIB_VASZPRINTF''@/$(GL_GNULIB_VASZPRINTF)/g' \
1804 -e 's/@''GNULIB_VDPRINTF''@/$(GL_GNULIB_VDPRINTF)/g' \ 2308 -e 's/@''GNULIB_VDPRINTF''@/$(GL_GNULIB_VDPRINTF)/g' \
2309 -e 's/@''GNULIB_VDZPRINTF''@/$(GL_GNULIB_VDZPRINTF)/g' \
1805 -e 's/@''GNULIB_VFPRINTF''@/$(GL_GNULIB_VFPRINTF)/g' \ 2310 -e 's/@''GNULIB_VFPRINTF''@/$(GL_GNULIB_VFPRINTF)/g' \
1806 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GL_GNULIB_VFPRINTF_POSIX)/g' \ 2311 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GL_GNULIB_VFPRINTF_POSIX)/g' \
2312 -e 's/@''GNULIB_VFZPRINTF''@/$(GL_GNULIB_VFZPRINTF)/g' \
1807 -e 's/@''GNULIB_VFSCANF''@/$(GL_GNULIB_VFSCANF)/g' \ 2313 -e 's/@''GNULIB_VFSCANF''@/$(GL_GNULIB_VFSCANF)/g' \
1808 -e 's/@''GNULIB_VSCANF''@/$(GL_GNULIB_VSCANF)/g' \ 2314 -e 's/@''GNULIB_VSCANF''@/$(GL_GNULIB_VSCANF)/g' \
1809 -e 's/@''GNULIB_VPRINTF''@/$(GL_GNULIB_VPRINTF)/g' \ 2315 -e 's/@''GNULIB_VPRINTF''@/$(GL_GNULIB_VPRINTF)/g' \
1810 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GL_GNULIB_VPRINTF_POSIX)/g' \ 2316 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GL_GNULIB_VPRINTF_POSIX)/g' \
1811 -e 's/@''GNULIB_VSNPRINTF''@/$(GL_GNULIB_VSNPRINTF)/g' \ 2317 -e 's/@''GNULIB_VSNPRINTF''@/$(GL_GNULIB_VSNPRINTF)/g' \
2318 -e 's/@''GNULIB_VSNZPRINTF''@/$(GL_GNULIB_VSNZPRINTF)/g' \
1812 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GL_GNULIB_VSPRINTF_POSIX)/g' \ 2319 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GL_GNULIB_VSPRINTF_POSIX)/g' \
2320 -e 's/@''GNULIB_VSZPRINTF''@/$(GL_GNULIB_VSZPRINTF)/g' \
2321 -e 's/@''GNULIB_VZPRINTF''@/$(GL_GNULIB_VZPRINTF)/g' \
2322 -e 's/@''GNULIB_ZPRINTF''@/$(GL_GNULIB_ZPRINTF)/g' \
1813 -e 's/@''GNULIB_MDA_FCLOSEALL''@/$(GL_GNULIB_MDA_FCLOSEALL)/g' \ 2323 -e 's/@''GNULIB_MDA_FCLOSEALL''@/$(GL_GNULIB_MDA_FCLOSEALL)/g' \
1814 -e 's/@''GNULIB_MDA_FDOPEN''@/$(GL_GNULIB_MDA_FDOPEN)/g' \ 2324 -e 's/@''GNULIB_MDA_FDOPEN''@/$(GL_GNULIB_MDA_FDOPEN)/g' \
1815 -e 's/@''GNULIB_MDA_FILENO''@/$(GL_GNULIB_MDA_FILENO)/g' \ 2325 -e 's/@''GNULIB_MDA_FILENO''@/$(GL_GNULIB_MDA_FILENO)/g' \
1816 -e 's/@''GNULIB_MDA_GETW''@/$(GL_GNULIB_MDA_GETW)/g' \ 2326 -e 's/@''GNULIB_MDA_GETW''@/$(GL_GNULIB_MDA_GETW)/g' \
1817 -e 's/@''GNULIB_MDA_PUTW''@/$(GL_GNULIB_MDA_PUTW)/g' \ 2327 -e 's/@''GNULIB_MDA_PUTW''@/$(GL_GNULIB_MDA_PUTW)/g' \
1818 -e 's/@''GNULIB_MDA_TEMPNAM''@/$(GL_GNULIB_MDA_TEMPNAM)/g' \ 2328 -e 's/@''GNULIB_MDA_TEMPNAM''@/$(GL_GNULIB_MDA_TEMPNAM)/g' \
1819 < $(srcdir)/stdio.in.h | \ 2329 < $(srcdir)/stdio.in.h > $@-t1
1820 sed -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \ 2330 $(AM_V_at)sed \
2331 -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \
1821 -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ 2332 -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
1822 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ 2333 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
1823 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ 2334 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
1824 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ 2335 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
1825 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ 2336 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
2337 -e 's|@''HAVE_DECL_GETW''@|$(HAVE_DECL_GETW)|g' \
1826 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ 2338 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
2339 -e 's|@''HAVE_DECL_PUTW''@|$(HAVE_DECL_PUTW)|g' \
1827 -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ 2340 -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
1828 -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ 2341 -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
1829 -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ 2342 -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
@@ -1834,6 +2347,8 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1834 -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ 2347 -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
1835 -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ 2348 -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
1836 -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ 2349 -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
2350 < $@-t1 > $@-t2
2351 $(AM_V_at)sed \
1837 -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ 2352 -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
1838 -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ 2353 -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
1839 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ 2354 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
@@ -1871,9 +2386,10 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1871 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2386 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1872 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2387 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1873 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2388 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1874 > $@-t 2389 < $@-t2 > $@-t3
1875 $(AM_V_at)mv $@-t $@ 2390 $(AM_V_at)rm -f $@-t1 $@-t2
1876MOSTLYCLEANFILES += stdio.h stdio.h-t 2391 $(AM_V_at)mv $@-t3 $@
2392MOSTLYCLEANFILES += stdio.h stdio.h-t1 stdio.h-t2 stdio.h-t3
1877 2393
1878if GL_COND_OBJ_STDIO_READ 2394if GL_COND_OBJ_STDIO_READ
1879libgnu_a_SOURCES += stdio-read.c 2395libgnu_a_SOURCES += stdio-read.c
@@ -1884,14 +2400,21 @@ endif
1884 2400
1885EXTRA_DIST += stdio.in.h 2401EXTRA_DIST += stdio.in.h
1886 2402
1887## end gnulib module stdio 2403## end gnulib module stdio-h
2404
2405## begin gnulib module stdio-windows
2406
2407if GL_COND_OBJ_STDIO_CONSOLESAFE
2408libgnu_a_SOURCES += stdio-consolesafe.c
2409endif
2410
2411## end gnulib module stdio-windows
1888 2412
1889## begin gnulib module stdlib 2413## begin gnulib module stdlib-h
1890 2414
1891BUILT_SOURCES += stdlib.h 2415BUILT_SOURCES += stdlib.h
2416libgnu_a_SOURCES += stdlib.c
1892 2417
1893# We need the following in order to create <stdlib.h> when the system
1894# doesn't have one that works with the given compiler.
1895stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ 2418stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1896 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2419 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1897 $(gl_V_at)$(SED_HEADER_STDOUT) \ 2420 $(gl_V_at)$(SED_HEADER_STDOUT) \
@@ -1901,6 +2424,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1901 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2424 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1902 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ 2425 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
1903 -e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \ 2426 -e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \
2427 -e 's/@''GNULIB_ABORT_DEBUG''@/$(GL_GNULIB_ABORT_DEBUG)/g' \
1904 -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \ 2428 -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \
1905 -e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \ 2429 -e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \
1906 -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \ 2430 -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \
@@ -1908,10 +2432,12 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1908 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \ 2432 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \
1909 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ 2433 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
1910 -e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \ 2434 -e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \
2435 -e 's/@''GNULIB_GETPROGNAME''@/$(GL_GNULIB_GETPROGNAME)/g' \
1911 -e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \ 2436 -e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \
1912 -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \ 2437 -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \
1913 -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \ 2438 -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \
1914 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \ 2439 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \
2440 -e 's/@''GNULIB_MBSTOWCS''@/$(GL_GNULIB_MBSTOWCS)/g' \
1915 -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \ 2441 -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \
1916 -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \ 2442 -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \
1917 -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \ 2443 -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \
@@ -1924,16 +2450,18 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1924 -e 's/@''GNULIB_PTSNAME_R''@/$(GL_GNULIB_PTSNAME_R)/g' \ 2450 -e 's/@''GNULIB_PTSNAME_R''@/$(GL_GNULIB_PTSNAME_R)/g' \
1925 -e 's/@''GNULIB_PUTENV''@/$(GL_GNULIB_PUTENV)/g' \ 2451 -e 's/@''GNULIB_PUTENV''@/$(GL_GNULIB_PUTENV)/g' \
1926 -e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \ 2452 -e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \
2453 -e 's/@''GNULIB_RAND''@/$(GL_GNULIB_RAND)/g' \
1927 -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \ 2454 -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \
1928 -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \ 2455 -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \
1929 -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \
1930 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \ 2456 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \
1931 -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \ 2457 -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \
1932 -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \ 2458 -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \
1933 -e 's/@''GNULIB_RPMATCH''@/$(GL_GNULIB_RPMATCH)/g' \ 2459 -e 's/@''GNULIB_RPMATCH''@/$(GL_GNULIB_RPMATCH)/g' \
1934 -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \ 2460 -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \
1935 -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \ 2461 -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \
2462 -e 's/@''GNULIB_STACK_TRACE''@/$(GL_GNULIB_STACK_TRACE)/g' \
1936 -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \ 2463 -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \
2464 -e 's/@''GNULIB_STRTOF''@/$(GL_GNULIB_STRTOF)/g' \
1937 -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \ 2465 -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \
1938 -e 's/@''GNULIB_STRTOLD''@/$(GL_GNULIB_STRTOLD)/g' \ 2466 -e 's/@''GNULIB_STRTOLD''@/$(GL_GNULIB_STRTOLD)/g' \
1939 -e 's/@''GNULIB_STRTOLL''@/$(GL_GNULIB_STRTOLL)/g' \ 2467 -e 's/@''GNULIB_STRTOLL''@/$(GL_GNULIB_STRTOLL)/g' \
@@ -1948,8 +2476,9 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1948 -e 's/@''GNULIB_MDA_GCVT''@/$(GL_GNULIB_MDA_GCVT)/g' \ 2476 -e 's/@''GNULIB_MDA_GCVT''@/$(GL_GNULIB_MDA_GCVT)/g' \
1949 -e 's/@''GNULIB_MDA_MKTEMP''@/$(GL_GNULIB_MDA_MKTEMP)/g' \ 2477 -e 's/@''GNULIB_MDA_MKTEMP''@/$(GL_GNULIB_MDA_MKTEMP)/g' \
1950 -e 's/@''GNULIB_MDA_PUTENV''@/$(GL_GNULIB_MDA_PUTENV)/g' \ 2478 -e 's/@''GNULIB_MDA_PUTENV''@/$(GL_GNULIB_MDA_PUTENV)/g' \
1951 < $(srcdir)/stdlib.in.h | \ 2479 < $(srcdir)/stdlib.in.h > $@-t1
1952 sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ 2480 $(AM_V_at)sed \
2481 -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
1953 -e 's|@''HAVE_ALIGNED_ALLOC''@|$(HAVE_ALIGNED_ALLOC)|g' \ 2482 -e 's|@''HAVE_ALIGNED_ALLOC''@|$(HAVE_ALIGNED_ALLOC)|g' \
1954 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ 2483 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
1955 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ 2484 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
@@ -1957,6 +2486,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1957 -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \ 2486 -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \
1958 -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \ 2487 -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \
1959 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ 2488 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
2489 -e 's|@''HAVE_DECL_PROGRAM_INVOCATION_NAME''@|$(HAVE_DECL_PROGRAM_INVOCATION_NAME)|g' \
2490 -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \
1960 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ 2491 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
1961 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ 2492 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
1962 -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \ 2493 -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \
@@ -1973,7 +2504,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1973 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ 2504 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
1974 -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \ 2505 -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
1975 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ 2506 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
1976 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
1977 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ 2507 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
1978 -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \ 2508 -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
1979 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ 2509 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
@@ -1983,6 +2513,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1983 -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \ 2513 -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \
1984 -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \ 2514 -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
1985 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ 2515 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
2516 -e 's|@''HAVE_STRTOF''@|$(HAVE_STRTOF)|g' \
1986 -e 's|@''HAVE_STRTOL''@|$(HAVE_STRTOL)|g' \ 2517 -e 's|@''HAVE_STRTOL''@|$(HAVE_STRTOL)|g' \
1987 -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \ 2518 -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \
1988 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ 2519 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
@@ -1990,32 +2521,46 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1990 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ 2521 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
1991 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ 2522 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
1992 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ 2523 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
2524 -e 's|@''HAVE_SYS_PROCESS_H''@|$(HAVE_SYS_PROCESS_H)|g' \
1993 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ 2525 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
1994 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ 2526 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
2527 < $@-t1 > $@-t2
2528 $(AM_V_at)sed \
2529 -e 's|@''REPLACE__EXIT''@|$(REPLACE__EXIT)|g' \
2530 -e 's|@''REPLACE_ABORT''@|$(REPLACE_ABORT)|g' \
1995 -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \ 2531 -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
1996 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \ 2532 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
1997 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \ 2533 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
1998 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ 2534 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
1999 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ 2535 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2536 -e 's|@''REPLACE_GETLOADAVG''@|$(REPLACE_GETLOADAVG)|g' \
2537 -e 's|@''REPLACE_GETPROGNAME''@|$(REPLACE_GETPROGNAME)|g' \
2538 -e 's|@''REPLACE_GETSUBOPT''@|$(REPLACE_GETSUBOPT)|g' \
2000 -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \ 2539 -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
2001 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \ 2540 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
2002 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \ 2541 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
2542 -e 's|@''REPLACE_MB_CUR_MAX''@|$(REPLACE_MB_CUR_MAX)|g' \
2543 -e 's|@''REPLACE_MBSTOWCS''@|$(REPLACE_MBSTOWCS)|g' \
2003 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ 2544 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
2545 -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \
2546 -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \
2004 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ 2547 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
2005 -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \ 2548 -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
2549 -e 's|@''REPLACE_POSIX_OPENPT''@|$(REPLACE_POSIX_OPENPT)|g' \
2006 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ 2550 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
2007 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ 2551 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
2008 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ 2552 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
2009 -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \ 2553 -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
2554 -e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \
2010 -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \ 2555 -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
2011 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ 2556 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
2012 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
2013 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \ 2557 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
2014 -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \ 2558 -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
2015 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ 2559 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
2016 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ 2560 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
2017 -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \ 2561 -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \
2018 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ 2562 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
2563 -e 's|@''REPLACE_STRTOF''@|$(REPLACE_STRTOF)|g' \
2019 -e 's|@''REPLACE_STRTOL''@|$(REPLACE_STRTOL)|g' \ 2564 -e 's|@''REPLACE_STRTOL''@|$(REPLACE_STRTOL)|g' \
2020 -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \ 2565 -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \
2021 -e 's|@''REPLACE_STRTOLL''@|$(REPLACE_STRTOLL)|g' \ 2566 -e 's|@''REPLACE_STRTOLL''@|$(REPLACE_STRTOLL)|g' \
@@ -2023,28 +2568,27 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
2023 -e 's|@''REPLACE_STRTOULL''@|$(REPLACE_STRTOULL)|g' \ 2568 -e 's|@''REPLACE_STRTOULL''@|$(REPLACE_STRTOULL)|g' \
2024 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ 2569 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
2025 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ 2570 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
2571 -e 's|@''CAN_PRINT_STACK_TRACE''@|$(CAN_PRINT_STACK_TRACE)|g' \
2026 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2572 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2027 -e '/definition of _Noreturn/r $(_NORETURN_H)' \ 2573 -e '/definition of _Noreturn/r $(_NORETURN_H)' \
2028 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2574 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2029 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2575 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2030 > $@-t 2576 < $@-t2 > $@-t3
2031 $(AM_V_at)mv $@-t $@ 2577 $(AM_V_at)rm -f $@-t1 $@-t2
2032MOSTLYCLEANFILES += stdlib.h stdlib.h-t 2578 $(AM_V_at)mv $@-t3 $@
2579MOSTLYCLEANFILES += stdlib.h stdlib.h-t1 stdlib.h-t2 stdlib.h-t3
2033 2580
2034EXTRA_DIST += stdlib.in.h 2581EXTRA_DIST += stdlib.in.h
2035 2582
2036## end gnulib module stdlib 2583## end gnulib module stdlib-h
2037 2584
2038## begin gnulib module strcase 2585## begin gnulib module strcasecmp
2039 2586
2040if GL_COND_OBJ_STRCASECMP 2587if GL_COND_OBJ_STRCASECMP
2041libgnu_a_SOURCES += strcasecmp.c 2588libgnu_a_SOURCES += strcasecmp.c
2042endif 2589endif
2043if GL_COND_OBJ_STRNCASECMP
2044libgnu_a_SOURCES += strncasecmp.c
2045endif
2046 2590
2047## end gnulib module strcase 2591## end gnulib module strcasecmp
2048 2592
2049## begin gnulib module strcasestr 2593## begin gnulib module strcasestr
2050 2594
@@ -2089,7 +2633,7 @@ EXTRA_DIST += strerror-override.h
2089 2633
2090## end gnulib module strerror-override 2634## end gnulib module strerror-override
2091 2635
2092## begin gnulib module string 2636## begin gnulib module string-h
2093 2637
2094BUILT_SOURCES += string.h 2638BUILT_SOURCES += string.h
2095 2639
@@ -2119,6 +2663,8 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2119 -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \ 2663 -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \
2120 -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \ 2664 -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \
2121 -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \ 2665 -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \
2666 -e 's/@''GNULIB_MBS_ENDSWITH''@/$(GL_GNULIB_MBS_ENDSWITH)/g' \
2667 -e 's/@''GNULIB_MBS_STARTSWITH''@/$(GL_GNULIB_MBS_STARTSWITH)/g' \
2122 -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \ 2668 -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \
2123 -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \ 2669 -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \
2124 -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \ 2670 -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \
@@ -2129,7 +2675,9 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2129 -e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \ 2675 -e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \
2130 -e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \ 2676 -e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \
2131 -e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \ 2677 -e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \
2678 -e 's/@''GNULIB_STRINGEQ''@/$(GL_GNULIB_STRINGEQ)/g' \
2132 -e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \ 2679 -e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \
2680 -e 's/@''GNULIB_STRNCPY''@/$(GL_GNULIB_STRNCPY)/g' \
2133 -e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \ 2681 -e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \
2134 -e 's/@''GNULIB_STRNLEN''@/$(GL_GNULIB_STRNLEN)/g' \ 2682 -e 's/@''GNULIB_STRNLEN''@/$(GL_GNULIB_STRNLEN)/g' \
2135 -e 's/@''GNULIB_STRPBRK''@/$(GL_GNULIB_STRPBRK)/g' \ 2683 -e 's/@''GNULIB_STRPBRK''@/$(GL_GNULIB_STRPBRK)/g' \
@@ -2137,8 +2685,11 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2137 -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \ 2685 -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \
2138 -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \ 2686 -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \
2139 -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \ 2687 -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \
2688 -e 's/@''GNULIB_STR_ENDSWITH''@/$(GL_GNULIB_STR_ENDSWITH)/g' \
2689 -e 's/@''GNULIB_STR_STARTSWITH''@/$(GL_GNULIB_STR_STARTSWITH)/g' \
2140 -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \ 2690 -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \
2141 -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \ 2691 -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \
2692 -e 's/@''GNULIB_STRERROR_L''@/$(GL_GNULIB_STRERROR_L)/g' \
2142 -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \ 2693 -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \
2143 -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \ 2694 -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \
2144 -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \ 2695 -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \
@@ -2147,11 +2698,13 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2147 -e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \ 2698 -e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \
2148 -e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \ 2699 -e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \
2149 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ 2700 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
2150 < $(srcdir)/string.in.h | \ 2701 < $(srcdir)/string.in.h > $@-t1
2151 sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \ 2702 $(AM_V_at)sed \
2703 -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
2152 -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ 2704 -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
2153 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ 2705 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
2154 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ 2706 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
2707 -e 's|@''HAVE_DECL_MEMEQ''@|$(HAVE_DECL_MEMEQ)|g' \
2155 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ 2708 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
2156 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ 2709 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
2157 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ 2710 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
@@ -2161,6 +2714,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2161 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ 2714 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
2162 -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ 2715 -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
2163 -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ 2716 -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
2717 -e 's|@''HAVE_DECL_STREQ''@|$(HAVE_DECL_STREQ)|g' \
2164 -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ 2718 -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
2165 -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ 2719 -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
2166 -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ 2720 -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
@@ -2168,6 +2722,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2168 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ 2722 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
2169 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ 2723 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
2170 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ 2724 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
2725 -e 's|@''HAVE_STRERROR_L''@|$(HAVE_STRERROR_L)|g' \
2171 -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \ 2726 -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \
2172 -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \ 2727 -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \
2173 -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \ 2728 -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \
@@ -2176,11 +2731,15 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2176 -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \ 2731 -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
2177 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ 2732 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
2178 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ 2733 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
2734 -e 's|@''REPLACE_MEMPCPY''@|$(REPLACE_MEMPCPY)|g' \
2735 -e 's|@''REPLACE_MEMSET_EXPLICIT''@|$(REPLACE_MEMSET_EXPLICIT)|g' \
2179 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ 2736 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2737 -e 's|@''REPLACE_STPCPY''@|$(REPLACE_STPCPY)|g' \
2180 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ 2738 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
2181 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ 2739 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
2182 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ 2740 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
2183 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ 2741 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
2742 -e 's|@''REPLACE_STRNCPY''@|$(REPLACE_STRNCPY)|g' \
2184 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ 2743 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
2185 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ 2744 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
2186 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ 2745 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
@@ -2188,21 +2747,30 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2188 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ 2747 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
2189 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ 2748 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
2190 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ 2749 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
2750 -e 's|@''REPLACE_STRERROR_L''@|$(REPLACE_STRERROR_L)|g' \
2191 -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \ 2751 -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \
2192 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ 2752 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
2753 -e 's|@''REPLACE_STRVERSCMP''@|$(REPLACE_STRVERSCMP)|g' \
2193 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ 2754 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
2194 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2755 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2195 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2756 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2196 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2757 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2197 > $@-t 2758 < $@-t1 > $@-t2
2198 $(AM_V_at)mv $@-t $@ 2759 $(AM_V_at)rm -f $@-t1
2199MOSTLYCLEANFILES += string.h string.h-t 2760 $(AM_V_at)mv $@-t2 $@
2761MOSTLYCLEANFILES += string.h string.h-t1 string.h-t2
2200 2762
2201EXTRA_DIST += string.in.h 2763EXTRA_DIST += string.in.h
2202 2764
2203## end gnulib module string 2765## end gnulib module string-h
2204 2766
2205## begin gnulib module strings 2767## begin gnulib module stringeq
2768
2769libgnu_a_SOURCES += string.c
2770
2771## end gnulib module stringeq
2772
2773## begin gnulib module strings-h
2206 2774
2207BUILT_SOURCES += strings.h 2775BUILT_SOURCES += strings.h
2208 2776
@@ -2217,9 +2785,20 @@ strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE
2217 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2785 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2218 -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ 2786 -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
2219 -e 's/@''GNULIB_FFS''@/$(GL_GNULIB_FFS)/g' \ 2787 -e 's/@''GNULIB_FFS''@/$(GL_GNULIB_FFS)/g' \
2788 -e 's/@''GNULIB_STRCASECMP''@/$(GL_GNULIB_STRCASECMP)/g' \
2789 -e 's/@''GNULIB_STRCASECMP_L''@/$(GL_GNULIB_STRCASECMP_L)/g' \
2790 -e 's/@''GNULIB_STRNCASECMP''@/$(GL_GNULIB_STRNCASECMP)/g' \
2791 -e 's/@''GNULIB_STRNCASECMP_L''@/$(GL_GNULIB_STRNCASECMP_L)/g' \
2220 -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \ 2792 -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
2221 -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ 2793 -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
2794 -e 's|@''HAVE_STRCASECMP_L''@|$(HAVE_STRCASECMP_L)|g' \
2795 -e 's|@''HAVE_STRNCASECMP''@|$(HAVE_STRNCASECMP)|g' \
2796 -e 's|@''HAVE_STRNCASECMP_L''@|$(HAVE_STRNCASECMP_L)|g' \
2222 -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ 2797 -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
2798 -e 's|@''REPLACE_STRCASECMP''@|$(REPLACE_STRCASECMP)|g' \
2799 -e 's|@''REPLACE_STRCASECMP_L''@|$(REPLACE_STRCASECMP_L)|g' \
2800 -e 's|@''REPLACE_STRNCASECMP''@|$(REPLACE_STRNCASECMP)|g' \
2801 -e 's|@''REPLACE_STRNCASECMP_L''@|$(REPLACE_STRNCASECMP_L)|g' \
2223 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2802 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2224 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2803 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2225 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2804 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@@ -2229,7 +2808,23 @@ MOSTLYCLEANFILES += strings.h strings.h-t
2229 2808
2230EXTRA_DIST += strings.in.h 2809EXTRA_DIST += strings.in.h
2231 2810
2232## end gnulib module strings 2811## end gnulib module strings-h
2812
2813## begin gnulib module strncasecmp
2814
2815if GL_COND_OBJ_STRNCASECMP
2816libgnu_a_SOURCES += strncasecmp.c
2817endif
2818
2819## end gnulib module strncasecmp
2820
2821## begin gnulib module strncpy
2822
2823if GL_COND_OBJ_STRNCPY
2824libgnu_a_SOURCES += strncpy.c
2825endif
2826
2827## end gnulib module strncpy
2233 2828
2234## begin gnulib module strsep 2829## begin gnulib module strsep
2235 2830
@@ -2248,7 +2843,7 @@ EXTRA_libgnu_a_SOURCES += strstr.c
2248 2843
2249## end gnulib module strstr-simple 2844## end gnulib module strstr-simple
2250 2845
2251## begin gnulib module sys_socket 2846## begin gnulib module sys_socket-h
2252 2847
2253BUILT_SOURCES += sys/socket.h 2848BUILT_SOURCES += sys/socket.h
2254libgnu_a_SOURCES += sys_socket.c 2849libgnu_a_SOURCES += sys_socket.c
@@ -2296,9 +2891,9 @@ MOSTLYCLEANDIRS += sys
2296 2891
2297EXTRA_DIST += sys_socket.in.h 2892EXTRA_DIST += sys_socket.in.h
2298 2893
2299## end gnulib module sys_socket 2894## end gnulib module sys_socket-h
2300 2895
2301## begin gnulib module sys_stat 2896## begin gnulib module sys_stat-h
2302 2897
2303BUILT_SOURCES += sys/stat.h 2898BUILT_SOURCES += sys/stat.h
2304 2899
@@ -2369,9 +2964,9 @@ MOSTLYCLEANDIRS += sys
2369 2964
2370EXTRA_DIST += sys_stat.in.h 2965EXTRA_DIST += sys_stat.in.h
2371 2966
2372## end gnulib module sys_stat 2967## end gnulib module sys_stat-h
2373 2968
2374## begin gnulib module sys_types 2969## begin gnulib module sys_types-h
2375 2970
2376BUILT_SOURCES += sys/types.h 2971BUILT_SOURCES += sys/types.h
2377 2972
@@ -2386,16 +2981,20 @@ sys/types.h: sys_types.in.h $(top_builddir)/config.status
2386 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2981 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2387 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ 2982 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
2388 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ 2983 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
2984 -e 's|@''HAVE_OFF64_T''@|$(HAVE_OFF64_T)|g' \
2389 -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \ 2985 -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
2986 -e 's|@''HAVE_BLKSIZE_T''@|$(HAVE_BLKSIZE_T)|g' \
2987 -e 's|@''HAVE_BLKCNT_T''@|$(HAVE_BLKCNT_T)|g' \
2390 $(srcdir)/sys_types.in.h > $@-t 2988 $(srcdir)/sys_types.in.h > $@-t
2391 $(AM_V_at)mv $@-t $@ 2989 $(AM_V_at)mv $@-t $@
2392MOSTLYCLEANFILES += sys/types.h sys/types.h-t 2990MOSTLYCLEANFILES += sys/types.h sys/types.h-t
2991MOSTLYCLEANDIRS += sys
2393 2992
2394EXTRA_DIST += sys_types.in.h 2993EXTRA_DIST += sys_types.in.h
2395 2994
2396## end gnulib module sys_types 2995## end gnulib module sys_types-h
2397 2996
2398## begin gnulib module sys_uio 2997## begin gnulib module sys_uio-h
2399 2998
2400BUILT_SOURCES += sys/uio.h 2999BUILT_SOURCES += sys/uio.h
2401 3000
@@ -2417,7 +3016,7 @@ MOSTLYCLEANDIRS += sys
2417 3016
2418EXTRA_DIST += sys_uio.in.h 3017EXTRA_DIST += sys_uio.in.h
2419 3018
2420## end gnulib module sys_uio 3019## end gnulib module sys_uio-h
2421 3020
2422## begin gnulib module threadlib 3021## begin gnulib module threadlib
2423 3022
@@ -2425,7 +3024,7 @@ libgnu_a_SOURCES += glthread/threadlib.c
2425 3024
2426## end gnulib module threadlib 3025## end gnulib module threadlib
2427 3026
2428## begin gnulib module time 3027## begin gnulib module time-h
2429 3028
2430BUILT_SOURCES += time.h 3029BUILT_SOURCES += time.h
2431 3030
@@ -2444,11 +3043,13 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
2444 -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \ 3043 -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \
2445 -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \ 3044 -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \
2446 -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \ 3045 -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \
3046 -e 's/@''GNULIB_TIME''@/$(GL_GNULIB_TIME)/g' \
2447 -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \ 3047 -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \
2448 -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \ 3048 -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \
2449 -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \ 3049 -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \
2450 -e 's/@''GNULIB_TIME_R''@/$(GL_GNULIB_TIME_R)/g' \ 3050 -e 's/@''GNULIB_TIME_R''@/$(GL_GNULIB_TIME_R)/g' \
2451 -e 's/@''GNULIB_TIME_RZ''@/$(GL_GNULIB_TIME_RZ)/g' \ 3051 -e 's/@''GNULIB_TIME_RZ''@/$(GL_GNULIB_TIME_RZ)/g' \
3052 -e 's/@''GNULIB_TZNAME''@/$(GL_GNULIB_TZNAME)/g' \
2452 -e 's/@''GNULIB_TZSET''@/$(GL_GNULIB_TZSET)/g' \ 3053 -e 's/@''GNULIB_TZSET''@/$(GL_GNULIB_TZSET)/g' \
2453 -e 's/@''GNULIB_MDA_TZSET''@/$(GL_GNULIB_MDA_TZSET)/g' \ 3054 -e 's/@''GNULIB_MDA_TZSET''@/$(GL_GNULIB_MDA_TZSET)/g' \
2454 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ 3055 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
@@ -2458,14 +3059,20 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
2458 -e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \ 3059 -e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \
2459 -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \ 3060 -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \
2460 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ 3061 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
3062 -e 's|@''HAVE_TZALLOC''@|$(HAVE_TZALLOC)|g' \
2461 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ 3063 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
2462 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ 3064 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
2463 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ 3065 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
2464 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ 3066 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
3067 -e 's|@''REPLACE_LOCALTIME_RZ''@|$(REPLACE_LOCALTIME_RZ)|g' \
2465 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ 3068 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
3069 -e 's|@''REPLACE_MKTIME_Z''@|$(REPLACE_MKTIME_Z)|g' \
2466 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ 3070 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
2467 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ 3071 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
3072 -e 's|@''REPLACE_TIME''@|$(REPLACE_TIME)|g' \
2468 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ 3073 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
3074 -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \
3075 -e 's|@''REPLACE_TIMESPEC_GETRES''@|$(REPLACE_TIMESPEC_GETRES)|g' \
2469 -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \ 3076 -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
2470 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ 3077 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
2471 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 3078 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
@@ -2481,7 +3088,7 @@ MOSTLYCLEANFILES += time.h time.h-t
2481 3088
2482EXTRA_DIST += time.in.h 3089EXTRA_DIST += time.in.h
2483 3090
2484## end gnulib module time 3091## end gnulib module time-h
2485 3092
2486## begin gnulib module time_r 3093## begin gnulib module time_r
2487 3094
@@ -2501,7 +3108,412 @@ EXTRA_DIST += mktime-internal.h
2501 3108
2502## end gnulib module timegm 3109## end gnulib module timegm
2503 3110
2504## begin gnulib module unistd 3111## begin gnulib module uchar-h
3112
3113BUILT_SOURCES += uchar.h
3114
3115uchar.h: uchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
3116 $(gl_V_at)$(SED_HEADER_STDOUT) \
3117 -e 's|@''GUARD_PREFIX''@|GL|g' \
3118 -e 's/@''HAVE_UCHAR_H''@/$(HAVE_UCHAR_H)/g' \
3119 -e 's/@''CXX_HAVE_UCHAR_H''@/$(CXX_HAVE_UCHAR_H)/g' \
3120 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
3121 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
3122 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
3123 -e 's|@''NEXT_UCHAR_H''@|$(NEXT_UCHAR_H)|g' \
3124 -e 's|@''CXX_HAS_CHAR8_TYPE''@|$(CXX_HAS_CHAR8_TYPE)|g' \
3125 -e 's|@''CXX_HAS_UCHAR_TYPES''@|$(CXX_HAS_UCHAR_TYPES)|g' \
3126 -e 's|@''SMALL_WCHAR_T''@|$(SMALL_WCHAR_T)|g' \
3127 -e 's|@''GNULIBHEADERS_OVERRIDE_CHAR8_T''@|$(GNULIBHEADERS_OVERRIDE_CHAR8_T)|g' \
3128 -e 's|@''GNULIBHEADERS_OVERRIDE_CHAR16_T''@|$(GNULIBHEADERS_OVERRIDE_CHAR16_T)|g' \
3129 -e 's|@''GNULIBHEADERS_OVERRIDE_CHAR32_T''@|$(GNULIBHEADERS_OVERRIDE_CHAR32_T)|g' \
3130 -e 's/@''GNULIB_BTOC32''@/$(GL_GNULIB_BTOC32)/g' \
3131 -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \
3132 -e 's/@''GNULIB_C32ISALNUM''@/$(GL_GNULIB_C32ISALNUM)/g' \
3133 -e 's/@''GNULIB_C32ISALPHA''@/$(GL_GNULIB_C32ISALPHA)/g' \
3134 -e 's/@''GNULIB_C32ISBLANK''@/$(GL_GNULIB_C32ISBLANK)/g' \
3135 -e 's/@''GNULIB_C32ISCNTRL''@/$(GL_GNULIB_C32ISCNTRL)/g' \
3136 -e 's/@''GNULIB_C32ISDIGIT''@/$(GL_GNULIB_C32ISDIGIT)/g' \
3137 -e 's/@''GNULIB_C32ISGRAPH''@/$(GL_GNULIB_C32ISGRAPH)/g' \
3138 -e 's/@''GNULIB_C32ISLOWER''@/$(GL_GNULIB_C32ISLOWER)/g' \
3139 -e 's/@''GNULIB_C32ISPRINT''@/$(GL_GNULIB_C32ISPRINT)/g' \
3140 -e 's/@''GNULIB_C32ISPUNCT''@/$(GL_GNULIB_C32ISPUNCT)/g' \
3141 -e 's/@''GNULIB_C32ISSPACE''@/$(GL_GNULIB_C32ISSPACE)/g' \
3142 -e 's/@''GNULIB_C32ISUPPER''@/$(GL_GNULIB_C32ISUPPER)/g' \
3143 -e 's/@''GNULIB_C32ISXDIGIT''@/$(GL_GNULIB_C32ISXDIGIT)/g' \
3144 -e 's/@''GNULIB_C32TOLOWER''@/$(GL_GNULIB_C32TOLOWER)/g' \
3145 -e 's/@''GNULIB_C32TOUPPER''@/$(GL_GNULIB_C32TOUPPER)/g' \
3146 -e 's/@''GNULIB_C32WIDTH''@/$(GL_GNULIB_C32WIDTH)/g' \
3147 -e 's/@''GNULIB_C32RTOMB''@/$(GL_GNULIB_C32RTOMB)/g' \
3148 -e 's/@''GNULIB_C32SNRTOMBS''@/$(GL_GNULIB_C32SNRTOMBS)/g' \
3149 -e 's/@''GNULIB_C32SRTOMBS''@/$(GL_GNULIB_C32SRTOMBS)/g' \
3150 -e 's/@''GNULIB_C32STOMBS''@/$(GL_GNULIB_C32STOMBS)/g' \
3151 -e 's/@''GNULIB_C32SWIDTH''@/$(GL_GNULIB_C32SWIDTH)/g' \
3152 -e 's/@''GNULIB_C32TOB''@/$(GL_GNULIB_C32TOB)/g' \
3153 -e 's/@''GNULIB_C32_APPLY_MAPPING''@/$(GL_GNULIB_C32_APPLY_MAPPING)/g' \
3154 -e 's/@''GNULIB_C32_APPLY_TYPE_TEST''@/$(GL_GNULIB_C32_APPLY_TYPE_TEST)/g' \
3155 -e 's/@''GNULIB_C32_GET_MAPPING''@/$(GL_GNULIB_C32_GET_MAPPING)/g' \
3156 -e 's/@''GNULIB_C32_GET_TYPE_TEST''@/$(GL_GNULIB_C32_GET_TYPE_TEST)/g' \
3157 -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \
3158 -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \
3159 -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \
3160 -e 's/@''GNULIB_MBRTOC16''@/$(GL_GNULIB_MBRTOC16)/g' \
3161 -e 's/@''GNULIB_MBRTOC32''@/$(GL_GNULIB_MBRTOC32)/g' \
3162 -e 's/@''GNULIB_MBSNRTOC32S''@/$(GL_GNULIB_MBSNRTOC32S)/g' \
3163 -e 's/@''GNULIB_MBSNRTOWCS''@/$(GL_GNULIB_MBSNRTOWCS)/g' \
3164 -e 's/@''GNULIB_MBSRTOC32S''@/$(GL_GNULIB_MBSRTOC32S)/g' \
3165 -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \
3166 -e 's/@''GNULIB_MBSTOC32S''@/$(GL_GNULIB_MBSTOC32S)/g' \
3167 -e 's/@''GNULIB_TOWCTRANS''@/$(GL_GNULIB_TOWCTRANS)/g' \
3168 -e 's/@''GNULIB_WCSNRTOMBS''@/$(GL_GNULIB_WCSNRTOMBS)/g' \
3169 -e 's/@''GNULIB_WCSRTOMBS''@/$(GL_GNULIB_WCSRTOMBS)/g' \
3170 -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \
3171 -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \
3172 -e 's/@''GNULIB_WCTRANS''@/$(GL_GNULIB_WCTRANS)/g' \
3173 -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \
3174 -e 's/@''GNULIB_WCWIDTH''@/$(GL_GNULIB_WCWIDTH)/g' \
3175 -e 's|@''HAVE_C32RTOMB''@|$(HAVE_C32RTOMB)|g' \
3176 -e 's|@''HAVE_MBRTOC16''@|$(HAVE_MBRTOC16)|g' \
3177 -e 's|@''HAVE_MBRTOC32''@|$(HAVE_MBRTOC32)|g' \
3178 -e 's|@''REPLACE_C32RTOMB''@|$(REPLACE_C32RTOMB)|g' \
3179 -e 's|@''REPLACE_MBRTOC16''@|$(REPLACE_MBRTOC16)|g' \
3180 -e 's|@''REPLACE_MBRTOC32''@|$(REPLACE_MBRTOC32)|g' \
3181 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
3182 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
3183 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
3184 $(srcdir)/uchar.in.h > $@-t
3185 $(AM_V_at)mv $@-t $@
3186MOSTLYCLEANFILES += uchar.h uchar.h-t
3187
3188EXTRA_DIST += uchar.in.h
3189
3190## end gnulib module uchar-h
3191
3192## begin gnulib module unicase/base
3193
3194BUILT_SOURCES += $(LIBUNISTRING_UNICASE_H)
3195
3196unicase.h: unicase.in.h
3197 $(gl_V_at)$(SED_HEADER_STDOUT) \
3198 -e 's|@''HAVE_UNISTRING_WOE32DLL_H''@|$(HAVE_UNISTRING_WOE32DLL_H)|g' \
3199 -e 's/@''GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE''@/$(GL_GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE)/g' \
3200 -e 's/@''GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE''@/$(GL_GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE)/g' \
3201 $(srcdir)/unicase.in.h > $@-t
3202 $(AM_V_at)mv $@-t $@
3203MOSTLYCLEANFILES += unicase.h unicase.h-t
3204
3205EXTRA_DIST += unicase.in.h
3206
3207## end gnulib module unicase/base
3208
3209## begin gnulib module unicase/tolower
3210
3211if LIBUNISTRING_COMPILE_UNICASE_TOLOWER
3212libgnu_a_SOURCES += unicase/tolower.c
3213endif
3214
3215EXTRA_DIST += unicase/simple-mapping.h unicase/tolower.h
3216
3217## end gnulib module unicase/tolower
3218
3219## begin gnulib module unictype/base
3220
3221BUILT_SOURCES += $(LIBUNISTRING_UNICTYPE_H)
3222
3223unictype.h: unictype.in.h
3224 $(gl_V_at)$(SED_HEADER_STDOUT) \
3225 -e 's|@''HAVE_UNISTRING_WOE32DLL_H''@|$(HAVE_UNISTRING_WOE32DLL_H)|g' \
3226 -e 's/@''GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE)/g' \
3227 -e 's/@''GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE)/g' \
3228 -e 's/@''GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE)/g' \
3229 -e 's/@''GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE)/g' \
3230 -e 's/@''GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE)/g' \
3231 -e 's/@''GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE)/g' \
3232 -e 's/@''GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE)/g' \
3233 -e 's/@''GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE)/g' \
3234 -e 's/@''GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE)/g' \
3235 -e 's/@''GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE)/g' \
3236 -e 's/@''GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE)/g' \
3237 -e 's/@''GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE)/g' \
3238 -e 's/@''GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE)/g' \
3239 -e 's/@''GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE)/g' \
3240 -e 's/@''GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE)/g' \
3241 -e 's/@''GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE)/g' \
3242 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE)/g' \
3243 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE)/g' \
3244 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE)/g' \
3245 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE)/g' \
3246 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE)/g' \
3247 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE)/g' \
3248 -e 's/@''GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE)/g' \
3249 -e 's/@''GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE)/g' \
3250 -e 's/@''GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE)/g' \
3251 -e 's/@''GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE)/g' \
3252 -e 's/@''GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE)/g' \
3253 -e 's/@''GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE)/g' \
3254 -e 's/@''GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE)/g' \
3255 -e 's/@''GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE)/g' \
3256 -e 's/@''GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE)/g' \
3257 -e 's/@''GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE)/g' \
3258 -e 's/@''GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE)/g' \
3259 -e 's/@''GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE)/g' \
3260 -e 's/@''GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE)/g' \
3261 -e 's/@''GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE)/g' \
3262 -e 's/@''GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE)/g' \
3263 -e 's/@''GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE)/g' \
3264 < $(srcdir)/unictype.in.h > $@-t1
3265 $(AM_V_at)sed \
3266 -e 's/@''GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE)/g' \
3267 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE)/g' \
3268 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE)/g' \
3269 -e 's/@''GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE)/g' \
3270 -e 's/@''GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE)/g' \
3271 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE)/g' \
3272 -e 's/@''GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE)/g' \
3273 -e 's/@''GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE)/g' \
3274 -e 's/@''GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE)/g' \
3275 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE)/g' \
3276 -e 's/@''GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE)/g' \
3277 -e 's/@''GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE)/g' \
3278 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE)/g' \
3279 -e 's/@''GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE)/g' \
3280 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE)/g' \
3281 -e 's/@''GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE)/g' \
3282 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE)/g' \
3283 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE)/g' \
3284 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE)/g' \
3285 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE)/g' \
3286 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE)/g' \
3287 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE)/g' \
3288 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE)/g' \
3289 -e 's/@''GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE)/g' \
3290 < $@-t1 > $@-t2
3291 $(AM_V_at)sed \
3292 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE)/g' \
3293 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE)/g' \
3294 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE)/g' \
3295 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE)/g' \
3296 -e 's/@''GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE)/g' \
3297 -e 's/@''GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE)/g' \
3298 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_START_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_START_DLL_VARIABLE)/g' \
3299 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_CONTINUE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_CONTINUE_DLL_VARIABLE)/g' \
3300 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE)/g' \
3301 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE)/g' \
3302 -e 's/@''GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE)/g' \
3303 -e 's/@''GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE)/g' \
3304 -e 's/@''GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE)/g' \
3305 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE)/g' \
3306 -e 's/@''GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE)/g' \
3307 -e 's/@''GNULIB_UNICTYPE_PROPERTY_MODIFIER_COMBINING_MARK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_MODIFIER_COMBINING_MARK_DLL_VARIABLE)/g' \
3308 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE)/g' \
3309 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE)/g' \
3310 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE)/g' \
3311 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE)/g' \
3312 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE)/g' \
3313 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE)/g' \
3314 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE)/g' \
3315 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE)/g' \
3316 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE)/g' \
3317 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE)/g' \
3318 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE)/g' \
3319 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE)/g' \
3320 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE)/g' \
3321 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE)/g' \
3322 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE)/g' \
3323 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE)/g' \
3324 -e 's/@''GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE)/g' \
3325 < $@-t2 > $@-t3
3326 $(AM_V_at)sed \
3327 -e 's/@''GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE)/g' \
3328 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE)/g' \
3329 -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE)/g' \
3330 -e 's/@''GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE)/g' \
3331 -e 's/@''GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE)/g' \
3332 -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDS_UNARY_OPERATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDS_UNARY_OPERATOR_DLL_VARIABLE)/g' \
3333 -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE)/g' \
3334 -e 's/@''GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE)/g' \
3335 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE)/g' \
3336 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE)/g' \
3337 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE)/g' \
3338 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE)/g' \
3339 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE)/g' \
3340 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE)/g' \
3341 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE)/g' \
3342 -e 's/@''GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE)/g' \
3343 -e 's/@''GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE)/g' \
3344 -e 's/@''GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE)/g' \
3345 -e 's/@''GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE)/g' \
3346 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PREPENDED_CONCATENATION_MARK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PREPENDED_CONCATENATION_MARK_DLL_VARIABLE)/g' \
3347 -e 's/@''GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE)/g' \
3348 -e 's/@''GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE)/g' \
3349 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE)/g' \
3350 -e 's/@''GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE)/g' \
3351 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE)/g' \
3352 -e 's/@''GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE)/g' \
3353 -e 's/@''GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE)/g' \
3354 -e 's/@''GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE)/g' \
3355 -e 's/@''GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE)/g' \
3356 -e 's/@''GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE)/g' \
3357 -e 's/@''GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE)/g' \
3358 -e 's/@''GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE)/g' \
3359 -e 's/@''GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE)/g' \
3360 -e 's/@''GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE)/g' \
3361 -e 's/@''GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE)/g' \
3362 -e 's/@''GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE)/g' \
3363 -e 's/@''GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE)/g' \
3364 -e 's/@''GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE)/g' \
3365 -e 's/@''GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE)/g' \
3366 -e 's/@''GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE)/g' \
3367 -e 's/@''GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE''@/$(GL_GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE)/g' \
3368 < $@-t3 > $@-t4
3369 $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3
3370 $(AM_V_at)mv $@-t4 $@
3371MOSTLYCLEANFILES += unictype.h unictype.h-t1 unictype.h-t2 unictype.h-t3 unictype.h-t4
3372
3373EXTRA_DIST += unictype.in.h
3374
3375## end gnulib module unictype/base
3376
3377## begin gnulib module unictype/ctype-alnum
3378
3379if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_ALNUM
3380libgnu_a_SOURCES += unictype/ctype_alnum.c
3381endif
3382
3383EXTRA_DIST += unictype/bitmap.h unictype/ctype_alnum.h
3384
3385## end gnulib module unictype/ctype-alnum
3386
3387## begin gnulib module unictype/ctype-alpha
3388
3389if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_ALPHA
3390libgnu_a_SOURCES += unictype/ctype_alpha.c
3391endif
3392
3393EXTRA_DIST += unictype/bitmap.h unictype/ctype_alpha.h
3394
3395## end gnulib module unictype/ctype-alpha
3396
3397## begin gnulib module unictype/ctype-blank
3398
3399if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_BLANK
3400libgnu_a_SOURCES += unictype/ctype_blank.c
3401endif
3402
3403EXTRA_DIST += unictype/bitmap.h unictype/ctype_blank.h
3404
3405## end gnulib module unictype/ctype-blank
3406
3407## begin gnulib module unictype/ctype-cntrl
3408
3409if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_CNTRL
3410libgnu_a_SOURCES += unictype/ctype_cntrl.c
3411endif
3412
3413EXTRA_DIST += unictype/bitmap.h unictype/ctype_cntrl.h
3414
3415## end gnulib module unictype/ctype-cntrl
3416
3417## begin gnulib module unictype/ctype-digit
3418
3419if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_DIGIT
3420libgnu_a_SOURCES += unictype/ctype_digit.c
3421endif
3422
3423EXTRA_DIST += unictype/bitmap.h unictype/ctype_digit.h
3424
3425## end gnulib module unictype/ctype-digit
3426
3427## begin gnulib module unictype/ctype-graph
3428
3429if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_GRAPH
3430libgnu_a_SOURCES += unictype/ctype_graph.c
3431endif
3432
3433EXTRA_DIST += unictype/bitmap.h unictype/ctype_graph.h
3434
3435## end gnulib module unictype/ctype-graph
3436
3437## begin gnulib module unictype/ctype-lower
3438
3439if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_LOWER
3440libgnu_a_SOURCES += unictype/ctype_lower.c
3441endif
3442
3443EXTRA_DIST += unictype/bitmap.h unictype/ctype_lower.h
3444
3445## end gnulib module unictype/ctype-lower
3446
3447## begin gnulib module unictype/ctype-print
3448
3449if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_PRINT
3450libgnu_a_SOURCES += unictype/ctype_print.c
3451endif
3452
3453EXTRA_DIST += unictype/bitmap.h unictype/ctype_print.h
3454
3455## end gnulib module unictype/ctype-print
3456
3457## begin gnulib module unictype/ctype-punct
3458
3459if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_PUNCT
3460libgnu_a_SOURCES += unictype/ctype_punct.c
3461endif
3462
3463EXTRA_DIST += unictype/bitmap.h unictype/ctype_punct.h
3464
3465## end gnulib module unictype/ctype-punct
3466
3467## begin gnulib module unictype/ctype-space
3468
3469if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_SPACE
3470libgnu_a_SOURCES += unictype/ctype_space.c
3471endif
3472
3473EXTRA_DIST += unictype/bitmap.h unictype/ctype_space.h
3474
3475## end gnulib module unictype/ctype-space
3476
3477## begin gnulib module unictype/ctype-upper
3478
3479if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_UPPER
3480libgnu_a_SOURCES += unictype/ctype_upper.c
3481endif
3482
3483EXTRA_DIST += unictype/bitmap.h unictype/ctype_upper.h
3484
3485## end gnulib module unictype/ctype-upper
3486
3487## begin gnulib module unictype/ctype-xdigit
3488
3489if LIBUNISTRING_COMPILE_UNICTYPE_CTYPE_XDIGIT
3490libgnu_a_SOURCES += unictype/ctype_xdigit.c
3491endif
3492
3493EXTRA_DIST += unictype/bitmap.h unictype/ctype_xdigit.h
3494
3495## end gnulib module unictype/ctype-xdigit
3496
3497## begin gnulib module uninorm/base
3498
3499BUILT_SOURCES += $(LIBUNISTRING_UNINORM_H)
3500
3501uninorm.h: uninorm.in.h
3502 $(gl_V_at)$(SED_HEADER_STDOUT) \
3503 -e 's|@''HAVE_UNISTRING_WOE32DLL_H''@|$(HAVE_UNISTRING_WOE32DLL_H)|g' \
3504 -e 's/@''GNULIB_UNINORM_NFD_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFD_DLL_VARIABLE)/g' \
3505 -e 's/@''GNULIB_UNINORM_NFC_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFC_DLL_VARIABLE)/g' \
3506 -e 's/@''GNULIB_UNINORM_NFKD_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFKD_DLL_VARIABLE)/g' \
3507 -e 's/@''GNULIB_UNINORM_NFKC_DLL_VARIABLE''@/$(GL_GNULIB_UNINORM_NFKC_DLL_VARIABLE)/g' \
3508 $(srcdir)/uninorm.in.h > $@-t
3509 $(AM_V_at)mv $@-t $@
3510MOSTLYCLEANFILES += uninorm.h uninorm.h-t
3511
3512EXTRA_DIST += uninorm.in.h
3513
3514## end gnulib module uninorm/base
3515
3516## begin gnulib module unistd-h
2505 3517
2506BUILT_SOURCES += unistd.h 3518BUILT_SOURCES += unistd.h
2507libgnu_a_SOURCES += unistd.c 3519libgnu_a_SOURCES += unistd.c
@@ -2540,6 +3552,8 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2540 -e 's/@''GNULIB_FDATASYNC''@/$(GL_GNULIB_FDATASYNC)/g' \ 3552 -e 's/@''GNULIB_FDATASYNC''@/$(GL_GNULIB_FDATASYNC)/g' \
2541 -e 's/@''GNULIB_FSYNC''@/$(GL_GNULIB_FSYNC)/g' \ 3553 -e 's/@''GNULIB_FSYNC''@/$(GL_GNULIB_FSYNC)/g' \
2542 -e 's/@''GNULIB_FTRUNCATE''@/$(GL_GNULIB_FTRUNCATE)/g' \ 3554 -e 's/@''GNULIB_FTRUNCATE''@/$(GL_GNULIB_FTRUNCATE)/g' \
3555 < $(srcdir)/unistd.in.h > $@-t1
3556 $(AM_V_at)sed \
2543 -e 's/@''GNULIB_GETCWD''@/$(GL_GNULIB_GETCWD)/g' \ 3557 -e 's/@''GNULIB_GETCWD''@/$(GL_GNULIB_GETCWD)/g' \
2544 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GL_GNULIB_GETDOMAINNAME)/g' \ 3558 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GL_GNULIB_GETDOMAINNAME)/g' \
2545 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GL_GNULIB_GETDTABLESIZE)/g' \ 3559 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GL_GNULIB_GETDTABLESIZE)/g' \
@@ -2601,8 +3615,9 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2601 -e 's/@''GNULIB_MDA_SWAB''@/$(GL_GNULIB_MDA_SWAB)/g' \ 3615 -e 's/@''GNULIB_MDA_SWAB''@/$(GL_GNULIB_MDA_SWAB)/g' \
2602 -e 's/@''GNULIB_MDA_UNLINK''@/$(GL_GNULIB_MDA_UNLINK)/g' \ 3616 -e 's/@''GNULIB_MDA_UNLINK''@/$(GL_GNULIB_MDA_UNLINK)/g' \
2603 -e 's/@''GNULIB_MDA_WRITE''@/$(GL_GNULIB_MDA_WRITE)/g' \ 3617 -e 's/@''GNULIB_MDA_WRITE''@/$(GL_GNULIB_MDA_WRITE)/g' \
2604 < $(srcdir)/unistd.in.h | \ 3618 < $@-t1 > $@-t2
2605 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ 3619 $(AM_V_at)sed \
3620 -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
2606 -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \ 3621 -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \
2607 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ 3622 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
2608 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ 3623 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
@@ -2649,13 +3664,15 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2649 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ 3664 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
2650 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ 3665 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
2651 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ 3666 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
2652 | \ 3667 < $@-t2 > $@-t3
2653 sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \ 3668 $(AM_V_at)sed \
3669 -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
2654 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ 3670 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
2655 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ 3671 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
2656 -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \ 3672 -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
2657 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ 3673 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
2658 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ 3674 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
3675 -e 's|@''REPLACE_DUP3''@|$(REPLACE_DUP3)|g' \
2659 -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \ 3676 -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
2660 -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \ 3677 -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \
2661 -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \ 3678 -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \
@@ -2664,27 +3681,34 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2664 -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \ 3681 -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \
2665 -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \ 3682 -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \
2666 -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \ 3683 -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
3684 -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
2667 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ 3685 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
3686 -e 's|@''REPLACE_FDATASYNC''@|$(REPLACE_FDATASYNC)|g' \
2668 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ 3687 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
2669 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 3688 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
2670 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ 3689 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
2671 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ 3690 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
3691 -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \
3692 -e 's|@''REPLACE_GETLOGIN''@|$(REPLACE_GETLOGIN)|g' \
2672 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ 3693 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
2673 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ 3694 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
2674 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 3695 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
2675 -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \ 3696 -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
2676 -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \ 3697 -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
3698 -e 's|@''REPLACE_GETUSERSHELL''@|$(REPLACE_GETUSERSHELL)|g' \
2677 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ 3699 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
2678 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ 3700 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
2679 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ 3701 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
2680 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ 3702 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
2681 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ 3703 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
3704 -e 's|@''REPLACE_PIPE2''@|$(REPLACE_PIPE2)|g' \
2682 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ 3705 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
2683 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ 3706 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
2684 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ 3707 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
2685 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ 3708 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
2686 -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ 3709 -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
2687 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ 3710 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
3711 -e 's|@''REPLACE_SETHOSTNAME''@|$(REPLACE_SETHOSTNAME)|g' \
2688 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ 3712 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
2689 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ 3713 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
2690 -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ 3714 -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
@@ -2700,13 +3724,50 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2700 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 3724 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2701 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 3725 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2702 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 3726 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2703 > $@-t 3727 < $@-t3 > $@-t4
2704 $(AM_V_at)mv $@-t $@ 3728 $(AM_V_at)rm -f $@-t1 $@-t2 $@-t3
2705MOSTLYCLEANFILES += unistd.h unistd.h-t 3729 $(AM_V_at)mv $@-t4 $@
3730MOSTLYCLEANFILES += unistd.h unistd.h-t1 unistd.h-t2 unistd.h-t3 unistd.h-t4
2706 3731
2707EXTRA_DIST += unistd.in.h 3732EXTRA_DIST += unistd.in.h
2708 3733
2709## end gnulib module unistd 3734## end gnulib module unistd-h
3735
3736## begin gnulib module unitypes-h
3737
3738BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H)
3739
3740unitypes.h: unitypes.in.h
3741 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/unitypes.in.h
3742 $(AM_V_at)mv $@-t $@
3743MOSTLYCLEANFILES += unitypes.h unitypes.h-t
3744
3745EXTRA_DIST += unitypes.in.h
3746
3747## end gnulib module unitypes-h
3748
3749## begin gnulib module uniwidth/base
3750
3751BUILT_SOURCES += $(LIBUNISTRING_UNIWIDTH_H)
3752
3753uniwidth.h: uniwidth.in.h
3754 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/uniwidth.in.h
3755 $(AM_V_at)mv $@-t $@
3756MOSTLYCLEANFILES += uniwidth.h uniwidth.h-t
3757
3758EXTRA_DIST += localcharset.h uniwidth.in.h
3759
3760## end gnulib module uniwidth/base
3761
3762## begin gnulib module uniwidth/width
3763
3764if LIBUNISTRING_COMPILE_UNIWIDTH_WIDTH
3765libgnu_a_SOURCES += uniwidth/width.c
3766endif
3767
3768EXTRA_DIST += unictype/bitmap.h uniwidth/cjk.h uniwidth/width0.h uniwidth/width2.h
3769
3770## end gnulib module uniwidth/width
2710 3771
2711## begin gnulib module unlocked-io-internal 3772## begin gnulib module unlocked-io-internal
2712 3773
@@ -2757,7 +3818,13 @@ EXTRA_libgnu_a_SOURCES += vsnprintf.c
2757 3818
2758## end gnulib module vsnprintf 3819## end gnulib module vsnprintf
2759 3820
2760## begin gnulib module wchar 3821## begin gnulib module vsnzprintf
3822
3823libgnu_a_SOURCES += vsnzprintf.c
3824
3825## end gnulib module vsnzprintf
3826
3827## begin gnulib module wchar-h
2761 3828
2762BUILT_SOURCES += wchar.h 3829BUILT_SOURCES += wchar.h
2763 3830
@@ -2777,6 +3844,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2777 -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \ 3844 -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \
2778 -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \ 3845 -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \
2779 -e 's/@''GNULIB_MBSINIT''@/$(GL_GNULIB_MBSINIT)/g' \ 3846 -e 's/@''GNULIB_MBSINIT''@/$(GL_GNULIB_MBSINIT)/g' \
3847 -e 's/@''GNULIB_MBSZERO''@/$(GL_GNULIB_MBSZERO)/g' \
2780 -e 's/@''GNULIB_MBRTOWC''@/$(GL_GNULIB_MBRTOWC)/g' \ 3848 -e 's/@''GNULIB_MBRTOWC''@/$(GL_GNULIB_MBRTOWC)/g' \
2781 -e 's/@''GNULIB_MBRLEN''@/$(GL_GNULIB_MBRLEN)/g' \ 3849 -e 's/@''GNULIB_MBRLEN''@/$(GL_GNULIB_MBRLEN)/g' \
2782 -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \ 3850 -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \
@@ -2815,10 +3883,12 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2815 -e 's/@''GNULIB_WCSTOK''@/$(GL_GNULIB_WCSTOK)/g' \ 3883 -e 's/@''GNULIB_WCSTOK''@/$(GL_GNULIB_WCSTOK)/g' \
2816 -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \ 3884 -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \
2817 -e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \ 3885 -e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \
3886 -e 's/@''GNULIB_WGETCWD''@/$(GL_GNULIB_WGETCWD)/g' \
2818 -e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \ 3887 -e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \
2819 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \ 3888 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
2820 < $(srcdir)/wchar.in.h | \ 3889 < $(srcdir)/wchar.in.h > $@-t1
2821 sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ 3890 $(AM_V_at)sed \
3891 -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
2822 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ 3892 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
2823 -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ 3893 -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \
2824 -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ 3894 -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \
@@ -2858,11 +3928,12 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2858 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ 3928 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
2859 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ 3929 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
2860 -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \ 3930 -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
2861 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ 3931 -e 's|@''HAVE_WCTOB''@|$(HAVE_WCTOB)|g' \
2862 -e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \ 3932 -e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \
2863 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ 3933 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
2864 | \ 3934 < $@-t1 > $@-t2
2865 sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ 3935 $(AM_V_at)sed \
3936 -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
2866 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ 3937 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
2867 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ 3938 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
2868 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \ 3939 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
@@ -2877,17 +3948,24 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2877 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ 3948 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
2878 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \ 3949 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
2879 -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \ 3950 -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
3951 -e 's|@''REPLACE_WCSCMP''@|$(REPLACE_WCSCMP)|g' \
3952 -e 's|@''REPLACE_WCSNCAT''@|$(REPLACE_WCSNCAT)|g' \
3953 -e 's|@''REPLACE_WCSNCMP''@|$(REPLACE_WCSNCMP)|g' \
3954 -e 's|@''REPLACE_WCSSTR''@|$(REPLACE_WCSSTR)|g' \
2880 -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \ 3955 -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \
3956 -e 's|@''REPLACE_WMEMCMP''@|$(REPLACE_WMEMCMP)|g' \
3957 -e 's|@''REPLACE_WMEMPCPY''@|$(REPLACE_WMEMPCPY)|g' \
2881 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 3958 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2882 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 3959 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2883 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 3960 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2884 > $@-t 3961 < $@-t2 > $@-t3
2885 $(AM_V_at)mv $@-t $@ 3962 $(AM_V_at)rm -f $@-t1 $@-t2
2886MOSTLYCLEANFILES += wchar.h wchar.h-t 3963 $(AM_V_at)mv $@-t3 $@
3964MOSTLYCLEANFILES += wchar.h wchar.h-t1 wchar.h-t2 wchar.h-t3
2887 3965
2888EXTRA_DIST += wchar.in.h 3966EXTRA_DIST += wchar.in.h
2889 3967
2890## end gnulib module wchar 3968## end gnulib module wchar-h
2891 3969
2892## begin gnulib module wcrtomb 3970## begin gnulib module wcrtomb
2893 3971
@@ -2897,6 +3975,16 @@ endif
2897 3975
2898## end gnulib module wcrtomb 3976## end gnulib module wcrtomb
2899 3977
3978## begin gnulib module wctype
3979
3980if GL_COND_OBJ_WCTYPE
3981libgnu_a_SOURCES += wctype.c
3982endif
3983
3984EXTRA_DIST += wctype-impl.h
3985
3986## end gnulib module wctype
3987
2900## begin gnulib module wctype-h 3988## begin gnulib module wctype-h
2901 3989
2902BUILT_SOURCES += wctype.h 3990BUILT_SOURCES += wctype.h
@@ -2904,7 +3992,7 @@ libgnu_a_SOURCES += wctype-h.c
2904 3992
2905# We need the following in order to create <wctype.h> when the system 3993# We need the following in order to create <wctype.h> when the system
2906# doesn't have one that works with the given compiler. 3994# doesn't have one that works with the given compiler.
2907wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) 3995wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2908 $(gl_V_at)$(SED_HEADER_STDOUT) \ 3996 $(gl_V_at)$(SED_HEADER_STDOUT) \
2909 -e 's|@''GUARD_PREFIX''@|GL|g' \ 3997 -e 's|@''GUARD_PREFIX''@|GL|g' \
2910 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ 3998 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
@@ -2916,6 +4004,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
2916 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \ 4004 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
2917 -e 's/@''GNULIB_ISWBLANK''@/$(GL_GNULIB_ISWBLANK)/g' \ 4005 -e 's/@''GNULIB_ISWBLANK''@/$(GL_GNULIB_ISWBLANK)/g' \
2918 -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \ 4006 -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \
4007 -e 's/@''GNULIB_ISWPUNCT''@/$(GL_GNULIB_ISWPUNCT)/g' \
2919 -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \ 4008 -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \
2920 -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \ 4009 -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \
2921 -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \ 4010 -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \
@@ -2928,10 +4017,14 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
2928 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ 4017 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
2929 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ 4018 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
2930 -e 's/@''REPLACE_ISWDIGIT''@/$(REPLACE_ISWDIGIT)/g' \ 4019 -e 's/@''REPLACE_ISWDIGIT''@/$(REPLACE_ISWDIGIT)/g' \
4020 -e 's/@''REPLACE_ISWPUNCT''@/$(REPLACE_ISWPUNCT)/g' \
2931 -e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \ 4021 -e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \
2932 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ 4022 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
2933 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ 4023 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
4024 -e 's/@''REPLACE_WCTRANS''@/$(REPLACE_WCTRANS)/g' \
4025 -e 's/@''REPLACE_WCTYPE''@/$(REPLACE_WCTYPE)/g' \
2934 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 4026 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
4027 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2935 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 4028 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2936 $(srcdir)/wctype.in.h > $@-t 4029 $(srcdir)/wctype.in.h > $@-t
2937 $(AM_V_at)mv $@-t $@ 4030 $(AM_V_at)mv $@-t $@
@@ -2941,6 +4034,14 @@ EXTRA_DIST += wctype.in.h
2941 4034
2942## end gnulib module wctype-h 4035## end gnulib module wctype-h
2943 4036
4037## begin gnulib module wcwidth
4038
4039if GL_COND_OBJ_WCWIDTH
4040libgnu_a_SOURCES += wcwidth.c
4041endif
4042
4043## end gnulib module wcwidth
4044
2944## begin gnulib module windows-mutex 4045## begin gnulib module windows-mutex
2945 4046
2946if GL_COND_OBJ_WINDOWS_MUTEX 4047if GL_COND_OBJ_WINDOWS_MUTEX
@@ -3020,5 +4121,5 @@ mostlyclean-local: mostlyclean-generic
3020 : 4121 :
3021distclean-local: distclean-gnulib-libobjs 4122distclean-local: distclean-gnulib-libobjs
3022distclean-gnulib-libobjs: 4123distclean-gnulib-libobjs:
3023 -rm -f @gl_LIBOBJDEPS@ 4124 -rm -f @gl_libgnu_LIBOBJDEPS@
3024maintainer-clean-local: distclean-gnulib-libobjs 4125maintainer-clean-local: distclean-gnulib-libobjs
diff --git a/gl/_Noreturn.h b/gl/_Noreturn.h
index 6ecea98b..0bab051e 100644
--- a/gl/_Noreturn.h
+++ b/gl/_Noreturn.h
@@ -1,5 +1,5 @@
1/* A C macro for declaring that a function does not return. 1/* A C macro for declaring that a function does not return.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published 5 under the terms of the GNU Lesser General Public License as published
@@ -14,33 +14,26 @@
14 You should have received a copy of the GNU Lesser General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* The _Noreturn keyword of C11.
18 Do not use [[noreturn]], because with it the syntax
19 extern _Noreturn void func (...);
20 would not be valid; such a declaration would be valid only with 'extern'
21 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
22 AIX system header files and several gnulib header files use precisely
23 this syntax with 'extern'. So even though C23 deprecates _Noreturn,
24 it is currently more portable to prefer it to [[noreturn]].
25
26 Also, do not try to work around LLVM bug 59792 (clang 15 or earlier).
27 This rare bug can be worked around by compiling with 'clang -D_Noreturn=',
28 though the workaround may generate many false-alarm warnings. */
17#ifndef _Noreturn 29#ifndef _Noreturn
18# if (defined __cplusplus \ 30# if ((!defined __cplusplus || defined __clang__) \
19 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ 31 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)))
20 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
21 && 0)
22 /* [[noreturn]] is not practically usable, because with it the syntax
23 extern _Noreturn void func (...);
24 would not be valid; such a declaration would only be valid with 'extern'
25 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
26 AIX system header files and several gnulib header files use precisely
27 this syntax with 'extern'. */
28# define _Noreturn [[noreturn]]
29# elif (defined __clang__ && __clang_major__ < 16 \
30 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
31 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
32 that rare LLVM bug, though you may get many false-alarm warnings. */
33# define _Noreturn
34# elif ((!defined __cplusplus || defined __clang__) \
35 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
36 || (!defined __STRICT_ANSI__ \
37 && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
38 || (defined __apple_build_version__ \
39 ? 6000000 <= __apple_build_version__ \
40 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
41 /* _Noreturn works as-is. */ 32 /* _Noreturn works as-is. */
42# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \ 33# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
43 || 0x5110 <= __SUNPRO_C) 34 || 0x5110 <= __SUNPRO_C)
35 /* Prefer __attribute__ ((__noreturn__)) to plain _Noreturn even if the
36 latter works, as 'gcc -std=gnu99 -Wpedantic' warns about _Noreturn. */
44# define _Noreturn __attribute__ ((__noreturn__)) 37# define _Noreturn __attribute__ ((__noreturn__))
45# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) 38# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
46# define _Noreturn __declspec (noreturn) 39# define _Noreturn __declspec (noreturn)
diff --git a/gl/af_alg.c b/gl/af_alg.c
index 9f022ce5..91f3df15 100644
--- a/gl/af_alg.c
+++ b/gl/af_alg.c
@@ -1,5 +1,5 @@
1/* af_alg.c - Compute message digests from file streams and buffers. 1/* af_alg.c - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc. 2 Copyright (C) 2018-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -112,100 +112,102 @@ afalg_stream (FILE *stream, const char *alg,
112 read-write loop work around an empty-input bug noted below. */ 112 read-write loop work around an empty-input bug noted below. */
113 int fd = fileno (stream); 113 int fd = fileno (stream);
114 int result; 114 int result;
115 struct stat st; 115 {
116 off_t off = ftello (stream); 116 struct stat st;
117 if (0 <= off && fstat (fd, &st) == 0 117 off_t off = ftello (stream);
118 && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st)) 118 if (0 <= off && fstat (fd, &st) == 0
119 && off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX) 119 && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
120 { 120 && off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
121 /* Make sure the offset of fileno (stream) reflects how many bytes 121 {
122 have been read from stream before this function got invoked. 122 /* Make sure the offset of fileno (stream) reflects how many bytes
123 Note: fflush on an input stream after ungetc does not work as expected 123 have been read from stream before this function got invoked.
124 on some platforms. Therefore this situation is not supported here. */ 124 Note: fflush on an input stream after ungetc does not work as expected
125 if (fflush (stream)) 125 on some platforms. Therefore this situation is not supported here. */
126 result = -EIO; 126 if (fflush (stream))
127 else 127 result = -EIO;
128 { 128 else
129 off_t nbytes = st.st_size - off; 129 {
130 if (sendfile (ofd, fd, &off, nbytes) == nbytes) 130 off_t nbytes = st.st_size - off;
131 { 131 if (sendfile (ofd, fd, &off, nbytes) == nbytes)
132 if (read (ofd, resblock, hashlen) == hashlen) 132 {
133 { 133 if (read (ofd, resblock, hashlen) == hashlen)
134 /* The input buffers of stream are no longer valid. */ 134 {
135 if (lseek (fd, off, SEEK_SET) != (off_t)-1) 135 /* The input buffers of stream are no longer valid. */
136 result = 0; 136 if (lseek (fd, off, SEEK_SET) != (off_t)-1)
137 else 137 result = 0;
138 /* The file position of fd has not changed. */ 138 else
139 /* The file position of fd has not changed. */
140 result = -EAFNOSUPPORT;
141 }
142 else
143 /* The file position of fd has not changed. */
144 result = -EAFNOSUPPORT;
145 }
146 else
147 /* The file position of fd has not changed. */
148 result = -EAFNOSUPPORT;
149 }
150 }
151 else
152 {
153 /* sendfile not possible, do a classic read-write loop. */
154
155 /* Number of bytes to seek (backwards) in case of error. */
156 off_t nseek = 0;
157
158 for (;;)
159 {
160 char buf[BLOCKSIZE];
161 /* When the stream is not seekable, start with a single-byte block,
162 so that we can use ungetc() in the case that send() fails. */
163 size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
164 ssize_t size = fread (buf, 1, blocksize, stream);
165 if (size == 0)
166 {
167 /* On Linux < 4.9, the value for an empty stream is wrong (all 0).
168 See <https://patchwork.kernel.org/patch/9308641/>.
169 This was not fixed properly until November 2016,
170 see <https://patchwork.kernel.org/patch/9434741/>. */
171 result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
172 break;
173 }
174 nseek -= size;
175 if (send (ofd, buf, size, MSG_MORE) != size)
176 {
177 if (nseek == -1)
178 {
179 /* 1 byte of pushback buffer is guaranteed on stream, even
180 if stream is not seekable. */
181 ungetc ((unsigned char) buf[0], stream);
139 result = -EAFNOSUPPORT; 182 result = -EAFNOSUPPORT;
140 } 183 }
141 else 184 else if (fseeko (stream, nseek, SEEK_CUR) == 0)
142 /* The file position of fd has not changed. */ 185 /* The position of stream has been restored. */
143 result = -EAFNOSUPPORT;
144 }
145 else
146 /* The file position of fd has not changed. */
147 result = -EAFNOSUPPORT;
148 }
149 }
150 else
151 {
152 /* sendfile not possible, do a classic read-write loop. */
153
154 /* Number of bytes to seek (backwards) in case of error. */
155 off_t nseek = 0;
156
157 for (;;)
158 {
159 char buf[BLOCKSIZE];
160 /* When the stream is not seekable, start with a single-byte block,
161 so that we can use ungetc() in the case that send() fails. */
162 size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
163 ssize_t size = fread (buf, 1, blocksize, stream);
164 if (size == 0)
165 {
166 /* On Linux < 4.9, the value for an empty stream is wrong (all 0).
167 See <https://patchwork.kernel.org/patch/9308641/>.
168 This was not fixed properly until November 2016,
169 see <https://patchwork.kernel.org/patch/9434741/>. */
170 result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
171 break;
172 }
173 nseek -= size;
174 if (send (ofd, buf, size, MSG_MORE) != size)
175 {
176 if (nseek == -1)
177 {
178 /* 1 byte of pushback buffer is guaranteed on stream, even
179 if stream is not seekable. */
180 ungetc ((unsigned char) buf[0], stream);
181 result = -EAFNOSUPPORT; 186 result = -EAFNOSUPPORT;
182 } 187 else
183 else if (fseeko (stream, nseek, SEEK_CUR) == 0) 188 result = -EIO;
184 /* The position of stream has been restored. */ 189 break;
185 result = -EAFNOSUPPORT; 190 }
186 else 191
187 result = -EIO; 192 /* Don't assume that EOF is sticky. See:
188 break; 193 <https://sourceware.org/PR19476>. */
189 } 194 if (feof (stream))
190 195 {
191 /* Don't assume that EOF is sticky. See: 196 result = 0;
192 <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>. */ 197 break;
193 if (feof (stream)) 198 }
194 { 199 }
195 result = 0; 200
196 break; 201 if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
197 } 202 {
198 } 203 if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
199 204 /* The position of stream has been restored. */
200 if (result == 0 && read (ofd, resblock, hashlen) != hashlen) 205 result = -EAFNOSUPPORT;
201 { 206 else
202 if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0) 207 result = -EIO;
203 /* The position of stream has been restored. */ 208 }
204 result = -EAFNOSUPPORT; 209 }
205 else 210 }
206 result = -EIO;
207 }
208 }
209 close (ofd); 211 close (ofd);
210 return result; 212 return result;
211} 213}
diff --git a/gl/af_alg.h b/gl/af_alg.h
index e8ffb3f7..1321970f 100644
--- a/gl/af_alg.h
+++ b/gl/af_alg.h
@@ -1,5 +1,5 @@
1/* af_alg.h - Compute message digests from file streams and buffers. 1/* af_alg.h - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc. 2 Copyright (C) 2018-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/alloca.in.h b/gl/alloca.in.h
index a1bb3d75..bb2cb881 100644
--- a/gl/alloca.in.h
+++ b/gl/alloca.in.h
@@ -1,6 +1,6 @@
1/* Memory allocation on the stack. 1/* Memory allocation on the stack.
2 2
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2023 Free Software Foundation, 3 Copyright (C) 1995, 1999, 2001-2004, 2006-2026 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
diff --git a/gl/arg-nonnull.h b/gl/arg-nonnull.h
index 9498ae1f..d370d139 100644
--- a/gl/arg-nonnull.h
+++ b/gl/arg-nonnull.h
@@ -1,5 +1,5 @@
1/* A C macro for declaring that specific arguments must not be NULL. 1/* A C macro for declaring that specific arguments must not be NULL.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published 5 under the terms of the GNU Lesser General Public License as published
diff --git a/gl/arpa_inet.c b/gl/arpa_inet.c
new file mode 100644
index 00000000..d0ff3a31
--- /dev/null
+++ b/gl/arpa_inet.c
@@ -0,0 +1,20 @@
1/* Inline functions for <arpa/inet.h>.
2
3 Copyright (C) 2024-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#define _GL_ARPA_INET_INLINE _GL_EXTERN_INLINE
19#include <config.h>
20#include <arpa/inet.h>
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h
index 80e6713f..a9c93d07 100644
--- a/gl/arpa_inet.in.h
+++ b/gl/arpa_inet.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <arpa/inet.h>. 1/* A GNU-like <arpa/inet.h>.
2 2
3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -49,12 +49,64 @@
49#ifndef _@GUARD_PREFIX@_ARPA_INET_H 49#ifndef _@GUARD_PREFIX@_ARPA_INET_H
50#define _@GUARD_PREFIX@_ARPA_INET_H 50#define _@GUARD_PREFIX@_ARPA_INET_H
51 51
52/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
53#if !_GL_CONFIG_H_INCLUDED
54 #error "Please include config.h first."
55#endif
56
52/* Get all possible declarations of inet_ntop() and inet_pton(). */ 57/* Get all possible declarations of inet_ntop() and inet_pton(). */
53#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \ 58#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
54 && @HAVE_WS2TCPIP_H@ 59 && @HAVE_WS2TCPIP_H@
55# include <ws2tcpip.h> 60# include <ws2tcpip.h>
56#endif 61#endif
57 62
63#if !(@HAVE_DECL_HTONL@ || @HAVE_DECL_HTONS@ || @HAVE_DECL_NTOHL@ || @HAVE_DECL_NTOHS@)
64# include <endian.h>
65#endif
66
67_GL_INLINE_HEADER_BEGIN
68#ifndef _GL_ARPA_INET_INLINE
69# define _GL_ARPA_INET_INLINE _GL_INLINE
70#endif
71
72
73/* Host to network byte order. */
74
75#if !@HAVE_DECL_HTONS@
76_GL_ARPA_INET_INLINE uint16_t
77htons (uint16_t value)
78{
79 return htobe16 (value);
80}
81#endif
82
83#if !@HAVE_DECL_HTONL@
84_GL_ARPA_INET_INLINE uint32_t
85htonl (uint32_t value)
86{
87 return htobe32 (value);
88}
89#endif
90
91/* Network to host byte order. */
92
93#if !@HAVE_DECL_NTOHS@
94_GL_ARPA_INET_INLINE uint16_t
95ntohs (uint16_t value)
96{
97 return htobe16 (value);
98}
99#endif
100
101#if !@HAVE_DECL_NTOHL@
102_GL_ARPA_INET_INLINE uint32_t
103ntohl (uint32_t value)
104{
105 return htobe32 (value);
106}
107#endif
108
109
58/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 110/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
59 111
60/* The definition of _GL_ARG_NONNULL is copied here. */ 112/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -85,7 +137,7 @@
85# endif 137# endif
86_GL_FUNCDECL_RPL (inet_ntop, const char *, 138_GL_FUNCDECL_RPL (inet_ntop, const char *,
87 (int af, const void *restrict src, 139 (int af, const void *restrict src,
88 char *restrict dst, socklen_t cnt) 140 char *restrict dst, socklen_t cnt),
89 _GL_ARG_NONNULL ((2, 3))); 141 _GL_ARG_NONNULL ((2, 3)));
90_GL_CXXALIAS_RPL (inet_ntop, const char *, 142_GL_CXXALIAS_RPL (inet_ntop, const char *,
91 (int af, const void *restrict src, 143 (int af, const void *restrict src,
@@ -94,7 +146,7 @@ _GL_CXXALIAS_RPL (inet_ntop, const char *,
94# if !@HAVE_DECL_INET_NTOP@ 146# if !@HAVE_DECL_INET_NTOP@
95_GL_FUNCDECL_SYS (inet_ntop, const char *, 147_GL_FUNCDECL_SYS (inet_ntop, const char *,
96 (int af, const void *restrict src, 148 (int af, const void *restrict src,
97 char *restrict dst, socklen_t cnt) 149 char *restrict dst, socklen_t cnt),
98 _GL_ARG_NONNULL ((2, 3))); 150 _GL_ARG_NONNULL ((2, 3)));
99# endif 151# endif
100/* Need to cast, because on NonStop Kernel, the fourth parameter is 152/* Need to cast, because on NonStop Kernel, the fourth parameter is
@@ -107,7 +159,6 @@ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
107_GL_CXXALIASWARN (inet_ntop); 159_GL_CXXALIASWARN (inet_ntop);
108# endif 160# endif
109#elif defined GNULIB_POSIXCHECK 161#elif defined GNULIB_POSIXCHECK
110# undef inet_ntop
111# if HAVE_RAW_DECL_INET_NTOP 162# if HAVE_RAW_DECL_INET_NTOP
112_GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - " 163_GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
113 "use gnulib module inet_ntop for portability"); 164 "use gnulib module inet_ntop for portability");
@@ -121,14 +172,14 @@ _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
121# define inet_pton rpl_inet_pton 172# define inet_pton rpl_inet_pton
122# endif 173# endif
123_GL_FUNCDECL_RPL (inet_pton, int, 174_GL_FUNCDECL_RPL (inet_pton, int,
124 (int af, const char *restrict src, void *restrict dst) 175 (int af, const char *restrict src, void *restrict dst),
125 _GL_ARG_NONNULL ((2, 3))); 176 _GL_ARG_NONNULL ((2, 3)));
126_GL_CXXALIAS_RPL (inet_pton, int, 177_GL_CXXALIAS_RPL (inet_pton, int,
127 (int af, const char *restrict src, void *restrict dst)); 178 (int af, const char *restrict src, void *restrict dst));
128# else 179# else
129# if !@HAVE_DECL_INET_PTON@ 180# if !@HAVE_DECL_INET_PTON@
130_GL_FUNCDECL_SYS (inet_pton, int, 181_GL_FUNCDECL_SYS (inet_pton, int,
131 (int af, const char *restrict src, void *restrict dst) 182 (int af, const char *restrict src, void *restrict dst),
132 _GL_ARG_NONNULL ((2, 3))); 183 _GL_ARG_NONNULL ((2, 3)));
133# endif 184# endif
134_GL_CXXALIAS_SYS (inet_pton, int, 185_GL_CXXALIAS_SYS (inet_pton, int,
@@ -138,13 +189,13 @@ _GL_CXXALIAS_SYS (inet_pton, int,
138_GL_CXXALIASWARN (inet_pton); 189_GL_CXXALIASWARN (inet_pton);
139# endif 190# endif
140#elif defined GNULIB_POSIXCHECK 191#elif defined GNULIB_POSIXCHECK
141# undef inet_pton
142# if HAVE_RAW_DECL_INET_PTON 192# if HAVE_RAW_DECL_INET_PTON
143_GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - " 193_GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
144 "use gnulib module inet_pton for portability"); 194 "use gnulib module inet_pton for portability");
145# endif 195# endif
146#endif 196#endif
147 197
198_GL_INLINE_HEADER_END
148 199
149#endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 200#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
150#endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 201#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
diff --git a/gl/asnprintf.c b/gl/asnprintf.c
index f4861bf8..05582499 100644
--- a/gl/asnprintf.c
+++ b/gl/asnprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -25,10 +25,8 @@ char *
25asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 25asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
26{ 26{
27 va_list args; 27 va_list args;
28 char *result;
29
30 va_start (args, format); 28 va_start (args, format);
31 result = vasnprintf (resultbuf, lengthp, format, args); 29 char *result = vasnprintf (resultbuf, lengthp, format, args);
32 va_end (args); 30 va_end (args);
33 return result; 31 return result;
34} 32}
diff --git a/gl/asprintf.c b/gl/asprintf.c
index ba58e064..5da2d085 100644
--- a/gl/asprintf.c
+++ b/gl/asprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2007, 2009-2023 Free Software Foundation, 2 Copyright (C) 1999, 2002, 2006-2007, 2009-2026 Free Software Foundation,
3 Inc. 3 Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -30,10 +30,8 @@ int
30asprintf (char **resultp, const char *format, ...) 30asprintf (char **resultp, const char *format, ...)
31{ 31{
32 va_list args; 32 va_list args;
33 int result;
34
35 va_start (args, format); 33 va_start (args, format);
36 result = vasprintf (resultp, format, args); 34 int result = vasprintf (resultp, format, args);
37 va_end (args); 35 va_end (args);
38 return result; 36 return result;
39} 37}
diff --git a/gl/assert.in.h b/gl/assert.in.h
index b0ab99c7..8a564670 100644
--- a/gl/assert.in.h
+++ b/gl/assert.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <assert.h> 1/* Substitute for and wrapper around <assert.h>
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/attribute.h b/gl/attribute.h
index 130644d8..c50befdf 100644
--- a/gl/attribute.h
+++ b/gl/attribute.h
@@ -1,6 +1,6 @@
1/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers 1/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
2 2
3 Copyright 2020-2023 Free Software Foundation, Inc. 3 Copyright 2020-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,12 +20,50 @@
20/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_* 20/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
21 macros used within Gnulib. */ 21 macros used within Gnulib. */
22 22
23/* These attributes can be placed in two ways: 23/* The placement of these attributes depends on the kind of declaration
24 - At the start of a declaration (i.e. even before storage-class 24 and, in some cases, also on the programming language (C vs. C++).
25 specifiers!); then they apply to all entities that are declared 25
26 by the declaration. 26 In function declarations and function definitions:
27 - Immediately after the name of an entity being declared by the 27
28 declaration; then they apply to that entity only. */ 28 * ATTRIBUTE_NOTHROW must come after the parameter list.
29
30 * The macros
31 ATTRIBUTE_CONST
32 ATTRIBUTE_PURE
33 DEPRECATED
34 MAYBE_UNUSED
35 NODISCARD
36 REPRODUCIBLE
37 UNSEQUENCED
38 must come before the return type, and more precisely:
39 - In a function declaration/definition without a storage-class
40 specifier: at the beginning of the declaration/definition.
41 - In a function declaration/definition with a storage-class
42 specifier:
43 - In C: before the storage-class specifier.
44 - In C++: between the storage-class specifier and the return type.
45
46 * The other macros can be placed
47 - Either
48 - In a function declaration/definition without a storage-class
49 specifier: at the beginning of the declaration/definition.
50 - In a function declaration/definition with a storage-class
51 specifier: between the storage-class specifier and the return
52 type.
53 - Or, in a function declaration:
54 after the parameter list,
55 ∙ but after ATTRIBUTE_NOTHROW if present.
56
57 In other declarations, such as variable declarations:
58
59 * Either
60 - In C: before the storage-class specifier.
61 - In C++: between the storage-class specifier and the return type.
62 Then they apply to all entities that are declared by the declaration.
63
64 * Or immediately after the name of an entity being declared by the
65 declaration. Then they apply to that entity only.
66 */
29 67
30#ifndef _GL_ATTRIBUTE_H 68#ifndef _GL_ATTRIBUTE_H
31#define _GL_ATTRIBUTE_H 69#define _GL_ATTRIBUTE_H
@@ -41,6 +79,22 @@
41 These names begin with 'ATTRIBUTE_' to avoid name clashes. */ 79 These names begin with 'ATTRIBUTE_' to avoid name clashes. */
42 80
43 81
82/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE,
83 _GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST,
84 _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR,
85 _GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE,
86 _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF,
87 _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED,
88 _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL,
89 _GL_ATTRIBUTE_NONNULL_IF_NONZERO, _GL_ATTRIBUTE_NONSTRING,
90 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE,
91 _GL_ATTRIBUTE_REPRODUCIBLE, _GL_ATTRIBUTE_RETURNS_NONNULL,
92 _GL_ATTRIBUTE_SENTINEL, _GL_ATTRIBUTE_UNSEQUENCED, _GL_UNNAMED. */
93#if !_GL_CONFIG_H_INCLUDED
94 #error "Please include config.h first."
95#endif
96
97
44/* =============== Attributes for specific kinds of functions =============== */ 98/* =============== Attributes for specific kinds of functions =============== */
45 99
46/* Attributes for functions that should not be used. */ 100/* Attributes for functions that should not be used. */
@@ -73,7 +127,7 @@
73 is the size of the returned memory block. 127 is the size of the returned memory block.
74 ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments 128 ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
75 to determine the size of the returned memory block. */ 129 to determine the size of the returned memory block. */
76/* Applies to: function, pointer to function, function types. */ 130/* Applies to: functions, pointer to functions, function types. */
77#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args) 131#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
78 132
79/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 133/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
@@ -117,6 +171,12 @@
117/* Applies to: functions. */ 171/* Applies to: functions. */
118#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args) 172#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
119 173
174/* ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) - Argument NP (a pointer)
175 must not be NULL if the argument NI (an integer) is != 0. */
176/* Applies to: functions. */
177#define ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (np, ni)
178
179
120/* The function's return value is a non-NULL pointer. */ 180/* The function's return value is a non-NULL pointer. */
121/* Applies to: functions. */ 181/* Applies to: functions. */
122#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL 182#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
@@ -155,7 +215,7 @@
155/* Attributes regarding debugging information emitted by the compiler. */ 215/* Attributes regarding debugging information emitted by the compiler. */
156 216
157/* Omit the function from stack traces when debugging. */ 217/* Omit the function from stack traces when debugging. */
158/* Applies to: function. */ 218/* Applies to: functions. */
159#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL 219#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
160 220
161/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */ 221/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
@@ -167,6 +227,8 @@
167 227
168/* The function does not throw exceptions. */ 228/* The function does not throw exceptions. */
169/* Applies to: functions. */ 229/* Applies to: functions. */
230/* After a function's parameter list, this attribute must come first, before
231 other attributes. */
170#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW 232#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
171 233
172/* Do not inline the function. */ 234/* Do not inline the function. */
@@ -175,25 +237,74 @@
175 237
176/* Always inline the function, and report an error if the compiler 238/* Always inline the function, and report an error if the compiler
177 cannot inline. */ 239 cannot inline. */
178/* Applies to: function. */ 240/* Applies to: functions. */
179#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE 241#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
180 242
181/* It is OK for a compiler to omit duplicate calls with the same arguments. 243/* It is OK for a compiler to move a call, or omit a duplicate call
182 This attribute is safe for a function that neither depends on 244 and reuse a cached return value, even if the state changes between calls.
183 nor affects observable state, and always returns exactly once - 245 It is also OK to omit a call if the result is not used.
184 e.g., does not loop forever, and does not call longjmp. 246 This attribute is safe if the function does not change observable state,
185 (This attribute is stricter than ATTRIBUTE_PURE.) */ 247 returns a value determined solely by its arguments' values
248 without examining state, and always returns exactly once -
249 e.g., does not raise an exception, call longjmp, or loop forever.
250 (This attribute is stricter than _GL_ATTRIBUTE_PURE because the
251 function cannot observe state. Unlike _GL_ATTRIBUTE_UNSEQUENCED
252 the function must return exactly once and cannot access state
253 addressed by its pointer arguments or that happens to have the same
254 value for all calls to the function, but the function is allowed to
255 return a pointer to storage that can be modified later. */
186/* Applies to: functions. */ 256/* Applies to: functions. */
187#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST 257#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
188 258
189/* It is OK for a compiler to omit duplicate calls with the same 259/* It is OK for a compiler to move a call, or omit a duplicate call
190 arguments if observable state is not changed between calls. 260 and reuse a cached value returned either directly or indirectly via
191 This attribute is safe for a function that does not affect 261 a pointer, if the state addressed by its pointer arguments is the same;
192 observable state, and always returns exactly once. 262 however, pointer arguments cannot alias.
193 (This attribute is looser than ATTRIBUTE_CONST.) */ 263 This attribute is safe for a function that is effectless, idempotent,
264 stateless, and independent; see ISO C 23 § 6.7.13.8 for a definition of
265 these terms.
266 (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because
267 the function must be stateless and independent. Unlike
268 _GL_ATTRIBUTE_CONST the function need not return exactly once, and
269 can depend on state accessed via its pointer arguments or that
270 happens to have the same value for all calls to the function, but
271 the function cannot return a pointer to storage whose contents
272 change later.)
273 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
274 <https://stackoverflow.com/questions/76847905/>. */
275/* Applies to: functions, pointer to functions, function type. */
276#define UNSEQUENCED _GL_ATTRIBUTE_UNSEQUENCED
277
278/* It is OK for a compiler to move a call, or omit a duplicate call
279 and reuse a cached return value, if observable state is the same.
280 It is also OK to omit a call if the return value is not used.
281 This attribute is safe if the function does not change observable state,
282 returns a value determined solely by its arguments's values
283 together with observable state, and always returns exactly once.
284 (This attribute is looser than _GL_ATTRIBUTE_CONST because the function
285 can depend on observable state.
286 Unlike _GL_ATTRIBUTE_REPRODUCIBLE the function must return exactly
287 once and cannot change state addressed by its arguments, but the
288 function can return a pointer to storage whose contents change later.) */
194/* Applies to: functions. */ 289/* Applies to: functions. */
195#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE 290#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
196 291
292/* It is OK for a compiler to move a call, or omit a duplicate call
293 and reuse a cached value returned either directly or indirectly via
294 a pointer, if other observable state is the same;
295 however, pointer arguments cannot alias.
296 This attribute is safe for a function that is effectless and idempotent;
297 see ISO C 23 § 6.7.13.8 for a definition of these terms.
298 (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because
299 the function need not be stateless or independent.
300 Unlike _GL_ATTRIBUTE_PURE the function need not return exactly once
301 and can change state addressed by its pointer arguments, but the
302 function cannot return a pointer to storage whose contents change later.)
303 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
304 <https://stackoverflow.com/questions/76847905/>. */
305/* Applies to: functions, pointer to functions, function type. */
306#define REPRODUCIBLE _GL_ATTRIBUTE_REPRODUCIBLE
307
197/* The function is rarely executed. */ 308/* The function is rarely executed. */
198/* Applies to: functions. */ 309/* Applies to: functions. */
199#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD 310#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
@@ -223,4 +334,18 @@
223#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS 334#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
224 335
225 336
337/* ==================== Unnamed function parameters ======================== */
338
339/* Although UNNAMED is not an attribute, it is related to MAYBE_UNUSED
340 and so is defined here for convenience. */
341
342/* UNNAMED (ID) is the "name" of an unnamed function parameter.
343 Each of the function's unnamed parameters should have a unique "name".
344 The "name" cannot be used. This ports both to C17 and earlier, which
345 lack unnamed parameters, and to C++ and later C, which have them. */
346/* Applies to:
347 - function parameters. */
348#define UNNAMED(id) _GL_UNNAMED (id)
349
350
226#endif /* _GL_ATTRIBUTE_H */ 351#endif /* _GL_ATTRIBUTE_H */
diff --git a/gl/base64.c b/gl/base64.c
index 95b669aa..77ee371b 100644
--- a/gl/base64.c
+++ b/gl/base64.c
@@ -1,5 +1,5 @@
1/* base64.c -- Encode binary data using printable characters. 1/* base64.c -- Encode binary data using printable characters.
2 Copyright (C) 1999-2001, 2004-2006, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999-2001, 2004-2006, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -39,6 +39,7 @@
39 * 39 *
40 */ 40 */
41 41
42#define BASE64_INLINE _GL_EXTERN_INLINE
42#include <config.h> 43#include <config.h>
43 44
44/* Get prototype. */ 45/* Get prototype. */
@@ -47,10 +48,7 @@
47/* Get imalloc. */ 48/* Get imalloc. */
48#include <ialloc.h> 49#include <ialloc.h>
49 50
50#include <intprops.h> 51#include <stdckdint.h>
51
52/* Get UCHAR_MAX. */
53#include <limits.h>
54 52
55#include <string.h> 53#include <string.h>
56 54
@@ -61,7 +59,7 @@ to_uchar (char ch)
61 return ch; 59 return ch;
62} 60}
63 61
64static const char b64c[64] = 62static const char b64c[64] _GL_ATTRIBUTE_NONSTRING =
65 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 63 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
66 64
67/* Base64 encode IN array of size INLEN into OUT array. OUT needs 65/* Base64 encode IN array of size INLEN into OUT array. OUT needs
@@ -150,7 +148,7 @@ base64_encode_alloc (const char *in, idx_t inlen, char **out)
150 Treat negative INLEN as overflow, for better compatibility with 148 Treat negative INLEN as overflow, for better compatibility with
151 pre-2021-08-27 API, which used size_t. */ 149 pre-2021-08-27 API, which used size_t. */
152 idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen; 150 idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
153 if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0) 151 if (ckd_mul (&outlen, in_over_3, 4) || inlen < 0)
154 { 152 {
155 *out = NULL; 153 *out = NULL;
156 return 0; 154 return 0;
@@ -242,7 +240,7 @@ base64_encode_alloc (const char *in, idx_t inlen, char **out)
242 : (_) == '/' ? 63 \ 240 : (_) == '/' ? 63 \
243 : -1) 241 : -1)
244 242
245static const signed char b64[0x100] = { 243signed char const base64_to_int[256] = {
246 B64 (0), B64 (1), B64 (2), B64 (3), 244 B64 (0), B64 (1), B64 (2), B64 (3),
247 B64 (4), B64 (5), B64 (6), B64 (7), 245 B64 (4), B64 (5), B64 (6), B64 (7),
248 B64 (8), B64 (9), B64 (10), B64 (11), 246 B64 (8), B64 (9), B64 (10), B64 (11),
@@ -309,28 +307,6 @@ static const signed char b64[0x100] = {
309 B64 (252), B64 (253), B64 (254), B64 (255) 307 B64 (252), B64 (253), B64 (254), B64 (255)
310}; 308};
311 309
312#if UCHAR_MAX == 255
313# define uchar_in_range(c) true
314#else
315# define uchar_in_range(c) ((c) <= 255)
316#endif
317
318/* Return true if CH is a character from the Base64 alphabet, and
319 false otherwise. Note that '=' is padding and not considered to be
320 part of the alphabet. */
321bool
322isbase64 (char ch)
323{
324 return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
325}
326
327/* Initialize decode-context buffer, CTX. */
328void
329base64_decode_ctx_init (struct base64_decode_context *ctx)
330{
331 ctx->i = 0;
332}
333
334/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and 310/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and
335 none of those four is a newline, then return *IN. Otherwise, copy up to 311 none of those four is a newline, then return *IN. Otherwise, copy up to
336 4 - CTX->i non-newline bytes from that range into CTX->buf, starting at 312 4 - CTX->i non-newline bytes from that range into CTX->buf, starting at
@@ -396,17 +372,18 @@ static bool
396decode_4 (char const *restrict in, idx_t inlen, 372decode_4 (char const *restrict in, idx_t inlen,
397 char *restrict *outp, idx_t *outleft) 373 char *restrict *outp, idx_t *outleft)
398{ 374{
399 char *out = *outp;
400 if (inlen < 2) 375 if (inlen < 2)
401 return false; 376 return false;
402 377
403 if (!isbase64 (in[0]) || !isbase64 (in[1])) 378 if (!isbase64 (in[0]) || !isbase64 (in[1]))
404 return false; 379 return false;
405 380
381 char *out = *outp;
382
406 if (*outleft) 383 if (*outleft)
407 { 384 {
408 *out++ = ((b64[to_uchar (in[0])] << 2) 385 *out++ = ((base64_to_int[to_uchar (in[0])] << 2)
409 | (b64[to_uchar (in[1])] >> 4)); 386 | (base64_to_int[to_uchar (in[1])] >> 4));
410 --*outleft; 387 --*outleft;
411 } 388 }
412 389
@@ -420,6 +397,10 @@ decode_4 (char const *restrict in, idx_t inlen,
420 397
421 if (in[3] != '=') 398 if (in[3] != '=')
422 return_false; 399 return_false;
400
401 /* Reject non-canonical encodings. */
402 if (base64_to_int[to_uchar (in[1])] & 0x0f)
403 return_false;
423 } 404 }
424 else 405 else
425 { 406 {
@@ -428,8 +409,8 @@ decode_4 (char const *restrict in, idx_t inlen,
428 409
429 if (*outleft) 410 if (*outleft)
430 { 411 {
431 *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) 412 *out++ = (((base64_to_int[to_uchar (in[1])] << 4) & 0xf0)
432 | (b64[to_uchar (in[2])] >> 2)); 413 | (base64_to_int[to_uchar (in[2])] >> 2));
433 --*outleft; 414 --*outleft;
434 } 415 }
435 416
@@ -440,6 +421,10 @@ decode_4 (char const *restrict in, idx_t inlen,
440 { 421 {
441 if (inlen != 4) 422 if (inlen != 4)
442 return_false; 423 return_false;
424
425 /* Reject non-canonical encodings. */
426 if (base64_to_int[to_uchar (in[2])] & 0x03)
427 return_false;
443 } 428 }
444 else 429 else
445 { 430 {
@@ -448,8 +433,8 @@ decode_4 (char const *restrict in, idx_t inlen,
448 433
449 if (*outleft) 434 if (*outleft)
450 { 435 {
451 *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0) 436 *out++ = (((base64_to_int[to_uchar (in[2])] << 6) & 0xc0)
452 | b64[to_uchar (in[3])]); 437 | base64_to_int[to_uchar (in[3])]);
453 --*outleft; 438 --*outleft;
454 } 439 }
455 } 440 }
@@ -482,7 +467,6 @@ base64_decode_ctx (struct base64_decode_context *ctx,
482 const char *restrict in, idx_t inlen, 467 const char *restrict in, idx_t inlen,
483 char *restrict out, idx_t *outlen) 468 char *restrict out, idx_t *outlen)
484{ 469{
485 idx_t outleft = *outlen;
486 bool ignore_newlines = ctx != NULL; 470 bool ignore_newlines = ctx != NULL;
487 bool flush_ctx = false; 471 bool flush_ctx = false;
488 unsigned int ctx_i = 0; 472 unsigned int ctx_i = 0;
@@ -493,6 +477,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
493 flush_ctx = inlen == 0; 477 flush_ctx = inlen == 0;
494 } 478 }
495 479
480 idx_t outleft = *outlen;
496 481
497 while (true) 482 while (true)
498 { 483 {
@@ -521,35 +506,36 @@ base64_decode_ctx (struct base64_decode_context *ctx,
521 { 506 {
522 ++in; 507 ++in;
523 --inlen; 508 --inlen;
524 continue;
525 } 509 }
510 else
511 {
512 /* Restore OUT and OUTLEFT. */
513 out -= outleft_save - outleft;
514 outleft = outleft_save;
526 515
527 /* Restore OUT and OUTLEFT. */
528 out -= outleft_save - outleft;
529 outleft = outleft_save;
530
531 {
532 char const *in_end = in + inlen;
533 char const *non_nl;
534
535 if (ignore_newlines)
536 non_nl = get_4 (ctx, &in, in_end, &inlen);
537 else
538 non_nl = in; /* Might have nl in this case. */
539
540 /* If the input is empty or consists solely of newlines (0 non-newlines),
541 then we're done. Likewise if there are fewer than 4 bytes when not
542 flushing context and not treating newlines as garbage. */
543 if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
544 { 516 {
545 inlen = 0; 517 char const *in_end = in + inlen;
546 break; 518
547 } 519 char const *non_nl;
548 if (!decode_4 (non_nl, inlen, &out, &outleft)) 520 if (ignore_newlines)
549 break; 521 non_nl = get_4 (ctx, &in, in_end, &inlen);
522 else
523 non_nl = in; /* Might have nl in this case. */
524
525 /* If the input is empty or consists solely of newlines (0 non-newlines),
526 then we're done. Likewise if there are fewer than 4 bytes when not
527 flushing context and not treating newlines as garbage. */
528 if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
529 {
530 inlen = 0;
531 break;
532 }
533 if (!decode_4 (non_nl, inlen, &out, &outleft))
534 break;
550 535
551 inlen = in_end - in; 536 inlen = in_end - in;
552 } 537 }
538 }
553 } 539 }
554 540
555 *outlen -= outleft; 541 *outlen -= outleft;
diff --git a/gl/base64.h b/gl/base64.h
index 99137652..35f8a30b 100644
--- a/gl/base64.h
+++ b/gl/base64.h
@@ -1,5 +1,5 @@
1/* base64.h -- Encode binary data using printable characters. 1/* base64.h -- Encode binary data using printable characters.
2 Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2004-2006, 2009-2026 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -16,18 +16,33 @@
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef BASE64_H 18#ifndef BASE64_H
19# define BASE64_H 19#define BASE64_H
20
21/* This file uses _GL_INLINE_HEADER_BEGIN. */
22#if !_GL_CONFIG_H_INCLUDED
23 #error "Please include config.h first."
24#endif
20 25
21/* Get idx_t. */ 26/* Get idx_t. */
22# include <idx.h> 27#include <idx.h>
28
29/* Pacify GCC in isubase64. */
30#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__
31# pragma GCC diagnostic ignored "-Wtype-limits"
32#endif
33
34_GL_INLINE_HEADER_BEGIN
35#ifndef BASE64_INLINE
36# define BASE64_INLINE _GL_INLINE
37#endif
23 38
24# ifdef __cplusplus 39#ifdef __cplusplus
25extern "C" { 40extern "C" {
26# endif 41#endif
27 42
28/* This uses that the expression (n+(k-1))/k means the smallest 43/* This uses that the expression (n+(k-1))/k means the smallest
29 integer >= n/k, i.e., the ceiling of n/k. */ 44 integer >= n/k, i.e., the ceiling of n/k. */
30# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) 45#define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
31 46
32struct base64_decode_context 47struct base64_decode_context
33{ 48{
@@ -35,14 +50,31 @@ struct base64_decode_context
35 char buf[4]; 50 char buf[4];
36}; 51};
37 52
38extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST; 53extern signed char const base64_to_int[256];
54
55BASE64_INLINE bool
56isubase64 (unsigned char ch)
57{
58 return ch < sizeof base64_to_int && 0 <= base64_to_int[ch];
59}
60
61BASE64_INLINE bool
62isbase64 (char ch)
63{
64 return isubase64 (ch);
65}
39 66
40extern void base64_encode (const char *restrict in, idx_t inlen, 67extern void base64_encode (const char *restrict in, idx_t inlen,
41 char *restrict out, idx_t outlen); 68 char *restrict out, idx_t outlen);
42 69
43extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out); 70extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out);
44 71
45extern void base64_decode_ctx_init (struct base64_decode_context *ctx); 72/* Initialize decode-context buffer, CTX. */
73BASE64_INLINE void
74base64_decode_ctx_init (struct base64_decode_context *ctx)
75{
76 ctx->i = 0;
77}
46 78
47extern bool base64_decode_ctx (struct base64_decode_context *ctx, 79extern bool base64_decode_ctx (struct base64_decode_context *ctx,
48 const char *restrict in, idx_t inlen, 80 const char *restrict in, idx_t inlen,
@@ -58,8 +90,10 @@ extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
58#define base64_decode_alloc(in, inlen, out, outlen) \ 90#define base64_decode_alloc(in, inlen, out, outlen) \
59 base64_decode_alloc_ctx (NULL, in, inlen, out, outlen) 91 base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
60 92
61# ifdef __cplusplus 93#ifdef __cplusplus
62} 94}
63# endif 95#endif
96
97_GL_INLINE_HEADER_END
64 98
65#endif /* BASE64_H */ 99#endif /* BASE64_H */
diff --git a/gl/basename-lgpl.c b/gl/basename-lgpl.c
index 6de60aa6..53f3bae5 100644
--- a/gl/basename-lgpl.c
+++ b/gl/basename-lgpl.c
@@ -1,6 +1,6 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -29,13 +29,11 @@ char *
29last_component (char const *name) 29last_component (char const *name)
30{ 30{
31 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); 31 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
32 char const *p;
33 bool last_was_slash = false;
34
35 while (ISSLASH (*base)) 32 while (ISSLASH (*base))
36 base++; 33 base++;
37 34
38 for (p = base; *p; p++) 35 bool last_was_slash = false;
36 for (char const *p = base; *p; p++)
39 { 37 {
40 if (ISSLASH (*p)) 38 if (ISSLASH (*p))
41 last_was_slash = true; 39 last_was_slash = true;
@@ -53,8 +51,6 @@ size_t
53base_len (char const *name) 51base_len (char const *name)
54{ 52{
55 size_t len; 53 size_t len;
56 size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
57
58 for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--) 54 for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
59 continue; 55 continue;
60 56
@@ -62,6 +58,7 @@ base_len (char const *name)
62 && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2]) 58 && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
63 return 2; 59 return 2;
64 60
61 size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
65 if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len 62 if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
66 && len == prefix_len && ISSLASH (name[prefix_len])) 63 && len == prefix_len && ISSLASH (name[prefix_len]))
67 return prefix_len + 1; 64 return prefix_len + 1;
diff --git a/gl/basename-lgpl.h b/gl/basename-lgpl.h
index 5d996c1d..fa43cffb 100644
--- a/gl/basename-lgpl.h
+++ b/gl/basename-lgpl.h
@@ -1,6 +1,6 @@
1/* Extract the last component (base name) of a file name. 1/* Extract the last component (base name) of a file name.
2 2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation, 3 Copyright (C) 1998, 2001, 2003-2006, 2009-2026 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -19,6 +19,11 @@
19#ifndef _BASENAME_LGPL_H 19#ifndef _BASENAME_LGPL_H
20#define _BASENAME_LGPL_H 20#define _BASENAME_LGPL_H
21 21
22/* This file uses _GL_ATTRIBUTE_PURE. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
22#include <stddef.h> 27#include <stddef.h>
23 28
24#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT 29#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
diff --git a/gl/basename.c b/gl/basename.c
index 21fab1ef..3a825981 100644
--- a/gl/basename.c
+++ b/gl/basename.c
@@ -1,6 +1,6 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/gl/btowc.c b/gl/btowc.c
index caadbd76..19b490d1 100644
--- a/gl/btowc.c
+++ b/gl/btowc.c
@@ -1,5 +1,5 @@
1/* Convert unibyte character to wide character. 1/* Convert unibyte character to wide character.
2 Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008, 2010-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -22,6 +22,7 @@
22 22
23#include <stdio.h> 23#include <stdio.h>
24#include <stdlib.h> 24#include <stdlib.h>
25#include <string.h>
25 26
26wint_t 27wint_t
27btowc (int c) 28btowc (int c)
@@ -32,7 +33,14 @@ btowc (int c)
32 wchar_t wc; 33 wchar_t wc;
33 34
34 buf[0] = c; 35 buf[0] = c;
36#if HAVE_MBRTOWC
37 mbstate_t state;
38 mbszero (&state);
39 size_t ret = mbrtowc (&wc, buf, 1, &state);
40 if (!(ret == (size_t)(-1) || ret == (size_t)(-2)))
41#else
35 if (mbtowc (&wc, buf, 1) >= 0) 42 if (mbtowc (&wc, buf, 1) >= 0)
43#endif
36 return wc; 44 return wc;
37 } 45 }
38 return WEOF; 46 return WEOF;
diff --git a/gl/byteswap.c b/gl/byteswap.c
new file mode 100644
index 00000000..e01eaa9a
--- /dev/null
+++ b/gl/byteswap.c
@@ -0,0 +1,20 @@
1/* Inline functions for <byteswap.h>.
2
3 Copyright 2024-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#define _GL_BYTESWAP_INLINE _GL_EXTERN_INLINE
19#include <config.h>
20#include <byteswap.h>
diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h
index e61be27e..b2b26af8 100644
--- a/gl/byteswap.in.h
+++ b/gl/byteswap.in.h
@@ -1,5 +1,5 @@
1/* byteswap.h - Byte swapping 1/* byteswap.h - Byte swapping
2 Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005, 2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005. 3 Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -16,29 +16,103 @@
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _GL_BYTESWAP_H 18#ifndef _GL_BYTESWAP_H
19#define _GL_BYTESWAP_H 19#define _GL_BYTESWAP_H 1
20
21/* This file uses _GL_INLINE. */
22#if !_GL_CONFIG_H_INCLUDED
23 #error "Please include config.h first."
24#endif
25
26/* Define this now, rather than after including stdint.h, in case
27 stdint.h recursively includes us. This is for Gnulib endian.h. */
28#ifndef _GL_BYTESWAP_INLINE
29# define _GL_BYTESWAP_INLINE _GL_INLINE
30#endif
31
32#include <stdint.h>
33
34_GL_INLINE_HEADER_BEGIN
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
41# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP16 true
42#elif defined __has_builtin
43# if __has_builtin (__builtin_bswap16)
44# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP16 true
45# endif
46#endif
47
48#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
49# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP32 true
50# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP64 true
51#elif defined __has_builtin
52# if __has_builtin (__builtin_bswap32)
53# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP32 true
54# endif
55# if __has_builtin (__builtin_bswap64)
56# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP64 true
57# endif
58#endif
20 59
21/* Given an unsigned 16-bit argument X, return the value corresponding to 60/* Given an unsigned 16-bit argument X, return the value corresponding to
22 X with reversed byte order. */ 61 X with reversed byte order. */
23#define bswap_16(x) ((((x) & 0x00FF) << 8) | \ 62_GL_BYTESWAP_INLINE uint_least16_t
24 (((x) & 0xFF00) >> 8)) 63bswap_16 (uint_least16_t x)
64{
65#ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP16
66 return __builtin_bswap16 (x);
67#else
68 uint_fast16_t mask = 0xff;
69 return ( (x & mask << 8 * 1) >> 8 * 1
70 | (x & mask << 8 * 0) << 8 * 1);
71#endif
72}
25 73
26/* Given an unsigned 32-bit argument X, return the value corresponding to 74/* Given an unsigned 32-bit argument X, return the value corresponding to
27 X with reversed byte order. */ 75 X with reversed byte order. */
28#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \ 76_GL_BYTESWAP_INLINE uint_least32_t
29 (((x) & 0x0000FF00) << 8) | \ 77bswap_32 (uint_least32_t x)
30 (((x) & 0x00FF0000) >> 8) | \ 78{
31 (((x) & 0xFF000000) >> 24)) 79#ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP32
80 return __builtin_bswap32 (x);
81#else
82 uint_fast32_t mask = 0xff;
83 return ( (x & mask << 8 * 3) >> 8 * 3
84 | (x & mask << 8 * 2) >> 8 * 1
85 | (x & mask << 8 * 1) << 8 * 1
86 | (x & mask << 8 * 0) << 8 * 3);
87#endif
88}
32 89
90#ifdef UINT_LEAST64_MAX
33/* Given an unsigned 64-bit argument X, return the value corresponding to 91/* Given an unsigned 64-bit argument X, return the value corresponding to
34 X with reversed byte order. */ 92 X with reversed byte order. */
35#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \ 93_GL_BYTESWAP_INLINE uint_least64_t
36 (((x) & 0x000000000000FF00ULL) << 40) | \ 94bswap_64 (uint_least64_t x)
37 (((x) & 0x0000000000FF0000ULL) << 24) | \ 95{
38 (((x) & 0x00000000FF000000ULL) << 8) | \ 96# ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP64
39 (((x) & 0x000000FF00000000ULL) >> 8) | \ 97 return __builtin_bswap64 (x);
40 (((x) & 0x0000FF0000000000ULL) >> 24) | \ 98# else
41 (((x) & 0x00FF000000000000ULL) >> 40) | \ 99 uint_fast64_t mask = 0xff;
42 (((x) & 0xFF00000000000000ULL) >> 56)) 100 return ( (x & mask << 8 * 7) >> 8 * 7
101 | (x & mask << 8 * 6) >> 8 * 5
102 | (x & mask << 8 * 5) >> 8 * 3
103 | (x & mask << 8 * 4) >> 8 * 1
104 | (x & mask << 8 * 3) << 8 * 1
105 | (x & mask << 8 * 2) << 8 * 3
106 | (x & mask << 8 * 1) << 8 * 5
107 | (x & mask << 8 * 0) << 8 * 7);
108# endif
109}
110#endif
111
112#ifdef __cplusplus
113}
114#endif
115
116_GL_INLINE_HEADER_END
43 117
44#endif /* _GL_BYTESWAP_H */ 118#endif /* _GL_BYTESWAP_H */
diff --git a/gl/c++defs.h b/gl/c++defs.h
index 8ad46951..cfe68cb1 100644
--- a/gl/c++defs.h
+++ b/gl/c++defs.h
@@ -1,5 +1,5 @@
1/* C++ compatible function declaration macros. 1/* C++ compatible function declaration macros.
2 Copyright (C) 2010-2023 Free Software Foundation, Inc. 2 Copyright (C) 2010-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published 5 under the terms of the GNU Lesser General Public License as published
@@ -93,27 +93,63 @@
93# define _GL_EXTERN_C extern 93# define _GL_EXTERN_C extern
94#endif 94#endif
95 95
96/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 96/* _GL_EXTERN_C_FUNC declaration;
97 performs the declaration of a function with C linkage. */
98#if defined __cplusplus
99# define _GL_EXTERN_C_FUNC extern "C"
100#else
101/* In C mode, omit the 'extern' keyword, because attributes in bracket syntax
102 are not allowed between 'extern' and the return type (see gnulib-common.m4).
103 */
104# define _GL_EXTERN_C_FUNC
105#endif
106
107/* _GL_FUNCDECL_RPL (func, rettype, parameters, [attributes]);
97 declares a replacement function, named rpl_func, with the given prototype, 108 declares a replacement function, named rpl_func, with the given prototype,
98 consisting of return type, parameters, and attributes. 109 consisting of return type, parameters, and attributes.
99 Example: 110 Although attributes are optional, the comma before them is required
100 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 111 for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
112 if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
113 at the end of the declaration.
114 Examples:
115 _GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
116 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
101 _GL_ARG_NONNULL ((1))); 117 _GL_ARG_NONNULL ((1)));
118
119 Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
120 of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
121 because
122 [[...]] extern "C" <declaration>;
123 is invalid syntax in C++.)
102 */ 124 */
103#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 125#define _GL_FUNCDECL_RPL(func,rettype,parameters,...) \
104 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 126 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters, __VA_ARGS__)
105#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 127#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters,...) \
106 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 128 _GL_EXTERN_C_FUNC __VA_ARGS__ rettype rpl_func parameters
129
130/* _GL_FUNCDECL_SYS_NAME (func) expands to plain func if C++, and to
131 parenthesized func otherwise. Parenthesization is needed in C23 if
132 the function is like strchr and so is a qualifier-generic macro
133 that expands to something more complicated. */
134#ifdef __cplusplus
135# define _GL_FUNCDECL_SYS_NAME(func) func
136#else
137# define _GL_FUNCDECL_SYS_NAME(func) (func)
138#endif
107 139
108/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 140/* _GL_FUNCDECL_SYS (func, rettype, parameters, [attributes]);
109 declares the system function, named func, with the given prototype, 141 declares the system function, named func, with the given prototype,
110 consisting of return type, parameters, and attributes. 142 consisting of return type, parameters, and attributes.
111 Example: 143 Although attributes are optional, the comma before them is required
112 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 144 for portability to C17 and earlier. The attribute _GL_ATTRIBUTE_NOTHROW,
113 _GL_ARG_NONNULL ((1))); 145 if needed, must be placed after the _GL_FUNCDECL_RPL invocation,
146 at the end of the declaration.
147 Examples:
148 _GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
149 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
114 */ 150 */
115#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 151#define _GL_FUNCDECL_SYS(func,rettype,parameters,...) \
116 _GL_EXTERN_C rettype func parameters_and_attributes 152 _GL_EXTERN_C_FUNC __VA_ARGS__ rettype _GL_FUNCDECL_SYS_NAME (func) parameters
117 153
118/* _GL_CXXALIAS_RPL (func, rettype, parameters); 154/* _GL_CXXALIAS_RPL (func, rettype, parameters);
119 declares a C++ alias called GNULIB_NAMESPACE::func 155 declares a C++ alias called GNULIB_NAMESPACE::func
@@ -284,14 +320,14 @@
284 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 320 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
285# define _GL_CXXALIASWARN_1(func,namespace) \ 321# define _GL_CXXALIASWARN_1(func,namespace) \
286 _GL_CXXALIASWARN_2 (func, namespace) 322 _GL_CXXALIASWARN_2 (func, namespace)
287/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 323/* To work around GCC bug <https://gcc.gnu.org/PR43881>,
288 we enable the warning only when not optimizing. */ 324 we enable the warning only when not optimizing. */
289# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 325# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
290# define _GL_CXXALIASWARN_2(func,namespace) \ 326# define _GL_CXXALIASWARN_2(func,namespace) \
291 _GL_WARN_ON_USE (func, \ 327 _GL_WARN_ON_USE (func, \
292 "The symbol ::" #func " refers to the system function. " \ 328 "The symbol ::" #func " refers to the system function. " \
293 "Use " #namespace "::" #func " instead.") 329 "Use " #namespace "::" #func " instead.")
294# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 330# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
295# define _GL_CXXALIASWARN_2(func,namespace) \ 331# define _GL_CXXALIASWARN_2(func,namespace) \
296 extern __typeof__ (func) func 332 extern __typeof__ (func) func
297# else 333# else
@@ -312,7 +348,7 @@
312 GNULIB_NAMESPACE) 348 GNULIB_NAMESPACE)
313# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 349# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
314 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 350 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
315/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 351/* To work around GCC bug <https://gcc.gnu.org/PR43881>,
316 we enable the warning only when not optimizing. */ 352 we enable the warning only when not optimizing. */
317# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 353# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
318# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 354# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
diff --git a/gl/c-ctype.c b/gl/c-ctype.c
new file mode 100644
index 00000000..cd9a205a
--- /dev/null
+++ b/gl/c-ctype.c
@@ -0,0 +1,20 @@
1/* Character handling in C locale.
2
3 Copyright (C) 2003-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#define C_CTYPE_INLINE _GL_EXTERN_INLINE
19#include <config.h>
20#include "c-ctype.h"
diff --git a/gl/c-ctype.h b/gl/c-ctype.h
new file mode 100644
index 00000000..e3448a43
--- /dev/null
+++ b/gl/c-ctype.h
@@ -0,0 +1,366 @@
1/* Character handling in C locale.
2
3 These functions work like the corresponding functions in <ctype.h>,
4 except that they have the C (POSIX) locale hardwired, whereas the
5 <ctype.h> functions' behaviour depends on the current locale set via
6 setlocale.
7
8 Copyright (C) 2000-2003, 2006, 2008-2026 Free Software Foundation, Inc.
9
10 This file is free software: you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as
12 published by the Free Software Foundation; either version 2.1 of the
13 License, or (at your option) any later version.
14
15 This file is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with this program. If not, see <https://www.gnu.org/licenses/>. */
22
23#ifndef C_CTYPE_H
24#define C_CTYPE_H
25
26/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
27#if !_GL_CONFIG_H_INCLUDED
28 #error "Please include config.h first."
29#endif
30
31_GL_INLINE_HEADER_BEGIN
32#ifndef C_CTYPE_INLINE
33# define C_CTYPE_INLINE _GL_INLINE
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40
41/* The functions defined in this file assume the "C" locale and a character
42 set without diacritics (ASCII-US or EBCDIC-US or something like that).
43 Even if the "C" locale on a particular system is an extension of the ASCII
44 character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
45 is ISO-8859-1), the functions in this file recognize only the ASCII
46 characters. */
47
48
49#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
50 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
51 && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
52 && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
53 && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
54 && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
55 && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
56 && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
57 && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
58 && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
59 && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
60 && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
61 && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
62 && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
63 && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
64 && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
65 && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
66 && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
67 && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
68 && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
69 && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
70 && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
71 && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
72/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
73 Testing the value of '\n' and '\r' is not relevant. */
74# define C_CTYPE_ASCII 1
75#elif ! (' ' == '\x40' && '0' == '\xf0' \
76 && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \
77 && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2')
78# error "Only ASCII and EBCDIC are supported"
79#endif
80
81#if 'A' < 0
82# error "EBCDIC and char is signed -- not supported"
83#endif
84
85/* Cases for control characters. */
86
87#define _C_CTYPE_CNTRL \
88 case '\a': case '\b': case '\f': case '\n': \
89 case '\r': case '\t': case '\v': \
90 _C_CTYPE_OTHER_CNTRL
91
92/* ASCII control characters other than those with \-letter escapes. */
93
94#if C_CTYPE_ASCII
95# define _C_CTYPE_OTHER_CNTRL \
96 case '\x00': case '\x01': case '\x02': case '\x03': \
97 case '\x04': case '\x05': case '\x06': case '\x0e': \
98 case '\x0f': case '\x10': case '\x11': case '\x12': \
99 case '\x13': case '\x14': case '\x15': case '\x16': \
100 case '\x17': case '\x18': case '\x19': case '\x1a': \
101 case '\x1b': case '\x1c': case '\x1d': case '\x1e': \
102 case '\x1f': case '\x7f'
103#else
104 /* Use EBCDIC code page 1047's assignments for ASCII control chars;
105 assume all EBCDIC code pages agree about these assignments. */
106# define _C_CTYPE_OTHER_CNTRL \
107 case '\x00': case '\x01': case '\x02': case '\x03': \
108 case '\x07': case '\x0e': case '\x0f': case '\x10': \
109 case '\x11': case '\x12': case '\x13': case '\x18': \
110 case '\x19': case '\x1c': case '\x1d': case '\x1e': \
111 case '\x1f': case '\x26': case '\x27': case '\x2d': \
112 case '\x2e': case '\x32': case '\x37': case '\x3c': \
113 case '\x3d': case '\x3f'
114#endif
115
116/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */
117
118#define _C_CTYPE_LOWER_A_THRU_F_N(N) \
119 case 'a' + (N): case 'b' + (N): case 'c' + (N): case 'd' + (N): \
120 case 'e' + (N): case 'f' + (N)
121#define _C_CTYPE_LOWER_N(N) \
122 _C_CTYPE_LOWER_A_THRU_F_N(N): \
123 case 'g' + (N): case 'h' + (N): case 'i' + (N): case 'j' + (N): \
124 case 'k' + (N): case 'l' + (N): case 'm' + (N): case 'n' + (N): \
125 case 'o' + (N): case 'p' + (N): case 'q' + (N): case 'r' + (N): \
126 case 's' + (N): case 't' + (N): case 'u' + (N): case 'v' + (N): \
127 case 'w' + (N): case 'x' + (N): case 'y' + (N): case 'z' + (N)
128
129/* Cases for hex letters, digits, lower, punct, and upper. */
130
131#define _C_CTYPE_A_THRU_F \
132 _C_CTYPE_LOWER_A_THRU_F_N (0): \
133 _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a')
134#define _C_CTYPE_DIGIT \
135 case '0': case '1': case '2': case '3': \
136 case '4': case '5': case '6': case '7': \
137 case '8': case '9'
138#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0)
139#define _C_CTYPE_PUNCT \
140 case '!': case '"': case '#': case '$': \
141 case '%': case '&': case '\'': case '(': \
142 case ')': case '*': case '+': case ',': \
143 case '-': case '.': case '/': case ':': \
144 case ';': case '<': case '=': case '>': \
145 case '?': case '@': case '[': case '\\': \
146 case ']': case '^': case '_': case '`': \
147 case '{': case '|': case '}': case '~'
148#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a')
149
150
151/* Function definitions. */
152
153/* Unlike the functions in <ctype.h>, which require an argument in the range
154 of the 'unsigned char' type, the functions here operate on values that are
155 in the 'unsigned char' range or in the 'char' range. In other words,
156 when you have a 'char' value, you need to cast it before using it as
157 argument to a <ctype.h> function:
158
159 const char *s = ...;
160 if (isalpha ((unsigned char) *s)) ...
161
162 but you don't need to cast it for the functions defined in this file:
163
164 const char *s = ...;
165 if (c_isalpha (*s)) ...
166 */
167
168C_CTYPE_INLINE bool
169c_isalnum (int c)
170{
171 switch (c)
172 {
173 _C_CTYPE_DIGIT:
174 _C_CTYPE_LOWER:
175 _C_CTYPE_UPPER:
176 return true;
177 default:
178 return false;
179 }
180}
181
182C_CTYPE_INLINE bool
183c_isalpha (int c)
184{
185 switch (c)
186 {
187 _C_CTYPE_LOWER:
188 _C_CTYPE_UPPER:
189 return true;
190 default:
191 return false;
192 }
193}
194
195/* The function isascii is not locale dependent.
196 Its use in EBCDIC is questionable. */
197C_CTYPE_INLINE bool
198c_isascii (int c)
199{
200 switch (c)
201 {
202 case ' ':
203 _C_CTYPE_CNTRL:
204 _C_CTYPE_DIGIT:
205 _C_CTYPE_LOWER:
206 _C_CTYPE_PUNCT:
207 _C_CTYPE_UPPER:
208 return true;
209 default:
210 return false;
211 }
212}
213
214C_CTYPE_INLINE bool
215c_isblank (int c)
216{
217 return c == ' ' || c == '\t';
218}
219
220C_CTYPE_INLINE bool
221c_iscntrl (int c)
222{
223 switch (c)
224 {
225 _C_CTYPE_CNTRL:
226 return true;
227 default:
228 return false;
229 }
230}
231
232C_CTYPE_INLINE bool
233c_isdigit (int c)
234{
235 switch (c)
236 {
237 _C_CTYPE_DIGIT:
238 return true;
239 default:
240 return false;
241 }
242}
243
244C_CTYPE_INLINE bool
245c_isgraph (int c)
246{
247 switch (c)
248 {
249 _C_CTYPE_DIGIT:
250 _C_CTYPE_LOWER:
251 _C_CTYPE_PUNCT:
252 _C_CTYPE_UPPER:
253 return true;
254 default:
255 return false;
256 }
257}
258
259C_CTYPE_INLINE bool
260c_islower (int c)
261{
262 switch (c)
263 {
264 _C_CTYPE_LOWER:
265 return true;
266 default:
267 return false;
268 }
269}
270
271C_CTYPE_INLINE bool
272c_isprint (int c)
273{
274 switch (c)
275 {
276 case ' ':
277 _C_CTYPE_DIGIT:
278 _C_CTYPE_LOWER:
279 _C_CTYPE_PUNCT:
280 _C_CTYPE_UPPER:
281 return true;
282 default:
283 return false;
284 }
285}
286
287C_CTYPE_INLINE bool
288c_ispunct (int c)
289{
290 switch (c)
291 {
292 _C_CTYPE_PUNCT:
293 return true;
294 default:
295 return false;
296 }
297}
298
299C_CTYPE_INLINE bool
300c_isspace (int c)
301{
302 switch (c)
303 {
304 case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
305 return true;
306 default:
307 return false;
308 }
309}
310
311C_CTYPE_INLINE bool
312c_isupper (int c)
313{
314 switch (c)
315 {
316 _C_CTYPE_UPPER:
317 return true;
318 default:
319 return false;
320 }
321}
322
323C_CTYPE_INLINE bool
324c_isxdigit (int c)
325{
326 switch (c)
327 {
328 _C_CTYPE_DIGIT:
329 _C_CTYPE_A_THRU_F:
330 return true;
331 default:
332 return false;
333 }
334}
335
336C_CTYPE_INLINE int
337c_tolower (int c)
338{
339 switch (c)
340 {
341 _C_CTYPE_UPPER:
342 return c - 'A' + 'a';
343 default:
344 return c;
345 }
346}
347
348C_CTYPE_INLINE int
349c_toupper (int c)
350{
351 switch (c)
352 {
353 _C_CTYPE_LOWER:
354 return c - 'a' + 'A';
355 default:
356 return c;
357 }
358}
359
360#ifdef __cplusplus
361}
362#endif
363
364_GL_INLINE_HEADER_END
365
366#endif /* C_CTYPE_H */
diff --git a/gl/c32is-impl.h b/gl/c32is-impl.h
new file mode 100644
index 00000000..7fa79291
--- /dev/null
+++ b/gl/c32is-impl.h
@@ -0,0 +1,105 @@
1/* Test whether a 32-bit wide character belongs to a specific character class.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
18
19#include <wchar.h>
20#include <wctype.h>
21
22#ifdef __CYGWIN__
23# include <cygwin/version.h>
24#endif
25
26#if GNULIB_defined_mbstate_t
27# include "localcharset.h"
28# include "streq.h"
29#endif
30
31#if GL_CHAR32_T_IS_UNICODE
32# include "lc-charset-unicode.h"
33#endif
34
35#include "unictype.h"
36
37#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
38_GL_EXTERN_INLINE
39#endif
40int
41FUNC (wint_t wc)
42{
43 /* The char32_t encoding of a multibyte character is defined by the way
44 mbrtoc32() is defined. */
45
46#if GNULIB_defined_mbstate_t /* AIX */
47 /* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
48 and directly for the UTF-8 locales. */
49 if (wc != WEOF)
50 {
51 const char *encoding = locale_charset ();
52 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
53 return UCS_FUNC (wc);
54 else
55 return WCHAR_FUNC (wc);
56 }
57 else
58 return 0;
59
60#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
61 /* mbrtoc32() is essentially defined by the system libc. */
62
63# if _GL_WCHAR_T_IS_UCS4
64 /* The char32_t encoding of a multibyte character is known to be the same as
65 the wchar_t encoding. */
66 return WCHAR_FUNC (wc);
67# else
68 /* The char32_t encoding of a multibyte character is known to be UCS-4,
69 different from the wchar_t encoding. */
70 if (wc != WEOF)
71 return UCS_FUNC (wc);
72 else
73 return 0;
74# endif
75
76#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
77 /* The wchar_t encoding is UTF-16.
78 The char32_t encoding is UCS-4. */
79
80# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007
81 /* As an extension to POSIX, the iswalnum() function of Cygwin >= 1.7
82 supports also wc arguments outside the Unicode BMP, that is, outside
83 the 'wchar_t' range. See
84 <https://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00019.html>
85 = <https://cygwin.com/ml/cygwin/2011-02/msg00044.html>. */
86 return WCHAR_FUNC (wc);
87# else
88 if (wc == WEOF || wc == (wchar_t) wc)
89 /* wc is in the range for the isw* functions. */
90 return WCHAR_FUNC (wc);
91 else
92 return UCS_FUNC (wc);
93# endif
94
95#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
96 /* char32_t and wchar_t are equivalent. */
97 static_assert (sizeof (char32_t) == sizeof (wchar_t));
98
99# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
100 return UCS_FUNC (wc);
101# else
102 return WCHAR_FUNC (wc);
103# endif
104#endif
105}
diff --git a/gl/c32isalnum.c b/gl/c32isalnum.c
new file mode 100644
index 00000000..0972d5be
--- /dev/null
+++ b/gl/c32isalnum.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being alphanumeric.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISALNUM
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isalnum
24#define WCHAR_FUNC iswalnum
25#define UCS_FUNC uc_is_alnum
26#include "c32is-impl.h"
diff --git a/gl/c32isalpha.c b/gl/c32isalpha.c
new file mode 100644
index 00000000..1dde246d
--- /dev/null
+++ b/gl/c32isalpha.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being alphabetic.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISALPHA
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isalpha
24#define WCHAR_FUNC iswalpha
25#define UCS_FUNC uc_is_alpha
26#include "c32is-impl.h"
diff --git a/gl/c32isblank.c b/gl/c32isblank.c
new file mode 100644
index 00000000..36f21ec1
--- /dev/null
+++ b/gl/c32isblank.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being blank.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISBLANK
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isblank
24#define WCHAR_FUNC iswblank
25#define UCS_FUNC uc_is_blank
26#include "c32is-impl.h"
diff --git a/gl/c32iscntrl.c b/gl/c32iscntrl.c
new file mode 100644
index 00000000..dcb32705
--- /dev/null
+++ b/gl/c32iscntrl.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being a control character.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISCNTRL
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32iscntrl
24#define WCHAR_FUNC iswcntrl
25#define UCS_FUNC uc_is_cntrl
26#include "c32is-impl.h"
diff --git a/gl/c32isdigit.c b/gl/c32isdigit.c
new file mode 100644
index 00000000..96374718
--- /dev/null
+++ b/gl/c32isdigit.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being a digit.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISDIGIT
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isdigit
24#define WCHAR_FUNC iswdigit
25#define UCS_FUNC uc_is_digit
26#include "c32is-impl.h"
diff --git a/gl/c32isgraph.c b/gl/c32isgraph.c
new file mode 100644
index 00000000..f660ceba
--- /dev/null
+++ b/gl/c32isgraph.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being graphic.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISGRAPH
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isgraph
24#define WCHAR_FUNC iswgraph
25#define UCS_FUNC uc_is_graph
26#include "c32is-impl.h"
diff --git a/gl/c32islower.c b/gl/c32islower.c
new file mode 100644
index 00000000..98abb8a2
--- /dev/null
+++ b/gl/c32islower.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being lowercase.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISLOWER
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32islower
24#define WCHAR_FUNC iswlower
25#define UCS_FUNC uc_is_lower
26#include "c32is-impl.h"
diff --git a/gl/c32isprint.c b/gl/c32isprint.c
new file mode 100644
index 00000000..72975751
--- /dev/null
+++ b/gl/c32isprint.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being printable.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISPRINT
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isprint
24#define WCHAR_FUNC iswprint
25#define UCS_FUNC uc_is_print
26#include "c32is-impl.h"
diff --git a/gl/c32ispunct.c b/gl/c32ispunct.c
new file mode 100644
index 00000000..1945c6c5
--- /dev/null
+++ b/gl/c32ispunct.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being a punctuation or symbol character.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISPUNCT
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32ispunct
24#define WCHAR_FUNC iswpunct
25#define UCS_FUNC uc_is_punct
26#include "c32is-impl.h"
diff --git a/gl/c32isspace.c b/gl/c32isspace.c
new file mode 100644
index 00000000..58e2a02a
--- /dev/null
+++ b/gl/c32isspace.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being white-space.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISSPACE
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isspace
24#define WCHAR_FUNC iswspace
25#define UCS_FUNC uc_is_space
26#include "c32is-impl.h"
diff --git a/gl/c32isupper.c b/gl/c32isupper.c
new file mode 100644
index 00000000..29558234
--- /dev/null
+++ b/gl/c32isupper.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being uppercase.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISUPPER
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isupper
24#define WCHAR_FUNC iswupper
25#define UCS_FUNC uc_is_upper
26#include "c32is-impl.h"
diff --git a/gl/c32isxdigit.c b/gl/c32isxdigit.c
new file mode 100644
index 00000000..c9262b58
--- /dev/null
+++ b/gl/c32isxdigit.c
@@ -0,0 +1,26 @@
1/* Test 32-bit wide character for being a hexadecimal digit.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32ISXDIGIT
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32isxdigit
24#define WCHAR_FUNC iswxdigit
25#define UCS_FUNC uc_is_xdigit
26#include "c32is-impl.h"
diff --git a/gl/c32to-impl.h b/gl/c32to-impl.h
new file mode 100644
index 00000000..2528e51d
--- /dev/null
+++ b/gl/c32to-impl.h
@@ -0,0 +1,103 @@
1/* Case mapping of a 32-bit wide character.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
18
19#include <wchar.h>
20#include <wctype.h>
21
22#if GNULIB_defined_mbstate_t
23# include "localcharset.h"
24# include "streq.h"
25#endif
26
27#if GL_CHAR32_T_IS_UNICODE
28# include "lc-charset-unicode.h"
29#endif
30
31#include "unicase.h"
32
33#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
34_GL_EXTERN_INLINE
35#endif
36wint_t
37FUNC (wint_t wc)
38{
39 /* The char32_t encoding of a multibyte character is defined by the way
40 mbrtoc32() is defined. */
41
42#if GNULIB_defined_mbstate_t /* AIX */
43 /* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
44 and directly for the UTF-8 locales. */
45 if (wc != WEOF)
46 {
47 const char *encoding = locale_charset ();
48 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
49 return UCS_FUNC (wc);
50 else
51 return WCHAR_FUNC (wc);
52 }
53 else
54 return wc;
55
56#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
57 /* mbrtoc32() is essentially defined by the system libc. */
58
59# if _GL_WCHAR_T_IS_UCS4
60 /* The char32_t encoding of a multibyte character is known to be the same as
61 the wchar_t encoding. */
62 return WCHAR_FUNC (wc);
63# else
64 /* The char32_t encoding of a multibyte character is known to be UCS-4,
65 different from the wchar_t encoding. */
66 if (wc != WEOF)
67 return UCS_FUNC (wc);
68 else
69 return wc;
70# endif
71
72#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
73 /* The wchar_t encoding is UTF-16.
74 The char32_t encoding is UCS-4. */
75
76# if defined _WIN32 && !defined __CYGWIN__
77 /* On native Windows, in the UTF-8 locale, towlower and towupper are
78 lacking (at least) the mappings for ISO-8859-1 characters, such as
79 0x00C9 <-> 0x00E9. Since it is expensive to test whether the locale
80 encoding is UTF-8, ignore the system's WCHAR_FUNC altogether. */
81 if (wc != WEOF)
82 return UCS_FUNC (wc);
83 else
84 return wc;
85# else
86 if (wc == WEOF || wc == (wchar_t) wc)
87 /* wc is in the range for the tow* functions. */
88 return WCHAR_FUNC (wc);
89 else
90 return UCS_FUNC (wc);
91# endif
92
93#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
94 /* char32_t and wchar_t are equivalent. */
95 static_assert (sizeof (char32_t) == sizeof (wchar_t));
96
97# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
98 return UCS_FUNC (wc);
99# else
100 return WCHAR_FUNC (wc);
101# endif
102#endif
103}
diff --git a/gl/c32tolower.c b/gl/c32tolower.c
new file mode 100644
index 00000000..15608d88
--- /dev/null
+++ b/gl/c32tolower.c
@@ -0,0 +1,26 @@
1/* Map a 32-bit wide character to lowercase.
2 Copyright (C) 2023-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19#define IN_C32TOLOWER
20/* Specification. */
21#include <uchar.h>
22
23#define FUNC c32tolower
24#define WCHAR_FUNC towlower
25#define UCS_FUNC uc_tolower
26#include "c32to-impl.h"
diff --git a/gl/c32width.c b/gl/c32width.c
new file mode 100644
index 00000000..727c2bd3
--- /dev/null
+++ b/gl/c32width.c
@@ -0,0 +1,102 @@
1/* Determine the number of screen columns needed for a 32-bit wide character.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
18
19#include <config.h>
20
21#define IN_C32WIDTH
22/* Specification. */
23#include <uchar.h>
24
25#include <wchar.h>
26
27#ifdef __CYGWIN__
28# include <cygwin/version.h>
29#endif
30
31#if GNULIB_defined_mbstate_t
32# include "streq.h"
33#endif
34
35#include "localcharset.h"
36
37#if GL_CHAR32_T_IS_UNICODE
38# include "lc-charset-unicode.h"
39#endif
40
41#include "uniwidth.h"
42
43#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
44_GL_EXTERN_INLINE
45#endif
46int
47c32width (char32_t wc)
48{
49 /* The char32_t encoding of a multibyte character is defined by the way
50 mbrtoc32() is defined. */
51
52#if GNULIB_defined_mbstate_t /* AIX */
53 /* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
54 and directly for the UTF-8 locales. */
55 const char *encoding = locale_charset ();
56 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
57 return uc_width (wc, encoding);
58 else
59 return wcwidth (wc);
60
61#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
62 /* mbrtoc32() is essentially defined by the system libc. */
63
64# if _GL_WCHAR_T_IS_UCS4
65 /* The char32_t encoding of a multibyte character is known to be the same as
66 the wchar_t encoding. */
67 return wcwidth (wc);
68# else
69 /* The char32_t encoding of a multibyte character is known to be UCS-4,
70 different from the wchar_t encoding. */
71 return uc_width (wc, locale_charset ());
72# endif
73
74#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
75 /* The wchar_t encoding is UTF-16.
76 The char32_t encoding is UCS-4. */
77
78# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007 && 0
79 /* As an extension to POSIX, the wcwidth() function of Cygwin >= 1.7
80 supports also wc arguments outside the Unicode BMP, that is, outside
81 the 'wchar_t' range. See
82 <https://www.cygwin.com/cgit/newlib-cygwin/commit/?id=098a75dc51caa98f369d98a9809d773bc45329aa>.
83 But the resulting values for these characters are not of good quality. */
84 return wcwidth (wc);
85# else
86 if (wc == (wchar_t) wc)
87 /* wc is in the range for the wcwidth function. */
88 return wcwidth (wc);
89 else
90 return uc_width (wc, locale_charset ());
91# endif
92
93#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
94 /* char32_t and wchar_t are equivalent. */
95 static_assert (sizeof (char32_t) == sizeof (wchar_t));
96
97# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
98 return uc_width (wc, locale_charset ());
99# endif
100 return wcwidth (wc);
101#endif
102}
diff --git a/gl/calloc.c b/gl/calloc.c
index 08843acd..b4ca8f89 100644
--- a/gl/calloc.c
+++ b/gl/calloc.c
@@ -1,6 +1,6 @@
1/* calloc() function that is glibc compatible. 1/* calloc() function that is glibc compatible.
2 This wrapper function is required at least on Tru64 UNIX 5.1 and mingw. 2 This wrapper function is required at least on mingw.
3 Copyright (C) 2004-2007, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2004-2007, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -17,17 +17,15 @@
17 17
18/* written by Jim Meyering and Bruno Haible */ 18/* written by Jim Meyering and Bruno Haible */
19 19
20/* Ensure that we call the system's calloc() below. */
21#define _GL_USE_STDLIB_ALLOC 1
20#include <config.h> 22#include <config.h>
21 23
22/* Specification. */ 24/* Specification. */
23#include <stdlib.h> 25#include <stdlib.h>
24 26
25#include <errno.h> 27#include <errno.h>
26 28#include <stdckdint.h>
27#include "xalloc-oversized.h"
28
29/* Call the system's calloc below. */
30#undef calloc
31 29
32/* Allocate and zero-fill an NxS-byte block of memory from the heap, 30/* Allocate and zero-fill an NxS-byte block of memory from the heap,
33 even if N or S is zero. */ 31 even if N or S is zero. */
@@ -35,14 +33,19 @@
35void * 33void *
36rpl_calloc (size_t n, size_t s) 34rpl_calloc (size_t n, size_t s)
37{ 35{
36#if !HAVE_MALLOC_0_NONNULL
38 if (n == 0 || s == 0) 37 if (n == 0 || s == 0)
39 n = s = 1; 38 n = s = 1;
39#endif
40 40
41 if (xalloc_oversized (n, s)) 41#if !HAVE_MALLOC_PTRDIFF
42 ptrdiff_t signed_n;
43 if (ckd_mul (&signed_n, n, s))
42 { 44 {
43 errno = ENOMEM; 45 errno = ENOMEM;
44 return NULL; 46 return NULL;
45 } 47 }
48#endif
46 49
47 void *result = calloc (n, s); 50 void *result = calloc (n, s);
48 51
diff --git a/gl/cdefs.h b/gl/cdefs.h
index 09a3d19b..696e6542 100644
--- a/gl/cdefs.h
+++ b/gl/cdefs.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2023 Free Software Foundation, Inc. 1/* Copyright (C) 1992-2026 Free Software Foundation, Inc.
2 Copyright The GNU Toolchain Authors. 2 Copyright The GNU Toolchain Authors.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
@@ -42,8 +42,8 @@
42#if (defined __has_attribute \ 42#if (defined __has_attribute \
43 && (!defined __clang_minor__ \ 43 && (!defined __clang_minor__ \
44 || (defined __apple_build_version__ \ 44 || (defined __apple_build_version__ \
45 ? 6000000 <= __apple_build_version__ \ 45 ? 7000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__)))) 46 : 5 <= __clang_major__)))
47# define __glibc_has_attribute(attr) __has_attribute (attr) 47# define __glibc_has_attribute(attr) __has_attribute (attr)
48#else 48#else
49# define __glibc_has_attribute(attr) 0 49# define __glibc_has_attribute(attr) 0
@@ -83,7 +83,7 @@
83# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct 83# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
84# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct 84# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
85# else 85# else
86# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4) 86# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
87# if __cplusplus >= 201103L 87# if __cplusplus >= 201103L
88# define __THROW noexcept (true) 88# define __THROW noexcept (true)
89# else 89# else
@@ -140,32 +140,37 @@
140#endif 140#endif
141 141
142 142
143/* Gnulib avoids these definitions, as they don't work on non-glibc platforms.
144 In particular, __bos and __bos0 are defined differently in the Android libc.
145 */
146#ifndef __GNULIB_CDEFS
147
143/* Fortify support. */ 148/* Fortify support. */
144#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) 149# define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
145#define __bos0(ptr) __builtin_object_size (ptr, 0) 150# define __bos0(ptr) __builtin_object_size (ptr, 0)
146 151
147/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ 152/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
148#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ 153# if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
149 || __GNUC_PREREQ (12, 0)) 154 || __GNUC_PREREQ (12, 0))
150# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) 155# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
151# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) 156# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
152#else 157# else
153# define __glibc_objsize0(__o) __bos0 (__o) 158# define __glibc_objsize0(__o) __bos0 (__o)
154# define __glibc_objsize(__o) __bos (__o) 159# define __glibc_objsize(__o) __bos (__o)
155#endif 160# endif
156 161
157/* Compile time conditions to choose between the regular, _chk and _chk_warn 162/* Compile time conditions to choose between the regular, _chk and _chk_warn
158 variants. These conditions should get evaluated to constant and optimized 163 variants. These conditions should get evaluated to constant and optimized
159 away. */ 164 away. */
160 165
161#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) 166# define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
162#define __glibc_unsigned_or_positive(__l) \ 167# define __glibc_unsigned_or_positive(__l) \
163 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \ 168 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
164 || (__builtin_constant_p (__l) && (__l) > 0)) 169 || (__builtin_constant_p (__l) && (__l) > 0))
165 170
166/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ 171/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
167 condition can be folded to a constant and if it is true, or unknown (-1) */ 172 condition can be folded to a constant and if it is true, or unknown (-1) */
168#define __glibc_safe_or_unknown_len(__l, __s, __osz) \ 173# define __glibc_safe_or_unknown_len(__l, __s, __osz) \
169 ((__osz) == (__SIZE_TYPE__) -1 \ 174 ((__osz) == (__SIZE_TYPE__) -1 \
170 || (__glibc_unsigned_or_positive (__l) \ 175 || (__glibc_unsigned_or_positive (__l) \
171 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ 176 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
@@ -175,7 +180,7 @@
175/* Conversely, we know at compile time that the length is unsafe if the 180/* Conversely, we know at compile time that the length is unsafe if the
176 __L * __S <= __OBJSZ condition can be folded to a constant and if it is 181 __L * __S <= __OBJSZ condition can be folded to a constant and if it is
177 false. */ 182 false. */
178#define __glibc_unsafe_len(__l, __s, __osz) \ 183# define __glibc_unsafe_len(__l, __s, __osz) \
179 (__glibc_unsigned_or_positive (__l) \ 184 (__glibc_unsigned_or_positive (__l) \
180 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ 185 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
181 __s, __osz)) \ 186 __s, __osz)) \
@@ -184,7 +189,7 @@
184/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be 189/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
185 declared. */ 190 declared. */
186 191
187#define __glibc_fortify(f, __l, __s, __osz, ...) \ 192# define __glibc_fortify(f, __l, __s, __osz, ...) \
188 (__glibc_safe_or_unknown_len (__l, __s, __osz) \ 193 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
189 ? __ ## f ## _alias (__VA_ARGS__) \ 194 ? __ ## f ## _alias (__VA_ARGS__) \
190 : (__glibc_unsafe_len (__l, __s, __osz) \ 195 : (__glibc_unsafe_len (__l, __s, __osz) \
@@ -194,13 +199,16 @@
194/* Fortify function f, where object size argument passed to f is the number of 199/* Fortify function f, where object size argument passed to f is the number of
195 elements and not total size. */ 200 elements and not total size. */
196 201
197#define __glibc_fortify_n(f, __l, __s, __osz, ...) \ 202# define __glibc_fortify_n(f, __l, __s, __osz, ...) \
198 (__glibc_safe_or_unknown_len (__l, __s, __osz) \ 203 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
199 ? __ ## f ## _alias (__VA_ARGS__) \ 204 ? __ ## f ## _alias (__VA_ARGS__) \
200 : (__glibc_unsafe_len (__l, __s, __osz) \ 205 : (__glibc_unsafe_len (__l, __s, __osz) \
201 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ 206 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
202 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \ 207 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
203 208
209#endif
210
211
204#if __GNUC_PREREQ (4,3) 212#if __GNUC_PREREQ (4,3)
205# define __warnattr(msg) __attribute__((__warning__ (msg))) 213# define __warnattr(msg) __attribute__((__warning__ (msg)))
206# define __errordecl(name, msg) \ 214# define __errordecl(name, msg) \
@@ -269,10 +277,10 @@
269*/ 277*/
270#endif 278#endif
271 279
272/* GCC and clang have various useful declarations that can be made with 280/* GCC, clang, and compatible compilers have various useful declarations
273 the '__attribute__' syntax. All of the ways we use this do fine if 281 that can be made with the '__attribute__' syntax. All of the ways we use
274 they are omitted for compilers that don't understand it. */ 282 this do fine if they are omitted for compilers that don't understand it. */
275#if !(defined __GNUC__ || defined __clang__) 283#if !(defined __GNUC__ || defined __clang__ || defined __TINYC__)
276# define __attribute__(xyz) /* Ignore */ 284# define __attribute__(xyz) /* Ignore */
277#endif 285#endif
278 286
@@ -474,7 +482,7 @@
474 run in pedantic mode if the uses are carefully marked using the 482 run in pedantic mode if the uses are carefully marked using the
475 `__extension__' keyword. But this is not generally available before 483 `__extension__' keyword. But this is not generally available before
476 version 2.8. */ 484 version 2.8. */
477#if !(__GNUC_PREREQ (2,8) || defined __clang__) 485#if ! (__GNUC_PREREQ (2,8) || defined __clang__ || 0x5150 <= __SUNPRO_C)
478# define __extension__ /* Ignore */ 486# define __extension__ /* Ignore */
479#endif 487#endif
480 488
@@ -489,7 +497,7 @@
489# endif 497# endif
490#endif 498#endif
491 499
492/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is 500/* ISO C99 also allows declaring arrays as non-overlapping. The syntax is
493 array_name[restrict] 501 array_name[restrict]
494 GCC 3.1 and clang support this. 502 GCC 3.1 and clang support this.
495 This syntax is not usable in C++ mode. */ 503 This syntax is not usable in C++ mode. */
diff --git a/gl/cloexec.c b/gl/cloexec.c
index e4cecbd2..3d4f916b 100644
--- a/gl/cloexec.c
+++ b/gl/cloexec.c
@@ -1,6 +1,6 @@
1/* cloexec.c - set or clear the close-on-exec descriptor flag 1/* cloexec.c - set or clear the close-on-exec descriptor flag
2 2
3 Copyright (C) 1991, 2004-2006, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 1991, 2004-2006, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/cloexec.h b/gl/cloexec.h
index 057fd668..3716bd72 100644
--- a/gl/cloexec.h
+++ b/gl/cloexec.h
@@ -1,6 +1,6 @@
1/* cloexec.c - set or clear the close-on-exec descriptor flag 1/* cloexec.c - set or clear the close-on-exec descriptor flag
2 2
3 Copyright (C) 2004, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,6 +15,11 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
18/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, 23/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
19 or clear the flag if VALUE is false. 24 or clear the flag if VALUE is false.
20 Return 0 on success, or -1 on error with 'errno' set. 25 Return 0 on success, or -1 on error with 'errno' set.
@@ -32,3 +37,8 @@ int set_cloexec_flag (int desc, bool value);
32 be duplicated. */ 37 be duplicated. */
33 38
34int dup_cloexec (int fd); 39int dup_cloexec (int fd);
40
41
42#ifdef __cplusplus
43}
44#endif
diff --git a/gl/close.c b/gl/close.c
index 3c1b09ea..86ccdf9a 100644
--- a/gl/close.c
+++ b/gl/close.c
@@ -1,5 +1,5 @@
1/* close replacement. 1/* close replacement.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/dirname-lgpl.c b/gl/dirname-lgpl.c
index e9454af3..9f772e0f 100644
--- a/gl/dirname-lgpl.c
+++ b/gl/dirname-lgpl.c
@@ -1,6 +1,6 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -32,7 +32,6 @@ size_t
32dir_len (char const *file) 32dir_len (char const *file)
33{ 33{
34 size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file); 34 size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
35 size_t length;
36 35
37 /* Advance prefix_length beyond important leading slashes. */ 36 /* Advance prefix_length beyond important leading slashes. */
38 prefix_length += (prefix_length != 0 37 prefix_length += (prefix_length != 0
@@ -45,8 +44,10 @@ dir_len (char const *file)
45 : 0)); 44 : 0));
46 45
47 /* Strip the basename and any redundant slashes before it. */ 46 /* Strip the basename and any redundant slashes before it. */
47 size_t length;
48 for (length = last_component (file) - file; 48 for (length = last_component (file) - file;
49 prefix_length < length; length--) 49 prefix_length < length;
50 length--)
50 if (! ISSLASH (file[length - 1])) 51 if (! ISSLASH (file[length - 1]))
51 break; 52 break;
52 return length; 53 return length;
diff --git a/gl/dirname.c b/gl/dirname.c
index e72f7130..a67c7593 100644
--- a/gl/dirname.c
+++ b/gl/dirname.c
@@ -1,6 +1,6 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
diff --git a/gl/dirname.h b/gl/dirname.h
index f98e83bd..8ecbb9e6 100644
--- a/gl/dirname.h
+++ b/gl/dirname.h
@@ -1,6 +1,6 @@
1/* Take file names apart into directory and base names. 1/* Take file names apart into directory and base names.
2 2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation, 3 Copyright (C) 1998, 2001, 2003-2006, 2009-2026 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -19,6 +19,12 @@
19#ifndef DIRNAME_H_ 19#ifndef DIRNAME_H_
20# define DIRNAME_H_ 1 20# define DIRNAME_H_ 1
21 21
22/* This file uses _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_PURE,
23 _GL_ATTRIBUTE_RETURNS_NONNULL. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
22# include <stdlib.h> 28# include <stdlib.h>
23# include "filename.h" 29# include "filename.h"
24# include "basename-lgpl.h" 30# include "basename-lgpl.h"
diff --git a/gl/dup2.c b/gl/dup2.c
index 7d197ca3..b9a55263 100644
--- a/gl/dup2.c
+++ b/gl/dup2.c
@@ -1,6 +1,6 @@
1/* Duplicate an open file descriptor to a specified file descriptor. 1/* Duplicate an open file descriptor to a specified file descriptor.
2 2
3 Copyright (C) 1999, 2004-2007, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 1999, 2004-2007, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -70,8 +70,6 @@ dup2_nothrow (int fd, int desired_fd)
70static int 70static int
71ms_windows_dup2 (int fd, int desired_fd) 71ms_windows_dup2 (int fd, int desired_fd)
72{ 72{
73 int result;
74
75 /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open, 73 /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
76 dup2 (fd, fd) returns 0, but all further attempts to use fd in 74 dup2 (fd, fd) returns 0, but all further attempts to use fd in
77 future dup2 calls will hang. */ 75 future dup2 calls will hang. */
@@ -93,7 +91,7 @@ ms_windows_dup2 (int fd, int desired_fd)
93 return -1; 91 return -1;
94 } 92 }
95 93
96 result = dup2_nothrow (fd, desired_fd); 94 int result = dup2_nothrow (fd, desired_fd);
97 95
98 if (result == 0) 96 if (result == 0)
99 result = desired_fd; 97 result = desired_fd;
@@ -110,14 +108,11 @@ ms_windows_dup2 (int fd, int desired_fd)
110static int 108static int
111klibc_dup2dirfd (int fd, int desired_fd) 109klibc_dup2dirfd (int fd, int desired_fd)
112{ 110{
113 int tempfd; 111 int tempfd = open ("NUL", O_RDONLY);
114 int dupfd; 112 if (tempfd < 0)
115 113 return tempfd;
116 tempfd = open ("NUL", O_RDONLY);
117 if (tempfd == -1)
118 return -1;
119 114
120 if (tempfd == desired_fd) 115 if (tempfd >= desired_fd)
121 { 116 {
122 close (tempfd); 117 close (tempfd);
123 118
@@ -125,10 +120,32 @@ klibc_dup2dirfd (int fd, int desired_fd)
125 if (__libc_Back_ioFHToPath (fd, path, sizeof (path))) 120 if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
126 return -1; 121 return -1;
127 122
128 return open(path, O_RDONLY); 123 for (;;)
124 {
125 close (desired_fd);
126
127 int dupfd = open (path, O_RDONLY);
128 if (dupfd < 0)
129 return dupfd;
130
131 if (dupfd == desired_fd)
132 return dupfd;
133
134 /* If lower FD was closed by other threads, fill again. */
135 if (dupfd < desired_fd)
136 {
137 tempfd = dupfd;
138 break;
139 }
140
141 /* desired_fd was opened by other threads. Try again. */
142 /* FIXME: Closing desired_fd opened by other threads may lead to
143 unexpected behavior. */
144 close (dupfd);
145 }
129 } 146 }
130 147
131 dupfd = klibc_dup2dirfd (fd, desired_fd); 148 int dupfd = klibc_dup2dirfd (fd, desired_fd);
132 149
133 close (tempfd); 150 close (tempfd);
134 151
@@ -138,16 +155,16 @@ klibc_dup2dirfd (int fd, int desired_fd)
138static int 155static int
139klibc_dup2 (int fd, int desired_fd) 156klibc_dup2 (int fd, int desired_fd)
140{ 157{
141 int dupfd; 158 int dupfd = dup2 (fd, desired_fd);
142 struct stat sbuf; 159 if (dupfd < 0 && errno == ENOTSUP)
143
144 dupfd = dup2 (fd, desired_fd);
145 if (dupfd == -1 && errno == ENOTSUP \
146 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
147 { 160 {
148 close (desired_fd); 161 struct stat sbuf;
162 if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
163 {
164 close (desired_fd);
149 165
150 return klibc_dup2dirfd (fd, desired_fd); 166 return klibc_dup2dirfd (fd, desired_fd);
167 }
151 } 168 }
152 169
153 return dupfd; 170 return dupfd;
@@ -159,8 +176,6 @@ klibc_dup2 (int fd, int desired_fd)
159int 176int
160rpl_dup2 (int fd, int desired_fd) 177rpl_dup2 (int fd, int desired_fd)
161{ 178{
162 int result;
163
164#ifdef F_GETFL 179#ifdef F_GETFL
165 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. 180 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
166 On Cygwin 1.5.x, dup2 (1, 1) returns 0. 181 On Cygwin 1.5.x, dup2 (1, 1) returns 0.
@@ -176,13 +191,14 @@ rpl_dup2 (int fd, int desired_fd)
176 return fcntl (fd, F_GETFL) == -1 ? -1 : fd; 191 return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
177#endif 192#endif
178 193
179 result = dup2 (fd, desired_fd); 194 int result = dup2 (fd, desired_fd);
180 195
181 /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */ 196 /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
182 if (result == -1 && errno == EMFILE) 197 if (result < 0 && errno == EMFILE)
183 errno = EBADF; 198 errno = EBADF;
199
184#if REPLACE_FCHDIR 200#if REPLACE_FCHDIR
185 if (fd != desired_fd && result != -1) 201 if (! (result < 0 || fd == desired_fd))
186 result = _gl_register_dup (fd, result); 202 result = _gl_register_dup (fd, result);
187#endif 203#endif
188 return result; 204 return result;
diff --git a/gl/dynarray.h b/gl/dynarray.h
index 91559109..a5cdf630 100644
--- a/gl/dynarray.h
+++ b/gl/dynarray.h
@@ -1,5 +1,5 @@
1/* Type-safe arrays which grow dynamically. 1/* Type-safe arrays which grow dynamically.
2 Copyright 2021-2023 Free Software Foundation, Inc. 2 Copyright 2021-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/errno.in.h b/gl/errno.in.h
index 3dda9c26..784a4018 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -1,6 +1,6 @@
1/* A POSIX-like <errno.h>. 1/* A POSIX-like <errno.h>.
2 2
3 Copyright (C) 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -133,7 +133,7 @@
133 133
134/* These are intentionally the same values as the WSA* error numbers, defined 134/* These are intentionally the same values as the WSA* error numbers, defined
135 in <winsock2.h>. */ 135 in <winsock2.h>. */
136# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */ 136# define ESOCKTNOSUPPORT 10044
137# define EPFNOSUPPORT 10046 /* not required by POSIX */ 137# define EPFNOSUPPORT 10046 /* not required by POSIX */
138# define ESHUTDOWN 10058 /* not required by POSIX */ 138# define ESHUTDOWN 10058 /* not required by POSIX */
139# define ETOOMANYREFS 10059 /* not required by POSIX */ 139# define ETOOMANYREFS 10059 /* not required by POSIX */
@@ -148,27 +148,11 @@
148# endif 148# endif
149 149
150 150
151/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
152 EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */
153# if @EMULTIHOP_HIDDEN@
154# define EMULTIHOP @EMULTIHOP_VALUE@
155# define GNULIB_defined_EMULTIHOP 1
156# endif
157# if @ENOLINK_HIDDEN@
158# define ENOLINK @ENOLINK_VALUE@
159# define GNULIB_defined_ENOLINK 1
160# endif
161# if @EOVERFLOW_HIDDEN@
162# define EOVERFLOW @EOVERFLOW_VALUE@
163# define GNULIB_defined_EOVERFLOW 1
164# endif
165
166
167/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, 151/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
168 EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. 152 EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
169 Likewise, on NonStop Kernel, EDQUOT is not defined. 153 Likewise, on NonStop Kernel, EDQUOT is not defined.
170 Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, 154 Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
171 HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. 155 HP-UX EWOULDBLOCK = 246.
172 156
173 Note: When one of these systems defines some of these macros some day, 157 Note: When one of these systems defines some of these macros some day,
174 binaries will have to be recompiled so that they recognizes the new 158 binaries will have to be recompiled so that they recognizes the new
@@ -270,10 +254,17 @@
270# define GNULIB_defined_ENOTRECOVERABLE 1 254# define GNULIB_defined_ENOTRECOVERABLE 1
271# endif 255# endif
272 256
257/* On LynxOS, the macro EILSEQ is not defined. */
273# ifndef EILSEQ 258# ifndef EILSEQ
274# define EILSEQ 2015 259# define EILSEQ 2015
275# define GNULIB_defined_EILSEQ 1 260# define GNULIB_defined_EILSEQ 1
276# endif 261# endif
277 262
263/* On Haiku, the macro ESOCKTNOSUPPORT is not defined. */
264# ifndef ESOCKTNOSUPPORT
265# define ESOCKTNOSUPPORT 2016
266# define GNULIB_defined_ESOCKTNOSUPPORT 1
267# endif
268
278#endif /* _@GUARD_PREFIX@_ERRNO_H */ 269#endif /* _@GUARD_PREFIX@_ERRNO_H */
279#endif /* _@GUARD_PREFIX@_ERRNO_H */ 270#endif /* _@GUARD_PREFIX@_ERRNO_H */
diff --git a/gl/error.c b/gl/error.c
index 6875f134..e066241b 100644
--- a/gl/error.c
+++ b/gl/error.c
@@ -1,27 +1,35 @@
1/* Error handler for noninteractive utilities 1/* Error handler for noninteractive utilities
2 Copyright (C) 1990-1998, 2000-2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 1990-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This file is free software: you can redistribute it and/or modify 5 The GNU C Library is free software; you can redistribute it and/or
6 it under the terms of the GNU Lesser General Public License as 6 modify it under the terms of the GNU Lesser General Public
7 published by the Free Software Foundation; either version 2.1 of the 7 License as published by the Free Software Foundation; either
8 License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 GNU Lesser General Public License for more details. 13 Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
17 18
18/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ 19/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
19 20
20#if !_LIBC 21#if !_LIBC
21# include <config.h> 22# include <config.h>
23# define _GL_NO_INLINE_ERROR
24# define __error_internal(status, err, fmt, args, flags) \
25 verror (status, err, fmt, args)
26# define __error_at_line_internal(status, err, file, line, fmt, args, flags) \
27 verror_at_line (status, err, file, line, fmt, args)
28# define error_tail(status, err, fmt, args, flags) \
29 error_tail (status, err, fmt, args)
22#endif 30#endif
23 31
24#include "error.h" 32#include <error.h>
25 33
26#include <stdarg.h> 34#include <stdarg.h>
27#include <stdio.h> 35#include <stdio.h>
@@ -30,7 +38,7 @@
30 38
31#if !_LIBC && ENABLE_NLS 39#if !_LIBC && ENABLE_NLS
32# include "gettext.h" 40# include "gettext.h"
33# define _(msgid) gettext (msgid) 41# define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
34#endif 42#endif
35 43
36#ifdef _LIBC 44#ifdef _LIBC
@@ -42,8 +50,6 @@
42# define USE_UNLOCKED_IO 0 50# define USE_UNLOCKED_IO 0
43# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b) 51# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
44# define _GL_ARG_NONNULL(a) 52# define _GL_ARG_NONNULL(a)
45#else
46# include "getprogname.h"
47#endif 53#endif
48 54
49#if USE_UNLOCKED_IO 55#if USE_UNLOCKED_IO
@@ -86,7 +92,7 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
86# undef putc 92# undef putc
87# define putc(c, fp) _IO_putc (c, fp) 93# define putc(c, fp) _IO_putc (c, fp)
88 94
89# include <bits/libc-lock.h> 95# include <libc-lock.h>
90 96
91#else /* not _LIBC */ 97#else /* not _LIBC */
92 98
@@ -124,6 +130,13 @@ int strerror_r (int errnum, char *buf, size_t buflen);
124# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r 130# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
125# define __strerror_r strerror_r 131# define __strerror_r strerror_r
126# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */ 132# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
133
134# if GNULIB_defined_verror
135# undef verror
136# endif
137# if GNULIB_defined_verror_at_line
138# undef verror_at_line
139# endif
127#endif /* not _LIBC */ 140#endif /* not _LIBC */
128 141
129#if !_LIBC 142#if !_LIBC
@@ -152,8 +165,8 @@ flush_stdout (void)
152#if !_LIBC 165#if !_LIBC
153 int stdout_fd; 166 int stdout_fd;
154 167
155# if GNULIB_FREOPEN_SAFER 168# if GNULIB_FREOPEN_SAFER || GNULIB_XSTDOPEN
156 /* Use of gnulib's freopen-safer module normally ensures that 169 /* Gnulib's freopen-safer and/or xstdopen modules normally ensure that
157 fileno (stdout) == 1 170 fileno (stdout) == 1
158 whenever stdout is open. */ 171 whenever stdout is open. */
159 stdout_fd = STDOUT_FILENO; 172 stdout_fd = STDOUT_FILENO;
@@ -184,7 +197,7 @@ print_errno_message (int errnum)
184 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) 197 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
185 s = errbuf; 198 s = errbuf;
186 else 199 else
187 s = 0; 200 s = NULL;
188# endif 201# endif
189#else 202#else
190 s = strerror (errnum); 203 s = strerror (errnum);
@@ -203,75 +216,18 @@ print_errno_message (int errnum)
203} 216}
204 217
205static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3)) 218static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
206error_tail (int status, int errnum, const char *message, va_list args) 219error_tail (int status, int errnum, const char *message, va_list args,
220 unsigned int mode_flags)
207{ 221{
208#if _LIBC 222#if _LIBC
209 if (_IO_fwide (stderr, 0) > 0) 223 int ret = __vfxprintf (stderr, message, args, mode_flags);
210 { 224 if (ret < 0 && errno == ENOMEM && _IO_fwide (stderr, 0) > 0)
211 size_t len = strlen (message) + 1; 225 /* Leave a trace in case the heap allocation of the message string
212 wchar_t *wmessage = NULL; 226 failed. */
213 mbstate_t st; 227 fputws_unlocked (L"out of memory\n", stderr);
214 size_t res; 228#else
215 const char *tmp; 229 vfprintf (stderr, message, args);
216 bool use_malloc = false;
217
218 while (1)
219 {
220 if (__libc_use_alloca (len * sizeof (wchar_t)))
221 wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
222 else
223 {
224 if (!use_malloc)
225 wmessage = NULL;
226
227 wchar_t *p = (wchar_t *) realloc (wmessage,
228 len * sizeof (wchar_t));
229 if (p == NULL)
230 {
231 free (wmessage);
232 fputws_unlocked (L"out of memory\n", stderr);
233 return;
234 }
235 wmessage = p;
236 use_malloc = true;
237 }
238
239 memset (&st, '\0', sizeof (st));
240 tmp = message;
241
242 res = mbsrtowcs (wmessage, &tmp, len, &st);
243 if (res != len)
244 break;
245
246 if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
247 {
248 /* This really should not happen if everything is fine. */
249 res = (size_t) -1;
250 break;
251 }
252
253 len *= 2;
254 }
255
256 if (res == (size_t) -1)
257 {
258 /* The string cannot be converted. */
259 if (use_malloc)
260 {
261 free (wmessage);
262 use_malloc = false;
263 }
264 wmessage = (wchar_t *) L"???";
265 }
266
267 __vfwprintf (stderr, wmessage, args);
268
269 if (use_malloc)
270 free (wmessage);
271 }
272 else
273#endif 230#endif
274 vfprintf (stderr, message, args);
275 231
276 ++error_message_count; 232 ++error_message_count;
277 if (errnum) 233 if (errnum)
@@ -292,16 +248,14 @@ error_tail (int status, int errnum, const char *message, va_list args)
292 If ERRNUM is nonzero, print its corresponding system error message. 248 If ERRNUM is nonzero, print its corresponding system error message.
293 Exit with status STATUS if it is nonzero. */ 249 Exit with status STATUS if it is nonzero. */
294void 250void
295error (int status, int errnum, const char *message, ...) 251__error_internal (int status, int errnum, const char *message,
252 va_list args, unsigned int mode_flags)
296{ 253{
297 va_list args; 254#if defined _LIBC
298
299#if defined _LIBC && defined __libc_ptf_call
300 /* We do not want this call to be cut short by a thread 255 /* We do not want this call to be cut short by a thread
301 cancellation. Therefore disable cancellation for now. */ 256 cancellation. Therefore disable cancellation for now. */
302 int state = PTHREAD_CANCEL_ENABLE; 257 int state = PTHREAD_CANCEL_ENABLE;
303 __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), 258 __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
304 0);
305#endif 259#endif
306 260
307 flush_stdout (); 261 flush_stdout ();
@@ -319,28 +273,32 @@ error (int status, int errnum, const char *message, ...)
319#endif 273#endif
320 } 274 }
321 275
322 va_start (args, message); 276 error_tail (status, errnum, message, args, mode_flags);
323 error_tail (status, errnum, message, args);
324 va_end (args);
325 277
326#ifdef _LIBC 278#ifdef _LIBC
327 _IO_funlockfile (stderr); 279 _IO_funlockfile (stderr);
328# ifdef __libc_ptf_call 280 __pthread_setcancelstate (state, NULL);
329 __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
330# endif
331#endif 281#endif
332} 282}
283
284void
285error (int status, int errnum, const char *message, ...)
286{
287 va_list ap;
288 va_start (ap, message);
289 __error_internal (status, errnum, message, ap, 0);
290 va_end (ap);
291}
333 292
334/* Sometimes we want to have at most one error per line. This 293/* Sometimes we want to have at most one error per line. This
335 variable controls whether this mode is selected or not. */ 294 variable controls whether this mode is selected or not. */
336int error_one_per_line; 295int error_one_per_line;
337 296
338void 297void
339error_at_line (int status, int errnum, const char *file_name, 298__error_at_line_internal (int status, int errnum, const char *file_name,
340 unsigned int line_number, const char *message, ...) 299 unsigned int line_number, const char *message,
300 va_list args, unsigned int mode_flags)
341{ 301{
342 va_list args;
343
344 if (error_one_per_line) 302 if (error_one_per_line)
345 { 303 {
346 static const char *old_file_name; 304 static const char *old_file_name;
@@ -359,12 +317,11 @@ error_at_line (int status, int errnum, const char *file_name,
359 old_line_number = line_number; 317 old_line_number = line_number;
360 } 318 }
361 319
362#if defined _LIBC && defined __libc_ptf_call 320#if defined _LIBC
363 /* We do not want this call to be cut short by a thread 321 /* We do not want this call to be cut short by a thread
364 cancellation. Therefore disable cancellation for now. */ 322 cancellation. Therefore disable cancellation for now. */
365 int state = PTHREAD_CANCEL_ENABLE; 323 int state = PTHREAD_CANCEL_ENABLE;
366 __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), 324 __pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
367 0);
368#endif 325#endif
369 326
370 flush_stdout (); 327 flush_stdout ();
@@ -390,18 +347,25 @@ error_at_line (int status, int errnum, const char *file_name,
390 file_name, line_number); 347 file_name, line_number);
391#endif 348#endif
392 349
393 va_start (args, message); 350 error_tail (status, errnum, message, args, mode_flags);
394 error_tail (status, errnum, message, args);
395 va_end (args);
396 351
397#ifdef _LIBC 352#ifdef _LIBC
398 _IO_funlockfile (stderr); 353 _IO_funlockfile (stderr);
399# ifdef __libc_ptf_call 354 __pthread_setcancelstate (state, NULL);
400 __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
401# endif
402#endif 355#endif
403} 356}
404 357
358void
359error_at_line (int status, int errnum, const char *file_name,
360 unsigned int line_number, const char *message, ...)
361{
362 va_list ap;
363 va_start (ap, message);
364 __error_at_line_internal (status, errnum, file_name, line_number,
365 message, ap, 0);
366 va_end (ap);
367}
368
405#ifdef _LIBC 369#ifdef _LIBC
406/* Make the weak alias. */ 370/* Make the weak alias. */
407# undef error 371# undef error
diff --git a/gl/error.h b/gl/error.h
deleted file mode 100644
index a240526a..00000000
--- a/gl/error.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/* Declaration for error-reporting function
2 Copyright (C) 1995-1997, 2003, 2006, 2008-2023 Free Software Foundation,
3 Inc.
4 This file is part of the GNU C Library.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef _ERROR_H
20#define _ERROR_H 1
21
22/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
23#include <stdio.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/* Print a message with 'fprintf (stderr, FORMAT, ...)';
30 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
31 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
32
33extern void error (int __status, int __errnum, const char *__format, ...)
34#if GNULIB_VFPRINTF_POSIX
35 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4))
36#else
37 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 3, 4))
38#endif
39 ;
40
41extern void error_at_line (int __status, int __errnum, const char *__fname,
42 unsigned int __lineno, const char *__format, ...)
43#if GNULIB_VFPRINTF_POSIX
44 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 6))
45#else
46 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 5, 6))
47#endif
48 ;
49
50/* If NULL, error will flush stdout, then print on stderr the program
51 name, a colon and a space. Otherwise, error will call this
52 function without parameters instead. */
53extern void (*error_print_progname) (void);
54
55/* This variable is incremented each time 'error' is called. */
56extern unsigned int error_message_count;
57
58/* Sometimes we want to have at most one error per line. This
59 variable controls whether this mode is selected or not. */
60extern int error_one_per_line;
61
62#ifdef __cplusplus
63}
64#endif
65
66#endif /* error.h */
diff --git a/gl/error.in.h b/gl/error.in.h
new file mode 100644
index 00000000..3355fb3b
--- /dev/null
+++ b/gl/error.in.h
@@ -0,0 +1,261 @@
1/* Declarations for error-reporting functions.
2 Copyright (C) 1995-1997, 2003, 2006, 2008-2026 Free Software Foundation,
3 Inc.
4 This file is part of the GNU C Library.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef _@GUARD_PREFIX@_ERROR_H
20
21/* No @PRAGMA_SYSTEM_HEADER@ here, because it would prevent
22 -Wimplicit-fallthrough warnings for missing FALLTHROUGH after error(...)
23 or error_at_line(...) invocations. */
24
25/* The include_next requires a split double-inclusion guard. */
26#if @HAVE_ERROR_H@ && !defined __MINGW32__
27# @INCLUDE_NEXT@ @NEXT_ERROR_H@
28#endif
29
30#ifndef _@GUARD_PREFIX@_ERROR_H
31#define _@GUARD_PREFIX@_ERROR_H
32
33/* This file uses _GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_COLD,
34 _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_MAYBE_UNUSED. */
35#if !_GL_CONFIG_H_INCLUDED
36 #error "Please include config.h first."
37#endif
38
39/* Get va_list. */
40#include <stdarg.h>
41
42/* Get 'gl_unreachable'. */
43#include <stddef.h>
44
45/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
46#include <stdio.h>
47
48/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
49
50#if GNULIB_VFPRINTF_POSIX
51# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
52#else
53# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM
54#endif
55
56/* Helper macro for supporting the compiler's control flow analysis better.
57 It evaluates its arguments only once.
58 Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */
59#if defined __GNUC__ || defined __clang__
60/* Use 'gl_unreachable' to tell the compiler when the function call does not
61 return. */
62# define __gl_error_call1(function, status, ...) \
63 ((function) (status, __VA_ARGS__), \
64 (status) != 0 ? gl_unreachable () : (void) 0)
65/* If STATUS is a not a constant, the function call may or may not return;
66 therefore -Wimplicit-fallthrough will produce a warning. Use a compound
67 statement in order to evaluate STATUS only once.
68 If STATUS is a constant, we don't use a compound statement, because that
69 would trigger a -Wimplicit-fallthrough warning even when STATUS is != 0,
70 when not optimizing. This causes STATUS to be evaluated twice, but
71 that's OK since it does not have side effects. */
72# define __gl_error_call(function, status, ...) \
73 (__builtin_constant_p (status) \
74 ? __gl_error_call1 (function, status, __VA_ARGS__) \
75 : __extension__ \
76 ({ \
77 int const __errstatus = status; \
78 __gl_error_call1 (function, __errstatus, __VA_ARGS__); \
79 }))
80#else
81# define __gl_error_call(function, status, ...) \
82 (function) (status, __VA_ARGS__)
83#endif
84
85#ifdef __cplusplus
86extern "C" {
87#endif
88
89/* Print a message with 'fprintf (stderr, FORMAT, ...)';
90 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
91 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
92#if @REPLACE_ERROR@
93# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
94# undef error
95# define error rpl_error
96# endif
97_GL_FUNCDECL_RPL (error, void,
98 (int __status, int __errnum, const char *__format, ...),
99 _GL_ATTRIBUTE_COLD
100 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
101_GL_CXXALIAS_RPL (error, void,
102 (int __status, int __errnum, const char *__format, ...));
103# ifndef _GL_NO_INLINE_ERROR
104# undef error
105# define error(status, ...) \
106 __gl_error_call (rpl_error, status, __VA_ARGS__)
107# endif
108#else
109# if ! @HAVE_ERROR@
110_GL_FUNCDECL_SYS (error, void,
111 (int __status, int __errnum, const char *__format, ...),
112 _GL_ATTRIBUTE_COLD
113 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
114# endif
115_GL_CXXALIAS_SYS (error, void,
116 (int __status, int __errnum, const char *__format, ...));
117# ifndef _GL_NO_INLINE_ERROR
118# ifdef error
119/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */
120# if _GL_GNUC_PREREQ (4, 7)
121# pragma GCC diagnostic push
122# pragma GCC diagnostic ignored "-Wattributes"
123_GL_ATTRIBUTE_MAYBE_UNUSED
124static void
125_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
126_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4))
127_gl_inline_error (int __status, int __errnum, const char *__format, ...)
128{
129 return error (__status, __errnum, __format, __builtin_va_arg_pack ());
130}
131# pragma GCC diagnostic pop
132# undef error
133# define error(status, ...) \
134 __gl_error_call (_gl_inline_error, status, __VA_ARGS__)
135# endif
136# else
137# define error(status, ...) \
138 __gl_error_call (error, status, __VA_ARGS__)
139# endif
140# endif
141#endif
142#if __GLIBC__ >= 2
143_GL_CXXALIASWARN (error);
144#endif
145
146/* Likewise. If FILENAME is non-NULL, include FILENAME:LINENO: in the
147 message. */
148#if @REPLACE_ERROR_AT_LINE@
149# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
150# undef error_at_line
151# define error_at_line rpl_error_at_line
152# endif
153_GL_FUNCDECL_RPL (error_at_line, void,
154 (int __status, int __errnum, const char *__filename,
155 unsigned int __lineno, const char *__format, ...),
156 _GL_ATTRIBUTE_COLD
157 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
158_GL_CXXALIAS_RPL (error_at_line, void,
159 (int __status, int __errnum, const char *__filename,
160 unsigned int __lineno, const char *__format, ...));
161# ifndef _GL_NO_INLINE_ERROR
162# undef error_at_line
163# define error_at_line(status, ...) \
164 __gl_error_call (rpl_error_at_line, status, __VA_ARGS__)
165# endif
166#else
167# if ! @HAVE_ERROR_AT_LINE@
168_GL_FUNCDECL_SYS (error_at_line, void,
169 (int __status, int __errnum, const char *__filename,
170 unsigned int __lineno, const char *__format, ...),
171 _GL_ATTRIBUTE_COLD
172 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
173# endif
174_GL_CXXALIAS_SYS (error_at_line, void,
175 (int __status, int __errnum, const char *__filename,
176 unsigned int __lineno, const char *__format, ...));
177# ifndef _GL_NO_INLINE_ERROR
178# ifdef error_at_line
179/* Only gcc ≥ 4.7 has __builtin_va_arg_pack. */
180# if _GL_GNUC_PREREQ (4, 7)
181# pragma GCC diagnostic push
182# pragma GCC diagnostic ignored "-Wattributes"
183_GL_ATTRIBUTE_MAYBE_UNUSED
184static void
185_GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
186_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6))
187_gl_inline_error_at_line (int __status, int __errnum, const char *__filename,
188 unsigned int __lineno, const char *__format, ...)
189{
190 return error_at_line (__status, __errnum, __filename, __lineno, __format,
191 __builtin_va_arg_pack ());
192}
193# pragma GCC diagnostic pop
194# undef error_at_line
195# define error_at_line(status, ...) \
196 __gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__)
197# endif
198# else
199# define error_at_line(status, ...) \
200 __gl_error_call (error_at_line, status, __VA_ARGS__)
201# endif
202# endif
203#endif
204_GL_CXXALIASWARN (error_at_line);
205
206/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
207 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
208 If STATUS is nonzero, terminate the program with 'exit (STATUS)'.
209 Use the globals error_print_progname and error_message_count similarly
210 to error(). */
211
212extern void verror (int __status, int __errnum, const char *__format,
213 va_list __args)
214 _GL_ATTRIBUTE_COLD
215 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
216#ifndef _GL_NO_INLINE_ERROR
217# ifndef verror
218# define verror(status, ...) \
219 __gl_error_call (verror, status, __VA_ARGS__)
220# define GNULIB_defined_verror 1
221# endif
222#endif
223
224/* Print a message with 'vfprintf (stderr, FORMAT, ARGS)';
225 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
226 If STATUS is nonzero, terminate the program with 'exit (STATUS)'.
227 If FNAME is not NULL, prepend the message with "FNAME:LINENO:".
228 Use the globals error_print_progname, error_message_count, and
229 error_one_per_line similarly to error_at_line(). */
230
231extern void verror_at_line (int __status, int __errnum, const char *__fname,
232 unsigned int __lineno, const char *__format,
233 va_list __args)
234 _GL_ATTRIBUTE_COLD
235 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0));
236#ifdef _GL_NO_INLINE_ERROR
237# ifndef verror_at_line
238# define verror_at_line(status, ...) \
239 __gl_error_call (verror_at_line, status, __VA_ARGS__)
240# define GNULIB_defined_verror_at_line 1
241# endif
242#endif
243
244/* If NULL, error will flush stdout, then print on stderr the program
245 name, a colon and a space. Otherwise, error will call this
246 function without parameters instead. */
247extern void (*error_print_progname) (void);
248
249/* This variable is incremented each time 'error' is called. */
250extern unsigned int error_message_count;
251
252/* Sometimes we want to have at most one error per line. This
253 variable controls whether this mode is selected or not. */
254extern int error_one_per_line;
255
256#ifdef __cplusplus
257}
258#endif
259
260#endif /* _@GUARD_PREFIX@_ERROR_H */
261#endif /* _@GUARD_PREFIX@_ERROR_H */
diff --git a/gl/exitfail.c b/gl/exitfail.c
index d67a130c..148468b7 100644
--- a/gl/exitfail.c
+++ b/gl/exitfail.c
@@ -1,6 +1,6 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2005-2007, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/exitfail.h b/gl/exitfail.h
index 85a6af64..64e2aa33 100644
--- a/gl/exitfail.h
+++ b/gl/exitfail.h
@@ -1,6 +1,6 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,4 +15,14 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
18extern int volatile exit_failure; 23extern int volatile exit_failure;
24
25
26#ifdef __cplusplus
27}
28#endif
diff --git a/gl/fcntl.c b/gl/fcntl.c
index e2208008..1c0e52d2 100644
--- a/gl/fcntl.c
+++ b/gl/fcntl.c
@@ -1,6 +1,6 @@
1/* Provide file descriptor control. 1/* Provide file descriptor control.
2 2
3 Copyright (C) 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -29,8 +29,8 @@
29#include <unistd.h> 29#include <unistd.h>
30 30
31#ifdef __KLIBC__ 31#ifdef __KLIBC__
32# define INCL_DOS 32# include <emx/io.h>
33# include <os2.h> 33# include <InnoTekLIBC/backend.h>
34#endif 34#endif
35 35
36#if defined _WIN32 && ! defined __CYGWIN__ 36#if defined _WIN32 && ! defined __CYGWIN__
@@ -56,19 +56,15 @@ dupfd (int oldfd, int newfd, int flags)
56{ 56{
57 /* Mingw has no way to create an arbitrary fd. Iterate until all 57 /* Mingw has no way to create an arbitrary fd. Iterate until all
58 file descriptors less than newfd are filled up. */ 58 file descriptors less than newfd are filled up. */
59 HANDLE curr_process = GetCurrentProcess ();
60 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
61 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
62 unsigned int fds_to_close_bound = 0;
63 int result;
64 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
65 int mode;
66 59
67 if (newfd < 0 || getdtablesize () <= newfd) 60 if (newfd < 0 || getdtablesize () <= newfd)
68 { 61 {
69 errno = EINVAL; 62 errno = EINVAL;
70 return -1; 63 return -1;
71 } 64 }
65
66 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
67 int mode;
72 if (old_handle == INVALID_HANDLE_VALUE 68 if (old_handle == INVALID_HANDLE_VALUE
73 || (mode = _setmode (oldfd, O_BINARY)) == -1) 69 || (mode = _setmode (oldfd, O_BINARY)) == -1)
74 { 70 {
@@ -80,6 +76,11 @@ dupfd (int oldfd, int newfd, int flags)
80 _setmode (oldfd, mode); 76 _setmode (oldfd, mode);
81 flags |= mode; 77 flags |= mode;
82 78
79 HANDLE curr_process = GetCurrentProcess ();
80 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
81 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
82 unsigned int fds_to_close_bound = 0;
83 int result;
83 for (;;) 84 for (;;)
84 { 85 {
85 HANDLE new_handle; 86 HANDLE new_handle;
@@ -146,9 +147,8 @@ dupfd (int oldfd, int newfd, int flags)
146 /* Close the previous fds that turned out to be too small. */ 147 /* Close the previous fds that turned out to be too small. */
147 { 148 {
148 int saved_errno = errno; 149 int saved_errno = errno;
149 unsigned int duplicated_fd;
150 150
151 for (duplicated_fd = 0; 151 for (unsigned int duplicated_fd = 0;
152 duplicated_fd < fds_to_close_bound * CHAR_BIT; 152 duplicated_fd < fds_to_close_bound * CHAR_BIT;
153 duplicated_fd++) 153 duplicated_fd++)
154 if ((fds_to_close[duplicated_fd / CHAR_BIT] 154 if ((fds_to_close[duplicated_fd / CHAR_BIT]
@@ -206,8 +206,9 @@ fcntl (int fd, int action, /* arg */...)
206#endif 206#endif
207{ 207{
208 va_list arg; 208 va_list arg;
209 int result = -1;
210 va_start (arg, action); 209 va_start (arg, action);
210
211 int result = -1;
211 switch (action) 212 switch (action)
212 { 213 {
213 case F_DUPFD: 214 case F_DUPFD:
@@ -376,12 +377,6 @@ fcntl (int fd, int action, /* arg */...)
376 #ifdef F_NOTIFY /* Linux */ 377 #ifdef F_NOTIFY /* Linux */
377 case F_NOTIFY: 378 case F_NOTIFY:
378 #endif 379 #endif
379 #ifdef F_OPLKACK /* IRIX */
380 case F_OPLKACK:
381 #endif
382 #ifdef F_OPLKREG /* IRIX */
383 case F_OPLKREG:
384 #endif
385 #ifdef F_RDAHEAD /* macOS */ 380 #ifdef F_RDAHEAD /* macOS */
386 case F_RDAHEAD: 381 case F_RDAHEAD:
387 #endif 382 #endif
@@ -439,7 +434,9 @@ fcntl (int fd, int action, /* arg */...)
439 break; 434 break;
440 } 435 }
441 } 436 }
437
442 va_end (arg); 438 va_end (arg);
439
443 return result; 440 return result;
444} 441}
445 442
@@ -546,78 +543,115 @@ rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
546#undef fcntl 543#undef fcntl
547 544
548#ifdef __KLIBC__ 545#ifdef __KLIBC__
549
550static int 546static int
551klibc_fcntl (int fd, int action, /* arg */...) 547klibc_dupdirfd (int fd, int minfd)
552{ 548{
553 va_list arg_ptr; 549 int tempfd = open ("NUL", O_RDONLY);
554 int arg; 550 if (tempfd == -1)
555 struct stat sbuf; 551 return -1;
556 int result;
557 552
558 va_start (arg_ptr, action); 553 if (tempfd >= minfd)
559 arg = va_arg (arg_ptr, int);
560 result = fcntl (fd, action, arg);
561 /* EPERM for F_DUPFD, ENOTSUP for others */
562 if (result == -1 && (errno == EPERM || errno == ENOTSUP)
563 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
564 { 554 {
565 ULONG ulMode; 555 close (tempfd);
566 556
567 switch (action) 557 char path[_MAX_PATH];
568 { 558 if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
569 case F_DUPFD: 559 return -1;
570 /* Find available fd */
571 while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
572 arg++;
573 560
574 result = dup2 (fd, arg); 561 int dupfd = open (path, O_RDONLY);
575 break; 562 if (dupfd == -1)
563 return -1;
576 564
577 /* Using underlying APIs is right ? */ 565 if (dupfd >= minfd)
578 case F_GETFD: 566 return dupfd;
579 if (DosQueryFHState (fd, &ulMode))
580 break;
581
582 result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
583 break;
584
585 case F_SETFD:
586 if (arg & ~FD_CLOEXEC)
587 break;
588 567
589 if (DosQueryFHState (fd, &ulMode)) 568 /* Lower FD was closed by other threads. Fill again. */
590 break; 569 tempfd = dupfd;
570 }
591 571
592 if (arg & FD_CLOEXEC) 572 int dupfd = klibc_dupdirfd (fd, minfd);
593 ulMode |= OPEN_FLAGS_NOINHERIT;
594 else
595 ulMode &= ~OPEN_FLAGS_NOINHERIT;
596 573
597 /* Filter supported flags. */ 574 close (tempfd);
598 ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
599 | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
600 575
601 if (DosSetFHState (fd, ulMode)) 576 return dupfd;
602 break; 577}
603
604 result = 0;
605 break;
606 578
607 case F_GETFL: 579static int
608 result = 0; 580klibc_fcntl (int fd, int action, /* arg */...)
609 break; 581{
582 va_list arg_ptr;
583 va_start (arg_ptr, action);
610 584
611 case F_SETFL: 585 int arg = va_arg (arg_ptr, int);
612 if (arg != 0) 586 int result = fcntl (fd, action, arg);
613 break; 587 /* EPERM for F_DUPFD, ENOTSUP for others */
588 if (result == -1 && (errno == EPERM || errno == ENOTSUP))
589 {
590 struct stat sbuf;
591 if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
592 {
593 switch (action)
594 {
595 case F_DUPFD:
596 result = klibc_dupdirfd (fd, arg);
597 break;
598
599 case F_GETFD:
600 {
601 PLIBCFH pFH = __libc_FH (fd);
602 if (!pFH)
603 {
604 errno = EBADF;
605 break;
606 }
607
608 result = (pFH->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT )
609 | O_NOINHERIT)) ? FD_CLOEXEC : 0;
610 }
611 break;
612
613 case F_SETFD:
614 {
615 if (arg & ~FD_CLOEXEC)
616 break;
617
618 PLIBCFH pFH = __libc_FH (fd);
619 if (!pFH)
620 {
621 errno = EBADF;
622 break;
623 }
624
625 unsigned fFlags = pFH->fFlags;
626 if (arg & FD_CLOEXEC)
627 fFlags |= (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT;
628 else
629 fFlags &= ~((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT);
630
631 result = __libc_FHSetFlags (pFH, fd, fFlags);
632 if (result < 0)
633 {
634 errno = -result;
635 result = -1;
636 }
637 }
638 break;
639
640 case F_GETFL:
641 result = 0;
642 break;
643
644 case F_SETFL:
645 if (arg != 0)
646 break;
614 647
615 result = 0; 648 result = 0;
616 break; 649 break;
617 650
618 default: 651 default:
619 errno = EINVAL; 652 errno = EINVAL;
620 break; 653 break;
654 }
621 } 655 }
622 } 656 }
623 657
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
index e034eaf9..52727074 100644
--- a/gl/fcntl.in.h
+++ b/gl/fcntl.in.h
@@ -1,6 +1,6 @@
1/* Like <fcntl.h>, but with non-working flags defined to 0. 1/* Like <fcntl.h>, but with non-working flags defined to 0.
2 2
3 Copyright (C) 2006-2023 Free Software Foundation, Inc. 3 Copyright (C) 2006-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -22,8 +22,12 @@
22#endif 22#endif
23@PRAGMA_COLUMNS@ 23@PRAGMA_COLUMNS@
24 24
25#if defined __need_system_fcntl_h 25#if defined __need_system_fcntl_h || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
26/* Special invocation convention. */ 26/* Special invocation convention:
27 - On Haiku we have a sequence of nested includes
28 <fcntl.h> -> <unistd.h> -> <fcntl.h>
29 In this situation, GNULIB_defined_O_NONBLOCK gets defined before the
30 system's definition of O_NONBLOCK is processed. */
27 31
28/* Needed before <sys/stat.h>. 32/* Needed before <sys/stat.h>.
29 May also define off_t to a 64-bit type on native Windows. */ 33 May also define off_t to a 64-bit type on native Windows. */
@@ -50,8 +54,11 @@
50 54
51#ifndef _@GUARD_PREFIX@_FCNTL_H 55#ifndef _@GUARD_PREFIX@_FCNTL_H
52 56
57#define _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
58
53/* Needed before <sys/stat.h>. 59/* Needed before <sys/stat.h>.
54 May also define off_t to a 64-bit type on native Windows. */ 60 May also define off_t to a 64-bit type on native Windows.
61 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
55#include <sys/types.h> 62#include <sys/types.h>
56/* On some systems other than glibc, <sys/stat.h> is a prerequisite of 63/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
57 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 64 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
@@ -71,9 +78,16 @@
71# include <io.h> 78# include <io.h>
72#endif 79#endif
73 80
81#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H
82
74#ifndef _@GUARD_PREFIX@_FCNTL_H 83#ifndef _@GUARD_PREFIX@_FCNTL_H
75#define _@GUARD_PREFIX@_FCNTL_H 84#define _@GUARD_PREFIX@_FCNTL_H
76 85
86/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
87#if !_GL_CONFIG_H_INCLUDED
88 #error "Please include config.h first."
89#endif
90
77#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 91#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
78# include <unistd.h> 92# include <unistd.h>
79#endif 93#endif
@@ -94,7 +108,7 @@
94# undef creat 108# undef creat
95# define creat rpl_creat 109# define creat rpl_creat
96# endif 110# endif
97_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) 111_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode),
98 _GL_ARG_NONNULL ((1))); 112 _GL_ARG_NONNULL ((1)));
99_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); 113_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
100# elif defined _WIN32 && !defined __CYGWIN__ 114# elif defined _WIN32 && !defined __CYGWIN__
@@ -108,7 +122,6 @@ _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
108# endif 122# endif
109_GL_CXXALIASWARN (creat); 123_GL_CXXALIASWARN (creat);
110#elif defined GNULIB_POSIXCHECK 124#elif defined GNULIB_POSIXCHECK
111# undef creat
112/* Assume creat is always declared. */ 125/* Assume creat is always declared. */
113_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " 126_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
114 "use gnulib module creat for portability"); 127 "use gnulib module creat for portability");
@@ -135,14 +148,14 @@ _GL_CXXALIASWARN (creat);
135# undef fcntl 148# undef fcntl
136# define fcntl rpl_fcntl 149# define fcntl rpl_fcntl
137# endif 150# endif
138_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 151_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...), );
139_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 152_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
140# if !GNULIB_defined_rpl_fcntl 153# if !GNULIB_defined_rpl_fcntl
141# define GNULIB_defined_rpl_fcntl 1 154# define GNULIB_defined_rpl_fcntl 1
142# endif 155# endif
143# else 156# else
144# if !@HAVE_FCNTL@ 157# if !@HAVE_FCNTL@
145_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 158_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...), );
146# if !GNULIB_defined_fcntl 159# if !GNULIB_defined_fcntl
147# define GNULIB_defined_fcntl 1 160# define GNULIB_defined_fcntl 1
148# endif 161# endif
@@ -151,7 +164,6 @@ _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
151# endif 164# endif
152_GL_CXXALIASWARN (fcntl); 165_GL_CXXALIASWARN (fcntl);
153#elif defined GNULIB_POSIXCHECK 166#elif defined GNULIB_POSIXCHECK
154# undef fcntl
155# if HAVE_RAW_DECL_FCNTL 167# if HAVE_RAW_DECL_FCNTL
156_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " 168_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
157 "use gnulib module fcntl for portability"); 169 "use gnulib module fcntl for portability");
@@ -164,7 +176,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
164# undef open 176# undef open
165# define open rpl_open 177# define open rpl_open
166# endif 178# endif
167_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 179_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
168 _GL_ARG_NONNULL ((1))); 180 _GL_ARG_NONNULL ((1)));
169_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 181_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
170# elif defined _WIN32 && !defined __CYGWIN__ 182# elif defined _WIN32 && !defined __CYGWIN__
@@ -182,7 +194,6 @@ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
182_GL_CXXALIASWARN (open); 194_GL_CXXALIASWARN (open);
183# endif 195# endif
184#elif defined GNULIB_POSIXCHECK 196#elif defined GNULIB_POSIXCHECK
185# undef open
186/* Assume open is always declared. */ 197/* Assume open is always declared. */
187_GL_WARN_ON_USE (open, "open is not always POSIX compliant - " 198_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
188 "use gnulib module open for portability"); 199 "use gnulib module open for portability");
@@ -195,7 +206,9 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
195# undef open 206# undef open
196# define open _open 207# define open _open
197# endif 208# endif
198_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 209/* Need to cast, because in MSVC the parameter list of _open as a C++ function
210 is (const char *, int, int = 0). */
211_GL_CXXALIAS_MDA_CAST (open, int, (const char *filename, int flags, ...));
199# else 212# else
200_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 213_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
201# endif 214# endif
@@ -211,14 +224,14 @@ _GL_CXXALIASWARN (open);
211# define openat rpl_openat 224# define openat rpl_openat
212# endif 225# endif
213_GL_FUNCDECL_RPL (openat, int, 226_GL_FUNCDECL_RPL (openat, int,
214 (int fd, char const *file, int flags, /* mode_t mode */ ...) 227 (int fd, char const *file, int flags, /* mode_t mode */ ...),
215 _GL_ARG_NONNULL ((2))); 228 _GL_ARG_NONNULL ((2)));
216_GL_CXXALIAS_RPL (openat, int, 229_GL_CXXALIAS_RPL (openat, int,
217 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 230 (int fd, char const *file, int flags, /* mode_t mode */ ...));
218# else 231# else
219# if !@HAVE_OPENAT@ 232# if !@HAVE_OPENAT@
220_GL_FUNCDECL_SYS (openat, int, 233_GL_FUNCDECL_SYS (openat, int,
221 (int fd, char const *file, int flags, /* mode_t mode */ ...) 234 (int fd, char const *file, int flags, /* mode_t mode */ ...),
222 _GL_ARG_NONNULL ((2))); 235 _GL_ARG_NONNULL ((2)));
223# endif 236# endif
224_GL_CXXALIAS_SYS (openat, int, 237_GL_CXXALIAS_SYS (openat, int,
@@ -226,13 +239,51 @@ _GL_CXXALIAS_SYS (openat, int,
226# endif 239# endif
227_GL_CXXALIASWARN (openat); 240_GL_CXXALIASWARN (openat);
228#elif defined GNULIB_POSIXCHECK 241#elif defined GNULIB_POSIXCHECK
229# undef openat
230# if HAVE_RAW_DECL_OPENAT 242# if HAVE_RAW_DECL_OPENAT
231_GL_WARN_ON_USE (openat, "openat is not portable - " 243_GL_WARN_ON_USE (openat, "openat is not portable - "
232 "use gnulib module openat for portability"); 244 "use gnulib module openat for portability");
233# endif 245# endif
234#endif 246#endif
235 247
248#if @GNULIB_OPENAT2@
249# if !defined RESOLVE_NO_XDEV && defined __has_include
250# if __has_include (<linux/openat2.h>)
251# include <linux/openat2.h>
252# endif
253# endif
254# ifndef RESOLVE_NO_XDEV
255struct open_how
256{
257# ifdef __UINT64_TYPE__
258 __UINT64_TYPE__ flags, mode, resolve;
259# else
260 unsigned long long int flags, mode, resolve;
261# endif
262};
263# define RESOLVE_NO_XDEV 0x01
264# define RESOLVE_NO_MAGICLINKS 0x02
265# define RESOLVE_NO_SYMLINKS 0x04
266# define RESOLVE_BENEATH 0x08
267# define RESOLVE_IN_ROOT 0x10
268# define RESOLVE_CACHED 0x20
269# endif
270
271# if !@HAVE_OPENAT2@
272_GL_FUNCDECL_SYS (openat2, int,
273 (int fd, char const *file, struct open_how const *how,
274 size_t size),
275 _GL_ARG_NONNULL ((2, 3)));
276# endif
277_GL_CXXALIAS_SYS (openat2, int,
278 (int fd, char const *file, struct open_how const *how,
279 size_t size));
280_GL_CXXALIASWARN (openat2);
281#elif defined GNULIB_POSIXCHECK
282# if HAVE_RAW_DECL_OPENAT2
283_GL_WARN_ON_USE (openat2, "openat2 is not portable - "
284 "use gnulib module openat2 for portability");
285# endif
286#endif
236 287
237/* Fix up the FD_* macros, only known to be missing on mingw. */ 288/* Fix up the FD_* macros, only known to be missing on mingw. */
238 289
@@ -277,11 +328,6 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
277# endif 328# endif
278#endif 329#endif
279 330
280#if !defined O_DIRECT && defined O_DIRECTIO
281/* Tru64 spells it 'O_DIRECTIO'. */
282# define O_DIRECT O_DIRECTIO
283#endif
284
285#if !defined O_CLOEXEC && defined O_NOINHERIT 331#if !defined O_CLOEXEC && defined O_NOINHERIT
286/* Mingw spells it 'O_NOINHERIT'. */ 332/* Mingw spells it 'O_NOINHERIT'. */
287# define O_CLOEXEC O_NOINHERIT 333# define O_CLOEXEC O_NOINHERIT
@@ -299,7 +345,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
299#endif 345#endif
300 346
301#ifndef O_DIRECTORY 347#ifndef O_DIRECTORY
302# define O_DIRECTORY 0 348# define O_DIRECTORY 0x20000000 /* Try to not collide with system O_* flags. */
303#endif 349#endif
304 350
305#ifndef O_DSYNC 351#ifndef O_DSYNC
@@ -363,8 +409,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
363# define O_RSYNC 0 409# define O_RSYNC 0
364#endif 410#endif
365 411
412#if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH
413# undef O_SEARCH /* musl mistakenly #defines O_SEARCH to O_PATH. */
414#endif
415
366#ifndef O_SEARCH 416#ifndef O_SEARCH
367# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ 417# define O_SEARCH O_RDONLY /* Often close enough in non-POSIX systems. */
368#endif 418#endif
369 419
370#ifndef O_SYNC 420#ifndef O_SYNC
@@ -440,6 +490,15 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
440# define AT_NO_AUTOMOUNT 0 490# define AT_NO_AUTOMOUNT 0
441#endif 491#endif
442 492
493/* errno when openat+O_NOFOLLOW fails because the file is a symlink. */
494#if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__
495# define _GL_OPENAT_ESYMLINK EMLINK
496#elif defined __NetBSD__
497# define _GL_OPENAT_ESYMLINK EFTYPE
498#else
499# define _GL_OPENAT_ESYMLINK ELOOP
500#endif
501
443#endif /* _@GUARD_PREFIX@_FCNTL_H */ 502#endif /* _@GUARD_PREFIX@_FCNTL_H */
444#endif /* _@GUARD_PREFIX@_FCNTL_H */ 503#endif /* _@GUARD_PREFIX@_FCNTL_H */
445#endif 504#endif
diff --git a/gl/fd-hook.c b/gl/fd-hook.c
index 36261150..eef4e81e 100644
--- a/gl/fd-hook.c
+++ b/gl/fd-hook.c
@@ -1,5 +1,5 @@
1/* Hook for making file descriptor functions close(), ioctl() extensible. 1/* Hook for making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009. 3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
diff --git a/gl/fd-hook.h b/gl/fd-hook.h
index 6bf3c24d..0f029d42 100644
--- a/gl/fd-hook.h
+++ b/gl/fd-hook.h
@@ -1,5 +1,5 @@
1/* Hook for making file descriptor functions close(), ioctl() extensible. 1/* Hook for making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/fflush.c b/gl/fflush.c
index f3689b3e..862ff926 100644
--- a/gl/fflush.c
+++ b/gl/fflush.c
@@ -1,5 +1,5 @@
1/* fflush.c -- allow flushing input streams 1/* fflush.c -- allow flushing input streams
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -33,12 +33,15 @@
33 33
34#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 34#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35/* GNU libc, BeOS, Haiku, Linux libc5 */ 35/* GNU libc, BeOS, Haiku, Linux libc5 */
36# if !defined __HAIKU__
37# define fp_ fp
38# endif
36 39
37/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */ 40/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
38static void 41static void
39clear_ungetc_buffer_preserving_position (FILE *fp) 42clear_ungetc_buffer_preserving_position (FILE *fp)
40{ 43{
41 if (fp->_flags & _IO_IN_BACKUP) 44 if (fp_->_flags & _IO_IN_BACKUP)
42 /* _IO_free_backup_area is a bit complicated. Simply call fseek. */ 45 /* _IO_free_backup_area is a bit complicated. Simply call fseek. */
43 fseeko (fp, 0, SEEK_CUR); 46 fseeko (fp, 0, SEEK_CUR);
44} 47}
@@ -50,7 +53,7 @@ static void
50clear_ungetc_buffer (FILE *fp) 53clear_ungetc_buffer (FILE *fp)
51{ 54{
52# if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 55# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
53 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 56 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
54 if (HASUB (fp)) 57 if (HASUB (fp))
55 { 58 {
56 fp_->_p += fp_->_r; 59 fp_->_p += fp_->_r;
@@ -62,7 +65,7 @@ clear_ungetc_buffer (FILE *fp)
62 fp->_ungetc_count = 0; 65 fp->_ungetc_count = 0;
63 fp->_rcount = - fp->_rcount; 66 fp->_rcount = - fp->_rcount;
64 } 67 }
65# elif defined _IOERR /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 68# elif defined _IOERR /* Minix, AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
66 /* Nothing to do. */ 69 /* Nothing to do. */
67# else /* other implementations */ 70# else /* other implementations */
68 fseeko (fp, 0, SEEK_CUR); 71 fseeko (fp, 0, SEEK_CUR);
@@ -75,7 +78,7 @@ clear_ungetc_buffer (FILE *fp)
75/* GNU libc, BeOS, Haiku, Linux libc5 */ 78/* GNU libc, BeOS, Haiku, Linux libc5 */
76 79
77# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT 80# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
78/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 81/* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
79 82
80static int 83static int
81disable_seek_optimization (FILE *fp) 84disable_seek_optimization (FILE *fp)
@@ -98,7 +101,7 @@ update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
98 _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos) 101 _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
99{ 102{
100# if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 103# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
101 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 104 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
102# if defined __CYGWIN__ || defined __ANDROID__ 105# if defined __CYGWIN__ || defined __ANDROID__
103 /* fp_->_offset is typed as an integer. */ 106 /* fp_->_offset is typed as an integer. */
104 fp_->_offset = pos; 107 fp_->_offset = pos;
@@ -203,7 +206,7 @@ rpl_fflush (FILE *stream)
203 } 206 }
204 207
205# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT 208# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
206 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 209 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
207 210
208 { 211 {
209 /* Disable seek optimization for the next fseeko call. This tells the 212 /* Disable seek optimization for the next fseeko call. This tells the
diff --git a/gl/filename.h b/gl/filename.h
index a2400a9d..e353363e 100644
--- a/gl/filename.h
+++ b/gl/filename.h
@@ -1,5 +1,5 @@
1/* Basic filename support macros. 1/* Basic filename support macros.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc. 2 Copyright (C) 2001-2025 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
diff --git a/gl/float+.h b/gl/float+.h
index e7531e46..58eca376 100644
--- a/gl/float+.h
+++ b/gl/float+.h
@@ -1,5 +1,5 @@
1/* Supplemental information about the floating-point formats. 1/* Supplemental information about the floating-point formats.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2007. 3 Written by Bruno Haible <bruno@clisp.org>, 2007.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
diff --git a/gl/float.c b/gl/float.c
index f81ff33d..2e95957a 100644
--- a/gl/float.c
+++ b/gl/float.c
@@ -1,5 +1,5 @@
1/* Auxiliary definitions for <float.h>. 1/* Auxiliary definitions for <float.h>.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -20,14 +20,98 @@
20/* Specification. */ 20/* Specification. */
21#include <float.h> 21#include <float.h>
22 22
23#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ 23#if GNULIB_defined_long_double_union
24const union gl_long_double_union gl_LDBL_MAX = 24# ifdef __i386__
25 { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
26#elif defined __i386__
27const union gl_long_double_union gl_LDBL_MAX = 25const union gl_long_double_union gl_LDBL_MAX =
28 { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } }; 26 { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
29#else 27# endif
28# if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
29/* We can't even simply evaluate the formula (LDBL_MIN / 9223372036854775808.0L)
30 at run time, because it would require BEGIN_LONG_DOUBLE_ROUNDING /
31 END_LONG_DOUBLE_ROUNDING invocations. It simpler to just write down the
32 representation of LDBL_TRUE_MIN, based on
33 <https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format>. */
34const union gl_long_double_union gl_LDBL_TRUE_MIN =
35 { { 0x00000001, 0x00000000, 0 } };
36# endif
37#endif
38
39#if GNULIB_defined_FLT_SNAN
40/* Define like memory_positive_SNaNf(), see signed-snan.h and snan.h,
41 or like setpayloadsigf() with an arbitrary payload. */
42gl_FLT_SNAN_t gl_FLT_SNAN =
43# if FLT_MANT_DIG == 24
44# if defined __hppa || (defined __mips__ && !MIPS_NAN2008_FLOAT) || defined __sh__
45 /* sign bit: 0, 8 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
46 { { 0x7FE00000U } }
47# else
48 /* sign bit: 0, 8 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
49 { { 0x7FA00000U } }
50# endif
51# endif
52 ;
53#endif
54
55#if GNULIB_defined_DBL_SNAN
56/* Define like memory_positive_SNaNd(), see signed-snan.h and snan.h,
57 or like setpayloadsig() with an arbitrary payload. */
58gl_DBL_SNAN_t gl_DBL_SNAN =
59# if DBL_MANT_DIG == 53
60# if defined __hppa || (defined __mips__ && !MIPS_NAN2008_FLOAT) || defined __sh__
61 /* sign bit: 0, 11 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
62 { { 0x7FFC000000000000ULL } }
63# else
64 /* sign bit: 0, 11 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
65 { { 0x7FF4000000000000ULL } }
66# endif
67# endif
68 ;
69#endif
70
71#if GNULIB_defined_LDBL_SNAN
72# ifdef WORDS_BIGENDIAN
73# define TWO(hi,lo) { hi, lo }
74# else
75# define TWO(hi,lo) { lo, hi }
76# endif
77/* Define like memory_positive_SNaNl(), see signed-snan.h and snan.h,
78 or like setpayloadsigl() with an arbitrary payload. */
79gl_LDBL_SNAN_t gl_LDBL_SNAN =
80# if LDBL_MANT_DIG == 53 /* on arm, hppa, mips, sh, but also MSVC */
81# if defined __hppa || (defined __mips__ && !MIPS_NAN2008_FLOAT) || defined __sh__
82 /* sign bit: 0, 11 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
83 { { 0x7FFC000000000000ULL } }
84# else
85 /* sign bit: 0, 11 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
86 { { 0x7FF4000000000000ULL } }
87# endif
88# elif LDBL_MANT_DIG == 64 /* on i386, x86_64, ia64, m68k */
89# if defined __m68k__
90 /* sign bit: 0, 15 exponent bits: all 1, 16 gap bits: all 0,
91 always=1 bit: 1, next bit: 0, payload: 0b10...0 */
92 { { 0x7FFF0000ULL, 0xA0000000ULL, 0x00000000ULL } }
93# else
94 /* sign bit: 0, 15 exponent bits: all 1, always=1 bit: 1, next bit: 0, payload: 0b10...0
95 (see <https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format>) */
96 { TWO (0x00007FFFULL, 0xA000000000000000ULL) }
97# endif
98# elif LDBL_MANT_DIG == 106 /* on powerpc, powerpc64, powerpc64le */
99 /* most-significant double:
100 sign bit: 0, 11 exponent bits: all 1, next bit: 0, payload: 0b10...0,
101 least-significant double: 0.0 */
102 { { 0x7FF4000000000000ULL, 0ULL } }
103# elif LDBL_MANT_DIG == 113 /* on alpha, arm64, loongarch64, mips64, riscv64, s390x, sparc64 */
104# if (defined __mips__ && !MIPS_NAN2008_FLOAT)
105 /* sign bit: 0, 15 exponent bits: all 1, next bit: 1, payload: 0b10...0 */
106 { TWO (0x7FFFC00000000000ULL, 0ULL) }
107# else
108 /* sign bit: 0, 15 exponent bits: all 1, next bit: 0, payload: 0b10...0 */
109 { TWO (0x7FFF400000000000ULL, 0ULL) }
110# endif
111# endif
112 ;
113#endif
114
30/* This declaration is solely to ensure that after preprocessing 115/* This declaration is solely to ensure that after preprocessing
31 this file is never empty. */ 116 this file is never empty. */
32typedef int dummy; 117typedef int dummy;
33#endif
diff --git a/gl/float.in.h b/gl/float.in.h
index bf2c502c..9f735cb9 100644
--- a/gl/float.in.h
+++ b/gl/float.in.h
@@ -1,6 +1,6 @@
1/* A correct <float.h>. 1/* A correct <float.h>.
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -28,6 +28,8 @@
28#ifndef _@GUARD_PREFIX@_FLOAT_H 28#ifndef _@GUARD_PREFIX@_FLOAT_H
29#define _@GUARD_PREFIX@_FLOAT_H 29#define _@GUARD_PREFIX@_FLOAT_H
30 30
31/* ============================ ISO C99 support ============================ */
32
31/* 'long double' properties. */ 33/* 'long double' properties. */
32 34
33#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) 35#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
@@ -113,71 +115,199 @@ extern const union gl_long_double_union gl_LDBL_MAX;
113 115
114/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are 116/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
115 wrong. 117 wrong.
116 On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */ 118 On Linux/PowerPC with gcc 8.3, the values of LDBL_MAX and LDBL_EPSILON are
117#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__ 119 wrong.
120 Assume these bugs are fixed in any GCC new enough
121 to define __LDBL_NORM_MAX__. */
122#if (defined _ARCH_PPC && LDBL_MANT_DIG == 106 \
123 && defined __GNUC__ && !defined __LDBL_NORM_MAX__)
118# undef LDBL_MIN_EXP 124# undef LDBL_MIN_EXP
119# define LDBL_MIN_EXP DBL_MIN_EXP 125# define LDBL_MIN_EXP (-968)
120# undef LDBL_MIN_10_EXP 126# undef LDBL_MIN_10_EXP
121# define LDBL_MIN_10_EXP DBL_MIN_10_EXP 127# define LDBL_MIN_10_EXP (-291)
122# undef LDBL_MIN 128# undef LDBL_MIN
123# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ 129# define LDBL_MIN 0x1p-969L
124#endif 130
125#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ 131/* IBM long double is tricky: it is represented as the sum of two doubles,
132 and the high double must equal the sum of the two parts rounded to nearest.
133 The maximum finite value for which this is true is
134 { 0x1.fffffffffffffp+1023, 0x1.ffffffffffffep+969 },
135 which represents 0x1.fffffffffffff7ffffffffffff8p+1023L.
136 Although computations can yield representations of numbers larger than this,
137 these computations are considered to have overflowed and behavior is undefined.
138 See <https://gcc.gnu.org/PR120993>. */
126# undef LDBL_MAX 139# undef LDBL_MAX
127/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }. 140# define LDBL_MAX 0x1.fffffffffffff7ffffffffffff8p+1023L
128 It is not easy to define:
129 #define LDBL_MAX 1.79769313486231580793728971405302307166e308L
130 is too small, whereas
131 #define LDBL_MAX 1.79769313486231580793728971405302307167e308L
132 is too large. Apparently a bug in GCC decimal-to-binary conversion.
133 Also, I can't get values larger than
134 #define LDBL63 ((long double) (1ULL << 63))
135 #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
136 #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
137 #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
138 #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
139 which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
140 So, define it like this through a reference to an external variable
141 141
142 const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL }; 142/* On PowerPC platforms, 'long double' has a double-double representation.
143 extern const long double LDBL_MAX; 143 Up to ISO C 17, this was outside the scope of ISO C because it can represent
144 numbers with mantissas of the form 1.<52 bits><many zeroes><52 bits>, such as
145 1.0L + 4.94065645841246544176568792868221e-324L = 1 + 2^-1074; see
146 ISO C 17 § 5.2.4.2.2.(3).
147 In ISO C 23, wording has been included that makes this 'long double'
148 representation compliant; see ISO C 23 § 5.2.5.3.3.(8)-(9). In this setting,
149 numbers with mantissas of the form 1.<52 bits><many zeroes><52 bits> are
150 called "unnormalized". And since LDBL_EPSILON must be normalized (per
151 ISO C 23 § 5.2.5.3.3.(33)), it must be 2^-105. */
152# undef LDBL_EPSILON
153# define LDBL_EPSILON 0x1p-105L
154#endif
144 155
145 or through a pointer cast 156/* ============================ ISO C11 support ============================ */
146 157
147 #define LDBL_MAX \ 158/* 'float' properties */
148 (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
149 159
150 Unfortunately, this is not a constant expression, and the latter expression 160#ifndef FLT_HAS_SUBNORM
151 does not work well when GCC is optimizing.. */ 161# define FLT_HAS_SUBNORM 1
152# if !GNULIB_defined_long_double_union 162#endif
153union gl_long_double_union 163#ifndef FLT_DECIMAL_DIG
154 { 164/* FLT_MANT_DIG = 24 => FLT_DECIMAL_DIG = 9 */
155 struct { double hi; double lo; } dd; 165# define FLT_DECIMAL_DIG ((int)(FLT_MANT_DIG * 0.3010299956639812 + 2))
156 long double ld; 166#endif
157 }; 167#if defined _AIX && !defined __GNUC__
158# define GNULIB_defined_long_double_union 1 168/* On AIX, the value of FLT_TRUE_MIN in /usr/include/float.h is a 'double',
169 not a 'float'. */
170# undef FLT_TRUE_MIN
171#endif
172#ifndef FLT_TRUE_MIN
173/* FLT_MIN / 2^(FLT_MANT_DIG-1) */
174# define FLT_TRUE_MIN (FLT_MIN / 8388608.0f)
175#endif
176
177/* 'double' properties */
178
179#ifndef DBL_HAS_SUBNORM
180# define DBL_HAS_SUBNORM 1
181#endif
182#ifndef DBL_DECIMAL_DIG
183/* DBL_MANT_DIG = 53 => DBL_DECIMAL_DIG = 17 */
184# define DBL_DECIMAL_DIG ((int)(DBL_MANT_DIG * 0.3010299956639812 + 2))
185#endif
186#ifndef DBL_TRUE_MIN
187/* DBL_MIN / 2^(DBL_MANT_DIG-1) */
188# define DBL_TRUE_MIN (DBL_MIN / 4503599627370496.0)
189#endif
190
191/* 'long double' properties */
192
193#ifndef LDBL_HAS_SUBNORM
194# define LDBL_HAS_SUBNORM 1
195#endif
196#ifndef LDBL_DECIMAL_DIG
197/* LDBL_MANT_DIG = 53 => LDBL_DECIMAL_DIG = 17 */
198/* LDBL_MANT_DIG = 64 => LDBL_DECIMAL_DIG = 21 */
199/* LDBL_MANT_DIG = 106 => LDBL_DECIMAL_DIG = 33 */
200/* LDBL_MANT_DIG = 113 => LDBL_DECIMAL_DIG = 36 */
201# define LDBL_DECIMAL_DIG ((int)(LDBL_MANT_DIG * 0.3010299956639812 + 2))
202#endif
203#ifndef LDBL_TRUE_MIN
204/* LDBL_MIN / 2^(LDBL_MANT_DIG-1) */
205# if LDBL_MANT_DIG == 53
206# define LDBL_TRUE_MIN (LDBL_MIN / 4503599627370496.0L)
207# elif LDBL_MANT_DIG == 64
208# if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
209/* Work around FreeBSD/x86 problem mentioned above. */
210extern const union gl_long_double_union gl_LDBL_TRUE_MIN;
211# define LDBL_TRUE_MIN (gl_LDBL_TRUE_MIN.ld)
212# else
213# define LDBL_TRUE_MIN (LDBL_MIN / 9223372036854775808.0L)
214# endif
215# elif LDBL_MANT_DIG == 106
216# define LDBL_TRUE_MIN (LDBL_MIN / 40564819207303340847894502572032.0L)
217# elif LDBL_MANT_DIG == 113
218# define LDBL_TRUE_MIN (LDBL_MIN / 5192296858534827628530496329220096.0L)
159# endif 219# endif
160extern const union gl_long_double_union gl_LDBL_MAX;
161# define LDBL_MAX (gl_LDBL_MAX.ld)
162#endif 220#endif
163 221
164/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong. 222/* ============================ ISO C23 support ============================ */
165 On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON 223
166 are wrong. */ 224/* 'float' properties */
167#if defined __sgi && (LDBL_MANT_DIG >= 106) 225
168# undef LDBL_MANT_DIG 226#ifndef FLT_IS_IEC_60559
169# define LDBL_MANT_DIG 106 227# if defined __m68k__
170# if defined __GNUC__ 228# define FLT_IS_IEC_60559 0
171# undef LDBL_MIN_EXP 229# else
172# define LDBL_MIN_EXP DBL_MIN_EXP 230# define FLT_IS_IEC_60559 1
173# undef LDBL_MIN_10_EXP 231# endif
174# define LDBL_MIN_10_EXP DBL_MIN_10_EXP 232#endif
175# undef LDBL_MIN 233#ifndef FLT_NORM_MAX
176# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */ 234# define FLT_NORM_MAX FLT_MAX
177# undef LDBL_EPSILON 235#endif
178# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */ 236#ifndef FLT_SNAN
237/* For sh, beware of <https://gcc.gnu.org/PR111814>. */
238# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
239# define FLT_SNAN __builtin_nansf ("")
240# else
241typedef union { unsigned int word[1]; float value; } gl_FLT_SNAN_t;
242extern gl_FLT_SNAN_t gl_FLT_SNAN;
243# define FLT_SNAN (gl_FLT_SNAN.value)
244# define GNULIB_defined_FLT_SNAN 1
245# endif
246#endif
247
248/* 'double' properties */
249
250#ifndef DBL_IS_IEC_60559
251# if defined __m68k__
252# define DBL_IS_IEC_60559 0
253# else
254# define DBL_IS_IEC_60559 1
179# endif 255# endif
180#endif 256#endif
257#ifndef DBL_NORM_MAX
258# define DBL_NORM_MAX DBL_MAX
259#endif
260#ifndef DBL_SNAN
261/* For sh, beware of <https://gcc.gnu.org/PR111814>. */
262# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
263# define DBL_SNAN __builtin_nans ("")
264# else
265typedef union { unsigned long long word[1]; double value; } gl_DBL_SNAN_t;
266extern gl_DBL_SNAN_t gl_DBL_SNAN;
267# define DBL_SNAN (gl_DBL_SNAN.value)
268# define GNULIB_defined_DBL_SNAN 1
269# endif
270#endif
271
272/* 'long double' properties */
273
274#ifndef LDBL_IS_IEC_60559
275# if defined __m68k__
276# define LDBL_IS_IEC_60559 0
277# elif LDBL_MANT_DIG == 53 || LDBL_MANT_DIG == 113
278# define LDBL_IS_IEC_60559 1
279# else
280# define LDBL_IS_IEC_60559 0
281# endif
282#endif
283#ifndef LDBL_NORM_MAX
284# ifdef __LDBL_NORM_MAX__
285# define LDBL_NORM_MAX __LDBL_NORM_MAX__
286# elif FLT_RADIX == 2 && LDBL_MAX_EXP == 1024 && LDBL_MANT_DIG == 106
287# define LDBL_NORM_MAX 0x1.ffffffffffffffffffffffffff8p+1022L
288# else
289# define LDBL_NORM_MAX LDBL_MAX
290# endif
291#endif
292#ifndef LDBL_SNAN
293/* For sh, beware of <https://gcc.gnu.org/PR111814>. */
294# if ((__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__) && !defined __sh__
295# define LDBL_SNAN __builtin_nansl ("")
296# else
297# if LDBL_MANT_DIG == 53
298typedef union { unsigned long long word[1]; long double value; } gl_LDBL_SNAN_t;
299# elif defined __m68k__
300typedef union { unsigned int word[3]; long double value; } gl_LDBL_SNAN_t;
301# else
302typedef union { unsigned long long word[2]; long double value; } gl_LDBL_SNAN_t;
303# endif
304extern gl_LDBL_SNAN_t gl_LDBL_SNAN;
305# define LDBL_SNAN (gl_LDBL_SNAN.value)
306# define GNULIB_defined_LDBL_SNAN 1
307# endif
308#endif
309
310/* ================================= Other ================================= */
181 311
182#if @REPLACE_ITOLD@ 312#if @REPLACE_ITOLD@
183/* Pull in a function that fixes the 'int' to 'long double' conversion 313/* Pull in a function that fixes the 'int' to 'long double' conversion
diff --git a/gl/floor.c b/gl/floor.c
index 238f4879..9cecb7bb 100644
--- a/gl/floor.c
+++ b/gl/floor.c
@@ -1,5 +1,5 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2010-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2010-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/floorf.c b/gl/floorf.c
index e465c180..34a507b9 100644
--- a/gl/floorf.c
+++ b/gl/floorf.c
@@ -1,5 +1,5 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/fopen.c b/gl/fopen.c
index f8469a0b..93710ad0 100644
--- a/gl/fopen.c
+++ b/gl/fopen.c
@@ -1,5 +1,5 @@
1/* Open a stream to a file. 1/* Open a stream to a file.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -19,12 +19,12 @@
19/* If the user's config.h happens to include <stdio.h>, let it include only 19/* If the user's config.h happens to include <stdio.h>, let it include only
20 the system's <stdio.h> here, so that orig_fopen doesn't recurse to 20 the system's <stdio.h> here, so that orig_fopen doesn't recurse to
21 rpl_fopen. */ 21 rpl_fopen. */
22#define _GL_ALREADY_INCLUDING_STDIO_H 22#define _GL_SKIP_GNULIB_STDIO_H
23#include <config.h> 23#include <config.h>
24 24
25/* Get the original definition of fopen. It might be defined as a macro. */ 25/* Get the original definition of fopen. It might be defined as a macro. */
26#include <stdio.h> 26#include <stdio.h>
27#undef _GL_ALREADY_INCLUDING_STDIO_H 27#undef _GL_SKIP_GNULIB_STDIO_H
28 28
29static FILE * 29static FILE *
30orig_fopen (const char *filename, const char *mode) 30orig_fopen (const char *filename, const char *mode)
@@ -33,9 +33,7 @@ orig_fopen (const char *filename, const char *mode)
33} 33}
34 34
35/* Specification. */ 35/* Specification. */
36/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates 36#include <stdio.h>
37 this include because of the preliminary #include <stdio.h> above. */
38#include "stdio.h"
39 37
40#include <errno.h> 38#include <errno.h>
41#include <fcntl.h> 39#include <fcntl.h>
@@ -47,24 +45,18 @@ orig_fopen (const char *filename, const char *mode)
47FILE * 45FILE *
48rpl_fopen (const char *filename, const char *mode) 46rpl_fopen (const char *filename, const char *mode)
49{ 47{
50 int open_direction;
51 int open_flags;
52#if GNULIB_FOPEN_GNU
53 bool open_flags_gnu;
54# define BUF_SIZE 80
55 char fdopen_mode_buf[BUF_SIZE + 1];
56#endif
57
58#if defined _WIN32 && ! defined __CYGWIN__ 48#if defined _WIN32 && ! defined __CYGWIN__
59 if (strcmp (filename, "/dev/null") == 0) 49 if (streq (filename, "/dev/null"))
60 filename = "NUL"; 50 filename = "NUL";
61#endif 51#endif
62 52
63 /* Parse the mode. */ 53 /* Parse the mode. */
64 open_direction = 0; 54 int open_direction = 0;
65 open_flags = 0; 55 int open_flags = 0;
66#if GNULIB_FOPEN_GNU 56#if GNULIB_FOPEN_GNU
67 open_flags_gnu = false; 57 bool open_flags_gnu = false;
58# define BUF_SIZE 80
59 char fdopen_mode_buf[BUF_SIZE + 1];
68#endif 60#endif
69 { 61 {
70 const char *p = mode; 62 const char *p = mode;
@@ -165,21 +157,18 @@ rpl_fopen (const char *filename, const char *mode)
165 size_t len = strlen (filename); 157 size_t len = strlen (filename);
166 if (len > 0 && filename[len - 1] == '/') 158 if (len > 0 && filename[len - 1] == '/')
167 { 159 {
168 int fd;
169 struct stat statbuf;
170 FILE *fp;
171
172 if (open_direction != O_RDONLY) 160 if (open_direction != O_RDONLY)
173 { 161 {
174 errno = EISDIR; 162 errno = EISDIR;
175 return NULL; 163 return NULL;
176 } 164 }
177 165
178 fd = open (filename, open_direction | open_flags, 166 int fd = open (filename, open_direction | open_flags,
179 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); 167 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
180 if (fd < 0) 168 if (fd < 0)
181 return NULL; 169 return NULL;
182 170
171 struct stat statbuf;
183 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) 172 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
184 { 173 {
185 close (fd); 174 close (fd);
@@ -187,6 +176,7 @@ rpl_fopen (const char *filename, const char *mode)
187 return NULL; 176 return NULL;
188 } 177 }
189 178
179 FILE *fp;
190# if GNULIB_FOPEN_GNU 180# if GNULIB_FOPEN_GNU
191 fp = fdopen (fd, fdopen_mode_buf); 181 fp = fdopen (fd, fdopen_mode_buf);
192# else 182# else
@@ -206,15 +196,12 @@ rpl_fopen (const char *filename, const char *mode)
206#if GNULIB_FOPEN_GNU 196#if GNULIB_FOPEN_GNU
207 if (open_flags_gnu) 197 if (open_flags_gnu)
208 { 198 {
209 int fd; 199 int fd = open (filename, open_direction | open_flags,
210 FILE *fp; 200 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
211
212 fd = open (filename, open_direction | open_flags,
213 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
214 if (fd < 0) 201 if (fd < 0)
215 return NULL; 202 return NULL;
216 203
217 fp = fdopen (fd, fdopen_mode_buf); 204 FILE *fp = fdopen (fd, fdopen_mode_buf);
218 if (fp == NULL) 205 if (fp == NULL)
219 { 206 {
220 int saved_errno = errno; 207 int saved_errno = errno;
@@ -225,5 +212,9 @@ rpl_fopen (const char *filename, const char *mode)
225 } 212 }
226#endif 213#endif
227 214
215 /* open_direction is sometimes used, sometimes unused.
216 Silence gcc's warning about this situation. */
217 (void) open_direction;
218
228 return orig_fopen (filename, mode); 219 return orig_fopen (filename, mode);
229} 220}
diff --git a/gl/fpurge.c b/gl/fpurge.c
index 0dcb2b79..6799b52b 100644
--- a/gl/fpurge.c
+++ b/gl/fpurge.c
@@ -1,5 +1,5 @@
1/* Flushing buffers of a FILE stream. 1/* Flushing buffers of a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -37,7 +37,7 @@ fpurge (FILE *fp)
37 /* The __fpurge function does not have a return value. */ 37 /* The __fpurge function does not have a return value. */
38 return 0; 38 return 0;
39 39
40#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */ 40#elif HAVE_FPURGE /* FreeBSD, NetBSD, 2.0 <= OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin >= 1.7 */
41 41
42 /* Call the system's fpurge function. */ 42 /* Call the system's fpurge function. */
43# undef fpurge 43# undef fpurge
@@ -46,7 +46,7 @@ fpurge (FILE *fp)
46# endif 46# endif
47 int result = fpurge (fp); 47 int result = fpurge (fp);
48# if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 48# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
49 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 49 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
50 if (result == 0) 50 if (result == 0)
51 /* Correct the invariants that fpurge broke. 51 /* Correct the invariants that fpurge broke.
52 <stdio.h> on BSD systems says: 52 <stdio.h> on BSD systems says:
@@ -76,7 +76,7 @@ fpurge (FILE *fp)
76 } 76 }
77 return 0; 77 return 0;
78# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ 78# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
79 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 79 /* FreeBSD, NetBSD, OpenBSD < 2.0, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
80 fp_->_p = fp_->_bf._base; 80 fp_->_p = fp_->_bf._base;
81 fp_->_r = 0; 81 fp_->_r = 0;
82 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */ 82 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
@@ -101,7 +101,7 @@ fpurge (FILE *fp)
101 if (fp->_ptr != NULL) 101 if (fp->_ptr != NULL)
102 fp->_count = 0; 102 fp->_count = 0;
103 return 0; 103 return 0;
104# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 104# elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
105 fp_->_ptr = fp_->_base; 105 fp_->_ptr = fp_->_base;
106 if (fp_->_ptr != NULL) 106 if (fp_->_ptr != NULL)
107 fp_->_cnt = 0; 107 fp_->_cnt = 0;
diff --git a/gl/freading.c b/gl/freading.c
index b9377cb0..8e06282e 100644
--- a/gl/freading.c
+++ b/gl/freading.c
@@ -1,5 +1,5 @@
1/* Retrieve information about a FILE stream. 1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -22,9 +22,13 @@
22#include "stdio-impl.h" 22#include "stdio-impl.h"
23 23
24/* Don't use glibc's __freading function in glibc < 2.7, see 24/* Don't use glibc's __freading function in glibc < 2.7, see
25 <https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */ 25 <https://sourceware.org/PR4359> */
26#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))) 26#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
27 27
28/* This code is not compiled on systems that have a working __freading function,
29 namely glibc >= 2.7, OpenBSD >= 7.6, Solaris >= 7, UnixWare >= 7.1.4.MP4,
30 Cygwin >= 1.7.34, Android API >= 28, musl libc, Haiku >= hrev58760. */
31
28bool 32bool
29freading (FILE *fp) 33freading (FILE *fp)
30{ 34{
@@ -37,13 +41,13 @@ freading (FILE *fp)
37 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 41 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
38 && fp->_IO_read_base != NULL)); 42 && fp->_IO_read_base != NULL));
39# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ 43# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
40 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */ 44 /* FreeBSD, NetBSD, OpenBSD < 7.6, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
41 return (fp_->_flags & __SRD) != 0; 45 return (fp_->_flags & __SRD) != 0;
42# elif defined __EMX__ /* emx+gcc */ 46# elif defined __EMX__ /* emx+gcc */
43 return (fp->_flags & _IOREAD) != 0; 47 return (fp->_flags & _IOREAD) != 0;
44# elif defined __minix /* Minix */ 48# elif defined __minix /* Minix */
45 return (fp->_flags & _IOREADING) != 0; 49 return (fp->_flags & _IOREADING) != 0;
46# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 50# elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
47# if defined __sun /* Solaris */ 51# if defined __sun /* Solaris */
48 return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0; 52 return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
49# else 53# else
diff --git a/gl/freading.h b/gl/freading.h
index 27b3abbc..3d75d75e 100644
--- a/gl/freading.h
+++ b/gl/freading.h
@@ -1,5 +1,5 @@
1/* Retrieve information about a FILE stream. 1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -14,6 +14,11 @@
14 You should have received a copy of the GNU Lesser General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* This file uses _GL_ATTRIBUTE_PURE, HAVE___FREADING, HAVE_STDIO_EXT_H. */
18#if !_GL_CONFIG_H_INCLUDED
19 #error "Please include config.h first."
20#endif
21
17#include <stdio.h> 22#include <stdio.h>
18 23
19/* Return true if the stream STREAM is opened read-only, or if the 24/* Return true if the stream STREAM is opened read-only, or if the
diff --git a/gl/free.c b/gl/free.c
index 372a6b0f..e6e7cf0f 100644
--- a/gl/free.c
+++ b/gl/free.c
@@ -1,6 +1,6 @@
1/* Make free() preserve errno. 1/* Make free() preserve errno.
2 2
3 Copyright (C) 2003, 2006, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -33,7 +33,7 @@ rpl_free (void *p)
33{ 33{
34# if defined __GNUC__ && !defined __clang__ 34# if defined __GNUC__ && !defined __clang__
35 /* An invalid GCC optimization 35 /* An invalid GCC optimization
36 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396> 36 <https://gcc.gnu.org/PR98396>
37 would optimize away the assignments in the code below, when link-time 37 would optimize away the assignments in the code below, when link-time
38 optimization (LTO) is enabled. Make the code more complicated, so that 38 optimization (LTO) is enabled. Make the code more complicated, so that
39 GCC does not grok how to optimize it. */ 39 GCC does not grok how to optimize it. */
@@ -44,9 +44,9 @@ rpl_free (void *p)
44 free (p); 44 free (p);
45 errno = err[errno == 0]; 45 errno = err[errno == 0];
46# else 46# else
47 int err = errno; 47 int saved_errno = errno;
48 free (p); 48 free (p);
49 errno = err; 49 errno = saved_errno;
50# endif 50# endif
51} 51}
52 52
diff --git a/gl/fseek.c b/gl/fseek.c
index 9764375a..bf1f303f 100644
--- a/gl/fseek.c
+++ b/gl/fseek.c
@@ -1,5 +1,5 @@
1/* An fseek() function that, together with fflush(), is POSIX compliant. 1/* An fseek() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/fseeko.c b/gl/fseeko.c
index 89a70874..f6cd7cba 100644
--- a/gl/fseeko.c
+++ b/gl/fseeko.c
@@ -1,5 +1,5 @@
1/* An fseeko() function that, together with fflush(), is POSIX compliant. 1/* An fseeko() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -48,12 +48,15 @@ fseeko (FILE *fp, off_t offset, int whence)
48 48
49 /* These tests are based on fpurge.c. */ 49 /* These tests are based on fpurge.c. */
50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51# if !defined __HAIKU__
52# define fp_ fp
53# endif
51 /* GNU libc, BeOS, Haiku, Linux libc5 */ 54 /* GNU libc, BeOS, Haiku, Linux libc5 */
52 if (fp->_IO_read_end == fp->_IO_read_ptr 55 if (fp_->_IO_read_end == fp_->_IO_read_ptr
53 && fp->_IO_write_ptr == fp->_IO_write_base 56 && fp_->_IO_write_ptr == fp_->_IO_write_base
54 && fp->_IO_save_base == NULL) 57 && fp_->_IO_save_base == NULL)
55#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ 58#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
56 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 59 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
57# if defined __SL64 && defined __SCLE /* Cygwin */ 60# if defined __SL64 && defined __SCLE /* Cygwin */
58 if ((fp->_flags & __SL64) == 0) 61 if ((fp->_flags & __SL64) == 0)
59 { 62 {
@@ -81,7 +84,7 @@ fseeko (FILE *fp, off_t offset, int whence)
81#elif defined __minix /* Minix */ 84#elif defined __minix /* Minix */
82 if (fp_->_ptr == fp_->_buf 85 if (fp_->_ptr == fp_->_buf
83 && (fp_->_ptr == NULL || fp_->_count == 0)) 86 && (fp_->_ptr == NULL || fp_->_count == 0))
84#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 87#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
85 if (fp_->_ptr == fp_->_base 88 if (fp_->_ptr == fp_->_base
86 && (fp_->_ptr == NULL || fp_->_cnt == 0)) 89 && (fp_->_ptr == NULL || fp_->_cnt == 0))
87#elif defined __UCLIBC__ /* uClibc */ 90#elif defined __UCLIBC__ /* uClibc */
@@ -101,6 +104,9 @@ fseeko (FILE *fp, off_t offset, int whence)
101#elif defined EPLAN9 /* Plan9 */ 104#elif defined EPLAN9 /* Plan9 */
102 if (fp->rp == fp->buf 105 if (fp->rp == fp->buf
103 && fp->wp == fp->buf) 106 && fp->wp == fp->buf)
107#elif defined __OpenBSD__ && !defined __sferror /* OpenBSD >= 7.8 */
108 /* fseeko and fflush work as advertised. */
109 if (0)
104#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION 110#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
105 /* Cross-compiling to some other system advertising conformance to 111 /* Cross-compiling to some other system advertising conformance to
106 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised. 112 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
@@ -118,7 +124,7 @@ fseeko (FILE *fp, off_t offset, int whence)
118 if (pos == -1) 124 if (pos == -1)
119 { 125 {
120#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 126#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
121 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 127 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
122 fp_->_flags &= ~__SOFF; 128 fp_->_flags &= ~__SOFF;
123#endif 129#endif
124 return -1; 130 return -1;
@@ -126,10 +132,10 @@ fseeko (FILE *fp, off_t offset, int whence)
126 132
127#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 133#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128 /* GNU libc, BeOS, Haiku, Linux libc5 */ 134 /* GNU libc, BeOS, Haiku, Linux libc5 */
129 fp->_flags &= ~_IO_EOF_SEEN; 135 fp_->_flags &= ~_IO_EOF_SEEN;
130 fp->_offset = pos; 136 fp_->_offset = pos;
131#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ 137#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
132 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 138 /* FreeBSD, NetBSD, OpenBSD <= 7.7, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
133# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix 139# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
134 /* fp_->_offset is typed as an integer. */ 140 /* fp_->_offset is typed as an integer. */
135 fp_->_offset = pos; 141 fp_->_offset = pos;
@@ -152,7 +158,7 @@ fseeko (FILE *fp, off_t offset, int whence)
152 fp_->_flags &= ~__SEOF; 158 fp_->_flags &= ~__SEOF;
153#elif defined __EMX__ /* emx+gcc */ 159#elif defined __EMX__ /* emx+gcc */
154 fp->_flags &= ~_IOEOF; 160 fp->_flags &= ~_IOEOF;
155#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */ 161#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
156 fp_->_flag &= ~_IOEOF; 162 fp_->_flag &= ~_IOEOF;
157#elif defined __MINT__ /* Atari FreeMiNT */ 163#elif defined __MINT__ /* Atari FreeMiNT */
158 fp->__offset = pos; 164 fp->__offset = pos;
diff --git a/gl/fseterr.c b/gl/fseterr.c
new file mode 100644
index 00000000..0ab61765
--- /dev/null
+++ b/gl/fseterr.c
@@ -0,0 +1,80 @@
1/* Set the error indicator of a stream.
2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include "fseterr.h"
21
22#include <errno.h>
23
24#include "stdio-impl.h"
25
26/* This file is not used on systems that have the __fseterr function,
27 namely OpenBSD >= 7.6, musl libc, Haiku >= hrev58760. */
28
29void
30fseterr (FILE *fp)
31{
32 /* Most systems provide FILE as a struct and the necessary bitmask in
33 <stdio.h>, because they need it for implementing getc() and putc() as
34 fast macros. */
35#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
36 /* GNU libc, BeOS, Haiku, Linux libc5 */
37 fp->_flags |= _IO_ERR_SEEN;
38#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
39 /* FreeBSD, NetBSD, OpenBSD < 7.6, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
40 fp_->_flags |= __SERR;
41#elif defined __EMX__ /* emx+gcc */
42 fp->_flags |= _IOERR;
43#elif defined __minix /* Minix */
44 fp->_flags |= _IOERR;
45#elif defined _IOERR /* AIX, HP-UX, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
46 fp_->_flag |= _IOERR;
47#elif defined __UCLIBC__ /* uClibc */
48 fp->__modeflags |= __FLAG_ERROR;
49#elif defined __QNX__ /* QNX */
50 fp->_Mode |= 0x200 /* _MERR */;
51#elif defined __MINT__ /* Atari FreeMiNT */
52 fp->__error = 1;
53#elif defined EPLAN9 /* Plan9 */
54 if (fp->state != 0 /* CLOSED */)
55 fp->state = 5 /* ERR */;
56#elif 0 /* unknown */
57 /* Portable fallback, based on an idea by Rich Felker.
58 Wow! 6 system calls for something that is just a bit operation!
59 Not activated on any system, because there is no way to repair FP when
60 the sequence of system calls fails, and library code should not call
61 abort(). */
62 int saved_errno = errno;
63 fflush (fp);
64 int fd = fileno (fp);
65 int fd2 = dup (fd);
66 if (fd2 >= 0)
67 {
68 close (fd);
69 fputc ('\0', fp); /* This should set the error indicator. */
70 fflush (fp); /* Or this. */
71 if (dup2 (fd2, fd) < 0)
72 /* Whee... we botched the stream and now cannot restore it! */
73 abort ();
74 close (fd2);
75 }
76 errno = saved_errno;
77#else
78 #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."
79#endif
80}
diff --git a/gl/fseterr.h b/gl/fseterr.h
new file mode 100644
index 00000000..ac2b793e
--- /dev/null
+++ b/gl/fseterr.h
@@ -0,0 +1,55 @@
1/* Set the error indicator of a stream.
2 Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _FSETERR_H
18#define _FSETERR_H
19
20/* This file uses HAVE___FSETERR. */
21#if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23#endif
24
25#include <stdio.h>
26
27/* Set the error indicator of the stream FP.
28 The "error indicator" is set when an I/O operation on the stream fails, and
29 is cleared (together with the "end-of-file" indicator) by clearerr (FP). */
30
31#if HAVE___FSETERR /* musl libc */
32
33/* Haiku has __fseterr but does not declare it. */
34# if defined __HAIKU__
35extern void __fseterr (FILE *fp);
36# endif
37
38# include <stdio_ext.h>
39# define fseterr(fp) __fseterr (fp)
40
41#else
42
43# ifdef __cplusplus
44extern "C" {
45# endif
46
47extern void fseterr (FILE *fp);
48
49# ifdef __cplusplus
50}
51# endif
52
53#endif
54
55#endif /* _FSETERR_H */
diff --git a/gl/fstat.c b/gl/fstat.c
index 6a235002..292ce75f 100644
--- a/gl/fstat.c
+++ b/gl/fstat.c
@@ -1,5 +1,5 @@
1/* fstat() replacement. 1/* fstat() replacement.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -40,14 +40,7 @@ orig_fstat (int fd, struct stat *buf)
40#endif 40#endif
41 41
42/* Specification. */ 42/* Specification. */
43#ifdef __osf__ 43#include <sys/stat.h>
44/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
45 eliminates this include because of the preliminary #include <sys/stat.h>
46 above. */
47# include "sys/stat.h"
48#else
49# include <sys/stat.h>
50#endif
51 44
52#include "stat-time.h" 45#include "stat-time.h"
53 46
diff --git a/gl/fsusage.c b/gl/fsusage.c
index f6f4b1c3..1700a19c 100644
--- a/gl/fsusage.c
+++ b/gl/fsusage.c
@@ -1,6 +1,6 @@
1/* fsusage.c -- return space usage of mounted file systems 1/* fsusage.c -- return space usage of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2023 Free Software 3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -91,10 +91,12 @@ static int
91statvfs_works (void) 91statvfs_works (void)
92{ 92{
93 static int statvfs_works_cache = -1; 93 static int statvfs_works_cache = -1;
94 struct utsname name;
95 if (statvfs_works_cache < 0) 94 if (statvfs_works_cache < 0)
96 statvfs_works_cache = (uname (&name) == 0 95 {
97 && 0 <= strverscmp (name.release, "2.6.36")); 96 struct utsname name;
97 statvfs_works_cache = (uname (&name) == 0
98 && 0 <= strverscmp (name.release, "2.6.36"));
99 }
98 return statvfs_works_cache; 100 return statvfs_works_cache;
99} 101}
100# endif 102# endif
@@ -148,15 +150,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
148 ? PROPAGATE_ALL_ONES (fsd.f_frsize) 150 ? PROPAGATE_ALL_ONES (fsd.f_frsize)
149 : PROPAGATE_ALL_ONES (fsd.f_bsize)); 151 : PROPAGATE_ALL_ONES (fsd.f_bsize));
150 152
151#elif defined STAT_STATFS3_OSF1 /* OSF/1 */
152
153 struct statfs fsd;
154
155 if (statfs (file, &fsd, sizeof (struct statfs)) != 0)
156 return -1;
157
158 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
159
160#elif defined STAT_STATFS2_FRSIZE /* 2.6 < glibc/Linux < 2.6.36 */ 153#elif defined STAT_STATFS2_FRSIZE /* 2.6 < glibc/Linux < 2.6.36 */
161 154
162 struct statfs fsd; 155 struct statfs fsd;
@@ -201,7 +194,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
201 194
202 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); 195 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
203 196
204#elif defined STAT_STATFS4 /* SVR3, old Irix */ 197#elif defined STAT_STATFS4 /* SVR3 */
205 198
206 struct statfs fsd; 199 struct statfs fsd;
207 200
diff --git a/gl/fsusage.h b/gl/fsusage.h
index 9630b04e..bfa1857e 100644
--- a/gl/fsusage.h
+++ b/gl/fsusage.h
@@ -1,6 +1,6 @@
1/* fsusage.h -- declarations for file system space usage info 1/* fsusage.h -- declarations for file system space usage info
2 2
3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2023 Free Software 3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -19,9 +19,14 @@
19/* Space usage statistics for a file system. Blocks are 512-byte. */ 19/* Space usage statistics for a file system. Blocks are 512-byte. */
20 20
21#if !defined FSUSAGE_H_ 21#if !defined FSUSAGE_H_
22# define FSUSAGE_H_ 22#define FSUSAGE_H_
23
24#include <stdint.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
23 29
24# include <stdint.h>
25 30
26struct fs_usage 31struct fs_usage
27{ 32{
@@ -36,4 +41,9 @@ struct fs_usage
36 41
37int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); 42int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);
38 43
44
45#ifdef __cplusplus
46}
47#endif
48
39#endif 49#endif
diff --git a/gl/ftell.c b/gl/ftell.c
index ce2bd542..f2a64e73 100644
--- a/gl/ftell.c
+++ b/gl/ftell.c
@@ -1,5 +1,5 @@
1/* An ftell() function that works around platform bugs. 1/* An ftell() function that works around platform bugs.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/ftello.c b/gl/ftello.c
index 14184e5e..e4f96d1a 100644
--- a/gl/ftello.c
+++ b/gl/ftello.c
@@ -1,5 +1,5 @@
1/* An ftello() function that works around platform bugs. 1/* An ftello() function that works around platform bugs.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -20,7 +20,7 @@
20#include <stdio.h> 20#include <stdio.h>
21 21
22#include <errno.h> 22#include <errno.h>
23#include "intprops.h" 23#include <stdckdint.h>
24 24
25/* Get lseek. */ 25/* Get lseek. */
26#include <unistd.h> 26#include <unistd.h>
@@ -34,7 +34,10 @@ ftello (FILE *fp)
34# undef ftell 34# undef ftell
35# define ftello ftell 35# define ftello ftell
36#endif 36#endif
37#if _GL_WINDOWS_64_BIT_OFF_T 37#if (defined _WIN32 && !defined __CYGWIN__) \
38 /* We need to test _FILE_OFFSET_BITS for mingw-w64 */ \
39 /* and _GL_WINDOWS_64_BIT_OFF_T for MSVC. */ \
40 && (_FILE_OFFSET_BITS == 64 || _GL_WINDOWS_64_BIT_OFF_T)
38# undef ftello 41# undef ftello
39# if HAVE__FTELLI64 /* msvc, mingw64 */ 42# if HAVE__FTELLI64 /* msvc, mingw64 */
40# define ftello _ftelli64 43# define ftello _ftelli64
@@ -97,7 +100,7 @@ ftello (FILE *fp)
97 100
98 /* Compute pos + buffered, with overflow check. */ 101 /* Compute pos + buffered, with overflow check. */
99 off_t sum; 102 off_t sum;
100 if (! INT_ADD_OK (pos, buffered, &sum)) 103 if (ckd_add (&sum, pos, buffered))
101 { 104 {
102 errno = EOVERFLOW; 105 errno = EOVERFLOW;
103 return -1; 106 return -1;
@@ -121,13 +124,11 @@ ftello (FILE *fp)
121 gets confused by this. */ 124 gets confused by this. */
122 if (fp_->_flag & _IOWRT) 125 if (fp_->_flag & _IOWRT)
123 { 126 {
124 off_t pos;
125
126 /* Call ftello nevertheless, for the side effects that it does on fp. */ 127 /* Call ftello nevertheless, for the side effects that it does on fp. */
127 ftello (fp); 128 ftello (fp);
128 129
129 /* Compute the file position ourselves. */ 130 /* Compute the file position ourselves. */
130 pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR); 131 off_t pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
131 if (pos >= 0) 132 if (pos >= 0)
132 { 133 {
133 if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL) 134 if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c
index 3436c07a..ef6b506b 100644
--- a/gl/gai_strerror.c
+++ b/gl/gai_strerror.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2023 Free Software 1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2026 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. 4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
@@ -27,8 +27,8 @@
27# include <libintl.h> 27# include <libintl.h>
28#else 28#else
29# include "gettext.h" 29# include "gettext.h"
30# define _(String) gettext (String) 30# define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
31# define N_(String) String 31# define N_(msgid) msgid
32#endif 32#endif
33 33
34#if HAVE_DECL_GAI_STRERROR 34#if HAVE_DECL_GAI_STRERROR
@@ -79,8 +79,7 @@ values[] =
79const char * 79const char *
80gai_strerror (int code) 80gai_strerror (int code)
81{ 81{
82 size_t i; 82 for (size_t i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
83 for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
84 if (values[i].code == code) 83 if (values[i].code == code)
85 return _(values[i].msg); 84 return _(values[i].msg);
86 85
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 6586ee58..2b60377b 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,5 +1,5 @@
1/* Get address information (partial implementation). 1/* Get address information (partial implementation).
2 Copyright (C) 1997, 2001-2002, 2004-2023 Free Software Foundation, Inc. 2 Copyright (C) 1997, 2001-2002, 2004-2026 Free Software Foundation, Inc.
3 Contributed by Simon Josefsson <simon@josefsson.org>. 3 Contributed by Simon Josefsson <simon@josefsson.org>.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -40,8 +40,8 @@
40#include <stdio.h> 40#include <stdio.h>
41 41
42#include "gettext.h" 42#include "gettext.h"
43#define _(String) gettext (String) 43#define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
44#define N_(String) String 44#define N_(msgid) msgid
45 45
46/* BeOS has AF_INET, but not PF_INET. */ 46/* BeOS has AF_INET, but not PF_INET. */
47#ifndef PF_INET 47#ifndef PF_INET
@@ -52,9 +52,40 @@
52# define PF_UNSPEC 0 52# define PF_UNSPEC 0
53#endif 53#endif
54 54
55#if defined __sun || !HAVE_GETADDRINFO
56
57static bool
58is_numeric_host (const char *host, int family)
59{
60# if HAVE_IPV4
61 if (family == PF_INET || family == PF_UNSPEC)
62 {
63 /* glibc supports IPv4 addresses in numbers-and-dots notation, that is,
64 also hexadecimal and octal number formats and formats that don't
65 require all four bytes to be explicitly written, via inet_aton().
66 But POSIX doesn't require support for these legacy formats. Therefore
67 we are free to use inet_pton() instead of inet_aton(). */
68 struct in_addr addr;
69 if (inet_pton (AF_INET, host, &addr))
70 return true;
71 }
72# endif
73# if HAVE_IPV6
74 if (family == PF_INET6 || family == PF_UNSPEC)
75 {
76 struct in6_addr addr;
77 if (inet_pton (AF_INET6, host, &addr))
78 return true;
79 }
80# endif
81 return false;
82}
83
84#endif
85
55#if HAVE_GETADDRINFO 86#if HAVE_GETADDRINFO
56 87
57/* Override with cdecl calling convention. */ 88/* Override with cdecl calling convention and Windows and Solaris 10 fixes. */
58 89
59int 90int
60getaddrinfo (const char *restrict nodename, 91getaddrinfo (const char *restrict nodename,
@@ -63,6 +94,18 @@ getaddrinfo (const char *restrict nodename,
63 struct addrinfo **restrict res) 94 struct addrinfo **restrict res)
64# undef getaddrinfo 95# undef getaddrinfo
65{ 96{
97 /* Workaround for native Windows. */
98 if (hints && (hints->ai_flags & AI_NUMERICSERV) != 0
99 && servname && !(*servname >= '0' && *servname <= '9'))
100 return EAI_NONAME;
101
102# ifdef __sun
103 /* Workaround for Solaris 10. */
104 if (hints && (hints->ai_flags & AI_NUMERICHOST)
105 && nodename && !is_numeric_host (nodename, hints->ai_family))
106 return EAI_NONAME;
107# endif
108
66 return getaddrinfo (nodename, servname, hints, res); 109 return getaddrinfo (nodename, servname, hints, res);
67} 110}
68 111
@@ -110,14 +153,13 @@ static int
110use_win32_p (void) 153use_win32_p (void)
111{ 154{
112 static int done = 0; 155 static int done = 0;
113 HMODULE h;
114 156
115 if (done) 157 if (done)
116 return getaddrinfo_ptr ? 1 : 0; 158 return getaddrinfo_ptr ? 1 : 0;
117 159
118 done = 1; 160 done = 1;
119 161
120 h = GetModuleHandle ("ws2_32.dll"); 162 HMODULE h = GetModuleHandle ("ws2_32.dll");
121 163
122 if (h) 164 if (h)
123 { 165 {
@@ -169,16 +211,16 @@ validate_family (int family)
169{ 211{
170 /* FIXME: Support more families. */ 212 /* FIXME: Support more families. */
171# if HAVE_IPV4 213# if HAVE_IPV4
172 if (family == PF_INET) 214 if (family == PF_INET)
173 return true; 215 return true;
174# endif 216# endif
175# if HAVE_IPV6 217# if HAVE_IPV6
176 if (family == PF_INET6) 218 if (family == PF_INET6)
177 return true; 219 return true;
178# endif 220# endif
179 if (family == PF_UNSPEC) 221 if (family == PF_UNSPEC)
180 return true; 222 return true;
181 return false; 223 return false;
182} 224}
183 225
184/* Translate name of a service location and/or a service name to set of 226/* Translate name of a service location and/or a service name to set of
@@ -190,11 +232,6 @@ getaddrinfo (const char *restrict nodename,
190 struct addrinfo **restrict res) 232 struct addrinfo **restrict res)
191#undef getaddrinfo 233#undef getaddrinfo
192{ 234{
193 struct addrinfo *tmp;
194 int port = 0;
195 struct hostent *he;
196 void *storage;
197 size_t size;
198# if HAVE_IPV6 235# if HAVE_IPV6
199 struct v6_pair { 236 struct v6_pair {
200 struct addrinfo addrinfo; 237 struct addrinfo addrinfo;
@@ -210,10 +247,17 @@ getaddrinfo (const char *restrict nodename,
210 247
211# ifdef WINDOWS_NATIVE 248# ifdef WINDOWS_NATIVE
212 if (use_win32_p ()) 249 if (use_win32_p ())
213 return getaddrinfo_ptr (nodename, servname, hints, res); 250 {
251 if (hints && (hints->ai_flags & AI_NUMERICSERV) != 0
252 && servname && !(*servname >= '0' && *servname <= '9'))
253 return EAI_NONAME;
254 return getaddrinfo_ptr (nodename, servname, hints, res);
255 }
214# endif 256# endif
215 257
216 if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE))) 258 if (hints
259 && (hints->ai_flags
260 & ~(AI_CANONNAME | AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV)))
217 /* FIXME: Support more flags. */ 261 /* FIXME: Support more flags. */
218 return EAI_BADFLAGS; 262 return EAI_BADFLAGS;
219 263
@@ -225,18 +269,25 @@ getaddrinfo (const char *restrict nodename,
225 /* FIXME: Support other socktype. */ 269 /* FIXME: Support other socktype. */
226 return EAI_SOCKTYPE; /* FIXME: Better return code? */ 270 return EAI_SOCKTYPE; /* FIXME: Better return code? */
227 271
228 if (!nodename) 272 if (nodename != NULL)
273 {
274 if (hints && (hints->ai_flags & AI_NUMERICHOST) != 0
275 && !is_numeric_host (nodename, hints->ai_family))
276 return EAI_NONAME;
277 }
278 else
229 { 279 {
230 if (!(hints->ai_flags & AI_PASSIVE)) 280 if (!(hints->ai_flags & AI_PASSIVE))
231 return EAI_NONAME; 281 return EAI_NONAME;
232 282
233# ifdef HAVE_IPV6 283# if HAVE_IPV6
234 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0"; 284 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
235# else 285# else
236 nodename = "0.0.0.0"; 286 nodename = "0.0.0.0";
237# endif 287# endif
238 } 288 }
239 289
290 int port = 0;
240 if (servname) 291 if (servname)
241 { 292 {
242 struct servent *se = NULL; 293 struct servent *se = NULL;
@@ -262,10 +313,11 @@ getaddrinfo (const char *restrict nodename,
262 } 313 }
263 314
264 /* FIXME: Use gethostbyname_r if available. */ 315 /* FIXME: Use gethostbyname_r if available. */
265 he = gethostbyname (nodename); 316 struct hostent *he = gethostbyname (nodename);
266 if (!he || he->h_addr_list[0] == NULL) 317 if (!he || he->h_addr_list[0] == NULL)
267 return EAI_NONAME; 318 return EAI_NONAME;
268 319
320 size_t size;
269 switch (he->h_addrtype) 321 switch (he->h_addrtype)
270 { 322 {
271# if HAVE_IPV6 323# if HAVE_IPV6
@@ -284,10 +336,11 @@ getaddrinfo (const char *restrict nodename,
284 return EAI_NODATA; 336 return EAI_NODATA;
285 } 337 }
286 338
287 storage = calloc (1, size); 339 void *storage = calloc (1, size);
288 if (!storage) 340 if (!storage)
289 return EAI_MEMORY; 341 return EAI_MEMORY;
290 342
343 struct addrinfo *tmp;
291 switch (he->h_addrtype) 344 switch (he->h_addrtype)
292 { 345 {
293# if HAVE_IPV6 346# if HAVE_IPV6
@@ -402,9 +455,7 @@ freeaddrinfo (struct addrinfo *ai)
402 455
403 while (ai) 456 while (ai)
404 { 457 {
405 struct addrinfo *cur; 458 struct addrinfo *cur = ai;
406
407 cur = ai;
408 ai = ai->ai_next; 459 ai = ai->ai_next;
409 460
410 free (cur->ai_canonname); 461 free (cur->ai_canonname);
diff --git a/gl/getdelim.c b/gl/getdelim.c
index 79ec3dd1..21f3abc2 100644
--- a/gl/getdelim.c
+++ b/gl/getdelim.c
@@ -1,5 +1,5 @@
1/* getdelim.c --- Implementation of replacement getdelim function. 1/* getdelim.c --- Implementation of replacement getdelim function.
2 Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2023 Free Software 2 Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2026 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -30,10 +30,6 @@
30#include <stdlib.h> 30#include <stdlib.h>
31#include <errno.h> 31#include <errno.h>
32 32
33#ifndef SSIZE_MAX
34# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
35#endif
36
37#if USE_UNLOCKED_IO 33#if USE_UNLOCKED_IO
38# include "unlocked-io.h" 34# include "unlocked-io.h"
39# define getc_maybe_unlocked(fp) getc(fp) 35# define getc_maybe_unlocked(fp) getc(fp)
@@ -66,10 +62,13 @@ alloc_failed (void)
66ssize_t 62ssize_t
67getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) 63getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
68{ 64{
69 ssize_t result; 65 if (lineptr == NULL || n == NULL
70 size_t cur_len = 0; 66 /* glibc already declares this function as __nonnull ((4)).
71 67 Avoid a gcc warning "‘nonnull’ argument ‘fp’ compared to NULL". */
72 if (lineptr == NULL || n == NULL || fp == NULL) 68#if !(__GLIBC__ >= 2)
69 || fp == NULL
70#endif
71 )
73 { 72 {
74 errno = EINVAL; 73 errno = EINVAL;
75 return -1; 74 return -1;
@@ -77,6 +76,8 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
77 76
78 flockfile (fp); 77 flockfile (fp);
79 78
79 ssize_t result;
80
80 if (*lineptr == NULL || *n == 0) 81 if (*lineptr == NULL || *n == 0)
81 { 82 {
82 char *new_lineptr; 83 char *new_lineptr;
@@ -91,54 +92,56 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
91 *lineptr = new_lineptr; 92 *lineptr = new_lineptr;
92 } 93 }
93 94
94 for (;;) 95 {
95 { 96 size_t cur_len = 0;
96 int i; 97 for (;;)
97 98 {
98 i = getc_maybe_unlocked (fp); 99 int i;
99 if (i == EOF) 100
100 { 101 i = getc_maybe_unlocked (fp);
101 result = -1; 102 if (i == EOF)
103 {
104 result = -1;
105 break;
106 }
107
108 /* Make enough space for len+1 (for final NUL) bytes. */
109 if (cur_len + 1 >= *n)
110 {
111 size_t needed_max =
112 SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
113 size_t needed = 2 * *n + 1; /* Be generous. */
114
115 if (needed_max < needed)
116 needed = needed_max;
117 if (cur_len + 1 >= needed)
118 {
119 result = -1;
120 errno = EOVERFLOW;
121 goto unlock_return;
122 }
123
124 char *new_lineptr = (char *) realloc (*lineptr, needed);
125 if (new_lineptr == NULL)
126 {
127 alloc_failed ();
128 result = -1;
129 goto unlock_return;
130 }
131
132 *lineptr = new_lineptr;
133 *n = needed;
134 }
135
136 (*lineptr)[cur_len] = i;
137 cur_len++;
138
139 if (i == delimiter)
102 break; 140 break;
103 } 141 }
104 142 (*lineptr)[cur_len] = '\0';
105 /* Make enough space for len+1 (for final NUL) bytes. */ 143 result = cur_len ? cur_len : result;
106 if (cur_len + 1 >= *n) 144 }
107 {
108 size_t needed_max =
109 SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
110 size_t needed = 2 * *n + 1; /* Be generous. */
111 char *new_lineptr;
112
113 if (needed_max < needed)
114 needed = needed_max;
115 if (cur_len + 1 >= needed)
116 {
117 result = -1;
118 errno = EOVERFLOW;
119 goto unlock_return;
120 }
121
122 new_lineptr = (char *) realloc (*lineptr, needed);
123 if (new_lineptr == NULL)
124 {
125 alloc_failed ();
126 result = -1;
127 goto unlock_return;
128 }
129
130 *lineptr = new_lineptr;
131 *n = needed;
132 }
133
134 (*lineptr)[cur_len] = i;
135 cur_len++;
136
137 if (i == delimiter)
138 break;
139 }
140 (*lineptr)[cur_len] = '\0';
141 result = cur_len ? cur_len : result;
142 145
143 unlock_return: 146 unlock_return:
144 funlockfile (fp); /* doesn't set errno */ 147 funlockfile (fp); /* doesn't set errno */
diff --git a/gl/getdtablesize.c b/gl/getdtablesize.c
index ac2d1753..cc823952 100644
--- a/gl/getdtablesize.c
+++ b/gl/getdtablesize.c
@@ -1,5 +1,5 @@
1/* getdtablesize() function: Return maximum possible file descriptor value + 1. 1/* getdtablesize() function: Return maximum possible file descriptor value + 1.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -61,13 +61,10 @@ getdtablesize (void)
61 { 61 {
62 /* We are looking for the number N such that the valid file descriptors 62 /* We are looking for the number N such that the valid file descriptors
63 are 0..N-1. It can be obtained through a loop as follows: 63 are 0..N-1. It can be obtained through a loop as follows:
64 { 64 for (int fd = 3; fd < 65536; fd++)
65 int fd; 65 if (dup2 (0, fd) == -1)
66 for (fd = 3; fd < 65536; fd++) 66 break;
67 if (dup2 (0, fd) == -1) 67 return fd;
68 break;
69 return fd;
70 }
71 On Windows XP, the result is 2048. 68 On Windows XP, the result is 2048.
72 The drawback of this loop is that it allocates memory for a libc 69 The drawback of this loop is that it allocates memory for a libc
73 internal array that is never freed. 70 internal array that is never freed.
diff --git a/gl/gethostname.c b/gl/gethostname.c
index 0c616c34..464bac39 100644
--- a/gl/gethostname.c
+++ b/gl/gethostname.c
@@ -1,6 +1,6 @@
1/* gethostname emulation for SysV and POSIX.1. 1/* gethostname emulation for SysV and POSIX.1.
2 2
3 Copyright (C) 1992, 2003, 2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 1992, 2003, 2006, 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -89,12 +89,10 @@ gethostname (char *name, size_t len)
89int 89int
90rpl_gethostname (char *name, size_t len) 90rpl_gethostname (char *name, size_t len)
91{ 91{
92 int r;
93
94 if (len > INT_MAX) 92 if (len > INT_MAX)
95 len = INT_MAX; 93 len = INT_MAX;
96 gl_sockets_startup (SOCKETS_1_1); 94 gl_sockets_startup (SOCKETS_1_1);
97 r = gethostname (name, (int) len); 95 int r = gethostname (name, (int) len);
98 if (r < 0) 96 if (r < 0)
99 set_winsock_errno (); 97 set_winsock_errno ();
100 98
diff --git a/gl/getline.c b/gl/getline.c
index 85f16ab8..bbc8712d 100644
--- a/gl/getline.c
+++ b/gl/getline.c
@@ -1,5 +1,5 @@
1/* getline.c --- Implementation of replacement getline function. 1/* getline.c --- Implementation of replacement getline function.
2 Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/getloadavg.c b/gl/getloadavg.c
index 59b53e79..73b2ee28 100644
--- a/gl/getloadavg.c
+++ b/gl/getloadavg.c
@@ -1,6 +1,6 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 2
3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2023 Free Software 3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with gnulib. 6 NOTE: The canonical source of this file is maintained with gnulib.
@@ -47,8 +47,6 @@
47 N_NAME_POINTER The nlist n_name element is a pointer, 47 N_NAME_POINTER The nlist n_name element is a pointer,
48 not an array. 48 not an array.
49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'. 49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
50 LINUX_LDAV_FILE [__linux__, __ANDROID__, __CYGWIN__]: File
51 containing load averages.
52 50
53 Specific system predefines this file uses, aside from setting 51 Specific system predefines this file uses, aside from setting
54 default values if not emacs: 52 default values if not emacs:
@@ -65,8 +63,7 @@
65 UMAX4_3 63 UMAX4_3
66 VMS 64 VMS
67 _WIN32 Native Windows (possibly also defined on Cygwin) 65 _WIN32 Native Windows (possibly also defined on Cygwin)
68 __linux__, __ANDROID__ Linux: assumes /proc file system mounted. 66 __linux__, __ANDROID__ Linux: assumes sysinfo() call.
69 Support from Michael K. Johnson.
70 __CYGWIN__ Cygwin emulates linux /proc/loadavg. 67 __CYGWIN__ Cygwin emulates linux /proc/loadavg.
71 __NetBSD__ NetBSD: assumes /kern file system mounted. 68 __NetBSD__ NetBSD: assumes /kern file system mounted.
72 69
@@ -108,10 +105,10 @@
108# endif 105# endif
109 106
110/* Same issues as for NeXT apply to the HURD-based GNU system. */ 107/* Same issues as for NeXT apply to the HURD-based GNU system. */
111# ifdef __GNU__ 108# if defined __gnu_hurd__ || defined NeXT
112# undef BSD 109# undef BSD
113# undef FSCALE 110# undef FSCALE
114# endif /* __GNU__ */ 111# endif /* __gnu_hurd__ || NeXT */
115 112
116/* Set values that are different from the defaults, which are 113/* Set values that are different from the defaults, which are
117 set a little farther down with #ifndef. */ 114 set a little farther down with #ifndef. */
@@ -143,21 +140,6 @@
143# define SUNOS_5 140# define SUNOS_5
144# endif 141# endif
145 142
146# if defined (__osf__) && (defined (__alpha) || defined (__alpha__))
147# define OSF_ALPHA
148# include <sys/mbuf.h>
149# include <sys/socket.h>
150# include <net/route.h>
151# include <sys/table.h>
152/* Tru64 4.0D's table.h redefines sys */
153# undef sys
154# endif
155
156# if defined (__osf__) && (defined (mips) || defined (__mips__))
157# define OSF_MIPS
158# include <sys/table.h>
159# endif
160
161 143
162/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ 144/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */
163# ifndef LOAD_AVE_TYPE 145# ifndef LOAD_AVE_TYPE
@@ -170,31 +152,16 @@
170# define LOAD_AVE_TYPE long 152# define LOAD_AVE_TYPE long
171# endif 153# endif
172 154
173# ifdef sgi
174# define LOAD_AVE_TYPE long
175# endif
176
177# ifdef SVR4 155# ifdef SVR4
178# define LOAD_AVE_TYPE long 156# define LOAD_AVE_TYPE long
179# endif 157# endif
180 158
181# ifdef OSF_ALPHA
182# define LOAD_AVE_TYPE long
183# endif
184
185# if defined _AIX && ! defined HAVE_LIBPERFSTAT 159# if defined _AIX && ! defined HAVE_LIBPERFSTAT
186# define LOAD_AVE_TYPE long 160# define LOAD_AVE_TYPE long
187# endif 161# endif
188 162
189# endif /* No LOAD_AVE_TYPE. */ 163# endif /* No LOAD_AVE_TYPE. */
190 164
191# ifdef OSF_ALPHA
192/* <sys/param.h> defines an incorrect value for FSCALE on Alpha OSF/1,
193 according to ghazi@noc.rutgers.edu. */
194# undef FSCALE
195# define FSCALE 1024.0
196# endif
197
198 165
199# ifndef FSCALE 166# ifndef FSCALE
200 167
@@ -312,8 +279,7 @@
312# endif 279# endif
313# endif 280# endif
314 281
315# if defined (__GNU__) && !defined (NeXT) 282# if defined __gnu_hurd__ && !defined NeXT
316/* Note that NeXT Openstep defines __GNU__ even though it should not. */
317/* GNU system acts much like NeXT, for load average purposes, 283/* GNU system acts much like NeXT, for load average purposes,
318 but not exactly. */ 284 but not exactly. */
319# define NeXT 285# define NeXT
@@ -328,10 +294,6 @@
328# endif 294# endif
329# endif /* NeXT */ 295# endif /* NeXT */
330 296
331# ifdef sgi
332# include <sys/sysmp.h>
333# endif /* sgi */
334
335# ifdef UMAX 297# ifdef UMAX
336# include <signal.h> 298# include <signal.h>
337# include <sys/time.h> 299# include <sys/time.h>
@@ -358,6 +320,11 @@
358# include <sys/dg_sys_info.h> 320# include <sys/dg_sys_info.h>
359# endif 321# endif
360 322
323# if defined __linux__ || defined __ANDROID__
324# include <sys/param.h>
325# include <sys/sysinfo.h>
326# endif
327
361# if (defined __linux__ || defined __ANDROID__ \ 328# if (defined __linux__ || defined __ANDROID__ \
362 || defined __CYGWIN__ || defined SUNOS_5 \ 329 || defined __CYGWIN__ || defined SUNOS_5 \
363 || (defined LOAD_AVE_TYPE && ! defined __VMS)) 330 || (defined LOAD_AVE_TYPE && ! defined __VMS))
@@ -388,7 +355,7 @@ static bool getloadavg_initialized;
388/* Offset in kmem to seek to read load average, or 0 means invalid. */ 355/* Offset in kmem to seek to read load average, or 0 means invalid. */
389static long offset; 356static long offset;
390 357
391# if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__) 358# if ! defined __VMS && ! (defined __linux__ || defined __ANDROID__)
392static struct nlist name_list[2]; 359static struct nlist name_list[2];
393# endif 360# endif
394 361
@@ -417,51 +384,47 @@ getloadavg (double loadavg[], int nelem)
417# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT) /* Solaris <= 2.6 */ 384# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT) /* Solaris <= 2.6 */
418/* Use libkstat because we don't have to be root. */ 385/* Use libkstat because we don't have to be root. */
419# define LDAV_DONE 386# define LDAV_DONE
420 kstat_ctl_t *kc; 387 {
421 kstat_t *ksp; 388 kstat_ctl_t *kc = kstat_open ();
422 kstat_named_t *kn; 389 if (kc == NULL)
423 int saved_errno; 390 return -1;
424 391 kstat_t *ksp = kstat_lookup (kc, "unix", 0, "system_misc");
425 kc = kstat_open (); 392 if (ksp == NULL)
426 if (kc == NULL) 393 return -1;
427 return -1; 394 if (kstat_read (kc, ksp, 0) == -1)
428 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); 395 return -1;
429 if (ksp == NULL)
430 return -1;
431 if (kstat_read (kc, ksp, 0) == -1)
432 return -1;
433
434
435 kn = kstat_data_lookup (ksp, "avenrun_1min");
436 if (kn == NULL)
437 {
438 /* Return -1 if no load average information is available. */
439 nelem = 0;
440 elem = -1;
441 }
442
443 if (nelem >= 1)
444 loadavg[elem++] = (double) kn->value.ul / FSCALE;
445
446 if (nelem >= 2)
447 {
448 kn = kstat_data_lookup (ksp, "avenrun_5min");
449 if (kn != NULL)
450 {
451 loadavg[elem++] = (double) kn->value.ul / FSCALE;
452 396
453 if (nelem >= 3) 397 kstat_named_t *kn = kstat_data_lookup (ksp, "avenrun_1min");
454 { 398 if (kn == NULL)
455 kn = kstat_data_lookup (ksp, "avenrun_15min"); 399 {
456 if (kn != NULL) 400 /* Return -1 if no load average information is available. */
457 loadavg[elem++] = (double) kn->value.ul / FSCALE; 401 nelem = 0;
458 } 402 elem = -1;
459 } 403 }
460 } 404
405 if (nelem >= 1)
406 loadavg[elem++] = (double) kn->value.ul / FSCALE;
407
408 if (nelem >= 2)
409 {
410 kn = kstat_data_lookup (ksp, "avenrun_5min");
411 if (kn != NULL)
412 {
413 loadavg[elem++] = (double) kn->value.ul / FSCALE;
414
415 if (nelem >= 3)
416 {
417 kn = kstat_data_lookup (ksp, "avenrun_15min");
418 if (kn != NULL)
419 loadavg[elem++] = (double) kn->value.ul / FSCALE;
420 }
421 }
422 }
461 423
462 saved_errno = errno; 424 int saved_errno = errno;
463 kstat_close (kc); 425 kstat_close (kc);
464 errno = saved_errno; 426 errno = saved_errno;
427 }
465# endif /* HAVE_LIBKSTAT */ 428# endif /* HAVE_LIBKSTAT */
466 429
467# if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC) 430# if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
@@ -498,24 +461,36 @@ getloadavg (double loadavg[], int nelem)
498 } 461 }
499# endif 462# endif
500 463
501# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__) 464# if (!defined LDAV_DONE \
502 /* Linux without glibc, Android, Cygwin */ 465 && (defined __ANDROID__ ? 13 <= __ANDROID_API__ : defined __linux__))
466 /* non-Android Linux without glibc, Android 3.2+, Cygwin */
503# define LDAV_DONE 467# define LDAV_DONE
504# undef LOAD_AVE_TYPE 468# undef LOAD_AVE_TYPE
505 469
506# ifndef LINUX_LDAV_FILE 470 {
507# define LINUX_LDAV_FILE "/proc/loadavg" 471 struct sysinfo info;
508# endif 472 if (sysinfo (&info) < 0)
473 return -1;
474 loadavg[0] = info.loads[0] / (double)(1U << SI_LOAD_SHIFT);
475 loadavg[1] = info.loads[1] / (double)(1U << SI_LOAD_SHIFT);
476 loadavg[2] = info.loads[2] / (double)(1U << SI_LOAD_SHIFT);
477 elem = 3;
478 }
479# endif /* __ANDROID__ ? 13 <= __ANDROID_API__ : __linux__ */
480
481# if !defined (LDAV_DONE) && defined __CYGWIN__
482 /* Cygwin */
483# define LDAV_DONE
484# undef LOAD_AVE_TYPE
509 485
510 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")]; 486 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
511 char const *ptr = ldavgbuf; 487 char const *ptr = ldavgbuf;
512 int fd, count, saved_errno;
513 488
514 fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC); 489 int fd = open ("/proc/loadavg", O_RDONLY | O_CLOEXEC);
515 if (fd == -1) 490 if (fd == -1)
516 return -1; 491 return -1;
517 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1); 492 int count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
518 saved_errno = errno; 493 int saved_errno = errno;
519 (void) close (fd); 494 (void) close (fd);
520 errno = saved_errno; 495 errno = saved_errno;
521 if (count <= 0) 496 if (count <= 0)
@@ -524,9 +499,6 @@ getloadavg (double loadavg[], int nelem)
524 499
525 for (elem = 0; elem < nelem; elem++) 500 for (elem = 0; elem < nelem; elem++)
526 { 501 {
527 double numerator = 0;
528 double denominator = 1;
529
530 while (*ptr == ' ') 502 while (*ptr == ' ')
531 ptr++; 503 ptr++;
532 504
@@ -542,6 +514,9 @@ getloadavg (double loadavg[], int nelem)
542 break; 514 break;
543 } 515 }
544 516
517 double numerator = 0;
518 double denominator = 1;
519
545 while ('0' <= *ptr && *ptr <= '9') 520 while ('0' <= *ptr && *ptr <= '9')
546 numerator = 10 * numerator + (*ptr++ - '0'); 521 numerator = 10 * numerator + (*ptr++ - '0');
547 522
@@ -554,7 +529,7 @@ getloadavg (double loadavg[], int nelem)
554 529
555 return elem; 530 return elem;
556 531
557# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */ 532# endif /* __CYGWIN__ */
558 533
559# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */ 534# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */
560# define LDAV_DONE 535# define LDAV_DONE
@@ -564,24 +539,25 @@ getloadavg (double loadavg[], int nelem)
564# define NETBSD_LDAV_FILE "/kern/loadavg" 539# define NETBSD_LDAV_FILE "/kern/loadavg"
565# endif 540# endif
566 541
567 unsigned long int load_ave[3], scale;
568 int count;
569 char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
570 int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC); 542 int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
571 if (fd < 0) 543 if (fd < 0)
572 return fd; 544 return fd;
545
546 char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
573 int nread = read (fd, readbuf, sizeof readbuf - 1); 547 int nread = read (fd, readbuf, sizeof readbuf - 1);
574 int err = errno; 548 int saved_errno = errno;
575 close (fd); 549 close (fd);
576 if (nread < 0) 550 if (nread < 0)
577 { 551 {
578 errno = err; 552 errno = saved_errno;
579 return -1; 553 return -1;
580 } 554 }
581 readbuf[nread] = '\0'; 555 readbuf[nread] = '\0';
582 count = sscanf (readbuf, "%lu %lu %lu %lu\n", 556
583 &load_ave[0], &load_ave[1], &load_ave[2], 557 unsigned long int load_ave[3], scale;
584 &scale); 558 int count = sscanf (readbuf, "%lu %lu %lu %lu\n",
559 &load_ave[0], &load_ave[1], &load_ave[2],
560 &scale);
585 if (count != 4) 561 if (count != 4)
586 { 562 {
587 errno = ENOTSUP; 563 errno = ENOTSUP;
@@ -599,10 +575,6 @@ getloadavg (double loadavg[], int nelem)
599# define LDAV_DONE 575# define LDAV_DONE
600 /* The NeXT code was adapted from iscreen 3.2. */ 576 /* The NeXT code was adapted from iscreen 3.2. */
601 577
602 host_t host;
603 struct processor_set_basic_info info;
604 unsigned int info_count;
605
606 /* We only know how to get the 1-minute average for this system, 578 /* We only know how to get the 1-minute average for this system,
607 so even if the caller asks for more than 1, we only return 1. */ 579 so even if the caller asks for more than 1, we only return 1. */
608 580
@@ -614,7 +586,9 @@ getloadavg (double loadavg[], int nelem)
614 586
615 if (getloadavg_initialized) 587 if (getloadavg_initialized)
616 { 588 {
617 info_count = PROCESSOR_SET_BASIC_INFO_COUNT; 589 host_t host;
590 struct processor_set_basic_info info;
591 unsigned int info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
618 if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host, 592 if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
619 (processor_set_info_t) &info, &info_count) 593 (processor_set_info_t) &info, &info_count)
620 != KERN_SUCCESS) 594 != KERN_SUCCESS)
@@ -640,14 +614,9 @@ getloadavg (double loadavg[], int nelem)
640 can be gathered with inq_stats system calls. 614 can be gathered with inq_stats system calls.
641 We only know how to get the 1-minute average for this system. */ 615 We only know how to get the 1-minute average for this system. */
642 616
643 struct proc_summary proc_sum_data;
644 struct stat_descr proc_info;
645 double load;
646 register unsigned int i, j;
647
648 if (cpus == 0) 617 if (cpus == 0)
649 { 618 {
650 register unsigned int c, i; 619 register unsigned int c;
651 struct cpu_config conf; 620 struct cpu_config conf;
652 struct stat_descr desc; 621 struct stat_descr desc;
653 622
@@ -661,7 +630,7 @@ getloadavg (double loadavg[], int nelem)
661 return -1; 630 return -1;
662 631
663 c = 0; 632 c = 0;
664 for (i = 0; i < conf.config_maxclass; ++i) 633 for (unsigned int i = 0; i < conf.config_maxclass; ++i)
665 { 634 {
666 struct class_stats stats; 635 struct class_stats stats;
667 memset (&stats, 0, sizeof stats); 636 memset (&stats, 0, sizeof stats);
@@ -680,6 +649,9 @@ getloadavg (double loadavg[], int nelem)
680 samples = cpus < 2 ? 3 : (2 * cpus / 3); 649 samples = cpus < 2 ? 3 : (2 * cpus / 3);
681 } 650 }
682 651
652 struct proc_summary proc_sum_data;
653
654 struct stat_descr proc_info;
683 proc_info.sd_next = 0; 655 proc_info.sd_next = 0;
684 proc_info.sd_subsys = SUBSYS_PROC; 656 proc_info.sd_subsys = SUBSYS_PROC;
685 proc_info.sd_type = PROCTYPE_SUMMARY; 657 proc_info.sd_type = PROCTYPE_SUMMARY;
@@ -690,9 +662,9 @@ getloadavg (double loadavg[], int nelem)
690 if (inq_stats (1, &proc_info) != 0) 662 if (inq_stats (1, &proc_info) != 0)
691 return -1; 663 return -1;
692 664
693 load = proc_sum_data.ps_nrunnable; 665 double load = proc_sum_data.ps_nrunnable;
694 j = 0; 666 register unsigned int j = 0;
695 for (i = samples - 1; i > 0; --i) 667 for (unsigned int i = samples - 1; i > 0; --i)
696 { 668 {
697 load += proc_sum_data.ps_nrun[j]; 669 load += proc_sum_data.ps_nrun[j];
698 if (j++ == PS_NRUNSIZE) 670 if (j++ == PS_NRUNSIZE)
@@ -767,18 +739,6 @@ getloadavg (double loadavg[], int nelem)
767 } 739 }
768# endif /* __MSDOS__ || WINDOWS32 */ 740# endif /* __MSDOS__ || WINDOWS32 */
769 741
770# if !defined (LDAV_DONE) && defined (OSF_ALPHA) /* OSF/1 */
771# define LDAV_DONE
772
773 struct tbl_loadavg load_ave;
774 table (TBL_LOADAVG, 0, &load_ave, 1, sizeof (load_ave));
775 for (elem = 0; elem < nelem; elem++)
776 loadavg[elem]
777 = (load_ave.tl_lscale == 0
778 ? load_ave.tl_avenrun.d[elem]
779 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
780# endif /* OSF_ALPHA */
781
782# if ! defined LDAV_DONE && defined __VMS /* VMS */ 742# if ! defined LDAV_DONE && defined __VMS /* VMS */
783 /* VMS specific code -- read from the Load Ave driver. */ 743 /* VMS specific code -- read from the Load Ave driver. */
784 744
@@ -823,52 +783,44 @@ getloadavg (double loadavg[], int nelem)
823# endif /* ! defined LDAV_DONE && defined __VMS */ 783# endif /* ! defined LDAV_DONE && defined __VMS */
824 784
825# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS 785# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
826 /* IRIX, other old systems */ 786 /* other old systems */
827 787
828 /* UNIX-specific code -- read the average from /dev/kmem. */ 788 /* UNIX-specific code -- read the average from /dev/kmem. */
829 789
830# define LDAV_PRIVILEGED /* This code requires special installation. */ 790# define LDAV_PRIVILEGED /* This code requires special installation. */
831 791
832 LOAD_AVE_TYPE load_ave[3];
833
834 /* Get the address of LDAV_SYMBOL. */ 792 /* Get the address of LDAV_SYMBOL. */
835 if (offset == 0) 793 if (offset == 0)
836 { 794 {
837# ifndef sgi 795# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
838# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
839 strcpy (name_list[0].n_name, LDAV_SYMBOL); 796 strcpy (name_list[0].n_name, LDAV_SYMBOL);
840 strcpy (name_list[1].n_name, ""); 797 strcpy (name_list[1].n_name, "");
841# else /* NLIST_STRUCT */ 798# else /* NLIST_STRUCT */
842# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME 799# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
843 name_list[0].n_un.n_name = LDAV_SYMBOL; 800 name_list[0].n_un.n_name = LDAV_SYMBOL;
844 name_list[1].n_un.n_name = 0; 801 name_list[1].n_un.n_name = 0;
845# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */ 802# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
846 name_list[0].n_name = LDAV_SYMBOL; 803 name_list[0].n_name = LDAV_SYMBOL;
847 name_list[1].n_name = 0; 804 name_list[1].n_name = 0;
848# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */ 805# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
849# endif /* NLIST_STRUCT */ 806# endif /* NLIST_STRUCT */
850 807
851# ifndef SUNOS_5 808# ifndef SUNOS_5
852 if ( 809 if (
853# if !defined (_AIX) 810# if !defined (_AIX)
854 nlist (KERNEL_FILE, name_list) 811 nlist (KERNEL_FILE, name_list)
855# else /* _AIX */ 812# else /* _AIX */
856 knlist (name_list, 1, sizeof (name_list[0])) 813 knlist (name_list, 1, sizeof (name_list[0]))
857# endif 814# endif
858 >= 0) 815 >= 0)
859 /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */ 816 /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */
860 { 817 {
861# ifdef FIXUP_KERNEL_SYMBOL_ADDR 818# ifdef FIXUP_KERNEL_SYMBOL_ADDR
862 FIXUP_KERNEL_SYMBOL_ADDR (name_list); 819 FIXUP_KERNEL_SYMBOL_ADDR (name_list);
863# endif 820# endif
864 offset = name_list[0].n_value; 821 offset = name_list[0].n_value;
865 } 822 }
866# endif /* !SUNOS_5 */ 823# endif /* !SUNOS_5 */
867# else /* sgi */
868 ptrdiff_t ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
869 if (ldav_off != -1)
870 offset = (long int) ldav_off & 0x7fffffff;
871# endif /* sgi */
872 } 824 }
873 825
874 /* Make sure we have /dev/kmem open. */ 826 /* Make sure we have /dev/kmem open. */
@@ -895,6 +847,8 @@ getloadavg (double loadavg[], int nelem)
895# endif /* SUNOS_5 */ 847# endif /* SUNOS_5 */
896 } 848 }
897 849
850 LOAD_AVE_TYPE load_ave[3];
851
898 /* If we can, get the load average values. */ 852 /* If we can, get the load average values. */
899 if (offset && getloadavg_initialized) 853 if (offset && getloadavg_initialized)
900 { 854 {
diff --git a/gl/getopt-cdefs.in.h b/gl/getopt-cdefs.in.h
index e76c78cb..57406947 100644
--- a/gl/getopt-cdefs.in.h
+++ b/gl/getopt-cdefs.in.h
@@ -1,5 +1,5 @@
1/* getopt-on-non-glibc compatibility macros. 1/* getopt-on-non-glibc compatibility macros.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared 4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library. 5 with the GNU C Library.
@@ -46,10 +46,14 @@
46# endif 46# endif
47#endif 47#endif
48 48
49#if defined __clang__
50 /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
51# undef __GNUC_PREREQ
52# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
53#endif
49#ifndef __GNUC_PREREQ 54#ifndef __GNUC_PREREQ
50# if defined __GNUC__ && defined __GNUC_VERSION__ 55# if defined __GNUC__ && defined __GNUC_MINOR__
51# define __GNUC_PREREQ(maj, min) \ 56# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
52 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
53# else 57# else
54# define __GNUC_PREREQ(maj, min) 0 58# define __GNUC_PREREQ(maj, min) 0
55# endif 59# endif
@@ -57,7 +61,11 @@
57 61
58#ifndef __THROW 62#ifndef __THROW
59# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4) 63# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
60# define __THROW throw () 64# if __cplusplus >= 201103L
65# define __THROW noexcept (true)
66# else
67# define __THROW throw ()
68# endif
61# else 69# else
62# define __THROW 70# define __THROW
63# endif 71# endif
diff --git a/gl/getopt-core.h b/gl/getopt-core.h
index c5dd4936..c815966f 100644
--- a/gl/getopt-core.h
+++ b/gl/getopt-core.h
@@ -1,5 +1,5 @@
1/* Declarations for getopt (basic, portable features only). 1/* Declarations for getopt (basic, portable features only).
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib. 3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects. 4 Patches to this file should be submitted to both projects.
5 5
diff --git a/gl/getopt-ext.h b/gl/getopt-ext.h
index d37c2932..c0784d96 100644
--- a/gl/getopt-ext.h
+++ b/gl/getopt-ext.h
@@ -1,5 +1,5 @@
1/* Declarations for getopt (GNU extensions). 1/* Declarations for getopt (GNU extensions).
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib. 3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects. 4 Patches to this file should be submitted to both projects.
5 5
diff --git a/gl/getopt-pfx-core.h b/gl/getopt-pfx-core.h
index 3a2fde5a..d7dd8788 100644
--- a/gl/getopt-pfx-core.h
+++ b/gl/getopt-pfx-core.h
@@ -1,5 +1,5 @@
1/* getopt (basic, portable features) gnulib wrapper header. 1/* getopt (basic, portable features) gnulib wrapper header.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared 4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library. 5 with the GNU C Library.
@@ -31,6 +31,16 @@
31 functions and variables. Renaming avoids problems with some 31 functions and variables. Renaming avoids problems with some
32 compilers and linkers. */ 32 compilers and linkers. */
33#ifdef __GETOPT_PREFIX 33#ifdef __GETOPT_PREFIX
34
35/* Include platform-dependent header files that may declare getopt() and
36 friends. */
37# if defined _AIX || defined __hpux || defined __sun || defined __QNX__
38# include <stdio.h>
39# endif
40# if defined MUSL_LIBC || (defined __FreeBSD__ || defined __DragonFly__) || defined __NetBSD__ || defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined _AIX || defined __sun || defined __minix || defined __HAIKU__
41# include <unistd.h>
42# endif
43
34# ifndef __GETOPT_ID 44# ifndef __GETOPT_ID
35# define __GETOPT_CONCAT(x, y) x ## y 45# define __GETOPT_CONCAT(x, y) x ## y
36# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) 46# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
@@ -47,7 +57,7 @@
47# define optind __GETOPT_ID (optind) 57# define optind __GETOPT_ID (optind)
48# define optopt __GETOPT_ID (optopt) 58# define optopt __GETOPT_ID (optopt)
49 59
50/* Work around a a problem on macOS, which declares getopt with a 60/* Work around a problem on macOS, which declares getopt with a
51 trailing __DARWIN_ALIAS(getopt) that would expand to something like 61 trailing __DARWIN_ALIAS(getopt) that would expand to something like
52 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following 62 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
53 hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */ 63 hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
diff --git a/gl/getopt-pfx-ext.h b/gl/getopt-pfx-ext.h
index 8578d725..db2e27f3 100644
--- a/gl/getopt-pfx-ext.h
+++ b/gl/getopt-pfx-ext.h
@@ -1,5 +1,5 @@
1/* getopt (GNU extensions) gnulib wrapper header. 1/* getopt (GNU extensions) gnulib wrapper header.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared 4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library. 5 with the GNU C Library.
@@ -38,11 +38,9 @@
38# endif 38# endif
39# undef getopt_long 39# undef getopt_long
40# undef getopt_long_only 40# undef getopt_long_only
41# undef option
42# undef _getopt_internal 41# undef _getopt_internal
43# define getopt_long __GETOPT_ID (getopt_long) 42# define getopt_long __GETOPT_ID (getopt_long)
44# define getopt_long_only __GETOPT_ID (getopt_long_only) 43# define getopt_long_only __GETOPT_ID (getopt_long_only)
45# define option __GETOPT_ID (option)
46# define _getopt_internal __GETOPT_ID (getopt_internal) 44# define _getopt_internal __GETOPT_ID (getopt_internal)
47 45
48/* The system's getopt.h may have already included getopt-ext.h to 46/* The system's getopt.h may have already included getopt-ext.h to
diff --git a/gl/getopt.c b/gl/getopt.c
index 1e2441c4..406a406b 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -1,5 +1,5 @@
1/* Getopt for GNU. 1/* Getopt for GNU.
2 Copyright (C) 1987-2023 Free Software Foundation, Inc. 2 Copyright (C) 1987-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib. 3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects. 4 Patches to this file should be submitted to both projects.
5 5
@@ -21,7 +21,7 @@
21# include <config.h> 21# include <config.h>
22#endif 22#endif
23 23
24#include "getopt.h" 24#include <getopt.h>
25 25
26#include <stdio.h> 26#include <stdio.h>
27#include <stdlib.h> 27#include <stdlib.h>
@@ -42,7 +42,7 @@
42# define funlockfile(fp) _IO_funlockfile (fp) 42# define funlockfile(fp) _IO_funlockfile (fp)
43#else 43#else
44# include "gettext.h" 44# include "gettext.h"
45# define _(msgid) gettext (msgid) 45# define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
46/* When used standalone, flockfile and funlockfile might not be 46/* When used standalone, flockfile and funlockfile might not be
47 available. */ 47 available. */
48# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \ 48# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
@@ -133,7 +133,6 @@ exchange (char **argv, struct _getopt_data *d)
133 int bottom = d->__first_nonopt; 133 int bottom = d->__first_nonopt;
134 int middle = d->__last_nonopt; 134 int middle = d->__last_nonopt;
135 int top = d->optind; 135 int top = d->optind;
136 char *tem;
137 136
138 /* Exchange the shorter segment with the far end of the longer segment. 137 /* Exchange the shorter segment with the far end of the longer segment.
139 That puts the shorter segment into the right place. 138 That puts the shorter segment into the right place.
@@ -151,7 +150,7 @@ exchange (char **argv, struct _getopt_data *d)
151 /* Swap it with the top part of the top segment. */ 150 /* Swap it with the top part of the top segment. */
152 for (i = 0; i < len; i++) 151 for (i = 0; i < len; i++)
153 { 152 {
154 tem = argv[bottom + i]; 153 char *tem = argv[bottom + i];
155 argv[bottom + i] = argv[top - (middle - bottom) + i]; 154 argv[bottom + i] = argv[top - (middle - bottom) + i];
156 argv[top - (middle - bottom) + i] = tem; 155 argv[top - (middle - bottom) + i] = tem;
157 } 156 }
@@ -167,7 +166,7 @@ exchange (char **argv, struct _getopt_data *d)
167 /* Swap it with the bottom part of the bottom segment. */ 166 /* Swap it with the bottom part of the bottom segment. */
168 for (i = 0; i < len; i++) 167 for (i = 0; i < len; i++)
169 { 168 {
170 tem = argv[bottom + i]; 169 char *tem = argv[bottom + i];
171 argv[bottom + i] = argv[middle + i]; 170 argv[bottom + i] = argv[middle + i];
172 argv[middle + i] = tem; 171 argv[middle + i] = tem;
173 } 172 }
@@ -196,36 +195,39 @@ process_long_option (int argc, char **argv, const char *optstring,
196 int long_only, struct _getopt_data *d, 195 int long_only, struct _getopt_data *d,
197 int print_errors, const char *prefix) 196 int print_errors, const char *prefix)
198{ 197{
199 char *nameend;
200 size_t namelen;
201 const struct option *p;
202 const struct option *pfound = NULL;
203 int n_options;
204 int option_index;
205 198
199 char *nameend;
206 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) 200 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
207 /* Do nothing. */ ; 201 /* Do nothing. */ ;
208 namelen = nameend - d->__nextchar; 202 size_t namelen = nameend - d->__nextchar;
209 203
210 /* First look for an exact match, counting the options as a side 204 /* First look for an exact match, counting the options as a side
211 effect. */ 205 effect. */
212 for (p = longopts, n_options = 0; p->name; p++, n_options++) 206 const struct option *pfound = NULL;
213 if (!strncmp (p->name, d->__nextchar, namelen) 207 int n_options;
214 && namelen == strlen (p->name)) 208 int option_index;
215 { 209 {
216 /* Exact match found. */ 210 const struct option *p;
217 pfound = p; 211 for (p = longopts, n_options = 0; p->name; p++, n_options++)
218 option_index = n_options; 212 if (!strncmp (p->name, d->__nextchar, namelen)
219 break; 213 && namelen == strlen (p->name))
220 } 214 {
215 /* Exact match found. */
216 pfound = p;
217 option_index = n_options;
218 break;
219 }
220 }
221 221
222 if (pfound == NULL) 222 if (pfound == NULL)
223 { 223 {
224 /* Didn't find an exact match, so look for abbreviations. */ 224 /* Didn't find an exact match, so look for abbreviations. */
225 unsigned char *ambig_set = NULL; 225 unsigned char *ambig_set = NULL;
226 int ambig_malloced = 0; 226 /* Use simpler fallback diagnostic if ambig_set == &ambig_fallback. */
227 int ambig_fallback = 0; 227 unsigned char ambig_fallback;
228 void *ambig_malloced = NULL;
228 int indfound = -1; 229 int indfound = -1;
230 const struct option *p;
229 231
230 for (p = longopts, option_index = 0; p->name; p++, option_index++) 232 for (p = longopts, option_index = 0; p->name; p++, option_index++)
231 if (!strncmp (p->name, d->__nextchar, namelen)) 233 if (!strncmp (p->name, d->__nextchar, namelen))
@@ -242,39 +244,42 @@ process_long_option (int argc, char **argv, const char *optstring,
242 || pfound->val != p->val) 244 || pfound->val != p->val)
243 { 245 {
244 /* Second or later nonexact match found. */ 246 /* Second or later nonexact match found. */
245 if (!ambig_fallback) 247 if (ambig_set != &ambig_fallback)
246 { 248 {
247 if (!print_errors) 249 if (!print_errors)
248 /* Don't waste effort tracking the ambig set if 250 /* Don't waste effort tracking the ambig set if
249 we're not going to print it anyway. */ 251 we're not going to print it anyway. */
250 ambig_fallback = 1; 252 ambig_set = &ambig_fallback;
251 else if (!ambig_set) 253 else if (!ambig_set)
252 { 254 {
253 if (__libc_use_alloca (n_options)) 255 if (__libc_use_alloca (n_options))
254 ambig_set = alloca (n_options); 256 ambig_set = alloca (n_options);
255 else if ((ambig_set = malloc (n_options)) == NULL)
256 /* Fall back to simpler error message. */
257 ambig_fallback = 1;
258 else 257 else
259 ambig_malloced = 1; 258 {
259 ambig_malloced = malloc (n_options);
260 /* Fall back to simpler diagnostic if
261 memory allocation fails. */
262 ambig_set = (ambig_malloced ? ambig_malloced
263 : &ambig_fallback);
264 }
260 265
261 if (ambig_set) 266 if (ambig_set != &ambig_fallback)
262 { 267 {
263 memset (ambig_set, 0, n_options); 268 memset (ambig_set, 0, n_options);
264 ambig_set[indfound] = 1; 269 ambig_set[indfound] = 1;
265 } 270 }
266 } 271 }
267 if (ambig_set) 272 if (ambig_set && ambig_set != &ambig_fallback)
268 ambig_set[option_index] = 1; 273 ambig_set[option_index] = 1;
269 } 274 }
270 } 275 }
271 } 276 }
272 277
273 if (ambig_set || ambig_fallback) 278 if (ambig_set)
274 { 279 {
275 if (print_errors) 280 if (print_errors)
276 { 281 {
277 if (ambig_fallback) 282 if (ambig_set == &ambig_fallback)
278 fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"), 283 fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"),
279 argv[0], prefix, d->__nextchar); 284 argv[0], prefix, d->__nextchar);
280 else 285 else
@@ -296,8 +301,7 @@ process_long_option (int argc, char **argv, const char *optstring,
296 funlockfile (stderr); 301 funlockfile (stderr);
297 } 302 }
298 } 303 }
299 if (ambig_malloced) 304 free (ambig_malloced);
300 free (ambig_set);
301 d->__nextchar += strlen (d->__nextchar); 305 d->__nextchar += strlen (d->__nextchar);
302 d->optind++; 306 d->optind++;
303 d->optopt = 0; 307 d->optopt = 0;
@@ -472,11 +476,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
472 const struct option *longopts, int *longind, 476 const struct option *longopts, int *longind,
473 int long_only, struct _getopt_data *d, int posixly_correct) 477 int long_only, struct _getopt_data *d, int posixly_correct)
474{ 478{
475 int print_errors = d->opterr;
476
477 if (argc < 1) 479 if (argc < 1)
478 return -1; 480 return -1;
479 481
482 int print_errors = d->opterr;
483
480 d->optarg = NULL; 484 d->optarg = NULL;
481 485
482 if (d->optind == 0 || !d->__initialized) 486 if (d->optind == 0 || !d->__initialized)
@@ -591,11 +595,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
591 if (long_only && (argv[d->optind][2] 595 if (long_only && (argv[d->optind][2]
592 || !strchr (optstring, argv[d->optind][1]))) 596 || !strchr (optstring, argv[d->optind][1])))
593 { 597 {
594 int code;
595 d->__nextchar = argv[d->optind] + 1; 598 d->__nextchar = argv[d->optind] + 1;
596 code = process_long_option (argc, argv, optstring, longopts, 599 int code = process_long_option (argc, argv, optstring, longopts,
597 longind, long_only, d, 600 longind, long_only, d,
598 print_errors, "-"); 601 print_errors, "-");
599 if (code != -1) 602 if (code != -1)
600 return code; 603 return code;
601 } 604 }
@@ -704,14 +707,12 @@ _getopt_internal (int argc, char **argv, const char *optstring,
704 const struct option *longopts, int *longind, int long_only, 707 const struct option *longopts, int *longind, int long_only,
705 int posixly_correct) 708 int posixly_correct)
706{ 709{
707 int result;
708
709 getopt_data.optind = optind; 710 getopt_data.optind = optind;
710 getopt_data.opterr = opterr; 711 getopt_data.opterr = opterr;
711 712
712 result = _getopt_internal_r (argc, argv, optstring, longopts, 713 int result = _getopt_internal_r (argc, argv, optstring, longopts,
713 longind, long_only, &getopt_data, 714 longind, long_only, &getopt_data,
714 posixly_correct); 715 posixly_correct);
715 716
716 optind = getopt_data.optind; 717 optind = getopt_data.optind;
717 optarg = getopt_data.optarg; 718 optarg = getopt_data.optarg;
@@ -720,7 +721,7 @@ _getopt_internal (int argc, char **argv, const char *optstring,
720 return result; 721 return result;
721} 722}
722 723
723/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt. 724/* glibc gets a LSB-compliant getopt and a POSIX-compliant __posix_getopt.
724 Standalone applications just get a POSIX-compliant getopt. 725 Standalone applications just get a POSIX-compliant getopt.
725 POSIX and LSB both require these functions to take 'char *const *argv' 726 POSIX and LSB both require these functions to take 'char *const *argv'
726 even though this is incorrect (because of the permutation). */ 727 even though this is incorrect (because of the permutation). */
@@ -729,7 +730,7 @@ _getopt_internal (int argc, char **argv, const char *optstring,
729 NAME (int argc, char *const *argv, const char *optstring) \ 730 NAME (int argc, char *const *argv, const char *optstring) \
730 { \ 731 { \
731 return _getopt_internal (argc, (char **)argv, optstring, \ 732 return _getopt_internal (argc, (char **)argv, optstring, \
732 0, 0, 0, POSIXLY_CORRECT); \ 733 NULL, NULL, 0, POSIXLY_CORRECT); \
733 } 734 }
734 735
735#ifdef _LIBC 736#ifdef _LIBC
@@ -748,14 +749,13 @@ GETOPT_ENTRY(getopt, 1)
748int 749int
749main (int argc, char **argv) 750main (int argc, char **argv)
750{ 751{
751 int c;
752 int digit_optind = 0; 752 int digit_optind = 0;
753 753
754 while (1) 754 while (1)
755 { 755 {
756 int this_option_optind = optind ? optind : 1; 756 int this_option_optind = optind ? optind : 1;
757 757
758 c = getopt (argc, argv, "abc:d:0123456789"); 758 int c = getopt (argc, argv, "abc:d:0123456789");
759 if (c == -1) 759 if (c == -1)
760 break; 760 break;
761 761
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index 0867d365..e72a034b 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,5 +1,5 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared 4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library, which supplies a different version of 5 with the GNU C Library, which supplies a different version of
@@ -30,7 +30,12 @@
30 <getopt.h>; our definitions will be present soon enough. */ 30 <getopt.h>; our definitions will be present soon enough. */
31#if @HAVE_GETOPT_H@ 31#if @HAVE_GETOPT_H@
32# define _GL_SYSTEM_GETOPT 32# define _GL_SYSTEM_GETOPT
33/* Rename the system's 'struct option' to 'struct sys_option',
34 so that we don't have to rename ours to 'struct rpl_option'
35 (which would cause significant trouble in C++ mode). */
36# define option sys_option
33# @INCLUDE_NEXT@ @NEXT_GETOPT_H@ 37# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
38# undef option
34# undef _GL_SYSTEM_GETOPT 39# undef _GL_SYSTEM_GETOPT
35#endif 40#endif
36 41
diff --git a/gl/getopt1.c b/gl/getopt1.c
index 49323aa8..a5f99888 100644
--- a/gl/getopt1.c
+++ b/gl/getopt1.c
@@ -1,5 +1,5 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt. 1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987-2023 Free Software Foundation, Inc. 2 Copyright (C) 1987-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib. 3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects. 4 Patches to this file should be submitted to both projects.
5 5
@@ -21,7 +21,7 @@
21# include <config.h> 21# include <config.h>
22#endif 22#endif
23 23
24#include "getopt.h" 24#include <getopt.h>
25#include "getopt_int.h" 25#include "getopt_int.h"
26 26
27int 27int
@@ -73,7 +73,6 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
73int 73int
74main (int argc, char **argv) 74main (int argc, char **argv)
75{ 75{
76 int c;
77 int digit_optind = 0; 76 int digit_optind = 0;
78 77
79 while (1) 78 while (1)
@@ -91,8 +90,8 @@ main (int argc, char **argv)
91 {0, 0, 0, 0} 90 {0, 0, 0, 0}
92 }; 91 };
93 92
94 c = getopt_long (argc, argv, "abc:d:0123456789", 93 int c = getopt_long (argc, argv, "abc:d:0123456789",
95 long_options, &option_index); 94 long_options, &option_index);
96 if (c == -1) 95 if (c == -1)
97 break; 96 break;
98 97
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index 4d9e24be..023d8a4f 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,5 +1,5 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc. 2 Copyright (C) 1989-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib. 3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects. 4 Patches to this file should be submitted to both projects.
5 5
diff --git a/gl/getprogname.c b/gl/getprogname.c
index 32c96043..8eec96c5 100644
--- a/gl/getprogname.c
+++ b/gl/getprogname.c
@@ -1,5 +1,5 @@
1/* Program name management. 1/* Program name management.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc. 2 Copyright (C) 2016-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by 5 it under the terms of the GNU Lesser General Public License as published by
@@ -16,11 +16,10 @@
16 16
17#include <config.h> 17#include <config.h>
18 18
19/* Specification. */ 19/* Specification. Also get __argv declaration. */
20#include "getprogname.h" 20#include <stdlib.h>
21 21
22#include <errno.h> /* get program_invocation_name declaration */ 22#include <errno.h> /* get program_invocation_name declaration */
23#include <stdlib.h> /* get __argv declaration */
24 23
25#ifdef _AIX 24#ifdef _AIX
26# include <unistd.h> 25# include <unistd.h>
@@ -43,23 +42,14 @@
43# include <string.h> 42# include <string.h>
44#endif 43#endif
45 44
46#if defined __sgi || defined __osf__
47# include <string.h>
48# include <unistd.h>
49# include <stdio.h>
50# include <fcntl.h>
51# include <sys/procfs.h>
52#endif
53
54#if defined __SCO_VERSION__ || defined __sysv5__ 45#if defined __SCO_VERSION__ || defined __sysv5__
55# include <fcntl.h> 46# include <fcntl.h>
56# include <stdlib.h>
57# include <string.h> 47# include <string.h>
58#endif 48#endif
59 49
60#include "basename-lgpl.h" 50#include "basename-lgpl.h"
61 51
62#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */ 52#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Solaris >= 11, Cygwin, Android API level >= 21 */
63char const * 53char const *
64getprogname (void) 54getprogname (void)
65{ 55{
@@ -139,7 +129,7 @@ getprogname (void)
139 else 129 else
140 p = cmd; 130 p = cmd;
141 if (strlen (p) > PST_UCOMMLEN - 1 131 if (strlen (p) > PST_UCOMMLEN - 1
142 && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0) 132 && memeq (p, ucomm, PST_UCOMMLEN - 1))
143 /* p is less truncated than ucomm. */ 133 /* p is less truncated than ucomm. */
144 ; 134 ;
145 else 135 else
@@ -175,7 +165,7 @@ getprogname (void)
175 else 165 else
176 p = cmd; 166 p = cmd;
177 if (strlen (p) > PST_UCOMMLEN - 1 167 if (strlen (p) > PST_UCOMMLEN - 1
178 && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0) 168 && memeq (p, ucomm, PST_UCOMMLEN - 1))
179 /* p is less truncated than ucomm. */ 169 /* p is less truncated than ucomm. */
180 ; 170 ;
181 else 171 else
@@ -198,7 +188,6 @@ getprogname (void)
198 if (first) 188 if (first)
199 { 189 {
200 pid_t pid = getpid (); 190 pid_t pid = getpid ();
201 int token;
202 W_PSPROC buf; 191 W_PSPROC buf;
203 first = 0; 192 first = 0;
204 memset (&buf, 0, sizeof(buf)); 193 memset (&buf, 0, sizeof(buf));
@@ -207,14 +196,27 @@ getprogname (void)
207 buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN); 196 buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN);
208 if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr) 197 if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr)
209 { 198 {
210 for (token = 0; token >= 0; 199 for (int token = 0;
200 token >= 0;
211 token = w_getpsent (token, &buf, sizeof(buf))) 201 token = w_getpsent (token, &buf, sizeof(buf)))
212 { 202 {
213 if (token > 0 && buf.ps_pid == pid) 203 if (token > 0 && buf.ps_pid == pid)
214 { 204 {
215 char *s = strdup (last_component (buf.ps_pathptr)); 205 char *s = strdup (last_component (buf.ps_pathptr));
216 if (s) 206 if (s)
217 p = s; 207 {
208# if defined __XPLINK__ && __CHARSET_LIB == 1
209 /* The compiler option -qascii is in use.
210 https://makingdeveloperslivesbetter.wordpress.com/2022/01/07/is-z-os-ascii-or-ebcdic-yes/
211 https://www.ibm.com/docs/en/zos/2.5.0?topic=features-macros-related-compiler-option-settings
212 So, convert the result from EBCDIC to ASCII.
213 https://www.ibm.com/docs/en/zos/2.5.0?topic=functions-e2a-s-convert-string-from-ebcdic-ascii */
214 if (__e2a_s (s) == (size_t)-1)
215 free (s);
216 else
217# endif
218 p = s;
219 }
218 break; 220 break;
219 } 221 }
220 } 222 }
@@ -224,60 +226,22 @@ getprogname (void)
224 free (buf.ps_pathptr); 226 free (buf.ps_pathptr);
225 } 227 }
226 return p; 228 return p;
227# elif defined __sgi || defined __osf__ /* IRIX or Tru64 */
228 char filename[50];
229 int fd;
230
231 # if defined __sgi
232 sprintf (filename, "/proc/pinfo/%d", (int) getpid ());
233 # else
234 sprintf (filename, "/proc/%d", (int) getpid ());
235 # endif
236 fd = open (filename, O_RDONLY | O_CLOEXEC);
237 if (0 <= fd)
238 {
239 prpsinfo_t buf;
240 int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf);
241 close (fd);
242 if (ioctl_ok)
243 {
244 char *name = buf.pr_fname;
245 size_t namesize = sizeof buf.pr_fname;
246 /* It may not be NUL-terminated. */
247 char *namenul = memchr (name, '\0', namesize);
248 size_t namelen = namenul ? namenul - name : namesize;
249 char *namecopy = malloc (namelen + 1);
250 if (namecopy)
251 {
252 namecopy[namelen] = '\0';
253 return memcpy (namecopy, name, namelen);
254 }
255 }
256 }
257 return NULL;
258# elif defined __SCO_VERSION__ || defined __sysv5__ /* SCO OpenServer6/UnixWare */ 229# elif defined __SCO_VERSION__ || defined __sysv5__ /* SCO OpenServer6/UnixWare */
259 char buf[80]; 230 char buf[80];
260 int fd;
261 sprintf (buf, "/proc/%d/cmdline", getpid()); 231 sprintf (buf, "/proc/%d/cmdline", getpid());
262 fd = open (buf, O_RDONLY); 232 int fd = open (buf, O_RDONLY);
263 if (0 <= fd) 233 if (0 <= fd)
264 { 234 {
265 size_t n = read (fd, buf, 79); 235 size_t n = read (fd, buf, 79);
266 if (n > 0) 236 if (n > 0)
267 { 237 {
268 buf[n] = '\0'; /* Guarantee null-termination */ 238 buf[n] = '\0'; /* Guarantee null-termination */
269 char *progname; 239 char *progname = strrchr (buf, '/');
270 progname = strrchr (buf, '/');
271 if (progname) 240 if (progname)
272 { 241 progname = progname + 1; /* Skip the '/' */
273 progname = progname + 1; /* Skip the '/' */
274 }
275 else 242 else
276 { 243 progname = buf;
277 progname = buf; 244 char *ret = malloc (strlen (progname) + 1);
278 }
279 char *ret;
280 ret = malloc (strlen (progname) + 1);
281 if (ret) 245 if (ret)
282 { 246 {
283 strcpy (ret, progname); 247 strcpy (ret, progname);
diff --git a/gl/getprogname.h b/gl/getprogname.h
index 4b9126f9..3b5e502e 100644
--- a/gl/getprogname.h
+++ b/gl/getprogname.h
@@ -1,5 +1,5 @@
1/* Program name management. 1/* Program name management.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc. 2 Copyright (C) 2016-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by 5 it under the terms of the GNU Lesser General Public License as published by
@@ -19,22 +19,8 @@
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21 21
22#ifdef __cplusplus 22#if __GNUC__ || (__clang_major__ >= 4)
23extern "C" { 23# warning "The include file getprogname.h is deprecated. Use <stdlib.h> instead."
24#endif
25
26/* Return the base name of the executing program.
27 On native Windows this will usually end in ".exe" or ".EXE". */
28#ifndef HAVE_GETPROGNAME
29extern char const *getprogname (void)
30# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
31 _GL_ATTRIBUTE_PURE
32# endif
33 ;
34#endif
35
36#ifdef __cplusplus
37}
38#endif 24#endif
39 25
40#endif 26#endif
diff --git a/gl/gettext.h b/gl/gettext.h
index d0462c47..0291cf09 100644
--- a/gl/gettext.h
+++ b/gl/gettext.h
@@ -1,6 +1,5 @@
1/* Convenience header for conditional use of GNU <libintl.h>. 1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2023 Free Software 2 Copyright (C) 1995-2026 Free Software Foundation, Inc.
3 Foundation, Inc.
4 3
5 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -18,6 +17,7 @@
18#ifndef _LIBGETTEXT_H 17#ifndef _LIBGETTEXT_H
19#define _LIBGETTEXT_H 1 18#define _LIBGETTEXT_H 1
20 19
20
21/* NLS can be disabled through the configure --disable-nls option 21/* NLS can be disabled through the configure --disable-nls option
22 or through "#define ENABLE NLS 0" before including this file. */ 22 or through "#define ENABLE NLS 0" before including this file. */
23#if defined ENABLE_NLS && ENABLE_NLS 23#if defined ENABLE_NLS && ENABLE_NLS
@@ -45,32 +45,90 @@
45 as well because people using "gettext.h" will not include <libintl.h>, 45 as well because people using "gettext.h" will not include <libintl.h>,
46 and also including <libintl.h> would fail on SunOS 4, whereas <locale.h> 46 and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
47 is OK. */ 47 is OK. */
48#if defined(__sun) 48# if defined(__sun)
49# include <locale.h> 49# include <locale.h>
50#endif 50# endif
51 51
52/* Many header files from the libstdc++ coming with g++ 3.3 or newer include 52/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
53 <libintl.h>, which chokes if dcgettext is defined as a macro. So include 53 <libintl.h>, which chokes if dcgettext is defined as a macro. So include
54 it now, to make later inclusions of <libintl.h> a NOP. */ 54 it now, to make later inclusions of <libintl.h> a NOP. */
55#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) 55# if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
56# include <cstdlib> 56# include <cstdlib>
57# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H 57# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
58# include <libintl.h> 58# include <libintl.h>
59# endif
59# endif 60# endif
60#endif
61 61
62/* Disabled NLS. 62/* Disabled NLS. */
63 The casts to 'const char *' serve the purpose of producing warnings 63# if defined __GNUC__ && !defined __clang__ && !defined __cplusplus
64 for invalid uses of the value returned from these functions. 64/* Use inline functions, to avoid warnings
65 On pre-ANSI systems without 'const', the config.h file is supposed to 65 warning: format not a string literal and no format arguments
66 contain "#define const". */ 66 that don't occur with enabled NLS. */
67# undef gettext 67/* The return type 'const char *' serves the purpose of producing warnings
68# define gettext(Msgid) ((const char *) (Msgid)) 68 for invalid uses of the value returned from these functions. */
69# undef dgettext 69# if __GNUC__ >= 9
70# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) 70# pragma GCC diagnostic push
71# undef dcgettext 71# pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
72# define dcgettext(Domainname, Msgid, Category) \ 72# endif
73 ((void) (Category), dgettext (Domainname, Msgid)) 73# if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
74__attribute__ ((__always_inline__, __gnu_inline__))
75# else
76__attribute__ ((__always_inline__))
77# endif
78extern inline
79# if !defined(__sun)
80const
81# endif
82char *
83gettext (const char *msgid)
84{
85 return msgid;
86}
87# if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
88__attribute__ ((__always_inline__, __gnu_inline__))
89# else
90__attribute__ ((__always_inline__))
91# endif
92extern inline
93# if !defined(__sun)
94const
95# endif
96char *
97dgettext (const char *domain, const char *msgid)
98{
99 (void) domain;
100 return msgid;
101}
102# if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
103__attribute__ ((__always_inline__, __gnu_inline__))
104# else
105__attribute__ ((__always_inline__))
106# endif
107extern inline
108# if !defined(__sun)
109const
110# endif
111char *
112dcgettext (const char *domain, const char *msgid, int category)
113{
114 (void) domain;
115 (void) category;
116 return msgid;
117}
118# if __GNUC__ >= 9
119# pragma GCC diagnostic pop
120# endif
121# else
122/* The casts to 'const char *' serve the purpose of producing warnings
123 for invalid uses of the value returned from these functions. */
124# undef gettext
125# define gettext(Msgid) ((const char *) (Msgid))
126# undef dgettext
127# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
128# undef dcgettext
129# define dcgettext(Domainname, Msgid, Category) \
130 ((void) (Category), dgettext (Domainname, Msgid))
131# endif
74# undef ngettext 132# undef ngettext
75# define ngettext(Msgid1, Msgid2, N) \ 133# define ngettext(Msgid1, Msgid2, N) \
76 ((N) == 1 \ 134 ((N) == 1 \
@@ -93,12 +151,14 @@
93 151
94#endif 152#endif
95 153
154
96/* Prefer gnulib's setlocale override over libintl's setlocale override. */ 155/* Prefer gnulib's setlocale override over libintl's setlocale override. */
97#ifdef GNULIB_defined_setlocale 156#ifdef GNULIB_defined_setlocale
98# undef setlocale 157# undef setlocale
99# define setlocale rpl_setlocale 158# define setlocale rpl_setlocale
100#endif 159#endif
101 160
161
102/* A pseudo function call that serves as a marker for the automated 162/* A pseudo function call that serves as a marker for the automated
103 extraction of messages, but does not call gettext(). The run-time 163 extraction of messages, but does not call gettext(). The run-time
104 translation is done at a different place in the code. 164 translation is done at a different place in the code.
@@ -108,6 +168,7 @@
108 initializer for static 'char[]' or 'const char[]' variables. */ 168 initializer for static 'char[]' or 'const char[]' variables. */
109#define gettext_noop(String) String 169#define gettext_noop(String) String
110 170
171
111/* The separator between msgctxt and msgid in a .mo file. */ 172/* The separator between msgctxt and msgid in a .mo file. */
112#define GETTEXT_CONTEXT_GLUE "\004" 173#define GETTEXT_CONTEXT_GLUE "\004"
113 174
@@ -115,6 +176,9 @@
115 MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be 176 MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
116 short and rarely need to change. 177 short and rarely need to change.
117 The letter 'p' stands for 'particular' or 'special'. */ 178 The letter 'p' stands for 'particular' or 'special'. */
179
180#include <locale.h> /* for LC_MESSAGES */
181
118#ifdef DEFAULT_TEXT_DOMAIN 182#ifdef DEFAULT_TEXT_DOMAIN
119# define pgettext(Msgctxt, Msgid) \ 183# define pgettext(Msgctxt, Msgid) \
120 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) 184 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
@@ -178,11 +242,12 @@ npgettext_aux (const char *domain,
178 return translation; 242 return translation;
179} 243}
180 244
245
181/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID 246/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
182 can be arbitrary expressions. But for string literals these macros are 247 can be arbitrary expressions. But for string literals these macros are
183 less efficient than those above. */ 248 less efficient than those above. */
184 249
185#include <string.h> 250#include <string.h> /* for memcpy */
186 251
187/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. 252/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
188 This relates to the -Wvla and -Wvla-larger-than warnings, enabled in 253 This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
@@ -199,7 +264,7 @@ npgettext_aux (const char *domain,
199#endif 264#endif
200 265
201#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 266#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
202#include <stdlib.h> 267# include <stdlib.h> /* for malloc, free */
203#endif 268#endif
204 269
205#define pgettext_expr(Msgctxt, Msgid) \ 270#define pgettext_expr(Msgctxt, Msgid) \
@@ -233,12 +298,11 @@ dcpgettext_expr (const char *domain,
233 if (msg_ctxt_id != NULL) 298 if (msg_ctxt_id != NULL)
234#endif 299#endif
235 { 300 {
236 int found_translation;
237 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 301 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
238 msg_ctxt_id[msgctxt_len - 1] = '\004'; 302 msg_ctxt_id[msgctxt_len - 1] = '\004';
239 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 303 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
240 translation = dcgettext (domain, msg_ctxt_id, category); 304 translation = dcgettext (domain, msg_ctxt_id, category);
241 found_translation = (translation != msg_ctxt_id); 305 int found_translation = (translation != msg_ctxt_id);
242#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 306#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
243 if (msg_ctxt_id != buf) 307 if (msg_ctxt_id != buf)
244 free (msg_ctxt_id); 308 free (msg_ctxt_id);
@@ -281,12 +345,11 @@ dcnpgettext_expr (const char *domain,
281 if (msg_ctxt_id != NULL) 345 if (msg_ctxt_id != NULL)
282#endif 346#endif
283 { 347 {
284 int found_translation;
285 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 348 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
286 msg_ctxt_id[msgctxt_len - 1] = '\004'; 349 msg_ctxt_id[msgctxt_len - 1] = '\004';
287 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 350 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
288 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); 351 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
289 found_translation = !(translation == msg_ctxt_id || translation == msgid_plural); 352 int found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
290#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 353#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
291 if (msg_ctxt_id != buf) 354 if (msg_ctxt_id != buf)
292 free (msg_ctxt_id); 355 free (msg_ctxt_id);
@@ -297,4 +360,5 @@ dcnpgettext_expr (const char *domain,
297 return (n == 1 ? msgid : msgid_plural); 360 return (n == 1 ? msgid : msgid_plural);
298} 361}
299 362
363
300#endif /* _LIBGETTEXT_H */ 364#endif /* _LIBGETTEXT_H */
diff --git a/gl/gl_openssl.h b/gl/gl_openssl.h
index f63c386e..06fd8f66 100644
--- a/gl/gl_openssl.h
+++ b/gl/gl_openssl.h
@@ -1,6 +1,6 @@
1/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*- 1/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*-
2 2
3 Copyright (C) 2013-2023 Free Software Foundation, Inc. 3 Copyright (C) 2013-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -17,13 +17,15 @@
17 17
18/* Written by Pádraig Brady */ 18/* Written by Pádraig Brady */
19 19
20/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
21#if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23#endif
24
20#ifndef GL_OPENSSL_NAME 25#ifndef GL_OPENSSL_NAME
21# error "Please define GL_OPENSSL_NAME to 1,5,256 etc." 26# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
22#endif 27#endif
23 28
24#ifndef _GL_INLINE_HEADER_BEGIN
25# error "Please include config.h first."
26#endif
27_GL_INLINE_HEADER_BEGIN 29_GL_INLINE_HEADER_BEGIN
28#ifndef GL_OPENSSL_INLINE 30#ifndef GL_OPENSSL_INLINE
29# define GL_OPENSSL_INLINE _GL_INLINE 31# define GL_OPENSSL_INLINE _GL_INLINE
@@ -101,7 +103,7 @@ GL_OPENSSL_INLINE void *
101GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res) 103GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
102{ 104{
103 /* Assume any unprocessed bytes in ctx are not to be ignored. */ 105 /* Assume any unprocessed bytes in ctx are not to be ignored. */
104 _gl_CTX tmp_ctx = *(_gl_CTX *) ctx; 106 _gl_CTX tmp_ctx = *(_gl_CTX const *) ctx;
105 OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx); 107 OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
106 return res; 108 return res;
107} 109}
diff --git a/gl/glthread/lock.c b/gl/glthread/lock.c
index 82fb7553..cfb9393c 100644
--- a/gl/glthread/lock.c
+++ b/gl/glthread/lock.c
@@ -1,5 +1,5 @@
1/* Locking in multithreaded situations. 1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -240,8 +240,6 @@ glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
240 return 0; 240 return 0;
241} 241}
242 242
243/* -------------------------- gl_once_t datatype -------------------------- */
244
245#endif 243#endif
246 244
247/* ========================================================================= */ 245/* ========================================================================= */
@@ -257,21 +255,19 @@ glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
257# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP 255# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP
258 256
259# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER 257# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
260 /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ 258 /* glibc with bug https://sourceware.org/PR13701 */
261 259
262int 260int
263glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock) 261glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
264{ 262{
265 pthread_rwlockattr_t attributes; 263 pthread_rwlockattr_t attributes;
266 int err; 264 int err = pthread_rwlockattr_init (&attributes);
267
268 err = pthread_rwlockattr_init (&attributes);
269 if (err != 0) 265 if (err != 0)
270 return err; 266 return err;
271 /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that 267 /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
272 causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not 268 causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
273 do this; see 269 do this; see
274 http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */ 270 https://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
275 err = pthread_rwlockattr_setkind_np (&attributes, 271 err = pthread_rwlockattr_setkind_np (&attributes,
276 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); 272 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
277 if (err == 0) 273 if (err == 0)
@@ -288,9 +284,7 @@ glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
288int 284int
289glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) 285glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
290{ 286{
291 int err; 287 int err = pthread_rwlock_init (&lock->rwlock, NULL);
292
293 err = pthread_rwlock_init (&lock->rwlock, NULL);
294 if (err != 0) 288 if (err != 0)
295 return err; 289 return err;
296 lock->initialized = 1; 290 lock->initialized = 1;
@@ -302,9 +296,7 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
302{ 296{
303 if (!lock->initialized) 297 if (!lock->initialized)
304 { 298 {
305 int err; 299 int err = pthread_mutex_lock (&lock->guard);
306
307 err = pthread_mutex_lock (&lock->guard);
308 if (err != 0) 300 if (err != 0)
309 return err; 301 return err;
310 if (!lock->initialized) 302 if (!lock->initialized)
@@ -328,9 +320,7 @@ glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
328{ 320{
329 if (!lock->initialized) 321 if (!lock->initialized)
330 { 322 {
331 int err; 323 int err = pthread_mutex_lock (&lock->guard);
332
333 err = pthread_mutex_lock (&lock->guard);
334 if (err != 0) 324 if (err != 0)
335 return err; 325 return err;
336 if (!lock->initialized) 326 if (!lock->initialized)
@@ -360,11 +350,9 @@ glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
360int 350int
361glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) 351glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
362{ 352{
363 int err;
364
365 if (!lock->initialized) 353 if (!lock->initialized)
366 return EINVAL; 354 return EINVAL;
367 err = pthread_rwlock_destroy (&lock->rwlock); 355 int err = pthread_rwlock_destroy (&lock->rwlock);
368 if (err != 0) 356 if (err != 0)
369 return err; 357 return err;
370 lock->initialized = 0; 358 lock->initialized = 0;
@@ -378,9 +366,7 @@ glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
378int 366int
379glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) 367glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
380{ 368{
381 int err; 369 int err = pthread_mutex_init (&lock->lock, NULL);
382
383 err = pthread_mutex_init (&lock->lock, NULL);
384 if (err != 0) 370 if (err != 0)
385 return err; 371 return err;
386 err = pthread_cond_init (&lock->waiting_readers, NULL); 372 err = pthread_cond_init (&lock->waiting_readers, NULL);
@@ -397,9 +383,7 @@ glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
397int 383int
398glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) 384glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
399{ 385{
400 int err; 386 int err = pthread_mutex_lock (&lock->lock);
401
402 err = pthread_mutex_lock (&lock->lock);
403 if (err != 0) 387 if (err != 0)
404 return err; 388 return err;
405 /* Test whether only readers are currently running, and whether the runcount 389 /* Test whether only readers are currently running, and whether the runcount
@@ -424,9 +408,7 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
424int 408int
425glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) 409glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
426{ 410{
427 int err; 411 int err = pthread_mutex_lock (&lock->lock);
428
429 err = pthread_mutex_lock (&lock->lock);
430 if (err != 0) 412 if (err != 0)
431 return err; 413 return err;
432 /* Test whether no readers or writers are currently running. */ 414 /* Test whether no readers or writers are currently running. */
@@ -451,9 +433,7 @@ glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
451int 433int
452glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) 434glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
453{ 435{
454 int err; 436 int err = pthread_mutex_lock (&lock->lock);
455
456 err = pthread_mutex_lock (&lock->lock);
457 if (err != 0) 437 if (err != 0)
458 return err; 438 return err;
459 if (lock->runcount < 0) 439 if (lock->runcount < 0)
@@ -507,9 +487,7 @@ glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
507int 487int
508glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) 488glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
509{ 489{
510 int err; 490 int err = pthread_mutex_destroy (&lock->lock);
511
512 err = pthread_mutex_destroy (&lock->lock);
513 if (err != 0) 491 if (err != 0)
514 return err; 492 return err;
515 err = pthread_cond_destroy (&lock->waiting_readers); 493 err = pthread_cond_destroy (&lock->waiting_readers);
@@ -533,9 +511,7 @@ int
533glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) 511glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
534{ 512{
535 pthread_mutexattr_t attributes; 513 pthread_mutexattr_t attributes;
536 int err; 514 int err = pthread_mutexattr_init (&attributes);
537
538 err = pthread_mutexattr_init (&attributes);
539 if (err != 0) 515 if (err != 0)
540 return err; 516 return err;
541 err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); 517 err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
@@ -562,9 +538,7 @@ int
562glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) 538glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
563{ 539{
564 pthread_mutexattr_t attributes; 540 pthread_mutexattr_t attributes;
565 int err; 541 int err = pthread_mutexattr_init (&attributes);
566
567 err = pthread_mutexattr_init (&attributes);
568 if (err != 0) 542 if (err != 0)
569 return err; 543 return err;
570 err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); 544 err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
@@ -591,9 +565,7 @@ glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
591{ 565{
592 if (!lock->initialized) 566 if (!lock->initialized)
593 { 567 {
594 int err; 568 int err = pthread_mutex_lock (&lock->guard);
595
596 err = pthread_mutex_lock (&lock->guard);
597 if (err != 0) 569 if (err != 0)
598 return err; 570 return err;
599 if (!lock->initialized) 571 if (!lock->initialized)
@@ -623,11 +595,9 @@ glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
623int 595int
624glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) 596glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
625{ 597{
626 int err;
627
628 if (!lock->initialized) 598 if (!lock->initialized)
629 return EINVAL; 599 return EINVAL;
630 err = pthread_mutex_destroy (&lock->recmutex); 600 int err = pthread_mutex_destroy (&lock->recmutex);
631 if (err != 0) 601 if (err != 0)
632 return err; 602 return err;
633 lock->initialized = 0; 603 lock->initialized = 0;
@@ -641,9 +611,7 @@ glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
641int 611int
642glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) 612glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
643{ 613{
644 int err; 614 int err = pthread_mutex_init (&lock->mutex, NULL);
645
646 err = pthread_mutex_init (&lock->mutex, NULL);
647 if (err != 0) 615 if (err != 0)
648 return err; 616 return err;
649 lock->owner = (pthread_t) 0; 617 lock->owner = (pthread_t) 0;
@@ -657,9 +625,7 @@ glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
657 pthread_t self = pthread_self (); 625 pthread_t self = pthread_self ();
658 if (lock->owner != self) 626 if (lock->owner != self)
659 { 627 {
660 int err; 628 int err = pthread_mutex_lock (&lock->mutex);
661
662 err = pthread_mutex_lock (&lock->mutex);
663 if (err != 0) 629 if (err != 0)
664 return err; 630 return err;
665 lock->owner = self; 631 lock->owner = self;
@@ -698,46 +664,6 @@ glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
698 664
699# endif 665# endif
700 666
701/* -------------------------- gl_once_t datatype -------------------------- */
702
703static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
704
705int
706glthread_once_singlethreaded (pthread_once_t *once_control)
707{
708 /* We don't know whether pthread_once_t is an integer type, a floating-point
709 type, a pointer type, or a structure type. */
710 char *firstbyte = (char *)once_control;
711 if (*firstbyte == *(const char *)&fresh_once)
712 {
713 /* First time use of once_control. Invert the first byte. */
714 *firstbyte = ~ *(const char *)&fresh_once;
715 return 1;
716 }
717 else
718 return 0;
719}
720
721# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK)
722
723int
724glthread_once_multithreaded (pthread_once_t *once_control,
725 void (*init_function) (void))
726{
727 int err = pthread_once (once_control, init_function);
728 if (err == ENOSYS)
729 {
730 /* This happens on FreeBSD 11: The pthread_once function in libc returns
731 ENOSYS. */
732 if (glthread_once_singlethreaded (once_control))
733 init_function ();
734 return 0;
735 }
736 return err;
737}
738
739# endif
740
741#endif 667#endif
742 668
743/* ========================================================================= */ 669/* ========================================================================= */
diff --git a/gl/glthread/lock.h b/gl/glthread/lock.h
index ae3ee2d6..d8190b6c 100644
--- a/gl/glthread/lock.h
+++ b/gl/glthread/lock.h
@@ -1,5 +1,5 @@
1/* Locking in multithreaded situations. 1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -64,33 +64,26 @@
64 Taking the lock: err = glthread_recursive_lock_lock (&name); 64 Taking the lock: err = glthread_recursive_lock_lock (&name);
65 Releasing the lock: err = glthread_recursive_lock_unlock (&name); 65 Releasing the lock: err = glthread_recursive_lock_unlock (&name);
66 De-initialization: err = glthread_recursive_lock_destroy (&name); 66 De-initialization: err = glthread_recursive_lock_destroy (&name);
67
68 Once-only execution:
69 Type: gl_once_t
70 Initializer: gl_once_define(extern, name)
71 Execution: gl_once (name, initfunction);
72 Equivalent functions with control of error handling:
73 Execution: err = glthread_once (&name, initfunction);
74*/ 67*/
75 68
76 69
77#ifndef _LOCK_H 70#ifndef _LOCK_H
78#define _LOCK_H 71#define _LOCK_H
79 72
73/* This file uses HAVE_THREADS_H, HAVE_PTHREAD_RWLOCK,
74 HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER,
75 PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
76 HAVE_PTHREAD_MUTEX_RECURSIVE. */
77#if !_GL_CONFIG_H_INCLUDED
78 #error "Please include config.h first."
79#endif
80
80#include <errno.h> 81#include <errno.h>
81#include <stdlib.h> 82#include <stdlib.h>
82 83
83#if !defined c11_threads_in_use 84#include "glthread/once.h"
84# if HAVE_THREADS_H && USE_POSIX_THREADS_FROM_LIBC 85
85# define c11_threads_in_use() 1 86/* c11_threads_in_use() is defined in glthread/once.h. */
86# elif HAVE_THREADS_H && USE_POSIX_THREADS_WEAK
87# include <threads.h>
88# pragma weak thrd_exit
89# define c11_threads_in_use() (thrd_exit != NULL)
90# else
91# define c11_threads_in_use() 0
92# endif
93#endif
94 87
95/* ========================================================================= */ 88/* ========================================================================= */
96 89
@@ -187,14 +180,6 @@ extern int glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
187extern int glthread_recursive_lock_unlock (gl_recursive_lock_t *lock); 180extern int glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
188extern int glthread_recursive_lock_destroy (gl_recursive_lock_t *lock); 181extern int glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
189 182
190/* -------------------------- gl_once_t datatype -------------------------- */
191
192typedef once_flag gl_once_t;
193# define gl_once_define(STORAGECLASS, NAME) \
194 STORAGECLASS once_flag NAME = ONCE_FLAG_INIT;
195# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
196 (call_once (ONCE_CONTROL, INITFUNCTION), 0)
197
198# ifdef __cplusplus 183# ifdef __cplusplus
199} 184}
200# endif 185# endif
@@ -213,80 +198,7 @@ typedef once_flag gl_once_t;
213extern "C" { 198extern "C" {
214# endif 199# endif
215 200
216# if PTHREAD_IN_USE_DETECTION_HARD 201/* pthread_in_use() is defined in glthread/once.h. */
217
218/* The pthread_in_use() detection needs to be done at runtime. */
219# define pthread_in_use() \
220 glthread_in_use ()
221extern int glthread_in_use (void);
222
223# endif
224
225# if USE_POSIX_THREADS_WEAK
226
227/* Use weak references to the POSIX threads library. */
228
229/* Weak references avoid dragging in external libraries if the other parts
230 of the program don't use them. Here we use them, because we don't want
231 every program that uses libintl to depend on libpthread. This assumes
232 that libpthread would not be loaded after libintl; i.e. if libintl is
233 loaded first, by an executable that does not depend on libpthread, and
234 then a module is dynamically loaded that depends on libpthread, libintl
235 will not be multithread-safe. */
236
237/* The way to test at runtime whether libpthread is present is to test
238 whether a function pointer's value, such as &pthread_mutex_init, is
239 non-NULL. However, some versions of GCC have a bug through which, in
240 PIC mode, &foo != NULL always evaluates to true if there is a direct
241 call to foo(...) in the same function. To avoid this, we test the
242 address of a function in libpthread that we don't use. */
243
244# pragma weak pthread_mutex_init
245# pragma weak pthread_mutex_lock
246# pragma weak pthread_mutex_unlock
247# pragma weak pthread_mutex_destroy
248# pragma weak pthread_rwlock_init
249# pragma weak pthread_rwlock_rdlock
250# pragma weak pthread_rwlock_wrlock
251# pragma weak pthread_rwlock_unlock
252# pragma weak pthread_rwlock_destroy
253# pragma weak pthread_once
254# pragma weak pthread_cond_init
255# pragma weak pthread_cond_wait
256# pragma weak pthread_cond_signal
257# pragma weak pthread_cond_broadcast
258# pragma weak pthread_cond_destroy
259# pragma weak pthread_mutexattr_init
260# pragma weak pthread_mutexattr_settype
261# pragma weak pthread_mutexattr_destroy
262# pragma weak pthread_rwlockattr_init
263# if __GNU_LIBRARY__ > 1
264# pragma weak pthread_rwlockattr_setkind_np
265# endif
266# pragma weak pthread_rwlockattr_destroy
267# ifndef pthread_self
268# pragma weak pthread_self
269# endif
270
271# if !PTHREAD_IN_USE_DETECTION_HARD
272 /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
273 can be used to determine whether libpthread is in use. These are:
274 pthread_mutexattr_gettype
275 pthread_rwlockattr_destroy
276 pthread_rwlockattr_init
277 */
278# pragma weak pthread_mutexattr_gettype
279# define pthread_in_use() \
280 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
281# endif
282
283# else
284
285# if !PTHREAD_IN_USE_DETECTION_HARD
286# define pthread_in_use() 1
287# endif
288
289# endif
290 202
291/* -------------------------- gl_lock_t datatype -------------------------- */ 203/* -------------------------- gl_lock_t datatype -------------------------- */
292 204
@@ -327,7 +239,7 @@ typedef pthread_rwlock_t gl_rwlock_t;
327# endif 239# endif
328# define glthread_rwlock_init(LOCK) \ 240# define glthread_rwlock_init(LOCK) \
329 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) 241 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
330# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */ 242# else /* glibc with bug https://sourceware.org/PR13701 */
331# define gl_rwlock_initializer \ 243# define gl_rwlock_initializer \
332 PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP 244 PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
333# define glthread_rwlock_init(LOCK) \ 245# define glthread_rwlock_init(LOCK) \
@@ -502,26 +414,6 @@ extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *l
502 414
503# endif 415# endif
504 416
505/* -------------------------- gl_once_t datatype -------------------------- */
506
507typedef pthread_once_t gl_once_t;
508# define gl_once_define(STORAGECLASS, NAME) \
509 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
510# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK
511# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
512 (pthread_in_use () \
513 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
514 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
515# else
516# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
517 (pthread_in_use () \
518 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
519 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
520extern int glthread_once_multithreaded (pthread_once_t *once_control,
521 void (*init_function) (void));
522# endif
523extern int glthread_once_singlethreaded (pthread_once_t *once_control);
524
525# ifdef __cplusplus 417# ifdef __cplusplus
526} 418}
527# endif 419# endif
@@ -538,7 +430,6 @@ extern int glthread_once_singlethreaded (pthread_once_t *once_control);
538# include "windows-mutex.h" 430# include "windows-mutex.h"
539# include "windows-rwlock.h" 431# include "windows-rwlock.h"
540# include "windows-recmutex.h" 432# include "windows-recmutex.h"
541# include "windows-once.h"
542 433
543# ifdef __cplusplus 434# ifdef __cplusplus
544extern "C" { 435extern "C" {
@@ -611,14 +502,6 @@ typedef glwthread_recmutex_t gl_recursive_lock_t;
611# define glthread_recursive_lock_destroy(LOCK) \ 502# define glthread_recursive_lock_destroy(LOCK) \
612 glwthread_recmutex_destroy (LOCK) 503 glwthread_recmutex_destroy (LOCK)
613 504
614/* -------------------------- gl_once_t datatype -------------------------- */
615
616typedef glwthread_once_t gl_once_t;
617# define gl_once_define(STORAGECLASS, NAME) \
618 STORAGECLASS gl_once_t NAME = GLWTHREAD_ONCE_INIT;
619# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
620 (glwthread_once (ONCE_CONTROL, INITFUNCTION), 0)
621
622# ifdef __cplusplus 505# ifdef __cplusplus
623} 506}
624# endif 507# endif
@@ -662,14 +545,6 @@ typedef int gl_recursive_lock_t;
662# define glthread_recursive_lock_unlock(NAME) 0 545# define glthread_recursive_lock_unlock(NAME) 0
663# define glthread_recursive_lock_destroy(NAME) 0 546# define glthread_recursive_lock_destroy(NAME) 0
664 547
665/* -------------------------- gl_once_t datatype -------------------------- */
666
667typedef int gl_once_t;
668# define gl_once_define(STORAGECLASS, NAME) \
669 STORAGECLASS gl_once_t NAME = 0;
670# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
671 (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
672
673#endif 548#endif
674 549
675/* ========================================================================= */ 550/* ========================================================================= */
@@ -776,16 +651,6 @@ typedef int gl_once_t;
776 } \ 651 } \
777 while (0) 652 while (0)
778 653
779/* -------------------------- gl_once_t datatype -------------------------- */
780
781#define gl_once(NAME, INITFUNCTION) \
782 do \
783 { \
784 if (glthread_once (&NAME, INITFUNCTION)) \
785 abort (); \
786 } \
787 while (0)
788
789/* ========================================================================= */ 654/* ========================================================================= */
790 655
791#endif /* _LOCK_H */ 656#endif /* _LOCK_H */
diff --git a/gl/glthread/once.c b/gl/glthread/once.c
new file mode 100644
index 00000000..b72a4a20
--- /dev/null
+++ b/gl/glthread/once.c
@@ -0,0 +1,80 @@
1/* Once-only initialization in multithreaded situations.
2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h. */
19
20#include <config.h>
21
22#include "glthread/once.h"
23
24/* ========================================================================= */
25
26#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
27
28#endif
29
30/* ========================================================================= */
31
32#if USE_POSIX_THREADS
33
34static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
35
36int
37glthread_once_singlethreaded (pthread_once_t *once_control)
38{
39 /* We don't know whether pthread_once_t is an integer type, a floating-point
40 type, a pointer type, or a structure type. */
41 char *firstbyte = (char *)once_control;
42 if (*firstbyte == *(const char *)&fresh_once)
43 {
44 /* First time use of once_control. Invert the first byte. */
45 *firstbyte = ~ *(const char *)&fresh_once;
46 return 1;
47 }
48 else
49 return 0;
50}
51
52# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK)
53
54int
55glthread_once_multithreaded (pthread_once_t *once_control,
56 void (*init_function) (void))
57{
58 int err = pthread_once (once_control, init_function);
59 if (err == ENOSYS)
60 {
61 /* This happens on FreeBSD 11: The pthread_once function in libc returns
62 ENOSYS. */
63 if (glthread_once_singlethreaded (once_control))
64 init_function ();
65 return 0;
66 }
67 return err;
68}
69
70# endif
71
72#endif
73
74/* ========================================================================= */
75
76#if USE_WINDOWS_THREADS
77
78#endif
79
80/* ========================================================================= */
diff --git a/gl/glthread/once.h b/gl/glthread/once.h
new file mode 100644
index 00000000..b6d9ab40
--- /dev/null
+++ b/gl/glthread/once.h
@@ -0,0 +1,272 @@
1/* Once-only initialization in multithreaded situations.
2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */
19
20/* This file contains once-only initialization primitives for use with a given
21 thread library.
22 It does not contain primitives for creating threads or for other
23 synchronization primitives.
24
25 Once-only execution:
26 Type: gl_once_t
27 Initializer: gl_once_define(extern, name)
28 Execution: gl_once (name, initfunction);
29 Equivalent functions with control of error handling:
30 Execution: err = glthread_once (&name, initfunction);
31*/
32
33
34#ifndef _ONCE_H
35#define _ONCE_H
36
37/* This file uses HAVE_THREADS_H. */
38#if !_GL_CONFIG_H_INCLUDED
39 #error "Please include config.h first."
40#endif
41
42#include <errno.h>
43#include <stdlib.h>
44
45#if !defined c11_threads_in_use
46# if HAVE_THREADS_H && USE_POSIX_THREADS_FROM_LIBC
47# define c11_threads_in_use() 1
48# elif HAVE_THREADS_H && USE_POSIX_THREADS_WEAK
49# include <threads.h>
50# pragma weak thrd_exit
51# define c11_threads_in_use() (thrd_exit != NULL)
52# else
53# define c11_threads_in_use() 0
54# endif
55#endif
56
57/* ========================================================================= */
58
59#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
60
61/* Use the ISO C threads library. */
62
63# include <threads.h>
64
65# ifdef __cplusplus
66extern "C" {
67# endif
68
69/* -------------------------- gl_once_t datatype -------------------------- */
70
71typedef once_flag gl_once_t;
72# define gl_once_define(STORAGECLASS, NAME) \
73 STORAGECLASS once_flag NAME = ONCE_FLAG_INIT;
74# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
75 (call_once (ONCE_CONTROL, INITFUNCTION), 0)
76
77# ifdef __cplusplus
78}
79# endif
80
81#endif
82
83/* ========================================================================= */
84
85#if USE_POSIX_THREADS
86
87/* Use the POSIX threads library. */
88
89# include <pthread.h>
90
91# ifdef __cplusplus
92extern "C" {
93# endif
94
95# if PTHREAD_IN_USE_DETECTION_HARD
96
97/* The pthread_in_use() detection needs to be done at runtime. */
98# define pthread_in_use() \
99 glthread_in_use ()
100extern int glthread_in_use (void);
101
102# endif
103
104# if USE_POSIX_THREADS_WEAK
105
106/* Use weak references to the POSIX threads library. */
107
108/* Weak references avoid dragging in external libraries if the other parts
109 of the program don't use them. Here we use them, because we don't want
110 every program that uses libintl to depend on libpthread. This assumes
111 that libpthread would not be loaded after libintl; i.e. if libintl is
112 loaded first, by an executable that does not depend on libpthread, and
113 then a module is dynamically loaded that depends on libpthread, libintl
114 will not be multithread-safe. */
115
116/* The way to test at runtime whether libpthread is present is to test
117 whether a function pointer's value, such as &pthread_mutex_init, is
118 non-NULL. However, some versions of GCC have a bug through which, in
119 PIC mode, &foo != NULL always evaluates to true if there is a direct
120 call to foo(...) in the same function. To avoid this, we test the
121 address of a function in libpthread that we don't use. */
122
123# pragma weak pthread_mutex_init
124# pragma weak pthread_mutex_lock
125# pragma weak pthread_mutex_unlock
126# pragma weak pthread_mutex_destroy
127/* Work around clang bug <https://github.com/llvm/llvm-project/issues/104670> */
128# ifndef pthread_rwlock_init
129# pragma weak pthread_rwlock_init
130# endif
131# pragma weak pthread_rwlock_rdlock
132# pragma weak pthread_rwlock_wrlock
133# pragma weak pthread_rwlock_unlock
134# pragma weak pthread_rwlock_destroy
135# pragma weak pthread_once
136# pragma weak pthread_cond_init
137# pragma weak pthread_cond_wait
138# pragma weak pthread_cond_signal
139# pragma weak pthread_cond_broadcast
140# pragma weak pthread_cond_destroy
141# pragma weak pthread_mutexattr_init
142# pragma weak pthread_mutexattr_settype
143# pragma weak pthread_mutexattr_destroy
144/* Work around clang bug <https://github.com/llvm/llvm-project/issues/104670> */
145# ifndef pthread_rwlockattr_init
146# pragma weak pthread_rwlockattr_init
147# endif
148# if __GNU_LIBRARY__ > 1
149# pragma weak pthread_rwlockattr_setkind_np
150# endif
151# pragma weak pthread_rwlockattr_destroy
152# ifndef pthread_self
153# pragma weak pthread_self
154# endif
155
156# if !PTHREAD_IN_USE_DETECTION_HARD
157 /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
158 can be used to determine whether libpthread is in use. These are:
159 pthread_mutexattr_gettype
160 pthread_rwlockattr_destroy
161 pthread_rwlockattr_init
162 */
163# pragma weak pthread_mutexattr_gettype
164# define pthread_in_use() \
165 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
166# endif
167
168# else
169
170# if !PTHREAD_IN_USE_DETECTION_HARD
171# define pthread_in_use() 1
172# endif
173
174# endif
175
176/* -------------------------- gl_once_t datatype -------------------------- */
177
178typedef pthread_once_t gl_once_t;
179# define gl_once_define(STORAGECLASS, NAME) \
180 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
181# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK
182# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
183 (pthread_in_use () \
184 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
185 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
186# else
187# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
188 (pthread_in_use () \
189 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
190 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
191extern int glthread_once_multithreaded (pthread_once_t *once_control,
192 void (*init_function) (void));
193# endif
194extern int glthread_once_singlethreaded (pthread_once_t *once_control);
195
196# ifdef __cplusplus
197}
198# endif
199
200#endif
201
202/* ========================================================================= */
203
204#if USE_WINDOWS_THREADS
205
206# define WIN32_LEAN_AND_MEAN /* avoid including junk */
207# include <windows.h>
208
209# include "windows-once.h"
210
211# ifdef __cplusplus
212extern "C" {
213# endif
214
215/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
216 Mutex, Semaphore types, because
217 - we need only to synchronize inside a single process (address space),
218 not inter-process locking,
219 - we don't need to support trylock operations. (TryEnterCriticalSection
220 does not work on Windows 95/98/ME. Packages that need trylock usually
221 define their own mutex type.) */
222
223/* There is no way to statically initialize a CRITICAL_SECTION. It needs
224 to be done lazily, once only. For this we need spinlocks. */
225
226/* -------------------------- gl_once_t datatype -------------------------- */
227
228typedef glwthread_once_t gl_once_t;
229# define gl_once_define(STORAGECLASS, NAME) \
230 STORAGECLASS gl_once_t NAME = GLWTHREAD_ONCE_INIT;
231# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
232 (glwthread_once (ONCE_CONTROL, INITFUNCTION), 0)
233
234# ifdef __cplusplus
235}
236# endif
237
238#endif
239
240/* ========================================================================= */
241
242#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS)
243
244/* Provide dummy implementation if threads are not supported. */
245
246/* -------------------------- gl_once_t datatype -------------------------- */
247
248typedef int gl_once_t;
249# define gl_once_define(STORAGECLASS, NAME) \
250 STORAGECLASS gl_once_t NAME = 0;
251# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
252 (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
253
254#endif
255
256/* ========================================================================= */
257
258/* Macros with built-in error handling. */
259
260/* -------------------------- gl_once_t datatype -------------------------- */
261
262#define gl_once(NAME, INITFUNCTION) \
263 do \
264 { \
265 if (glthread_once (&NAME, INITFUNCTION)) \
266 abort (); \
267 } \
268 while (0)
269
270/* ========================================================================= */
271
272#endif /* _ONCE_H */
diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c
index 5ecf827f..5c0ba1f4 100644
--- a/gl/glthread/threadlib.c
+++ b/gl/glthread/threadlib.c
@@ -1,5 +1,5 @@
1/* Multithreading primitives. 1/* Multithreading primitives.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/hard-locale.c b/gl/hard-locale.c
index 0a28552e..6a3dad4f 100644
--- a/gl/hard-locale.c
+++ b/gl/hard-locale.c
@@ -1,6 +1,6 @@
1/* hard-locale.c -- Determine whether a locale is hard. 1/* hard-locale.c -- Determine whether a locale is hard.
2 2
3 Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2023 Free Software 3 Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -21,6 +21,7 @@
21#include "hard-locale.h" 21#include "hard-locale.h"
22 22
23#include <locale.h> 23#include <locale.h>
24#include <stdlib.h>
24#include <string.h> 25#include <string.h>
25 26
26bool 27bool
@@ -31,5 +32,16 @@ hard_locale (int category)
31 if (setlocale_null_r (category, locale, sizeof (locale))) 32 if (setlocale_null_r (category, locale, sizeof (locale)))
32 return false; 33 return false;
33 34
34 return !(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0); 35 if (!(streq (locale, "C") || streq (locale, "POSIX")))
36 return true;
37
38#if defined __ANDROID__
39 /* On Android 5.0 or newer, it is possible to set a locale that has the same
40 name as the "C" locale but in fact uses UTF-8 encoding. Cf. test case 2 in
41 <https://lists.gnu.org/archive/html/bug-gnulib/2023-01/msg00141.html>. */
42 if (MB_CUR_MAX > 1)
43 return true;
44#endif
45
46 return false;
35} 47}
diff --git a/gl/hard-locale.h b/gl/hard-locale.h
index 880c9e85..b8d7029d 100644
--- a/gl/hard-locale.h
+++ b/gl/hard-locale.h
@@ -1,6 +1,6 @@
1/* Determine whether a locale is hard. 1/* Determine whether a locale is hard.
2 2
3 Copyright (C) 1999, 2003-2004, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 1999, 2003-2004, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -16,11 +16,23 @@
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef HARD_LOCALE_H_ 18#ifndef HARD_LOCALE_H_
19# define HARD_LOCALE_H_ 1 19#define HARD_LOCALE_H_ 1
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
20 25
21/* Return true if the specified CATEGORY of the current locale is hard, i.e. 26/* Return true if the specified CATEGORY of the current locale is hard, i.e.
22 different from the C or POSIX locale that has a fixed behavior. 27 different from the C or POSIX locale that has a fixed behavior.
23 CATEGORY must be one of the LC_* values, but not LC_ALL. */ 28 CATEGORY must be one of the LC_* values, but not LC_ALL.
29 Note: This function uses the current global locale; it ignores the
30 per-thread locale. */
24extern bool hard_locale (int category); 31extern bool hard_locale (int category);
25 32
33
34#ifdef __cplusplus
35}
36#endif
37
26#endif /* HARD_LOCALE_H_ */ 38#endif /* HARD_LOCALE_H_ */
diff --git a/gl/ialloc.c b/gl/ialloc.c
index cd44d8ca..38ec1d05 100644
--- a/gl/ialloc.c
+++ b/gl/ialloc.c
@@ -1,6 +1,6 @@
1/* malloc with idx_t rather than size_t 1/* malloc with idx_t rather than size_t
2 2
3 Copyright 2021-2023 Free Software Foundation, Inc. 3 Copyright 2021-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,7 +15,6 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h>
19
20#define IALLOC_INLINE _GL_EXTERN_INLINE 18#define IALLOC_INLINE _GL_EXTERN_INLINE
19#include <config.h>
21#include "ialloc.h" 20#include "ialloc.h"
diff --git a/gl/ialloc.h b/gl/ialloc.h
index 1d43faf3..97b0e0c5 100644
--- a/gl/ialloc.h
+++ b/gl/ialloc.h
@@ -1,6 +1,6 @@
1/* ialloc.h -- malloc with idx_t rather than size_t 1/* ialloc.h -- malloc with idx_t rather than size_t
2 2
3 Copyright 2021-2023 Free Software Foundation, Inc. 3 Copyright 2021-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -18,15 +18,18 @@
18#ifndef IALLOC_H_ 18#ifndef IALLOC_H_
19#define IALLOC_H_ 19#define IALLOC_H_
20 20
21/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_COLD,
22 _GL_ATTRIBUTE_MALLOC. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
21#include "idx.h" 27#include "idx.h"
22 28
23#include <errno.h> 29#include <errno.h>
24#include <stdint.h> 30#include <stdint.h>
25#include <stdlib.h> 31#include <stdlib.h>
26 32
27#ifndef _GL_INLINE_HEADER_BEGIN
28 #error "Please include config.h first."
29#endif
30_GL_INLINE_HEADER_BEGIN 33_GL_INLINE_HEADER_BEGIN
31#ifndef IALLOC_INLINE 34#ifndef IALLOC_INLINE
32# define IALLOC_INLINE _GL_INLINE 35# define IALLOC_INLINE _GL_INLINE
@@ -43,6 +46,9 @@ _gl_alloc_nomem (void)
43 return NULL; 46 return NULL;
44} 47}
45 48
49/* imalloc (size) is like malloc (size).
50 It returns a non-NULL pointer to size bytes of memory.
51 Upon failure, it returns NULL with errno set. */
46IALLOC_INLINE 52IALLOC_INLINE
47_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ 53_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/
48void * 54void *
@@ -51,16 +57,20 @@ imalloc (idx_t s)
51 return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem (); 57 return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem ();
52} 58}
53 59
60/* irealloc (ptr, size) is like realloc (ptr, size).
61 It returns a non-NULL pointer to size bytes of memory.
62 Upon failure, it returns NULL with errno set. */
54IALLOC_INLINE 63IALLOC_INLINE
55/*_GL_ATTRIBUTE_DEALLOC_FREE*/ 64/*_GL_ATTRIBUTE_DEALLOC_FREE*/
56void * 65void *
57irealloc (void *p, idx_t s) 66irealloc (void *p, idx_t s)
58{ 67{
59 /* Work around GNU realloc glitch by treating a zero size as if it 68 return s <= SIZE_MAX ? realloc (p, s) : _gl_alloc_nomem ();
60 were 1, so that returning NULL is equivalent to failing. */
61 return s <= SIZE_MAX ? realloc (p, s | !s) : _gl_alloc_nomem ();
62} 69}
63 70
71/* icalloc (num, size) is like calloc (num, size).
72 It returns a non-NULL pointer to num * size bytes of memory.
73 Upon failure, it returns NULL with errno set. */
64IALLOC_INLINE 74IALLOC_INLINE
65_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ 75_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/
66void * 76void *
@@ -81,13 +91,12 @@ icalloc (idx_t n, idx_t s)
81 return calloc (n, s); 91 return calloc (n, s);
82} 92}
83 93
94/* ireallocarray (ptr, num, size) is like reallocarray (ptr, num, size).
95 It returns a non-NULL pointer to num * size bytes of memory.
96 Upon failure, it returns NULL with errno set. */
84IALLOC_INLINE void * 97IALLOC_INLINE void *
85ireallocarray (void *p, idx_t n, idx_t s) 98ireallocarray (void *p, idx_t n, idx_t s)
86{ 99{
87 /* Work around GNU reallocarray glitch by treating a zero size as if
88 it were 1, so that returning NULL is equivalent to failing. */
89 if (n == 0 || s == 0)
90 n = s = 1;
91 return (n <= SIZE_MAX && s <= SIZE_MAX 100 return (n <= SIZE_MAX && s <= SIZE_MAX
92 ? reallocarray (p, n, s) 101 ? reallocarray (p, n, s)
93 : _gl_alloc_nomem ()); 102 : _gl_alloc_nomem ());
@@ -97,4 +106,6 @@ ireallocarray (void *p, idx_t n, idx_t s)
97} 106}
98#endif 107#endif
99 108
109_GL_INLINE_HEADER_END
110
100#endif 111#endif
diff --git a/gl/idpriv-droptemp.c b/gl/idpriv-droptemp.c
index 2a85431a..993d25b6 100644
--- a/gl/idpriv-droptemp.c
+++ b/gl/idpriv-droptemp.c
@@ -1,5 +1,5 @@
1/* Dropping uid/gid privileges of the current process temporarily. 1/* Dropping uid/gid privileges of the current process temporarily.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -25,18 +25,18 @@
25 25
26/* The privileged uid and gid that the process had earlier. */ 26/* The privileged uid and gid that the process had earlier. */
27#if HAVE_GETUID 27#if HAVE_GETUID
28static int saved_uid = -1; 28static uid_t saved_uid = -1;
29#endif 29#endif
30#if HAVE_GETGID 30#if HAVE_GETGID
31static int saved_gid = -1; 31static gid_t saved_gid = -1;
32#endif 32#endif
33 33
34int 34int
35idpriv_temp_drop (void) 35idpriv_temp_drop (void)
36{ 36{
37#if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID) 37#if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID)
38 int uid = getuid (); 38 uid_t uid = getuid ();
39 int gid = getgid (); 39 gid_t gid = getgid ();
40 40
41 /* Find out about the privileged uid and gid at the first call. */ 41 /* Find out about the privileged uid and gid at the first call. */
42 if (saved_uid == -1) 42 if (saved_uid == -1)
@@ -51,7 +51,7 @@ idpriv_temp_drop (void)
51# if HAVE_SETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */ 51# if HAVE_SETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */
52 if (setresgid (-1, gid, saved_gid) < 0) 52 if (setresgid (-1, gid, saved_gid) < 0)
53 return -1; 53 return -1;
54# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */ 54# else /* Mac OS X, NetBSD, AIX, Solaris >= 2.5, Cygwin */
55 if (setregid (-1, gid) < 0) 55 if (setregid (-1, gid) < 0)
56 return -1; 56 return -1;
57# endif 57# endif
@@ -64,7 +64,7 @@ idpriv_temp_drop (void)
64 figure 14. */ 64 figure 14. */
65 if (setresuid (-1, uid, saved_uid) < 0) 65 if (setresuid (-1, uid, saved_uid) < 0)
66 return -1; 66 return -1;
67# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */ 67# else /* Mac OS X, NetBSD, AIX, Solaris >= 2.5, Cygwin */
68 if (setreuid (-1, uid) < 0) 68 if (setreuid (-1, uid) < 0)
69 return -1; 69 return -1;
70# endif 70# endif
@@ -124,8 +124,8 @@ int
124idpriv_temp_restore (void) 124idpriv_temp_restore (void)
125{ 125{
126#if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID) 126#if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID)
127 int uid = getuid (); 127 uid_t uid = getuid ();
128 int gid = getgid (); 128 gid_t gid = getgid ();
129 129
130 if (saved_uid == -1 || saved_gid == -1) 130 if (saved_uid == -1 || saved_gid == -1)
131 /* Caller error: idpriv_temp_drop was never invoked. */ 131 /* Caller error: idpriv_temp_drop was never invoked. */
@@ -142,7 +142,7 @@ idpriv_temp_restore (void)
142 figure 14. */ 142 figure 14. */
143 if (setresuid (-1, saved_uid, -1) < 0) 143 if (setresuid (-1, saved_uid, -1) < 0)
144 return -1; 144 return -1;
145# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */ 145# else /* Mac OS X, NetBSD, AIX, Solaris >= 2.5, Cygwin */
146 if (setreuid (-1, saved_uid) < 0) 146 if (setreuid (-1, saved_uid) < 0)
147 return -1; 147 return -1;
148# endif 148# endif
@@ -151,7 +151,7 @@ idpriv_temp_restore (void)
151# if HAVE_SETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */ 151# if HAVE_SETRESGID /* glibc, FreeBSD, OpenBSD, HP-UX */
152 if (setresgid (-1, saved_gid, -1) < 0) 152 if (setresgid (-1, saved_gid, -1) < 0)
153 return -1; 153 return -1;
154# else /* Mac OS X, NetBSD, AIX, IRIX, Solaris >= 2.5, OSF/1, Cygwin */ 154# else /* Mac OS X, NetBSD, AIX, Solaris >= 2.5, Cygwin */
155 if (setregid (-1, saved_gid) < 0) 155 if (setregid (-1, saved_gid) < 0)
156 return -1; 156 return -1;
157# endif 157# endif
diff --git a/gl/idpriv.h b/gl/idpriv.h
index 99f87c08..8fa6c0e6 100644
--- a/gl/idpriv.h
+++ b/gl/idpriv.h
@@ -1,5 +1,5 @@
1/* Dropping uid/gid privileges of the current process. 1/* Dropping uid/gid privileges of the current process.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/gl/idx.h b/gl/idx.h
index 23020b7e..deb7dc4c 100644
--- a/gl/idx.h
+++ b/gl/idx.h
@@ -1,5 +1,5 @@
1/* A type for indices and sizes. 1/* A type for indices and sizes.
2 Copyright (C) 2020-2023 Free Software Foundation, Inc. 2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
@@ -111,6 +111,11 @@
111 help producing good code and good warnings. The type 'idx_t' could 111 help producing good code and good warnings. The type 'idx_t' could
112 then be typedef'ed to a range type that is signed after promotion. */ 112 then be typedef'ed to a range type that is signed after promotion. */
113 113
114#ifdef __cplusplus
115extern "C" {
116#endif
117
118
114/* In the future, idx_t could be typedef'ed to a signed range type. 119/* In the future, idx_t could be typedef'ed to a signed range type.
115 The clang "extended integer types", supported in Clang 11 or newer 120 The clang "extended integer types", supported in Clang 11 or newer
116 <https://clang.llvm.org/docs/LanguageExtensions.html#extended-integer-types>, 121 <https://clang.llvm.org/docs/LanguageExtensions.html#extended-integer-types>,
@@ -131,4 +136,9 @@ typedef ptrdiff_t idx_t;
131 Perhaps there should be another macro IDX_VALUE_BITS that does not 136 Perhaps there should be another macro IDX_VALUE_BITS that does not
132 count the sign bit and is therefore one less than PTRDIFF_WIDTH. */ 137 count the sign bit and is therefore one less than PTRDIFF_WIDTH. */
133 138
139
140#ifdef __cplusplus
141}
142#endif
143
134#endif /* _IDX_H */ 144#endif /* _IDX_H */
diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c
index 9e2d412e..599ca4fb 100644
--- a/gl/inet_ntop.c
+++ b/gl/inet_ntop.c
@@ -1,6 +1,6 @@
1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form 1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
2 2
3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -117,7 +117,7 @@ inet_ntop (int af, const void *restrict src,
117 * 'dst' (as a const) 117 * 'dst' (as a const)
118 * notes: 118 * notes:
119 * (1) uses no statics 119 * (1) uses no statics
120 * (2) takes a u_char* not an in_addr as input 120 * (2) takes a 'unsigned char *' not an in_addr as input
121 * author: 121 * author:
122 * Paul Vixie, 1996. 122 * Paul Vixie, 1996.
123 */ 123 */
@@ -125,9 +125,7 @@ static const char *
125inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) 125inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
126{ 126{
127 char tmp[sizeof "255.255.255.255"]; 127 char tmp[sizeof "255.255.255.255"];
128 int len; 128 int len = sprintf (tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
129
130 len = sprintf (tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
131 if (len < 0) 129 if (len < 0)
132 return NULL; 130 return NULL;
133 131
@@ -152,33 +150,25 @@ static const char *
152inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) 150inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
153{ 151{
154 /* 152 /*
155 * Note that int32_t and int16_t need only be "at least" large enough
156 * to contain a value of the specified size. On some systems, like
157 * Crays, there is no such thing as an integer variable with 16 bits.
158 * Keep this in mind if you think this function should have been coded
159 * to use pointer overlays. All the world's not a VAX.
160 */
161 char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
162 struct
163 {
164 int base, len;
165 } best, cur;
166 unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
167 int i;
168
169 /*
170 * Preprocess: 153 * Preprocess:
171 * Copy the input (bytewise) array into a wordwise array. 154 * Copy the input (bytewise) array into a wordwise array.
172 * Find the longest run of 0x00's in src[] for :: shorthanding. 155 * Find the longest run of 0x00's in src[] for :: shorthanding.
173 */ 156 */
157 unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
174 memset (words, '\0', sizeof words); 158 memset (words, '\0', sizeof words);
175 for (i = 0; i < NS_IN6ADDRSZ; i += 2) 159 for (int i = 0; i < NS_IN6ADDRSZ; i += 2)
176 words[i / 2] = (src[i] << 8) | src[i + 1]; 160 words[i / 2] = (src[i] << 8) | src[i + 1];
161
162 struct
163 {
164 int base, len;
165 } best, cur;
177 best.base = -1; 166 best.base = -1;
178 cur.base = -1; 167 cur.base = -1;
179 IF_LINT(best.len = 0); 168 IF_LINT(best.len = 0);
180 IF_LINT(cur.len = 0); 169 IF_LINT(cur.len = 0);
181 for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) 170
171 for (int i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
182 { 172 {
183 if (words[i] == 0) 173 if (words[i] == 0)
184 { 174 {
@@ -208,8 +198,16 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
208 /* 198 /*
209 * Format the result. 199 * Format the result.
210 */ 200 */
211 tp = tmp; 201 /*
212 for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) 202 * Note that int32_t and int16_t need only be "at least" large enough
203 * to contain a value of the specified size. On some systems, like
204 * Crays, there is no such thing as an integer variable with 16 bits.
205 * Keep this in mind if you think this function should have been coded
206 * to use pointer overlays. All the world's not a VAX.
207 */
208 char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
209 char *tp = tmp;
210 for (int i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
213 { 211 {
214 /* Are we inside the best run of 0x00's? */ 212 /* Are we inside the best run of 0x00's? */
215 if (best.base != -1 && i >= best.base && i < (best.base + best.len)) 213 if (best.base != -1 && i >= best.base && i < (best.base + best.len))
diff --git a/gl/inet_pton.c b/gl/inet_pton.c
new file mode 100644
index 00000000..1e75c8c5
--- /dev/null
+++ b/gl/inet_pton.c
@@ -0,0 +1,265 @@
1/* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
2
3 Copyright (C) 2006, 2008-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/*
19 * Copyright (c) 1996,1999 by Internet Software Consortium.
20 *
21 * Permission to use, copy, modify, and distribute this software for any
22 * purpose with or without fee is hereby granted, provided that the above
23 * copyright notice and this permission notice appear in all copies.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
26 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
28 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
29 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
30 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
32 * SOFTWARE.
33 */
34
35#include <config.h>
36
37/* Specification. */
38#include <arpa/inet.h>
39
40#if HAVE_DECL_INET_PTON
41
42# undef inet_pton
43
44int
45rpl_inet_pton (int af, const char *restrict src, void *restrict dst)
46{
47 return inet_pton (af, src, dst);
48}
49
50#else
51
52# include <c-ctype.h>
53# include <string.h>
54# include <errno.h>
55
56# define NS_INADDRSZ 4
57# define NS_IN6ADDRSZ 16
58# define NS_INT16SZ 2
59
60/*
61 * WARNING: Don't even consider trying to compile this on a system where
62 * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
63 */
64
65static int inet_pton4 (const char *src, unsigned char *dst);
66# if HAVE_IPV6
67static int inet_pton6 (const char *src, unsigned char *dst);
68# endif
69
70/* int
71 * inet_pton(af, src, dst)
72 * convert from presentation format (which usually means ASCII printable)
73 * to network format (which is usually some kind of binary format).
74 * return:
75 * 1 if the address was valid for the specified address family
76 * 0 if the address wasn't valid ('dst' is untouched in this case)
77 * -1 if some other error occurred ('dst' is untouched in this case, too)
78 * author:
79 * Paul Vixie, 1996.
80 */
81int
82inet_pton (int af, const char *restrict src, void *restrict dst)
83{
84 switch (af)
85 {
86 case AF_INET:
87 return (inet_pton4 (src, dst));
88
89# if HAVE_IPV6
90 case AF_INET6:
91 return (inet_pton6 (src, dst));
92# endif
93
94 default:
95 errno = EAFNOSUPPORT;
96 return (-1);
97 }
98 /* NOTREACHED */
99}
100
101/* int
102 * inet_pton4(src, dst)
103 * like inet_aton() but without all the hexadecimal, octal (with the
104 * exception of 0) and shorthand.
105 * return:
106 * 1 if 'src' is a valid dotted quad, else 0.
107 * notice:
108 * does not touch 'dst' unless it's returning 1.
109 * author:
110 * Paul Vixie, 1996.
111 */
112static int
113inet_pton4 (const char *restrict src, unsigned char *restrict dst)
114{
115 unsigned char tmp[NS_INADDRSZ];
116
117 {
118 int saw_digit = 0;
119 int octets = 0;
120 unsigned char *tp = tmp;
121 *tp = 0;
122 int ch;
123 while ((ch = *src++) != '\0')
124 {
125 if (ch >= '0' && ch <= '9')
126 {
127 if (saw_digit && *tp == 0)
128 return (0);
129 unsigned new = *tp * 10 + (ch - '0');
130 if (new > 255)
131 return (0);
132 *tp = new;
133 if (!saw_digit)
134 {
135 if (++octets > 4)
136 return (0);
137 saw_digit = 1;
138 }
139 }
140 else if (ch == '.' && saw_digit)
141 {
142 if (octets == 4)
143 return (0);
144 *++tp = 0;
145 saw_digit = 0;
146 }
147 else
148 return (0);
149 }
150 if (octets < 4)
151 return (0);
152 }
153 memcpy (dst, tmp, NS_INADDRSZ);
154 return (1);
155}
156
157# if HAVE_IPV6
158
159/* int
160 * inet_pton6(src, dst)
161 * convert presentation level address to network order binary form.
162 * return:
163 * 1 if 'src' is a valid [RFC1884 2.2] address, else 0.
164 * notice:
165 * (1) does not touch 'dst' unless it's returning 1.
166 * (2) :: in a full address is silently ignored.
167 * credit:
168 * inspired by Mark Andrews.
169 * author:
170 * Paul Vixie, 1996.
171 */
172static int
173inet_pton6 (const char *restrict src, unsigned char *restrict dst)
174{
175 static const char xdigits[] = "0123456789abcdef";
176 unsigned char tmp[NS_IN6ADDRSZ];
177
178 /* Leading :: requires some special handling. */
179 if (*src == ':')
180 if (*++src != ':')
181 return (0);
182
183 {
184 unsigned char *tp = memset (tmp, '\0', NS_IN6ADDRSZ);
185 unsigned char *endp = tp + NS_IN6ADDRSZ;
186 unsigned char *colonp = NULL;
187 const char *curtok = src;
188 int saw_xdigit = 0;
189 unsigned int val = 0;
190 int ch;
191 while ((ch = c_tolower (*src++)) != '\0')
192 {
193 const char *pch = strchr (xdigits, ch);
194 if (pch != NULL)
195 {
196 val <<= 4;
197 val |= (pch - xdigits);
198 if (val > 0xffff)
199 return (0);
200 saw_xdigit = 1;
201 }
202 else if (ch == ':')
203 {
204 curtok = src;
205 if (!saw_xdigit)
206 {
207 if (colonp)
208 return (0);
209 colonp = tp;
210 }
211 else if (*src == '\0')
212 return (0);
213 else if (tp + NS_INT16SZ > endp)
214 return (0);
215 else
216 {
217 *tp++ = (unsigned char) (val >> 8) & 0xff;
218 *tp++ = (unsigned char) val & 0xff;
219 saw_xdigit = 0;
220 val = 0;
221 }
222 }
223 else if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
224 inet_pton4 (curtok, tp) > 0)
225 {
226 tp += NS_INADDRSZ;
227 saw_xdigit = 0;
228 break; /* '\0' was seen by inet_pton4(). */
229 }
230 else
231 return (0);
232 }
233 if (saw_xdigit)
234 {
235 if (tp + NS_INT16SZ > endp)
236 return (0);
237 *tp++ = (unsigned char) (val >> 8) & 0xff;
238 *tp++ = (unsigned char) val & 0xff;
239 }
240 if (colonp != NULL)
241 {
242 if (tp == endp)
243 return (0);
244 /*
245 * Since some memmove()'s erroneously fail to handle
246 * overlapping regions, we'll do the shift by hand.
247 */
248 const int n = tp - colonp;
249 for (int i = 1; i <= n; i++)
250 {
251 endp[-i] = colonp[n - i];
252 colonp[n - i] = 0;
253 }
254 tp = endp;
255 }
256 if (tp != endp)
257 return (0);
258 }
259 memcpy (dst, tmp, NS_IN6ADDRSZ);
260 return (1);
261}
262
263# endif
264
265#endif
diff --git a/gl/intprops-internal.h b/gl/intprops-internal.h
index 0467a9ca..0df385b9 100644
--- a/gl/intprops-internal.h
+++ b/gl/intprops-internal.h
@@ -1,6 +1,6 @@
1/* intprops-internal.h -- properties of integer types not visible to users 1/* intprops-internal.h -- properties of integer types not visible to users
2 2
3 Copyright (C) 2001-2023 Free Software Foundation, Inc. 3 Copyright (C) 2001-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published 6 under the terms of the GNU Lesser General Public License as published
@@ -20,14 +20,15 @@
20 20
21#include <limits.h> 21#include <limits.h>
22 22
23/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */
24#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__
25# pragma GCC diagnostic ignored "-Wtype-limits"
26#endif
27
23/* Return a value with the common real type of E and V and the value of V. 28/* Return a value with the common real type of E and V and the value of V.
24 Do not evaluate E. */ 29 Do not evaluate E. */
25#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) 30#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
26 31
27/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
28 <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
29#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
30
31/* The extra casts in the following macros work around compiler bugs, 32/* The extra casts in the following macros work around compiler bugs,
32 e.g., in Cray C 5.0.3.0. */ 33 e.g., in Cray C 5.0.3.0. */
33 34
@@ -36,7 +37,7 @@
36 37
37/* Return 1 if the real expression E, after promotion, has a 38/* Return 1 if the real expression E, after promotion, has a
38 signed or floating type. Do not evaluate E. */ 39 signed or floating type. Do not evaluate E. */
39#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) 40#define _GL_EXPR_SIGNED(e) (_GL_INT_CONVERT (e, -1) < 0)
40 41
41 42
42/* Minimum and maximum values for integer types and expressions. */ 43/* Minimum and maximum values for integer types and expressions. */
@@ -55,7 +56,7 @@
55#define _GL_INT_MAXIMUM(e) \ 56#define _GL_INT_MAXIMUM(e) \
56 (_GL_EXPR_SIGNED (e) \ 57 (_GL_EXPR_SIGNED (e) \
57 ? _GL_SIGNED_INT_MAXIMUM (e) \ 58 ? _GL_SIGNED_INT_MAXIMUM (e) \
58 : _GL_INT_NEGATE_CONVERT (e, 1)) 59 : _GL_INT_CONVERT (e, -1))
59#define _GL_SIGNED_INT_MAXIMUM(e) \ 60#define _GL_SIGNED_INT_MAXIMUM(e) \
60 (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1) 61 (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
61 62
@@ -72,10 +73,11 @@
72 73
73/* Does the __typeof__ keyword work? This could be done by 74/* Does the __typeof__ keyword work? This could be done by
74 'configure', but for now it's easier to do it by hand. */ 75 'configure', but for now it's easier to do it by hand. */
75#if (2 <= __GNUC__ \ 76#if ((defined __GNUC__ && 2 <= __GNUC__) \
76 || (4 <= __clang_major__) \ 77 || (defined __clang_major__ && 4 <= __clang_major__) \
77 || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ 78 || (defined __IBMC__ && 1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
78 || (0x5110 <= __SUNPRO_C && !__STDC__)) 79 || (defined __SUNPRO_C && 0x5110 <= __SUNPRO_C && !__STDC__) \
80 || (defined _MSC_VER && 1939 <= _MSC_VER))
79# define _GL_HAVE___TYPEOF__ 1 81# define _GL_HAVE___TYPEOF__ 1
80#else 82#else
81# define _GL_HAVE___TYPEOF__ 0 83# define _GL_HAVE___TYPEOF__ 0
@@ -106,7 +108,7 @@
106#elif defined __has_builtin 108#elif defined __has_builtin
107# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) 109# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
108/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, 110/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
109 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */ 111 see <https://gcc.gnu.org/PR98269>. */
110#elif 7 <= __GNUC__ 112#elif 7 <= __GNUC__
111# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 113# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
112#else 114#else
@@ -114,8 +116,8 @@
114#endif 116#endif
115 117
116/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ 118/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
117#if defined __clang_major__ && __clang_major__ < 14 119#if defined __clang_major__ && __clang_major__ < 21
118/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */ 120/* Work around Clang bug <https://github.com/llvm/llvm-project/issues/16778>. */
119# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 121# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
120#else 122#else
121# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW 123# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
@@ -158,13 +160,15 @@
158#if _GL_HAS_BUILTIN_MUL_OVERFLOW 160#if _GL_HAS_BUILTIN_MUL_OVERFLOW
159# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ 161# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
160 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ 162 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
161 && !defined __EDG__) 163 && !defined __clang__ && !defined __EDG__)
162# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) 164# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
163# else 165# else
164 /* Work around GCC bug 91450. */ 166 /* Work around GCC bug 91450. */
165# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ 167# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
166 ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \ 168 ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
167 && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ 169 && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \
170 (__typeof__ (*(r))) 0, \
171 (__typeof__ (*(r))) -1)) \
168 ? ((void) __builtin_mul_overflow (a, b, r), 1) \ 172 ? ((void) __builtin_mul_overflow (a, b, r), 1) \
169 : __builtin_mul_overflow (a, b, r)) 173 : __builtin_mul_overflow (a, b, r))
170# endif 174# endif
@@ -175,13 +179,13 @@
175 _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) 179 _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
176#endif 180#endif
177 181
178/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: 182/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25764. See:
179 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 183 https://gcc.gnu.org/PR68193
180 https://llvm.org/bugs/show_bug.cgi?id=25390 184 https://github.com/llvm/llvm-project/issues/25764
181 For now, assume all versions of GCC-like compilers generate bogus 185 For now, assume GCC < 14 and all Clang versions generate bogus
182 warnings for _Generic. This matters only for compilers that 186 warnings for _Generic. This matters only for compilers that
183 lack relevant builtins. */ 187 lack relevant builtins. */
184#if __GNUC__ || defined __clang__ 188#if (__GNUC__ && __GNUC__ < 14) || defined __clang__
185# define _GL__GENERIC_BOGUS 1 189# define _GL__GENERIC_BOGUS 1
186#else 190#else
187# define _GL__GENERIC_BOGUS 0 191# define _GL__GENERIC_BOGUS 0
diff --git a/gl/intprops.h b/gl/intprops.h
index 44b5e60f..924b6f9a 100644
--- a/gl/intprops.h
+++ b/gl/intprops.h
@@ -1,6 +1,6 @@
1/* intprops.h -- properties of integer types 1/* intprops.h -- properties of integer types
2 2
3 Copyright (C) 2001-2023 Free Software Foundation, Inc. 3 Copyright (C) 2001-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published 6 under the terms of the GNU Lesser General Public License as published
@@ -34,6 +34,14 @@
34 signed or floating type. Do not evaluate E. */ 34 signed or floating type. Do not evaluate E. */
35#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e) 35#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e)
36 36
37/* The same value as as the arithmetic expression E, but with E's type
38 after integer promotions. For example, if E is of type 'enum {A, B}'
39 then 'switch (INT_PROMOTE (E))' pacifies gcc -Wswitch-enum if some
40 enum values are deliberately omitted from the switch's cases.
41 Here, unary + is safer than a cast or inline function, as unary +
42 does only integer promotions and is disallowed on pointers. */
43#define INT_PROMOTE(e) (+ (e))
44
37 45
38/* Minimum and maximum values for integer types and expressions. */ 46/* Minimum and maximum values for integer types and expressions. */
39 47
@@ -197,11 +205,11 @@
197 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) 205 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
198#endif 206#endif
199#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ 207#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
200 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ 208 ((min) < 0 ? (b) == _GL_INT_CONVERT (min, -1) && (a) < - (max) \
201 : (a) < 0 ? (b) <= (a) + (b) - 1 \ 209 : (a) < 0 ? (b) <= (a) + (b) - 1 \
202 : (b) < 0 && (a) + (b) <= (a)) 210 : (b) < 0 && (a) + (b) <= (a))
203#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ 211#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
204 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ 212 ((min) < 0 ? (b) == _GL_INT_CONVERT (min, -1) && (a) < - (max) \
205 : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ 213 : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
206 : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) 214 : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
207 215
diff --git a/gl/inttypes.in.h b/gl/inttypes.in.h
index 50a2bbfc..cbe5a6f0 100644
--- a/gl/inttypes.in.h
+++ b/gl/inttypes.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2006-2023 Free Software Foundation, Inc. 1/* Copyright (C) 2006-2026 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Derek Price. 2 Written by Paul Eggert, Bruno Haible, Derek Price.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
@@ -46,6 +46,11 @@
46#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 46#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
47#define INTTYPES_H 47#define INTTYPES_H
48 48
49/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
50#if !_GL_CONFIG_H_INCLUDED
51 #error "Please include config.h first."
52#endif
53
49/* Include <stdint.h> or the gnulib replacement. 54/* Include <stdint.h> or the gnulib replacement.
50 But avoid namespace pollution on glibc systems. */ 55 But avoid namespace pollution on glibc systems. */
51#ifndef __GLIBC__ 56#ifndef __GLIBC__
@@ -903,11 +908,23 @@ extern "C" {
903#endif 908#endif
904 909
905#if @GNULIB_IMAXABS@ 910#if @GNULIB_IMAXABS@
906# if !@HAVE_DECL_IMAXABS@ 911# if @REPLACE_IMAXABS@
907extern intmax_t imaxabs (intmax_t); 912# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
913# undef imaxabs
914# define imaxabs rpl_imaxabs
915# endif
916_GL_FUNCDECL_RPL (imaxabs, intmax_t, (intmax_t x), );
917_GL_CXXALIAS_RPL (imaxabs, intmax_t, (intmax_t x));
918# else
919# if !@HAVE_DECL_IMAXABS@
920_GL_FUNCDECL_SYS (imaxabs, intmax_t, (intmax_t x), );
921# endif
922_GL_CXXALIAS_SYS (imaxabs, intmax_t, (intmax_t x));
923# endif
924# if __GLIBC__ >= 2
925_GL_CXXALIASWARN (imaxabs);
908# endif 926# endif
909#elif defined GNULIB_POSIXCHECK 927#elif defined GNULIB_POSIXCHECK
910# undef imaxabs
911# if HAVE_RAW_DECL_IMAXABS 928# if HAVE_RAW_DECL_IMAXABS
912_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - " 929_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
913 "use gnulib module imaxabs for portability"); 930 "use gnulib module imaxabs for portability");
@@ -921,11 +938,23 @@ typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
921# define GNULIB_defined_imaxdiv_t 1 938# define GNULIB_defined_imaxdiv_t 1
922# endif 939# endif
923# endif 940# endif
924# if !@HAVE_DECL_IMAXDIV@ 941# if @REPLACE_IMAXDIV@
925extern imaxdiv_t imaxdiv (intmax_t, intmax_t); 942# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
943# undef imaxdiv
944# define imaxdiv rpl_imaxdiv
945# endif
946_GL_FUNCDECL_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom), );
947_GL_CXXALIAS_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom));
948# else
949# if !@HAVE_DECL_IMAXDIV@
950_GL_FUNCDECL_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom), );
951# endif
952_GL_CXXALIAS_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom));
953# endif
954# if __GLIBC__ >= 2
955_GL_CXXALIASWARN (imaxdiv);
926# endif 956# endif
927#elif defined GNULIB_POSIXCHECK 957#elif defined GNULIB_POSIXCHECK
928# undef imaxdiv
929# if HAVE_RAW_DECL_IMAXDIV 958# if HAVE_RAW_DECL_IMAXDIV
930_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - " 959_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
931 "use gnulib module imaxdiv for portability"); 960 "use gnulib module imaxdiv for portability");
@@ -939,7 +968,7 @@ _GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
939# define strtoimax rpl_strtoimax 968# define strtoimax rpl_strtoimax
940# endif 969# endif
941_GL_FUNCDECL_RPL (strtoimax, intmax_t, 970_GL_FUNCDECL_RPL (strtoimax, intmax_t,
942 (const char *restrict, char **restrict, int) 971 (const char *restrict, char **restrict, int),
943 _GL_ARG_NONNULL ((1))); 972 _GL_ARG_NONNULL ((1)));
944_GL_CXXALIAS_RPL (strtoimax, intmax_t, 973_GL_CXXALIAS_RPL (strtoimax, intmax_t,
945 (const char *restrict, char **restrict, int)); 974 (const char *restrict, char **restrict, int));
@@ -947,7 +976,7 @@ _GL_CXXALIAS_RPL (strtoimax, intmax_t,
947# if !@HAVE_DECL_STRTOIMAX@ 976# if !@HAVE_DECL_STRTOIMAX@
948# undef strtoimax 977# undef strtoimax
949_GL_FUNCDECL_SYS (strtoimax, intmax_t, 978_GL_FUNCDECL_SYS (strtoimax, intmax_t,
950 (const char *restrict, char **restrict, int) 979 (const char *restrict, char **restrict, int),
951 _GL_ARG_NONNULL ((1))); 980 _GL_ARG_NONNULL ((1)));
952# endif 981# endif
953_GL_CXXALIAS_SYS (strtoimax, intmax_t, 982_GL_CXXALIAS_SYS (strtoimax, intmax_t,
@@ -955,7 +984,6 @@ _GL_CXXALIAS_SYS (strtoimax, intmax_t,
955# endif 984# endif
956_GL_CXXALIASWARN (strtoimax); 985_GL_CXXALIASWARN (strtoimax);
957#elif defined GNULIB_POSIXCHECK 986#elif defined GNULIB_POSIXCHECK
958# undef strtoimax
959# if HAVE_RAW_DECL_STRTOIMAX 987# if HAVE_RAW_DECL_STRTOIMAX
960_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - " 988_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
961 "use gnulib module strtoimax for portability"); 989 "use gnulib module strtoimax for portability");
@@ -969,7 +997,7 @@ _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
969# define strtoumax rpl_strtoumax 997# define strtoumax rpl_strtoumax
970# endif 998# endif
971_GL_FUNCDECL_RPL (strtoumax, uintmax_t, 999_GL_FUNCDECL_RPL (strtoumax, uintmax_t,
972 (const char *restrict, char **restrict, int) 1000 (const char *restrict, char **restrict, int),
973 _GL_ARG_NONNULL ((1))); 1001 _GL_ARG_NONNULL ((1)));
974_GL_CXXALIAS_RPL (strtoumax, uintmax_t, 1002_GL_CXXALIAS_RPL (strtoumax, uintmax_t,
975 (const char *restrict, char **restrict, int)); 1003 (const char *restrict, char **restrict, int));
@@ -977,7 +1005,7 @@ _GL_CXXALIAS_RPL (strtoumax, uintmax_t,
977# if !@HAVE_DECL_STRTOUMAX@ 1005# if !@HAVE_DECL_STRTOUMAX@
978# undef strtoumax 1006# undef strtoumax
979_GL_FUNCDECL_SYS (strtoumax, uintmax_t, 1007_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
980 (const char *restrict, char **restrict, int) 1008 (const char *restrict, char **restrict, int),
981 _GL_ARG_NONNULL ((1))); 1009 _GL_ARG_NONNULL ((1)));
982# endif 1010# endif
983_GL_CXXALIAS_SYS (strtoumax, uintmax_t, 1011_GL_CXXALIAS_SYS (strtoumax, uintmax_t,
@@ -985,7 +1013,6 @@ _GL_CXXALIAS_SYS (strtoumax, uintmax_t,
985# endif 1013# endif
986_GL_CXXALIASWARN (strtoumax); 1014_GL_CXXALIASWARN (strtoumax);
987#elif defined GNULIB_POSIXCHECK 1015#elif defined GNULIB_POSIXCHECK
988# undef strtoumax
989# if HAVE_RAW_DECL_STRTOUMAX 1016# if HAVE_RAW_DECL_STRTOUMAX
990_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - " 1017_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
991 "use gnulib module strtoumax for portability"); 1018 "use gnulib module strtoumax for portability");
diff --git a/gl/iswblank.c b/gl/iswblank.c
new file mode 100644
index 00000000..c09f33bd
--- /dev/null
+++ b/gl/iswblank.c
@@ -0,0 +1,26 @@
1/* Test wide character for being blank.
2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <wctype.h>
21
22int
23iswblank (wint_t wc)
24{
25 return wc == ' ' || wc == '\t';
26}
diff --git a/gl/iswctype-impl.h b/gl/iswctype-impl.h
new file mode 100644
index 00000000..34d84b19
--- /dev/null
+++ b/gl/iswctype-impl.h
@@ -0,0 +1,22 @@
1/* Test whether a wide character has a given property.
2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18int
19iswctype (wint_t wc, wctype_t desc)
20{
21 return ((int (*) (wint_t)) desc) (wc);
22}
diff --git a/gl/iswctype.c b/gl/iswctype.c
new file mode 100644
index 00000000..97a60032
--- /dev/null
+++ b/gl/iswctype.c
@@ -0,0 +1,36 @@
1/* Test whether a wide character has a given property.
2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <wctype.h>
22
23#if GNULIB_defined_wint_t && !GNULIB_defined_wctype_t
24
25int
26iswctype (wint_t wc, wctype_t desc)
27# undef iswctype
28{
29 return ((wchar_t) wc == wc ? iswctype ((wchar_t) wc, desc) : 0);
30}
31
32#else
33
34# include "iswctype-impl.h"
35
36#endif
diff --git a/gl/iswdigit.c b/gl/iswdigit.c
new file mode 100644
index 00000000..65616822
--- /dev/null
+++ b/gl/iswdigit.c
@@ -0,0 +1,26 @@
1/* Test wide character for being a digit.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <wctype.h>
21
22int
23iswdigit (wint_t wc)
24{
25 return wc >= '0' && wc <= '9';
26}
diff --git a/gl/iswpunct.c b/gl/iswpunct.c
new file mode 100644
index 00000000..5308ddae
--- /dev/null
+++ b/gl/iswpunct.c
@@ -0,0 +1,33 @@
1/* Test wide character for being a punctuation or symbol character.
2 Copyright (C) 2023-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <wctype.h>
21
22#include <ctype.h>
23
24int
25iswpunct (wint_t wc)
26#undef iswpunct
27{
28#if defined __ANDROID__
29 if ((unsigned int) wc < 128)
30 return ispunct ((unsigned int) wc);
31#endif
32 return iswpunct (wc);
33}
diff --git a/gl/iswxdigit.c b/gl/iswxdigit.c
new file mode 100644
index 00000000..7db2f676
--- /dev/null
+++ b/gl/iswxdigit.c
@@ -0,0 +1,33 @@
1/* Test wide character for being a hexadecimal digit.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <wctype.h>
21
22int
23iswxdigit (wint_t wc)
24{
25 return ((wc >= '0' && wc <= '9')
26#if 'A' == 0x41 && 'a' == 0x61
27 /* Optimization, assuming ASCII */
28 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')
29#else
30 || (wc >= 'A' && wc <= 'F') || (wc >= 'a' && wc <= 'f')
31#endif
32 );
33}
diff --git a/gl/itold.c b/gl/itold.c
index 0ef4464e..d240fb7e 100644
--- a/gl/itold.c
+++ b/gl/itold.c
@@ -1,5 +1,5 @@
1/* Replacement for 'int' to 'long double' conversion routine. 1/* Replacement for 'int' to 'long double' conversion routine.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
diff --git a/gl/langinfo.in.h b/gl/langinfo.in.h
index c7555a6a..4b3f9b5b 100644
--- a/gl/langinfo.in.h
+++ b/gl/langinfo.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <langinfo.h>. 1/* Substitute for and wrapper around <langinfo.h>.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -34,6 +34,11 @@
34#ifndef _@GUARD_PREFIX@_LANGINFO_H 34#ifndef _@GUARD_PREFIX@_LANGINFO_H
35#define _@GUARD_PREFIX@_LANGINFO_H 35#define _@GUARD_PREFIX@_LANGINFO_H
36 36
37/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
38#if !_GL_CONFIG_H_INCLUDED
39 #error "Please include config.h first."
40#endif
41
37 42
38#if !@HAVE_LANGINFO_H@ 43#if !@HAVE_LANGINFO_H@
39 44
@@ -110,6 +115,18 @@ typedef int nl_item;
110# define ABMON_10 (ABMON_1 + 9) 115# define ABMON_10 (ABMON_1 + 9)
111# define ABMON_11 (ABMON_1 + 10) 116# define ABMON_11 (ABMON_1 + 10)
112# define ABMON_12 (ABMON_1 + 11) 117# define ABMON_12 (ABMON_1 + 11)
118# define ABALTMON_1 10220
119# define ABALTMON_2 (ABALTMON_1 + 1)
120# define ABALTMON_3 (ABALTMON_1 + 2)
121# define ABALTMON_4 (ABALTMON_1 + 3)
122# define ABALTMON_5 (ABALTMON_1 + 4)
123# define ABALTMON_6 (ABALTMON_1 + 5)
124# define ABALTMON_7 (ABALTMON_1 + 6)
125# define ABALTMON_8 (ABALTMON_1 + 7)
126# define ABALTMON_9 (ABALTMON_1 + 8)
127# define ABALTMON_10 (ABALTMON_1 + 9)
128# define ABALTMON_11 (ABALTMON_1 + 10)
129# define ABALTMON_12 (ABALTMON_1 + 11)
113# define ERA 10047 130# define ERA 10047
114# define ERA_D_FMT 10048 131# define ERA_D_FMT 10048
115# define ERA_D_T_FMT 10049 132# define ERA_D_T_FMT 10049
@@ -145,11 +162,6 @@ typedef int nl_item;
145# define GNULIB_defined_CODESET 1 162# define GNULIB_defined_CODESET 1
146# endif 163# endif
147 164
148# if !@HAVE_LANGINFO_T_FMT_AMPM@
149# define T_FMT_AMPM 10006
150# define GNULIB_defined_T_FMT_AMPM 1
151# endif
152
153# if !@HAVE_LANGINFO_ALTMON@ 165# if !@HAVE_LANGINFO_ALTMON@
154# define ALTMON_1 10200 166# define ALTMON_1 10200
155# define ALTMON_2 (ALTMON_1 + 1) 167# define ALTMON_2 (ALTMON_1 + 1)
@@ -166,6 +178,37 @@ typedef int nl_item;
166# define GNULIB_defined_ALTMON 1 178# define GNULIB_defined_ALTMON 1
167# endif 179# endif
168 180
181# if !@HAVE_LANGINFO_ABALTMON@
182# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 27
183# define ABALTMON_1 _NL_ABALTMON_1
184# define ABALTMON_2 _NL_ABALTMON_2
185# define ABALTMON_3 _NL_ABALTMON_3
186# define ABALTMON_4 _NL_ABALTMON_4
187# define ABALTMON_5 _NL_ABALTMON_5
188# define ABALTMON_6 _NL_ABALTMON_6
189# define ABALTMON_7 _NL_ABALTMON_7
190# define ABALTMON_8 _NL_ABALTMON_8
191# define ABALTMON_9 _NL_ABALTMON_9
192# define ABALTMON_10 _NL_ABALTMON_10
193# define ABALTMON_11 _NL_ABALTMON_11
194# define ABALTMON_12 _NL_ABALTMON_12
195# else
196# define ABALTMON_1 10220
197# define ABALTMON_2 (ABALTMON_1 + 1)
198# define ABALTMON_3 (ABALTMON_1 + 2)
199# define ABALTMON_4 (ABALTMON_1 + 3)
200# define ABALTMON_5 (ABALTMON_1 + 4)
201# define ABALTMON_6 (ABALTMON_1 + 5)
202# define ABALTMON_7 (ABALTMON_1 + 6)
203# define ABALTMON_8 (ABALTMON_1 + 7)
204# define ABALTMON_9 (ABALTMON_1 + 8)
205# define ABALTMON_10 (ABALTMON_1 + 9)
206# define ABALTMON_11 (ABALTMON_1 + 10)
207# define ABALTMON_12 (ABALTMON_1 + 11)
208# define GNULIB_defined_ABALTMON 1
209# endif
210# endif
211
169# if !@HAVE_LANGINFO_ERA@ 212# if !@HAVE_LANGINFO_ERA@
170# define ERA 10047 213# define ERA 10047
171# define ERA_D_FMT 10048 214# define ERA_D_FMT 10048
@@ -175,12 +218,6 @@ typedef int nl_item;
175# define GNULIB_defined_ERA 1 218# define GNULIB_defined_ERA 1
176# endif 219# endif
177 220
178# if !@HAVE_LANGINFO_YESEXPR@
179# define YESEXPR 10053
180# define NOEXPR 10054
181# define GNULIB_defined_YESEXPR 1
182# endif
183
184#endif 221#endif
185 222
186/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 223/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -200,17 +237,18 @@ typedef int nl_item;
200# undef nl_langinfo 237# undef nl_langinfo
201# define nl_langinfo rpl_nl_langinfo 238# define nl_langinfo rpl_nl_langinfo
202# endif 239# endif
203_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); 240_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item), );
204_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); 241_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
205# else 242# else
206# if !@HAVE_NL_LANGINFO@ 243# if !@HAVE_NL_LANGINFO@
207_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); 244_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item), );
208# endif 245# endif
209_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); 246_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
210# endif 247# endif
248# if __GLIBC__ >= 2
211_GL_CXXALIASWARN (nl_langinfo); 249_GL_CXXALIASWARN (nl_langinfo);
250# endif
212#elif defined GNULIB_POSIXCHECK 251#elif defined GNULIB_POSIXCHECK
213# undef nl_langinfo
214# if HAVE_RAW_DECL_NL_LANGINFO 252# if HAVE_RAW_DECL_NL_LANGINFO
215_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " 253_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
216 "use gnulib module nl_langinfo for portability"); 254 "use gnulib module nl_langinfo for portability");
diff --git a/gl/lc-charset-dispatch.c b/gl/lc-charset-dispatch.c
index cd74466b..53a9b2cd 100644
--- a/gl/lc-charset-dispatch.c
+++ b/gl/lc-charset-dispatch.c
@@ -1,5 +1,5 @@
1/* Dispatching based on the current locale's character encoding. 1/* Dispatching based on the current locale's character encoding.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc. 2 Copyright (C) 2018-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/lc-charset-dispatch.h b/gl/lc-charset-dispatch.h
index c82b6a60..665da408 100644
--- a/gl/lc-charset-dispatch.h
+++ b/gl/lc-charset-dispatch.h
@@ -1,5 +1,5 @@
1/* Dispatching based on the current locale's character encoding. 1/* Dispatching based on the current locale's character encoding.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc. 2 Copyright (C) 2018-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/libc-config.h b/gl/libc-config.h
index 1d28e58c..e5102aa9 100644
--- a/gl/libc-config.h
+++ b/gl/libc-config.h
@@ -1,6 +1,6 @@
1/* System definitions for code taken from the GNU C Library 1/* System definitions for code taken from the GNU C Library
2 2
3 Copyright 2017-2023 Free Software Foundation, Inc. 3 Copyright 2017-2026 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or 5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
@@ -48,6 +48,11 @@
48 48
49/* From glibc <features.h>. */ 49/* From glibc <features.h>. */
50 50
51#if defined __clang__
52 /* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
53# undef __GNUC_PREREQ
54# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
55#endif
51#ifndef __GNUC_PREREQ 56#ifndef __GNUC_PREREQ
52# if defined __GNUC__ && defined __GNUC_MINOR__ 57# if defined __GNUC__ && defined __GNUC_MINOR__
53# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) 58# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
@@ -137,8 +142,6 @@
137# undef __attribute_returns_twice__ 142# undef __attribute_returns_twice__
138# undef __attribute_used__ 143# undef __attribute_used__
139# undef __attribute_warn_unused_result__ 144# undef __attribute_warn_unused_result__
140# undef __bos
141# undef __bos0
142# undef __errordecl 145# undef __errordecl
143# undef __extension__ 146# undef __extension__
144# undef __extern_always_inline 147# undef __extern_always_inline
@@ -147,21 +150,13 @@
147# undef __fortified_attr_access 150# undef __fortified_attr_access
148# undef __fortify_function 151# undef __fortify_function
149# undef __glibc_c99_flexarr_available 152# undef __glibc_c99_flexarr_available
150# undef __glibc_fortify
151# undef __glibc_fortify_n
152# undef __glibc_has_attribute 153# undef __glibc_has_attribute
153# undef __glibc_has_builtin 154# undef __glibc_has_builtin
154# undef __glibc_has_extension 155# undef __glibc_has_extension
155# undef __glibc_likely 156# undef __glibc_likely
156# undef __glibc_macro_warning 157# undef __glibc_macro_warning
157# undef __glibc_macro_warning1 158# undef __glibc_macro_warning1
158# undef __glibc_objsize
159# undef __glibc_objsize0
160# undef __glibc_safe_len_cond
161# undef __glibc_safe_or_unknown_len
162# undef __glibc_unlikely 159# undef __glibc_unlikely
163# undef __glibc_unsafe_len
164# undef __glibc_unsigned_or_positive
165# undef __inline 160# undef __inline
166# undef __ptr_t 161# undef __ptr_t
167# undef __restrict 162# undef __restrict
@@ -170,6 +165,18 @@
170# undef __va_arg_pack_len 165# undef __va_arg_pack_len
171# undef __warnattr 166# undef __warnattr
172# undef __wur 167# undef __wur
168# ifndef __GNULIB_CDEFS
169# undef __bos
170# undef __bos0
171# undef __glibc_fortify
172# undef __glibc_fortify_n
173# undef __glibc_objsize
174# undef __glibc_objsize0
175# undef __glibc_safe_len_cond
176# undef __glibc_safe_or_unknown_len
177# undef __glibc_unsafe_len
178# undef __glibc_unsigned_or_positive
179# endif
173 180
174/* Include our copy of glibc <sys/cdefs.h>. */ 181/* Include our copy of glibc <sys/cdefs.h>. */
175# include <cdefs.h> 182# include <cdefs.h>
diff --git a/gl/limits.in.h b/gl/limits.in.h
index eaeac472..66bd63ee 100644
--- a/gl/limits.in.h
+++ b/gl/limits.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <limits.h>. 1/* A GNU-like <limits.h>.
2 2
3 Copyright 2016-2023 Free Software Foundation, Inc. 3 Copyright 2016-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,7 +20,7 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined _GL_ALREADY_INCLUDING_LIMITS_H 23#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_LIMITS_H
24/* Special invocation convention: 24/* Special invocation convention:
25 On Haiku/x86_64, we have a sequence of nested includes 25 On Haiku/x86_64, we have a sequence of nested includes
26 <limits.h> -> <syslimits.h> -> <limits.h>. 26 <limits.h> -> <syslimits.h> -> <limits.h>.
@@ -34,12 +34,12 @@
34 34
35#ifndef _@GUARD_PREFIX@_LIMITS_H 35#ifndef _@GUARD_PREFIX@_LIMITS_H
36 36
37# define _GL_ALREADY_INCLUDING_LIMITS_H 37# define _@GUARD_PREFIX@_ALREADY_INCLUDING_LIMITS_H
38 38
39/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
40# @INCLUDE_NEXT@ @NEXT_LIMITS_H@ 40# @INCLUDE_NEXT@ @NEXT_LIMITS_H@
41 41
42# undef _GL_ALREADY_INCLUDING_LIMITS_H 42# undef _@GUARD_PREFIX@_ALREADY_INCLUDING_LIMITS_H
43 43
44#ifndef _@GUARD_PREFIX@_LIMITS_H 44#ifndef _@GUARD_PREFIX@_LIMITS_H
45#define _@GUARD_PREFIX@_LIMITS_H 45#define _@GUARD_PREFIX@_LIMITS_H
@@ -47,7 +47,7 @@
47#ifndef LLONG_MIN 47#ifndef LLONG_MIN
48# if defined LONG_LONG_MIN /* HP-UX 11.31 */ 48# if defined LONG_LONG_MIN /* HP-UX 11.31 */
49# define LLONG_MIN LONG_LONG_MIN 49# define LLONG_MIN LONG_LONG_MIN
50# elif defined LONGLONG_MIN /* IRIX 6.5 */ 50# elif defined LONGLONG_MIN /* AIX, BeOS */
51# define LLONG_MIN LONGLONG_MIN 51# define LLONG_MIN LONGLONG_MIN
52# elif defined __GNUC__ 52# elif defined __GNUC__
53# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL) 53# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
@@ -56,7 +56,7 @@
56#ifndef LLONG_MAX 56#ifndef LLONG_MAX
57# if defined LONG_LONG_MAX /* HP-UX 11.31 */ 57# if defined LONG_LONG_MAX /* HP-UX 11.31 */
58# define LLONG_MAX LONG_LONG_MAX 58# define LLONG_MAX LONG_LONG_MAX
59# elif defined LONGLONG_MAX /* IRIX 6.5 */ 59# elif defined LONGLONG_MAX /* AIX, BeOS */
60# define LLONG_MAX LONGLONG_MAX 60# define LLONG_MAX LONGLONG_MAX
61# elif defined __GNUC__ 61# elif defined __GNUC__
62# define LLONG_MAX __LONG_LONG_MAX__ 62# define LLONG_MAX __LONG_LONG_MAX__
@@ -65,7 +65,7 @@
65#ifndef ULLONG_MAX 65#ifndef ULLONG_MAX
66# if defined ULONG_LONG_MAX /* HP-UX 11.31 */ 66# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
67# define ULLONG_MAX ULONG_LONG_MAX 67# define ULLONG_MAX ULONG_LONG_MAX
68# elif defined ULONGLONG_MAX /* IRIX 6.5 */ 68# elif defined ULONGLONG_MAX /* AIX, BeOS */
69# define ULLONG_MAX ULONGLONG_MAX 69# define ULLONG_MAX ULONGLONG_MAX
70# elif defined __GNUC__ 70# elif defined __GNUC__
71# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) 71# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
@@ -99,6 +99,11 @@
99# endif 99# endif
100#endif 100#endif
101 101
102/* Assume no multibyte character is longer than 16 bytes. */
103#ifndef MB_LEN_MAX
104# define MB_LEN_MAX 16
105#endif
106
102/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */ 107/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */
103 108
104#if (! defined ULLONG_WIDTH \ 109#if (! defined ULLONG_WIDTH \
@@ -119,11 +124,26 @@
119 124
120/* Macros specified by C23. */ 125/* Macros specified by C23. */
121 126
122#if (! defined BOOL_WIDTH \ 127#if (defined _GNU_SOURCE \
123 && (defined _GNU_SOURCE \ 128 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))
124 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))) 129# if ! defined BOOL_WIDTH
125# define BOOL_MAX 1 130# define BOOL_WIDTH 1
126# define BOOL_WIDTH 1 131# define BOOL_MAX 1
132# elif ! defined BOOL_MAX
133# define BOOL_MAX 1
134# endif
135#endif
136
137/* Macro specified by POSIX. */
138
139/* The maximum ssize_t value. Although it might not be of ssize_t type
140 as it should be, it's too much trouble to fix this minor detail. */
141#ifndef SSIZE_MAX
142# ifdef _WIN64
143# define SSIZE_MAX LLONG_MAX
144# else
145# define SSIZE_MAX LONG_MAX
146# endif
127#endif 147#endif
128 148
129#endif /* _@GUARD_PREFIX@_LIMITS_H */ 149#endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/gl/localcharset.c b/gl/localcharset.c
index 7ed9c957..22dc38d3 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -1,6 +1,6 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 2
3 Copyright (C) 2000-2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2000-2006, 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -279,45 +279,6 @@ static const struct table_entry alias_table[] =
279 { "utf8", "UTF-8" } 279 { "utf8", "UTF-8" }
280# define alias_table_defined 280# define alias_table_defined
281# endif 281# endif
282# if defined __sgi /* IRIX */
283 { "ISO8859-1", "ISO-8859-1" },
284 { "ISO8859-15", "ISO-8859-15" },
285 { "ISO8859-2", "ISO-8859-2" },
286 { "ISO8859-5", "ISO-8859-5" },
287 { "ISO8859-7", "ISO-8859-7" },
288 { "ISO8859-9", "ISO-8859-9" },
289 { "eucCN", "GB2312" },
290 { "eucJP", "EUC-JP" },
291 { "eucKR", "EUC-KR" },
292 { "eucTW", "EUC-TW" }
293# define alias_table_defined
294# endif
295# if defined __osf__ /* OSF/1 */
296 /*{ "GBK", "GBK" },*/
297 { "ISO8859-1", "ISO-8859-1" },
298 { "ISO8859-15", "ISO-8859-15" },
299 { "ISO8859-2", "ISO-8859-2" },
300 { "ISO8859-4", "ISO-8859-4" },
301 { "ISO8859-5", "ISO-8859-5" },
302 { "ISO8859-7", "ISO-8859-7" },
303 { "ISO8859-8", "ISO-8859-8" },
304 { "ISO8859-9", "ISO-8859-9" },
305 { "KSC5601", "CP949" },
306 { "SJIS", "SHIFT_JIS" },
307 { "TACTIS", "TIS-620" },
308 /*{ "UTF-8", "UTF-8" },*/
309 { "big5", "BIG5" },
310 { "cp850", "CP850" },
311 { "dechanyu", "DEC-HANYU" },
312 { "dechanzi", "GB2312" },
313 { "deckanji", "DEC-KANJI" },
314 { "deckorean", "EUC-KR" },
315 { "eucJP", "EUC-JP" },
316 { "eucKR", "EUC-KR" },
317 { "eucTW", "EUC-TW" },
318 { "sdeckanji", "EUC-JP" }
319# define alias_table_defined
320# endif
321# if defined __sun /* Solaris */ 282# if defined __sun /* Solaris */
322 { "5601", "EUC-KR" }, 283 { "5601", "EUC-KR" },
323 { "646", "ASCII" }, 284 { "646", "ASCII" },
@@ -380,7 +341,7 @@ static const struct table_entry alias_table[] =
380# if defined OS2 /* OS/2 */ 341# if defined OS2 /* OS/2 */
381 /* The list of encodings is taken from "List of OS/2 Codepages" 342 /* The list of encodings is taken from "List of OS/2 Codepages"
382 by Alex Taylor: 343 by Alex Taylor:
383 <http://altsan.org/os2/toolkits/uls/index.html#codepages>. 344 <https://altsan.org/os2/toolkits/uls/index.html#codepages>.
384 See also "__convcp() of kLIBC": 345 See also "__convcp() of kLIBC":
385 <https://github.com/bitwiseworks/libc/blob/master/src/emx/src/lib/locale/__convcp.c>. */ 346 <https://github.com/bitwiseworks/libc/blob/master/src/emx/src/lib/locale/__convcp.c>. */
386 { "CP1004", "CP1252" }, 347 { "CP1004", "CP1252" },
@@ -850,12 +811,11 @@ locale_charset (void)
850 /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always 811 /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
851 returns "US-ASCII". Return the suffix of the locale name from the 812 returns "US-ASCII". Return the suffix of the locale name from the
852 environment variables (if present) or the codepage as a number. */ 813 environment variables (if present) or the codepage as a number. */
853 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) 814 if (codeset != NULL && streq (codeset, "US-ASCII"))
854 { 815 {
855 const char *locale;
856 static char resultbuf[2 + 10 + 1]; 816 static char resultbuf[2 + 10 + 1];
857 817
858 locale = getenv ("LC_ALL"); 818 const char *locale = getenv ("LC_ALL");
859 if (locale == NULL || locale[0] == '\0') 819 if (locale == NULL || locale[0] == '\0')
860 { 820 {
861 locale = getenv ("LC_CTYPE"); 821 locale = getenv ("LC_CTYPE");
@@ -939,8 +899,9 @@ locale_charset (void)
939 sprintf (buf, "CP%u", GetACP ()); 899 sprintf (buf, "CP%u", GetACP ());
940 } 900 }
941 /* For a locale name such as "French_France.65001", in Windows 10, 901 /* For a locale name such as "French_France.65001", in Windows 10,
942 setlocale now returns "French_France.utf8" instead. */ 902 setlocale now returns "French_France.utf8" instead, or in the UTF-8
943 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) 903 environment (with modern system settings) "fr_FR.UTF-8". */
904 if (streq (buf + 2, "65001") || streq (buf + 2, "utf8") || streq (buf + 2, "UTF-8"))
944 codeset = "UTF-8"; 905 codeset = "UTF-8";
945 else 906 else
946 { 907 {
@@ -950,16 +911,13 @@ locale_charset (void)
950 911
951# elif defined OS2 912# elif defined OS2
952 913
953 const char *locale;
954 static char resultbuf[2 + 10 + 1]; 914 static char resultbuf[2 + 10 + 1];
955 ULONG cp[3];
956 ULONG cplen;
957 915
958 codeset = NULL; 916 codeset = NULL;
959 917
960 /* Allow user to override the codeset, as set in the operating system, 918 /* Allow user to override the codeset, as set in the operating system,
961 with standard language environment variables. */ 919 with standard language environment variables. */
962 locale = getenv ("LC_ALL"); 920 const char *locale = getenv ("LC_ALL");
963 if (locale == NULL || locale[0] == '\0') 921 if (locale == NULL || locale[0] == '\0')
964 { 922 {
965 locale = getenv ("LC_CTYPE"); 923 locale = getenv ("LC_CTYPE");
@@ -990,12 +948,15 @@ locale_charset (void)
990 } 948 }
991 949
992 /* For the POSIX locale, don't use the system's codepage. */ 950 /* For the POSIX locale, don't use the system's codepage. */
993 if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0) 951 if (streq (locale, "C") || streq (locale, "POSIX"))
994 codeset = ""; 952 codeset = "";
995 } 953 }
996 954
997 if (codeset == NULL) 955 if (codeset == NULL)
998 { 956 {
957 ULONG cp[3];
958 ULONG cplen;
959
999 /* OS/2 has a function returning the locale's codepage as a number. */ 960 /* OS/2 has a function returning the locale's codepage as a number. */
1000 if (DosQueryCp (sizeof (cp), cp, &cplen)) 961 if (DosQueryCp (sizeof (cp), cp, &cplen))
1001 codeset = ""; 962 codeset = "";
@@ -1022,7 +983,7 @@ locale_charset (void)
1022 Speed up the common case and slow down the less common cases by 983 Speed up the common case and slow down the less common cases by
1023 testing for this case first. */ 984 testing for this case first. */
1024# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__ 985# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
1025 if (strcmp (codeset, "UTF-8") == 0) 986 if (streq (codeset, "UTF-8"))
1026 goto done_table_lookup; 987 goto done_table_lookup;
1027 else 988 else
1028# endif 989# endif
@@ -1054,7 +1015,7 @@ locale_charset (void)
1054 } 1015 }
1055 } 1016 }
1056 if (0) 1017 if (0)
1057 done_table_lookup: ; 1018 done_table_lookup: {}
1058 else 1019 else
1059# endif 1020# endif
1060 { 1021 {
@@ -1151,7 +1112,7 @@ locale_charset (void)
1151#ifdef DARWIN7 1112#ifdef DARWIN7
1152 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" 1113 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
1153 (the default codeset) does not work when MB_CUR_MAX is 1. */ 1114 (the default codeset) does not work when MB_CUR_MAX is 1. */
1154 if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1) 1115 if (streq (codeset, "UTF-8") && MB_CUR_MAX_L (uselocale (NULL)) <= 1)
1155 codeset = "ASCII"; 1116 codeset = "ASCII";
1156#endif 1117#endif
1157 1118
diff --git a/gl/localcharset.h b/gl/localcharset.h
index 29ee8dc0..59f748d7 100644
--- a/gl/localcharset.h
+++ b/gl/localcharset.h
@@ -1,5 +1,5 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 Copyright (C) 2000-2003, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2000-2003, 2009-2026 Free Software Foundation, Inc.
3 This file is part of the GNU CHARSET Library. 3 This file is part of the GNU CHARSET Library.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -48,24 +48,24 @@ extern const char * locale_charset (void);
48 (darwin = Mac OS X, windows = native Windows) 48 (darwin = Mac OS X, windows = native Windows)
49 49
50 ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin 50 ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
51 ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos 51 ISO-8859-1 Y glibc aix hpux solaris freebsd netbsd openbsd darwin cygwin zos
52 ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos 52 ISO-8859-2 Y glibc aix hpux solaris freebsd netbsd openbsd darwin cygwin zos
53 ISO-8859-3 Y glibc solaris cygwin 53 ISO-8859-3 Y glibc solaris cygwin
54 ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin 54 ISO-8859-4 Y hpux solaris freebsd netbsd openbsd darwin
55 ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos 55 ISO-8859-5 Y glibc aix hpux solaris freebsd netbsd openbsd darwin cygwin zos
56 ISO-8859-6 Y glibc aix hpux solaris cygwin 56 ISO-8859-6 Y glibc aix hpux solaris cygwin
57 ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos 57 ISO-8859-7 Y glibc aix hpux solaris freebsd netbsd openbsd darwin cygwin zos
58 ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos 58 ISO-8859-8 Y glibc aix hpux solaris cygwin zos
59 ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos 59 ISO-8859-9 Y glibc aix hpux solaris freebsd darwin cygwin zos
60 ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin 60 ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
61 ISO-8859-14 glibc cygwin 61 ISO-8859-14 glibc cygwin
62 ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin 62 ISO-8859-15 glibc aix solaris freebsd netbsd openbsd darwin cygwin
63 KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin 63 KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
64 KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin 64 KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
65 KOI8-T glibc 65 KOI8-T glibc
66 CP437 dos 66 CP437 dos
67 CP775 dos 67 CP775 dos
68 CP850 aix osf dos 68 CP850 aix dos
69 CP852 dos 69 CP852 dos
70 CP855 dos 70 CP855 dos
71 CP856 aix 71 CP856 aix
@@ -80,7 +80,7 @@ extern const char * locale_charset (void);
80 CP922 aix 80 CP922 aix
81 CP932 aix cygwin windows dos 81 CP932 aix cygwin windows dos
82 CP943 aix zos 82 CP943 aix zos
83 CP949 osf darwin windows dos 83 CP949 darwin windows dos
84 CP950 windows dos 84 CP950 windows dos
85 CP1046 aix 85 CP1046 aix
86 CP1124 aix 86 CP1124 aix
@@ -95,19 +95,17 @@ extern const char * locale_charset (void);
95 CP1255 glibc windows 95 CP1255 glibc windows
96 CP1256 windows 96 CP1256 windows
97 CP1257 windows 97 CP1257 windows
98 GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos 98 GB2312 Y glibc aix hpux solaris freebsd netbsd darwin cygwin zos
99 EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin 99 EUC-JP Y glibc aix hpux solaris freebsd netbsd darwin cygwin
100 EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos 100 EUC-KR Y glibc aix hpux solaris freebsd netbsd darwin cygwin zos
101 EUC-TW glibc aix hpux irix osf solaris netbsd 101 EUC-TW glibc aix hpux solaris netbsd
102 BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos 102 BIG5 Y glibc aix hpux solaris freebsd netbsd darwin cygwin zos
103 BIG5-HKSCS glibc hpux solaris netbsd darwin 103 BIG5-HKSCS glibc hpux solaris netbsd darwin
104 GBK glibc aix osf solaris freebsd darwin cygwin windows dos 104 GBK glibc aix solaris freebsd darwin cygwin windows dos
105 GB18030 glibc hpux solaris freebsd netbsd darwin 105 GB18030 glibc hpux solaris freebsd netbsd darwin
106 SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin 106 SHIFT_JIS Y hpux solaris freebsd netbsd darwin
107 JOHAB glibc solaris windows 107 JOHAB solaris windows
108 TIS-620 glibc aix hpux osf solaris cygwin zos 108 TIS-620 glibc aix hpux solaris cygwin zos
109 VISCII Y glibc
110 TCVN5712-1 glibc
111 ARMSCII-8 glibc freebsd netbsd darwin 109 ARMSCII-8 glibc freebsd netbsd darwin
112 GEORGIAN-PS glibc cygwin 110 GEORGIAN-PS glibc cygwin
113 PT154 glibc netbsd cygwin 111 PT154 glibc netbsd cygwin
@@ -117,9 +115,9 @@ extern const char * locale_charset (void);
117 HP-HEBREW8 hpux 115 HP-HEBREW8 hpux
118 HP-TURKISH8 hpux 116 HP-TURKISH8 hpux
119 HP-KANA8 hpux 117 HP-KANA8 hpux
120 DEC-KANJI osf 118 DEC-KANJI vms
121 DEC-HANYU osf 119 DEC-HANYU vms
122 UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos 120 UTF-8 Y glibc aix hpux solaris netbsd darwin cygwin zos
123 121
124 Note: Names which are not marked as being a MIME name should not be used in 122 Note: Names which are not marked as being a MIME name should not be used in
125 Internet protocols for information interchange (mail, news, etc.). 123 Internet protocols for information interchange (mail, news, etc.).
diff --git a/gl/locale.in.h b/gl/locale.in.h
index 538b8341..c264493e 100644
--- a/gl/locale.in.h
+++ b/gl/locale.in.h
@@ -1,5 +1,5 @@
1/* A POSIX <locale.h>. 1/* A POSIX <locale.h>.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -20,7 +20,7 @@
20@PRAGMA_COLUMNS@ 20@PRAGMA_COLUMNS@
21 21
22#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \ 22#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
23 || defined _GL_ALREADY_INCLUDING_LOCALE_H 23 || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H
24 24
25/* Special invocation convention: 25/* Special invocation convention:
26 - Inside mingw header files, 26 - Inside mingw header files,
@@ -34,16 +34,21 @@
34 34
35#ifndef _@GUARD_PREFIX@_LOCALE_H 35#ifndef _@GUARD_PREFIX@_LOCALE_H
36 36
37#define _GL_ALREADY_INCLUDING_LOCALE_H 37#define _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H
38 38
39/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
40#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ 40#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
41 41
42#undef _GL_ALREADY_INCLUDING_LOCALE_H 42#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H
43 43
44#ifndef _@GUARD_PREFIX@_LOCALE_H 44#ifndef _@GUARD_PREFIX@_LOCALE_H
45#define _@GUARD_PREFIX@_LOCALE_H 45#define _@GUARD_PREFIX@_LOCALE_H
46 46
47/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
48#if !_GL_CONFIG_H_INCLUDED
49 #error "Please include config.h first."
50#endif
51
47/* NetBSD 5.0 mis-defines NULL. */ 52/* NetBSD 5.0 mis-defines NULL. */
48#include <stddef.h> 53#include <stddef.h>
49 54
@@ -64,6 +69,85 @@
64# define LC_MESSAGES 1729 69# define LC_MESSAGES 1729
65#endif 70#endif
66 71
72#if !@HAVE_LOCALE_T@
73# if !defined GNULIB_defined_locale_t
74/* The values of the POSIX-standardized LC_* macros are:
75
76 LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
77
78 glibc, Solaris, 3 0 5 4 1 2
79 Android
80 macOS, *BSD 1 2 6 3 4 5
81 native Windows 1 2 1729 3 4 5
82
83 We map these to the log2(LC_*_MASK) values, chosen to be compatible with
84 later releases of the same operating system. */
85# if defined __APPLE__ && defined __MACH__ /* macOS */
86/* LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
87
88 category 1 2 6 3 4 5
89 log2(LC_*_MASK) 0 1 2 3 4 5
90 */
91# define gl_log2_lc_mask(category) ((0x2543100 >> (4 * (category))) & 0xf)
92# elif defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
93/* LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
94
95 category 1 2 6 3 4 5
96 log2(LC_*_MASK) 0 1 5 2 3 4
97 */
98# define gl_log2_lc_mask(category) ((category) - 1)
99# elif defined _WIN32 && !defined __CYGWIN__ /* native Windows */
100# define gl_log2_lc_mask(category) \
101 ((category) == LC_MESSAGES ? 0 : (category))
102# else /* glibc, Solaris, Android, NetBSD, OpenBSD */
103# define gl_log2_lc_mask(category) (category)
104# endif
105/* From there we map them to array indices 0..5. */
106# if (gl_log2_lc_mask (LC_COLLATE) == 0 || gl_log2_lc_mask (LC_CTYPE) == 0 \
107 || gl_log2_lc_mask (LC_MESSAGES) == 0)
108 /* glibc, Solaris, Android, macOS, FreeBSD, native Windows */
109# define gl_log2_lcmask_to_index(c) (c)
110# define gl_index_to_log2_lcmask(i) (i)
111# else
112 /* NetBSD, OpenBSD */
113# define gl_log2_lcmask_to_index(c) ((c) - 1)
114# define gl_index_to_log2_lcmask(i) ((i) + 1)
115# endif
116/* Define the LC_*_MASK macros. */
117# define LC_COLLATE_MASK (1 << gl_log2_lc_mask (LC_COLLATE))
118# define LC_CTYPE_MASK (1 << gl_log2_lc_mask (LC_CTYPE))
119# define LC_MESSAGES_MASK (1 << gl_log2_lc_mask (LC_MESSAGES))
120# define LC_MONETARY_MASK (1 << gl_log2_lc_mask (LC_MONETARY))
121# define LC_NUMERIC_MASK (1 << gl_log2_lc_mask (LC_NUMERIC))
122# define LC_TIME_MASK (1 << gl_log2_lc_mask (LC_TIME))
123# define LC_ALL_MASK \
124 (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK \
125 | LC_NUMERIC_MASK | LC_TIME_MASK)
126/* Now define the locale_t type. */
127struct gl_locale_category_t
128{
129 char *name;
130 bool is_c_locale;
131# if @HAVE_WINDOWS_LOCALE_T@
132 /* Use the native Windows '_locale_t' type.
133 Documentation:
134 <https://learn.microsoft.com/en-us/cpp/c-runtime-library/locale>
135 This field is NULL if is_c_locale is true. But don't use this NULL value,
136 since for the native Windows *_l functions a null _locale_t means to use
137 the global locale. */
138 _locale_t system_locale;
139# endif
140};
141struct gl_locale_t
142{
143 struct gl_locale_category_t category[6];
144};
145typedef struct gl_locale_t *locale_t;
146# define LC_GLOBAL_LOCALE ((locale_t)(-1))
147# define GNULIB_defined_locale_t 1
148# endif
149#endif
150
67/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and 151/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
68 int_n_*. Instead of overriding 'struct lconv', merely define these member 152 int_n_*. Instead of overriding 'struct lconv', merely define these member
69 names as macros. This avoids trouble in C++ mode. */ 153 names as macros. This avoids trouble in C++ mode. */
@@ -78,7 +162,8 @@
78 162
79/* Bionic libc's 'struct lconv' is just a dummy. */ 163/* Bionic libc's 'struct lconv' is just a dummy. */
80#if @REPLACE_STRUCT_LCONV@ 164#if @REPLACE_STRUCT_LCONV@
81# define lconv rpl_lconv 165# if !defined GNULIB_defined_struct_lconv
166# define lconv rpl_lconv
82struct lconv 167struct lconv
83{ 168{
84 /* All 'char *' are actually 'const char *'. */ 169 /* All 'char *' are actually 'const char *'. */
@@ -155,6 +240,8 @@ struct lconv
155 number. */ 240 number. */
156 char int_n_sep_by_space; 241 char int_n_sep_by_space;
157}; 242};
243# define GNULIB_defined_struct_lconv 1
244# endif
158#endif 245#endif
159 246
160#if @GNULIB_LOCALECONV@ 247#if @GNULIB_LOCALECONV@
@@ -163,7 +250,7 @@ struct lconv
163# undef localeconv 250# undef localeconv
164# define localeconv rpl_localeconv 251# define localeconv rpl_localeconv
165# endif 252# endif
166_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void)); 253_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void), );
167_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void)); 254_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
168# else 255# else
169_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void)); 256_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
@@ -172,10 +259,11 @@ _GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
172_GL_CXXALIASWARN (localeconv); 259_GL_CXXALIASWARN (localeconv);
173# endif 260# endif
174#elif @REPLACE_STRUCT_LCONV@ 261#elif @REPLACE_STRUCT_LCONV@
175# undef localeconv 262# if !GNULIB_LOCALECONV
176# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv 263# undef localeconv
264# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
265# endif
177#elif defined GNULIB_POSIXCHECK 266#elif defined GNULIB_POSIXCHECK
178# undef localeconv
179# if HAVE_RAW_DECL_LOCALECONV 267# if HAVE_RAW_DECL_LOCALECONV
180_GL_WARN_ON_USE (localeconv, 268_GL_WARN_ON_USE (localeconv,
181 "localeconv returns too few information on some platforms - " 269 "localeconv returns too few information on some platforms - "
@@ -190,7 +278,7 @@ _GL_WARN_ON_USE (localeconv,
190# define setlocale rpl_setlocale 278# define setlocale rpl_setlocale
191# define GNULIB_defined_setlocale 1 279# define GNULIB_defined_setlocale 1
192# endif 280# endif
193_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale)); 281_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale), );
194_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale)); 282_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
195# else 283# else
196_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale)); 284_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
@@ -199,7 +287,6 @@ _GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
199_GL_CXXALIASWARN (setlocale); 287_GL_CXXALIASWARN (setlocale);
200# endif 288# endif
201#elif defined GNULIB_POSIXCHECK 289#elif defined GNULIB_POSIXCHECK
202# undef setlocale
203# if HAVE_RAW_DECL_SETLOCALE 290# if HAVE_RAW_DECL_SETLOCALE
204_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - " 291_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
205 "use gnulib module setlocale for portability"); 292 "use gnulib module setlocale for portability");
@@ -211,7 +298,7 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
211# include "setlocale_null.h" 298# include "setlocale_null.h"
212#endif 299#endif
213 300
214#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@) 301#if @GNULIB_NEWLOCALE@ || (@GNULIB_GETLOCALENAME_L_UNSAFE@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@)
215# if @REPLACE_NEWLOCALE@ 302# if @REPLACE_NEWLOCALE@
216# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 303# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
217# undef newlocale 304# undef newlocale
@@ -219,87 +306,108 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
219# define GNULIB_defined_newlocale 1 306# define GNULIB_defined_newlocale 1
220# endif 307# endif
221_GL_FUNCDECL_RPL (newlocale, locale_t, 308_GL_FUNCDECL_RPL (newlocale, locale_t,
222 (int category_mask, const char *name, locale_t base) 309 (int category_mask, const char *name, locale_t base),
223 _GL_ARG_NONNULL ((2))); 310 _GL_ARG_NONNULL ((2)));
224_GL_CXXALIAS_RPL (newlocale, locale_t, 311_GL_CXXALIAS_RPL (newlocale, locale_t,
225 (int category_mask, const char *name, locale_t base)); 312 (int category_mask, const char *name, locale_t base));
226# else 313# else
227# if @HAVE_NEWLOCALE@ 314# if !@HAVE_NEWLOCALE@
315_GL_FUNCDECL_SYS (newlocale, locale_t,
316 (int category_mask, const char *name, locale_t base),
317 _GL_ARG_NONNULL ((2)));
318# endif
228_GL_CXXALIAS_SYS (newlocale, locale_t, 319_GL_CXXALIAS_SYS (newlocale, locale_t,
229 (int category_mask, const char *name, locale_t base)); 320 (int category_mask, const char *name, locale_t base));
230# endif
231# endif 321# endif
232# if @HAVE_NEWLOCALE@ 322# if __GLIBC__ >= 2
233_GL_CXXALIASWARN (newlocale); 323_GL_CXXALIASWARN (newlocale);
234# endif 324# endif
235# if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
236# ifndef HAVE_WORKING_NEWLOCALE
237# define HAVE_WORKING_NEWLOCALE 1
238# endif
239# endif
240#elif defined GNULIB_POSIXCHECK 325#elif defined GNULIB_POSIXCHECK
241# undef newlocale
242# if HAVE_RAW_DECL_NEWLOCALE 326# if HAVE_RAW_DECL_NEWLOCALE
243_GL_WARN_ON_USE (newlocale, "newlocale is not portable"); 327_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
244# endif 328# endif
245#endif 329#endif
246 330
247#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@) 331#if @GNULIB_DUPLOCALE@ || (@GNULIB_GETLOCALENAME_L_UNSAFE@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@)
248# if @REPLACE_DUPLOCALE@ 332# if @REPLACE_DUPLOCALE@
249# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 333# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
250# undef duplocale 334# undef duplocale
251# define duplocale rpl_duplocale 335# define duplocale rpl_duplocale
252# define GNULIB_defined_duplocale 1 336# define GNULIB_defined_duplocale 1
253# endif 337# endif
254_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); 338_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale), _GL_ARG_NONNULL ((1)));
255_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); 339_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
256# else 340# else
257# if @HAVE_DUPLOCALE@ 341# if !@HAVE_DUPLOCALE@
258_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); 342_GL_FUNCDECL_SYS (duplocale, locale_t, (locale_t locale), _GL_ARG_NONNULL ((1)));
259# endif 343# endif
344_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
260# endif 345# endif
261# if @HAVE_DUPLOCALE@ 346# if __GLIBC__ >= 2
262_GL_CXXALIASWARN (duplocale); 347_GL_CXXALIASWARN (duplocale);
263# endif 348# endif
264# if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
265# ifndef HAVE_WORKING_DUPLOCALE
266# define HAVE_WORKING_DUPLOCALE 1
267# endif
268# endif
269#elif defined GNULIB_POSIXCHECK 349#elif defined GNULIB_POSIXCHECK
270# undef duplocale
271# if HAVE_RAW_DECL_DUPLOCALE 350# if HAVE_RAW_DECL_DUPLOCALE
272_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - " 351_GL_WARN_ON_USE (duplocale, "duplocale is unportable and buggy on some glibc systems - "
273 "use gnulib module duplocale for portability"); 352 "use gnulib module duplocale for portability");
274# endif 353# endif
275#endif 354#endif
276 355
277#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@) 356#if @GNULIB_FREELOCALE@ || (@GNULIB_GETLOCALENAME_L_UNSAFE@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@)
278# if @REPLACE_FREELOCALE@ 357# if @REPLACE_FREELOCALE@
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 358# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# undef freelocale 359# undef freelocale
281# define freelocale rpl_freelocale 360# define freelocale rpl_freelocale
282# define GNULIB_defined_freelocale 1 361# define GNULIB_defined_freelocale 1
283# endif 362# endif
284_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1))); 363_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale), _GL_ARG_NONNULL ((1)));
285_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale)); 364_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
286# else 365# else
287# if @HAVE_FREELOCALE@ 366# if !@HAVE_FREELOCALE@
367_GL_FUNCDECL_SYS (freelocale, void, (locale_t locale), _GL_ARG_NONNULL ((1)));
368# endif
288/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is 369/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
289 int. */ 370 int. */
290_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale)); 371_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
291# endif
292# endif 372# endif
293# if @HAVE_FREELOCALE@ 373# if __GLIBC__ >= 2
294_GL_CXXALIASWARN (freelocale); 374_GL_CXXALIASWARN (freelocale);
295# endif 375# endif
296#elif defined GNULIB_POSIXCHECK 376#elif defined GNULIB_POSIXCHECK
297# undef freelocale
298# if HAVE_RAW_DECL_FREELOCALE 377# if HAVE_RAW_DECL_FREELOCALE
299_GL_WARN_ON_USE (freelocale, "freelocale is not portable"); 378_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
300# endif 379# endif
301#endif 380#endif
302 381
382#if @GNULIB_GETLOCALENAME_L@
383# if @REPLACE_GETLOCALENAME_L@
384# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
385# undef getlocalename_l
386# define getlocalename_l rpl_getlocalename_l
387# endif
388_GL_FUNCDECL_RPL (getlocalename_l, const char *,
389 (int category, locale_t locale),
390 _GL_ARG_NONNULL ((2)));
391_GL_CXXALIAS_RPL (getlocalename_l, const char *,
392 (int category, locale_t locale));
393# else
394# if !@HAVE_GETLOCALENAME_L@
395_GL_FUNCDECL_SYS (getlocalename_l, const char *,
396 (int category, locale_t locale),
397 _GL_ARG_NONNULL ((2)));
398# endif
399_GL_CXXALIAS_SYS (getlocalename_l, const char *,
400 (int category, locale_t locale));
401# endif
402# if __GLIBC__ >= 2
403_GL_CXXALIASWARN (getlocalename_l);
404# endif
405#elif defined GNULIB_POSIXCHECK
406# if HAVE_RAW_DECL_GETLOCALENAME_L
407_GL_WARN_ON_USE (getlocalename_l, "getlocalename_l is not portable");
408# endif
409#endif
410
303#endif /* _@GUARD_PREFIX@_LOCALE_H */ 411#endif /* _@GUARD_PREFIX@_LOCALE_H */
304#endif /* _@GUARD_PREFIX@_LOCALE_H */ 412#endif /* _@GUARD_PREFIX@_LOCALE_H */
305#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */ 413#endif /* !(__need_locale_t || _@GUARD_PREFIX@_ALREADY_INCLUDING_LOCALE_H) */
diff --git a/gl/localeconv.c b/gl/localeconv.c
index 60c050f4..bf6271ee 100644
--- a/gl/localeconv.c
+++ b/gl/localeconv.c
@@ -1,5 +1,5 @@
1/* Query locale dependent information for formatting numbers. 1/* Query locale dependent information for formatting numbers.
2 Copyright (C) 2012-2023 Free Software Foundation, Inc. 2 Copyright (C) 2012-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -19,10 +19,14 @@
19/* Specification. */ 19/* Specification. */
20#include <locale.h> 20#include <locale.h>
21 21
22#include <limits.h>
23
22#if HAVE_STRUCT_LCONV_DECIMAL_POINT 24#if HAVE_STRUCT_LCONV_DECIMAL_POINT
23 25
26# define FIX_CHAR_VALUE(x) ((x) >= 0 ? (x) : CHAR_MAX)
27
24/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_* 28/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
25 members. */ 29 members or where fields of type 'char' are set to -1 instead of CHAR_MAX. */
26 30
27struct lconv * 31struct lconv *
28localeconv (void) 32localeconv (void)
@@ -41,21 +45,30 @@ localeconv (void)
41 result.positive_sign = sys_result->positive_sign; 45 result.positive_sign = sys_result->positive_sign;
42 result.negative_sign = sys_result->negative_sign; 46 result.negative_sign = sys_result->negative_sign;
43 result.currency_symbol = sys_result->currency_symbol; 47 result.currency_symbol = sys_result->currency_symbol;
44 result.frac_digits = sys_result->frac_digits; 48 result.frac_digits = FIX_CHAR_VALUE (sys_result->frac_digits);
45 result.p_cs_precedes = sys_result->p_cs_precedes; 49 result.p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes);
46 result.p_sign_posn = sys_result->p_sign_posn; 50 result.p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn);
47 result.p_sep_by_space = sys_result->p_sep_by_space; 51 result.p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space);
48 result.n_cs_precedes = sys_result->n_cs_precedes; 52 result.n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes);
49 result.n_sign_posn = sys_result->n_sign_posn; 53 result.n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn);
50 result.n_sep_by_space = sys_result->n_sep_by_space; 54 result.n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space);
51 result.int_curr_symbol = sys_result->int_curr_symbol; 55 result.int_curr_symbol = sys_result->int_curr_symbol;
52 result.int_frac_digits = sys_result->int_frac_digits; 56 result.int_frac_digits = FIX_CHAR_VALUE (sys_result->int_frac_digits);
53 result.int_p_cs_precedes = sys_result->p_cs_precedes; 57# if HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES
54 result.int_p_sign_posn = sys_result->p_sign_posn; 58 result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->int_p_cs_precedes);
55 result.int_p_sep_by_space = sys_result->p_sep_by_space; 59 result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->int_p_sign_posn);
56 result.int_n_cs_precedes = sys_result->n_cs_precedes; 60 result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->int_p_sep_by_space);
57 result.int_n_sign_posn = sys_result->n_sign_posn; 61 result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->int_n_cs_precedes);
58 result.int_n_sep_by_space = sys_result->n_sep_by_space; 62 result.int_n_sign_posn = FIX_CHAR_VALUE (sys_result->int_n_sign_posn);
63 result.int_n_sep_by_space = FIX_CHAR_VALUE (sys_result->int_n_sep_by_space);
64# else
65 result.int_p_cs_precedes = FIX_CHAR_VALUE (sys_result->p_cs_precedes);
66 result.int_p_sign_posn = FIX_CHAR_VALUE (sys_result->p_sign_posn);
67 result.int_p_sep_by_space = FIX_CHAR_VALUE (sys_result->p_sep_by_space);
68 result.int_n_cs_precedes = FIX_CHAR_VALUE (sys_result->n_cs_precedes);
69 result.int_n_sign_posn = FIX_CHAR_VALUE (sys_result->n_sign_posn);
70 result.int_n_sep_by_space = FIX_CHAR_VALUE (sys_result->n_sep_by_space);
71# endif
59 72
60 return &result; 73 return &result;
61} 74}
@@ -64,8 +77,6 @@ localeconv (void)
64 77
65/* Override for platforms where 'struct lconv' is a dummy. */ 78/* Override for platforms where 'struct lconv' is a dummy. */
66 79
67# include <limits.h>
68
69struct lconv * 80struct lconv *
70localeconv (void) 81localeconv (void)
71{ 82{
diff --git a/gl/lseek.c b/gl/lseek.c
index 7919b03c..7478ea13 100644
--- a/gl/lseek.c
+++ b/gl/lseek.c
@@ -1,5 +1,5 @@
1/* An lseek() function that detects pipes. 1/* An lseek() function that detects pipes.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/lstat.c b/gl/lstat.c
new file mode 100644
index 00000000..2495568f
--- /dev/null
+++ b/gl/lstat.c
@@ -0,0 +1,97 @@
1/* Work around a bug of lstat on some systems
2
3 Copyright (C) 1997-2006, 2008-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Jim Meyering */
19
20/* If the user's config.h happens to include <sys/stat.h>, let it include only
21 the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
22 rpl_lstat. */
23#define __need_system_sys_stat_h
24#include <config.h>
25
26#if !HAVE_LSTAT
27/* On systems that lack symlinks, our replacement <sys/stat.h> already
28 defined lstat as stat, so there is nothing further to do other than
29 avoid an empty file. */
30typedef int dummy;
31#else /* HAVE_LSTAT */
32
33/* Get the original definition of lstat. It might be defined as a macro. */
34# include <sys/types.h>
35# include <sys/stat.h>
36# undef __need_system_sys_stat_h
37
38static int
39orig_lstat (const char *filename, struct stat *buf)
40{
41 return lstat (filename, buf);
42}
43
44/* Specification. */
45# include <sys/stat.h>
46
47# include "stat-time.h"
48
49# include <string.h>
50# include <errno.h>
51
52/* lstat works differently on Linux and Solaris systems. POSIX (see
53 "pathname resolution" in the glossary) requires that programs like
54 'ls' take into consideration the fact that FILE has a trailing slash
55 when FILE is a symbolic link. On Linux and Solaris 10 systems, the
56 lstat function already has the desired semantics (in treating
57 'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)',
58 but on Solaris 9 and earlier it does not.
59
60 If FILE has a trailing slash and specifies a symbolic link,
61 then use stat() to get more info on the referent of FILE.
62 If the referent is a non-directory, then set errno to ENOTDIR
63 and return -1. Otherwise, return stat's result. */
64
65int
66rpl_lstat (const char *file, struct stat *sbuf)
67{
68 int result = orig_lstat (file, sbuf);
69
70 /* This replacement file can blindly check against '/' rather than
71 using the ISSLASH macro, because all platforms with '\\' either
72 lack symlinks (mingw) or have working lstat (cygwin) and thus do
73 not compile this file. 0 len should have already been filtered
74 out above, with a failure return of ENOENT. */
75 if (result == 0)
76 {
77 if (S_ISDIR (sbuf->st_mode) || file[strlen (file) - 1] != '/')
78 result = stat_time_normalize (result, sbuf);
79 else
80 {
81 /* At this point, a trailing slash is permitted only on
82 symlink-to-dir; but it should have found information on the
83 directory, not the symlink. Call 'stat' to get info about the
84 link's referent. Our replacement stat guarantees valid results,
85 even if the symlink is not pointing to a directory. */
86 if (!S_ISLNK (sbuf->st_mode))
87 {
88 errno = ENOTDIR;
89 return -1;
90 }
91 result = stat (file, sbuf);
92 }
93 }
94 return result;
95}
96
97#endif /* HAVE_LSTAT */
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4
index 7fe03e0b..a4b32403 100644
--- a/gl/m4/00gnulib.m4
+++ b/gl/m4/00gnulib.m4
@@ -1,8 +1,10 @@
1# 00gnulib.m4 serial 8 1# 00gnulib.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 9
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl This file must be named something that sorts before all other 9dnl This file must be named something that sorts before all other
8dnl gnulib-provided .m4 files. It is needed until the clang fix has 10dnl gnulib-provided .m4 files. It is needed until the clang fix has
@@ -49,14 +51,14 @@ dnl AC_REQUIRE([gl_COMPILER_CLANG])
49 [if test $gl_cv_compiler_clang = yes; then 51 [if test $gl_cv_compiler_clang = yes; then
50 dnl Test whether the compiler supports the option 52 dnl Test whether the compiler supports the option
51 dnl '-Werror=implicit-function-declaration'. 53 dnl '-Werror=implicit-function-declaration'.
52 save_ac_compile="$ac_compile" 54 saved_ac_compile="$ac_compile"
53 ac_compile="$ac_compile -Werror=implicit-function-declaration" 55 ac_compile="$ac_compile -Werror=implicit-function-declaration"
54 dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a 56 dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a
55 dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". 57 dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
56 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])], 58 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
57 [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'], 59 [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'],
58 [gl_cv_compiler_check_decl_option=none]) 60 [gl_cv_compiler_check_decl_option=none])
59 ac_compile="$save_ac_compile" 61 ac_compile="$saved_ac_compile"
60 else 62 else
61 gl_cv_compiler_check_decl_option=none 63 gl_cv_compiler_check_decl_option=none
62 fi 64 fi
@@ -71,11 +73,11 @@ dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl
71dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC 73dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC
72dnl in zzgnulib.m4 is inactive, use the original ac_compile. 74dnl in zzgnulib.m4 is inactive, use the original ac_compile.
73m4_define([_AC_CHECK_DECL_BODY], 75m4_define([_AC_CHECK_DECL_BODY],
74[ ac_save_ac_compile="$ac_compile" 76[ ac_saved_ac_compile="$ac_compile"
75 if test -n "$ac_compile_for_check_decl"; then 77 if test -n "$ac_compile_for_check_decl"; then
76 ac_compile="$ac_compile_for_check_decl" 78 ac_compile="$ac_compile_for_check_decl"
77 fi] 79 fi]
78m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile" 80m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_saved_ac_compile"
79]) 81])
80 82
81# gl_00GNULIB 83# gl_00GNULIB
diff --git a/gl/m4/__inline.m4 b/gl/m4/__inline.m4
index acf8668b..4dedc0d4 100644
--- a/gl/m4/__inline.m4
+++ b/gl/m4/__inline.m4
@@ -1,8 +1,12 @@
1# Test for __inline keyword 1# __inline.m4
2dnl Copyright 2017-2023 Free Software Foundation, Inc. 2# serial 1
3dnl Copyright 2017-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# Test for __inline keyword
6 10
7AC_DEFUN([gl___INLINE], 11AC_DEFUN([gl___INLINE],
8[ 12[
diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4
index e7947648..94ecc510 100644
--- a/gl/m4/absolute-header.m4
+++ b/gl/m4/absolute-header.m4
@@ -1,8 +1,10 @@
1# absolute-header.m4 serial 17 1# absolute-header.m4
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 2# serial 18
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Derek Price. 9dnl From Derek Price.
8 10
@@ -66,7 +68,7 @@ AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
66 esac 68 esac
67changequote(,) 69changequote(,)
68 case "$host_os" in 70 case "$host_os" in
69 mingw*) 71 mingw* | windows*)
70 dnl For the sake of native Windows compilers (excluding gcc), 72 dnl For the sake of native Windows compilers (excluding gcc),
71 dnl treat backslash as a directory separator, like /. 73 dnl treat backslash as a directory separator, like /.
72 dnl Actually, these compilers use a double-backslash as 74 dnl Actually, these compilers use a double-backslash as
diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4
index f4c0d624..e4ff9a3d 100644
--- a/gl/m4/af_alg.m4
+++ b/gl/m4/af_alg.m4
@@ -1,8 +1,10 @@
1# af_alg.m4 serial 6 1# af_alg.m4
2dnl Copyright 2018-2023 Free Software Foundation, Inc. 2# serial 6
3dnl Copyright 2018-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Matteo Croce. 9dnl From Matteo Croce.
8 10
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index c685fac9..ff0c59dd 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,9 +1,11 @@
1# alloca.m4 serial 21 1# alloca.m4
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2023 Free Software Foundation, 2# serial 21
3dnl Copyright (C) 2002-2004, 2006-2007, 2009-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8AC_DEFUN([gl_FUNC_ALLOCA], 10AC_DEFUN([gl_FUNC_ALLOCA],
9[ 11[
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index fa5fe831..63634c30 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,8 +1,10 @@
1# arpa_inet_h.m4 serial 17 1# arpa_inet_h.m4
2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc. 2# serial 18
3dnl Copyright (C) 2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Written by Simon Josefsson and Bruno Haible 9dnl Written by Simon Josefsson and Bruno Haible
8 10
@@ -67,8 +69,12 @@ AC_DEFUN([gl_ARPA_INET_H_REQUIRE_DEFAULTS],
67AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], 69AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
68[ 70[
69 dnl Assume proper GNU behavior unless another module says otherwise. 71 dnl Assume proper GNU behavior unless another module says otherwise.
72 HAVE_DECL_HTONL=1; AC_SUBST([HAVE_DECL_HTONL])
73 HAVE_DECL_HTONS=1; AC_SUBST([HAVE_DECL_HTONS])
70 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) 74 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
71 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) 75 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
76 HAVE_DECL_NTOHL=1; AC_SUBST([HAVE_DECL_NTOHL])
77 HAVE_DECL_NTOHS=1; AC_SUBST([HAVE_DECL_NTOHS])
72 REPLACE_INET_NTOP=0; AC_SUBST([REPLACE_INET_NTOP]) 78 REPLACE_INET_NTOP=0; AC_SUBST([REPLACE_INET_NTOP])
73 REPLACE_INET_PTON=0; AC_SUBST([REPLACE_INET_PTON]) 79 REPLACE_INET_PTON=0; AC_SUBST([REPLACE_INET_PTON])
74]) 80])
diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4
index abba4fa3..d9433ef7 100644
--- a/gl/m4/assert_h.m4
+++ b/gl/m4/assert_h.m4
@@ -1,40 +1,43 @@
1# assert-h.m4 1# assert_h.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 6
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Paul Eggert. 9dnl From Paul Eggert.
8 10
9AC_DEFUN([gl_ASSERT_H], 11AC_DEFUN([gl_ASSERT_H],
10[ 12[
11 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert], 13 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert],
12 [gl_save_CFLAGS=$CFLAGS 14 [gl_saved_CFLAGS=$CFLAGS
13 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do 15 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do
14 AS_CASE([$gl_working], 16 AS_CASE([$gl_working],
15 [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"]) 17 [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"])
16 18 AC_COMPILE_IFELSE(
17 AC_COMPILE_IFELSE( 19 [AC_LANG_PROGRAM(
18 [AC_LANG_PROGRAM( 20 [[#if defined __clang__ && __STDC_VERSION__ < 202311
19 [[#if defined __clang__ && __STDC_VERSION__ < 202311 21 #pragma clang diagnostic error "-Wc2x-extensions"
20 #pragma clang diagnostic error "-Wc2x-extensions" 22 #pragma clang diagnostic error "-Wc++1z-extensions"
21 #pragma clang diagnostic error "-Wc++17-extensions" 23 #endif
22 #endif 24 #ifdef INCLUDE_ASSERT_H
23 #ifdef INCLUDE_ASSERT_H 25 #include <assert.h>
24 #include <assert.h> 26 #endif
25 #endif 27 static_assert (2 + 2 == 4, "arithmetic does not work");
26 static_assert (2 + 2 == 4, "arithmetic does not work"); 28 static_assert (2 + 2 == 4);
27 static_assert (2 + 2 == 4); 29 ]],
28 ]], 30 [[
29 [[ 31 static_assert (sizeof (char) == 1, "sizeof does not work");
30 static_assert (sizeof (char) == 1, "sizeof does not work"); 32 static_assert (sizeof (char) == 1);
31 static_assert (sizeof (char) == 1); 33 ]])
32 ]])], 34 ],
33 [gl_cv_static_assert=$gl_working], 35 [gl_cv_static_assert=$gl_working],
34 [gl_cv_static_assert=no]) 36 [gl_cv_static_assert=no])
35 CFLAGS=$gl_save_CFLAGS 37 CFLAGS=$gl_saved_CFLAGS
36 test "$gl_cv_static_assert" != no && break 38 test "$gl_cv_static_assert" != no && break
37 done]) 39 done
40 ])
38 41
39 GL_GENERATE_ASSERT_H=false 42 GL_GENERATE_ASSERT_H=false
40 AS_CASE([$gl_cv_static_assert], 43 AS_CASE([$gl_cv_static_assert],
@@ -46,20 +49,37 @@ AC_DEFUN([gl_ASSERT_H],
46 gl_NEXT_HEADERS([assert.h])]) 49 gl_NEXT_HEADERS([assert.h])])
47 50
48 dnl The "zz" puts this toward config.h's end, to avoid potential 51 dnl The "zz" puts this toward config.h's end, to avoid potential
49 dnl collisions with other definitions. #undef assert so that 52 dnl collisions with other definitions.
50 dnl programs are not tempted to use it without specifically 53 dnl Hardcode the known configuration results for GCC and clang, so that
51 dnl including assert.h. Break the #undef apart with a comment 54 dnl a configuration made with the C compiler works also with the C++ compiler
52 dnl so that 'configure' does not comment it out. 55 dnl and vice versa.
56 dnl The seemingly redundant parentheses are necessary for MSVC 14.
57 dnl #undef assert so that programs are not tempted to use it without
58 dnl specifically including assert.h.
59 dnl Break the #undef_s apart with a comment so that 'configure' does
60 dnl not comment them out.
53 AH_VERBATIM([zzstatic_assert], 61 AH_VERBATIM([zzstatic_assert],
54[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ 62[#if (!(defined __clang__ \
63 ? (defined __cplusplus \
64 ? __cplusplus >= 201703L \
65 : __STDC_VERSION__ >= 202000L && __clang_major__ >= 16 \
66 && !defined __sun) \
67 : (defined __GNUC__ \
68 ? (defined __cplusplus \
69 ? __cplusplus >= 201103L && __GNUG__ >= 6 \
70 : __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 \
71 && !defined __sun) \
72 : defined HAVE_C_STATIC_ASSERT)) \
73 && !defined assert \
55 && (!defined __cplusplus \ 74 && (!defined __cplusplus \
56 || (__cpp_static_assert < 201411 \ 75 || (__cpp_static_assert < 201411 \
57 && __GNUG__ < 6 && __clang_major__ < 6))) 76 && __GNUG__ < 6 && __clang_major__ < 6)))
58 #include <assert.h> 77 #include <assert.h>
59 #undef/**/assert 78 #undef/**/assert
60 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments. 79 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
61 We need it also to be invocable with a single argument. */ 80 We need it also to be invocable with a single argument.
62 #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus 81 Haiku 2022 <assert.h> does not define static_assert at all. */
82 #if (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
63 #undef/**/static_assert 83 #undef/**/static_assert
64 #define static_assert _Static_assert 84 #define static_assert _Static_assert
65 #endif 85 #endif
diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4
index 987930ab..40beb50b 100644
--- a/gl/m4/base64.m4
+++ b/gl/m4/base64.m4
@@ -1,8 +1,10 @@
1# base64.m4 serial 4 1# base64.m4
2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc. 2# serial 4
3dnl Copyright (C) 2004, 2006, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_BASE64], 9AC_DEFUN([gl_FUNC_BASE64],
8[ 10[
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
index 77218a7d..93c9d769 100644
--- a/gl/m4/btowc.m4
+++ b/gl/m4/btowc.m4
@@ -1,16 +1,19 @@
1# btowc.m4 serial 12 1# btowc.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 16
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_BTOWC], 9AC_DEFUN([gl_FUNC_BTOWC],
8[ 10[
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 11 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
12 AC_REQUIRE([gt_TYPE_WINT_T])
10 13
11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test 14 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
12 dnl program below may lead to an endless loop. See 15 dnl program below may lead to an endless loop. See
13 dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. 16 dnl <https://gcc.gnu.org/PR42440>.
14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 17 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
15 18
16 AC_CHECK_FUNCS_ONCE([btowc]) 19 AC_CHECK_FUNCS_ONCE([btowc])
@@ -40,66 +43,88 @@ int main ()
40 [ 43 [
41changequote(,)dnl 44changequote(,)dnl
42 case "$host_os" in 45 case "$host_os" in
43 # Guess no on Cygwin. 46 # Guess no on Cygwin.
44 cygwin*) gl_cv_func_btowc_nul="guessing no" ;; 47 cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
45 # Guess yes on native Windows. 48 # Guess yes on native Windows.
46 mingw*) gl_cv_func_btowc_nul="guessing yes" ;; 49 mingw* | windows*) gl_cv_func_btowc_nul="guessing yes" ;;
47 # Guess yes otherwise. 50 # Guess yes otherwise.
48 *) gl_cv_func_btowc_nul="guessing yes" ;; 51 *) gl_cv_func_btowc_nul="guessing yes" ;;
49 esac 52 esac
50changequote([,])dnl 53changequote([,])dnl
51 ]) 54 ])
52 ]) 55 ])
53 56
54 dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF. 57 dnl On mingw, in the C locale, btowc is inconsistent with mbrtowc:
55 AC_CACHE_CHECK([whether btowc(EOF) is correct], 58 dnl mbrtowc avoids calling MultiByteToWideChar when MB_CUR_MAX is 1 and
56 [gl_cv_func_btowc_eof], 59 dnl ___lc_codepage_func() is 0, but btowc is lacking this special case.
60 AC_CHECK_FUNCS_ONCE([mbrtowc])
61 AC_CACHE_CHECK([whether btowc is consistent with mbrtowc in the C locale],
62 [gl_cv_func_btowc_consistent],
57 [ 63 [
58 dnl Initial guess, used when cross-compiling or when no suitable locale 64 AC_RUN_IFELSE(
59 dnl is present. 65 [AC_LANG_SOURCE([[
60changequote(,)dnl 66#include <stdlib.h>
61 case "$host_os" in 67#include <string.h>
62 # Guess no on IRIX.
63 irix*) gl_cv_func_btowc_eof="guessing no" ;;
64 # Guess yes on native Windows.
65 mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
66 # Guess yes otherwise.
67 *) gl_cv_func_btowc_eof="guessing yes" ;;
68 esac
69changequote([,])dnl
70 if test $LOCALE_FR != none; then
71 AC_RUN_IFELSE(
72 [AC_LANG_SOURCE([[
73#include <locale.h>
74#include <stdio.h>
75#include <wchar.h> 68#include <wchar.h>
76int main () 69int main ()
77{ 70{
78 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) 71#if HAVE_MBRTOWC
79 { 72 wint_t wc1 = btowc (0x80);
80 if (btowc (EOF) != WEOF) 73 wchar_t wc2 = (wchar_t) 0xbadface;
81 return 1; 74 char buf[1] = { 0x80 };
82 } 75 mbstate_t state;
76 memset (&state, 0, sizeof (mbstate_t));
77 if (mbrtowc (&wc2, buf, 1, &state) != 1 || wc1 != wc2)
78 return 1;
79#endif
83 return 0; 80 return 0;
84}]])], 81}]])],
85 [gl_cv_func_btowc_eof=yes], 82 [gl_cv_func_btowc_consistent=yes],
86 [gl_cv_func_btowc_eof=no], 83 [gl_cv_func_btowc_consistent=no],
87 [:]) 84 [case "$host_os" in
88 fi 85 # Guess no on mingw.
86 mingw* | windows*)
87 AC_EGREP_CPP([Problem], [
88#ifdef __MINGW32__
89 Problem
90#endif
91 ],
92 [gl_cv_func_btowc_consistent="guessing no"],
93 [gl_cv_func_btowc_consistent="guessing yes"])
94 ;;
95 # Guess yes otherwise.
96 *) gl_cv_func_btowc_consistent="guessing yes" ;;
97 esac
98 ])
89 ]) 99 ])
90 100
101 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
102 dnl On mingw/ucrt, we override the return type of btowc().
103 dnl While the original wint_t (= unsigned short) and the overridden wint_t
104 dnl (= unsigned int) are equivalent in function parameters, this is not
105 dnl the case for function return types.
106 REPLACE_BTOWC=1
107 fi
91 case "$gl_cv_func_btowc_nul" in 108 case "$gl_cv_func_btowc_nul" in
92 *yes) ;; 109 *yes) ;;
93 *) REPLACE_BTOWC=1 ;; 110 *) REPLACE_BTOWC=1 ;;
94 esac 111 esac
95 case "$gl_cv_func_btowc_eof" in 112 case "$gl_cv_func_btowc_consistent" in
96 *yes) ;; 113 *yes) ;;
97 *) REPLACE_BTOWC=1 ;; 114 *) REPLACE_BTOWC=1 ;;
98 esac 115 esac
116 if test $REPLACE_BTOWC = 0; then
117 gl_MBRTOWC_C_LOCALE
118 case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
119 *yes) ;;
120 *) REPLACE_BTOWC=1 ;;
121 esac
122 fi
99 fi 123 fi
100]) 124])
101 125
102# Prerequisites of lib/btowc.c. 126# Prerequisites of lib/btowc.c.
103AC_DEFUN([gl_PREREQ_BTOWC], [ 127AC_DEFUN([gl_PREREQ_BTOWC], [
104 : 128 :
129 AC_CHECK_FUNCS_ONCE([mbrtowc])
105]) 130])
diff --git a/gl/m4/build-to-host.m4 b/gl/m4/build-to-host.m4
new file mode 100644
index 00000000..d3b93ce1
--- /dev/null
+++ b/gl/m4/build-to-host.m4
@@ -0,0 +1,274 @@
1# build-to-host.m4
2# serial 5
3dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Written by Bruno Haible.
10
11dnl When the build environment ($build_os) is different from the target runtime
12dnl environment ($host_os), file names may need to be converted from the build
13dnl environment syntax to the target runtime environment syntax. This is
14dnl because the Makefiles are executed (mostly) by build environment tools and
15dnl therefore expect file names in build environment syntax, whereas the runtime
16dnl expects file names in target runtime environment syntax.
17dnl
18dnl For example, if $build_os = cygwin and $host_os = mingw32, filenames need
19dnl be converted from Cygwin syntax to native Windows syntax:
20dnl /cygdrive/c/foo/bar -> C:\foo\bar
21dnl /usr/local/share -> C:\cygwin64\usr\local\share
22dnl
23dnl gl_BUILD_TO_HOST([somedir])
24dnl This macro takes as input an AC_SUBSTed variable 'somedir', which must
25dnl already have its final value assigned, and produces two additional
26dnl AC_SUBSTed variables 'somedir_c' and 'somedir_c_make', that designate the
27dnl same file name value, just in different syntax:
28dnl - somedir_c is the file name in target runtime environment syntax,
29dnl as a C string (starting and ending with a double-quote,
30dnl and with escaped backslashes and double-quotes in
31dnl between).
32dnl - somedir_c_make is the same thing, escaped for use in a Makefile.
33
34AC_DEFUN([gl_BUILD_TO_HOST],
35[
36 AC_REQUIRE([AC_CANONICAL_BUILD])
37 AC_REQUIRE([AC_CANONICAL_HOST])
38 AC_REQUIRE([gl_BUILD_TO_HOST_INIT])
39
40 dnl Define somedir_c.
41 gl_final_[$1]="$[$1]"
42 dnl Translate it from build syntax to host syntax.
43 case "$build_os" in
44 cygwin*)
45 case "$host_os" in
46 mingw* | windows*)
47 gl_final_[$1]=`cygpath -w "$gl_final_[$1]"` ;;
48 esac
49 ;;
50 esac
51 dnl Convert it to C string syntax.
52 [$1]_c=`printf '%s\n' "$gl_final_[$1]" | sed -e "$gl_sed_double_backslashes" -e "$gl_sed_escape_doublequotes" | tr -d "$gl_tr_cr"`
53 [$1]_c='"'"$[$1]_c"'"'
54 AC_SUBST([$1_c])
55
56 dnl Define somedir_c_make.
57 [$1]_c_make=`printf '%s\n' "$[$1]_c" | sed -e "$gl_sed_escape_for_make_1" -e "$gl_sed_escape_for_make_2" | tr -d "$gl_tr_cr"`
58 dnl Use the substituted somedir variable, when possible, so that the user
59 dnl may adjust somedir a posteriori when there are no special characters.
60 if test "$[$1]_c_make" = '\"'"${gl_final_[$1]}"'\"'; then
61 [$1]_c_make='\"$([$1])\"'
62 fi
63 AC_SUBST([$1_c_make])
64])
65
66dnl Some initializations for gl_BUILD_TO_HOST.
67AC_DEFUN([gl_BUILD_TO_HOST_INIT],
68[
69 gl_sed_double_backslashes='s/\\/\\\\/g'
70 gl_sed_escape_doublequotes='s/"/\\"/g'
71changequote(,)dnl
72 gl_sed_escape_for_make_1="s,\\([ \"&'();<>\\\\\`|]\\),\\\\\\1,g"
73changequote([,])dnl
74 gl_sed_escape_for_make_2='s,\$,\\$$,g'
75 dnl Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
76 dnl does not understand '\r'.
77 case `echo r | tr -d '\r'` in
78 '') gl_tr_cr='\015' ;;
79 *) gl_tr_cr='\r' ;;
80 esac
81])
82
83
84dnl The following macros are convenience invocations of gl_BUILD_TO_HOST
85dnl for some of the variables that are defined by Autoconf.
86dnl To do so for _all_ the possible variables, use the module 'configmake'.
87
88dnl Defines bindir_c and bindir_c_make.
89AC_DEFUN_ONCE([gl_BUILD_TO_HOST_BINDIR],
90[
91 dnl Find the final value of bindir.
92 gl_saved_prefix="${prefix}"
93 gl_saved_exec_prefix="${exec_prefix}"
94 gl_saved_bindir="${bindir}"
95 dnl Unfortunately, prefix and exec_prefix get only finally determined
96 dnl at the end of configure.
97 if test "X$prefix" = "XNONE"; then
98 prefix="$ac_default_prefix"
99 fi
100 if test "X$exec_prefix" = "XNONE"; then
101 exec_prefix='${prefix}'
102 fi
103 eval exec_prefix="$exec_prefix"
104 eval bindir="$bindir"
105 gl_BUILD_TO_HOST([bindir])
106 bindir="${gl_saved_bindir}"
107 exec_prefix="${gl_saved_exec_prefix}"
108 prefix="${gl_saved_prefix}"
109])
110
111dnl Defines datadir_c and datadir_c_make,
112dnl where datadir = $(datarootdir)
113AC_DEFUN_ONCE([gl_BUILD_TO_HOST_DATADIR],
114[
115 dnl Find the final value of datadir.
116 gl_saved_prefix="${prefix}"
117 gl_saved_datarootdir="${datarootdir}"
118 gl_saved_datadir="${datadir}"
119 dnl Unfortunately, prefix gets only finally determined at the end of
120 dnl configure.
121 if test "X$prefix" = "XNONE"; then
122 prefix="$ac_default_prefix"
123 fi
124 eval datarootdir="$datarootdir"
125 eval datadir="$datadir"
126 gl_BUILD_TO_HOST([datadir])
127 datadir="${gl_saved_datadir}"
128 datarootdir="${gl_saved_datarootdir}"
129 prefix="${gl_saved_prefix}"
130])
131
132dnl Defines libdir_c and libdir_c_make.
133AC_DEFUN_ONCE([gl_BUILD_TO_HOST_LIBDIR],
134[
135 dnl Find the final value of libdir.
136 gl_saved_prefix="${prefix}"
137 gl_saved_exec_prefix="${exec_prefix}"
138 gl_saved_libdir="${libdir}"
139 dnl Unfortunately, prefix and exec_prefix get only finally determined
140 dnl at the end of configure.
141 if test "X$prefix" = "XNONE"; then
142 prefix="$ac_default_prefix"
143 fi
144 if test "X$exec_prefix" = "XNONE"; then
145 exec_prefix='${prefix}'
146 fi
147 eval exec_prefix="$exec_prefix"
148 eval libdir="$libdir"
149 gl_BUILD_TO_HOST([libdir])
150 libdir="${gl_saved_libdir}"
151 exec_prefix="${gl_saved_exec_prefix}"
152 prefix="${gl_saved_prefix}"
153])
154
155dnl Defines libexecdir_c and libexecdir_c_make.
156AC_DEFUN_ONCE([gl_BUILD_TO_HOST_LIBEXECDIR],
157[
158 dnl Find the final value of libexecdir.
159 gl_saved_prefix="${prefix}"
160 gl_saved_exec_prefix="${exec_prefix}"
161 gl_saved_libexecdir="${libexecdir}"
162 dnl Unfortunately, prefix and exec_prefix get only finally determined
163 dnl at the end of configure.
164 if test "X$prefix" = "XNONE"; then
165 prefix="$ac_default_prefix"
166 fi
167 if test "X$exec_prefix" = "XNONE"; then
168 exec_prefix='${prefix}'
169 fi
170 eval exec_prefix="$exec_prefix"
171 eval libexecdir="$libexecdir"
172 gl_BUILD_TO_HOST([libexecdir])
173 libexecdir="${gl_saved_libexecdir}"
174 exec_prefix="${gl_saved_exec_prefix}"
175 prefix="${gl_saved_prefix}"
176])
177
178dnl Defines localedir_c and localedir_c_make.
179AC_DEFUN_ONCE([gl_BUILD_TO_HOST_LOCALEDIR],
180[
181 dnl Find the final value of localedir.
182 gl_saved_prefix="${prefix}"
183 gl_saved_datarootdir="${datarootdir}"
184 gl_saved_localedir="${localedir}"
185 dnl Unfortunately, prefix gets only finally determined at the end of
186 dnl configure.
187 if test "X$prefix" = "XNONE"; then
188 prefix="$ac_default_prefix"
189 fi
190 eval datarootdir="$datarootdir"
191 eval localedir="$localedir"
192 gl_BUILD_TO_HOST([localedir])
193 localedir="${gl_saved_localedir}"
194 datarootdir="${gl_saved_datarootdir}"
195 prefix="${gl_saved_prefix}"
196])
197
198dnl Defines pkgdatadir_c and pkgdatadir_c_make,
199dnl where pkgdatadir = $(datadir)/$(PACKAGE)
200AC_DEFUN_ONCE([gl_BUILD_TO_HOST_PKGDATADIR],
201[
202 dnl Find the final value of pkgdatadir.
203 gl_saved_prefix="${prefix}"
204 gl_saved_datarootdir="${datarootdir}"
205 gl_saved_datadir="${datadir}"
206 gl_saved_pkgdatadir="${pkgdatadir}"
207 dnl Unfortunately, prefix gets only finally determined at the end of
208 dnl configure.
209 if test "X$prefix" = "XNONE"; then
210 prefix="$ac_default_prefix"
211 fi
212 eval datarootdir="$datarootdir"
213 eval datadir="$datadir"
214 eval pkgdatadir="$pkgdatadir"
215 gl_BUILD_TO_HOST([pkgdatadir])
216 pkgdatadir="${gl_saved_pkgdatadir}"
217 datadir="${gl_saved_datadir}"
218 datarootdir="${gl_saved_datarootdir}"
219 prefix="${gl_saved_prefix}"
220])
221
222dnl Defines pkglibdir_c and pkglibdir_c_make,
223dnl where pkglibdir = $(libdir)/$(PACKAGE)
224AC_DEFUN_ONCE([gl_BUILD_TO_HOST_PKGLIBDIR],
225[
226 dnl Find the final value of pkglibdir.
227 gl_saved_prefix="${prefix}"
228 gl_saved_exec_prefix="${exec_prefix}"
229 gl_saved_libdir="${libdir}"
230 gl_saved_pkglibdir="${pkglibdir}"
231 dnl Unfortunately, prefix and exec_prefix get only finally determined
232 dnl at the end of configure.
233 if test "X$prefix" = "XNONE"; then
234 prefix="$ac_default_prefix"
235 fi
236 if test "X$exec_prefix" = "XNONE"; then
237 exec_prefix='${prefix}'
238 fi
239 eval exec_prefix="$exec_prefix"
240 eval libdir="$libdir"
241 eval pkglibdir="$pkglibdir"
242 gl_BUILD_TO_HOST([pkglibdir])
243 pkglibdir="${gl_saved_pkglibdir}"
244 libdir="${gl_saved_libdir}"
245 exec_prefix="${gl_saved_exec_prefix}"
246 prefix="${gl_saved_prefix}"
247])
248
249dnl Defines pkglibexecdir_c and pkglibexecdir_c_make,
250dnl where pkglibexecdir = $(libexecdir)/$(PACKAGE)
251AC_DEFUN_ONCE([gl_BUILD_TO_HOST_PKGLIBEXECDIR],
252[
253 dnl Find the final value of pkglibexecdir.
254 gl_saved_prefix="${prefix}"
255 gl_saved_exec_prefix="${exec_prefix}"
256 gl_saved_libexecdir="${libexecdir}"
257 gl_saved_pkglibexecdir="${pkglibexecdir}"
258 dnl Unfortunately, prefix and exec_prefix get only finally determined
259 dnl at the end of configure.
260 if test "X$prefix" = "XNONE"; then
261 prefix="$ac_default_prefix"
262 fi
263 if test "X$exec_prefix" = "XNONE"; then
264 exec_prefix='${prefix}'
265 fi
266 eval exec_prefix="$exec_prefix"
267 eval libexecdir="$libexecdir"
268 eval pkglibexecdir="$pkglibexecdir"
269 gl_BUILD_TO_HOST([pkglibexecdir])
270 pkglibexecdir="${gl_saved_pkglibexecdir}"
271 libexecdir="${gl_saved_libexecdir}"
272 exec_prefix="${gl_saved_exec_prefix}"
273 prefix="${gl_saved_prefix}"
274])
diff --git a/gl/m4/builtin-expect.m4 b/gl/m4/builtin-expect.m4
index 531ed48a..cf96977e 100644
--- a/gl/m4/builtin-expect.m4
+++ b/gl/m4/builtin-expect.m4
@@ -1,9 +1,12 @@
1dnl Check for __builtin_expect. 1# builtin-expect.m4
2 2# serial 3
3dnl Copyright 2016-2023 Free Software Foundation, Inc. 3dnl Copyright 2016-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Provide a GCC-compatible __builtin_expect macro in <config.h>.
7 10
8dnl Written by Paul Eggert. 11dnl Written by Paul Eggert.
9 12
@@ -45,5 +48,4 @@ AC_DEFUN([gl___BUILTIN_EXPECT],
45#elif HAVE___BUILTIN_EXPECT == 2 48#elif HAVE___BUILTIN_EXPECT == 2
46# include <builtins.h> 49# include <builtins.h>
47#endif 50#endif
48 ]) 51])])
49])
diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4
index 8058d178..a0287062 100644
--- a/gl/m4/byteswap.m4
+++ b/gl/m4/byteswap.m4
@@ -1,17 +1,42 @@
1# byteswap.m4 serial 5 1# byteswap.m4
2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 7
3dnl Copyright (C) 2005, 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Written by Oskar Liljeblad. 9dnl Written by Oskar Liljeblad.
8 10
9AC_DEFUN([gl_BYTESWAP], 11AC_DEFUN([gl_BYTESWAP],
10[ 12[
11 dnl Prerequisites of lib/byteswap.in.h. 13 dnl Prerequisites of lib/byteswap.in.h.
12 AC_CHECK_HEADERS([byteswap.h], [ 14 AC_CHECK_HEADERS_ONCE([byteswap.h])
15 if test $ac_cv_header_byteswap_h = yes; then
16 AC_CACHE_CHECK([for working bswap_16, bswap_32, bswap_64],
17 [gl_cv_header_working_byteswap_h],
18 [gl_cv_header_working_byteswap_h=no
19 dnl Check that floating point arguments work.
20 dnl This also checks C libraries with implementations like
21 dnl '#define bswap_16(x) (((x) >> 8 & 0xff) | (((x) & 0xff) << 8))'
22 dnl that mistakenly evaluate their arguments multiple times.
23 AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM(
25 [[#include <byteswap.h>
26 ]],
27 [[int value_16 = bswap_16 (0.0);
28 int value_32 = bswap_32 (0.0);
29 int value_64 = bswap_64 (0.0);
30 return !(value_16 + value_32 + value_64);
31 ]])
32 ],
33 [gl_cv_header_working_byteswap_h=yes],
34 [gl_cv_header_working_byteswap_h=no])
35 ])
36 fi
37 if test "$gl_cv_header_working_byteswap_h" = yes; then
13 GL_GENERATE_BYTESWAP_H=false 38 GL_GENERATE_BYTESWAP_H=false
14 ], [ 39 else
15 GL_GENERATE_BYTESWAP_H=true 40 GL_GENERATE_BYTESWAP_H=true
16 ]) 41 fi
17]) 42])
diff --git a/gl/m4/c-bool.m4 b/gl/m4/c-bool.m4
index f614371b..f04041a4 100644
--- a/gl/m4/c-bool.m4
+++ b/gl/m4/c-bool.m4
@@ -1,9 +1,12 @@
1# Check for bool that conforms to C2023. 1# c-bool.m4
2 2# serial 3
3dnl Copyright 2022-2023 Free Software Foundation, Inc. 3dnl Copyright 2022-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# Check for bool that conforms to C2023.
7 10
8AC_DEFUN([gl_C_BOOL], 11AC_DEFUN([gl_C_BOOL],
9[ 12[
@@ -27,12 +30,23 @@ AC_DEFUN([gl_C_BOOL],
27 dnl The "zz" puts this toward config.h's end, to avoid potential 30 dnl The "zz" puts this toward config.h's end, to avoid potential
28 dnl collisions with other definitions. 31 dnl collisions with other definitions.
29 dnl If 'bool', 'true' and 'false' do not work, arrange for them to work. 32 dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
30 dnl In C, this means including <stdbool.h> if it is not already included. 33 dnl Hardcode the known configuration results for GCC and clang, so that
34 dnl a configuration made with the C compiler works also with the C++ compiler
35 dnl and vice versa.
36 dnl The seemingly redundant parentheses are necessary for MSVC 14.
37 dnl "Arrange for them to work", in C, means including <stdbool.h> if it is
38 dnl not already included.
31 dnl However, if the preprocessor mistakenly treats 'true' as 0, 39 dnl However, if the preprocessor mistakenly treats 'true' as 0,
32 dnl define it to a bool expression equal to 1; this is needed in 40 dnl define it to a bool expression equal to 1; this is needed in
33 dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older. 41 dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
34 AH_VERBATIM([zzbool], 42 AH_VERBATIM([zzbool],
35[#ifndef HAVE_C_BOOL 43[#if !(defined __cplusplus \
44 ? 1 \
45 : (defined __clang__ \
46 ? __STDC_VERSION__ >= 202000L && __clang_major__ >= 15 \
47 : (defined __GNUC__ \
48 ? __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 \
49 : defined HAVE_C_BOOL)))
36# if !defined __cplusplus && !defined __bool_true_false_are_defined 50# if !defined __cplusplus && !defined __bool_true_false_are_defined
37# if HAVE_STDBOOL_H 51# if HAVE_STDBOOL_H
38# include <stdbool.h> 52# include <stdbool.h>
diff --git a/gl/m4/c32rtomb.m4 b/gl/m4/c32rtomb.m4
new file mode 100644
index 00000000..b7a0d44c
--- /dev/null
+++ b/gl/m4/c32rtomb.m4
@@ -0,0 +1,187 @@
1# c32rtomb.m4
2# serial 8
3dnl Copyright (C) 2020-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_C32RTOMB],
10[
11 AC_REQUIRE([gl_UCHAR_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST])
13
14 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
15 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
16
17 AC_REQUIRE([gl_CHECK_FUNC_C32RTOMB])
18 if test $gl_cv_func_c32rtomb = no; then
19 HAVE_C32RTOMB=0
20 else
21 dnl When we override mbrtoc32, redefining the meaning of the char32_t
22 dnl values, we need to override c32rtomb as well, for consistency.
23 if test $HAVE_WORKING_MBRTOC32 = 0; then
24 REPLACE_C32RTOMB=1
25 fi
26 AC_CACHE_CHECK([whether c32rtomb return value is correct],
27 [gl_cv_func_c32rtomb_retval],
28 [
29 dnl Initial guess, used when cross-compiling.
30changequote(,)dnl
31 case "$host_os" in
32 # Guess no on AIX.
33 aix*) gl_cv_func_c32rtomb_retval="guessing no" ;;
34 # Guess yes otherwise.
35 *) gl_cv_func_c32rtomb_retval="guessing yes" ;;
36 esac
37changequote([,])dnl
38 AC_RUN_IFELSE(
39 [AC_LANG_SOURCE([[
40#include <stddef.h>
41#ifdef __HAIKU__
42 #include <stdint.h>
43#endif
44#include <uchar.h>
45int main ()
46{
47 int result = 0;
48 if (c32rtomb (NULL, 0, NULL) != 1)
49 result |= 1;
50 return result;
51}]])],
52 [gl_cv_func_c32rtomb_retval=yes],
53 [gl_cv_func_c32rtomb_retval=no],
54 [:])
55 ])
56 case "$gl_cv_func_c32rtomb_retval" in
57 *yes) ;;
58 *) AC_DEFINE([C32RTOMB_RETVAL_BUG], [1],
59 [Define if the c32rtomb function has an incorrect return value.])
60 REPLACE_C32RTOMB=1 ;;
61 esac
62 if test $HAVE_WORKING_C32RTOMB = 0; then
63 REPLACE_C32RTOMB=1
64 fi
65 fi
66])
67
68AC_DEFUN([gl_CHECK_FUNC_C32RTOMB],
69[
70 dnl Cf. gl_CHECK_FUNCS_ANDROID
71 AC_CHECK_DECL([c32rtomb], , ,
72 [[#ifdef __HAIKU__
73 #include <stdint.h>
74 #endif
75 #include <uchar.h>
76 ]])
77 if test $ac_cv_have_decl_c32rtomb = yes; then
78 dnl We can't use AC_CHECK_FUNC here, because c32rtomb() is defined as a
79 dnl static inline function on Haiku 2020.
80 AC_CACHE_CHECK([for c32rtomb], [gl_cv_func_c32rtomb],
81 [AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[#include <stdlib.h>
84 #ifdef __HAIKU__
85 #include <stdint.h>
86 #endif
87 #include <uchar.h>
88 ]],
89 [[char buf[8];
90 return c32rtomb (buf, 0, NULL) == 0;
91 ]])
92 ],
93 [gl_cv_func_c32rtomb=yes],
94 [gl_cv_func_c32rtomb=no])
95 ])
96 else
97 gl_cv_func_c32rtomb=no
98 fi
99])
100
101dnl Test whether c32rtomb works not worse than wcrtomb.
102dnl Result is HAVE_WORKING_C32RTOMB.
103
104AC_DEFUN([gl_C32RTOMB_SANITYCHECK],
105[
106 AC_REQUIRE([AC_PROG_CC])
107 AC_REQUIRE([gl_TYPE_CHAR32_T])
108 AC_REQUIRE([gl_CHECK_FUNC_C32RTOMB])
109 AC_REQUIRE([gt_LOCALE_ZH_CN])
110 AC_REQUIRE([AC_CANONICAL_HOST])
111 if test $GNULIBHEADERS_OVERRIDE_CHAR32_T = 1 || test $gl_cv_func_c32rtomb = no; then
112 HAVE_WORKING_C32RTOMB=0
113 else
114 AC_CACHE_CHECK([whether c32rtomb works as well as wcrtomb],
115 [gl_cv_func_c32rtomb_sanitycheck],
116 [
117 dnl Initial guess, used when cross-compiling or when no suitable locale
118 dnl is present.
119changequote(,)dnl
120 case "$host_os" in
121 # Guess no on Solaris derivatives.
122 solaris*)
123 if test -f /etc/release && grep 'Oracle Solaris' /etc/release >/dev/null; then
124 gl_cv_func_c32rtomb_sanitycheck="guessing yes"
125 else
126 gl_cv_func_c32rtomb_sanitycheck="guessing no"
127 fi
128 ;;
129 # Guess yes otherwise.
130 *)
131 gl_cv_func_c32rtomb_sanitycheck="guessing yes"
132 ;;
133 esac
134changequote([,])dnl
135 if test $LOCALE_ZH_CN != none; then
136 AC_RUN_IFELSE(
137 [AC_LANG_SOURCE([[
138#include <locale.h>
139#include <stdlib.h>
140#include <string.h>
141#include <wchar.h>
142#ifdef __HAIKU__
143 #include <stdint.h>
144#endif
145#include <uchar.h>
146int main ()
147{
148 int result = 0;
149 /* This fails on Solaris 11 OmniOS:
150 c32rtomb returns (size_t)-1.
151 wcrtomb returns 4 (correct). */
152 if (strcmp ("$LOCALE_ZH_CN", "none") != 0
153 && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
154 {
155 mbstate_t state;
156 wchar_t wc = (wchar_t) 0xBADFACE;
157 char buf[16];
158 memset (&state, '\0', sizeof (mbstate_t));
159 if (mbrtowc (&wc, "\201\060\211\070", 4, &state) == 4
160 && wcrtomb (buf, wc, NULL) == 4
161 && memcmp (buf, "\201\060\211\070", 4) == 0)
162 {
163 char32_t c32 = (wchar_t) 0xBADFACE;
164 memset (&state, '\0', sizeof (mbstate_t));
165 if (mbrtoc32 (&c32, "\201\060\211\070", 4, &state) == 4
166 && c32rtomb (buf, c32, NULL) != 4)
167 result |= 1;
168 }
169 }
170 return result;
171}]])],
172 [gl_cv_func_c32rtomb_sanitycheck=yes],
173 [gl_cv_func_c32rtomb_sanitycheck=no],
174 [:])
175 fi
176 ])
177 case "$gl_cv_func_c32rtomb_sanitycheck" in
178 *yes)
179 HAVE_WORKING_C32RTOMB=1
180 AC_DEFINE([HAVE_WORKING_C32RTOMB], [1],
181 [Define if the c32rtomb function basically works.])
182 ;;
183 *) HAVE_WORKING_C32RTOMB=0 ;;
184 esac
185 fi
186 AC_SUBST([HAVE_WORKING_C32RTOMB])
187])
diff --git a/gl/m4/calloc.m4 b/gl/m4/calloc.m4
index 23c0dd9f..2ed64332 100644
--- a/gl/m4/calloc.m4
+++ b/gl/m4/calloc.m4
@@ -1,9 +1,10 @@
1# calloc.m4 serial 29 1# calloc.m4
2 2# serial 36
3# Copyright (C) 2004-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2004-2026 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8# Written by Jim Meyering. 9# Written by Jim Meyering.
9 10
@@ -12,42 +13,35 @@
12# If so, define HAVE_CALLOC. Otherwise, define calloc to rpl_calloc 13# If so, define HAVE_CALLOC. Otherwise, define calloc to rpl_calloc
13# and arrange to use a calloc wrapper function that does work in that case. 14# and arrange to use a calloc wrapper function that does work in that case.
14 15
15# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT]) 16# gl_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT])
16# ------------------------------------- 17# ---------------------------------------
17# If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT. 18# If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT.
18AC_DEFUN([_AC_FUNC_CALLOC_IF], 19AC_DEFUN([gl_FUNC_CALLOC_IF],
19[ 20[
20 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 21 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull], 22 AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull],
22 [ac_cv_func_calloc_0_nonnull], 23 [gl_cv_func_calloc_0_nonnull],
23 [if test $cross_compiling != yes; then 24 [AC_RUN_IFELSE(
24 ac_cv_func_calloc_0_nonnull=yes 25 [AC_LANG_PROGRAM(
25 AC_RUN_IFELSE( 26 [[#include <stdlib.h>
26 [AC_LANG_PROGRAM( 27 /* Use pcalloc to test; "volatile" prevents the compiler
27 [AC_INCLUDES_DEFAULT], 28 from optimizing the calloc call away. */
28 [[int result = 0; 29 void *(*volatile pcalloc) (size_t, size_t) = calloc;]],
29 char * volatile p = calloc (0, 0); 30 [[void *p = pcalloc (0, 0);
30 if (!p) 31 int result = !p;
31 result |= 1; 32 free (p);
32 free (p); 33 return result;]])],
33 return result; 34 [gl_cv_func_calloc_0_nonnull=yes],
34 ]])], 35 [gl_cv_func_calloc_0_nonnull=no],
35 [], 36 [AS_CASE([$host_os],
36 [ac_cv_func_calloc_0_nonnull=no]) 37 [# Guess yes on platforms where we know the result.
37 else 38 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
38 case "$host_os" in 39 | gnu* | *-musl* | midipix* | midnightbsd* \
39 # Guess yes on glibc systems. 40 | hpux* | solaris* | cygwin* | mingw* | windows* | msys*],
40 *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; 41 [gl_cv_func_calloc_0_nonnull="guessing yes"],
41 # Guess yes on musl systems. 42 [# If we don't know, obey --enable-cross-guesses.
42 *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;; 43 gl_cv_func_calloc_0_nonnull="$gl_cross_guess_normal"])])])
43 # Guess yes on native Windows. 44 AS_CASE([$gl_cv_func_calloc_0_nonnull], [*yes], [$1], [$2])
44 mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
45 # If we don't know, obey --enable-cross-guesses.
46 *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;;
47 esac
48 fi
49 ])
50 AS_CASE([$ac_cv_func_calloc_0_nonnull], [*yes], [$1], [$2])
51]) 45])
52 46
53 47
@@ -58,9 +52,14 @@ AC_DEFUN([gl_FUNC_CALLOC_GNU],
58[ 52[
59 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 53 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
60 AC_REQUIRE([gl_FUNC_CALLOC_POSIX]) 54 AC_REQUIRE([gl_FUNC_CALLOC_POSIX])
55
56 dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT
57 dnl gets defined already before this macro gets invoked. This helps
58 dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
59
61 REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX" 60 REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX"
62 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then 61 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then
63 _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1]) 62 gl_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1])
64 fi 63 fi
65])# gl_FUNC_CALLOC_GNU 64])# gl_FUNC_CALLOC_GNU
66 65
@@ -73,9 +72,7 @@ AC_DEFUN([gl_FUNC_CALLOC_POSIX],
73[ 72[
74 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 73 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
75 AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) 74 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
76 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then 75 REPLACE_CALLOC_FOR_CALLOC_POSIX=$REPLACE_MALLOC_FOR_MALLOC_POSIX
77 REPLACE_CALLOC_FOR_CALLOC_POSIX=1
78 fi
79 dnl Although in theory we should also test for size_t overflow, 76 dnl Although in theory we should also test for size_t overflow,
80 dnl in practice testing for ptrdiff_t overflow suffices 77 dnl in practice testing for ptrdiff_t overflow suffices
81 dnl since PTRDIFF_MAX <= SIZE_MAX on all known Gnulib porting targets. 78 dnl since PTRDIFF_MAX <= SIZE_MAX on all known Gnulib porting targets.
diff --git a/gl/m4/close.m4 b/gl/m4/close.m4
index 9f95c670..9b498643 100644
--- a/gl/m4/close.m4
+++ b/gl/m4/close.m4
@@ -1,10 +1,12 @@
1# close.m4 serial 9 1# close.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 10
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_CLOSE], 9AC_DEFUN_ONCE([gl_FUNC_CLOSE],
8[ 10[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 m4_ifdef([gl_MSVC_INVAL], [ 12 m4_ifdef([gl_MSVC_INVAL], [
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index 5804f472..4ab542f4 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,9 +1,11 @@
1# codeset.m4 serial 5 (gettext-0.18.2) 1# codeset.m4
2dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2023 Free Software 2# serial 5 (gettext-0.18.2)
3dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2026 Free Software
3dnl Foundation, Inc. 4dnl Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8dnl From Bruno Haible. 10dnl From Bruno Haible.
9 11
diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4
index 1776e5eb..957adca6 100644
--- a/gl/m4/double-slash-root.m4
+++ b/gl/m4/double-slash-root.m4
@@ -1,8 +1,10 @@
1# double-slash-root.m4 serial 4 -*- Autoconf -*- 1# double-slash-root.m4
2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc. 2# serial 4 -*- Autoconf -*-
3dnl Copyright (C) 2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_DOUBLE_SLASH_ROOT], 9AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
8[ 10[
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
index e1cc73e1..e1d51898 100644
--- a/gl/m4/dup2.m4
+++ b/gl/m4/dup2.m4
@@ -1,8 +1,10 @@
1#serial 27 1# dup2.m4
2dnl Copyright (C) 2002, 2005, 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 28
3dnl Copyright (C) 2002, 2005, 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_DUP2], 9AC_DEFUN([gl_FUNC_DUP2],
8[ 10[
@@ -67,7 +69,7 @@ AC_DEFUN([gl_FUNC_DUP2],
67 ], 69 ],
68 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no], 70 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
69 [case "$host_os" in 71 [case "$host_os" in
70 mingw*) # on this platform, dup2 always returns 0 for success 72 mingw* | windows*) # on this platform, dup2 always returns 0 for success
71 gl_cv_func_dup2_works="guessing no" ;; 73 gl_cv_func_dup2_works="guessing no" ;;
72 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 74 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
73 gl_cv_func_dup2_works="guessing no" ;; 75 gl_cv_func_dup2_works="guessing no" ;;
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
deleted file mode 100644
index cb3e08fe..00000000
--- a/gl/m4/eealloc.m4
+++ /dev/null
@@ -1,31 +0,0 @@
1# eealloc.m4 serial 3
2dnl Copyright (C) 2003, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_EEALLOC],
8[
9 AC_REQUIRE([gl_EEMALLOC])
10 AC_REQUIRE([gl_EEREALLOC])
11])
12
13AC_DEFUN([gl_EEMALLOC],
14[
15 _AC_FUNC_MALLOC_IF(
16 [gl_cv_func_malloc_0_nonnull=1],
17 [gl_cv_func_malloc_0_nonnull=0])
18 AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull],
19 [If malloc(0) is != NULL, define this to 1. Otherwise define this
20 to 0.])
21])
22
23AC_DEFUN([gl_EEREALLOC],
24[
25 _AC_FUNC_REALLOC_IF(
26 [gl_cv_func_realloc_0_nonnull=1],
27 [gl_cv_func_realloc_0_nonnull=0])
28 AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull],
29 [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this
30 to 0.])
31])
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 741dfc56..5c0644ab 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,8 +1,10 @@
1# environ.m4 serial 8 1# environ.m4
2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc. 2# serial 8
3dnl Copyright (C) 2001-2004, 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_ENVIRON], 9AC_DEFUN_ONCE([gl_ENVIRON],
8[ 10[
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index 4c70d225..ade19b6f 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,14 +1,21 @@
1# errno_h.m4 serial 14 1# errno_h.m4
2dnl Copyright (C) 2004, 2006, 2008-2023 Free Software Foundation, Inc. 2# serial 19
3dnl Copyright (C) 2004, 2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_PREREQ([2.61]) 9AC_PREREQ([2.61])
8 10
9AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], 11AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
10[ 12[
11 AC_REQUIRE([AC_PROG_CC]) 13 AC_REQUIRE([AC_PROG_CC])
14
15 dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT
16 dnl gets defined already before this macro gets invoked. This persuades
17 dnl AIX 7.3 errno.h to assign ENOTEMPTY a value different than EEXIST.
18
12 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ 19 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
13 AC_EGREP_CPP([booboo],[ 20 AC_EGREP_CPP([booboo],[
14#include <errno.h> 21#include <errno.h>
@@ -63,6 +70,9 @@ booboo
63#if !defined EILSEQ 70#if !defined EILSEQ
64booboo 71booboo
65#endif 72#endif
73#if !defined ESOCKTNOSUPPORT
74booboo
75#endif
66 ], 76 ],
67 [gl_cv_header_errno_h_complete=no], 77 [gl_cv_header_errno_h_complete=no],
68 [gl_cv_header_errno_h_complete=yes]) 78 [gl_cv_header_errno_h_complete=yes])
@@ -73,59 +83,4 @@ booboo
73 gl_NEXT_HEADERS([errno.h]) 83 gl_NEXT_HEADERS([errno.h])
74 GL_GENERATE_ERRNO_H=true 84 GL_GENERATE_ERRNO_H=true
75 fi 85 fi
76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
77 gl_REPLACE_ERRNO_VALUE([ENOLINK])
78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
79])
80
81# Assuming $1 = EOVERFLOW.
82# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
83# POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
84# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
85# Check for the value of EOVERFLOW.
86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
87AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
88[
89 if $GL_GENERATE_ERRNO_H; then
90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
91 AC_EGREP_CPP([yes],[
92#include <errno.h>
93#ifdef ]$1[
94yes
95#endif
96 ],
97 [gl_cv_header_errno_h_]$1[=yes],
98 [gl_cv_header_errno_h_]$1[=no])
99 if test $gl_cv_header_errno_h_]$1[ = no; then
100 AC_EGREP_CPP([yes],[
101#define _XOPEN_SOURCE_EXTENDED 1
102#include <errno.h>
103#ifdef ]$1[
104yes
105#endif
106 ], [gl_cv_header_errno_h_]$1[=hidden])
107 if test $gl_cv_header_errno_h_]$1[ = hidden; then
108 dnl The macro exists but is hidden.
109 dnl Define it to the same value.
110 AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
111#define _XOPEN_SOURCE_EXTENDED 1
112#include <errno.h>
113/* The following two lines are a workaround against an autoconf-2.52 bug. */
114#include <stdio.h>
115#include <stdlib.h>
116])
117 fi
118 fi
119 ])
120 case $gl_cv_header_errno_h_]$1[ in
121 yes | no)
122 ]$1[_HIDDEN=0; ]$1[_VALUE=
123 ;;
124 *)
125 ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
126 ;;
127 esac
128 AC_SUBST($1[_HIDDEN])
129 AC_SUBST($1[_VALUE])
130 fi
131]) 86])
diff --git a/gl/m4/error.m4 b/gl/m4/error.m4
index 8cc75dff..f14b9ceb 100644
--- a/gl/m4/error.m4
+++ b/gl/m4/error.m4
@@ -1,22 +1,14 @@
1#serial 15 1# error.m4
2 2# serial 16
3# Copyright (C) 1996-1998, 2001-2004, 2009-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 1996-1998, 2001-2004, 2009-2026 Free Software Foundation,
4# 4dnl Inc.
5# This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
8 9
9AC_DEFUN([gl_ERROR], 10AC_DEFUN([gl_ERROR],
10[ 11[
11 dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer
12 dnl maintained in Autoconf and because it invokes AC_LIBOBJ.
13 AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line],
14 [AC_LINK_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <error.h>]],
17 [[error_at_line (0, 0, "", 0, "an error occurred");]])],
18 [ac_cv_lib_error_at_line=yes],
19 [ac_cv_lib_error_at_line=no])])
20]) 12])
21 13
22# Prerequisites of lib/error.c. 14# Prerequisites of lib/error.c.
diff --git a/gl/m4/error_h.m4 b/gl/m4/error_h.m4
new file mode 100644
index 00000000..73e96943
--- /dev/null
+++ b/gl/m4/error_h.m4
@@ -0,0 +1,129 @@
1# error_h.m4
2# serial 5
3dnl Copyright (C) 1996-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Bruno Haible.
10dnl Provide a working <error.h>.
11
12AC_DEFUN_ONCE([gl_ERROR_H],
13[
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15
16 gl_CHECK_NEXT_HEADERS([error.h])
17 if test $ac_cv_header_error_h = yes; then
18 HAVE_ERROR_H=1
19 else
20 HAVE_ERROR_H=0
21 fi
22 AC_SUBST([HAVE_ERROR_H])
23
24 REPLACE_ERROR=0
25
26 gl_CHECK_FUNCS_ANDROID([error], [[#include <error.h>]])
27 if test $ac_cv_func_error = yes; then
28 HAVE_ERROR=1
29 else
30 HAVE_ERROR=0
31 case "$gl_cv_onwards_func_error" in
32 future*) REPLACE_ERROR=1 ;;
33 esac
34 fi
35
36 dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer
37 dnl maintained in Autoconf and because it invokes AC_LIBOBJ.
38 dnl We need to notice a missing declaration, like gl_CHECK_FUNCS_ANDROID does.
39 AC_CHECK_DECL([error_at_line], , , [[#include <error.h>]])
40 if test $ac_cv_have_decl_error_at_line = yes; then
41 AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line],
42 [AC_LINK_IFELSE(
43 [AC_LANG_PROGRAM(
44 [[#include <error.h>]],
45 [[error_at_line (0, 0, "", 0, "an error occurred");]])],
46 [ac_cv_lib_error_at_line=yes],
47 [ac_cv_lib_error_at_line=no])])
48 else
49 ac_cv_lib_error_at_line=no
50 fi
51 if test $ac_cv_lib_error_at_line = yes; then
52 HAVE_ERROR_AT_LINE=1
53 else
54 HAVE_ERROR_AT_LINE=0
55 fi
56 REPLACE_ERROR_AT_LINE=0
57
58 if test $ac_cv_func_error = yes && test $ac_cv_lib_error_at_line = yes; then
59 dnl On Android 11, when error_print_progname is set, the output of the
60 dnl error() function contains an extra space.
61 AC_CACHE_CHECK([for working error function],
62 [gl_cv_func_working_error],
63 [if test $cross_compiling != yes; then
64 AC_LINK_IFELSE(
65 [AC_LANG_PROGRAM([[
66 #include <error.h>
67 static void print_no_progname (void) {}
68 ]], [[
69 error_print_progname = print_no_progname;
70 error (0, 0, "foo");
71 ]])
72 ],
73 [rm -f conftest.out
74 if test -s conftest$ac_exeext \
75 && ./conftest$ac_exeext 2> conftest.out; then
76 if grep ' ' conftest.out >/dev/null; then
77 gl_cv_func_working_error=no
78 else
79 gl_cv_func_working_error=yes
80 fi
81 else
82 gl_cv_func_working_error=no
83 fi
84 rm -f conftest.out
85 ],
86 [gl_cv_func_working_error=no])
87 else
88 AC_COMPILE_IFELSE(
89 [AC_LANG_PROGRAM([[
90 #include <error.h>
91 ]], [[
92 error (0, 0, "foo");
93 ]])
94 ],
95 [case "$host_os" in
96 # Guess yes on glibc systems.
97 *-gnu* | gnu*) gl_cv_func_working_error="guessing yes" ;;
98 # Guess no on Android.
99 linux*-android*) gl_cv_func_working_error="guessing no" ;;
100 # If we don't know, obey --enable-cross-guesses.
101 *) gl_cv_func_working_error="$gl_cross_guess_normal" ;;
102 esac
103 ],
104 [gl_cv_func_working_error=no])
105 fi
106 ])
107 case "$gl_cv_func_working_error" in
108 *no)
109 REPLACE_ERROR=1
110 REPLACE_ERROR_AT_LINE=1
111 ;;
112 esac
113 fi
114
115 m4_ifdef([gl_HAVE_MODULE_VERROR],
116 [COMPILE_ERROR_C=1],
117 [if test $HAVE_ERROR = 0 || test $REPLACE_ERROR = 1 \
118 || test $HAVE_ERROR_AT_LINE = 0 \
119 || test $REPLACE_ERROR_AT_LINE = 1; then
120 COMPILE_ERROR_C=1
121 else
122 COMPILE_ERROR_C=0
123 fi])
124
125 AC_SUBST([HAVE_ERROR])
126 AC_SUBST([HAVE_ERROR_AT_LINE])
127 AC_SUBST([REPLACE_ERROR])
128 AC_SUBST([REPLACE_ERROR_AT_LINE])
129])
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4
index 2ef46437..bff98570 100644
--- a/gl/m4/exponentd.m4
+++ b/gl/m4/exponentd.m4
@@ -1,9 +1,11 @@
1# exponentd.m4 serial 3 1# exponentd.m4
2dnl Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2007-2008, 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
6AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION], 7dnl This file is offered as-is, without any warranty.
8AC_DEFUN_ONCE([gl_DOUBLE_EXPONENT_LOCATION],
7[ 9[
8 AC_CACHE_CHECK([where to find the exponent in a 'double'], 10 AC_CACHE_CHECK([where to find the exponent in a 'double'],
9 [gl_cv_cc_double_expbit0], 11 [gl_cv_cc_double_expbit0],
@@ -83,7 +85,7 @@ int main ()
83 dnl The newer VFP instructions assume little-endian order 85 dnl The newer VFP instructions assume little-endian order
84 dnl consistently. 86 dnl consistently.
85 AC_EGREP_CPP([mixed_endianness], [ 87 AC_EGREP_CPP([mixed_endianness], [
86#if defined arm || defined __arm || defined __arm__ 88#if defined __arm__
87 mixed_endianness 89 mixed_endianness
88#endif 90#endif
89 ], 91 ],
diff --git a/gl/m4/extensions-aix.m4 b/gl/m4/extensions-aix.m4
new file mode 100644
index 00000000..9036d7bb
--- /dev/null
+++ b/gl/m4/extensions-aix.m4
@@ -0,0 +1,26 @@
1# extensions-aix.m4
2# serial 1
3dnl Copyright (C) 2024-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# On AIX, most extensions are already enabled through the _ALL_SOURCE macro,
10# defined by gl_USE_SYSTEM_EXTENSIONS. gl_USE_AIX_EXTENSIONS additionally
11# activates more GNU and Linux-like behaviours, affecting
12# - the time_t type,
13# - errno values in <errno.h>: ENOTEMPTY
14# - functions in <stdlib.h>: malloc calloc realloc valloc
15# <https://www.ibm.com/docs/en/aix/7.3?topic=m-malloc-free-realloc-calloc-mallopt-mallinfo-mallinfo-heap-alloca-valloc-posix-memalign-subroutine>
16# - functions in <string.h>: strerror_r (returns 'char *', like glibc)
17# - functions in <dirent.h>: scandir, alphasort, readdir_r
18# - functions in <netdb.h>: gethostbyname_r gethostbyaddr_r
19# - declarations in <unistd.h>: sbrk
20# and a couple of secondary <sys/*> header files.
21
22AC_DEFUN_ONCE([gl_USE_AIX_EXTENSIONS],
23[
24 AC_DEFINE([_LINUX_SOURCE_COMPAT], [1],
25 [Define so that AIX headers are more compatible with GNU/Linux.])
26])
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index 5336b8da..01a8e5f9 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,10 +1,12 @@
1# serial 23 -*- Autoconf -*- 1# extensions.m4
2# Enable extensions on systems that normally disable them. 2# serial 25 -*- Autoconf -*-
3dnl Copyright (C) 2003, 2006-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
3 8
4# Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc. 9# Enable extensions on systems that normally disable them.
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8 10
9dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that 11dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that
10dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+. 12dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+.
@@ -229,4 +231,15 @@ AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
229 [Define to enable the declarations of ISO C 11 types and functions.]) 231 [Define to enable the declarations of ISO C 11 types and functions.])
230 ;; 232 ;;
231 esac 233 esac
234
235 dnl On OpenSolaris derivatives, the include files contains a couple of
236 dnl declarations that are only activated with an explicit
237 dnl -D__STDC_WANT_LIB_EXT1__.
238 AH_VERBATIM([USE_ISO_C_23_ANNEX_K_EXTENSIONS],
239[/* Define to enable the declarations of ISO C 23 Annex K types and functions. */
240#if !(defined __STDC_WANT_LIB_EXT1__ && __STDC_WANT_LIB_EXT1__)
241#undef/**/__STDC_WANT_LIB_EXT1__
242#define __STDC_WANT_LIB_EXT1__ 1
243#endif
244])
232]) 245])
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index c001b1cf..4ccc4a95 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -1,9 +1,12 @@
1dnl 'extern inline' a la ISO C99. 1# extern-inline.m4
2 2# serial 2
3dnl Copyright 2012-2023 Free Software Foundation, Inc. 3dnl Copyright 2012-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl 'extern inline' a la ISO C99.
7 10
8AC_DEFUN([gl_EXTERN_INLINE], 11AC_DEFUN([gl_EXTERN_INLINE],
9[ 12[
@@ -40,9 +43,11 @@ AC_DEFUN([gl_EXTERN_INLINE],
40 functions or macros in standard C headers like <ctype.h>. For example, 43 functions or macros in standard C headers like <ctype.h>. For example,
41 if isdigit is mistakenly implemented via a static inline function, 44 if isdigit is mistakenly implemented via a static inline function,
42 a program containing an extern inline function that calls isdigit 45 a program containing an extern inline function that calls isdigit
43 may not work since the C standard prohibits extern inline functions 46 may not work since C99 through C23 prohibit extern inline functions
44 from calling static functions (ISO C 99 section 6.7.4.(3). 47 from calling static functions (ISO C 23 § 6.7.5 ¶ 3)).
45 This bug is known to occur on: 48 Although a future C standard will likely relax this restriction
49 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3622.txt>,
50 respect it for now. This bug is known to occur on:
46 51
47 OS X 10.8 and earlier; see: 52 OS X 10.8 and earlier; see:
48 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html 53 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
@@ -79,7 +84,8 @@ AC_DEFUN([gl_EXTERN_INLINE],
79# define _GL_EXTERN_INLINE_STDHEADER_BUG 84# define _GL_EXTERN_INLINE_STDHEADER_BUG
80#endif 85#endif
81#if ((__GNUC__ \ 86#if ((__GNUC__ \
82 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ 87 ? (defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
88 && !defined __PCC__) \
83 : (199901L <= __STDC_VERSION__ \ 89 : (199901L <= __STDC_VERSION__ \
84 && !defined __HP_cc \ 90 && !defined __HP_cc \
85 && !defined __PGI \ 91 && !defined __PGI \
@@ -89,6 +95,7 @@ AC_DEFUN([gl_EXTERN_INLINE],
89# define _GL_EXTERN_INLINE extern inline 95# define _GL_EXTERN_INLINE extern inline
90# define _GL_EXTERN_INLINE_IN_USE 96# define _GL_EXTERN_INLINE_IN_USE
91#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 97#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
98 && !defined __PCC__ \
92 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) 99 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
93# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ 100# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
94 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ 101 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
@@ -107,8 +114,8 @@ AC_DEFUN([gl_EXTERN_INLINE],
107 suppress bogus "no previous prototype for 'FOO'" 114 suppress bogus "no previous prototype for 'FOO'"
108 and "no previous declaration for 'FOO'" diagnostics, 115 and "no previous declaration for 'FOO'" diagnostics,
109 when FOO is an inline function in the header; see 116 when FOO is an inline function in the header; see
110 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and 117 <https://gcc.gnu.org/PR54113> and
111 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */ 118 <https://gcc.gnu.org/PR63877>. */
112#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ 119#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
113# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 120# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
114# define _GL_INLINE_HEADER_CONST_PRAGMA 121# define _GL_INLINE_HEADER_CONST_PRAGMA
diff --git a/gl/m4/fclose.m4 b/gl/m4/fclose.m4
new file mode 100644
index 00000000..65eb7705
--- /dev/null
+++ b/gl/m4/fclose.m4
@@ -0,0 +1,100 @@
1# fclose.m4
2# serial 12
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_FUNC_FCLOSE],
10[
11 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST])
13
14 gl_FUNC_FFLUSH_STDIN
15 case "$gl_cv_func_fflush_stdin" in
16 *yes) ;;
17 *) REPLACE_FCLOSE=1 ;;
18 esac
19
20 AC_REQUIRE([gl_FUNC_CLOSE])
21 if test $REPLACE_CLOSE = 1; then
22 REPLACE_FCLOSE=1
23 fi
24
25 case "$host_os" in
26 openedition) REPLACE_FCLOSE=1 ;;
27 esac
28
29 if test $REPLACE_FCLOSE = 0; then
30 gl_FUNC_FCLOSE_STDIN
31 case "$gl_cv_func_fclose_stdin" in
32 *yes) ;;
33 *) REPLACE_FCLOSE=1 ;;
34 esac
35 fi
36])
37
38dnl Determine whether fclose works on input streams.
39dnl Sets gl_cv_func_fclose_stdin.
40
41AC_DEFUN([gl_FUNC_FCLOSE_STDIN],
42[
43 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
44 AC_CHECK_HEADERS_ONCE([unistd.h])
45 AC_CACHE_CHECK([whether fclose works on input streams],
46 [gl_cv_func_fclose_stdin],
47 [echo hello world > conftest.txt
48 AC_RUN_IFELSE(
49 [AC_LANG_PROGRAM(
50 [[#include <fcntl.h>
51 #include <stdio.h>
52 #if HAVE_UNISTD_H
53 # include <unistd.h>
54 #else /* on Windows with MSVC */
55 # include <io.h>
56 #endif
57 ]GL_MDA_DEFINES],
58 [[int fd;
59 int fd2;
60 FILE *fp;
61 fd = open ("conftest.txt", O_RDONLY);
62 if (fd < 0)
63 return 1;
64 if (lseek (fd, 1, SEEK_SET) != 1)
65 return 2;
66 fd2 = dup (fd);
67 if (fd2 < 0)
68 return 3;
69 fp = fdopen (fd2, "r");
70 if (fp == NULL)
71 return 4;
72 if (fgetc (fp) != 'e')
73 { fclose (fp); return 5; }
74 /* This fclose() call should reposition the underlying file
75 descriptor. */
76 if (fclose (fp) != 0)
77 return 6;
78 if (lseek (fd2, 0, SEEK_CUR) != -1) /* should fail with EBADF */
79 return 7;
80 /* Verify the file position. */
81 if (lseek (fd, 0, SEEK_CUR) != 2)
82 return 8;
83 return 0;
84 ]])],
85 [gl_cv_func_fclose_stdin=yes],
86 [gl_cv_func_fclose_stdin=no],
87 [case "$host_os" in
88 # Guess no on glibc systems.
89 *-gnu* | gnu*) gl_cv_func_fclose_stdin="guessing no" ;;
90 # Guess yes on musl systems.
91 *-musl* | midipix*) gl_cv_func_fclose_stdin="guessing yes" ;;
92 # Guess no on native Windows.
93 mingw* | windows*) gl_cv_func_fclose_stdin="guessing no" ;;
94 # If we don't know, obey --enable-cross-guesses.
95 *) gl_cv_func_fclose_stdin="$gl_cross_guess_normal" ;;
96 esac
97 ])
98 rm conftest.txt
99 ])
100])
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 59d558bd..a94fc557 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,14 +1,17 @@
1# fcntl-o.m4 serial 7 1# fcntl-o.m4
2dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc. 2# serial 12
3dnl Copyright (C) 2006, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Written by Paul Eggert. 9dnl Written by Paul Eggert.
8 10
9AC_PREREQ([2.60]) 11AC_PREREQ([2.60])
10 12
11# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. 13# Test whether the flags O_DIRECTORY, O_NOATIME and O_NOFOLLOW actually work.
14# Define HAVE_WORKING_O_DIRECTORY to 1 if O_DIRECTORY works, or to 0 otherwise.
12# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. 15# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
13# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. 16# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
14AC_DEFUN([gl_FCNTL_O_FLAGS], 17AC_DEFUN([gl_FCNTL_O_FLAGS],
@@ -29,16 +32,23 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
29 #else /* on Windows with MSVC */ 32 #else /* on Windows with MSVC */
30 # include <io.h> 33 # include <io.h>
31 # include <stdlib.h> 34 # include <stdlib.h>
32 # defined sleep(n) _sleep ((n) * 1000) 35 # define sleep(n) _sleep ((n) * 1000)
33 #endif 36 #endif
37 #include <errno.h>
34 #include <fcntl.h> 38 #include <fcntl.h>
35 ]GL_MDA_DEFINES[ 39 ]GL_MDA_DEFINES[
40 #ifndef O_DIRECTORY
41 #define O_DIRECTORY 0
42 #endif
36 #ifndef O_NOATIME 43 #ifndef O_NOATIME
37 #define O_NOATIME 0 44 #define O_NOATIME 0
38 #endif 45 #endif
39 #ifndef O_NOFOLLOW 46 #ifndef O_NOFOLLOW
40 #define O_NOFOLLOW 0 47 #define O_NOFOLLOW 0
41 #endif 48 #endif
49 #ifndef O_SEARCH
50 #define O_SEARCH O_RDONLY
51 #endif
42 static int const constants[] = 52 static int const constants[] =
43 { 53 {
44 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, 54 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
@@ -51,31 +61,38 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
51 { 61 {
52 static char const sym[] = "conftest.sym"; 62 static char const sym[] = "conftest.sym";
53 if (symlink ("/dev/null", sym) != 0) 63 if (symlink ("/dev/null", sym) != 0)
54 result |= 2; 64 result |= 1;
55 else 65 else
56 { 66 {
57 int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0); 67 int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0);
58 if (fd >= 0) 68 if (fd >= 0)
59 { 69 {
60 close (fd); 70 close (fd);
61 result |= 4; 71 result |= 3;
62 } 72 }
63 } 73 }
64 if (unlink (sym) != 0 || symlink (".", sym) != 0) 74 if (unlink (sym) != 0 || symlink (".", sym) != 0)
65 result |= 2; 75 result |= 1;
66 else 76 else
67 { 77 {
68 int fd = open (sym, O_RDONLY | O_NOFOLLOW); 78 int fd = open (sym, O_RDONLY | O_NOFOLLOW);
69 if (fd >= 0) 79 if (fd >= 0)
70 { 80 {
71 close (fd); 81 close (fd);
72 result |= 4; 82 result |= 3;
73 } 83 }
74 } 84 }
75 unlink (sym); 85 unlink (sym);
76 } 86 }
77 #endif 87 #endif
78 { 88 {
89 int fd = open ("confdefs.h", O_SEARCH | O_DIRECTORY);
90 if (!(fd < 0 && errno == ENOTDIR))
91 result |= 4;
92 if (0 <= fd)
93 close (fd);
94 }
95 {
79 static char const file[] = "confdefs.h"; 96 static char const file[] = "confdefs.h";
80 int fd = open (file, O_RDONLY | O_NOATIME); 97 int fd = open (file, O_RDONLY | O_NOATIME);
81 if (fd < 0) 98 if (fd < 0)
@@ -110,31 +127,46 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
110 } 127 }
111 return result;]])], 128 return result;]])],
112 [gl_cv_header_working_fcntl_h=yes], 129 [gl_cv_header_working_fcntl_h=yes],
113 [case $? in #( 130 [AS_CASE([$?],
114 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 131 dnl We cannot catch exit code 1 or 2 here, because
115 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 132 dnl - exit code 1 can occur through a compilation error on mingw (e.g.
116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 133 dnl when O_NOCTTY, O_NONBLOCK, O_SYNC are not defined) or when
117 *) gl_cv_header_working_fcntl_h='no';; 134 dnl result = 1, whereas
118 esac], 135 dnl - exit code 2 can occur through a compilation error on MSVC (e.g.
119 [case "$host_os" in 136 dnl again when O_NOCTTY, O_NONBLOCK, O_SYNC are not defined) or when
120 # Guess 'no' on native Windows. 137 dnl result = 2.
121 mingw*) gl_cv_header_working_fcntl_h='no' ;; 138 [ 3], [gl_cv_header_working_fcntl_h="no (bad O_NOFOLLOW)"],
122 *) gl_cv_header_working_fcntl_h=cross-compiling ;; 139 [ 4], [gl_cv_header_working_fcntl_h="no (bad O_DIRECTORY)"],
123 esac 140 [ 7], [gl_cv_header_working_fcntl_h="no (bad O_NOFOLLOW, O_DIRECTORY)"],
124 ]) 141 [64], [gl_cv_header_working_fcntl_h="no (bad O_NOATIME)"],
125 ]) 142 [67], [gl_cv_header_working_fcntl_h="no (bad O_NOFOLLOW, O_NOATIME)"],
143 [68], [gl_cv_header_working_fcntl_h="no (bad O_DIRECTORY, O_NOATIME)"],
144 [71], [gl_cv_header_working_fcntl_h="no (bad O_NOFOLLOW, O_DIRECTORY, O_NOATIME)"],
145 [gl_cv_header_working_fcntl_h="no"])],
146 [AS_CASE([$host_os,$gl_cross_guess_normal],
147 # The O_DIRECTORY test is known to fail on Mac OS X 10.4.11 (2007)
148 # (see <https://bugs.gnu.org/78509#95>)
149 # and to succeed on Mac OS X 10.5.8 [darwin9.8.0] (2009).
150 # Guess it fails on Mac OS X 10.4.x and earlier.
151 [darwin[[0-8]].*yes],
152 [gl_cv_header_working_fcntl_h="guessing no (bad O_DIRECTORY)"],
153 # Known to be "no" on native MS-Windows.
154 [mingw* | windows*],
155 [gl_cv_header_working_fcntl_h=no],
156 [gl_cv_header_working_fcntl_h=$gl_cross_guess_normal])])])
157
158 AS_CASE([$gl_cv_header_working_fcntl_h],
159 [*O_DIRECTORY* | *no], [gl_val=0], [gl_val=1])
160 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_DIRECTORY], [$gl_val],
161 [Define to 1 if O_DIRECTORY works, 0 otherwise.])
126 162
127 case $gl_cv_header_working_fcntl_h in #( 163 AS_CASE([$gl_cv_header_working_fcntl_h],
128 *O_NOATIME* | no | cross-compiling) ac_val=0;; #( 164 [*O_NOATIME* | *no], [gl_val=0], [gl_val=1])
129 *) ac_val=1;; 165 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$gl_val],
130 esac 166 [Define to 1 if O_NOATIME works, 0 otherwise.])
131 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
132 [Define to 1 if O_NOATIME works.])
133 167
134 case $gl_cv_header_working_fcntl_h in #( 168 AS_CASE([$gl_cv_header_working_fcntl_h],
135 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( 169 [*O_NOFOLLOW* | *no], [gl_val=0], [gl_val=1])
136 *) ac_val=1;; 170 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$gl_val],
137 esac 171 [Define to 1 if O_NOFOLLOW works, 0 otherwise.])
138 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
139 [Define to 1 if O_NOFOLLOW works.])
140]) 172])
diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4
index 524a99af..69ac76f9 100644
--- a/gl/m4/fcntl.m4
+++ b/gl/m4/fcntl.m4
@@ -1,8 +1,10 @@
1# fcntl.m4 serial 11 1# fcntl.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 12
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# For now, this module ensures that fcntl() 9# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly 10# - supports F_DUPFD correctly
@@ -82,7 +84,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
82 esac 84 esac
83 85
84 dnl Many systems lack F_DUPFD_CLOEXEC. 86 dnl Many systems lack F_DUPFD_CLOEXEC.
85 dnl NetBSD 9.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD. 87 dnl NetBSD 10.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD.
86 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC], 88 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
87 [gl_cv_func_fcntl_f_dupfd_cloexec], 89 [gl_cv_func_fcntl_f_dupfd_cloexec],
88 [AC_RUN_IFELSE( 90 [AC_RUN_IFELSE(
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
index 68f4e648..946a0bd6 100644
--- a/gl/m4/fcntl_h.m4
+++ b/gl/m4/fcntl_h.m4
@@ -1,9 +1,12 @@
1# serial 20 1# fcntl_h.m4
2# Configure fcntl.h. 2# serial 21
3dnl Copyright (C) 2006-2007, 2009-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2006-2007, 2009-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# Configure fcntl.h.
7 10
8dnl Written by Paul Eggert. 11dnl Written by Paul Eggert.
9 12
@@ -23,7 +26,7 @@ AC_DEFUN_ONCE([gl_FCNTL_H],
23 dnl corresponding gnulib module is not in use, if it is not common 26 dnl corresponding gnulib module is not in use, if it is not common
24 dnl enough to be declared everywhere. 27 dnl enough to be declared everywhere.
25 gl_WARN_ON_USE_PREPARE([[#include <fcntl.h> 28 gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
26 ]], [fcntl openat]) 29 ]], [fcntl openat openat2])
27]) 30])
28 31
29# gl_FCNTL_MODULE_INDICATOR([modulename]) 32# gl_FCNTL_MODULE_INDICATOR([modulename])
@@ -50,6 +53,7 @@ AC_DEFUN([gl_FCNTL_H_REQUIRE_DEFAULTS],
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING]) 53 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING])
51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN]) 54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN])
52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT]) 55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT])
56 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT2])
53 dnl Support Microsoft deprecated alias function names by default. 57 dnl Support Microsoft deprecated alias function names by default.
54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1]) 58 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1])
55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1]) 59 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1])
@@ -63,6 +67,7 @@ AC_DEFUN([gl_FCNTL_H_DEFAULTS],
63 dnl Assume proper GNU behavior unless another module says otherwise. 67 dnl Assume proper GNU behavior unless another module says otherwise.
64 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL]) 68 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
65 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT]) 69 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
70 HAVE_OPENAT2=0; AC_SUBST([HAVE_OPENAT2])
66 REPLACE_CREAT=0; AC_SUBST([REPLACE_CREAT]) 71 REPLACE_CREAT=0; AC_SUBST([REPLACE_CREAT])
67 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL]) 72 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
68 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN]) 73 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4
index 3e3c8903..c5913b23 100644
--- a/gl/m4/fflush.m4
+++ b/gl/m4/fflush.m4
@@ -1,9 +1,10 @@
1# fflush.m4 serial 18 1# fflush.m4
2 2# serial 20
3# Copyright (C) 2007-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8dnl From Eric Blake 9dnl From Eric Blake
9 10
@@ -79,9 +80,10 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
79 [gl_cv_func_fflush_stdin=yes], 80 [gl_cv_func_fflush_stdin=yes],
80 [gl_cv_func_fflush_stdin=no], 81 [gl_cv_func_fflush_stdin=no],
81 [case "$host_os" in 82 [case "$host_os" in
82 # Guess no on native Windows. 83 # Guess no on NetBSD, OpenBSD, native Windows.
83 mingw*) gl_cv_func_fflush_stdin="guessing no" ;; 84 netbsd* | openbsd* | mingw* | windows*)
84 *) gl_cv_func_fflush_stdin=cross ;; 85 gl_cv_func_fflush_stdin="guessing no" ;;
86 *) gl_cv_func_fflush_stdin=cross ;;
85 esac 87 esac
86 ]) 88 ])
87 rm conftest.txt 89 rm conftest.txt
@@ -92,8 +94,8 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
92 *) gl_func_fflush_stdin='(-1)' ;; 94 *) gl_func_fflush_stdin='(-1)' ;;
93 esac 95 esac
94 AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin], 96 AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin],
95 [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008, 97 [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008
96 0 if fflush is known to not work, -1 if unknown.]) 98 or later, 0 if fflush is known to not work, -1 if unknown.])
97]) 99])
98 100
99# Prerequisites of lib/fflush.c. 101# Prerequisites of lib/fflush.c.
diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4
index 2f0c9c4e..c0ee7f8f 100644
--- a/gl/m4/float_h.m4
+++ b/gl/m4/float_h.m4
@@ -1,8 +1,10 @@
1# float_h.m4 serial 13 1# float_h.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 17
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FLOAT_H], 9AC_DEFUN([gl_FLOAT_H],
8[ 10[
@@ -11,7 +13,7 @@ AC_DEFUN([gl_FLOAT_H],
11 GL_GENERATE_FLOAT_H=false 13 GL_GENERATE_FLOAT_H=false
12 REPLACE_FLOAT_LDBL=0 14 REPLACE_FLOAT_LDBL=0
13 case "$host_os" in 15 case "$host_os" in
14 aix* | beos* | openbsd* | mirbsd* | irix*) 16 aix* | beos* | openbsd* | mirbsd*)
15 GL_GENERATE_FLOAT_H=true 17 GL_GENERATE_FLOAT_H=true
16 ;; 18 ;;
17 freebsd* | dragonfly*) 19 freebsd* | dragonfly*)
@@ -53,6 +55,32 @@ changequote([,])dnl
53 ;; 55 ;;
54 esac 56 esac
55 57
58 dnl Test for completeness w.r.t. ISO C 23.
59 REPLACE_FLOAT_SNAN=0
60 AC_CACHE_CHECK([whether float.h conforms to ISO C23],
61 [gl_cv_header_float_h_isoc23],
62 [AC_COMPILE_IFELSE(
63 [AC_LANG_PROGRAM(
64 [[#include <float.h>
65 int x[] = { FLT_DECIMAL_DIG, DBL_DECIMAL_DIG, LDBL_DECIMAL_DIG };
66 int y[] = { FLT_IS_IEC_60559, DBL_IS_IEC_60559, LDBL_IS_IEC_60559 };
67 float maxf = FLT_NORM_MAX;
68 double maxd = DBL_NORM_MAX;
69 long double maxl = LDBL_NORM_MAX;
70 ]],
71 [[float sf = FLT_SNAN;
72 double sd = DBL_SNAN;
73 long double sl = LDBL_SNAN;
74 return (sf != 0) + (sd != 0) + (sl != 0);
75 ]])],
76 [gl_cv_header_float_h_isoc23=yes],
77 [gl_cv_header_float_h_isoc23=no])
78 ])
79 if test $gl_cv_header_float_h_isoc23 != yes; then
80 GL_GENERATE_FLOAT_H=true
81 REPLACE_FLOAT_SNAN=1
82 fi
83
56 dnl Test against glibc-2.7 Linux/SPARC64 bug. 84 dnl Test against glibc-2.7 Linux/SPARC64 bug.
57 REPLACE_ITOLD=0 85 REPLACE_ITOLD=0
58 AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works], 86 AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
@@ -84,9 +112,11 @@ int main ()
84 [gl_cv_func_itold_works="guessing no"], 112 [gl_cv_func_itold_works="guessing no"],
85 [gl_cv_func_itold_works="guessing yes"]) 113 [gl_cv_func_itold_works="guessing yes"])
86 ;; 114 ;;
87 # Guess yes on native Windows. 115 # Guess yes on native Windows.
88 mingw*) gl_cv_func_itold_works="guessing yes" ;; 116 mingw* | windows*)
89 *) gl_cv_func_itold_works="guessing yes" ;; 117 gl_cv_func_itold_works="guessing yes" ;;
118 *)
119 gl_cv_func_itold_works="guessing yes" ;;
90 esac 120 esac
91 ]) 121 ])
92 ]) 122 ])
diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4
index c49ffa6b..731f0b0a 100644
--- a/gl/m4/floorf.m4
+++ b/gl/m4/floorf.m4
@@ -1,8 +1,10 @@
1# floorf.m4 serial 18 1# floorf.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 21
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FLOORF], 9AC_DEFUN([gl_FUNC_FLOORF],
8[ 10[
@@ -26,7 +28,7 @@ AC_DEFUN([gl_FUNC_FLOORF],
26 AC_CACHE_CHECK([whether floorf works according to ISO C 99 with IEC 60559], 28 AC_CACHE_CHECK([whether floorf works according to ISO C 99 with IEC 60559],
27 [gl_cv_func_floorf_ieee], 29 [gl_cv_func_floorf_ieee],
28 [ 30 [
29 save_LIBS="$LIBS" 31 saved_LIBS="$LIBS"
30 LIBS="$LIBS $FLOORF_LIBM" 32 LIBS="$LIBS $FLOORF_LIBM"
31 AC_RUN_IFELSE( 33 AC_RUN_IFELSE(
32 [AC_LANG_SOURCE([[ 34 [AC_LANG_SOURCE([[
@@ -49,17 +51,17 @@ int main (int argc, char *argv[])
49 [gl_cv_func_floorf_ieee=yes], 51 [gl_cv_func_floorf_ieee=yes],
50 [gl_cv_func_floorf_ieee=no], 52 [gl_cv_func_floorf_ieee=no],
51 [case "$host_os" in 53 [case "$host_os" in
52 # Guess yes on glibc systems. 54 # Guess yes on glibc systems.
53 *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;; 55 *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;;
54 # Guess yes on musl systems. 56 # Guess yes on musl systems.
55 *-musl*) gl_cv_func_floorf_ieee="guessing yes" ;; 57 *-musl* | midipix*) gl_cv_func_floorf_ieee="guessing yes" ;;
56 # Guess yes on native Windows. 58 # Guess yes on native Windows.
57 mingw*) gl_cv_func_floorf_ieee="guessing yes" ;; 59 mingw* | windows*) gl_cv_func_floorf_ieee="guessing yes" ;;
58 # If we don't know, obey --enable-cross-guesses. 60 # If we don't know, obey --enable-cross-guesses.
59 *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;; 61 *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;;
60 esac 62 esac
61 ]) 63 ])
62 LIBS="$save_LIBS" 64 LIBS="$saved_LIBS"
63 ]) 65 ])
64 case "$gl_cv_func_floorf_ieee" in 66 case "$gl_cv_func_floorf_ieee" in
65 *yes) ;; 67 *yes) ;;
@@ -94,7 +96,7 @@ AC_DEFUN([gl_FUNC_FLOORF_LIBS],
94 [[x = funcptr(x) + floorf(x);]])], 96 [[x = funcptr(x) + floorf(x);]])],
95 [gl_cv_func_floorf_libm=]) 97 [gl_cv_func_floorf_libm=])
96 if test "$gl_cv_func_floorf_libm" = "?"; then 98 if test "$gl_cv_func_floorf_libm" = "?"; then
97 save_LIBS="$LIBS" 99 saved_LIBS="$LIBS"
98 LIBS="$LIBS -lm" 100 LIBS="$LIBS -lm"
99 AC_LINK_IFELSE( 101 AC_LINK_IFELSE(
100 [AC_LANG_PROGRAM( 102 [AC_LANG_PROGRAM(
@@ -106,7 +108,7 @@ AC_DEFUN([gl_FUNC_FLOORF_LIBS],
106 float x;]], 108 float x;]],
107 [[x = funcptr(x) + floorf(x);]])], 109 [[x = funcptr(x) + floorf(x);]])],
108 [gl_cv_func_floorf_libm="-lm"]) 110 [gl_cv_func_floorf_libm="-lm"])
109 LIBS="$save_LIBS" 111 LIBS="$saved_LIBS"
110 fi 112 fi
111 ]) 113 ])
112 FLOORF_LIBM="$gl_cv_func_floorf_libm" 114 FLOORF_LIBM="$gl_cv_func_floorf_libm"
diff --git a/gl/m4/fopen.m4 b/gl/m4/fopen.m4
index 9c39ff72..07779a16 100644
--- a/gl/m4/fopen.m4
+++ b/gl/m4/fopen.m4
@@ -1,15 +1,17 @@
1# fopen.m4 serial 13 1# fopen.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 16
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FOPEN], 9AC_DEFUN([gl_FUNC_FOPEN_ITSELF],
8[ 10[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
11 case "$host_os" in 13 case "$host_os" in
12 mingw* | pw*) 14 mingw* | windows* | pw*)
13 dnl Replace fopen, for handling of "/dev/null". 15 dnl Replace fopen, for handling of "/dev/null".
14 REPLACE_FOPEN=1 16 REPLACE_FOPEN=1
15 dnl fopen on mingw also has the trailing slash bug. 17 dnl fopen on mingw also has the trailing slash bug.
@@ -58,6 +60,15 @@ changequote([,])dnl
58 esac 60 esac
59]) 61])
60 62
63AC_DEFUN([gl_FUNC_FOPEN],
64[
65 AC_REQUIRE([gl_FUNC_FOPEN_ITSELF])
66 AC_REQUIRE([gl_FUNC_FCLOSE])
67 if test $REPLACE_FCLOSE = 1; then
68 REPLACE_FOPEN=1
69 fi
70])
71
61AC_DEFUN([gl_FUNC_FOPEN_GNU], 72AC_DEFUN([gl_FUNC_FOPEN_GNU],
62[ 73[
63 AC_REQUIRE([gl_FUNC_FOPEN]) 74 AC_REQUIRE([gl_FUNC_FOPEN])
@@ -87,7 +98,7 @@ int main ()
87 [gl_cv_func_fopen_mode_x=no], 98 [gl_cv_func_fopen_mode_x=no],
88 [case "$host_os" in 99 [case "$host_os" in
89 # Guess yes on glibc and musl systems. 100 # Guess yes on glibc and musl systems.
90 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*) 101 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl* | midipix*)
91 gl_cv_func_fopen_mode_x="guessing yes" ;; 102 gl_cv_func_fopen_mode_x="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses. 103 # If we don't know, obey --enable-cross-guesses.
93 *) 104 *)
@@ -124,10 +135,10 @@ int main ()
124 [gl_cv_func_fopen_mode_e=no], 135 [gl_cv_func_fopen_mode_e=no],
125 [case "$host_os" in 136 [case "$host_os" in
126 # Guess yes on glibc and musl systems. 137 # Guess yes on glibc and musl systems.
127 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*) 138 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl* | midipix*)
128 gl_cv_func_fopen_mode_e="guessing yes" ;; 139 gl_cv_func_fopen_mode_e="guessing yes" ;;
129 # Guess no on native Windows. 140 # Guess no on native Windows.
130 mingw*) 141 mingw* | windows*)
131 gl_cv_func_fopen_mode_e="guessing no" ;; 142 gl_cv_func_fopen_mode_e="guessing no" ;;
132 # If we don't know, obey --enable-cross-guesses. 143 # If we don't know, obey --enable-cross-guesses.
133 *) 144 *)
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
index b365409d..a7cf67dc 100644
--- a/gl/m4/fpurge.m4
+++ b/gl/m4/fpurge.m4
@@ -1,64 +1,65 @@
1# fpurge.m4 serial 12 1# fpurge.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 16
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FPURGE], 9AC_DEFUN([gl_FUNC_FPURGE],
8[ 10[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 AC_CHECK_HEADERS_ONCE([stdio_ext.h]) 12 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
12 AC_CHECK_FUNCS_ONCE([fpurge]) 13 AC_CHECK_FUNCS_ONCE([fpurge])
13 AC_CHECK_FUNCS_ONCE([__fpurge]) 14 gl_CHECK_FUNCS_ANDROID([__fpurge], [[#include <stdio_ext.h>]])
14 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]]) 15 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
15 if test "x$ac_cv_func_fpurge" = xyes; then 16 if test $ac_cv_func_fpurge = yes; then
16 HAVE_FPURGE=1 17 HAVE_FPURGE=1
17 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune. 18 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune.
18 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works], 19 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
19 [AC_RUN_IFELSE( 20 [if test $ac_cv_have_decl_fpurge = yes; then
20 [AC_LANG_PROGRAM( 21 AC_RUN_IFELSE(
21 [[#include <stdio.h> 22 [AC_LANG_PROGRAM(
22]], 23 [[#include <stdio.h>
23 [[FILE *f = fopen ("conftest.txt", "w+"); 24 ]],
24 if (!f) 25 [[FILE *f = fopen ("conftest.txt", "w+");
25 return 1; 26 if (!f)
26 if (fputc ('a', f) != 'a') 27 return 1;
27 { fclose (f); return 2; } 28 if (fputc ('a', f) != 'a')
28 rewind (f); 29 { fclose (f); return 2; }
29 if (fgetc (f) != 'a') 30 rewind (f);
30 { fclose (f); return 3; } 31 if (fgetc (f) != 'a')
31 if (fgetc (f) != EOF) 32 { fclose (f); return 3; }
32 { fclose (f); return 4; } 33 if (fgetc (f) != EOF)
33 if (fpurge (f) != 0) 34 { fclose (f); return 4; }
34 { fclose (f); return 5; } 35 if (fpurge (f) != 0)
35 if (putc ('b', f) != 'b') 36 { fclose (f); return 5; }
36 { fclose (f); return 6; } 37 if (putc ('b', f) != 'b')
37 if (fclose (f) != 0) 38 { fclose (f); return 6; }
38 return 7; 39 if (fclose (f) != 0)
39 if ((f = fopen ("conftest.txt", "r")) == NULL) 40 return 7;
40 return 8; 41 if ((f = fopen ("conftest.txt", "r")) == NULL)
41 if (fgetc (f) != 'a') 42 return 8;
42 { fclose (f); return 9; } 43 if (fgetc (f) != 'a')
43 if (fgetc (f) != 'b') 44 { fclose (f); return 9; }
44 { fclose (f); return 10; } 45 if (fgetc (f) != 'b')
45 if (fgetc (f) != EOF) 46 { fclose (f); return 10; }
46 { fclose (f); return 11; } 47 if (fgetc (f) != EOF)
47 if (fclose (f) != 0) 48 { fclose (f); return 11; }
48 return 12; 49 if (fclose (f) != 0)
49 if (remove ("conftest.txt") != 0) 50 return 12;
50 return 13; 51 if (remove ("conftest.txt") != 0)
51 return 0; 52 return 13;
52 ]])], 53 return 0;
53 [gl_cv_func_fpurge_works=yes], 54 ]])],
54 [gl_cv_func_fpurge_works=no], 55 [gl_cv_func_fpurge_works=yes],
55 [case "$host_os" in 56 [gl_cv_func_fpurge_works=no],
56 # Guess yes on musl systems. 57 [# Obey --enable-cross-guesses.
57 *-musl*) gl_cv_func_fpurge_works="guessing yes" ;; 58 gl_cv_func_fpurge_works="$gl_cross_guess_normal"
58 # Otherwise obey --enable-cross-guesses. 59 ])
59 *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;; 60 else
60 esac 61 gl_cv_func_fpurge_works=no
61 ]) 62 fi
62 ]) 63 ])
63 case "$gl_cv_func_fpurge_works" in 64 case "$gl_cv_func_fpurge_works" in
64 *yes) ;; 65 *yes) ;;
diff --git a/gl/m4/freading.m4 b/gl/m4/freading.m4
index 35333369..b5b54f40 100644
--- a/gl/m4/freading.m4
+++ b/gl/m4/freading.m4
@@ -1,11 +1,16 @@
1# freading.m4 serial 2 1# freading.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 3
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FREADING], 9AC_DEFUN([gl_FUNC_FREADING],
8[ 10[
9 AC_CHECK_HEADERS_ONCE([stdio_ext.h]) 11 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
10 AC_CHECK_FUNCS_ONCE([__freading]) 12 gl_CHECK_FUNCS_ANDROID([__freading],
13 [[#include <stdio.h>
14 #include <stdio_ext.h>
15 ]])
11]) 16])
diff --git a/gl/m4/free.m4 b/gl/m4/free.m4
index 0389dea3..c7a134ba 100644
--- a/gl/m4/free.m4
+++ b/gl/m4/free.m4
@@ -1,8 +1,10 @@
1# free.m4 serial 6 1# free.m4
2# Copyright (C) 2003-2005, 2009-2023 Free Software Foundation, Inc. 2# serial 6
3# This file is free software; the Free Software Foundation 3dnl Copyright (C) 2003-2005, 2009-2026 Free Software Foundation, Inc.
4# gives unlimited permission to copy and/or distribute it, 4dnl This file is free software; the Free Software Foundation
5# with or without modifications, as long as this notice is preserved. 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# Written by Paul Eggert and Bruno Haible. 9# Written by Paul Eggert and Bruno Haible.
8 10
@@ -12,10 +14,10 @@ AC_DEFUN([gl_FUNC_FREE],
12 14
13 dnl In the next release of POSIX, free must preserve errno. 15 dnl In the next release of POSIX, free must preserve errno.
14 dnl https://www.austingroupbugs.net/view.php?id=385 16 dnl https://www.austingroupbugs.net/view.php?id=385
15 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924 17 dnl https://sourceware.org/PR17924
16 dnl So far, we know of three platforms that do this: 18 dnl So far, we know of three platforms that do this:
17 dnl * glibc >= 2.33, thanks to the fix for this bug: 19 dnl * glibc >= 2.33, thanks to the fix for this bug:
18 dnl <https://sourceware.org/bugzilla/show_bug.cgi?id=17924> 20 dnl <https://sourceware.org/PR17924>
19 dnl * OpenBSD >= 4.5, thanks to this commit: 21 dnl * OpenBSD >= 4.5, thanks to this commit:
20 dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h> 22 dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h>
21 dnl * Solaris, because its malloc() implementation is based on brk(), 23 dnl * Solaris, because its malloc() implementation is based on brk(),
diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4
index c5fe688c..398fd5f8 100644
--- a/gl/m4/fseek.m4
+++ b/gl/m4/fseek.m4
@@ -1,8 +1,10 @@
1# fseek.m4 serial 4 1# fseek.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 4
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FSEEK], 9AC_DEFUN([gl_FUNC_FSEEK],
8[ 10[
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
index 05ee06bc..cd81961a 100644
--- a/gl/m4/fseeko.m4
+++ b/gl/m4/fseeko.m4
@@ -1,8 +1,10 @@
1# fseeko.m4 serial 20 1# fseeko.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 21
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FSEEKO], 9AC_DEFUN([gl_FUNC_FSEEKO],
8[ 10[
@@ -68,6 +70,10 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
68# Prerequisites of lib/fseeko.c. 70# Prerequisites of lib/fseeko.c.
69AC_DEFUN([gl_PREREQ_FSEEKO], 71AC_DEFUN([gl_PREREQ_FSEEKO],
70[ 72[
73 if test $gl_cv_func_fseeko != no; then
74 AC_DEFINE([HAVE_FSEEKO], [1],
75 [Define to 1 if the system has the fseeko function.])
76 fi
71 dnl Native Windows has the function _fseeki64. mingw hides it in some 77 dnl Native Windows has the function _fseeki64. mingw hides it in some
72 dnl circumstances, but mingw64 makes it usable again. 78 dnl circumstances, but mingw64 makes it usable again.
73 AC_CHECK_FUNCS([_fseeki64]) 79 AC_CHECK_FUNCS([_fseeki64])
diff --git a/gl/m4/fseterr.m4 b/gl/m4/fseterr.m4
new file mode 100644
index 00000000..e5ad635b
--- /dev/null
+++ b/gl/m4/fseterr.m4
@@ -0,0 +1,15 @@
1# fseterr.m4
2# serial 2
3dnl Copyright (C) 2012-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_FSETERR],
10[
11 gl_CHECK_FUNCS_ANDROID([__fseterr],
12 [[#include <stdio.h>
13 #include <stdio_ext.h>
14 ]])
15])
diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4
index 7cb2edb0..7db4e346 100644
--- a/gl/m4/fstat.m4
+++ b/gl/m4/fstat.m4
@@ -1,8 +1,10 @@
1# fstat.m4 serial 8 1# fstat.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 10
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FSTAT], 9AC_DEFUN([gl_FUNC_FSTAT],
8[ 10[
@@ -10,10 +12,10 @@ AC_DEFUN([gl_FUNC_FSTAT],
10 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) 12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
11 13
12 case "$host_os" in 14 case "$host_os" in
13 mingw* | solaris*) 15 darwin* | mingw* | windows* | solaris*)
16 dnl macOS and Solaris stat can return a negative tv_nsec.
14 dnl On MinGW, the original stat() returns st_atime, st_mtime, 17 dnl On MinGW, the original stat() returns st_atime, st_mtime,
15 dnl st_ctime values that are affected by the time zone. 18 dnl st_ctime values that are affected by the time zone.
16 dnl Solaris stat can return a negative tv_nsec.
17 REPLACE_FSTAT=1 19 REPLACE_FSTAT=1
18 ;; 20 ;;
19 esac 21 esac
diff --git a/gl/m4/fstypename.m4 b/gl/m4/fstypename.m4
index f65c459f..64122a73 100644
--- a/gl/m4/fstypename.m4
+++ b/gl/m4/fstypename.m4
@@ -1,4 +1,11 @@
1#serial 6 1# fstypename.m4
2# serial 6
3dnl Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2026 Free Software
4dnl Foundation, Inc.
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
2 9
3dnl From Jim Meyering. 10dnl From Jim Meyering.
4dnl 11dnl
@@ -6,12 +13,6 @@ dnl See if struct statfs has the f_fstypename member.
6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. 13dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
7dnl 14dnl
8 15
9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2023 Free Software
10# Foundation, Inc.
11# This file is free software; the Free Software Foundation
12# gives unlimited permission to copy and/or distribute it,
13# with or without modifications, as long as this notice is preserved.
14
15AC_DEFUN([gl_FSTYPENAME], 16AC_DEFUN([gl_FSTYPENAME],
16[ 17[
17 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,, 18 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4
index 88f3ca81..db6e0e3b 100644
--- a/gl/m4/fsusage.m4
+++ b/gl/m4/fsusage.m4
@@ -1,11 +1,13 @@
1# serial 35 1# fsusage.m4
2# Obtaining file system usage information. 2# serial 37
3dnl Copyright (C) 1997-1998, 2000-2001, 2003-2026 Free Software Foundation,
4dnl Inc.
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
3 9
4# Copyright (C) 1997-1998, 2000-2001, 2003-2023 Free Software Foundation, Inc. 10# Obtaining file system usage information.
5#
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9 11
10# Written by Jim Meyering. 12# Written by Jim Meyering.
11 13
@@ -46,16 +48,12 @@ AC_DEFUN([gl_FILE_SYSTEM_USAGE],
46 # is what it gets when this test fails. 48 # is what it gets when this test fails.
47 if test $ac_fsusage_space = no; then 49 if test $ac_fsusage_space = no; then
48 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 50 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
49 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. 51 # OpenBSD >= 4.4, AIX, HP-UX, Solaris, Cygwin, Interix, BeOS.
50 AC_CACHE_CHECK([for statvfs function (SVR4)], 52 AC_CACHE_CHECK([for statvfs function (SVR4)],
51 [fu_cv_sys_stat_statvfs], 53 [fu_cv_sys_stat_statvfs],
52 [AC_LINK_IFELSE( 54 [AC_LINK_IFELSE(
53 [AC_LANG_PROGRAM([[ 55 [AC_LANG_PROGRAM([[
54#include <sys/types.h> 56#include <sys/types.h>
55#ifdef __osf__
56"Do not use Tru64's statvfs implementation"
57#endif
58
59#include <sys/statvfs.h> 57#include <sys/statvfs.h>
60 58
61struct statvfs fsd; 59struct statvfs fsd;
@@ -77,7 +75,7 @@ int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
77 if test $fu_cv_sys_stat_statvfs = yes; then 75 if test $fu_cv_sys_stat_statvfs = yes; then
78 ac_fsusage_space=yes 76 ac_fsusage_space=yes
79 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs. 77 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
80 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems 78 # glibc, HP-UX, Solaris have statvfs64 as well, but on these systems
81 # statvfs with large-file support is already equivalent to statvfs64. 79 # statvfs with large-file support is already equivalent to statvfs64.
82 AC_CACHE_CHECK([whether to use statvfs64], 80 AC_CACHE_CHECK([whether to use statvfs64],
83 [fu_cv_sys_stat_statvfs64], 81 [fu_cv_sys_stat_statvfs64],
@@ -139,37 +137,9 @@ int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
139 fi 137 fi
140 138
141 if test $ac_fsusage_space = no; then 139 if test $ac_fsusage_space = no; then
142 # DEC Alpha running OSF/1
143 AC_CACHE_CHECK([for 3-argument statfs function (DEC OSF/1)],
144 [fu_cv_sys_stat_statfs3_osf1],
145 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
146#include <sys/param.h>
147#include <sys/types.h>
148#include <sys/mount.h>
149 int
150 main ()
151 {
152 struct statfs fsd;
153 fsd.f_fsize = 0;
154 return statfs (".", &fsd, sizeof (struct statfs)) != 0;
155 }]])],
156 [fu_cv_sys_stat_statfs3_osf1=yes],
157 [fu_cv_sys_stat_statfs3_osf1=no],
158 [fu_cv_sys_stat_statfs3_osf1=no])
159 ])
160 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
161 ac_fsusage_space=yes
162 AC_DEFINE([STAT_STATFS3_OSF1], [1],
163 [Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
164 fi
165 fi
166
167 if test $ac_fsusage_space = no; then
168 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. 140 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
169 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 141 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
170 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) 142 # OpenBSD >= 4.4, AIX, HP-UX, Cygwin already handled above.)
171 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
172 # <sys/vfs.h>.)
173 # (On Solaris, statfs has 4 arguments.) 143 # (On Solaris, statfs has 4 arguments.)
174 AC_CACHE_CHECK([for two-argument statfs with statfs.f_bsize member (AIX, 4.3BSD)], 144 AC_CACHE_CHECK([for two-argument statfs with statfs.f_bsize member (AIX, 4.3BSD)],
175 [fu_cv_sys_stat_statfs2_bsize], 145 [fu_cv_sys_stat_statfs2_bsize],
@@ -223,13 +193,12 @@ int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
223 if test $fu_cv_sys_stat_statfs4 = yes; then 193 if test $fu_cv_sys_stat_statfs4 = yes; then
224 ac_fsusage_space=yes 194 ac_fsusage_space=yes
225 AC_DEFINE([STAT_STATFS4], [1], 195 AC_DEFINE([STAT_STATFS4], [1],
226 [Define if statfs takes 4 args. (SVR3, old Irix)]) 196 [Define if statfs takes 4 args. (SVR3)])
227 fi 197 fi
228 fi 198 fi
229 199
230 if test $ac_fsusage_space = no; then 200 if test $ac_fsusage_space = no; then
231 # 4.4BSD and older NetBSD 201 # 4.4BSD and older NetBSD
232 # (OSF/1 already handled above.)
233 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.) 202 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
234 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in 203 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
235 # <sys/mount.h>.) 204 # <sys/mount.h>.)
@@ -269,7 +238,7 @@ int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
269 238
270# Check for SunOS statfs brokenness wrt partitions 2GB and larger. 239# Check for SunOS statfs brokenness wrt partitions 2GB and larger.
271# If <sys/vfs.h> exists and struct statfs has a member named f_spare, 240# If <sys/vfs.h> exists and struct statfs has a member named f_spare,
272# enable the work-around code in fsusage.c. 241# enable the workaround code in fsusage.c.
273AC_DEFUN([gl_STATFS_TRUNCATES], 242AC_DEFUN([gl_STATFS_TRUNCATES],
274[ 243[
275 AC_CACHE_CHECK([for statfs that truncates block counts], 244 AC_CACHE_CHECK([for statfs that truncates block counts],
diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4
index 79f1aaf2..0b389f86 100644
--- a/gl/m4/ftell.m4
+++ b/gl/m4/ftell.m4
@@ -1,8 +1,10 @@
1# ftell.m4 serial 3 1# ftell.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 3
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FTELL], 9AC_DEFUN([gl_FUNC_FTELL],
8[ 10[
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
index 4901b168..ae0e884f 100644
--- a/gl/m4/ftello.m4
+++ b/gl/m4/ftello.m4
@@ -1,8 +1,10 @@
1# ftello.m4 serial 14 1# ftello.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 17
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_FTELLO], 9AC_DEFUN([gl_FUNC_FTELLO],
8[ 10[
@@ -37,13 +39,24 @@ AC_DEFUN([gl_FUNC_FTELLO],
37 if test $gl_cv_var_stdin_large_offset = no; then 39 if test $gl_cv_var_stdin_large_offset = no; then
38 REPLACE_FTELLO=1 40 REPLACE_FTELLO=1
39 fi 41 fi
42 AC_REQUIRE([AC_CANONICAL_HOST])
43 if test $REPLACE_FTELLO = 0; then
44 dnl On native Windows, in some circumstances, ftell(), ftello(),
45 dnl fgetpos(), lseek(), _lseeki64() all succeed on devices of type
46 dnl FILE_TYPE_PIPE. However, to match POSIX behaviour, we want
47 dnl ftell(), ftello(), fgetpos(), lseek() to fail when the argument fd
48 dnl designates a pipe. See also
49 dnl https://github.com/python/cpython/issues/78961#issuecomment-1093800325
50 case "$host_os" in
51 mingw* | windows*) REPLACE_FTELLO=1 ;;
52 esac
53 fi
40 if test $REPLACE_FTELLO = 0; then 54 if test $REPLACE_FTELLO = 0; then
41 dnl Detect bug on Solaris. 55 dnl Detect bug on Solaris.
42 dnl ftell and ftello produce incorrect results after putc that followed a 56 dnl ftell and ftello produce incorrect results after putc that followed a
43 dnl getc call that reached EOF on Solaris. This is because the _IOREAD 57 dnl getc call that reached EOF on Solaris. This is because the _IOREAD
44 dnl flag does not get cleared in this case, even though _IOWRT gets set, 58 dnl flag does not get cleared in this case, even though _IOWRT gets set,
45 dnl and ftell and ftello look whether the _IOREAD flag is set. 59 dnl and ftell and ftello look whether the _IOREAD flag is set.
46 AC_REQUIRE([AC_CANONICAL_HOST])
47 AC_CACHE_CHECK([whether ftello works], 60 AC_CACHE_CHECK([whether ftello works],
48 [gl_cv_func_ftello_works], 61 [gl_cv_func_ftello_works],
49 [ 62 [
@@ -51,12 +64,12 @@ AC_DEFUN([gl_FUNC_FTELLO],
51 dnl be opened. 64 dnl be opened.
52changequote(,)dnl 65changequote(,)dnl
53 case "$host_os" in 66 case "$host_os" in
54 # Guess no on Solaris. 67 # Guess no on Solaris.
55 solaris*) gl_cv_func_ftello_works="guessing no" ;; 68 solaris*) gl_cv_func_ftello_works="guessing no" ;;
56 # Guess yes on native Windows. 69 # Guess yes on native Windows.
57 mingw*) gl_cv_func_ftello_works="guessing yes" ;; 70 mingw* | windows*) gl_cv_func_ftello_works="guessing yes" ;;
58 # Guess yes otherwise. 71 # Guess yes otherwise.
59 *) gl_cv_func_ftello_works="guessing yes" ;; 72 *) gl_cv_func_ftello_works="guessing yes" ;;
60 esac 73 esac
61changequote([,])dnl 74changequote([,])dnl
62 AC_RUN_IFELSE( 75 AC_RUN_IFELSE(
@@ -145,6 +158,10 @@ main (void)
145# Prerequisites of lib/ftello.c. 158# Prerequisites of lib/ftello.c.
146AC_DEFUN([gl_PREREQ_FTELLO], 159AC_DEFUN([gl_PREREQ_FTELLO],
147[ 160[
161 if test $gl_cv_func_ftello != no; then
162 AC_DEFINE([HAVE_FTELLO], [1],
163 [Define to 1 if the system has the ftello function.])
164 fi
148 dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64 165 dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
149 dnl makes it usable again. 166 dnl makes it usable again.
150 AC_CHECK_FUNCS([_ftelli64]) 167 AC_CHECK_FUNCS([_ftelli64])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 15f09ffb..8a63600b 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,13 +1,16 @@
1# getaddrinfo.m4 serial 34 1# getaddrinfo.m4
2dnl Copyright (C) 2004-2023 Free Software Foundation, Inc. 2# serial 39
3dnl Copyright (C) 2004-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_GETADDRINFO], 9AC_DEFUN([gl_GETADDRINFO],
8[ 10[
9 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 11 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H 12 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H
13 AC_REQUIRE([AC_CANONICAL_HOST])
11 GETADDRINFO_LIB= 14 GETADDRINFO_LIB=
12 gai_saved_LIBS="$LIBS" 15 gai_saved_LIBS="$LIBS"
13 16
@@ -41,7 +44,7 @@ AC_DEFUN([gl_GETADDRINFO],
41 AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32], 44 AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
42 gl_cv_w32_getaddrinfo, [ 45 gl_cv_w32_getaddrinfo, [
43 gl_cv_w32_getaddrinfo=no 46 gl_cv_w32_getaddrinfo=no
44 am_save_LIBS="$LIBS" 47 gl_saved_LIBS="$LIBS"
45 LIBS="$LIBS -lws2_32" 48 LIBS="$LIBS -lws2_32"
46 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 49 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
47#ifdef HAVE_WS2TCPIP_H 50#ifdef HAVE_WS2TCPIP_H
@@ -49,7 +52,7 @@ AC_DEFUN([gl_GETADDRINFO],
49#endif 52#endif
50#include <stddef.h> 53#include <stddef.h>
51]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes]) 54]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes])
52 LIBS="$am_save_LIBS" 55 LIBS="$gl_saved_LIBS"
53 ]) 56 ])
54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 57 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
55 GETADDRINFO_LIB="-lws2_32" 58 GETADDRINFO_LIB="-lws2_32"
@@ -86,6 +89,60 @@ int getaddrinfo (const char *, const char *, const struct addrinfo *, struct add
86 HAVE_GETADDRINFO=0 89 HAVE_GETADDRINFO=0
87 fi 90 fi
88 fi 91 fi
92 if test $HAVE_GETADDRINFO != 0; then
93 AC_CACHE_CHECK([whether getaddrinfo supports AI_NUMERICHOST and AI_NUMERICSERV],
94 [gl_cv_func_getaddrinfo_works],
95 [AC_RUN_IFELSE(
96 [AC_LANG_PROGRAM([[
97#include <sys/types.h>
98#ifdef HAVE_SYS_SOCKET_H
99#include <sys/socket.h>
100#endif
101#ifdef HAVE_NETDB_H
102#include <netdb.h>
103#endif
104#ifdef HAVE_WS2TCPIP_H
105#include <ws2tcpip.h>
106#endif
107#include <stddef.h>
108#include <string.h>
109 ]], [[
110 int result = 0;
111 struct addrinfo *ai;
112 {
113 struct addrinfo hints;
114 memset (&hints, 0, sizeof (hints));
115 hints.ai_flags = AI_NUMERICHOST;
116 if (getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME)
117 result |= 1;
118 }
119 {
120 struct addrinfo hints;
121 memset (&hints, 0, sizeof (hints));
122 hints.ai_flags = AI_NUMERICSERV;
123 if (getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME)
124 result |= 2;
125 }
126 return result;
127 ]])
128 ],
129 [gl_cv_func_getaddrinfo_works=yes],
130 [gl_cv_func_getaddrinfo_works=no],
131 [case "$host_os" in
132 # Guess no on Solaris.
133 solaris*) gl_cv_func_getaddrinfo_works="guessing no" ;;
134 # Guess no on native Windows.
135 mingw* | windows*) gl_cv_func_getaddrinfo_works="guessing no" ;;
136 # Guess yes otherwise.
137 *) gl_cv_func_getaddrinfo_works="guessing yes" ;;
138 esac
139 ])
140 ])
141 case "$gl_cv_func_getaddrinfo_works" in
142 *yes) ;;
143 *) REPLACE_GETADDRINFO=1 ;;
144 esac
145 fi
89 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO], 146 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
90 [Define to 1 if getaddrinfo exists, or to 0 otherwise.]) 147 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
91 148
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
index 9aaed202..8b6eff47 100644
--- a/gl/m4/getdelim.m4
+++ b/gl/m4/getdelim.m4
@@ -1,10 +1,12 @@
1# getdelim.m4 serial 16 1# getdelim.m4
2# serial 21
2 3
3dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. 4dnl Copyright (C) 2005-2007, 2009-2026 Free Software Foundation, Inc.
4dnl 5dnl
5dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
9dnl This file is offered as-is, without any warranty.
8 10
9AC_PREREQ([2.59]) 11AC_PREREQ([2.59])
10 12
@@ -18,7 +20,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
18 20
19 AC_CHECK_DECLS_ONCE([getdelim]) 21 AC_CHECK_DECLS_ONCE([getdelim])
20 22
21 AC_CHECK_FUNCS_ONCE([getdelim]) 23 gl_CHECK_FUNCS_ANDROID([getdelim], [[#include <stdio.h>]])
22 if test $ac_cv_func_getdelim = yes; then 24 if test $ac_cv_func_getdelim = yes; then
23 HAVE_GETDELIM=1 25 HAVE_GETDELIM=1
24 dnl Found it in some library. Verify that it works. 26 dnl Found it in some library. Verify that it works.
@@ -35,6 +37,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
35 gl_cv_func_working_getdelim=no ;; 37 gl_cv_func_working_getdelim=no ;;
36 *) 38 *)
37 echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data 39 echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
40 touch conftest.empty
38 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 41 AC_RUN_IFELSE([AC_LANG_SOURCE([[
39# include <stdio.h> 42# include <stdio.h>
40# include <stdlib.h> 43# include <stdlib.h>
@@ -42,6 +45,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
42 int main () 45 int main ()
43 { 46 {
44 FILE *in = fopen ("./conftest.data", "r"); 47 FILE *in = fopen ("./conftest.data", "r");
48 int result = 0;
45 if (!in) 49 if (!in)
46 return 1; 50 return 1;
47 { 51 {
@@ -51,7 +55,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
51 size_t siz = 0; 55 size_t siz = 0;
52 int len = getdelim (&line, &siz, '\n', in); 56 int len = getdelim (&line, &siz, '\n', in);
53 if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) 57 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
54 { free (line); fclose (in); return 2; } 58 result |= 2;
55 free (line); 59 free (line);
56 } 60 }
57 { 61 {
@@ -60,35 +64,40 @@ AC_DEFUN([gl_FUNC_GETDELIM],
60 char *line = NULL; 64 char *line = NULL;
61 size_t siz = (size_t)(~0) / 4; 65 size_t siz = (size_t)(~0) / 4;
62 if (getdelim (&line, &siz, '\n', in) == -1) 66 if (getdelim (&line, &siz, '\n', in) == -1)
63 { fclose (in); return 3; } 67 result |= 4;
64 free (line); 68 free (line);
65 } 69 }
66 fclose (in); 70 fclose (in);
67 return 0; 71 {
72 /* Test that reading EOF as the first character sets the first byte
73 in the buffer to NUL. This fails on glibc 2.42 and earlier. */
74 in = fopen ("./conftest.empty", "r");
75 if (!in)
76 return 1;
77 char *line = malloc (1);
78 line[0] = 'A';
79 size_t siz = 1;
80 if (getdelim (&line, &siz, '\n', in) != -1 || line[0] != '\0')
81 result |= 8;
82 free (line);
83 }
84 fclose (in);
85 return result;
68 } 86 }
69 ]])], 87 ]])],
70 [gl_cv_func_working_getdelim=yes], 88 [gl_cv_func_working_getdelim=yes],
71 [gl_cv_func_working_getdelim=no], 89 [gl_cv_func_working_getdelim=no],
72 [dnl We're cross compiling. 90 [case "$host_os" in
73 dnl Guess it works on glibc2 systems and musl systems. 91 # Guess yes on musl.
74 AC_EGREP_CPP([Lucky GNU user], 92 *-musl* | midipix*) gl_cv_func_working_getdelim="guessing yes" ;;
75 [ 93 # Guess no on glibc.
76#include <features.h> 94 *-gnu* | gnu*) gl_cv_func_working_getdelim="guessing no" ;;
77#ifdef __GNU_LIBRARY__ 95 *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
78 #if (__GLIBC__ >= 2) && !defined __UCLIBC__ 96 esac
79 Lucky GNU user
80 #endif
81#endif
82 ],
83 [gl_cv_func_working_getdelim="guessing yes"],
84 [case "$host_os" in
85 *-musl*) gl_cv_func_working_getdelim="guessing yes" ;;
86 *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
87 esac
88 ])
89 ]) 97 ])
90 ;; 98 ;;
91 esac 99 esac
100 rm -f conftest.data conftest.empty
92 ]) 101 ])
93 case "$gl_cv_func_working_getdelim" in 102 case "$gl_cv_func_working_getdelim" in
94 *yes) ;; 103 *yes) ;;
@@ -96,6 +105,9 @@ AC_DEFUN([gl_FUNC_GETDELIM],
96 esac 105 esac
97 else 106 else
98 HAVE_GETDELIM=0 107 HAVE_GETDELIM=0
108 case "$gl_cv_onwards_func_getdelim" in
109 future*) REPLACE_GETDELIM=1 ;;
110 esac
99 fi 111 fi
100 112
101 if test $ac_cv_have_decl_getdelim = no; then 113 if test $ac_cv_have_decl_getdelim = no; then
diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4
index 8bcda905..0b780110 100644
--- a/gl/m4/getdtablesize.m4
+++ b/gl/m4/getdtablesize.m4
@@ -1,8 +1,10 @@
1# getdtablesize.m4 serial 8 1# getdtablesize.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 8
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_GETDTABLESIZE], 9AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[ 10[
diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4
index 63f5f636..33293521 100644
--- a/gl/m4/gethostname.m4
+++ b/gl/m4/gethostname.m4
@@ -1,8 +1,10 @@
1# gethostname.m4 serial 15 1# gethostname.m4
2dnl Copyright (C) 2002, 2008-2023 Free Software Foundation, Inc. 2# serial 16
3dnl Copyright (C) 2002, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# Ensure 9# Ensure
8# - the gethostname() function, 10# - the gethostname() function,
@@ -20,7 +22,7 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME],
20 AC_CACHE_CHECK([for gethostname in winsock2.h and -lws2_32], 22 AC_CACHE_CHECK([for gethostname in winsock2.h and -lws2_32],
21 [gl_cv_w32_gethostname], 23 [gl_cv_w32_gethostname],
22 [gl_cv_w32_gethostname=no 24 [gl_cv_w32_gethostname=no
23 gl_save_LIBS="$LIBS" 25 gl_saved_LIBS="$LIBS"
24 LIBS="$LIBS -lws2_32" 26 LIBS="$LIBS -lws2_32"
25 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 27 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
26#ifdef HAVE_WINSOCK2_H 28#ifdef HAVE_WINSOCK2_H
@@ -28,7 +30,7 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME],
28#endif 30#endif
29#include <stddef.h> 31#include <stddef.h>
30]], [[gethostname(NULL, 0);]])], [gl_cv_w32_gethostname=yes]) 32]], [[gethostname(NULL, 0);]])], [gl_cv_w32_gethostname=yes])
31 LIBS="$gl_save_LIBS" 33 LIBS="$gl_saved_LIBS"
32 ]) 34 ])
33 if test "$gl_cv_w32_gethostname" = "yes"; then 35 if test "$gl_cv_w32_gethostname" = "yes"; then
34 GETHOSTNAME_LIB="-lws2_32" 36 GETHOSTNAME_LIB="-lws2_32"
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
index 03569f06..ed32fa10 100644
--- a/gl/m4/getline.m4
+++ b/gl/m4/getline.m4
@@ -1,11 +1,13 @@
1# getline.m4 serial 30 1# getline.m4
2# serial 35
2 3
3dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation, 4dnl Copyright (C) 1998-2003, 2005-2007, 2009-2026 Free Software Foundation,
4dnl Inc. 5dnl Inc.
5dnl 6dnl
6dnl This file is free software; the Free Software Foundation 7dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 8dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 9dnl with or without modifications, as long as this notice is preserved.
10dnl This file is offered as-is, without any warranty.
9 11
10AC_PREREQ([2.59]) 12AC_PREREQ([2.59])
11 13
@@ -23,15 +25,13 @@ AC_DEFUN([gl_FUNC_GETLINE],
23 25
24 AC_CHECK_DECLS_ONCE([getline]) 26 AC_CHECK_DECLS_ONCE([getline])
25 27
26 gl_getline_needs_run_time_check=no 28 gl_CHECK_FUNCS_ANDROID([getline], [[#include <stdio.h>]])
27 AC_CHECK_FUNC([getline], 29 if test $ac_cv_func_getline = yes; then
28 [dnl Found it in some library. Verify that it works. 30 dnl Found it in some library. Verify that it works.
29 gl_getline_needs_run_time_check=yes],
30 [am_cv_func_working_getline=no])
31 if test $gl_getline_needs_run_time_check = yes; then
32 AC_CACHE_CHECK([for working getline function], 31 AC_CACHE_CHECK([for working getline function],
33 [am_cv_func_working_getline], 32 [am_cv_func_working_getline],
34 [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data 33 [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
34 touch conftest.empty
35 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 35 AC_RUN_IFELSE([AC_LANG_SOURCE([[
36# include <stdio.h> 36# include <stdio.h>
37# include <stdlib.h> 37# include <stdlib.h>
@@ -39,6 +39,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
39 int main () 39 int main ()
40 { 40 {
41 FILE *in = fopen ("./conftest.data", "r"); 41 FILE *in = fopen ("./conftest.data", "r");
42 int result = 0;
42 if (!in) 43 if (!in)
43 return 1; 44 return 1;
44 { 45 {
@@ -48,7 +49,7 @@ AC_DEFUN([gl_FUNC_GETLINE],
48 size_t siz = 0; 49 size_t siz = 0;
49 int len = getline (&line, &siz, in); 50 int len = getline (&line, &siz, in);
50 if (!(len == 4 && line && strcmp (line, "foo\n") == 0)) 51 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
51 { free (line); fclose (in); return 2; } 52 result |= 2;
52 free (line); 53 free (line);
53 } 54 }
54 { 55 {
@@ -57,34 +58,44 @@ AC_DEFUN([gl_FUNC_GETLINE],
57 char *line = NULL; 58 char *line = NULL;
58 size_t siz = (size_t)(~0) / 4; 59 size_t siz = (size_t)(~0) / 4;
59 if (getline (&line, &siz, in) == -1) 60 if (getline (&line, &siz, in) == -1)
60 { fclose (in); return 3; } 61 result |= 4;
61 free (line); 62 free (line);
62 } 63 }
63 fclose (in); 64 fclose (in);
64 return 0; 65 {
66 /* Test that reading EOF as the first character sets the first byte
67 in the buffer to NUL. This fails on glibc 2.42 and earlier. */
68 in = fopen ("./conftest.empty", "r");
69 if (!in)
70 return 1;
71 char *line = malloc (1);
72 line[0] = 'A';
73 size_t siz = 1;
74 if (getline (&line, &siz, in) != -1 || line[0] != '\0')
75 result |= 8;
76 free (line);
77 }
78 fclose (in);
79 return result;
65 } 80 }
66 ]])], 81 ]])],
67 [am_cv_func_working_getline=yes], 82 [am_cv_func_working_getline=yes],
68 [am_cv_func_working_getline=no], 83 [am_cv_func_working_getline=no],
69 [dnl We're cross compiling. 84 [case "$host_os" in
70 dnl Guess it works on glibc2 systems and musl systems. 85 # Guess yes on musl.
71 AC_EGREP_CPP([Lucky GNU user], 86 *-musl* | midipix*) am_cv_func_working_getline="guessing yes" ;;
72 [ 87 # Guess no on glibc.
73#include <features.h> 88 *-gnu* | gnu*) am_cv_func_working_getline="guessing no" ;;
74#ifdef __GNU_LIBRARY__ 89 *) am_cv_func_working_getline="$gl_cross_guess_normal" ;;
75 #if (__GLIBC__ >= 2) && !defined __UCLIBC__ 90 esac
76 Lucky GNU user
77 #endif
78#endif
79 ],
80 [am_cv_func_working_getline="guessing yes"],
81 [case "$host_os" in
82 *-musl*) am_cv_func_working_getline="guessing yes" ;;
83 *) am_cv_func_working_getline="$gl_cross_guess_normal" ;;
84 esac
85 ])
86 ]) 91 ])
92 rm -f conftest.data conftest.empty
87 ]) 93 ])
94 else
95 am_cv_func_working_getline=no
96 case "$gl_cv_onwards_func_getline" in
97 future*) REPLACE_GETLINE=1 ;;
98 esac
88 fi 99 fi
89 100
90 if test $ac_cv_have_decl_getline = no; then 101 if test $ac_cv_have_decl_getline = no; then
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index 79e420ba..dc226168 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,13 +1,13 @@
1# Check for getloadavg. 1# getloadavg.m4
2 2# serial 14
3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2023 Free Software 3dnl Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2026 Free
4# Foundation, Inc. 4dnl Software Foundation, Inc.
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
5 9
6# This file is free software; the Free Software Foundation 10# Check for getloadavg.
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10#serial 10
11 11
12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. 12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
13# New applications should use gl_GETLOADAVG instead. 13# New applications should use gl_GETLOADAVG instead.
@@ -20,13 +20,18 @@ AC_DEFUN([gl_GETLOADAVG],
20# Persuade glibc <stdlib.h> to declare getloadavg(). 20# Persuade glibc <stdlib.h> to declare getloadavg().
21AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 21AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22 22
23gl_save_LIBS=$LIBS 23gl_saved_LIBS=$LIBS
24 24
25# getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0, 25# getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. 26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
27HAVE_GETLOADAVG=1 27HAVE_GETLOADAVG=1
28AC_CHECK_FUNC([getloadavg], [], 28gl_CHECK_FUNCS_ANDROID([getloadavg], [[#include <stdlib.h>]])
29 [gl_func_getloadavg_done=no 29if test $ac_cv_func_getloadavg != yes; then
30 case "$gl_cv_onwards_func_getloadavg" in
31 future*) REPLACE_GETLOADAVG=1 ;;
32 esac
33
34 gl_func_getloadavg_done=no
30 35
31 # Some systems with -lutil have (and need) -lkvm as well, some do not. 36 # Some systems with -lutil have (and need) -lkvm as well, some do not.
32 # On Solaris, -lkvm requires nlist from -lelf, so check that first 37 # On Solaris, -lkvm requires nlist from -lelf, so check that first
@@ -73,14 +78,15 @@ AC_CHECK_FUNC([getloadavg], [],
73 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.]) 78 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
74 AC_CHECK_LIB([dgc], [dg_sys_info])]) 79 AC_CHECK_LIB([dgc], [dg_sys_info])])
75 fi 80 fi
76 fi]) 81 fi
82fi
77 83
78if test "x$gl_save_LIBS" = x; then 84if test "x$gl_saved_LIBS" = x; then
79 GETLOADAVG_LIBS=$LIBS 85 GETLOADAVG_LIBS=$LIBS
80else 86else
81 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"` 87 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_saved_LIBS!!"`
82fi 88fi
83LIBS=$gl_save_LIBS 89LIBS=$gl_saved_LIBS
84 90
85AC_SUBST([GETLOADAVG_LIBS])dnl 91AC_SUBST([GETLOADAVG_LIBS])dnl
86 92
@@ -118,8 +124,7 @@ if test $gl_func_getloadavg_done = no; then
118fi 124fi
119 125
120# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it 126# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
121# uses stabs), but it is still SVR4. We cannot check for <elf.h> because 127# uses stabs), but it is still SVR4.
122# Irix 4.0.5F has the header but not the library.
123if test $gl_func_getloadavg_done = no && test "$ac_cv_lib_elf_elf_begin" = yes \ 128if test $gl_func_getloadavg_done = no && test "$ac_cv_lib_elf_elf_begin" = yes \
124 && test "$ac_cv_lib_kvm_kvm_open" = yes; then 129 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
125 gl_func_getloadavg_done=yes 130 gl_func_getloadavg_done=yes
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 7981a095..c620b2b7 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,8 +1,10 @@
1# getopt.m4 serial 48 1# getopt.m4
2dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc. 2# serial 52
3dnl Copyright (C) 2002-2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# Request a POSIX compliant getopt function. 9# Request a POSIX compliant getopt function.
8AC_DEFUN([gl_FUNC_GETOPT_POSIX], 10AC_DEFUN([gl_FUNC_GETOPT_POSIX],
@@ -76,7 +78,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
76 fi 78 fi
77 79
78 dnl POSIX 2008 does not specify leading '+' behavior, but see 80 dnl POSIX 2008 does not specify leading '+' behavior, but see
79 dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on 81 dnl https://austingroupbugs.net/view.php?id=191 for a recommendation on
80 dnl the next version of POSIX. For now, we only guarantee leading '+' 82 dnl the next version of POSIX. For now, we only guarantee leading '+'
81 dnl behavior with getopt-gnu. 83 dnl behavior with getopt-gnu.
82 if test -z "$gl_replace_getopt"; then 84 if test -z "$gl_replace_getopt"; then
@@ -86,8 +88,8 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
86 dnl Merging these three different test programs into a single one 88 dnl Merging these three different test programs into a single one
87 dnl would require a reset mechanism. On BSD systems, it can be done 89 dnl would require a reset mechanism. On BSD systems, it can be done
88 dnl through 'optreset'; on some others (glibc), it can be done by 90 dnl through 'optreset'; on some others (glibc), it can be done by
89 dnl setting 'optind' to 0; on others again (HP-UX, IRIX, OSF/1, 91 dnl setting 'optind' to 0; on others again (HP-UX, Solaris 9,
90 dnl Solaris 9, musl libc), there is no such mechanism. 92 dnl musl libc), there is no such mechanism.
91 if test $cross_compiling = no; then 93 if test $cross_compiling = no; then
92 dnl Sanity check. Succeeds everywhere (except on MSVC, 94 dnl Sanity check. Succeeds everywhere (except on MSVC,
93 dnl which lacks <unistd.h> and getopt() entirely). 95 dnl which lacks <unistd.h> and getopt() entirely).
@@ -197,8 +199,8 @@ main ()
197 fi 199 fi
198 else 200 else
199 case "$host_os" in 201 case "$host_os" in
200 darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";; 202 darwin* | aix* | mingw* | windows*) gl_cv_func_getopt_posix="guessing no";;
201 *) gl_cv_func_getopt_posix="guessing yes";; 203 *) gl_cv_func_getopt_posix="guessing yes";;
202 esac 204 esac
203 fi 205 fi
204 ]) 206 ])
@@ -236,8 +238,7 @@ dnl is ambiguous with environment values that contain newlines.
236 nocrash_init(); 238 nocrash_init();
237 239
238 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, 240 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
239 and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, 241 and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, Solaris 10. */
240 OSF/1 5.1, Solaris 10. */
241 { 242 {
242 static char conftest[] = "conftest"; 243 static char conftest[] = "conftest";
243 static char plus[] = "-+"; 244 static char plus[] = "-+";
@@ -248,7 +249,7 @@ dnl is ambiguous with environment values that contain newlines.
248 } 249 }
249 /* This code succeeds on glibc 2.8, mingw, 250 /* This code succeeds on glibc 2.8, mingw,
250 and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, 251 and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
251 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ 252 Solaris 10, Cygwin 1.5.x. */
252 { 253 {
253 static char program[] = "program"; 254 static char program[] = "program";
254 static char p[] = "-p"; 255 static char p[] = "-p";
@@ -365,14 +366,7 @@ dnl is ambiguous with environment values that contain newlines.
365 366
366AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], 367AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
367[ 368[
368 AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) 369 gl_CHECK_HEADER_SYS_CDEFS_H
369 if test $ac_cv_header_sys_cdefs_h = yes; then
370 HAVE_SYS_CDEFS_H=1
371 else
372 HAVE_SYS_CDEFS_H=0
373 fi
374 AC_SUBST([HAVE_SYS_CDEFS_H])
375
376 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], 370 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
377 [Define to rpl_ if the getopt replacement functions and variables 371 [Define to rpl_ if the getopt replacement functions and variables
378 should be used.]) 372 should be used.])
diff --git a/gl/m4/getprogname.m4 b/gl/m4/getprogname.m4
index b67c527c..d60f3efb 100644
--- a/gl/m4/getprogname.m4
+++ b/gl/m4/getprogname.m4
@@ -1,16 +1,40 @@
1# getprogname.m4 - check for getprogname or replacements for it 1# getprogname.m4
2# serial 9
3dnl Copyright (C) 2016-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
2 8
3# Copyright (C) 2016-2023 Free Software Foundation, Inc. 9# Check for getprogname or replacements for it
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# serial 4
9 10
10AC_DEFUN([gl_FUNC_GETPROGNAME], 11AC_DEFUN([gl_FUNC_GETPROGNAME],
11[ 12[
12 AC_CHECK_FUNCS_ONCE([getprogname getexecname]) 13 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 AC_CHECK_HEADERS_ONCE([sys/process.h])
16 if test $ac_cv_header_sys_process_h = yes; then
17 HAVE_SYS_PROCESS_H=1
18 else
19 HAVE_SYS_PROCESS_H=0
20 fi
21 gl_CHECK_FUNCS_ANDROID([getprogname], [[#include <stdlib.h>]])
22 if test $ac_cv_func_getprogname = no; then
23 HAVE_GETPROGNAME=0
24 case "$gl_cv_onwards_func_getprogname" in
25 future*) REPLACE_GETPROGNAME=1 ;;
26 esac
27 fi
28 AC_CHECK_DECLS([program_invocation_name],
29 [],
30 [HAVE_DECL_PROGRAM_INVOCATION_NAME=0],
31 [[#include <errno.h>]])
32])
33
34AC_DEFUN([gl_PREREQ_GETPROGNAME],
35[
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 36 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
37 AC_CHECK_FUNCS_ONCE([getexecname])
14 ac_found=0 38 ac_found=0
15 AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [], 39 AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [],
16 [#include <errno.h>]) 40 [#include <errno.h>])
diff --git a/gl/m4/gettext_h.m4 b/gl/m4/gettext_h.m4
new file mode 100644
index 00000000..7ef89541
--- /dev/null
+++ b/gl/m4/gettext_h.m4
@@ -0,0 +1,21 @@
1# gettext_h.m4
2# serial 1
3dnl Copyright (C) 2025-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_GETTEXT_H],
10[
11 AC_SUBST([LIBINTL])
12 AC_SUBST([LTLIBINTL])
13 AH_BOTTOM([
14/* The text domainname for Gnulib messages. Ordinarily this is "gnulib",
15 but packages that do their own translations of Gnulib can use something
16 different by defining GNULIB_TEXT_DOMAIN in their config.h file. */
17#ifndef GNULIB_TEXT_DOMAIN
18# define GNULIB_TEXT_DOMAIN/**/"gnulib"
19#endif
20])
21])
diff --git a/gl/m4/gl-openssl.m4 b/gl/m4/gl-openssl.m4
index 7eab4e10..70f43a55 100644
--- a/gl/m4/gl-openssl.m4
+++ b/gl/m4/gl-openssl.m4
@@ -1,8 +1,10 @@
1# gl-openssl.m4 serial 6 1# gl-openssl.m4
2dnl Copyright (C) 2013-2023 Free Software Foundation, Inc. 2# serial 8
3dnl Copyright (C) 2013-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT], 9AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
8[ 10[
@@ -39,6 +41,9 @@ AC_DEFUN([gl_CRYPTO_CHECK],
39 AC_SUBST([LIB_CRYPTO]) 41 AC_SUBST([LIB_CRYPTO])
40 if test "x$with_openssl" != xno; then 42 if test "x$with_openssl" != xno; then
41 if test "x$with_openssl" = xauto-gpl-compat; then 43 if test "x$with_openssl" = xauto-gpl-compat; then
44 dnl OpenSSL versions < 3 are under the OpenSSL license, which is not
45 dnl GPL compatible.
46 dnl See <https://www.gnu.org/licenses/license-list.en.html#OpenSSL>.
42 AC_CACHE_CHECK([whether openssl is GPL compatible], 47 AC_CACHE_CHECK([whether openssl is GPL compatible],
43 [gl_cv_openssl_gpl_compat], 48 [gl_cv_openssl_gpl_compat],
44 [AC_COMPILE_IFELSE( 49 [AC_COMPILE_IFELSE(
@@ -53,12 +58,17 @@ AC_DEFUN([gl_CRYPTO_CHECK],
53 fi 58 fi
54 if test "x$with_openssl" != xauto-gpl-compat || 59 if test "x$with_openssl" != xauto-gpl-compat ||
55 test "x$gl_cv_openssl_gpl_compat" = xyes; then 60 test "x$gl_cv_openssl_gpl_compat" = xyes; then
56 AC_CHECK_LIB([crypto], [$1], 61 m4_if([$1], [SHA3],
57 [AC_CHECK_HEADERS( 62 [AC_CHECK_LIB([crypto], [EVP_sha3_224],
58 m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
59 [LIB_CRYPTO=-lcrypto 63 [LIB_CRYPTO=-lcrypto
60 AC_DEFINE([HAVE_OPENSSL_$1], [1], 64 AC_DEFINE([HAVE_OPENSSL_$1], [1],
61 [Define to 1 if libcrypto is used for $1.])])]) 65 [Define to 1 if libcrypto is used for $1.])])],
66 [AC_CHECK_LIB([crypto], [$1],
67 [AC_CHECK_HEADERS(
68 m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
69 [LIB_CRYPTO=-lcrypto
70 AC_DEFINE([HAVE_OPENSSL_$1], [1],
71 [Define to 1 if libcrypto is used for $1.])])])])
62 fi 72 fi
63 if test "x$LIB_CRYPTO" = x; then 73 if test "x$LIB_CRYPTO" = x; then
64 message='openssl development library not found for $1. 74 message='openssl development library not found for $1.
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 267f0692..1b964b34 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,4 +1,4 @@
1# Copyright (C) 2002-2023 Free Software Foundation, Inc. 1# Copyright (C) 2002-2026 Free Software Foundation, Inc.
2# 2#
3# This file is free software; you can redistribute it and/or modify 3# This file is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by 4# it under the terms of the GNU General Public License as published by
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index facc3404..26eef771 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,8 +1,10 @@
1# gnulib-common.m4 serial 75a 1# gnulib-common.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 115
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_PREREQ([2.62]) 9AC_PREREQ([2.62])
8 10
@@ -15,43 +17,65 @@ AC_DEFUN([gl_COMMON], [
15 AC_REQUIRE([gl_ZZGNULIB]) 17 AC_REQUIRE([gl_ZZGNULIB])
16]) 18])
17AC_DEFUN([gl_COMMON_BODY], [ 19AC_DEFUN([gl_COMMON_BODY], [
20 AH_VERBATIM([0witness],
21[/* Witness that <config.h> has been included. */
22#define _GL_CONFIG_H_INCLUDED 1
23])
24 dnl Avoid warnings from gcc -Wtrailing-whitespace.
25 dnl This is a temporary workaround until Autoconf fixes it.
26 dnl Test case:
27 dnl empty1=; empty2=; AC_DEFINE_UNQUOTED([FOO], [$empty1$empty2], [...])
28 dnl should produce "#define FOO /**/", not "#define FOO ".
29 AH_TOP([#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
30# pragma GCC diagnostic push
31# pragma GCC diagnostic ignored "-Wtrailing-whitespace"
32#endif
33])
34 AH_BOTTOM([#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
35# pragma GCC diagnostic pop
36#endif
37])
18 AH_VERBATIM([_GL_GNUC_PREREQ], 38 AH_VERBATIM([_GL_GNUC_PREREQ],
19[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ 39[/* True if the compiler says it groks GNU C version MAJOR.MINOR.
20#if defined __GNUC__ && defined __GNUC_MINOR__ 40 Except that
41 - clang groks GNU C 4.2, even on Windows, where it does not define
42 __GNUC__.
43 - The OpenMandriva-modified clang compiler pretends that it groks
44 GNU C version 13.1, but it doesn't: It does not support
45 __attribute__ ((__malloc__ (f, i))), nor does it support
46 __attribute__ ((__warning__ (message))) on a function redeclaration.
47 - Users can make clang lie as well, through the -fgnuc-version option. */
48#if defined __GNUC__ && defined __GNUC_MINOR__ && !defined __clang__
21# define _GL_GNUC_PREREQ(major, minor) \ 49# define _GL_GNUC_PREREQ(major, minor) \
22 ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) 50 ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
51#elif defined __clang__
52 /* clang really only groks GNU C 4.2. */
53# define _GL_GNUC_PREREQ(major, minor) \
54 ((major) < 4 + ((minor) <= 2))
23#else 55#else
24# define _GL_GNUC_PREREQ(major, minor) 0 56# define _GL_GNUC_PREREQ(major, minor) 0
25#endif 57#endif
26]) 58])
27 AH_VERBATIM([_Noreturn], 59 AH_VERBATIM([_Noreturn],
28[/* The _Noreturn keyword of C11. */ 60[/* The _Noreturn keyword of C11.
61 Do not use [[noreturn]], because with it the syntax
62 extern _Noreturn void func (...);
63 would not be valid; such a declaration would be valid only with 'extern'
64 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
65 AIX system header files and several gnulib header files use precisely
66 this syntax with 'extern'. So even though C23 deprecates _Noreturn,
67 it is currently more portable to prefer it to [[noreturn]].
68
69 Also, do not try to work around LLVM bug 59792 (clang 15 or earlier).
70 This rare bug can be worked around by compiling with 'clang -D_Noreturn=',
71 though the workaround may generate many false-alarm warnings. */
29#ifndef _Noreturn 72#ifndef _Noreturn
30# if (defined __cplusplus \ 73# if ((!defined __cplusplus || defined __clang__) \
31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ 74 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)))
32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
33 && 0)
34 /* [[noreturn]] is not practically usable, because with it the syntax
35 extern _Noreturn void func (...);
36 would not be valid; such a declaration would only be valid with 'extern'
37 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
38 AIX system header files and several gnulib header files use precisely
39 this syntax with 'extern'. */
40# define _Noreturn [[noreturn]]
41# elif (defined __clang__ && __clang_major__ < 16 \
42 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
43 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
44 that rare LLVM bug, though you may get many false-alarm warnings. */
45# define _Noreturn
46# elif ((!defined __cplusplus || defined __clang__) \
47 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
48 || (!defined __STRICT_ANSI__ \
49 && (_GL_GNUC_PREREQ (4, 7) \
50 || (defined __apple_build_version__ \
51 ? 6000000 <= __apple_build_version__ \
52 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
53 /* _Noreturn works as-is. */ 75 /* _Noreturn works as-is. */
54# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C 76# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
77 /* Prefer __attribute__ ((__noreturn__)) to plain _Noreturn even if the
78 latter works, as 'gcc -std=gnu99 -Wpedantic' warns about _Noreturn. */
55# define _Noreturn __attribute__ ((__noreturn__)) 79# define _Noreturn __attribute__ ((__noreturn__))
56# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) 80# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
57# define _Noreturn __declspec (noreturn) 81# define _Noreturn __declspec (noreturn)
@@ -72,50 +96,267 @@ AC_DEFUN([gl_COMMON_BODY], [
72#endif]) 96#endif])
73 AH_VERBATIM([attribute], 97 AH_VERBATIM([attribute],
74[/* Attributes. */ 98[/* Attributes. */
75#if (defined __has_attribute \ 99/* Define _GL_HAS_ATTRIBUTE only once, because on FreeBSD, with gcc < 5, if
76 && (!defined __clang_minor__ \ 100 <config.h> gets included once again after <sys/cdefs.h>, __has_attribute(x)
77 || (defined __apple_build_version__ \ 101 expands to 0 always, and redefining _GL_HAS_ATTRIBUTE would turn off all
78 ? 6000000 <= __apple_build_version__ \ 102 attributes. */
79 : 3 < __clang_major__ + (5 <= __clang_minor__)))) 103#ifndef _GL_HAS_ATTRIBUTE
80# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) 104# if (defined __has_attribute \
81#else 105 && (!defined __clang_minor__ \
82# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr 106 || (defined __apple_build_version__ \
83# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) 107 ? 7000000 <= __apple_build_version__ \
84# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) 108 : 5 <= __clang_major__)))
85# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) 109# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
86# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
87# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
88# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
89# define _GL_ATTR_diagnose_if 0
90# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
91# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
92# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
93# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
94# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
95# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
96# ifdef _ICC
97# define _GL_ATTR_may_alias 0
98# else 110# else
99# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) 111# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
112/* The following lines list the first GCC version that supports the attribute.
113 Although the lines are not used in GCC 5 and later (as GCC 5 introduced
114 __has_attribute support), list GCC versions 5+ anyway for completeness. */
115# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
116# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
117# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
118# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
119# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
120# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
121# define _GL_ATTR_diagnose_if 0
122# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
123# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
124# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
125# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
126# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
127# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
128# ifdef _ICC
129# define _GL_ATTR_may_alias 0
130# else
131# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
132# endif
133# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
134# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
135# define _GL_ATTR_nonnull_if_nonzero _GL_GNUC_PREREQ (15, 1)
136# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
137# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
138# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
139# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
140# define _GL_ATTR_reproducible _GL_GNUC_PREREQ (15, 1)
141# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
142# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
143# define _GL_ATTR_unsequenced _GL_GNUC_PREREQ (15, 1)
144# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
145# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
100# endif 146# endif
101# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
102# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
103# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
104# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
105# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
106# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
107# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
108# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
109# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
110# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
111#endif 147#endif
112 148
113/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */ 149/* Use __has_c_attribute if available. However, do not use with
114#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \ 150 pre-C23 GCC, which can issue false positives if -Wpedantic. */
115 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710) 151#if (defined __has_c_attribute \
116# pragma GCC diagnostic ignored "-Wpedantic" 152 && ! (_GL_GNUC_PREREQ (4, 6) \
153 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710))
154# define _GL_HAVE___HAS_C_ATTRIBUTE 1
155#else
156# define _GL_HAVE___HAS_C_ATTRIBUTE 0
117#endif 157#endif
118 158
159/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...))
160 syntax, in function declarations. There are two problems here.
161 (Last tested with gcc/g++ 14 and clang/clang++ 18.)
162
163 1) We want that the _GL_ATTRIBUTE_* can be cumulated on the same declaration
164 in any order.
165 =========================== foo.c = foo.cc ===========================
166 __attribute__ ((__deprecated__)) [[__nodiscard__]] int bar1 (int);
167 [[__nodiscard__]] __attribute__ ((__deprecated__)) int bar2 (int);
168 ======================================================================
169 This gives a syntax error
170 - in C mode with gcc
171 <https://gcc.gnu.org/PR108796>, and
172 - in C++ mode with clang++ version < 16, and
173 - in C++ mode, inside extern "C" {}, still in newer clang++ versions
174 <https://github.com/llvm/llvm-project/issues/101990>.
175 */
176/* Define if, in a function declaration, the attributes in bracket syntax
177 [[...]] must come before the attributes in __attribute__((...)) syntax.
178 If this is defined, it is best to avoid the bracket syntax, so that the
179 various _GL_ATTRIBUTE_* can be cumulated on the same declaration in any
180 order. */
181#ifdef __cplusplus
182# if defined __clang__
183# define _GL_BRACKET_BEFORE_ATTRIBUTE 1
184# endif
185#else
186# if defined __GNUC__ && !defined __clang__
187# define _GL_BRACKET_BEFORE_ATTRIBUTE 1
188# endif
189#endif
190/*
191 2) We want that the _GL_ATTRIBUTE_* can be placed in a declaration
192 - without 'extern', in C as well as in C++,
193 - with 'extern', in C,
194 - with 'extern "C"', in C++
195 in the same position. That is, we don't want to be forced to use a
196 macro which arranges for the attribute to come before 'extern' in
197 one case and after 'extern' in the other case, because such a macro
198 would make the source code of .h files pretty ugly.
199 =========================== foo.c = foo.cc ===========================
200 #ifdef __cplusplus
201 # define CC "C"
202 #else
203 # define CC
204 #endif
205
206 #define ND [[__nodiscard__]]
207 #define WUR __attribute__((__warn_unused_result__))
208
209 #ifdef __cplusplus
210 extern "C" {
211 #endif
212 // gcc clang g++ clang++
213
214 ND int foo (int);
215 int ND foo (int); // warn error warn error
216 int foo ND (int);
217 int foo (int) ND; // warn error warn error
218
219 WUR int foo (int);
220 int WUR foo (int);
221 int fo1 WUR (int); // error error error error
222 int foo (int) WUR;
223
224 #ifdef __cplusplus
225 }
226 #endif
227
228 // gcc clang g++ clang++
229
230 ND extern CC int foo (int); // error error
231 extern CC ND int foo (int); // error error
232 extern CC int ND foo (int); // warn error warn error
233 extern CC int foo ND (int);
234 extern CC int foo (int) ND; // warn error warn error
235
236 WUR extern CC int foo (int); // warn
237 extern CC WUR int foo (int);
238 extern CC int WUR foo (int);
239 extern CC int foo WUR (int); // error error error error
240 extern CC int foo (int) WUR;
241
242 ND EXTERN_C_FUNC int foo (int); // error error
243 EXTERN_C_FUNC ND int foo (int);
244 EXTERN_C_FUNC int ND foo (int); // warn error warn error
245 EXTERN_C_FUNC int foo ND (int);
246 EXTERN_C_FUNC int foo (int) ND; // warn error warn error
247
248 WUR EXTERN_C_FUNC int foo (int); // warn
249 EXTERN_C_FUNC WUR int foo (int);
250 EXTERN_C_FUNC int WUR foo (int);
251 EXTERN_C_FUNC int fo2 WUR (int); // error error error error
252 EXTERN_C_FUNC int foo (int) WUR;
253 ======================================================================
254 So, if we insist on using the 'extern' keyword ('extern CC' idiom):
255 * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]]
256 in both C and C++, there is one available position:
257 - between the function name and the parameter list.
258 * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax
259 in both C and C++, there are several available positions:
260 - before the return type,
261 - between return type and function name,
262 - at the end of the declaration.
263 * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to
264 __attribute__((...)) syntax in C++, there is no available position:
265 it would need to come before 'extern' in C but after 'extern "C"'
266 in C++.
267 * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and
268 to bracket syntax [[...]] in C++, there is one available position:
269 - before the return type.
270 Whereas, if we use the 'EXTERN_C_FUNC' idiom, which conditionally
271 omits the 'extern' keyword:
272 * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]]
273 in both C and C++, there are two available positions:
274 - before the return type,
275 - between the function name and the parameter list.
276 * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax
277 in both C and C++, there are several available positions:
278 - before the return type,
279 - between return type and function name,
280 - at the end of the declaration.
281 * If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to
282 __attribute__((...)) syntax in C++, there is one available position:
283 - before the return type.
284 * If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and
285 to bracket syntax [[...]] in C++, there is one available position:
286 - before the return type.
287 The best choice is therefore to use the 'EXTERN_C_FUNC' idiom and
288 put the attributes before the return type. This works regardless
289 to what the _GL_ATTRIBUTE_* macros expand.
290 */
291
292/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...))
293 syntax, in static/inline function definitions.
294
295 There are similar constraints as for function declarations. However, here,
296 we cannot omit the storage-class specifier. Therefore, the following rule
297 applies:
298 * The macros
299 _GL_ATTRIBUTE_CONST
300 _GL_ATTRIBUTE_DEPRECATED
301 _GL_ATTRIBUTE_MAYBE_UNUSED
302 _GL_ATTRIBUTE_NODISCARD
303 _GL_ATTRIBUTE_PURE
304 _GL_ATTRIBUTE_REPRODUCIBLE
305 _GL_ATTRIBUTE_UNSEQUENCED
306 which may expand to bracket syntax [[...]], must come first, before the
307 storage-class specifier.
308 * Other _GL_ATTRIBUTE_* macros, that expand to __attribute__((...)) syntax,
309 are better placed between the storage-class specifier and the return
310 type.
311 */
312
313/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...))
314 syntax, in variable declarations.
315
316 At which position can they be placed?
317 (Last tested with gcc/g++ 14 and clang/clang++ 18.)
318
319 =========================== foo.c = foo.cc ===========================
320 #ifdef __cplusplus
321 # define CC "C"
322 #else
323 # define CC
324 #endif
325
326 #define BD [[__deprecated__]]
327 #define AD __attribute__ ((__deprecated__))
328
329 // gcc clang g++ clang++
330
331 BD extern CC int var; // error error
332 extern CC BD int var; // error error
333 extern CC int BD var; // warn error warn error
334 extern CC int var BD;
335
336 AD extern CC int var; // warn
337 extern CC AD int var;
338 extern CC int AD var;
339 extern CC int var AD;
340
341 BD extern CC int z[]; // error error
342 extern CC BD int z[]; // error error
343 extern CC int BD z[]; // warn error warn error
344 extern CC int z1 BD [];
345 extern CC int z[] BD; // warn error error
346
347 AD extern CC int z[]; // warn
348 extern CC AD int z[];
349 extern CC int AD z[];
350 extern CC int z2 AD []; // error error error error
351 extern CC int z[] AD;
352 ======================================================================
353
354 * For non-array variables, the only good position is after the variable name,
355 that is, at the end of the declaration.
356 * For array variables, you will need to distinguish C and C++:
357 - In C, before the 'extern' keyword.
358 - In C++, between the 'extern "C"' and the variable's type.
359 */
119]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead. 360]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead.
120[ 361[
121/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function 362/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
@@ -123,7 +364,7 @@ AC_DEFUN([gl_COMMON_BODY], [
123 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied 364 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
124 by the Nth argument of the function is the size of the returned memory block. 365 by the Nth argument of the function is the size of the returned memory block.
125 */ 366 */
126/* Applies to: function, pointer to function, function types. */ 367/* Applies to: functions, pointer to functions, function types. */
127#ifndef _GL_ATTRIBUTE_ALLOC_SIZE 368#ifndef _GL_ATTRIBUTE_ALLOC_SIZE
128# if _GL_HAS_ATTRIBUTE (alloc_size) 369# if _GL_HAS_ATTRIBUTE (alloc_size)
129# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) 370# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
@@ -134,7 +375,7 @@ AC_DEFUN([gl_COMMON_BODY], [
134 375
135/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the 376/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
136 function and report an error if it cannot do so. */ 377 function and report an error if it cannot do so. */
137/* Applies to: function. */ 378/* Applies to: functions. */
138#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE 379#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
139# if _GL_HAS_ATTRIBUTE (always_inline) 380# if _GL_HAS_ATTRIBUTE (always_inline)
140# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) 381# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
@@ -146,7 +387,7 @@ AC_DEFUN([gl_COMMON_BODY], [
146/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show 387/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
147 in stack traces when debugging. The compiler should omit the function from 388 in stack traces when debugging. The compiler should omit the function from
148 stack traces. */ 389 stack traces. */
149/* Applies to: function. */ 390/* Applies to: functions. */
150#ifndef _GL_ATTRIBUTE_ARTIFICIAL 391#ifndef _GL_ATTRIBUTE_ARTIFICIAL
151# if _GL_HAS_ATTRIBUTE (artificial) 392# if _GL_HAS_ATTRIBUTE (artificial)
152# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) 393# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
@@ -172,12 +413,20 @@ AC_DEFUN([gl_COMMON_BODY], [
172# endif 413# endif
173#endif 414#endif
174 415
175/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate 416/* _GL_ATTRIBUTE_CONST declares:
176 calls to the function with the same arguments. 417 It is OK for a compiler to move a call, or omit a duplicate call
177 This attribute is safe for a function that neither depends on nor affects 418 and reuse a cached return value, even if the state changes between calls.
178 observable state, and always returns exactly once - e.g., does not loop 419 It is also OK to omit a call if the result is not used.
179 forever, and does not call longjmp. 420 This attribute is safe if the function does not change observable state,
180 (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ 421 returns a value determined solely by its arguments' values
422 without examining state, and always returns exactly once -
423 e.g., does not raise an exception, call longjmp, or loop forever.
424 (This attribute is stricter than _GL_ATTRIBUTE_PURE because the
425 function cannot observe state. Unlike _GL_ATTRIBUTE_UNSEQUENCED
426 the function must return exactly once and cannot access state
427 addressed by its pointer arguments or that happens to have the same
428 value for all calls to the function, but the function is allowed to
429 return a pointer to storage that can be modified later. */
181/* Applies to: functions. */ 430/* Applies to: functions. */
182#ifndef _GL_ATTRIBUTE_CONST 431#ifndef _GL_ATTRIBUTE_CONST
183# if _GL_HAS_ATTRIBUTE (const) 432# if _GL_HAS_ATTRIBUTE (const)
@@ -205,7 +454,7 @@ AC_DEFUN([gl_COMMON_BODY], [
205 yet. */ 454 yet. */
206#ifndef _GL_ATTRIBUTE_DEALLOC_FREE 455#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
207# if defined __cplusplus && defined __GNUC__ && !defined __clang__ 456# if defined __cplusplus && defined __GNUC__ && !defined __clang__
208/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */ 457/* Work around GCC bug <https://gcc.gnu.org/PR108231> */
209# define _GL_ATTRIBUTE_DEALLOC_FREE \ 458# define _GL_ATTRIBUTE_DEALLOC_FREE \
210 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) 459 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
211# else 460# else
@@ -223,9 +472,11 @@ AC_DEFUN([gl_COMMON_BODY], [
223 - typedef, 472 - typedef,
224 in C++ also: namespace, class, template specialization. */ 473 in C++ also: namespace, class, template specialization. */
225#ifndef _GL_ATTRIBUTE_DEPRECATED 474#ifndef _GL_ATTRIBUTE_DEPRECATED
226# ifdef __has_c_attribute 475# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
227# if __has_c_attribute (__deprecated__) 476# if _GL_HAVE___HAS_C_ATTRIBUTE
228# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] 477# if __has_c_attribute (__deprecated__)
478# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
479# endif
229# endif 480# endif
230# endif 481# endif
231# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) 482# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
@@ -271,7 +522,7 @@ AC_DEFUN([gl_COMMON_BODY], [
271/* Applies to: Empty statement (;), inside a 'switch' statement. */ 522/* Applies to: Empty statement (;), inside a 'switch' statement. */
272/* Always expands to something. */ 523/* Always expands to something. */
273#ifndef _GL_ATTRIBUTE_FALLTHROUGH 524#ifndef _GL_ATTRIBUTE_FALLTHROUGH
274# ifdef __has_c_attribute 525# if _GL_HAVE___HAS_C_ATTRIBUTE
275# if __has_c_attribute (__fallthrough__) 526# if __has_c_attribute (__fallthrough__)
276# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] 527# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
277# endif 528# endif
@@ -342,7 +593,9 @@ AC_DEFUN([gl_COMMON_BODY], [
342 593
343/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if 594/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
344 the entity is not used. The compiler should not warn if the entity is not 595 the entity is not used. The compiler should not warn if the entity is not
345 used. */ 596 used. However, 'int _GL_UNNAMED (i)' is preferable to
597 '_GL_ATTRIBUTE_MAYBE_UNUSED int i' when parameter I is unused
598 regardless of preprocessor macro settings. */
346/* Applies to: 599/* Applies to:
347 - function, variable, 600 - function, variable,
348 - struct, union, struct/union member, 601 - struct, union, struct/union member,
@@ -351,11 +604,19 @@ AC_DEFUN([gl_COMMON_BODY], [
351 in C++ also: class. */ 604 in C++ also: class. */
352/* In C++ and C23, this is spelled [[__maybe_unused__]]. 605/* In C++ and C23, this is spelled [[__maybe_unused__]].
353 GCC's syntax is __attribute__ ((__unused__)). 606 GCC's syntax is __attribute__ ((__unused__)).
354 clang supports both syntaxes. */ 607 clang supports both syntaxes. Except that with clang ≥ 6, < 10, in C++ mode,
608 __has_c_attribute (__maybe_unused__) yields true but the use of
609 [[__maybe_unused__]] nevertheless produces a warning. */
355#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED 610#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
356# ifdef __has_c_attribute 611# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
357# if __has_c_attribute (__maybe_unused__) 612# if defined __clang__ && defined __cplusplus
358# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] 613# if !defined __apple_build_version__ && __clang_major__ >= 10
614# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
615# endif
616# elif _GL_HAVE___HAS_C_ATTRIBUTE
617# if __has_c_attribute (__maybe_unused__)
618# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
619# endif
359# endif 620# endif
360# endif 621# endif
361# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED 622# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
@@ -373,9 +634,20 @@ AC_DEFUN([gl_COMMON_BODY], [
373 the return value, unless the caller uses something like ignore_value. */ 634 the return value, unless the caller uses something like ignore_value. */
374/* Applies to: function, enumeration, class. */ 635/* Applies to: function, enumeration, class. */
375#ifndef _GL_ATTRIBUTE_NODISCARD 636#ifndef _GL_ATTRIBUTE_NODISCARD
376# ifdef __has_c_attribute 637# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
377# if __has_c_attribute (__nodiscard__) 638# if defined __clang__ && defined __cplusplus
378# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] 639 /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces
640 a warning.
641 The 1000 below means a yet unknown threshold. When clang++ version X
642 starts supporting [[__nodiscard__]] without warning about it, you can
643 replace the 1000 with X. */
644# if __clang_major__ >= 1000
645# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
646# endif
647# elif _GL_HAVE___HAS_C_ATTRIBUTE
648# if __has_c_attribute (__nodiscard__)
649# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
650# endif
379# endif 651# endif
380# endif 652# endif
381# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) 653# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
@@ -410,6 +682,17 @@ AC_DEFUN([gl_COMMON_BODY], [
410# endif 682# endif
411#endif 683#endif
412 684
685/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
686 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
687/* Applies to: functions. */
688#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
689# if _GL_HAS_ATTRIBUTE (nonnull_if_nonzero)
690# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
691# else
692# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
693# endif
694#endif
695
413/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is 696/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
414 not meant to be NUL-terminated. */ 697 not meant to be NUL-terminated. */
415/* Applies to: struct/union members and variables that are arrays of element 698/* Applies to: struct/union members and variables that are arrays of element
@@ -427,11 +710,25 @@ AC_DEFUN([gl_COMMON_BODY], [
427/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. 710/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
428 */ 711 */
429/* Applies to: functions. */ 712/* Applies to: functions. */
713/* After a function's parameter list, this attribute must come first, before
714 other attributes. */
430#ifndef _GL_ATTRIBUTE_NOTHROW 715#ifndef _GL_ATTRIBUTE_NOTHROW
431# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus 716# if defined __cplusplus
432# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) 717# if _GL_GNUC_PREREQ (2, 8) || __clang_major__ >= 4
718# if __cplusplus >= 201103L
719# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
720# else
721# define _GL_ATTRIBUTE_NOTHROW throw ()
722# endif
723# else
724# define _GL_ATTRIBUTE_NOTHROW
725# endif
433# else 726# else
434# define _GL_ATTRIBUTE_NOTHROW 727# if _GL_HAS_ATTRIBUTE (nothrow)
728# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
729# else
730# define _GL_ATTRIBUTE_NOTHROW
731# endif
435# endif 732# endif
436#endif 733#endif
437 734
@@ -442,19 +739,27 @@ AC_DEFUN([gl_COMMON_BODY], [
442/* Applies to: struct members, struct, union, 739/* Applies to: struct members, struct, union,
443 in C++ also: class. */ 740 in C++ also: class. */
444#ifndef _GL_ATTRIBUTE_PACKED 741#ifndef _GL_ATTRIBUTE_PACKED
445# if _GL_HAS_ATTRIBUTE (packed) 742/* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite
743 __has_attribute OK. */
744# if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C
446# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) 745# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
447# else 746# else
448# define _GL_ATTRIBUTE_PACKED 747# define _GL_ATTRIBUTE_PACKED
449# endif 748# endif
450#endif 749#endif
451 750
452/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate 751/* _GL_ATTRIBUTE_PURE declares:
453 calls to the function with the same arguments if observable state is not 752 It is OK for a compiler to move a call, or omit a duplicate call
454 changed between calls. 753 and reuse a cached return value, if observable state is the same.
455 This attribute is safe for a function that does not affect 754 It is also OK to omit a call if the return value is not used.
456 observable state, and always returns exactly once. 755 This attribute is safe if the function does not change observable state,
457 (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ 756 returns a value determined solely by its arguments's values
757 together with observable state, and always returns exactly once.
758 (This attribute is looser than _GL_ATTRIBUTE_CONST because the function
759 can depend on observable state.
760 Unlike _GL_ATTRIBUTE_REPRODUCIBLE the function must return exactly
761 once and cannot change state addressed by its arguments, but the
762 function can return a pointer to storage whose contents change later.) */
458/* Applies to: functions. */ 763/* Applies to: functions. */
459#ifndef _GL_ATTRIBUTE_PURE 764#ifndef _GL_ATTRIBUTE_PURE
460# if _GL_HAS_ATTRIBUTE (pure) 765# if _GL_HAS_ATTRIBUTE (pure)
@@ -464,6 +769,34 @@ AC_DEFUN([gl_COMMON_BODY], [
464# endif 769# endif
465#endif 770#endif
466 771
772/* _GL_ATTRIBUTE_REPRODUCIBLE declares:
773 It is OK for a compiler to move a call, or omit a duplicate call
774 and reuse a cached value returned either directly or indirectly via
775 a pointer, if other observable state is the same;
776 however, pointer arguments cannot alias.
777 This attribute is safe for a function that is effectless and idempotent;
778 see ISO C 23 § 6.7.13.8 for a definition of these terms.
779 (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because
780 the function need not be stateless or independent.
781 Unlike _GL_ATTRIBUTE_PURE the function need not return exactly once
782 and can change state addressed by its pointer arguments, but the
783 function cannot return a pointer to storage whose contents change later.)
784 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
785 <https://stackoverflow.com/questions/76847905/>. */
786/* Applies to: functions, pointer to functions, function types. */
787#ifndef _GL_ATTRIBUTE_REPRODUCIBLE
788/* This may be revisited when gcc and clang support [[reproducible]] or possibly
789 __attribute__ ((__reproducible__)). */
790# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
791# if _GL_HAS_ATTRIBUTE (reproducible)
792# define _GL_ATTRIBUTE_REPRODUCIBLE [[reproducible]]
793# endif
794# endif
795# ifndef _GL_ATTRIBUTE_REPRODUCIBLE
796# define _GL_ATTRIBUTE_REPRODUCIBLE
797# endif
798#endif
799
467/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is 800/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
468 a non-NULL pointer. */ 801 a non-NULL pointer. */
469/* Applies to: functions. */ 802/* Applies to: functions. */
@@ -488,6 +821,37 @@ AC_DEFUN([gl_COMMON_BODY], [
488# endif 821# endif
489#endif 822#endif
490 823
824/* _GL_ATTRIBUTE_UNSEQUENCED declares:
825 It is OK for a compiler to move a call, or omit a duplicate call
826 and reuse a cached value returned either directly or indirectly via
827 a pointer, if the state addressed by its pointer arguments is the same;
828 however, pointer arguments cannot alias.
829 This attribute is safe for a function that is effectless, idempotent,
830 stateless, and independent; see ISO C 23 § 6.7.13.8 for a definition of
831 these terms.
832 (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because
833 the function must be stateless and independent. Unlike
834 _GL_ATTRIBUTE_CONST the function need not return exactly once, and
835 can depend on state accessed via its pointer arguments or that
836 happens to have the same value for all calls to the function, but
837 the function cannot return a pointer to storage whose contents
838 change later.)
839 See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
840 <https://stackoverflow.com/questions/76847905/>. */
841/* Applies to: functions, pointer to functions, function types. */
842#ifndef _GL_ATTRIBUTE_UNSEQUENCED
843/* This may be revisited when gcc and clang support [[unsequenced]] or possibly
844 __attribute__ ((__unsequenced__)). */
845# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
846# if _GL_HAS_ATTRIBUTE (unsequenced)
847# define _GL_ATTRIBUTE_UNSEQUENCED [[unsequenced]]
848# endif
849# endif
850# ifndef _GL_ATTRIBUTE_UNSEQUENCED
851# define _GL_ATTRIBUTE_UNSEQUENCED
852# endif
853#endif
854
491/* A helper macro. Don't use it directly. */ 855/* A helper macro. Don't use it directly. */
492#ifndef _GL_ATTRIBUTE_UNUSED 856#ifndef _GL_ATTRIBUTE_UNUSED
493# if _GL_HAS_ATTRIBUTE (unused) 857# if _GL_HAS_ATTRIBUTE (unused)
@@ -512,6 +876,62 @@ AC_DEFUN([gl_COMMON_BODY], [
512# define _GL_UNUSED_LABEL 876# define _GL_UNUSED_LABEL
513# endif 877# endif
514#endif 878#endif
879
880/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter.
881 Each of the function's unnamed parameters should have a unique "name".
882 The "name" cannot be used. This ports both to C17 and earlier, which
883 lack unnamed parameters, and to C++ and later C, which have them. */
884/* Applies to:
885 - function parameters. */
886#ifndef _GL_UNNAMED
887# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \
888 && !defined __cplusplus)
889# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED
890# else
891# define _GL_UNNAMED(id)
892# endif
893#endif
894
895/* The following attributes enable detection of multithread-safety problems
896 and resource leaks at compile-time, by clang ≥ 15, when the warning option
897 -Wthread-safety is enabled. For usage, see
898 <https://clang.llvm.org/docs/ThreadSafetyAnalysis.html>. */
899#ifndef _GL_ATTRIBUTE_CAPABILITY_TYPE
900# if __clang_major__ >= 15
901# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) \
902 __attribute__ ((__capability__ (concept)))
903# else
904# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept)
905# endif
906#endif
907#ifndef _GL_ATTRIBUTE_ACQUIRE_CAPABILITY
908# if __clang_major__ >= 15
909# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) \
910 __attribute__ ((__acquire_capability__ (resource)))
911# else
912# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource)
913# endif
914#endif
915#ifndef _GL_ATTRIBUTE_RELEASE_CAPABILITY
916# if __clang_major__ >= 15
917# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) \
918 __attribute__ ((__release_capability__ (resource)))
919# else
920# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource)
921# endif
922#endif
923])
924 AH_VERBATIM([c_linkage],
925[/* In C++, there is the concept of "language linkage", that encompasses
926 name mangling and function calling conventions.
927 The following macros start and end a block of "C" linkage. */
928#ifdef __cplusplus
929# define _GL_BEGIN_C_LINKAGE extern "C" {
930# define _GL_END_C_LINKAGE }
931#else
932# define _GL_BEGIN_C_LINKAGE
933# define _GL_END_C_LINKAGE
934#endif
515]) 935])
516 AH_VERBATIM([async_safe], 936 AH_VERBATIM([async_safe],
517[/* The _GL_ASYNC_SAFE marker should be attached to functions that are 937[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
@@ -550,8 +970,8 @@ AC_DEFUN([gl_COMMON_BODY], [
550 -1 if n1 < n2 970 -1 if n1 < n2
551 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional 971 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
552 jump with nearly all GCC versions up to GCC 10. 972 jump with nearly all GCC versions up to GCC 10.
553 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many 973 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional jump with
554 GCC versions up to GCC 9. 974 many GCC versions up to GCC 9.
555 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9 975 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
556 avoids conditional jumps in all GCC versions >= 3.4. */ 976 avoids conditional jumps in all GCC versions >= 3.4. */
557#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) 977#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
@@ -568,7 +988,7 @@ AC_DEFUN([gl_COMMON_BODY], [
568 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), 988 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
569 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). 989 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
570 AC_ARG_ENABLE([cross-guesses], 990 AC_ARG_ENABLE([cross-guesses],
571 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}], 991 [AS_HELP_STRING([[--enable-cross-guesses={conservative|risky}]],
572 [specify policy for cross-compilation guesses])], 992 [specify policy for cross-compilation guesses])],
573 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then 993 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
574 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) 994 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
@@ -928,7 +1348,7 @@ AC_DEFUN([gl_CC_ALLOW_WARNINGS],
928 AC_REQUIRE([AC_PROG_CC]) 1348 AC_REQUIRE([AC_PROG_CC])
929 AC_CACHE_CHECK([for C compiler option to allow warnings], 1349 AC_CACHE_CHECK([for C compiler option to allow warnings],
930 [gl_cv_cc_wallow], 1350 [gl_cv_cc_wallow],
931 [rm -f conftest* 1351 [rm -fr conftest*
932 echo 'int dummy;' > conftest.c 1352 echo 'int dummy;' > conftest.c
933 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null 1353 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
934 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null 1354 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
@@ -941,7 +1361,7 @@ AC_DEFUN([gl_CC_ALLOW_WARNINGS],
941 else 1361 else
942 gl_cv_cc_wallow=none 1362 gl_cv_cc_wallow=none
943 fi 1363 fi
944 rm -f conftest* 1364 rm -fr conftest*
945 ]) 1365 ])
946 case "$gl_cv_cc_wallow" in 1366 case "$gl_cv_cc_wallow" in
947 none) GL_CFLAG_ALLOW_WARNINGS='' ;; 1367 none) GL_CFLAG_ALLOW_WARNINGS='' ;;
@@ -959,7 +1379,7 @@ AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
959 if test -n "$CXX" && test "$CXX" != no; then 1379 if test -n "$CXX" && test "$CXX" != no; then
960 AC_CACHE_CHECK([for C++ compiler option to allow warnings], 1380 AC_CACHE_CHECK([for C++ compiler option to allow warnings],
961 [gl_cv_cxx_wallow], 1381 [gl_cv_cxx_wallow],
962 [rm -f conftest* 1382 [rm -fr conftest*
963 echo 'int dummy;' > conftest.cc 1383 echo 'int dummy;' > conftest.cc
964 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null 1384 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
965 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null 1385 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
@@ -972,7 +1392,7 @@ AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
972 else 1392 else
973 gl_cv_cxx_wallow=none 1393 gl_cv_cxx_wallow=none
974 fi 1394 fi
975 rm -f conftest* 1395 rm -fr conftest*
976 ]) 1396 ])
977 case "$gl_cv_cxx_wallow" in 1397 case "$gl_cv_cxx_wallow" in
978 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; 1398 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
@@ -1005,14 +1425,16 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
1005 dnl -Wno-pedantic >= 4.8 >= 3.9 1425 dnl -Wno-pedantic >= 4.8 >= 3.9
1006 dnl -Wno-sign-compare >= 3 >= 3.9 1426 dnl -Wno-sign-compare >= 3 >= 3.9
1007 dnl -Wno-sign-conversion >= 4.3 >= 3.9 1427 dnl -Wno-sign-conversion >= 4.3 >= 3.9
1428 dnl -Wno-tautological-out-of-range-compare - >= 3.9
1008 dnl -Wno-type-limits >= 4.3 >= 3.9 1429 dnl -Wno-type-limits >= 4.3 >= 3.9
1009 dnl -Wno-undef >= 3 >= 3.9 1430 dnl -Wno-undef >= 3 >= 3.9
1010 dnl -Wno-unsuffixed-float-constants >= 4.5 1431 dnl -Wno-unsuffixed-float-constants >= 4.5
1432 dnl -Wno-unused-const-variable >= 6.1 >= 3.9
1011 dnl -Wno-unused-function >= 3 >= 3.9 1433 dnl -Wno-unused-function >= 3 >= 3.9
1012 dnl -Wno-unused-parameter >= 3 >= 3.9 1434 dnl -Wno-unused-parameter >= 3 >= 3.9
1013 dnl 1435 dnl
1014 cat > conftest.c <<\EOF 1436 cat > conftest.c <<\EOF
1015 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3) 1437 #if (__GNUC__ >= 3 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1016 -Wno-cast-qual 1438 -Wno-cast-qual
1017 -Wno-conversion 1439 -Wno-conversion
1018 -Wno-float-equal 1440 -Wno-float-equal
@@ -1021,20 +1443,26 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
1021 -Wno-unused-function 1443 -Wno-unused-function
1022 -Wno-unused-parameter 1444 -Wno-unused-parameter
1023 #endif 1445 #endif
1024 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) 1446 #if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1025 -Wno-float-conversion 1447 -Wno-float-conversion
1026 #endif 1448 #endif
1027 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3) 1449 #if (__GNUC__ >= 7 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1028 -Wimplicit-fallthrough 1450 -Wimplicit-fallthrough
1029 #endif 1451 #endif
1030 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) 1452 #if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1031 -Wno-pedantic 1453 -Wno-pedantic
1032 #endif 1454 #endif
1033 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3) 1455 #if 3 < __clang_major__ + (9 <= __clang_minor__)
1456 -Wno-tautological-constant-out-of-range-compare
1457 #endif
1458 #if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1034 -Wno-sign-conversion 1459 -Wno-sign-conversion
1035 -Wno-type-limits 1460 -Wno-type-limits
1036 #endif 1461 #endif
1037 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4 1462 #if (__GNUC__ + (__GNUC_MINOR__ >= 1) > 6 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1463 -Wno-unused-const-variable
1464 #endif
1465 #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__)
1038 -Wno-unsuffixed-float-constants 1466 -Wno-unsuffixed-float-constants
1039 #endif 1467 #endif
1040EOF 1468EOF
@@ -1080,6 +1508,250 @@ AC_DEFUN([gl_CONDITIONAL_HEADER],
1080 m4_popdef([gl_header_name]) 1508 m4_popdef([gl_header_name])
1081]) 1509])
1082 1510
1511dnl Preparations for gl_CHECK_FUNCS_MACOS.
1512AC_DEFUN([gl_PREPARE_CHECK_FUNCS_MACOS],
1513[
1514 AC_REQUIRE([AC_CANONICAL_HOST])
1515 AC_REQUIRE([gl_COMPILER_CLANG])
1516 AC_CACHE_CHECK([for compiler option needed when checking for future declarations],
1517 [gl_cv_compiler_check_future_option],
1518 [case "$host_os" in
1519 dnl This is only needed on macOS.
1520 darwin*)
1521 if test $gl_cv_compiler_clang = yes; then
1522 dnl Test whether the compiler supports the option
1523 dnl '-Werror=unguarded-availability-new'.
1524 saved_ac_compile="$ac_compile"
1525 ac_compile="$ac_compile -Werror=unguarded-availability-new"
1526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
1527 [gl_cv_compiler_check_future_option='-Werror=unguarded-availability-new'],
1528 [gl_cv_compiler_check_future_option=none])
1529 ac_compile="$saved_ac_compile"
1530 else
1531 gl_cv_compiler_check_future_option=none
1532 fi
1533 ;;
1534 *) gl_cv_compiler_check_future_option=none ;;
1535 esac
1536 ])
1537])
1538
1539dnl Pieces of the expansion of
1540dnl gl_CHECK_FUNCS_ANDROID
1541dnl gl_CHECK_FUNCS_MACOS
1542dnl gl_CHECK_FUNCS_ANDROID_MACOS
1543
1544AC_DEFUN([gl_CHECK_FUNCS_DEFAULT_CASE],
1545[
1546 *)
1547 AC_CHECK_FUNC([$1])
1548 [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1]
1549 ;;
1550])
1551
1552AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_ANDROID],
1553[
1554 linux*-android*)
1555 AC_CHECK_DECL([$1], , , [$2])
1556 if test $[ac_cv_have_decl_][$1] = yes; then
1557 AC_CHECK_FUNC([[$1]])
1558 if test $[ac_cv_func_][$1] = yes; then
1559 [gl_cv_onwards_func_][$1]=yes
1560 else
1561 dnl The function is declared but does not exist. This should not
1562 dnl happen normally. But anyway, we know that a future version
1563 dnl of Android will have the function.
1564 [gl_cv_onwards_func_][$1]='future OS version'
1565 fi
1566 else
1567 [gl_cv_onwards_func_][$1]='future OS version'
1568 fi
1569 ;;
1570])
1571
1572AC_DEFUN([gl_CHECK_FUNCS_CASE_FOR_MACOS],
1573[
1574 darwin*)
1575 if test "x$gl_cv_compiler_check_future_option" != "xnone"; then
1576 dnl Use a compile test, not a link test.
1577 saved_ac_compile="$ac_compile"
1578 ac_compile="$ac_compile $gl_cv_compiler_check_future_option"
1579 saved_ac_compile_for_check_decl="$ac_compile_for_check_decl"
1580 ac_compile_for_check_decl="$ac_compile_for_check_decl $gl_cv_compiler_check_future_option"
1581 unset [ac_cv_have_decl_][$1]
1582 AC_CHECK_DECL([$1], , , [$2])
1583 ac_compile="$saved_ac_compile"
1584 ac_compile_for_check_decl="$saved_ac_compile_for_check_decl"
1585 [ac_cv_func_][$1]="$[ac_cv_have_decl_][$1]"
1586 if test $[ac_cv_func_][$1] = yes; then
1587 [gl_cv_onwards_func_][$1]=yes
1588 else
1589 dnl This is a bit complicated, because here we need the behaviour
1590 dnl of AC_CHECK_DECL before the
1591 dnl commit e1bbc9b93cdff61d70719c224b37970e065008bb (2025-05-26).
1592 [ac_cv_have_decl_][$1][_saved]="$[ac_cv_have_decl_][$1]"
1593 unset [ac_cv_have_decl_][$1]
1594 ac_c_future_darwin_options_saved="$ac_c_future_darwin_options"
1595 ac_cxx_future_darwin_options_saved="$ac_cxx_future_darwin_options"
1596 ac_c_future_darwin_options=
1597 ac_cxx_future_darwin_options=
1598 AC_CHECK_DECL([$1], , , [$2])
1599 ac_c_future_darwin_options="$ac_c_future_darwin_options_saved"
1600 ac_cxx_future_darwin_options="$ac_cxx_future_darwin_options_saved"
1601 if test $[ac_cv_have_decl_][$1] = yes; then
1602 [gl_cv_onwards_func_][$1]='future OS version'
1603 else
1604 [gl_cv_onwards_func_][$1]=no
1605 fi
1606 [ac_cv_have_decl_][$1]="$[ac_cv_have_decl_][$1][_saved]"
1607 unset [ac_cv_have_decl_][$1][_saved]
1608 fi
1609 else
1610 AC_CHECK_FUNC([$1])
1611 [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1]
1612 fi
1613 ;;
1614])
1615
1616AC_DEFUN([gl_CHECK_FUNCS_SET_RESULTS],
1617[
1618 case "$[gl_cv_onwards_func_][$1]" in
1619 future*) [ac_cv_func_][$1]=no ;;
1620 *) [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;;
1621 esac
1622 if test $[ac_cv_func_][$1] = yes; then
1623 AC_DEFINE([HAVE_]m4_translit([[$1]],
1624 [abcdefghijklmnopqrstuvwxyz],
1625 [ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
1626 [1], [Define to 1 if you have the `$1' function.])
1627 fi
1628])
1629
1630dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
1631dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
1632dnl on Android.
1633dnl
1634dnl When code is compiled on Android, it is in the context of a certain
1635dnl "Android API level", which indicates the minimum version of Android on
1636dnl which the app can be installed. In other words, you don't compile for a
1637dnl specific version of Android. You compile for all versions of Android,
1638dnl onwards from the given API level.
1639dnl Thus, the question "does the OS have the function func" has three possible
1640dnl answers:
1641dnl - yes, in all versions starting from the given API level,
1642dnl - no, in no version,
1643dnl - not in the given API level, but in a later version of Android.
1644dnl
1645dnl In detail, this works as follows:
1646dnl If func was added to Android API level, say, 28, then the libc.so has the
1647dnl symbol func always, whereas the header file <foo.h> declares func
1648dnl conditionally:
1649dnl #if __ANDROID_API__ >= 28
1650dnl ... func (...) __INTRODUCED_IN(28);
1651dnl #endif
1652dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28",
1653dnl the function func is declared and exists in libc.
1654dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27",
1655dnl the function func is not declared but exists in libc.
1656dnl
1657dnl This macro sets two variables:
1658dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
1659dnl - ac_cv_func_<func> to yes / no / no
1660dnl The first variable allows distinguishing all three cases.
1661dnl The second variable is set, so that an invocation
1662dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
1663dnl can be used as a drop-in replacement for
1664dnl AC_CHECK_FUNCS([func]).
1665AC_DEFUN([gl_CHECK_FUNCS_ANDROID],
1666[
1667 AC_REQUIRE([AC_CANONICAL_HOST])
1668 AC_CACHE_CHECK([for [$1]],
1669 [[gl_cv_onwards_func_][$1]],
1670 [gl_SILENT([
1671 case "$host_os" in
1672 gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2])
1673 gl_CHECK_FUNCS_DEFAULT_CASE([$1])
1674 esac
1675 ])
1676 ])
1677 gl_CHECK_FUNCS_SET_RESULTS([$1])
1678])
1679
1680dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]])
1681dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
1682dnl on macOS.
1683dnl
1684dnl When code is compiled on macOS, it is in the context of a certain minimum
1685dnl macOS version, that can be set through the option '-mmacosx-version-min='.
1686dnl In other words, you don't compile for a specific version of macOS. You
1687dnl compile for all versions of macOS, onwards from the given version.
1688dnl Thus, the question "does the OS have the function func" has three possible
1689dnl answers:
1690dnl - yes, in all versions starting from the given version,
1691dnl - no, in no version,
1692dnl - not in the given version, but in a later version of macOS.
1693dnl
1694dnl In detail, this works as follows:
1695dnl If func was added to, say, macOS version 13, then the libc has the
1696dnl symbol func always, whereas the header file <foo.h> declares func
1697dnl conditionally with a special availability attribute:
1698dnl ... func (...) __attribute__((availability(macos,introduced=13.0)));
1699dnl Thus, when compiling with "clang mmacosx-version-min=13", there is no
1700dnl warning about the use of func, and the resulting binary
1701dnl - runs fine on macOS 13,
1702dnl - aborts with a dyld "Symbol not found" message on macOS 12.
1703dnl Whereas, when compiling with "clang mmacosx-version-min=12", there is a
1704dnl warning: 'func' is only available on macOS 13.0 or newer
1705dnl [-Wunguarded-availability-new],
1706dnl and the resulting binary
1707dnl - runs fine on macOS 13,
1708dnl - crashes with a SIGSEGV (signal 11) on macOS 12.
1709dnl
1710dnl This macro sets two variables:
1711dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
1712dnl - ac_cv_func_<func> to yes / no / no
1713dnl The first variable allows distinguishing all three cases.
1714dnl The second variable is set, so that an invocation
1715dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]])
1716dnl can be used as a drop-in replacement for
1717dnl AC_CHECK_FUNCS([func]).
1718AC_DEFUN([gl_CHECK_FUNCS_MACOS],
1719[
1720 AC_REQUIRE([AC_CANONICAL_HOST])
1721 AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS])
1722 AC_CACHE_CHECK([for [$1]],
1723 [[gl_cv_onwards_func_][$1]],
1724 [gl_SILENT([
1725 case "$host_os" in
1726 gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2])
1727 gl_CHECK_FUNCS_DEFAULT_CASE([$1])
1728 esac
1729 ])
1730 ])
1731 gl_CHECK_FUNCS_SET_RESULTS([$1])
1732])
1733
1734dnl gl_CHECK_FUNCS_ANDROID_MACOS([func], [[#include <foo.h>]])
1735dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
1736dnl on Android and on macOS.
1737dnl It is the combination of gl_CHECK_FUNCS_ANDROID and gl_CHECK_FUNCS_MACOS.
1738AC_DEFUN([gl_CHECK_FUNCS_ANDROID_MACOS],
1739[
1740 AC_REQUIRE([AC_CANONICAL_HOST])
1741 AC_REQUIRE([gl_PREPARE_CHECK_FUNCS_MACOS])
1742 AC_CACHE_CHECK([for [$1]],
1743 [[gl_cv_onwards_func_][$1]],
1744 [gl_SILENT([
1745 case "$host_os" in
1746 gl_CHECK_FUNCS_CASE_FOR_ANDROID([$1], [$2])
1747 gl_CHECK_FUNCS_CASE_FOR_MACOS([$1], [$2])
1748 gl_CHECK_FUNCS_DEFAULT_CASE([$1])
1749 esac
1750 ])
1751 ])
1752 gl_CHECK_FUNCS_SET_RESULTS([$1])
1753])
1754
1083dnl Expands to some code for use in .c programs that, on native Windows, defines 1755dnl Expands to some code for use in .c programs that, on native Windows, defines
1084dnl the Microsoft deprecated alias function names to the underscore-prefixed 1756dnl the Microsoft deprecated alias function names to the underscore-prefixed
1085dnl actual function names. With this macro, these function names are available 1757dnl actual function names. With this macro, these function names are available
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 4764622e..cdd46759 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,5 +1,5 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY! 1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2002-2023 Free Software Foundation, Inc. 2# Copyright (C) 2002-2026 Free Software Foundation, Inc.
3# 3#
4# This file is free software; you can redistribute it and/or modify 4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
@@ -43,15 +43,32 @@ AC_DEFUN([gl_EARLY],
43 AC_REQUIRE([gl_PROG_AR_RANLIB]) 43 AC_REQUIRE([gl_PROG_AR_RANLIB])
44 44
45 # Code from module absolute-header: 45 # Code from module absolute-header:
46 # Code from module alignasof:
46 # Code from module alloca-opt: 47 # Code from module alloca-opt:
47 # Code from module arpa_inet: 48 # Code from module arpa_inet-h:
48 # Code from module assert-h: 49 # Code from module assert-h:
49 # Code from module attribute: 50 # Code from module attribute:
50 # Code from module base64: 51 # Code from module base64:
51 # Code from module basename-lgpl: 52 # Code from module basename-lgpl:
53 # Code from module bool:
52 # Code from module btowc: 54 # Code from module btowc:
53 # Code from module builtin-expect: 55 # Code from module builtin-expect:
54 # Code from module byteswap: 56 # Code from module byteswap:
57 # Code from module c-ctype:
58 # Code from module c32isalnum:
59 # Code from module c32isalpha:
60 # Code from module c32isblank:
61 # Code from module c32iscntrl:
62 # Code from module c32isdigit:
63 # Code from module c32isgraph:
64 # Code from module c32islower:
65 # Code from module c32isprint:
66 # Code from module c32ispunct:
67 # Code from module c32isspace:
68 # Code from module c32isupper:
69 # Code from module c32isxdigit:
70 # Code from module c32tolower:
71 # Code from module c32width:
55 # Code from module c99: 72 # Code from module c99:
56 # Code from module calloc-gnu: 73 # Code from module calloc-gnu:
57 # Code from module calloc-posix: 74 # Code from module calloc-posix:
@@ -65,10 +82,15 @@ AC_DEFUN([gl_EARLY],
65 # Code from module double-slash-root: 82 # Code from module double-slash-root:
66 # Code from module dup2: 83 # Code from module dup2:
67 # Code from module environ: 84 # Code from module environ:
68 # Code from module errno: 85 # Code from module errno-h:
69 # Code from module error: 86 # Code from module error:
87 # Code from module error-h:
70 # Code from module exitfail: 88 # Code from module exitfail:
71 # Code from module extensions: 89 # Code from module extensions:
90 # This is actually already done in the pre-early phase.
91 # AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
92 # Code from module extensions-aix:
93 AC_REQUIRE([gl_USE_AIX_EXTENSIONS])
72 # Code from module extern-inline: 94 # Code from module extern-inline:
73 # Code from module fcntl: 95 # Code from module fcntl:
74 # Code from module fcntl-h: 96 # Code from module fcntl-h:
@@ -76,7 +98,7 @@ AC_DEFUN([gl_EARLY],
76 # Code from module fflush: 98 # Code from module fflush:
77 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE]) 99 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
78 # Code from module filename: 100 # Code from module filename:
79 # Code from module float: 101 # Code from module float-h:
80 # Code from module floorf: 102 # Code from module floorf:
81 # Code from module fopen: 103 # Code from module fopen:
82 # Code from module fopen-gnu: 104 # Code from module fopen-gnu:
@@ -86,6 +108,7 @@ AC_DEFUN([gl_EARLY],
86 # Code from module fseek: 108 # Code from module fseek:
87 # Code from module fseeko: 109 # Code from module fseeko:
88 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE]) 110 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
111 # Code from module fseterr:
89 # Code from module fstat: 112 # Code from module fstat:
90 # Code from module fsusage: 113 # Code from module fsusage:
91 # Code from module ftell: 114 # Code from module ftell:
@@ -103,6 +126,7 @@ AC_DEFUN([gl_EARLY],
103 # Code from module getprogname: 126 # Code from module getprogname:
104 # Code from module gettext-h: 127 # Code from module gettext-h:
105 # Code from module glibc-internal/dynarray: 128 # Code from module glibc-internal/dynarray:
129 # Code from module gnulib-i18n:
106 # Code from module hard-locale: 130 # Code from module hard-locale:
107 # Code from module hostent: 131 # Code from module hostent:
108 # Code from module ialloc: 132 # Code from module ialloc:
@@ -110,24 +134,36 @@ AC_DEFUN([gl_EARLY],
110 # Code from module idx: 134 # Code from module idx:
111 # Code from module include_next: 135 # Code from module include_next:
112 # Code from module inet_ntop: 136 # Code from module inet_ntop:
137 # Code from module inet_pton:
113 # Code from module intprops: 138 # Code from module intprops:
114 # Code from module inttypes-incomplete: 139 # Code from module inttypes-h-incomplete:
115 # Code from module langinfo: 140 # Code from module iswblank:
141 # Code from module iswctype:
142 # Code from module iswdigit:
143 # Code from module iswpunct:
144 # Code from module iswxdigit:
145 # Code from module langinfo-h:
116 # Code from module largefile: 146 # Code from module largefile:
117 AC_REQUIRE([AC_SYS_LARGEFILE]) 147 AC_REQUIRE([AC_SYS_LARGEFILE])
118 # Code from module libc-config: 148 # Code from module libc-config:
119 # Code from module limits-h: 149 # Code from module limits-h:
120 # Code from module localcharset: 150 # Code from module localcharset:
121 # Code from module locale: 151 # Code from module locale-h:
122 # Code from module localeconv: 152 # Code from module localeconv:
123 # Code from module lock: 153 # Code from module lock:
124 # Code from module lseek: 154 # Code from module lseek:
155 # Code from module lstat:
125 # Code from module malloc-gnu: 156 # Code from module malloc-gnu:
126 # Code from module malloc-posix: 157 # Code from module malloc-posix:
127 # Code from module malloca: 158 # Code from module malloca:
128 # Code from module math: 159 # Code from module math-h:
160 # Code from module mbchar:
161 # Code from module mbiterf:
162 # Code from module mbrtoc32:
129 # Code from module mbrtowc: 163 # Code from module mbrtowc:
130 # Code from module mbsinit: 164 # Code from module mbsinit:
165 # Code from module mbsnlen:
166 # Code from module mbszero:
131 # Code from module mbtowc: 167 # Code from module mbtowc:
132 # Code from module memchr: 168 # Code from module memchr:
133 # Code from module minmax: 169 # Code from module minmax:
@@ -137,19 +173,24 @@ AC_DEFUN([gl_EARLY],
137 # Code from module msvc-inval: 173 # Code from module msvc-inval:
138 # Code from module msvc-nothrow: 174 # Code from module msvc-nothrow:
139 # Code from module multiarch: 175 # Code from module multiarch:
140 # Code from module netdb: 176 # Code from module netdb-h:
141 # Code from module netinet_in: 177 # Code from module netinet_in-h:
142 # Code from module nl_langinfo: 178 # Code from module nl_langinfo:
143 # Code from module nocrash: 179 # Code from module nocrash:
180 # Code from module once:
144 # Code from module open: 181 # Code from module open:
145 # Code from module pathmax: 182 # Code from module pathmax:
146 # Code from module realloc-gnu: 183 # Code from module pthread-h:
184 gl_ANYTHREADLIB_EARLY
185 # Code from module pthread-once:
147 # Code from module realloc-posix: 186 # Code from module realloc-posix:
148 # Code from module reallocarray: 187 # Code from module reallocarray:
149 # Code from module regex: 188 # Code from module regex:
189 # Code from module sched-h:
150 # Code from module servent: 190 # Code from module servent:
151 # Code from module setenv: 191 # Code from module setenv:
152 # Code from module setlocale-null: 192 # Code from module setlocale-null:
193 # Code from module setlocale-null-unlocked:
153 # Code from module size_max: 194 # Code from module size_max:
154 # Code from module snippet/_Noreturn: 195 # Code from module snippet/_Noreturn:
155 # Code from module snippet/arg-nonnull: 196 # Code from module snippet/arg-nonnull:
@@ -163,33 +204,58 @@ AC_DEFUN([gl_EARLY],
163 # Code from module stat: 204 # Code from module stat:
164 # Code from module stat-time: 205 # Code from module stat-time:
165 # Code from module std-gnu11: 206 # Code from module std-gnu11:
166 # Code from module stdalign: 207 # Code from module stdckdint-h:
167 # Code from module stdbool: 208 # Code from module stddef-h:
168 # Code from module stdckdint: 209 # Code from module stdint-h:
169 # Code from module stddef: 210 # Code from module stdio-h:
170 # Code from module stdint: 211 gl_STDIO_H_EARLY
171 # Code from module stdio: 212 # Code from module stdio-windows:
172 # Code from module stdlib: 213 # Code from module stdlib-h:
173 # Code from module strcase: 214 # Code from module strcase:
215 # Code from module strcasecmp:
174 # Code from module strcasestr: 216 # Code from module strcasestr:
175 # Code from module strcasestr-simple: 217 # Code from module strcasestr-simple:
176 # Code from module streq: 218 # Code from module streq:
177 # Code from module strerror: 219 # Code from module strerror:
178 # Code from module strerror-override: 220 # Code from module strerror-override:
179 # Code from module string: 221 # Code from module string-h:
180 # Code from module strings: 222 # Code from module stringeq:
223 # Code from module strings-h:
224 # Code from module strncasecmp:
225 # Code from module strncpy:
181 # Code from module strsep: 226 # Code from module strsep:
182 # Code from module strstr-simple: 227 # Code from module strstr-simple:
183 # Code from module sys_socket: 228 # Code from module sys_socket-h:
184 # Code from module sys_stat: 229 # Code from module sys_stat-h:
185 # Code from module sys_types: 230 # Code from module sys_types-h:
186 # Code from module sys_uio: 231 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
232 # Code from module sys_uio-h:
187 # Code from module threadlib: 233 # Code from module threadlib:
188 gl_THREADLIB_EARLY 234 gl_THREADLIB_EARLY
189 # Code from module time: 235 # Code from module time-h:
190 # Code from module time_r: 236 # Code from module time_r:
191 # Code from module timegm: 237 # Code from module timegm:
192 # Code from module unistd: 238 # Code from module uchar-h:
239 # Code from module unicase/base:
240 # Code from module unicase/tolower:
241 # Code from module unictype/base:
242 # Code from module unictype/ctype-alnum:
243 # Code from module unictype/ctype-alpha:
244 # Code from module unictype/ctype-blank:
245 # Code from module unictype/ctype-cntrl:
246 # Code from module unictype/ctype-digit:
247 # Code from module unictype/ctype-graph:
248 # Code from module unictype/ctype-lower:
249 # Code from module unictype/ctype-print:
250 # Code from module unictype/ctype-punct:
251 # Code from module unictype/ctype-space:
252 # Code from module unictype/ctype-upper:
253 # Code from module unictype/ctype-xdigit:
254 # Code from module uninorm/base:
255 # Code from module unistd-h:
256 # Code from module unitypes-h:
257 # Code from module uniwidth/base:
258 # Code from module uniwidth/width:
193 # Code from module unlocked-io-internal: 259 # Code from module unlocked-io-internal:
194 # Code from module unsetenv: 260 # Code from module unsetenv:
195 # Code from module vararrays: 261 # Code from module vararrays:
@@ -197,9 +263,12 @@ AC_DEFUN([gl_EARLY],
197 # Code from module vasprintf: 263 # Code from module vasprintf:
198 # Code from module verify: 264 # Code from module verify:
199 # Code from module vsnprintf: 265 # Code from module vsnprintf:
200 # Code from module wchar: 266 # Code from module vsnzprintf:
267 # Code from module wchar-h:
201 # Code from module wcrtomb: 268 # Code from module wcrtomb:
269 # Code from module wctype:
202 # Code from module wctype-h: 270 # Code from module wctype-h:
271 # Code from module wcwidth:
203 # Code from module windows-mutex: 272 # Code from module windows-mutex:
204 # Code from module windows-once: 273 # Code from module windows-once:
205 # Code from module windows-recmutex: 274 # Code from module windows-recmutex:
@@ -229,6 +298,7 @@ AC_DEFUN([gl_INIT],
229 gl_COMMON 298 gl_COMMON
230 gl_source_base='gl' 299 gl_source_base='gl'
231 gl_source_base_prefix= 300 gl_source_base_prefix=
301 gl_ALIGNASOF
232 gl_FUNC_ALLOCA 302 gl_FUNC_ALLOCA
233 gl_CONDITIONAL_HEADER([alloca.h]) 303 gl_CONDITIONAL_HEADER([alloca.h])
234 AC_PROG_MKDIR_P 304 AC_PROG_MKDIR_P
@@ -239,6 +309,7 @@ AC_DEFUN([gl_INIT],
239 gl_CONDITIONAL_HEADER([assert.h]) 309 gl_CONDITIONAL_HEADER([assert.h])
240 AC_PROG_MKDIR_P 310 AC_PROG_MKDIR_P
241 gl_FUNC_BASE64 311 gl_FUNC_BASE64
312 gl_C_BOOL
242 gl_FUNC_BTOWC 313 gl_FUNC_BTOWC
243 gl_CONDITIONAL([GL_COND_OBJ_BTOWC], 314 gl_CONDITIONAL([GL_COND_OBJ_BTOWC],
244 [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1]) 315 [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1])
@@ -250,6 +321,104 @@ AC_DEFUN([gl_INIT],
250 gl_BYTESWAP 321 gl_BYTESWAP
251 gl_CONDITIONAL_HEADER([byteswap.h]) 322 gl_CONDITIONAL_HEADER([byteswap.h])
252 AC_PROG_MKDIR_P 323 AC_PROG_MKDIR_P
324 AC_REQUIRE([gl_UCHAR_H])
325 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
326 dnl determined. It describes how mbrtoc32 is implemented.
327 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
328 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
329 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
330 gl_UCHAR_MODULE_INDICATOR([c32isalnum])
331 AC_REQUIRE([gl_UCHAR_H])
332 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
333 dnl determined. It describes how mbrtoc32 is implemented.
334 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
335 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
336 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
337 gl_UCHAR_MODULE_INDICATOR([c32isalpha])
338 AC_REQUIRE([gl_UCHAR_H])
339 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
340 dnl determined. It describes how mbrtoc32 is implemented.
341 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
342 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
343 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
344 gl_UCHAR_MODULE_INDICATOR([c32isblank])
345 AC_REQUIRE([gl_UCHAR_H])
346 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
347 dnl determined. It describes how mbrtoc32 is implemented.
348 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
349 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
350 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
351 gl_UCHAR_MODULE_INDICATOR([c32iscntrl])
352 AC_REQUIRE([gl_UCHAR_H])
353 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
354 dnl determined. It describes how mbrtoc32 is implemented.
355 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
356 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
357 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
358 gl_UCHAR_MODULE_INDICATOR([c32isdigit])
359 AC_REQUIRE([gl_UCHAR_H])
360 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
361 dnl determined. It describes how mbrtoc32 is implemented.
362 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
363 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
364 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
365 gl_UCHAR_MODULE_INDICATOR([c32isgraph])
366 AC_REQUIRE([gl_UCHAR_H])
367 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
368 dnl determined. It describes how mbrtoc32 is implemented.
369 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
370 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
371 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
372 gl_UCHAR_MODULE_INDICATOR([c32islower])
373 AC_REQUIRE([gl_UCHAR_H])
374 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
375 dnl determined. It describes how mbrtoc32 is implemented.
376 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
377 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
378 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
379 gl_UCHAR_MODULE_INDICATOR([c32isprint])
380 AC_REQUIRE([gl_UCHAR_H])
381 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
382 dnl determined. It describes how mbrtoc32 is implemented.
383 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
384 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
385 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
386 gl_UCHAR_MODULE_INDICATOR([c32ispunct])
387 AC_REQUIRE([gl_UCHAR_H])
388 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
389 dnl determined. It describes how mbrtoc32 is implemented.
390 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
391 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
392 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
393 gl_UCHAR_MODULE_INDICATOR([c32isspace])
394 AC_REQUIRE([gl_UCHAR_H])
395 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
396 dnl determined. It describes how mbrtoc32 is implemented.
397 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
398 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
399 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
400 gl_UCHAR_MODULE_INDICATOR([c32isupper])
401 AC_REQUIRE([gl_UCHAR_H])
402 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
403 dnl determined. It describes how mbrtoc32 is implemented.
404 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
405 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
406 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
407 gl_UCHAR_MODULE_INDICATOR([c32isxdigit])
408 AC_REQUIRE([gl_UCHAR_H])
409 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
410 dnl determined. It describes how mbrtoc32 is implemented.
411 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
412 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
413 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
414 gl_UCHAR_MODULE_INDICATOR([c32tolower])
415 AC_REQUIRE([gl_UCHAR_H])
416 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
417 dnl determined. It describes how mbrtoc32 is implemented.
418 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
419 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
420 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
421 gl_UCHAR_MODULE_INDICATOR([c32width])
253 gl_FUNC_CALLOC_GNU 422 gl_FUNC_CALLOC_GNU
254 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then 423 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then
255 AC_LIBOBJ([calloc]) 424 AC_LIBOBJ([calloc])
@@ -264,6 +433,7 @@ AC_DEFUN([gl_INIT],
264 gl_FUNC_CLOSE 433 gl_FUNC_CLOSE
265 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1]) 434 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
266 gl_UNISTD_MODULE_INDICATOR([close]) 435 gl_UNISTD_MODULE_INDICATOR([close])
436 gl_MODULE_INDICATOR([close])
267 gl_AF_ALG 437 gl_AF_ALG
268 AC_REQUIRE([AC_C_RESTRICT]) 438 AC_REQUIRE([AC_C_RESTRICT])
269 gl_SHA256 439 gl_SHA256
@@ -280,14 +450,17 @@ AC_DEFUN([gl_INIT],
280 gl_HEADER_ERRNO_H 450 gl_HEADER_ERRNO_H
281 gl_CONDITIONAL_HEADER([errno.h]) 451 gl_CONDITIONAL_HEADER([errno.h])
282 AC_PROG_MKDIR_P 452 AC_PROG_MKDIR_P
453 AC_REQUIRE([gl_ERROR_H])
283 gl_ERROR 454 gl_ERROR
284 gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test "$ac_cv_lib_error_at_line" = no]) 455 gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test $COMPILE_ERROR_C = 1])
285 AM_COND_IF([GL_COND_OBJ_ERROR], [ 456 AM_COND_IF([GL_COND_OBJ_ERROR], [
286 gl_PREREQ_ERROR 457 gl_PREREQ_ERROR
287 ]) 458 ])
288 m4_ifdef([AM_XGETTEXT_OPTION], 459 m4_ifdef([AM_XGETTEXT_OPTION],
289 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) 460 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
290 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) 461 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
462 gl_ERROR_H
463 AC_PROG_MKDIR_P
291 AC_REQUIRE([gl_EXTERN_INLINE]) 464 AC_REQUIRE([gl_EXTERN_INLINE])
292 gl_FUNC_FCNTL 465 gl_FUNC_FCNTL
293 gl_CONDITIONAL([GL_COND_OBJ_FCNTL], 466 gl_CONDITIONAL([GL_COND_OBJ_FCNTL],
@@ -306,8 +479,11 @@ AC_DEFUN([gl_INIT],
306 gl_FLOAT_H 479 gl_FLOAT_H
307 gl_CONDITIONAL_HEADER([float.h]) 480 gl_CONDITIONAL_HEADER([float.h])
308 AC_PROG_MKDIR_P 481 AC_PROG_MKDIR_P
309 gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1]) 482 gl_CONDITIONAL([GL_COND_OBJ_FLOAT],
483 [test $REPLACE_FLOAT_LDBL = 1 || test $REPLACE_FLOAT_SNAN = 1])
310 gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1]) 484 gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1])
485 dnl Prerequisites of lib/float.c.
486 AC_REQUIRE([gl_BIGENDIAN])
311 gl_FUNC_FLOORF 487 gl_FUNC_FLOORF
312 gl_CONDITIONAL([GL_COND_OBJ_FLOORF], 488 gl_CONDITIONAL([GL_COND_OBJ_FLOORF],
313 [test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1]) 489 [test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1])
@@ -346,17 +522,20 @@ AC_DEFUN([gl_INIT],
346 gl_PREREQ_FSEEKO 522 gl_PREREQ_FSEEKO
347 ]) 523 ])
348 gl_STDIO_MODULE_INDICATOR([fseeko]) 524 gl_STDIO_MODULE_INDICATOR([fseeko])
525 gl_FUNC_FSETERR
526 gl_CONDITIONAL([GL_COND_OBJ_FSETERR], [test $ac_cv_func___fseterr = no])
349 gl_FUNC_FSTAT 527 gl_FUNC_FSTAT
350 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1]) 528 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1])
351 AM_COND_IF([GL_COND_OBJ_FSTAT], [ 529 AM_COND_IF([GL_COND_OBJ_FSTAT], [
352 case "$host_os" in 530 case "$host_os" in
353 mingw*) 531 mingw* | windows*)
354 AC_LIBOBJ([stat-w32]) 532 AC_LIBOBJ([stat-w32])
355 ;; 533 ;;
356 esac 534 esac
357 gl_PREREQ_FSTAT 535 gl_PREREQ_FSTAT
358 ]) 536 ])
359 gl_SYS_STAT_MODULE_INDICATOR([fstat]) 537 gl_SYS_STAT_MODULE_INDICATOR([fstat])
538 gl_MODULE_INDICATOR([fstat])
360 gl_FSUSAGE 539 gl_FSUSAGE
361 gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes]) 540 gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes])
362 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [ 541 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [
@@ -393,11 +572,13 @@ AC_DEFUN([gl_INIT],
393 ]) 572 ])
394 gl_UNISTD_MODULE_INDICATOR([getdtablesize]) 573 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
395 gl_FUNC_GETHOSTNAME 574 gl_FUNC_GETHOSTNAME
396 gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME], [test $HAVE_GETHOSTNAME = 0]) 575 gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME],
576 [test $HAVE_GETHOSTNAME = 0 || test $UNISTD_H_HAVE_WINSOCK2_H = 1])
397 AM_COND_IF([GL_COND_OBJ_GETHOSTNAME], [ 577 AM_COND_IF([GL_COND_OBJ_GETHOSTNAME], [
398 gl_PREREQ_GETHOSTNAME 578 gl_PREREQ_GETHOSTNAME
399 ]) 579 ])
400 gl_UNISTD_MODULE_INDICATOR([gethostname]) 580 gl_UNISTD_MODULE_INDICATOR([gethostname])
581 gl_MODULE_INDICATOR([gethostname])
401 gl_FUNC_GETLINE 582 gl_FUNC_GETLINE
402 gl_CONDITIONAL([GL_COND_OBJ_GETLINE], [test $REPLACE_GETLINE = 1]) 583 gl_CONDITIONAL([GL_COND_OBJ_GETLINE], [test $REPLACE_GETLINE = 1])
403 AM_COND_IF([GL_COND_OBJ_GETLINE], [ 584 AM_COND_IF([GL_COND_OBJ_GETLINE], [
@@ -406,7 +587,8 @@ AC_DEFUN([gl_INIT],
406 gl_STDIO_MODULE_INDICATOR([getline]) 587 gl_STDIO_MODULE_INDICATOR([getline])
407 AC_REQUIRE([AC_CANONICAL_HOST]) 588 AC_REQUIRE([AC_CANONICAL_HOST])
408 gl_GETLOADAVG 589 gl_GETLOADAVG
409 gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0]) 590 gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG],
591 [test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1])
410 AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [ 592 AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
411 gl_PREREQ_GETLOADAVG 593 gl_PREREQ_GETLOADAVG
412 ]) 594 ])
@@ -426,12 +608,23 @@ AC_DEFUN([gl_INIT],
426 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1]) 608 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1])
427 ]) 609 ])
428 gl_UNISTD_MODULE_INDICATOR([getopt-posix]) 610 gl_UNISTD_MODULE_INDICATOR([getopt-posix])
611 gl_MUSL_LIBC
612 AC_REQUIRE([AC_CANONICAL_HOST])
429 gl_FUNC_GETPROGNAME 613 gl_FUNC_GETPROGNAME
430 AC_SUBST([LIBINTL]) 614 gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME],
431 AC_SUBST([LTLIBINTL]) 615 [test $HAVE_GETPROGNAME = 0 || test $REPLACE_GETPROGNAME = 1])
616 AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [
617 gl_PREREQ_GETPROGNAME
618 ])
619 gl_STDLIB_MODULE_INDICATOR([getprogname])
620 gl_GETTEXT_H
432 AC_PROG_MKDIR_P 621 AC_PROG_MKDIR_P
622 GNULIB_I18N
433 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) 623 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
434 LIB_HARD_LOCALE="$LIB_SETLOCALE_NULL" 624 HARD_LOCALE_LIB="$SETLOCALE_NULL_LIB"
625 AC_SUBST([HARD_LOCALE_LIB])
626 dnl For backward compatibility.
627 LIB_HARD_LOCALE="$HARD_LOCALE_LIB"
435 AC_SUBST([LIB_HARD_LOCALE]) 628 AC_SUBST([LIB_HARD_LOCALE])
436 gl_HOSTENT 629 gl_HOSTENT
437 gl_IDPRIV 630 gl_IDPRIV
@@ -442,9 +635,36 @@ AC_DEFUN([gl_INIT],
442 gl_PREREQ_INET_NTOP 635 gl_PREREQ_INET_NTOP
443 ]) 636 ])
444 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) 637 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
638 gl_FUNC_INET_PTON
639 gl_CONDITIONAL([GL_COND_OBJ_INET_PTON],
640 [test $HAVE_INET_PTON = 0 || test $REPLACE_INET_PTON = 1])
641 AM_COND_IF([GL_COND_OBJ_INET_PTON], [
642 gl_PREREQ_INET_PTON
643 ])
644 gl_ARPA_INET_MODULE_INDICATOR([inet_pton])
445 gl_INTTYPES_INCOMPLETE 645 gl_INTTYPES_INCOMPLETE
446 gl_INTTYPES_H_REQUIRE_DEFAULTS 646 gl_INTTYPES_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P 647 AC_PROG_MKDIR_P
648 gl_FUNC_ISWBLANK
649 gl_CONDITIONAL([GL_COND_OBJ_ISWBLANK],
650 [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && { test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; }])
651 gl_WCTYPE_MODULE_INDICATOR([iswblank])
652 gl_FUNC_ISWCTYPE
653 gl_CONDITIONAL([GL_COND_OBJ_ISWCTYPE],
654 [test $HAVE_WCTYPE_T = 0 || test $GNULIBHEADERS_OVERRIDE_WINT_T = 1 || test $REPLACE_WCTYPE = 1])
655 gl_WCTYPE_MODULE_INDICATOR([iswctype])
656 gl_FUNC_ISWDIGIT
657 gl_CONDITIONAL([GL_COND_OBJ_ISWDIGIT],
658 [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWDIGIT = 1])
659 gl_WCTYPE_MODULE_INDICATOR([iswdigit])
660 gl_FUNC_ISWPUNCT
661 gl_CONDITIONAL([GL_COND_OBJ_ISWPUNCT],
662 [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWPUNCT = 1])
663 gl_WCTYPE_MODULE_INDICATOR([iswpunct])
664 gl_FUNC_ISWXDIGIT
665 gl_CONDITIONAL([GL_COND_OBJ_ISWXDIGIT],
666 [! { test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; } && test $REPLACE_ISWXDIGIT = 1])
667 gl_WCTYPE_MODULE_INDICATOR([iswxdigit])
448 gl_LANGINFO_H 668 gl_LANGINFO_H
449 gl_LANGINFO_H_REQUIRE_DEFAULTS 669 gl_LANGINFO_H_REQUIRE_DEFAULTS
450 AC_PROG_MKDIR_P 670 AC_PROG_MKDIR_P
@@ -466,11 +686,19 @@ AC_DEFUN([gl_INIT],
466 gl_PREREQ_LOCALECONV 686 gl_PREREQ_LOCALECONV
467 ]) 687 ])
468 gl_LOCALE_MODULE_INDICATOR([localeconv]) 688 gl_LOCALE_MODULE_INDICATOR([localeconv])
689 gl_MODULE_INDICATOR([localeconv])
469 gl_LOCK 690 gl_LOCK
470 gl_MODULE_INDICATOR([lock]) 691 gl_MODULE_INDICATOR([lock])
471 gl_FUNC_LSEEK 692 gl_FUNC_LSEEK
472 gl_CONDITIONAL([GL_COND_OBJ_LSEEK], [test $REPLACE_LSEEK = 1]) 693 gl_CONDITIONAL([GL_COND_OBJ_LSEEK], [test $REPLACE_LSEEK = 1])
473 gl_UNISTD_MODULE_INDICATOR([lseek]) 694 gl_UNISTD_MODULE_INDICATOR([lseek])
695 gl_FUNC_LSTAT
696 gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1])
697 AM_COND_IF([GL_COND_OBJ_LSTAT], [
698 gl_PREREQ_LSTAT
699 ])
700 gl_SYS_STAT_MODULE_INDICATOR([lstat])
701 gl_MODULE_INDICATOR([lstat])
474 gl_FUNC_MALLOC_GNU 702 gl_FUNC_MALLOC_GNU
475 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then 703 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
476 AC_LIBOBJ([malloc]) 704 AC_LIBOBJ([malloc])
@@ -485,6 +713,20 @@ AC_DEFUN([gl_INIT],
485 gl_MATH_H 713 gl_MATH_H
486 gl_MATH_H_REQUIRE_DEFAULTS 714 gl_MATH_H_REQUIRE_DEFAULTS
487 AC_PROG_MKDIR_P 715 AC_PROG_MKDIR_P
716 gl_MBCHAR
717 gl_MBITER
718 gl_FUNC_MBRTOC32
719 gl_CONDITIONAL([GL_COND_OBJ_MBRTOC32],
720 [test $HAVE_MBRTOC32 = 0 || test $REPLACE_MBRTOC32 = 1])
721 AM_COND_IF([GL_COND_OBJ_MBRTOC32], [
722 if test $REPLACE_MBSTATE_T = 1; then
723 AC_LIBOBJ([lc-charset-dispatch])
724 AC_LIBOBJ([mbtowc-lock])
725 gl_PREREQ_MBTOWC_LOCK
726 fi
727 gl_PREREQ_MBRTOC32
728 ])
729 gl_UCHAR_MODULE_INDICATOR([mbrtoc32])
488 gl_FUNC_MBRTOWC 730 gl_FUNC_MBRTOWC
489 gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC], 731 gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC],
490 [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]) 732 [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1])
@@ -504,6 +746,11 @@ AC_DEFUN([gl_INIT],
504 gl_PREREQ_MBSINIT 746 gl_PREREQ_MBSINIT
505 ]) 747 ])
506 gl_WCHAR_MODULE_INDICATOR([mbsinit]) 748 gl_WCHAR_MODULE_INDICATOR([mbsinit])
749 gl_STRING_MODULE_INDICATOR([mbsnlen])
750 AC_REQUIRE([AC_TYPE_MBSTATE_T])
751 gl_MBSTATE_T_BROKEN
752 gl_MUSL_LIBC
753 gl_WCHAR_MODULE_INDICATOR([mbszero])
507 gl_FUNC_MBTOWC 754 gl_FUNC_MBTOWC
508 gl_CONDITIONAL([GL_COND_OBJ_MBTOWC], 755 gl_CONDITIONAL([GL_COND_OBJ_MBTOWC],
509 [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1]) 756 [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1])
@@ -530,10 +777,7 @@ AC_DEFUN([gl_INIT],
530 gl_PREREQ_MKTIME 777 gl_PREREQ_MKTIME
531 fi 778 fi
532 gl_MOUNTLIST 779 gl_MOUNTLIST
533 gl_CONDITIONAL([GL_COND_OBJ_MOUNTLIST], [test $gl_cv_list_mounted_fs = yes]) 780 gl_PREREQ_MOUNTLIST_EXTRA
534 AM_COND_IF([GL_COND_OBJ_MOUNTLIST], [
535 gl_PREREQ_MOUNTLIST_EXTRA
536 ])
537 AC_REQUIRE([gl_MSVC_INVAL]) 781 AC_REQUIRE([gl_MSVC_INVAL])
538 gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL], 782 gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL],
539 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1]) 783 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
@@ -557,6 +801,7 @@ AC_DEFUN([gl_INIT],
557 gl_PREREQ_NL_LANGINFO_LOCK 801 gl_PREREQ_NL_LANGINFO_LOCK
558 fi 802 fi
559 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) 803 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
804 gl_ONCE
560 gl_FUNC_OPEN 805 gl_FUNC_OPEN
561 gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1]) 806 gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1])
562 AM_COND_IF([GL_COND_OBJ_OPEN], [ 807 AM_COND_IF([GL_COND_OBJ_OPEN], [
@@ -564,15 +809,17 @@ AC_DEFUN([gl_INIT],
564 ]) 809 ])
565 gl_FCNTL_MODULE_INDICATOR([open]) 810 gl_FCNTL_MODULE_INDICATOR([open])
566 gl_PATHMAX 811 gl_PATHMAX
567 gl_FUNC_REALLOC_GNU 812 gl_PTHREAD_H
568 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then 813 gl_PTHREAD_H_REQUIRE_DEFAULTS
569 AC_LIBOBJ([realloc]) 814 AC_PROG_MKDIR_P
570 fi 815 gl_PTHREAD_ONCE
571 gl_STDLIB_MODULE_INDICATOR([realloc-gnu]) 816 gl_CONDITIONAL([GL_COND_OBJ_PTHREAD_ONCE],
817 [test $HAVE_PTHREAD_ONCE = 0 || test $REPLACE_PTHREAD_ONCE = 1])
818 gl_PTHREAD_MODULE_INDICATOR([pthread-once])
572 gl_FUNC_REALLOC_POSIX 819 gl_FUNC_REALLOC_POSIX
573 if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then 820 gl_FUNC_REALLOC_0_NONNULL
574 AC_LIBOBJ([realloc]) 821 gl_CONDITIONAL([GL_COND_OBJ_REALLOC_POSIX],
575 fi 822 [test $REPLACE_REALLOC_FOR_REALLOC_POSIX != 0])
576 gl_STDLIB_MODULE_INDICATOR([realloc-posix]) 823 gl_STDLIB_MODULE_INDICATOR([realloc-posix])
577 gl_FUNC_REALLOCARRAY 824 gl_FUNC_REALLOCARRAY
578 gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY], 825 gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY],
@@ -587,6 +834,9 @@ AC_DEFUN([gl_INIT],
587 AM_COND_IF([GL_COND_OBJ_REGEX], [ 834 AM_COND_IF([GL_COND_OBJ_REGEX], [
588 gl_PREREQ_REGEX 835 gl_PREREQ_REGEX
589 ]) 836 ])
837 gl_SCHED_H
838 gl_SCHED_H_REQUIRE_DEFAULTS
839 AC_PROG_MKDIR_P
590 gl_SERVENT 840 gl_SERVENT
591 gl_FUNC_SETENV 841 gl_FUNC_SETENV
592 gl_CONDITIONAL([GL_COND_OBJ_SETENV], 842 gl_CONDITIONAL([GL_COND_OBJ_SETENV],
@@ -611,25 +861,17 @@ AC_DEFUN([gl_INIT],
611 gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1]) 861 gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1])
612 AM_COND_IF([GL_COND_OBJ_STAT], [ 862 AM_COND_IF([GL_COND_OBJ_STAT], [
613 case "$host_os" in 863 case "$host_os" in
614 mingw*) 864 mingw* | windows*)
615 AC_LIBOBJ([stat-w32]) 865 AC_LIBOBJ([stat-w32])
616 ;; 866 ;;
617 esac 867 esac
618 gl_PREREQ_STAT 868 gl_PREREQ_STAT
619 ]) 869 ])
620 gl_SYS_STAT_MODULE_INDICATOR([stat]) 870 gl_SYS_STAT_MODULE_INDICATOR([stat])
871 gl_MODULE_INDICATOR([stat])
621 gl_STAT_TIME 872 gl_STAT_TIME
622 gl_STAT_BIRTHTIME 873 gl_STAT_BIRTHTIME
623 gl_STDALIGN_H 874 gl_STDCKDINT_H
624 gl_CONDITIONAL_HEADER([stdalign.h])
625 AC_PROG_MKDIR_P
626 gl_C_BOOL
627 AC_CHECK_HEADERS_ONCE([stdckdint.h])
628 if test $ac_cv_header_stdckdint_h = yes; then
629 GL_GENERATE_STDCKDINT_H=false
630 else
631 GL_GENERATE_STDCKDINT_H=true
632 fi
633 gl_CONDITIONAL_HEADER([stdckdint.h]) 875 gl_CONDITIONAL_HEADER([stdckdint.h])
634 AC_PROG_MKDIR_P 876 AC_PROG_MKDIR_P
635 gl_STDDEF_H 877 gl_STDDEF_H
@@ -669,18 +911,30 @@ AC_DEFUN([gl_INIT],
669 gl_STDIO_MODULE_INDICATOR([fputs]) 911 gl_STDIO_MODULE_INDICATOR([fputs])
670 gl_STDIO_MODULE_INDICATOR([puts]) 912 gl_STDIO_MODULE_INDICATOR([puts])
671 gl_STDIO_MODULE_INDICATOR([fwrite]) 913 gl_STDIO_MODULE_INDICATOR([fwrite])
914 AC_REQUIRE([AC_CANONICAL_HOST])
915 USES_MSVCRT=0
916 case "$host_os" in
917 mingw* | windows*)
918 AC_EGREP_CPP([Special], [
919 #ifndef _UCRT
920 Special
921 #endif
922 ],
923 [USES_MSVCRT=1])
924 ;;
925 esac
926 gl_CONDITIONAL([GL_COND_OBJ_STDIO_CONSOLESAFE], [test $USES_MSVCRT = 1])
927 AC_CHECK_FUNCS([vasprintf])
672 gl_STDLIB_H 928 gl_STDLIB_H
673 gl_STDLIB_H_REQUIRE_DEFAULTS 929 gl_STDLIB_H_REQUIRE_DEFAULTS
674 AC_PROG_MKDIR_P 930 AC_PROG_MKDIR_P
675 gl_STRCASE 931 gl_FUNC_STRCASECMP
676 gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0]) 932 gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP],
933 [test $HAVE_STRCASECMP = 0 || test $REPLACE_STRCASECMP = 1])
677 AM_COND_IF([GL_COND_OBJ_STRCASECMP], [ 934 AM_COND_IF([GL_COND_OBJ_STRCASECMP], [
678 gl_PREREQ_STRCASECMP 935 gl_PREREQ_STRCASECMP
679 ]) 936 ])
680 gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0]) 937 gl_STRINGS_MODULE_INDICATOR([strcasecmp])
681 AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [
682 gl_PREREQ_STRNCASECMP
683 ])
684 gl_FUNC_STRCASESTR 938 gl_FUNC_STRCASESTR
685 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then 939 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
686 AC_LIBOBJ([strcasestr]) 940 AC_LIBOBJ([strcasestr])
@@ -706,9 +960,25 @@ AC_DEFUN([gl_INIT],
706 gl_STRING_H 960 gl_STRING_H
707 gl_STRING_H_REQUIRE_DEFAULTS 961 gl_STRING_H_REQUIRE_DEFAULTS
708 AC_PROG_MKDIR_P 962 AC_PROG_MKDIR_P
963 gl_FUNC_STREQ
964 gl_FUNC_MEMEQ
965 gl_STRING_MODULE_INDICATOR([stringeq])
709 gl_STRINGS_H 966 gl_STRINGS_H
710 gl_STRINGS_H_REQUIRE_DEFAULTS 967 gl_STRINGS_H_REQUIRE_DEFAULTS
711 AC_PROG_MKDIR_P 968 AC_PROG_MKDIR_P
969 gl_FUNC_STRNCASECMP
970 gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP],
971 [test $HAVE_STRNCASECMP = 0 || test $REPLACE_STRNCASECMP = 1])
972 AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [
973 gl_PREREQ_STRNCASECMP
974 ])
975 gl_STRINGS_MODULE_INDICATOR([strncasecmp])
976 gl_FUNC_STRNCPY
977 gl_CONDITIONAL([GL_COND_OBJ_STRNCPY], [test $REPLACE_STRNCPY = 1])
978 AM_COND_IF([GL_COND_OBJ_STRNCPY], [
979 gl_PREREQ_STRNCPY
980 ])
981 gl_STRING_MODULE_INDICATOR([strncpy])
712 gl_FUNC_STRSEP 982 gl_FUNC_STRSEP
713 gl_CONDITIONAL([GL_COND_OBJ_STRSEP], [test $HAVE_STRSEP = 0]) 983 gl_CONDITIONAL([GL_COND_OBJ_STRSEP], [test $HAVE_STRSEP = 0])
714 AM_COND_IF([GL_COND_OBJ_STRSEP], [ 984 AM_COND_IF([GL_COND_OBJ_STRSEP], [
@@ -750,9 +1020,55 @@ AC_DEFUN([gl_INIT],
750 gl_PREREQ_TIMEGM 1020 gl_PREREQ_TIMEGM
751 ]) 1021 ])
752 gl_TIME_MODULE_INDICATOR([timegm]) 1022 gl_TIME_MODULE_INDICATOR([timegm])
1023 gl_UCHAR_H
1024 gl_UCHAR_H_REQUIRE_DEFAULTS
1025 AC_PROG_MKDIR_P
1026 gl_LIBUNISTRING_LIBHEADER([1.2], [unicase.h])
1027 gl_UNICASE_H
1028 gl_UNICASE_H_REQUIRE_DEFAULTS
1029 AC_PROG_MKDIR_P
1030 gl_LIBUNISTRING_MODULE([1.4], [unicase/tolower])
1031 gl_LIBUNISTRING_LIBHEADER([1.3], [unictype.h])
1032 gl_UNICTYPE_H
1033 gl_UNICTYPE_H_REQUIRE_DEFAULTS
1034 AC_PROG_MKDIR_P
1035 AC_REQUIRE([AC_C_INLINE])
1036 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-alnum])
1037 AC_REQUIRE([AC_C_INLINE])
1038 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-alpha])
1039 AC_REQUIRE([AC_C_INLINE])
1040 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-blank])
1041 AC_REQUIRE([AC_C_INLINE])
1042 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-cntrl])
1043 AC_REQUIRE([AC_C_INLINE])
1044 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-digit])
1045 AC_REQUIRE([AC_C_INLINE])
1046 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-graph])
1047 AC_REQUIRE([AC_C_INLINE])
1048 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-lower])
1049 AC_REQUIRE([AC_C_INLINE])
1050 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-print])
1051 AC_REQUIRE([AC_C_INLINE])
1052 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-punct])
1053 AC_REQUIRE([AC_C_INLINE])
1054 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-space])
1055 AC_REQUIRE([AC_C_INLINE])
1056 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-upper])
1057 AC_REQUIRE([AC_C_INLINE])
1058 gl_LIBUNISTRING_MODULE([1.4], [unictype/ctype-xdigit])
1059 gl_LIBUNISTRING_LIBHEADER([1.2], [uninorm.h])
1060 gl_UNINORM_H
1061 gl_UNINORM_H_REQUIRE_DEFAULTS
1062 AC_PROG_MKDIR_P
753 gl_UNISTD_H 1063 gl_UNISTD_H
754 gl_UNISTD_H_REQUIRE_DEFAULTS 1064 gl_UNISTD_H_REQUIRE_DEFAULTS
755 AC_PROG_MKDIR_P 1065 AC_PROG_MKDIR_P
1066 gl_LIBUNISTRING_LIBHEADER([0.9.11], [unitypes.h])
1067 AC_PROG_MKDIR_P
1068 gl_UNITYPES_H
1069 gl_LIBUNISTRING_LIBHEADER([0.9.11], [uniwidth.h])
1070 AC_PROG_MKDIR_P
1071 gl_LIBUNISTRING_MODULE([1.4], [uniwidth/width])
756 gl_FUNC_GLIBC_UNLOCKED_IO 1072 gl_FUNC_GLIBC_UNLOCKED_IO
757 gl_FUNC_UNSETENV 1073 gl_FUNC_UNSETENV
758 gl_CONDITIONAL([GL_COND_OBJ_UNSETENV], 1074 gl_CONDITIONAL([GL_COND_OBJ_UNSETENV],
@@ -771,6 +1087,7 @@ AC_DEFUN([gl_INIT],
771 AM_][XGETTEXT_OPTION([--flag=vasprintf:2:c-format])]) 1087 AM_][XGETTEXT_OPTION([--flag=vasprintf:2:c-format])])
772 gl_FUNC_VSNPRINTF 1088 gl_FUNC_VSNPRINTF
773 gl_STDIO_MODULE_INDICATOR([vsnprintf]) 1089 gl_STDIO_MODULE_INDICATOR([vsnprintf])
1090 gl_STDIO_MODULE_INDICATOR([vsnzprintf])
774 gl_WCHAR_H 1091 gl_WCHAR_H
775 gl_WCHAR_H_REQUIRE_DEFAULTS 1092 gl_WCHAR_H_REQUIRE_DEFAULTS
776 AC_PROG_MKDIR_P 1093 AC_PROG_MKDIR_P
@@ -781,21 +1098,31 @@ AC_DEFUN([gl_INIT],
781 gl_PREREQ_WCRTOMB 1098 gl_PREREQ_WCRTOMB
782 ]) 1099 ])
783 gl_WCHAR_MODULE_INDICATOR([wcrtomb]) 1100 gl_WCHAR_MODULE_INDICATOR([wcrtomb])
1101 gl_FUNC_WCTYPE
1102 gl_CONDITIONAL([GL_COND_OBJ_WCTYPE], [test $HAVE_WCTYPE = 0 || test $REPLACE_WCTYPE = 1])
1103 gl_WCTYPE_MODULE_INDICATOR([wctype])
784 gl_WCTYPE_H 1104 gl_WCTYPE_H
785 gl_WCTYPE_H_REQUIRE_DEFAULTS 1105 gl_WCTYPE_H_REQUIRE_DEFAULTS
786 AC_PROG_MKDIR_P 1106 AC_PROG_MKDIR_P
1107 gl_FUNC_WCWIDTH
1108 gl_CONDITIONAL([GL_COND_OBJ_WCWIDTH],
1109 [test $HAVE_WCWIDTH = 0 || test $REPLACE_WCWIDTH = 1])
1110 AM_COND_IF([GL_COND_OBJ_WCWIDTH], [
1111 gl_PREREQ_WCWIDTH
1112 ])
1113 gl_WCHAR_MODULE_INDICATOR([wcwidth])
787 AC_REQUIRE([AC_CANONICAL_HOST]) 1114 AC_REQUIRE([AC_CANONICAL_HOST])
788 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX], 1115 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX],
789 [case "$host_os" in mingw*) true;; *) false;; esac]) 1116 [case "$host_os" in mingw* | windows*) true;; *) false;; esac])
790 AC_REQUIRE([AC_CANONICAL_HOST]) 1117 AC_REQUIRE([AC_CANONICAL_HOST])
791 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE], 1118 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE],
792 [case "$host_os" in mingw*) true;; *) false;; esac]) 1119 [case "$host_os" in mingw* | windows*) true;; *) false;; esac])
793 AC_REQUIRE([AC_CANONICAL_HOST]) 1120 AC_REQUIRE([AC_CANONICAL_HOST])
794 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX], 1121 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX],
795 [case "$host_os" in mingw*) true;; *) false;; esac]) 1122 [case "$host_os" in mingw* | windows*) true;; *) false;; esac])
796 AC_REQUIRE([AC_CANONICAL_HOST]) 1123 AC_REQUIRE([AC_CANONICAL_HOST])
797 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK], 1124 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK],
798 [case "$host_os" in mingw*) true;; *) false;; esac]) 1125 [case "$host_os" in mingw* | windows*) true;; *) false;; esac])
799 gl_XALLOC 1126 gl_XALLOC
800 gl_MODULE_INDICATOR([xalloc]) 1127 gl_MODULE_INDICATOR([xalloc])
801 gl_MODULE_INDICATOR([xalloc-die]) 1128 gl_MODULE_INDICATOR([xalloc-die])
@@ -823,27 +1150,35 @@ AC_DEFUN([gl_INIT],
823 gl_libobjs= 1150 gl_libobjs=
824 gl_ltlibobjs= 1151 gl_ltlibobjs=
825 gl_libobjdeps= 1152 gl_libobjdeps=
1153 gl_libgnu_libobjs=
1154 gl_libgnu_ltlibobjs=
1155 gl_libgnu_libobjdeps=
826 if test -n "$gl_LIBOBJS"; then 1156 if test -n "$gl_LIBOBJS"; then
827 # Remove the extension. 1157 # Remove the extension.
828changequote(,)dnl 1158changequote(,)dnl
829 sed_drop_objext='s/\.o$//;s/\.obj$//' 1159 sed_drop_objext='s/\.o$//;s/\.obj$//'
830 sed_dirname1='s,//*,/,g' 1160 sed_dirname1='s,//*,/,g'
831 sed_dirname2='s,\(.\)/$,\1,' 1161 sed_dirname2='s,\(.\)/$,\1,'
832 sed_dirname3='s,^[^/]*$,.,' 1162 sed_dirname3='s,[^/]*$,,'
833 sed_dirname4='s,\(.\)/[^/]*$,\1,'
834 sed_basename1='s,.*/,,' 1163 sed_basename1='s,.*/,,'
835changequote([, ])dnl 1164changequote([, ])dnl
836 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 1165 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
837 gl_libobjs="$gl_libobjs $i.$ac_objext" 1166 gl_libobjs="$gl_libobjs $i.$ac_objext"
838 gl_ltlibobjs="$gl_ltlibobjs $i.lo" 1167 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
839 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` 1168 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3"`
840 i_base=`echo "$i" | sed -e "$sed_basename1"` 1169 i_base=`echo "$i" | sed -e "$sed_basename1"`
841 gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" 1170 gl_libgnu_libobjs="$gl_libgnu_libobjs $i_dir""libgnu_a-$i_base.$ac_objext"
1171 gl_libgnu_ltlibobjs="$gl_libgnu_ltlibobjs $i_dir""libgnu_la-$i_base.lo"
1172 gl_libobjdeps="$gl_libobjdeps $i_dir\$(DEPDIR)/$i_base.Po"
1173 gl_libgnu_libobjdeps="$gl_libgnu_libobjdeps $i_dir\$(DEPDIR)/libgnu_a-$i_base.Po"
842 done 1174 done
843 fi 1175 fi
844 AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) 1176 AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
845 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) 1177 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
846 AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps]) 1178 AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps])
1179 AC_SUBST([gl_libgnu_LIBOBJS], [$gl_libgnu_libobjs])
1180 AC_SUBST([gl_libgnu_LTLIBOBJS], [$gl_libgnu_ltlibobjs])
1181 AC_SUBST([gl_libgnu_LIBOBJDEPS], [$gl_libgnu_libobjdeps])
847 ]) 1182 ])
848 gltests_libdeps= 1183 gltests_libdeps=
849 gltests_ltlibdeps= 1184 gltests_ltlibdeps=
@@ -886,27 +1221,35 @@ changequote([, ])dnl
886 gltests_libobjs= 1221 gltests_libobjs=
887 gltests_ltlibobjs= 1222 gltests_ltlibobjs=
888 gltests_libobjdeps= 1223 gltests_libobjdeps=
1224 gltests_libgnu_libobjs=
1225 gltests_libgnu_ltlibobjs=
1226 gltests_libgnu_libobjdeps=
889 if test -n "$gltests_LIBOBJS"; then 1227 if test -n "$gltests_LIBOBJS"; then
890 # Remove the extension. 1228 # Remove the extension.
891changequote(,)dnl 1229changequote(,)dnl
892 sed_drop_objext='s/\.o$//;s/\.obj$//' 1230 sed_drop_objext='s/\.o$//;s/\.obj$//'
893 sed_dirname1='s,//*,/,g' 1231 sed_dirname1='s,//*,/,g'
894 sed_dirname2='s,\(.\)/$,\1,' 1232 sed_dirname2='s,\(.\)/$,\1,'
895 sed_dirname3='s,^[^/]*$,.,' 1233 sed_dirname3='s,[^/]*$,,'
896 sed_dirname4='s,\(.\)/[^/]*$,\1,'
897 sed_basename1='s,.*/,,' 1234 sed_basename1='s,.*/,,'
898changequote([, ])dnl 1235changequote([, ])dnl
899 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 1236 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
900 gltests_libobjs="$gltests_libobjs $i.$ac_objext" 1237 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
901 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" 1238 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
902 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"` 1239 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3"`
903 i_base=`echo "$i" | sed -e "$sed_basename1"` 1240 i_base=`echo "$i" | sed -e "$sed_basename1"`
904 gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po" 1241 gltests_libgnu_libobjs="$gltests_libgnu_libobjs $i_dir""libgnu_a-$i_base.$ac_objext"
1242 gltests_libgnu_ltlibobjs="$gltests_libgnu_ltlibobjs $i_dir""libgnu_la-$i_base.lo"
1243 gltests_libobjdeps="$gltests_libobjdeps $i_dir\$(DEPDIR)/$i_base.Po"
1244 gltests_libgnu_libobjdeps="$gltests_libgnu_libobjdeps $i_dir\$(DEPDIR)/libgnu_a-$i_base.Po"
905 done 1245 done
906 fi 1246 fi
907 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) 1247 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
908 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) 1248 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
909 AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps]) 1249 AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps])
1250 AC_SUBST([gltests_libgnu_LIBOBJS], [$gltests_libgnu_libobjs])
1251 AC_SUBST([gltests_libgnu_LTLIBOBJS], [$gltests_libgnu_ltlibobjs])
1252 AC_SUBST([gltests_libgnu_LIBOBJDEPS], [$gltests_libgnu_libobjdeps])
910 ]) 1253 ])
911 AC_REQUIRE([gl_CC_GNULIB_WARNINGS]) 1254 AC_REQUIRE([gl_CC_GNULIB_WARNINGS])
912 LIBGNU_LIBDEPS="$gl_libdeps" 1255 LIBGNU_LIBDEPS="$gl_libdeps"
@@ -977,6 +1320,7 @@ AC_DEFUN([gl_FILE_LIST], [
977 lib/af_alg.h 1320 lib/af_alg.h
978 lib/alloca.in.h 1321 lib/alloca.in.h
979 lib/arg-nonnull.h 1322 lib/arg-nonnull.h
1323 lib/arpa_inet.c
980 lib/arpa_inet.in.h 1324 lib/arpa_inet.in.h
981 lib/asnprintf.c 1325 lib/asnprintf.c
982 lib/asprintf.c 1326 lib/asprintf.c
@@ -988,8 +1332,27 @@ AC_DEFUN([gl_FILE_LIST], [
988 lib/basename-lgpl.h 1332 lib/basename-lgpl.h
989 lib/basename.c 1333 lib/basename.c
990 lib/btowc.c 1334 lib/btowc.c
1335 lib/byteswap.c
991 lib/byteswap.in.h 1336 lib/byteswap.in.h
992 lib/c++defs.h 1337 lib/c++defs.h
1338 lib/c-ctype.c
1339 lib/c-ctype.h
1340 lib/c32is-impl.h
1341 lib/c32isalnum.c
1342 lib/c32isalpha.c
1343 lib/c32isblank.c
1344 lib/c32iscntrl.c
1345 lib/c32isdigit.c
1346 lib/c32isgraph.c
1347 lib/c32islower.c
1348 lib/c32isprint.c
1349 lib/c32ispunct.c
1350 lib/c32isspace.c
1351 lib/c32isupper.c
1352 lib/c32isxdigit.c
1353 lib/c32to-impl.h
1354 lib/c32tolower.c
1355 lib/c32width.c
993 lib/calloc.c 1356 lib/calloc.c
994 lib/cdefs.h 1357 lib/cdefs.h
995 lib/cloexec.c 1358 lib/cloexec.c
@@ -1002,7 +1365,7 @@ AC_DEFUN([gl_FILE_LIST], [
1002 lib/dynarray.h 1365 lib/dynarray.h
1003 lib/errno.in.h 1366 lib/errno.in.h
1004 lib/error.c 1367 lib/error.c
1005 lib/error.h 1368 lib/error.in.h
1006 lib/exitfail.c 1369 lib/exitfail.c
1007 lib/exitfail.h 1370 lib/exitfail.h
1008 lib/fcntl.c 1371 lib/fcntl.c
@@ -1023,6 +1386,8 @@ AC_DEFUN([gl_FILE_LIST], [
1023 lib/free.c 1386 lib/free.c
1024 lib/fseek.c 1387 lib/fseek.c
1025 lib/fseeko.c 1388 lib/fseeko.c
1389 lib/fseterr.c
1390 lib/fseterr.h
1026 lib/fstat.c 1391 lib/fstat.c
1027 lib/fsusage.c 1392 lib/fsusage.c
1028 lib/fsusage.h 1393 lib/fsusage.h
@@ -1050,6 +1415,8 @@ AC_DEFUN([gl_FILE_LIST], [
1050 lib/gl_openssl.h 1415 lib/gl_openssl.h
1051 lib/glthread/lock.c 1416 lib/glthread/lock.c
1052 lib/glthread/lock.h 1417 lib/glthread/lock.h
1418 lib/glthread/once.c
1419 lib/glthread/once.h
1053 lib/glthread/threadlib.c 1420 lib/glthread/threadlib.c
1054 lib/hard-locale.c 1421 lib/hard-locale.c
1055 lib/hard-locale.h 1422 lib/hard-locale.h
@@ -1059,9 +1426,16 @@ AC_DEFUN([gl_FILE_LIST], [
1059 lib/idpriv.h 1426 lib/idpriv.h
1060 lib/idx.h 1427 lib/idx.h
1061 lib/inet_ntop.c 1428 lib/inet_ntop.c
1429 lib/inet_pton.c
1062 lib/intprops-internal.h 1430 lib/intprops-internal.h
1063 lib/intprops.h 1431 lib/intprops.h
1064 lib/inttypes.in.h 1432 lib/inttypes.in.h
1433 lib/iswblank.c
1434 lib/iswctype-impl.h
1435 lib/iswctype.c
1436 lib/iswdigit.c
1437 lib/iswpunct.c
1438 lib/iswxdigit.c
1065 lib/itold.c 1439 lib/itold.c
1066 lib/langinfo.in.h 1440 lib/langinfo.in.h
1067 lib/lc-charset-dispatch.c 1441 lib/lc-charset-dispatch.c
@@ -1073,6 +1447,7 @@ AC_DEFUN([gl_FILE_LIST], [
1073 lib/locale.in.h 1447 lib/locale.in.h
1074 lib/localeconv.c 1448 lib/localeconv.c
1075 lib/lseek.c 1449 lib/lseek.c
1450 lib/lstat.c
1076 lib/malloc.c 1451 lib/malloc.c
1077 lib/malloc/dynarray-skeleton.c 1452 lib/malloc/dynarray-skeleton.c
1078 lib/malloc/dynarray.h 1453 lib/malloc/dynarray.h
@@ -1085,10 +1460,17 @@ AC_DEFUN([gl_FILE_LIST], [
1085 lib/malloca.h 1460 lib/malloca.h
1086 lib/math.c 1461 lib/math.c
1087 lib/math.in.h 1462 lib/math.in.h
1463 lib/mbchar.c
1464 lib/mbchar.h
1465 lib/mbiterf.c
1466 lib/mbiterf.h
1467 lib/mbrtoc32.c
1088 lib/mbrtowc-impl-utf8.h 1468 lib/mbrtowc-impl-utf8.h
1089 lib/mbrtowc-impl.h 1469 lib/mbrtowc-impl.h
1090 lib/mbrtowc.c 1470 lib/mbrtowc.c
1091 lib/mbsinit.c 1471 lib/mbsinit.c
1472 lib/mbsnlen.c
1473 lib/mbszero.c
1092 lib/mbtowc-impl.h 1474 lib/mbtowc-impl.h
1093 lib/mbtowc-lock.c 1475 lib/mbtowc-lock.c
1094 lib/mbtowc-lock.h 1476 lib/mbtowc-lock.h
@@ -1114,6 +1496,8 @@ AC_DEFUN([gl_FILE_LIST], [
1114 lib/printf-args.h 1496 lib/printf-args.h
1115 lib/printf-parse.c 1497 lib/printf-parse.c
1116 lib/printf-parse.h 1498 lib/printf-parse.h
1499 lib/pthread-once.c
1500 lib/pthread.in.h
1117 lib/realloc.c 1501 lib/realloc.c
1118 lib/reallocarray.c 1502 lib/reallocarray.c
1119 lib/regcomp.c 1503 lib/regcomp.c
@@ -1122,8 +1506,10 @@ AC_DEFUN([gl_FILE_LIST], [
1122 lib/regex_internal.c 1506 lib/regex_internal.c
1123 lib/regex_internal.h 1507 lib/regex_internal.h
1124 lib/regexec.c 1508 lib/regexec.c
1509 lib/sched.in.h
1125 lib/setenv.c 1510 lib/setenv.c
1126 lib/setlocale-lock.c 1511 lib/setlocale-lock.c
1512 lib/setlocale_null-unlocked.c
1127 lib/setlocale_null.c 1513 lib/setlocale_null.c
1128 lib/setlocale_null.h 1514 lib/setlocale_null.h
1129 lib/sha256-stream.c 1515 lib/sha256-stream.c
@@ -1138,14 +1524,15 @@ AC_DEFUN([gl_FILE_LIST], [
1138 lib/stat-w32.c 1524 lib/stat-w32.c
1139 lib/stat-w32.h 1525 lib/stat-w32.h
1140 lib/stat.c 1526 lib/stat.c
1141 lib/stdalign.in.h
1142 lib/stdckdint.in.h 1527 lib/stdckdint.in.h
1143 lib/stddef.in.h 1528 lib/stddef.in.h
1144 lib/stdint.in.h 1529 lib/stdint.in.h
1530 lib/stdio-consolesafe.c
1145 lib/stdio-impl.h 1531 lib/stdio-impl.h
1146 lib/stdio-read.c 1532 lib/stdio-read.c
1147 lib/stdio-write.c 1533 lib/stdio-write.c
1148 lib/stdio.in.h 1534 lib/stdio.in.h
1535 lib/stdlib.c
1149 lib/stdlib.in.h 1536 lib/stdlib.in.h
1150 lib/str-two-way.h 1537 lib/str-two-way.h
1151 lib/strcasecmp.c 1538 lib/strcasecmp.c
@@ -1154,10 +1541,12 @@ AC_DEFUN([gl_FILE_LIST], [
1154 lib/strerror-override.c 1541 lib/strerror-override.c
1155 lib/strerror-override.h 1542 lib/strerror-override.h
1156 lib/strerror.c 1543 lib/strerror.c
1544 lib/string.c
1157 lib/string.in.h 1545 lib/string.in.h
1158 lib/strings.in.h 1546 lib/strings.in.h
1159 lib/stripslash.c 1547 lib/stripslash.c
1160 lib/strncasecmp.c 1548 lib/strncasecmp.c
1549 lib/strncpy.c
1161 lib/strsep.c 1550 lib/strsep.c
1162 lib/strstr.c 1551 lib/strstr.c
1163 lib/sys-limits.h 1552 lib/sys-limits.h
@@ -1169,8 +1558,46 @@ AC_DEFUN([gl_FILE_LIST], [
1169 lib/time.in.h 1558 lib/time.in.h
1170 lib/time_r.c 1559 lib/time_r.c
1171 lib/timegm.c 1560 lib/timegm.c
1561 lib/uchar.in.h
1562 lib/unicase.in.h
1563 lib/unicase/simple-mapping.h
1564 lib/unicase/tolower.c
1565 lib/unicase/tolower.h
1566 lib/unictype.in.h
1567 lib/unictype/bitmap.h
1568 lib/unictype/ctype_alnum.c
1569 lib/unictype/ctype_alnum.h
1570 lib/unictype/ctype_alpha.c
1571 lib/unictype/ctype_alpha.h
1572 lib/unictype/ctype_blank.c
1573 lib/unictype/ctype_blank.h
1574 lib/unictype/ctype_cntrl.c
1575 lib/unictype/ctype_cntrl.h
1576 lib/unictype/ctype_digit.c
1577 lib/unictype/ctype_digit.h
1578 lib/unictype/ctype_graph.c
1579 lib/unictype/ctype_graph.h
1580 lib/unictype/ctype_lower.c
1581 lib/unictype/ctype_lower.h
1582 lib/unictype/ctype_print.c
1583 lib/unictype/ctype_print.h
1584 lib/unictype/ctype_punct.c
1585 lib/unictype/ctype_punct.h
1586 lib/unictype/ctype_space.c
1587 lib/unictype/ctype_space.h
1588 lib/unictype/ctype_upper.c
1589 lib/unictype/ctype_upper.h
1590 lib/unictype/ctype_xdigit.c
1591 lib/unictype/ctype_xdigit.h
1592 lib/uninorm.in.h
1172 lib/unistd.c 1593 lib/unistd.c
1173 lib/unistd.in.h 1594 lib/unistd.in.h
1595 lib/unitypes.in.h
1596 lib/uniwidth.in.h
1597 lib/uniwidth/cjk.h
1598 lib/uniwidth/width.c
1599 lib/uniwidth/width0.h
1600 lib/uniwidth/width2.h
1174 lib/unlocked-io.h 1601 lib/unlocked-io.h
1175 lib/unsetenv.c 1602 lib/unsetenv.c
1176 lib/vasnprintf.c 1603 lib/vasnprintf.c
@@ -1178,12 +1605,16 @@ AC_DEFUN([gl_FILE_LIST], [
1178 lib/vasprintf.c 1605 lib/vasprintf.c
1179 lib/verify.h 1606 lib/verify.h
1180 lib/vsnprintf.c 1607 lib/vsnprintf.c
1608 lib/vsnzprintf.c
1181 lib/w32sock.h 1609 lib/w32sock.h
1182 lib/warn-on-use.h 1610 lib/warn-on-use.h
1183 lib/wchar.in.h 1611 lib/wchar.in.h
1184 lib/wcrtomb.c 1612 lib/wcrtomb.c
1185 lib/wctype-h.c 1613 lib/wctype-h.c
1614 lib/wctype-impl.h
1615 lib/wctype.c
1186 lib/wctype.in.h 1616 lib/wctype.in.h
1617 lib/wcwidth.c
1187 lib/windows-initguard.h 1618 lib/windows-initguard.h
1188 lib/windows-mutex.c 1619 lib/windows-mutex.c
1189 lib/windows-mutex.h 1620 lib/windows-mutex.h
@@ -1208,21 +1639,25 @@ AC_DEFUN([gl_FILE_LIST], [
1208 m4/assert_h.m4 1639 m4/assert_h.m4
1209 m4/base64.m4 1640 m4/base64.m4
1210 m4/btowc.m4 1641 m4/btowc.m4
1642 m4/build-to-host.m4
1211 m4/builtin-expect.m4 1643 m4/builtin-expect.m4
1212 m4/byteswap.m4 1644 m4/byteswap.m4
1213 m4/c-bool.m4 1645 m4/c-bool.m4
1646 m4/c32rtomb.m4
1214 m4/calloc.m4 1647 m4/calloc.m4
1215 m4/close.m4 1648 m4/close.m4
1216 m4/codeset.m4 1649 m4/codeset.m4
1217 m4/double-slash-root.m4 1650 m4/double-slash-root.m4
1218 m4/dup2.m4 1651 m4/dup2.m4
1219 m4/eealloc.m4
1220 m4/environ.m4 1652 m4/environ.m4
1221 m4/errno_h.m4 1653 m4/errno_h.m4
1222 m4/error.m4 1654 m4/error.m4
1655 m4/error_h.m4
1223 m4/exponentd.m4 1656 m4/exponentd.m4
1657 m4/extensions-aix.m4
1224 m4/extensions.m4 1658 m4/extensions.m4
1225 m4/extern-inline.m4 1659 m4/extern-inline.m4
1660 m4/fclose.m4
1226 m4/fcntl-o.m4 1661 m4/fcntl-o.m4
1227 m4/fcntl.m4 1662 m4/fcntl.m4
1228 m4/fcntl_h.m4 1663 m4/fcntl_h.m4
@@ -1235,6 +1670,7 @@ AC_DEFUN([gl_FILE_LIST], [
1235 m4/free.m4 1670 m4/free.m4
1236 m4/fseek.m4 1671 m4/fseek.m4
1237 m4/fseeko.m4 1672 m4/fseeko.m4
1673 m4/fseterr.m4
1238 m4/fstat.m4 1674 m4/fstat.m4
1239 m4/fstypename.m4 1675 m4/fstypename.m4
1240 m4/fsusage.m4 1676 m4/fsusage.m4
@@ -1248,19 +1684,29 @@ AC_DEFUN([gl_FILE_LIST], [
1248 m4/getloadavg.m4 1684 m4/getloadavg.m4
1249 m4/getopt.m4 1685 m4/getopt.m4
1250 m4/getprogname.m4 1686 m4/getprogname.m4
1687 m4/gettext_h.m4
1251 m4/gl-openssl.m4 1688 m4/gl-openssl.m4
1252 m4/gnulib-common.m4 1689 m4/gnulib-common.m4
1690 m4/gnulib-i18n.m4
1253 m4/hostent.m4 1691 m4/hostent.m4
1254 m4/idpriv.m4 1692 m4/idpriv.m4
1255 m4/include_next.m4 1693 m4/include_next.m4
1256 m4/inet_ntop.m4 1694 m4/inet_ntop.m4
1695 m4/inet_pton.m4
1257 m4/intmax_t.m4 1696 m4/intmax_t.m4
1258 m4/inttypes.m4 1697 m4/inttypes.m4
1259 m4/inttypes_h.m4 1698 m4/inttypes_h.m4
1699 m4/iswblank.m4
1700 m4/iswctype.m4
1701 m4/iswdigit.m4
1702 m4/iswpunct.m4
1703 m4/iswxdigit.m4
1260 m4/langinfo_h.m4 1704 m4/langinfo_h.m4
1261 m4/largefile.m4 1705 m4/largefile.m4
1706 m4/libunistring-base.m4
1262 m4/limits-h.m4 1707 m4/limits-h.m4
1263 m4/localcharset.m4 1708 m4/localcharset.m4
1709 m4/locale-en.m4
1264 m4/locale-fr.m4 1710 m4/locale-fr.m4
1265 m4/locale-ja.m4 1711 m4/locale-ja.m4
1266 m4/locale-zh.m4 1712 m4/locale-zh.m4
@@ -1268,9 +1714,13 @@ AC_DEFUN([gl_FILE_LIST], [
1268 m4/localeconv.m4 1714 m4/localeconv.m4
1269 m4/lock.m4 1715 m4/lock.m4
1270 m4/lseek.m4 1716 m4/lseek.m4
1717 m4/lstat.m4
1271 m4/malloc.m4 1718 m4/malloc.m4
1272 m4/malloca.m4 1719 m4/malloca.m4
1273 m4/math_h.m4 1720 m4/math_h.m4
1721 m4/mbchar.m4
1722 m4/mbiter.m4
1723 m4/mbrtoc32.m4
1274 m4/mbrtowc.m4 1724 m4/mbrtowc.m4
1275 m4/mbsinit.m4 1725 m4/mbsinit.m4
1276 m4/mbstate_t.m4 1726 m4/mbstate_t.m4
@@ -1284,21 +1734,28 @@ AC_DEFUN([gl_FILE_LIST], [
1284 m4/msvc-inval.m4 1734 m4/msvc-inval.m4
1285 m4/msvc-nothrow.m4 1735 m4/msvc-nothrow.m4
1286 m4/multiarch.m4 1736 m4/multiarch.m4
1737 m4/musl.m4
1287 m4/netdb_h.m4 1738 m4/netdb_h.m4
1288 m4/netinet_in_h.m4 1739 m4/netinet_in_h.m4
1289 m4/nl_langinfo.m4 1740 m4/nl_langinfo.m4
1290 m4/nocrash.m4 1741 m4/nocrash.m4
1742 m4/off64_t.m4
1291 m4/off_t.m4 1743 m4/off_t.m4
1744 m4/once.m4
1292 m4/open-cloexec.m4 1745 m4/open-cloexec.m4
1293 m4/open-slash.m4 1746 m4/open-slash.m4
1294 m4/open.m4 1747 m4/open.m4
1295 m4/pathmax.m4 1748 m4/pathmax.m4
1296 m4/pid_t.m4 1749 m4/pid_t.m4
1297 m4/printf.m4 1750 m4/printf.m4
1751 m4/pthread-once.m4
1752 m4/pthread-spin.m4
1753 m4/pthread_h.m4
1298 m4/pthread_rwlock_rdlock.m4 1754 m4/pthread_rwlock_rdlock.m4
1299 m4/realloc.m4 1755 m4/realloc.m4
1300 m4/reallocarray.m4 1756 m4/reallocarray.m4
1301 m4/regex.m4 1757 m4/regex.m4
1758 m4/sched_h.m4
1302 m4/servent.m4 1759 m4/servent.m4
1303 m4/setenv.m4 1760 m4/setenv.m4
1304 m4/setlocale_null.m4 1761 m4/setlocale_null.m4
@@ -1314,18 +1771,23 @@ AC_DEFUN([gl_FILE_LIST], [
1314 m4/stat.m4 1771 m4/stat.m4
1315 m4/std-gnu11.m4 1772 m4/std-gnu11.m4
1316 m4/stdalign.m4 1773 m4/stdalign.m4
1774 m4/stdckdint_h.m4
1317 m4/stddef_h.m4 1775 m4/stddef_h.m4
1318 m4/stdint.m4 1776 m4/stdint.m4
1319 m4/stdint_h.m4 1777 m4/stdint_h.m4
1320 m4/stdio_h.m4 1778 m4/stdio_h.m4
1321 m4/stdlib_h.m4 1779 m4/stdlib_h.m4
1322 m4/strcase.m4 1780 m4/strcasecmp.m4
1323 m4/strcasestr.m4 1781 m4/strcasestr.m4
1324 m4/strerror.m4 1782 m4/strerror.m4
1325 m4/string_h.m4 1783 m4/string_h.m4
1784 m4/stringeq.m4
1326 m4/strings_h.m4 1785 m4/strings_h.m4
1786 m4/strncasecmp.m4
1787 m4/strncpy.m4
1327 m4/strsep.m4 1788 m4/strsep.m4
1328 m4/strstr.m4 1789 m4/strstr.m4
1790 m4/sys_cdefs_h.m4
1329 m4/sys_socket_h.m4 1791 m4/sys_socket_h.m4
1330 m4/sys_stat_h.m4 1792 m4/sys_stat_h.m4
1331 m4/sys_types_h.m4 1793 m4/sys_types_h.m4
@@ -1334,8 +1796,13 @@ AC_DEFUN([gl_FILE_LIST], [
1334 m4/time_h.m4 1796 m4/time_h.m4
1335 m4/time_r.m4 1797 m4/time_r.m4
1336 m4/timegm.m4 1798 m4/timegm.m4
1799 m4/uchar_h.m4
1337 m4/ungetc.m4 1800 m4/ungetc.m4
1801 m4/unicase_h.m4
1802 m4/unictype_h.m4
1803 m4/uninorm_h.m4
1338 m4/unistd_h.m4 1804 m4/unistd_h.m4
1805 m4/unitypes_h.m4
1339 m4/unlocked-io.m4 1806 m4/unlocked-io.m4
1340 m4/vararrays.m4 1807 m4/vararrays.m4
1341 m4/vasnprintf.m4 1808 m4/vasnprintf.m4
@@ -1344,9 +1811,10 @@ AC_DEFUN([gl_FILE_LIST], [
1344 m4/vsnprintf.m4 1811 m4/vsnprintf.m4
1345 m4/warn-on-use.m4 1812 m4/warn-on-use.m4
1346 m4/wchar_h.m4 1813 m4/wchar_h.m4
1347 m4/wchar_t.m4
1348 m4/wcrtomb.m4 1814 m4/wcrtomb.m4
1815 m4/wctype.m4
1349 m4/wctype_h.m4 1816 m4/wctype_h.m4
1817 m4/wcwidth.m4
1350 m4/wint_t.m4 1818 m4/wint_t.m4
1351 m4/xalloc.m4 1819 m4/xalloc.m4
1352 m4/xsize.m4 1820 m4/xsize.m4
diff --git a/gl/m4/gnulib-i18n.m4 b/gl/m4/gnulib-i18n.m4
new file mode 100644
index 00000000..9a389187
--- /dev/null
+++ b/gl/m4/gnulib-i18n.m4
@@ -0,0 +1,61 @@
1# gnulib-i18n.m4
2# serial 1
3dnl Copyright (C) 2005-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Bruno Haible.
10
11dnl Support for internationalization of Gnulib code.
12
13dnl GNULIB_I18N
14dnl Sets GNULIB_LOCALEDIR to indicate where to find the gnulib.mo files.
15dnl Also it defines GNULIB_LOCALEDIR as macro in config.h, that expands to
16dnl the corresponding C string.
17AC_DEFUN([GNULIB_I18N],
18[
19 dnl It is best to not test "$USE_NLS" here, because: It would be empty
20 dnl in case the package is internationalized but this macro is used before
21 dnl AM_GNU_GETTEXT. We would need to warn about this situation. But since
22 dnl this module is used as a dependency of many packages, such a warning is
23 dnl not welcome.
24
25 dnl Determine gnulib's localedir.
26 dnl Generally, accept an option --with-gnulib-prefix=PREFIX to indicate
27 dnl where to find gnulib's runtime data.
28 dnl Usually ${prefix}/share/locale, but can be influenced by the configure
29 dnl options --datarootdir and --localedir.
30 GNULIB_LOCALEDIR="${localedir}"
31 AC_ARG_WITH([gnulib-prefix],
32 [[ --with-gnulib-prefix=DIR search for gnulib's runtime data in DIR/share]],
33 [if test "X$withval" != "X" && test "X$withval" != "Xno"; then
34 GNULIB_LOCALEDIR="$withval/share/locale"
35 fi
36 ])
37 AC_SUBST([GNULIB_LOCALEDIR])
38
39 dnl Define GNULIB_LOCALEDIR_c and GNULIB_LOCALEDIR_c_make.
40 dnl Find the final value of GNULIB_LOCALEDIR.
41 gl_saved_prefix="${prefix}"
42 gl_saved_datarootdir="${datarootdir}"
43 gl_saved_localedir="${localedir}"
44 gl_saved_gnuliblocaledir="${GNULIB_LOCALEDIR}"
45 dnl Unfortunately, prefix gets only finally determined at the end of
46 dnl configure.
47 if test "X$prefix" = "XNONE"; then
48 prefix="$ac_default_prefix"
49 fi
50 eval datarootdir="$datarootdir"
51 eval localedir="$localedir"
52 eval GNULIB_LOCALEDIR="$GNULIB_LOCALEDIR"
53 gl_BUILD_TO_HOST([GNULIB_LOCALEDIR])
54 GNULIB_LOCALEDIR="${gl_saved_gnuliblocaledir}"
55 localedir="${gl_saved_localedir}"
56 datarootdir="${gl_saved_datarootdir}"
57 prefix="${gl_saved_prefix}"
58
59 AC_DEFINE_UNQUOTED([GNULIB_LOCALEDIR], [${GNULIB_LOCALEDIR_c}],
60 [Define to the directory where to find the localizations of the translation domain 'gnulib', as a C string.])
61])
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index a9dd569b..83d1e701 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,8 +1,10 @@
1# gnulib-tool.m4 serial 4 1# gnulib-tool.m4
2dnl Copyright (C) 2004-2005, 2009-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2004-2005, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl The following macros need not be invoked explicitly. 9dnl The following macros need not be invoked explicitly.
8dnl Invoking them does nothing except to declare default arguments 10dnl Invoking them does nothing except to declare default arguments
@@ -41,6 +43,9 @@ AC_DEFUN([gl_LIB], [])
41dnl Usage: gl_LGPL or gl_LGPL([VERSION]) 43dnl Usage: gl_LGPL or gl_LGPL([VERSION])
42AC_DEFUN([gl_LGPL], []) 44AC_DEFUN([gl_LGPL], [])
43 45
46dnl Usage: gl_GPL([VERSION])
47AC_DEFUN([gl_GPL], [])
48
44dnl Usage: gl_MAKEFILE_NAME([FILENAME]) 49dnl Usage: gl_MAKEFILE_NAME([FILENAME])
45AC_DEFUN([gl_MAKEFILE_NAME], []) 50AC_DEFUN([gl_MAKEFILE_NAME], [])
46 51
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
index 3b2cc2b2..0303ff80 100644
--- a/gl/m4/hostent.m4
+++ b/gl/m4/hostent.m4
@@ -1,8 +1,10 @@
1# hostent.m4 serial 4 1# hostent.m4
2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2008, 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_HOSTENT], 9AC_DEFUN([gl_HOSTENT],
8[ 10[
@@ -26,7 +28,7 @@ AC_DEFUN([gl_HOSTENT],
26 AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32], 28 AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32],
27 [gl_cv_w32_gethostbyname], 29 [gl_cv_w32_gethostbyname],
28 [gl_cv_w32_gethostbyname=no 30 [gl_cv_w32_gethostbyname=no
29 gl_save_LIBS="$LIBS" 31 gl_saved_LIBS="$LIBS"
30 LIBS="$LIBS -lws2_32" 32 LIBS="$LIBS -lws2_32"
31 AC_LINK_IFELSE( 33 AC_LINK_IFELSE(
32 [AC_LANG_PROGRAM( 34 [AC_LANG_PROGRAM(
@@ -38,7 +40,7 @@ AC_DEFUN([gl_HOSTENT],
38 ]], 40 ]],
39 [[gethostbyname(NULL);]])], 41 [[gethostbyname(NULL);]])],
40 [gl_cv_w32_gethostbyname=yes]) 42 [gl_cv_w32_gethostbyname=yes])
41 LIBS="$gl_save_LIBS" 43 LIBS="$gl_saved_LIBS"
42 ]) 44 ])
43 if test "$gl_cv_w32_gethostbyname" = "yes"; then 45 if test "$gl_cv_w32_gethostbyname" = "yes"; then
44 HOSTENT_LIB="-lws2_32" 46 HOSTENT_LIB="-lws2_32"
diff --git a/gl/m4/idpriv.m4 b/gl/m4/idpriv.m4
index fc3dd17d..a7091ad3 100644
--- a/gl/m4/idpriv.m4
+++ b/gl/m4/idpriv.m4
@@ -1,8 +1,10 @@
1# idpriv.m4 serial 1 1# idpriv.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 1
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_IDPRIV], 9AC_DEFUN([gl_IDPRIV],
8[ 10[
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index 9f19215e..a19f2dfd 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,8 +1,10 @@
1# include_next.m4 serial 26 1# include_next.m4
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 2# serial 27
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Paul Eggert and Derek Price. 9dnl From Paul Eggert and Derek Price.
8 10
@@ -74,17 +76,17 @@ EOF
74#endif 76#endif
75#define DEFINED_IN_CONFTESTD2 77#define DEFINED_IN_CONFTESTD2
76EOF 78EOF
77 gl_save_CPPFLAGS="$CPPFLAGS" 79 gl_saved_CPPFLAGS="$CPPFLAGS"
78 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" 80 CPPFLAGS="$gl_saved_CPPFLAGS -Iconftestd1b -Iconftestd2"
79dnl We intentionally avoid using AC_LANG_SOURCE here. 81dnl We intentionally avoid using AC_LANG_SOURCE here.
80 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], 82 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
81 [gl_cv_have_include_next=yes], 83 [gl_cv_have_include_next=yes],
82 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" 84 [CPPFLAGS="$gl_saved_CPPFLAGS -Iconftestd1a -Iconftestd2"
83 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], 85 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
84 [gl_cv_have_include_next=buggy], 86 [gl_cv_have_include_next=buggy],
85 [gl_cv_have_include_next=no]) 87 [gl_cv_have_include_next=no])
86 ]) 88 ])
87 CPPFLAGS="$gl_save_CPPFLAGS" 89 CPPFLAGS="$gl_saved_CPPFLAGS"
88 rm -rf conftestd1a conftestd1b conftestd2 90 rm -rf conftestd1a conftestd1b conftestd2
89 ]) 91 ])
90 PRAGMA_SYSTEM_HEADER= 92 PRAGMA_SYSTEM_HEADER=
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index 48822d69..62e7a575 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,8 +1,10 @@
1# inet_ntop.m4 serial 21 1# inet_ntop.m4
2dnl Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 2# serial 23
3dnl Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_INET_NTOP], 9AC_DEFUN([gl_FUNC_INET_NTOP],
8[ 10[
@@ -17,6 +19,7 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
17 dnl Solaris 8..10 provide inet_ntop in libnsl instead. 19 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. 20 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
19 dnl Haiku provides it in -lnetwork. 21 dnl Haiku provides it in -lnetwork.
22 dnl QNX provides it in -lsocket.
20 dnl Native Windows provides it in -lws2_32 instead, with a declaration in 23 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
21 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl 24 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
22 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). 25 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
@@ -36,14 +39,14 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
36 HAVE_DECL_INET_NTOP=0 39 HAVE_DECL_INET_NTOP=0
37 fi 40 fi
38 else 41 else
39 gl_save_LIBS=$LIBS 42 gl_saved_LIBS=$LIBS
40 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [], 43 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network socket], [],
41 [AC_CHECK_FUNCS([inet_ntop]) 44 [AC_CHECK_FUNCS([inet_ntop])
42 if test $ac_cv_func_inet_ntop = no; then 45 if test $ac_cv_func_inet_ntop = no; then
43 HAVE_INET_NTOP=0 46 HAVE_INET_NTOP=0
44 fi 47 fi
45 ]) 48 ])
46 LIBS=$gl_save_LIBS 49 LIBS=$gl_saved_LIBS
47 50
48 if test "$ac_cv_search_inet_ntop" != "no" \ 51 if test "$ac_cv_search_inet_ntop" != "no" \
49 && test "$ac_cv_search_inet_ntop" != "none required"; then 52 && test "$ac_cv_search_inet_ntop" != "none required"; then
diff --git a/gl/m4/inet_pton.m4 b/gl/m4/inet_pton.m4
new file mode 100644
index 00000000..150c3a07
--- /dev/null
+++ b/gl/m4/inet_pton.m4
@@ -0,0 +1,73 @@
1# inet_pton.m4
2# serial 21
3dnl Copyright (C) 2006, 2008-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_INET_PTON],
10[
11 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
12
13 dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15
16 AC_REQUIRE([AC_C_RESTRICT])
17
18 dnl Most platforms that provide inet_pton define it in libc.
19 dnl Solaris 8..10 provide inet_pton in libnsl instead.
20 dnl Solaris 2.6..7 provide inet_pton in libresolv instead.
21 dnl Haiku provides it in -lnetwork.
22 dnl QNX provides it in -lsocket.
23 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
24 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
25 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
26 HAVE_INET_PTON=1
27 INET_PTON_LIB=
28 gl_PREREQ_SYS_H_WINSOCK2
29 if test $HAVE_WINSOCK2_H = 1; then
30 dnl It needs to be overridden, because the stdcall calling convention
31 dnl is not compliant with POSIX. Set REPLACE_INET_PTON in order to avoid
32 dnl a name conflict at the linker level, even though the header file
33 dnl <ws2tcpip.h> declares inet_pton only if _WIN32_WINNT >= 0x0600.
34 REPLACE_INET_PTON=1
35 AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
36 if test $ac_cv_have_decl_inet_pton = yes; then
37 INET_PTON_LIB="-lws2_32"
38 else
39 HAVE_DECL_INET_PTON=0
40 fi
41 else
42 gl_saved_LIBS=$LIBS
43 AC_SEARCH_LIBS([inet_pton], [nsl resolv network socket], [],
44 [AC_CHECK_FUNCS([inet_pton])
45 if test $ac_cv_func_inet_pton = no; then
46 HAVE_INET_PTON=0
47 fi
48 ])
49 LIBS=$gl_saved_LIBS
50
51 if test "$ac_cv_search_inet_pton" != "no" \
52 && test "$ac_cv_search_inet_pton" != "none required"; then
53 INET_PTON_LIB="$ac_cv_search_inet_pton"
54 fi
55
56 AC_CHECK_HEADERS_ONCE([netdb.h])
57 AC_CHECK_DECLS([inet_pton],,,
58 [[#include <arpa/inet.h>
59 #if HAVE_NETDB_H
60 # include <netdb.h>
61 #endif
62 ]])
63 if test $ac_cv_have_decl_inet_pton = no; then
64 HAVE_DECL_INET_PTON=0
65 fi
66 fi
67 AC_SUBST([INET_PTON_LIB])
68])
69
70# Prerequisites of lib/inet_pton.c.
71AC_DEFUN([gl_PREREQ_INET_PTON], [
72 AC_REQUIRE([gl_SOCKET_FAMILIES])
73])
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index ef32e1b9..ad79536c 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,9 +1,11 @@
1# intmax_t.m4 serial 9 1# intmax_t.m4
2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2023 Free Software Foundation, 2# serial 9
3dnl Copyright (C) 1997-2004, 2006-2007, 2009-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8dnl From Paul Eggert. 10dnl From Paul Eggert.
9 11
diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4
index bf2eab2b..ec17c237 100644
--- a/gl/m4/inttypes.m4
+++ b/gl/m4/inttypes.m4
@@ -1,8 +1,10 @@
1# inttypes.m4 serial 36 1# inttypes.m4
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 2# serial 37
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Derek Price, Bruno Haible. 9dnl From Derek Price, Bruno Haible.
8dnl Test whether <inttypes.h> is supported or must be substituted. 10dnl Test whether <inttypes.h> is supported or must be substituted.
@@ -170,6 +172,10 @@ AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
170 HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX]) 172 HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
171 HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX]) 173 HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
172 HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T]) 174 HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T])
175 HAVE_IMAXABS=1; AC_SUBST([HAVE_IMAXABS])
176 HAVE_IMAXDIV=1; AC_SUBST([HAVE_IMAXDIV])
177 REPLACE_IMAXABS=0; AC_SUBST([REPLACE_IMAXABS])
178 REPLACE_IMAXDIV=0; AC_SUBST([REPLACE_IMAXDIV])
173 REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX]) 179 REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX])
174 REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX]) 180 REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX])
175 INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX]) 181 INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index 68c60e9d..ed9e7033 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,8 +1,10 @@
1# inttypes_h.m4 serial 10 1# inttypes_h.m4
2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc. 2# serial 10
3dnl Copyright (C) 1997-2004, 2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Paul Eggert. 9dnl From Paul Eggert.
8 10
diff --git a/gl/m4/iswblank.m4 b/gl/m4/iswblank.m4
new file mode 100644
index 00000000..2c301a97
--- /dev/null
+++ b/gl/m4/iswblank.m4
@@ -0,0 +1,40 @@
1# iswblank.m4
2# serial 7
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_ISWBLANK],
10[
11 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
12 AC_REQUIRE([gl_WCTYPE_H])
13 dnl Persuade glibc <wctype.h> to declare iswblank().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 gl_CHECK_FUNCS_ANDROID([iswblank], [[#include <wctype.h>]])
16 AC_CHECK_DECLS([iswblank], , , [[
17 #include <wchar.h>
18 #include <wctype.h>
19 ]])
20 if test $ac_cv_func_iswblank = no; then
21 HAVE_ISWBLANK=0
22 if test $ac_cv_have_decl_iswblank = yes \
23 || case "$gl_cv_onwards_func_iswblank" in \
24 future*) true ;; \
25 *) false ;; \
26 esac; then
27 REPLACE_ISWBLANK=1
28 fi
29 fi
30 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
31 dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
32 :
33 else
34 if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then
35 dnl Redefine only iswblank.
36 :
37 fi
38 fi
39
40])
diff --git a/gl/m4/iswctype.m4 b/gl/m4/iswctype.m4
new file mode 100644
index 00000000..3b179a76
--- /dev/null
+++ b/gl/m4/iswctype.m4
@@ -0,0 +1,15 @@
1# iswctype.m4
2# serial 3
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_ISWCTYPE],
10[
11 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
12 AC_REQUIRE([gl_WCTYPE_H])
13 dnl Determine REPLACE_WCTYPE.
14 AC_REQUIRE([gl_FUNC_WCTYPE])
15])
diff --git a/gl/m4/iswdigit.m4 b/gl/m4/iswdigit.m4
new file mode 100644
index 00000000..7fca8167
--- /dev/null
+++ b/gl/m4/iswdigit.m4
@@ -0,0 +1,122 @@
1# iswdigit.m4
2# serial 9
3dnl Copyright (C) 2020-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_ISWDIGIT],
10[
11 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
12 AC_REQUIRE([gl_WCTYPE_H])
13 AC_REQUIRE([gt_LOCALE_FR])
14 AC_REQUIRE([gt_LOCALE_JA])
15 AC_REQUIRE([gt_LOCALE_EN_UTF8])
16 AC_REQUIRE([gt_LOCALE_ZH_CN])
17 AC_REQUIRE([AC_CANONICAL_HOST])
18
19 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
20 dnl <wctype.h> redefines iswdigit already.
21 REPLACE_ISWDIGIT="$REPLACE_ISWCNTRL"
22 else
23 AC_CACHE_CHECK([whether iswdigit is ISO C compliant],
24 [gl_cv_func_iswdigit_works],
25 [
26 dnl Initial guess, used when cross-compiling or when no suitable locale
27 dnl is present.
28changequote(,)dnl
29 case "$host_os" in
30 # Guess no on FreeBSD, NetBSD, OpenBSD, Solaris, native Windows, Haiku, Android.
31 freebsd* | dragonfly* | netbsd* | openbsd* | solaris* | mingw* | windows* | haiku* | *-android*)
32 gl_cv_func_iswdigit_works="guessing no" ;;
33 # Guess yes otherwise.
34 *) gl_cv_func_iswdigit_works="guessing yes" ;;
35 esac
36changequote([,])dnl
37 if test $LOCALE_FR != none || test $LOCALE_JA != none || test "$LOCALE_EN_UTF8" != none || test $LOCALE_ZH_CN != none; then
38 AC_RUN_IFELSE(
39 [AC_LANG_SOURCE([[
40#include <locale.h>
41#include <stdlib.h>
42#include <string.h>
43#include <wchar.h>
44#include <wctype.h>
45
46/* Returns the value of iswdigit for the multibyte character s[0..n-1]. */
47static int
48for_character (const char *s, size_t n)
49{
50 mbstate_t state;
51 wchar_t wc;
52 size_t ret;
53
54 memset (&state, '\0', sizeof (mbstate_t));
55 wc = (wchar_t) 0xBADFACE;
56 ret = mbrtowc (&wc, s, n, &state);
57 if (ret != n)
58 abort ();
59
60 return iswdigit (wc);
61}
62
63int
64main (int argc, char *argv[])
65{
66 int is;
67 int result = 0;
68
69 if (strcmp ("$LOCALE_FR", "none") != 0
70 && setlocale (LC_ALL, "$LOCALE_FR") != NULL)
71 {
72 /* This fails on mingw, MSVC 14. */
73 /* U+00B2 SUPERSCRIPT TWO */
74 is = for_character ("\262", 1);
75 if (!(is == 0))
76 result |= 1;
77 }
78 if (strcmp ("$LOCALE_JA", "none") != 0
79 && setlocale (LC_ALL, "$LOCALE_JA") != NULL)
80 {
81 /* This fails on NetBSD 10.0. */
82 /* U+FF11 FULLWIDTH DIGIT ONE */
83 is = for_character ("\243\261", 2);
84 if (!(is == 0))
85 result |= 2;
86 }
87 if (strcmp ("$LOCALE_EN_UTF8", "none") != 0
88 && setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
89 {
90 /* This fails on FreeBSD 13.0, NetBSD 10.0, OpenBSD 7.5, MSVC 14, Haiku, Android. */
91 /* U+0663 ARABIC-INDIC DIGIT THREE */
92 is = for_character ("\331\243", 2);
93 if (!(is == 0))
94 result |= 4;
95 /* This fails on FreeBSD 13.0, NetBSD 10.0, OpenBSD 7.5, MSVC 14, Haiku, Android. */
96 /* U+FF11 FULLWIDTH DIGIT ONE */
97 is = for_character ("\357\274\221", 3);
98 if (!(is == 0))
99 result |= 8;
100 }
101 if (strcmp ("$LOCALE_ZH_CN", "none") != 0
102 && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
103 {
104 /* This fails on NetBSD 10.0, Solaris 10, Solaris 11.4. */
105 /* U+FF11 FULLWIDTH DIGIT ONE */
106 is = for_character ("\243\261", 2);
107 if (!(is == 0))
108 result |= 16;
109 }
110 return result;
111}]])],
112 [gl_cv_func_iswdigit_works=yes],
113 [gl_cv_func_iswdigit_works=no],
114 [:])
115 fi
116 ])
117 case "$gl_cv_func_iswdigit_works" in
118 *yes) ;;
119 *) REPLACE_ISWDIGIT=1 ;;
120 esac
121 fi
122])
diff --git a/gl/m4/iswpunct.m4 b/gl/m4/iswpunct.m4
new file mode 100644
index 00000000..be312d6c
--- /dev/null
+++ b/gl/m4/iswpunct.m4
@@ -0,0 +1,50 @@
1# iswpunct.m4
2# serial 2
3dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_ISWPUNCT],
10[
11 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
12 AC_REQUIRE([gl_WCTYPE_H])
13 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
14
15 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
16 dnl <wctype.h> redefines iswpunct already.
17 REPLACE_ISWPUNCT="$REPLACE_ISWCNTRL"
18 else
19 AC_CACHE_CHECK([whether iswpunct is consistent with ispunct],
20 [gl_cv_func_iswpunct_works],
21 [AC_RUN_IFELSE(
22 [AC_LANG_SOURCE([[
23#include <ctype.h>
24#include <wchar.h>
25#include <wctype.h>
26int
27main (int argc, char *argv[])
28{
29 int result = 0;
30 /* This fails on Android 11. */
31 if ((! iswpunct ('\`')) != (! ispunct ('\`')))
32 result |= 1;
33 return result;
34}]])],
35 [gl_cv_func_iswpunct_works=yes],
36 [gl_cv_func_iswpunct_works=no],
37 [case "$host_os" in
38 # Guess no on Android.
39 android*) gl_cv_func_iswpunct_works="guessing no" ;;
40 # Guess yes otherwise.
41 *) gl_cv_func_iswpunct_works="guessing yes" ;;
42 esac
43 ])
44 ])
45 case "$gl_cv_func_iswpunct_works" in
46 *yes) ;;
47 *) REPLACE_ISWPUNCT=1 ;;
48 esac
49 fi
50])
diff --git a/gl/m4/iswxdigit.m4 b/gl/m4/iswxdigit.m4
new file mode 100644
index 00000000..2cb8e873
--- /dev/null
+++ b/gl/m4/iswxdigit.m4
@@ -0,0 +1,112 @@
1# iswxdigit.m4
2# serial 9
3dnl Copyright (C) 2020-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_ISWXDIGIT],
10[
11 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
12 AC_REQUIRE([gl_WCTYPE_H])
13 AC_REQUIRE([gt_LOCALE_JA])
14 AC_REQUIRE([gt_LOCALE_EN_UTF8])
15 AC_REQUIRE([gt_LOCALE_ZH_CN])
16 AC_REQUIRE([AC_CANONICAL_HOST])
17
18 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
19 dnl <wctype.h> redefines iswxdigit already.
20 REPLACE_ISWXDIGIT="$REPLACE_ISWCNTRL"
21 else
22 AC_CACHE_CHECK([whether iswxdigit is ISO C compliant],
23 [gl_cv_func_iswxdigit_works],
24 [
25 dnl Initial guess, used when cross-compiling or when no suitable locale
26 dnl is present.
27changequote(,)dnl
28 case "$host_os" in
29 # Guess no on FreeBSD, NetBSD, OpenBSD, Solaris, native Windows, Haiku, Android.
30 freebsd* | dragonfly* | netbsd* | openbsd* | solaris* | mingw* | windows* | haiku* | *-android*)
31 gl_cv_func_iswxdigit_works="guessing no" ;;
32 # Guess yes otherwise.
33 *) gl_cv_func_iswxdigit_works="guessing yes" ;;
34 esac
35changequote([,])dnl
36 if test $LOCALE_JA != none || test "$LOCALE_EN_UTF8" != none || test $LOCALE_ZH_CN != none; then
37 AC_RUN_IFELSE(
38 [AC_LANG_SOURCE([[
39#include <locale.h>
40#include <stdlib.h>
41#include <string.h>
42#include <wchar.h>
43#include <wctype.h>
44
45/* Returns the value of iswxdigit for the multibyte character s[0..n-1]. */
46static int
47for_character (const char *s, size_t n)
48{
49 mbstate_t state;
50 wchar_t wc;
51 size_t ret;
52
53 memset (&state, '\0', sizeof (mbstate_t));
54 wc = (wchar_t) 0xBADFACE;
55 ret = mbrtowc (&wc, s, n, &state);
56 if (ret != n)
57 abort ();
58
59 return iswxdigit (wc);
60}
61
62int
63main (int argc, char *argv[])
64{
65 int is;
66 int result = 0;
67
68 if (strcmp ("$LOCALE_JA", "none") != 0
69 && setlocale (LC_ALL, "$LOCALE_JA") != NULL)
70 {
71 /* This fails on NetBSD 10.0. */
72 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
73 is = for_character ("\243\301", 2);
74 if (!(is == 0))
75 result |= 1;
76 }
77 if (strcmp ("$LOCALE_EN_UTF8", "none") != 0
78 && setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
79 {
80 /* This fails on FreeBSD 13.0, Haiku, Android. */
81 /* U+0663 ARABIC-INDIC DIGIT THREE */
82 is = for_character ("\331\243", 2);
83 if (!(is == 0))
84 result |= 2;
85 /* This fails on NetBSD 10.0, OpenBSD 7.5, MSVC 14, Haiku, Android. */
86 /* U+FF21 FULLWIDTH LATIN CAPITAL LETTER A */
87 is = for_character ("\357\274\241", 3);
88 if (!(is == 0))
89 result |= 4;
90 }
91 if (strcmp ("$LOCALE_ZH_CN", "none") != 0
92 && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
93 {
94 /* This fails on Solaris 10, Solaris 11.4. */
95 /* U+FF11 FULLWIDTH DIGIT ONE */
96 is = for_character ("\243\261", 2);
97 if (!(is == 0))
98 result |= 8;
99 }
100 return result;
101}]])],
102 [gl_cv_func_iswxdigit_works=yes],
103 [gl_cv_func_iswxdigit_works=no],
104 [:])
105 fi
106 ])
107 case "$gl_cv_func_iswxdigit_works" in
108 *yes) ;;
109 *) REPLACE_ISWXDIGIT=1 ;;
110 esac
111 fi
112])
diff --git a/gl/m4/langinfo_h.m4 b/gl/m4/langinfo_h.m4
index b17a526a..3ed8d593 100644
--- a/gl/m4/langinfo_h.m4
+++ b/gl/m4/langinfo_h.m4
@@ -1,8 +1,10 @@
1# langinfo_h.m4 serial 12 1# langinfo_h.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 14
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_LANGINFO_H], 9AC_DEFUN_ONCE([gl_LANGINFO_H],
8[ 10[
@@ -16,18 +18,17 @@ AC_DEFUN_ONCE([gl_LANGINFO_H],
16 18
17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS. 19 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
18 HAVE_LANGINFO_CODESET=0 20 HAVE_LANGINFO_CODESET=0
19 HAVE_LANGINFO_T_FMT_AMPM=0
20 HAVE_LANGINFO_ALTMON=0 21 HAVE_LANGINFO_ALTMON=0
22 HAVE_LANGINFO_ABALTMON=0
21 HAVE_LANGINFO_ERA=0 23 HAVE_LANGINFO_ERA=0
22 HAVE_LANGINFO_YESEXPR=0
23 AC_CHECK_HEADERS_ONCE([langinfo.h]) 24 AC_CHECK_HEADERS_ONCE([langinfo.h])
24 if test $ac_cv_header_langinfo_h = yes; then 25 if test $ac_cv_header_langinfo_h = yes; then
25 HAVE_LANGINFO_H=1 26 HAVE_LANGINFO_H=1
26 dnl Determine what <langinfo.h> defines. 27 dnl Determine what <langinfo.h> defines.
27 dnl CODESET is missing on OpenBSD 3.8. 28 dnl CODESET is missing on OpenBSD 3.8.
28 dnl ERA etc. are missing on OpenBSD 6.7. 29 dnl ERA etc. are missing on OpenBSD 6.7.
29 dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
30 dnl ALTMON_* are missing on glibc 2.26 and many other systems. 30 dnl ALTMON_* are missing on glibc 2.26 and many other systems.
31 dnl ABALTMON_* are missing on glibc 2.41 and many other systems.
31 AC_CACHE_CHECK([whether langinfo.h defines CODESET], 32 AC_CACHE_CHECK([whether langinfo.h defines CODESET],
32 [gl_cv_header_langinfo_codeset], 33 [gl_cv_header_langinfo_codeset],
33 [AC_COMPILE_IFELSE( 34 [AC_COMPILE_IFELSE(
@@ -40,18 +41,6 @@ int a = CODESET;
40 if test $gl_cv_header_langinfo_codeset = yes; then 41 if test $gl_cv_header_langinfo_codeset = yes; then
41 HAVE_LANGINFO_CODESET=1 42 HAVE_LANGINFO_CODESET=1
42 fi 43 fi
43 AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM],
44 [gl_cv_header_langinfo_t_fmt_ampm],
45 [AC_COMPILE_IFELSE(
46 [AC_LANG_PROGRAM([[#include <langinfo.h>
47int a = T_FMT_AMPM;
48]])],
49 [gl_cv_header_langinfo_t_fmt_ampm=yes],
50 [gl_cv_header_langinfo_t_fmt_ampm=no])
51 ])
52 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
53 HAVE_LANGINFO_T_FMT_AMPM=1
54 fi
55 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1], 44 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1],
56 [gl_cv_header_langinfo_altmon], 45 [gl_cv_header_langinfo_altmon],
57 [AC_COMPILE_IFELSE( 46 [AC_COMPILE_IFELSE(
@@ -64,6 +53,18 @@ int a = ALTMON_1;
64 if test $gl_cv_header_langinfo_altmon = yes; then 53 if test $gl_cv_header_langinfo_altmon = yes; then
65 HAVE_LANGINFO_ALTMON=1 54 HAVE_LANGINFO_ALTMON=1
66 fi 55 fi
56 AC_CACHE_CHECK([whether langinfo.h defines ABALTMON_1],
57 [gl_cv_header_langinfo_abaltmon],
58 [AC_COMPILE_IFELSE(
59 [AC_LANG_PROGRAM([[#include <langinfo.h>
60int a = ABALTMON_1;
61]])],
62 [gl_cv_header_langinfo_abaltmon=yes],
63 [gl_cv_header_langinfo_abaltmon=no])
64 ])
65 if test $gl_cv_header_langinfo_abaltmon = yes; then
66 HAVE_LANGINFO_ABALTMON=1
67 fi
67 AC_CACHE_CHECK([whether langinfo.h defines ERA], 68 AC_CACHE_CHECK([whether langinfo.h defines ERA],
68 [gl_cv_header_langinfo_era], 69 [gl_cv_header_langinfo_era],
69 [AC_COMPILE_IFELSE( 70 [AC_COMPILE_IFELSE(
@@ -76,27 +77,14 @@ int a = ERA;
76 if test $gl_cv_header_langinfo_era = yes; then 77 if test $gl_cv_header_langinfo_era = yes; then
77 HAVE_LANGINFO_ERA=1 78 HAVE_LANGINFO_ERA=1
78 fi 79 fi
79 AC_CACHE_CHECK([whether langinfo.h defines YESEXPR],
80 [gl_cv_header_langinfo_yesexpr],
81 [AC_COMPILE_IFELSE(
82 [AC_LANG_PROGRAM([[#include <langinfo.h>
83int a = YESEXPR;
84]])],
85 [gl_cv_header_langinfo_yesexpr=yes],
86 [gl_cv_header_langinfo_yesexpr=no])
87 ])
88 if test $gl_cv_header_langinfo_yesexpr = yes; then
89 HAVE_LANGINFO_YESEXPR=1
90 fi
91 else 80 else
92 HAVE_LANGINFO_H=0 81 HAVE_LANGINFO_H=0
93 fi 82 fi
94 AC_SUBST([HAVE_LANGINFO_H]) 83 AC_SUBST([HAVE_LANGINFO_H])
95 AC_SUBST([HAVE_LANGINFO_CODESET]) 84 AC_SUBST([HAVE_LANGINFO_CODESET])
96 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
97 AC_SUBST([HAVE_LANGINFO_ALTMON]) 85 AC_SUBST([HAVE_LANGINFO_ALTMON])
86 AC_SUBST([HAVE_LANGINFO_ABALTMON])
98 AC_SUBST([HAVE_LANGINFO_ERA]) 87 AC_SUBST([HAVE_LANGINFO_ERA])
99 AC_SUBST([HAVE_LANGINFO_YESEXPR])
100 88
101 dnl Check for declarations of anything we want to poison if the 89 dnl Check for declarations of anything we want to poison if the
102 dnl corresponding gnulib module is not in use. 90 dnl corresponding gnulib module is not in use.
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
index 7fb81b86..3134f336 100644
--- a/gl/m4/largefile.m4
+++ b/gl/m4/largefile.m4
@@ -1,16 +1,19 @@
1# largefile.m4
2# serial 4
3dnl Copyright 1992-1996, 1998-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
1# Enable large files on systems where this is not the default. 9# Enable large files on systems where this is not the default.
2# Enable support for files on Linux file systems with 64-bit inode numbers. 10# Enable support for files on Linux file systems with 64-bit inode numbers.
3 11
4# Copyright 1992-1996, 1998-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO: 12# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO:
10# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this 13# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this
11# setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko 14# setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko
12# and ftello in C++ mode as well. 15# and ftello in C++ mode as well.
13# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038. 16# This problem occurs in Autoconf 2.71 and earlier, which lack AC_SYS_YEAR2038.
14AC_DEFUN([gl_SET_LARGEFILE_SOURCE], 17AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
15 m4_ifndef([AC_SYS_YEAR2038], [[ 18 m4_ifndef([AC_SYS_YEAR2038], [[
16 AC_REQUIRE([AC_CANONICAL_HOST]) 19 AC_REQUIRE([AC_CANONICAL_HOST])
@@ -24,29 +27,20 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
24 ]]) 27 ]])
25) 28)
26 29
27# Work around a problem in autoconf <= 2.69: 30dnl Remove AC_SYS_YEAR2038_RECOMMENDED if unpatched Autoconf 2.72 or earlier.
28# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, 31dnl Autoconf 2.72 still uses -n32, which is not a C preprocessor option,
29# or configures them incorrectly in some cases. 32dnl and which was useful only on IRIX which is no longer supported.
30m4_version_prereq([2.70], [], [ 33dnl This should be fixed in Autoconf 2.73.
31 34m4_ifdef([AC_SYS_YEAR2038_RECOMMENDED],
32# _AC_SYS_LARGEFILE_TEST_INCLUDES 35 [m4_bmatch(m4_ifdef([_AC_SYS_LARGEFILE_OPTIONS],
33# ------------------------------- 36 [m4_defn([_AC_SYS_LARGEFILE_OPTIONS])],
34m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], 37 ["-n32"]),
35[#include <sys/types.h> 38 ["-n32"],
36 /* Check that off_t can represent 2**63 - 1 correctly. 39 [m4_undefine([AC_SYS_YEAR2038_RECOMMENDED])])])
37 We can't simply define LARGE_OFF_T to be 9223372036854775807,
38 since some C++ compilers masquerading as C compilers
39 incorrectly reject 9223372036854775807. */
40#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
41 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
42 && LARGE_OFF_T % 2147483647 == 1)
43 ? 1 : -1]];[]dnl
44])
45])# m4_version_prereq 2.70
46 40
47# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier. 41m4_ifndef([AC_SYS_YEAR2038_RECOMMENDED], [
48# This code is taken from Autoconf master. 42# Fix up AC_SYS_YEAR2038_RECOMMENDED and related macros, even if
49m4_ifndef([AC_SYS_YEAR2038], [ 43# unpatched Autoconf 2.72 or earlier. This code is taken from Autoconf master.
50 44
51# _AC_SYS_YEAR2038_TEST_CODE 45# _AC_SYS_YEAR2038_TEST_CODE
52# -------------------------- 46# --------------------------
@@ -78,8 +72,8 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
78 dnl 32-bit MinGW (misconfiguration) 72 dnl 32-bit MinGW (misconfiguration)
79)) 73))
80 74
81# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED]) 75# _AC_SYS_YEAR2038_PROBE
82# ----------------------------------------- 76# ----------------------
83# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent 77# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent
84# time points more than 2**31 - 1 seconds after the epoch (dates after 78# time points more than 2**31 - 1 seconds after the epoch (dates after
85# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts 79# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
@@ -92,13 +86,10 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
92# AC_TRY_RUN. Note also that some systems only support large time_t 86# AC_TRY_RUN. Note also that some systems only support large time_t
93# together with large off_t. 87# together with large off_t.
94# 88#
95# If support is not detected, the behavior depends on which of the
96# top-level AC_SYS_YEAR2038 macros was used (see below).
97#
98# If you change this macro you may also need to change 89# If you change this macro you may also need to change
99# _AC_SYS_YEAR2038_OPTIONS. 90# _AC_SYS_YEAR2038_OPTIONS.
100AC_DEFUN([_AC_SYS_YEAR2038_PROBE], 91AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
101[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038], 92[AC_CACHE_CHECK([for $CC option to support timestamps after 2038],
102 [ac_cv_sys_year2038_opts], 93 [ac_cv_sys_year2038_opts],
103 [ac_save_CPPFLAGS="$CPPFLAGS" 94 [ac_save_CPPFLAGS="$CPPFLAGS"
104 ac_opt_found=no 95 ac_opt_found=no
@@ -117,40 +108,20 @@ ac_have_year2038=yes
117AS_CASE([$ac_cv_sys_year2038_opts], 108AS_CASE([$ac_cv_sys_year2038_opts],
118 ["none needed"], [], 109 ["none needed"], [],
119 ["support not detected"], 110 ["support not detected"],
120 [ac_have_year2038=no 111 [ac_have_year2038=no],
121 AS_CASE([$enable_year2038],
122 [yes],
123 [# If we're not cross compiling and 'touch' works with a large
124 # timestamp, then we can presume the system supports wider time_t
125 # *somehow* and we just weren't able to detect it. One common
126 # case that we deliberately *don't* probe for is a system that
127 # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
128 # wide time_t. (It would be inappropriate for us to override an
129 # intentional use of -m32.) Error out, demanding use of
130 # --disable-year2038 if this is intentional.
131 AS_IF([test $cross_compiling = no],
132 [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
133 [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
134 [*'Feb 7 2106'* | *'Feb 7 17:10'*],
135 [AC_MSG_FAILURE(m4_text_wrap(
136 [this system appears to support timestamps after January 2038,
137 but no mechanism for enabling wide 'time_t' was detected.
138 Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
139 To proceed with 32-bit time_t, configure with '--disable-year2038'.],
140 [], [], [55]))])])])])],
141 112
142 ["-D_TIME_BITS=64"], 113 ["-D_TIME_BITS=64"],
143 [AC_DEFINE([_TIME_BITS], [64], 114 [AC_DEFINE([_TIME_BITS], [64],
144 [Number of bits in time_t, on hosts where this is settable.])], 115 [Number of bits in time_t, on hosts where this is settable.])],
145 116
146 ["-D__MINGW_USE_VC2005_COMPAT=1"], 117 ["-D__MINGW_USE_VC2005_COMPAT"],
147 [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1], 118 [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
148 [Define to 1 on platforms where this makes time_t a 64-bit type.])], 119 [Define to 1 on platforms where this makes time_t a 64-bit type.])],
149 120
150 ["-U_USE_32_BIT_TIME_T"*], 121 ["-U_USE_32_BIT_TIME_T"*],
151 [AC_MSG_FAILURE(m4_text_wrap( 122 [AC_MSG_FAILURE(m4_text_wrap(
152 [the 'time_t' type is currently forced to be 32-bit. 123 [the 'time_t' type is currently forced to be 32-bit.
153 It will stop working after January 2038. 124 It will stop working after mid-January 2038.
154 Remove _USE_32BIT_TIME_T from the compiler flags.], 125 Remove _USE_32BIT_TIME_T from the compiler flags.],
155 [], [], [55]))], 126 [], [], [55]))],
156 127
@@ -160,12 +131,11 @@ AS_CASE([$ac_cv_sys_year2038_opts],
160 131
161# _AC_SYS_YEAR2038_ENABLE 132# _AC_SYS_YEAR2038_ENABLE
162# ----------------------- 133# -----------------------
163# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
164# Depending on which of the YEAR2038 macros was used, add either an 134# Depending on which of the YEAR2038 macros was used, add either an
165# --enable-year2038, or a --disable-year2038, or no option at all to 135# --enable-year2038 or a --disable-year2038 to
166# the configure script. Note that this is expanded very late and 136# the configure script. This is expanded very late and
167# therefore there cannot be any code in the AC_ARG_ENABLE. The 137# therefore there cannot be any code in the AC_ARG_ENABLE. The
168# default value for enable_year2038 is emitted unconditionally 138# default value for 'enable_year2038' is emitted unconditionally
169# because the generated code always looks at this variable. 139# because the generated code always looks at this variable.
170m4_define([_AC_SYS_YEAR2038_ENABLE], 140m4_define([_AC_SYS_YEAR2038_ENABLE],
171[m4_divert_text([DEFAULTS], 141[m4_divert_text([DEFAULTS],
@@ -175,50 +145,70 @@ m4_define([_AC_SYS_YEAR2038_ENABLE],
175[AC_ARG_ENABLE([year2038], 145[AC_ARG_ENABLE([year2038],
176 m4_provide_if([AC_SYS_YEAR2038], 146 m4_provide_if([AC_SYS_YEAR2038],
177 [AS_HELP_STRING([--disable-year2038], 147 [AS_HELP_STRING([--disable-year2038],
178 [do not support timestamps after 2038])], 148 [don't support timestamps after 2038])],
179 [AS_HELP_STRING([--enable-year2038], 149 [AS_HELP_STRING([--enable-year2038],
180 [support timestamps after 2038])]))]) 150 [support timestamps after 2038])]))])
181 151
182# _AC_SYS_YEAR2038_OPT_IN
183# -----------------------
184# If the --enable-year2038 option is given to configure, attempt to
185# detect and activate support for large time_t on 32-bit systems.
186# This macro is automatically invoked by AC_SYS_LARGEFILE when large
187# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE
188# to avoid a dependency loop, and is therefore unsafe to expose as a
189# documented macro.
190AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
191[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
192 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
193 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
194])])
195
196# AC_SYS_YEAR2038 152# AC_SYS_YEAR2038
197# --------------- 153# ---------------
198# Attempt to detect and activate support for large time_t. 154# Attempt to detect and activate support for large time_t.
199# On systems where time_t is not always 64 bits, this probe can be 155# On systems where time_t is not always 64 bits, this probe can be
200# skipped by passing the --disable-year2038 option to configure. 156# skipped by passing the --disable-year2038 option to configure.
201AC_DEFUN([AC_SYS_YEAR2038], 157AC_DEFUN([AC_SYS_YEAR2038],
202[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl 158[AC_REQUIRE([AC_SYS_LARGEFILE])dnl
203[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl 159AS_IF([test "$enable_year2038,$ac_have_year2038,$cross_compiling" = yes,no,no],
204 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE]) 160 [# If we're not cross compiling and 'touch' works with a large
205 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE]) 161 # timestamp, then we can presume the system supports wider time_t
206])]) 162 # *somehow* and we just weren't able to detect it. One common
163 # case that we deliberately *don't* probe for is a system that
164 # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
165 # wide time_t. (It would be inappropriate for us to override an
166 # intentional use of -m32.) Error out, demanding use of
167 # --disable-year2038 if this is intentional.
168 AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
169 [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
170 [*'Feb 7 2106'* | *'Feb 7 17:10'*],
171 [AC_MSG_FAILURE(m4_text_wrap(
172 [this system appears to support timestamps after mid-January 2038,
173 but no mechanism for enabling wide 'time_t' was detected.
174 Did you mean to build a 64-bit binary? (E.g., 'CC="${CC} -m64"'.)
175 To proceed with 32-bit time_t, configure with '--disable-year2038'.],
176 [], [], [55]))])])])])
177
178# AC_SYS_YEAR2038_RECOMMENDED
179# ---------------------------
180# Same as AC_SYS_YEAR2038, but recommend support for large time_t.
181# If we cannot find any way to make time_t capable of representing
182# values larger than 2**31 - 1, error out unless --disable-year2038 is given.
183AC_DEFUN([AC_SYS_YEAR2038_RECOMMENDED],
184[AC_REQUIRE([AC_SYS_YEAR2038])dnl
185AS_IF([test "$enable_year2038,$ac_have_year2038" = yes,no],
186 [AC_MSG_FAILURE(m4_text_wrap(
187 [could not enable timestamps after mid-January 2038.
188 This package recommends support for these later timestamps.
189 However, to proceed with signed 32-bit time_t even though it
190 will fail then, configure with '--disable-year2038'.],
191 [], [], [55]))])])
207 192
208# _AC_SYS_LARGEFILE_TEST_CODE 193# _AC_SYS_LARGEFILE_TEST_CODE
209# --------------------------- 194# ---------------------------
210# C code used to probe for large file support. 195# C code used to probe for large file support.
211m4_define([_AC_SYS_LARGEFILE_TEST_CODE], 196m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
212[@%:@include <sys/types.h> 197[@%:@include <sys/types.h>
213 /* Check that off_t can represent 2**63 - 1 correctly. 198@%:@ifndef FTYPE
214 We can't simply define LARGE_OFF_T to be 9223372036854775807, 199@%:@ define FTYPE off_t
200@%:@endif
201 /* Check that FTYPE can represent 2**63 - 1 correctly.
202 We can't simply define LARGE_FTYPE to be 9223372036854775807,
215 since some C++ compilers masquerading as C compilers 203 since some C++ compilers masquerading as C compilers
216 incorrectly reject 9223372036854775807. */ 204 incorrectly reject 9223372036854775807. */
217@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) 205@%:@define LARGE_FTYPE (((FTYPE) 1 << 31 << 31) - 1 + ((FTYPE) 1 << 31 << 31))
218 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 206 int FTYPE_is_large[[(LARGE_FTYPE % 2147483629 == 721
219 && LARGE_OFF_T % 2147483647 == 1) 207 && LARGE_FTYPE % 2147483647 == 1)
220 ? 1 : -1]];[]dnl 208 ? 1 : -1]];[]dnl
221]) 209])
210# Defined by Autoconf 2.71 and circa 2022 Gnulib unwisely depended on it.
211m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], [_AC_SYS_LARGEFILE_TEST_CODE])
222 212
223# _AC_SYS_LARGEFILE_OPTIONS 213# _AC_SYS_LARGEFILE_OPTIONS
224# ------------------------- 214# -------------------------
@@ -228,8 +218,7 @@ m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
228m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize( 218m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
229 ["none needed"] dnl Most current systems 219 ["none needed"] dnl Most current systems
230 ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec 220 ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec
231 ["-D_LARGE_FILES=1"] dnl AIX (which versions?) 221 ["-D_LARGE_FILES=1"] dnl 32-bit AIX 4.2.1+, 32-bit z/OS
232 ["-n32"] dnl Irix 6.2 w/ SGI compiler
233)) 222))
234 223
235# _AC_SYS_LARGEFILE_PROBE 224# _AC_SYS_LARGEFILE_PROBE
@@ -246,24 +235,43 @@ m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
246# If you change this macro you may also need to change 235# If you change this macro you may also need to change
247# _AC_SYS_LARGEFILE_OPTIONS. 236# _AC_SYS_LARGEFILE_OPTIONS.
248AC_DEFUN([_AC_SYS_LARGEFILE_PROBE], 237AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
249[AC_CACHE_CHECK([for $CC option to enable large file support], 238[AC_CACHE_CHECK([for $CC option to support large files],
250 [ac_cv_sys_largefile_opts], 239 [ac_cv_sys_largefile_opts],
251 [ac_save_CC="$CC" 240 [ac_save_CPPFLAGS=$CPPFLAGS
252 ac_opt_found=no 241 ac_opt_found=no
253 for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do 242 for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
254 AS_IF([test x"$ac_opt" != x"none needed"], 243 AS_IF([test x"$ac_opt" != x"none needed"],
255 [CC="$ac_save_CC $ac_opt"]) 244 [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])], 245 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
257 [ac_cv_sys_largefile_opts="$ac_opt" 246 [AS_IF([test x"$ac_opt" = x"none needed"],
247 [# GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t.
248 CPPFLAGS="$CPPFLAGS -DFTYPE=ino_t"
249 AC_COMPILE_IFELSE([], [],
250 [CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
251 AC_COMPILE_IFELSE([], [ac_opt='-D_FILE_OFFSET_BITS=64'])])])
252 ac_cv_sys_largefile_opts=$ac_opt
258 ac_opt_found=yes]) 253 ac_opt_found=yes])
259 test $ac_opt_found = no || break 254 test $ac_opt_found = no || break
260 done 255 done
261 CC="$ac_save_CC" 256 CPPFLAGS=$ac_save_CPPFLAGS
257 dnl Gnulib implements large file support for native Windows, based on the
258 dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE.
259 m4_ifdef([gl_LARGEFILE], [
260 AC_REQUIRE([AC_CANONICAL_HOST])
261 if test $ac_opt_found != yes; then
262 AS_CASE([$host_os],
263 [mingw* | windows*],
264 [ac_cv_sys_largefile_opts="supported through gnulib"
265 ac_opt_found=yes]
266 )
267 fi
268 ])
262 test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"]) 269 test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
263 270
264ac_have_largefile=yes 271ac_have_largefile=yes
265AS_CASE([$ac_cv_sys_largefile_opts], 272AS_CASE([$ac_cv_sys_largefile_opts],
266 ["none needed"], [], 273 ["none needed"], [],
274 ["supported through gnulib"], [],
267 ["support not detected"], 275 ["support not detected"],
268 [ac_have_largefile=no], 276 [ac_have_largefile=no],
269 277
@@ -275,45 +283,29 @@ AS_CASE([$ac_cv_sys_largefile_opts],
275 [AC_DEFINE([_LARGE_FILES], [1], 283 [AC_DEFINE([_LARGE_FILES], [1],
276 [Define to 1 on platforms where this makes off_t a 64-bit type.])], 284 [Define to 1 on platforms where this makes off_t a 64-bit type.])],
277 285
278 ["-n32"],
279 [CC="$CC -n32"],
280
281 [AC_MSG_ERROR( 286 [AC_MSG_ERROR(
282 [internal error: bad value for \$ac_cv_sys_largefile_opts])]) 287 [internal error: bad value for \$ac_cv_sys_largefile_opts])])
283 288
284_AC_SYS_YEAR2038_OPT_IN 289AS_IF([test "$enable_year2038" != no],
285]) 290 [_AC_SYS_YEAR2038_PROBE])
286 291AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])])
287# _AC_SYS_LARGEFILE_ENABLE
288# ------------------------
289# Subroutine of AC_SYS_LARGEFILE. Note that this
290# is expanded very late and therefore there cannot be any code in the
291# AC_ARG_ENABLE. The default value for enable_largefile is emitted
292# unconditionally because the generated shell code always looks at
293# this variable.
294m4_define([_AC_SYS_LARGEFILE_ENABLE],
295[m4_divert_text([DEFAULTS],
296 enable_largefile=yes)]dnl
297[AC_ARG_ENABLE([largefile],
298 [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])
299 292
300# AC_SYS_LARGEFILE 293# AC_SYS_LARGEFILE
301# ---------------- 294# ----------------
302# By default, many hosts won't let programs access large files; 295# By default, many hosts won't let programs access large files;
303# one must use special compiler options to get large-file access to work. 296# one must use special compiler options to get large-file access to work.
304# For more details about this brain damage please see: 297# For more details about this brain damage please see:
305# http://www.unix.org/version2/whatsnew/lfs20mar.html 298# https://www.unix.org/version2/whatsnew/lfs20mar.html
306# Additionally, on Linux file systems with 64-bit inodes a file that happens 299# Additionally, on Linux file systems with 64-bit inodes a file that happens
307# to have a 64-bit inode number cannot be accessed by 32-bit applications on 300# to have a 64-bit inode number cannot be accessed by 32-bit applications on
308# Linux x86/x86_64. This can occur with file systems such as XFS and NFS. 301# Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
309# This macro allows configuration to continue if the system doesn't support
310# large files.
311AC_DEFUN([AC_SYS_LARGEFILE], 302AC_DEFUN([AC_SYS_LARGEFILE],
312[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl 303[AC_ARG_ENABLE([largefile],
313 AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE]) 304 [AS_HELP_STRING([--disable-largefile],
314 AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE]) 305 [omit support for large files])])dnl
315])]) 306AS_IF([test "$enable_largefile,$enable_year2038" != no,no],
316])# m4_ifndef AC_SYS_YEAR2038 307 [_AC_SYS_LARGEFILE_PROBE])])
308])# m4_ifndef AC_SYS_YEAR2038_RECOMMENDED
317 309
318# Enable large files on systems where this is implemented by Gnulib, not by the 310# Enable large files on systems where this is implemented by Gnulib, not by the
319# system headers. 311# system headers.
@@ -323,7 +315,7 @@ AC_DEFUN([gl_LARGEFILE],
323[ 315[
324 AC_REQUIRE([AC_CANONICAL_HOST]) 316 AC_REQUIRE([AC_CANONICAL_HOST])
325 case "$host_os" in 317 case "$host_os" in
326 mingw*) 318 mingw* | windows*)
327 dnl Native Windows. 319 dnl Native Windows.
328 dnl mingw64 defines off_t to a 64-bit type already, if 320 dnl mingw64 defines off_t to a 64-bit type already, if
329 dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE. 321 dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE.
@@ -363,8 +355,7 @@ AC_DEFUN([gl_LARGEFILE],
363 *) 355 *)
364 dnl Nothing to do on gnulib's side. 356 dnl Nothing to do on gnulib's side.
365 dnl A 64-bit off_t is 357 dnl A 64-bit off_t is
366 dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX, 358 dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, Cygwin,
367 dnl OSF/1, Cygwin,
368 dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on 359 dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on
369 dnl glibc, HP-UX, Solaris, 360 dnl glibc, HP-UX, Solaris,
370 dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX, 361 dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX,
diff --git a/gl/m4/libunistring-base.m4 b/gl/m4/libunistring-base.m4
new file mode 100644
index 00000000..f2f144ac
--- /dev/null
+++ b/gl/m4/libunistring-base.m4
@@ -0,0 +1,204 @@
1# libunistring-base.m4
2# serial 10
3dnl Copyright (C) 2010-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Paolo Bonzini and Bruno Haible.
10
11dnl gl_LIBUNISTRING_MODULE([VERSION], [Module])
12dnl Declares that the source files of Module should be compiled, unless we
13dnl are linking with libunistring and its version is >= the given VERSION.
14dnl Defines an automake conditional LIBUNISTRING_COMPILE_$MODULE that is
15dnl true if the source files of Module should be compiled.
16dnl This macro is to be used for public libunistring API, not for
17dnl undocumented API.
18dnl
19dnl You have to bump the VERSION argument to the next projected version
20dnl number each time you make a change that affects the behaviour of the
21dnl functions defined in Module (even if the sources of Module itself do not
22dnl change).
23dnl
24dnl This macro invocation must not occur in macros that are AC_REQUIREd.
25
26AC_DEFUN([gl_LIBUNISTRING_MODULE],
27[
28 AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE])
29 dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from
30 dnl gl_LIBUNISTRING_CORE if that macro has been run.
31 gl_CONDITIONAL(AS_TR_CPP([LIBUNISTRING_COMPILE_$2]),
32 [gl_LIBUNISTRING_VERSION_CMP([$1])])
33])
34
35dnl gl_LIBUNISTRING_MODULE_WITH_VARIABLE([VERSION], [Module])
36dnl is like gl_LIBUNISTRING_MODULE([VERSION], [Module]), except that it also
37dnl defines an AC_SUBSTed autoconf variable GNULIB_$MODULE_DLL_VARIABLE.
38dnl What's the expansion of this autoconf variable?
39dnl - When building libunistring, it expands to LIBUNISTRING_DLL_VARIABLE.
40dnl (This is necessary because this token must be present in the .h files
41dnl when the .h files get installed.)
42dnl - When building gnulib or application code it expands to
43dnl - LIBUNISTRING_DLL_VARIABLE by default,
44dnl - if the automake conditional LIBUNISTRING_COMPILE_$MODULE evaluates
45dnl to true: the value of
46dnl ${module_indicator_prefix}_GNULIB_LIBUNISTRING_DLL_VARIABLE_NAME
47dnl (which usually is empty, unless explicitly set in configure.ac).
48dnl (This is necessary because when the conditional evaluates to false,
49dnl the application code expects to use the declared variable from the
50dnl installed libunistring; it's in this case that the
51dnl LIBUNISTRING_DLL_VARIABLE macro from the installed
52dnl <unistring/woe32dll.h> must be used.)
53dnl
54dnl This macro invocation must not occur in macros that are AC_REQUIREd.
55
56AC_DEFUN([gl_LIBUNISTRING_MODULE_WITH_VARIABLE],
57[
58 gl_LIBUNISTRING_MODULE([$1], [$2])
59 m4_ifndef([gl_IN_LIBUNISTRING],
60 [if test -z "${AS_TR_CPP([LIBUNISTRING_COMPILE_$2])_TRUE}"; then
61 GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]AS_TR_CPP([$2_DLL_VARIABLE])=$GL_MODULE_INDICATOR_PREFIX[]_GNULIB_LIBUNISTRING_DLL_VARIABLE_NAME
62 fi
63 ])
64])
65
66dnl gl_LIBUNISTRING_LIBHEADER([VERSION], [HeaderFile])
67dnl Declares that HeaderFile should be created, unless we are linking
68dnl with libunistring and its version is >= the given VERSION.
69dnl HeaderFile should be relative to the lib directory and end in '.h'.
70dnl Prepares for substituting LIBUNISTRING_HEADERFILE (to HeaderFile or empty).
71dnl
72dnl When we are linking with the already installed libunistring and its version
73dnl is < VERSION, we create HeaderFile here, because we may compile functions
74dnl (via gl_LIBUNISTRING_MODULE above) that are not contained in the installed
75dnl version.
76dnl When we are linking with the already installed libunistring and its version
77dnl is > VERSION, we don't create HeaderFile here: it could cause compilation
78dnl errors in other libunistring header files if some types are missing.
79dnl
80dnl You have to bump the VERSION argument to the next projected version
81dnl number each time you make a non-comment change to the HeaderFile.
82
83AC_DEFUN([gl_LIBUNISTRING_LIBHEADER],
84[
85 AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE])
86 dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from
87 dnl gl_LIBUNISTRING_CORE if that macro has been run.
88 if gl_LIBUNISTRING_VERSION_CMP([$1]); then
89 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
90 dnl versa.
91 if test -z "$LIBUNISTRING_[]AS_TR_CPP([$2])"; then
92 LIBUNISTRING_[]AS_TR_CPP([$2])="${gl_source_base_prefix}$2"
93 fi
94 else
95 LIBUNISTRING_[]AS_TR_CPP([$2])=
96 fi
97 AC_SUBST([LIBUNISTRING_]AS_TR_CPP([$2]))
98])
99
100dnl Miscellaneous preparations/initializations.
101
102AC_DEFUN([gl_LIBUNISTRING_LIB_PREPARE],
103[
104 dnl Ensure that HAVE_LIBUNISTRING is fully determined at this point.
105 m4_ifdef([gl_LIBUNISTRING], [AC_REQUIRE([gl_LIBUNISTRING])])
106
107 AC_REQUIRE([AC_PROG_AWK])
108
109dnl Sed expressions to extract the parts of a version number.
110changequote(,)
111gl_libunistring_sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;}
112i\
1130
114q
115'
116gl_libunistring_sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;}
117i\
1180
119q
120'
121gl_libunistring_sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;}
122i\
1230
124q
125'
126changequote([,])
127
128 if test "$HAVE_LIBUNISTRING" = yes; then
129 LIBUNISTRING_VERSION_MAJOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_major"`
130 LIBUNISTRING_VERSION_MINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_minor"`
131 LIBUNISTRING_VERSION_SUBMINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_subminor"`
132 fi
133
134 dnl Determine whether <unistring/woe32dll.h> from an installed libunistring
135 dnl is available.
136 m4_ifdef([gl_IN_LIBUNISTRING],
137 [dnl In libunistring, all .h files that declare variables need to
138 dnl #include <unistring/woe32dll.h>. This references the file
139 dnl unistring/woe32dll.h in libunistring.
140 HAVE_UNISTRING_WOE32DLL_H=1
141 ],
142 [dnl In gnulib or in applications, we need a #include <unistring/woe32dll.h>
143 dnl if and only if an installed libunistring is available.
144 if test "$HAVE_LIBUNISTRING" = yes; then
145 AC_CHECK_HEADERS([unistring/woe32dll.h],
146 [HAVE_UNISTRING_WOE32DLL_H=1],
147 [HAVE_UNISTRING_WOE32DLL_H=0])
148 else
149 HAVE_UNISTRING_WOE32DLL_H=0
150 fi
151 ])
152 AC_SUBST([HAVE_UNISTRING_WOE32DLL_H])
153])
154
155dnl gl_LIBUNISTRING_VERSION_CMP([VERSION])
156dnl Expands to a shell statement that evaluates to true if LIBUNISTRING_VERSION
157dnl is less than the VERSION argument.
158AC_DEFUN([gl_LIBUNISTRING_VERSION_CMP],
159[dnl VERSION = 999.9 means to evaluates to true always, i.e. to ignore
160dnl the installed libunistring regardless of its version.
161m4_if([$1], [999.9],
162[true],
163[ { test "$HAVE_LIBUNISTRING" != yes \
164 || {
165 dnl AS_LITERAL_IF exists and works fine since autoconf-2.59 at least.
166 AS_LITERAL_IF([$1],
167 [dnl This is the optimized variant, that assumes the argument is a literal:
168 m4_pushdef([requested_version_major],
169 [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^\([0-9]*\).*], [\1]), [])])
170 m4_pushdef([requested_version_minor],
171 [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.]\([0-9]*\).*], [\1]), [$1])])
172 m4_pushdef([requested_version_subminor],
173 [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.][0-9]*[.]\([0-9]*\).*], [\1]), [$1])])
174 test $LIBUNISTRING_VERSION_MAJOR -lt requested_version_major \
175 || { test $LIBUNISTRING_VERSION_MAJOR -eq requested_version_major \
176 && { test $LIBUNISTRING_VERSION_MINOR -lt requested_version_minor \
177 || { test $LIBUNISTRING_VERSION_MINOR -eq requested_version_minor \
178 && test $LIBUNISTRING_VERSION_SUBMINOR -lt requested_version_subminor
179 }
180 }
181 }
182 m4_popdef([requested_version_subminor])
183 m4_popdef([requested_version_minor])
184 m4_popdef([requested_version_major])
185 ],
186 [dnl This is the unoptimized variant:
187 requested_version_major=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_major"`
188 requested_version_minor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_minor"`
189 requested_version_subminor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_subminor"`
190 test $LIBUNISTRING_VERSION_MAJOR -lt $requested_version_major \
191 || { test $LIBUNISTRING_VERSION_MAJOR -eq $requested_version_major \
192 && { test $LIBUNISTRING_VERSION_MINOR -lt $requested_version_minor \
193 || { test $LIBUNISTRING_VERSION_MINOR -eq $requested_version_minor \
194 && test $LIBUNISTRING_VERSION_SUBMINOR -lt $requested_version_subminor
195 }
196 }
197 }
198 ])
199 }
200 }])])
201
202dnl gl_LIBUNISTRING_ARG_OR_ZERO([ARG], [ORIG]) expands to ARG if it is not the
203dnl same as ORIG, otherwise to 0.
204m4_define([gl_LIBUNISTRING_ARG_OR_ZERO], [m4_if([$1], [$2], [0], [$1])])
diff --git a/gl/m4/limits-h.m4 b/gl/m4/limits-h.m4
index 5088fa16..048c8fab 100644
--- a/gl/m4/limits-h.m4
+++ b/gl/m4/limits-h.m4
@@ -1,9 +1,12 @@
1dnl Check whether limits.h has needed features. 1# limits-h.m4
2 2# serial 1
3dnl Copyright 2016-2023 Free Software Foundation, Inc. 3dnl Copyright 2016-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Check whether limits.h has needed features.
7 10
8dnl From Paul Eggert. 11dnl From Paul Eggert.
9 12
@@ -23,14 +26,27 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
23 int wb = WORD_BIT; 26 int wb = WORD_BIT;
24 int ullw = ULLONG_WIDTH; 27 int ullw = ULLONG_WIDTH;
25 int bw = BOOL_WIDTH; 28 int bw = BOOL_WIDTH;
29 int bm = BOOL_MAX;
30 int mblm = MB_LEN_MAX;
26 ]])], 31 ]])],
27 [gl_cv_header_limits_width=yes], 32 [gl_cv_header_limits_width=yes],
28 [gl_cv_header_limits_width=no])]) 33 [gl_cv_header_limits_width=no])])
29 if test "$gl_cv_header_limits_width" = yes; then 34 GL_GENERATE_LIMITS_H=true
30 GL_GENERATE_LIMITS_H=false 35 AS_IF([test "$gl_cv_header_limits_width" = yes],
31 else 36 [AC_CACHE_CHECK([whether limits.h has SSIZE_MAX],
32 GL_GENERATE_LIMITS_H=true 37 [gl_cv_header_limits_ssize_max],
33 fi 38 [AC_COMPILE_IFELSE(
39 [AC_LANG_SOURCE(
40 [[#include <limits.h>
41 #ifndef SSIZE_MAX
42 #error "SSIZE_MAX is not defined"
43 #endif
44 ]])],
45 [gl_cv_header_limits_ssize_max=yes],
46 [gl_cv_header_limits_ssize_max=no])])
47 if test "$gl_cv_header_limits_ssize_max" = yes; then
48 GL_GENERATE_LIMITS_H=false
49 fi])
34]) 50])
35 51
36dnl Unconditionally enables the replacement of <limits.h>. 52dnl Unconditionally enables the replacement of <limits.h>.
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index 15b6b2a5..8e2c2755 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,8 +1,10 @@
1# localcharset.m4 serial 8 1# localcharset.m4
2dnl Copyright (C) 2002, 2004, 2006, 2009-2023 Free Software Foundation, Inc. 2# serial 8
3dnl Copyright (C) 2002, 2004, 2006, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_LOCALCHARSET], 9AC_DEFUN([gl_LOCALCHARSET],
8[ 10[
diff --git a/gl/m4/locale-en.m4 b/gl/m4/locale-en.m4
new file mode 100644
index 00000000..f5e035f3
--- /dev/null
+++ b/gl/m4/locale-en.m4
@@ -0,0 +1,138 @@
1# locale-en.m4
2# serial 1
3dnl Copyright (C) 2003-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Bruno Haible.
10
11dnl Determine the name of an English (or American English) locale with
12dnl UTF-8 encoding.
13AC_DEFUN_ONCE([gt_LOCALE_EN_UTF8],
14[
15 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_REQUIRE([AM_LANGINFO_CODESET])
17 AC_CACHE_CHECK([for an english Unicode locale], [gt_cv_locale_en_utf8], [
18 case "$host_os" in
19 *-musl* | midipix*)
20 dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without
21 dnl any locale file on disk. But they are effectively equivalent to the
22 dnl C.UTF-8 locale, except for locale categories (such as LC_MESSAGES)
23 dnl for which localizations (.mo files) have been installed.
24 gt_cv_locale_en_utf8=en_US.UTF-8
25 ;;
26 *)
27 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
28#include <locale.h>
29#include <time.h>
30#if HAVE_LANGINFO_CODESET
31# include <langinfo.h>
32#endif
33#include <stdlib.h>
34#include <string.h>
35struct tm t;
36char buf[16];
37int main () {
38 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
39 imitates locale dependent behaviour by looking at the environment
40 variables, and all locales use the UTF-8 encoding. */
41#if !(defined __BEOS__ || defined __HAIKU__)
42 /* Check whether the given locale name is recognized by the system. */
43# if defined _WIN32 && !defined __CYGWIN__
44 /* On native Windows, setlocale(category, "") looks at the system settings,
45 not at the environment variables. Also, when an encoding suffix such
46 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
47 category of the locale to "C". */
48 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
49 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
50 return 1;
51# else
52 if (setlocale (LC_ALL, "") == NULL) return 1;
53# endif
54 /* Check whether nl_langinfo(CODESET) is "UTF-8" or equivalent. */
55# if HAVE_LANGINFO_CODESET
56 {
57 const char *cs = nl_langinfo (CODESET);
58 if (!(strcmp (cs, "UTF-8") == 0 || strcmp (cs, "UTF8") == 0
59 || strcmp (cs, "utf-8") == 0 || strcmp (cs, "utf8") == 0))
60 return 1;
61 }
62# endif
63# ifdef __CYGWIN__
64 /* On Cygwin, avoid locale names without encoding suffix, because the
65 locale_charset() function relies on the encoding suffix. Note that
66 LC_ALL is set on the command line. */
67 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
68# endif
69 /* Check the third month name. */
70 t.tm_year = 1975 - 1900; t.tm_mon = 3 - 1; t.tm_mday = 24;
71 if (strftime (buf, sizeof (buf), "%B", &t) < 5 || strcmp (buf, "March") != 0)
72 return 1;
73#endif
74#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
75 /* Check whether the decimal separator is a dot. */
76 if (localeconv () ->decimal_point[0] != '.') return 1;
77#endif
78 return 0;
79}
80 ]])])
81 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
82 case "$host_os" in
83 # Handle native Windows specially, because there setlocale() interprets
84 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
85 # "en" or "eng" as "English" or "English_United States.1252",
86 # "fr" or "fra" as "French" or "French_France.1252",
87 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
88 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
89 # and similar.
90 mingw* | windows*)
91 # Test for the hypothetical native Windows locale name.
92 if (LC_ALL='English_United States.65001' LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
93 gt_cv_locale_en_utf8='English_United States.65001'
94 else
95 # None found.
96 gt_cv_locale_en_utf8=none
97 fi
98 ;;
99 *)
100 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
101 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
102 # configure script would override the LC_ALL setting. Likewise for
103 # LC_CTYPE, which is also set at the beginning of the configure script.
104 # Test for the locale name with explicit encoding suffix first
105 # (this is necessary on Haiku).
106 if (LC_ALL=en_US.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
107 gt_cv_locale_en_utf8=en_US.UTF-8
108 else
109 # Test for the locale name without encoding suffix.
110 if (LC_ALL=en_US LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
111 gt_cv_locale_en_utf8=en_US
112 else
113 # Test for the Solaris 10 locale name.
114 if (LC_ALL=en.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
115 gt_cv_locale_en_utf8=en.UTF-8
116 else
117 # None found.
118 gt_cv_locale_en_utf8=none
119 fi
120 fi
121 fi
122 ;;
123 esac
124 fi
125 rm -fr conftest*
126 ;;
127 esac
128 ])
129 LOCALE_EN_UTF8="$gt_cv_locale_en_utf8"
130 case "$LOCALE_EN_UTF8" in #(
131 '' | *[[\"\$\'*@<:@]]*)
132 dnl The empty value occurs when the conftest.c program above could not
133 dnl be compiled. The other values might cause trouble with sh or make.
134 AC_MSG_WARN([invalid locale "$LOCALE_EN_UTF8"; assuming "none"])
135 LOCALE_EN_UTF8=none;;
136 esac
137 AC_SUBST([LOCALE_EN_UTF8])
138])
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
index 8c41fadf..097cefa6 100644
--- a/gl/m4/locale-fr.m4
+++ b/gl/m4/locale-fr.m4
@@ -1,13 +1,15 @@
1# locale-fr.m4 serial 20 1# locale-fr.m4
2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc. 2# serial 25
3dnl Copyright (C) 2003, 2005-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
9dnl Determine the name of a french locale with traditional encoding. 11dnl Determine the name of a french locale with traditional encoding.
10AC_DEFUN([gt_LOCALE_FR], 12AC_DEFUN_ONCE([gt_LOCALE_FR],
11[ 13[
12 AC_REQUIRE([AC_CANONICAL_HOST]) 14 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 15 AC_REQUIRE([AM_LANGINFO_CODESET])
@@ -70,8 +72,9 @@ int main () {
70 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; 72 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
71# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ 73# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
72 /* Check whether the decimal separator is a comma. 74 /* Check whether the decimal separator is a comma.
73 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 75 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale
74 are nl_langinfo(RADIXCHAR) are both ".". */ 76 and on Haiku in the fr_FR.UTF-8 locale,
77 localeconv()->decimal_point are nl_langinfo(RADIXCHAR) are both ".". */
75 if (localeconv () ->decimal_point[0] != ',') return 1; 78 if (localeconv () ->decimal_point[0] != ',') return 1;
76# endif 79# endif
77 return 0; 80 return 0;
@@ -81,12 +84,13 @@ int main () {
81 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 84 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
82 case "$host_os" in 85 case "$host_os" in
83 # Handle native Windows specially, because there setlocale() interprets 86 # Handle native Windows specially, because there setlocale() interprets
84 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", 87 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
88 # "en" or "eng" as "English" or "English_United States.1252",
85 # "fr" or "fra" as "French" or "French_France.1252", 89 # "fr" or "fra" as "French" or "French_France.1252",
86 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", 90 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
87 # "ja" as "Japanese" or "Japanese_Japan.932", 91 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
88 # and similar. 92 # and similar.
89 mingw*) 93 mingw* | windows*)
90 # Test for the native Windows locale name. 94 # Test for the native Windows locale name.
91 if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 95 if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
92 gt_cv_locale_fr=French_France.1252 96 gt_cv_locale_fr=French_France.1252
@@ -108,7 +112,7 @@ int main () {
108 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 112 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
109 gt_cv_locale_fr=fr_FR.ISO-8859-1 113 gt_cv_locale_fr=fr_FR.ISO-8859-1
110 else 114 else
111 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. 115 # Test for the AIX, FreeBSD, NetBSD, OpenBSD locale name.
112 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 116 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
113 gt_cv_locale_fr=fr_FR.ISO8859-1 117 gt_cv_locale_fr=fr_FR.ISO8859-1
114 else 118 else
@@ -116,7 +120,7 @@ int main () {
116 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 120 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
117 gt_cv_locale_fr=fr_FR.iso88591 121 gt_cv_locale_fr=fr_FR.iso88591
118 else 122 else
119 # Test for the Solaris 7 locale name. 123 # Test for the Solaris 10 locale name.
120 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 124 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
121 gt_cv_locale_fr=fr 125 gt_cv_locale_fr=fr
122 else 126 else
@@ -133,15 +137,31 @@ int main () {
133 rm -fr conftest* 137 rm -fr conftest*
134 ]) 138 ])
135 LOCALE_FR=$gt_cv_locale_fr 139 LOCALE_FR=$gt_cv_locale_fr
140 case $LOCALE_FR in #(
141 '' | *[[[:space:]\"\$\'*@<:@]]*)
142 dnl This locale name might cause trouble with sh or make.
143 AC_MSG_WARN([invalid locale "$LOCALE_FR"; assuming "none"])
144 LOCALE_FR=none;;
145 esac
136 AC_SUBST([LOCALE_FR]) 146 AC_SUBST([LOCALE_FR])
137]) 147])
138 148
139dnl Determine the name of a french locale with UTF-8 encoding. 149dnl Determine the name of a french locale with UTF-8 encoding.
140AC_DEFUN([gt_LOCALE_FR_UTF8], 150AC_DEFUN_ONCE([gt_LOCALE_FR_UTF8],
141[ 151[
152 AC_REQUIRE([AC_CANONICAL_HOST])
142 AC_REQUIRE([AM_LANGINFO_CODESET]) 153 AC_REQUIRE([AM_LANGINFO_CODESET])
143 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ 154 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
144 AC_LANG_CONFTEST([AC_LANG_SOURCE([[ 155 case "$host_os" in
156 *-musl* | midipix*)
157 dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without
158 dnl any locale file on disk. But they are effectively equivalent to the
159 dnl C.UTF-8 locale, except for locale categories (such as LC_MESSAGES)
160 dnl for which localizations (.mo files) have been installed.
161 gt_cv_locale_fr_utf8=fr_FR.UTF-8
162 ;;
163 *)
164 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
145#include <locale.h> 165#include <locale.h>
146#include <time.h> 166#include <time.h>
147#if HAVE_LANGINFO_CODESET 167#if HAVE_LANGINFO_CODESET
@@ -197,57 +217,90 @@ int main () {
197#endif 217#endif
198#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ 218#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
199 /* Check whether the decimal separator is a comma. 219 /* Check whether the decimal separator is a comma.
200 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 220 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale
201 are nl_langinfo(RADIXCHAR) are both ".". */ 221 and on Haiku in the fr_FR.UTF-8 locale,
222 localeconv()->decimal_point are nl_langinfo(RADIXCHAR) are both ".". */
202 if (localeconv () ->decimal_point[0] != ',') return 1; 223 if (localeconv () ->decimal_point[0] != ',') return 1;
203#endif 224#endif
204 return 0; 225 return 0;
205} 226}
206 ]])]) 227 ]])])
207 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 228 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
208 case "$host_os" in 229 case "$host_os" in
209 # Handle native Windows specially, because there setlocale() interprets 230 # Handle native Windows specially, because there setlocale() interprets
210 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", 231 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
211 # "fr" or "fra" as "French" or "French_France.1252", 232 # "en" or "eng" as "English" or "English_United States.1252",
212 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", 233 # "fr" or "fra" as "French" or "French_France.1252",
213 # "ja" as "Japanese" or "Japanese_Japan.932", 234 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
214 # and similar. 235 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
215 mingw*) 236 # and similar.
216 # Test for the hypothetical native Windows locale name. 237 mingw* | windows*)
217 if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 238 # Test for the hypothetical native Windows locale name.
218 gt_cv_locale_fr_utf8=French_France.65001 239 if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
219 else 240 gt_cv_locale_fr_utf8=French_France.65001
220 # None found.
221 gt_cv_locale_fr_utf8=none
222 fi
223 ;;
224 *)
225 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
226 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
227 # configure script would override the LC_ALL setting. Likewise for
228 # LC_CTYPE, which is also set at the beginning of the configure script.
229 # Test for the usual locale name.
230 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
231 gt_cv_locale_fr_utf8=fr_FR
232 else
233 # Test for the locale name with explicit encoding suffix.
234 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
235 gt_cv_locale_fr_utf8=fr_FR.UTF-8
236 else
237 # Test for the Solaris 7 locale name.
238 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
239 gt_cv_locale_fr_utf8=fr.UTF-8
240 else 241 else
241 # None found. 242 # None found.
242 gt_cv_locale_fr_utf8=none 243 gt_cv_locale_fr_utf8=none
243 fi 244 fi
244 fi 245 ;;
245 fi 246 *)
246 ;; 247 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
247 esac 248 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
248 fi 249 # configure script would override the LC_ALL setting. Likewise for
249 rm -fr conftest* 250 # LC_CTYPE, which is also set at the beginning of the configure script.
251 # Test for the usual locale name.
252 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
253 gt_cv_locale_fr_utf8=fr_FR
254 else
255 # Test for the locale name with explicit encoding suffix.
256 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
257 gt_cv_locale_fr_utf8=fr_FR.UTF-8
258 else
259 # Test for the Solaris 10 locale name.
260 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
261 gt_cv_locale_fr_utf8=fr.UTF-8
262 else
263 # None found.
264 gt_cv_locale_fr_utf8=none
265 fi
266 fi
267 fi
268 ;;
269 esac
270 fi
271 rm -fr conftest*
272 ;;
273 esac
250 ]) 274 ])
251 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 275 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
276 case $LOCALE_FR_UTF8 in #(
277 '' | *[[[:space:]\"\$\'*@<:@]]*)
278 dnl This locale name might cause trouble with sh or make.
279 AC_MSG_WARN([invalid locale "$LOCALE_FR_UTF8"; assuming "none"])
280 LOCALE_FR_UTF8=none;;
281 esac
252 AC_SUBST([LOCALE_FR_UTF8]) 282 AC_SUBST([LOCALE_FR_UTF8])
283
284 dnl Users of $LOCALE_FR_UTF8 need to know which of the locale categories they
285 dnl can rely on.
286 case "$host_os" in
287 *-musl* | midipix*)
288 dnl On musl libc, locale categories other than LC_CTYPE and LC_MESSAGES
289 dnl are effectively unimplemented.
290 LC_COLLATE_IMPLEMENTED=false
291 LC_NUMERIC_IMPLEMENTED=false
292 LC_TIME_IMPLEMENTED=false
293 LC_MONETARY_IMPLEMENTED=false
294 ;;
295 *)
296 LC_COLLATE_IMPLEMENTED=true
297 LC_NUMERIC_IMPLEMENTED=true
298 LC_TIME_IMPLEMENTED=true
299 LC_MONETARY_IMPLEMENTED=true
300 ;;
301 esac
302 AC_SUBST([LC_COLLATE_IMPLEMENTED])
303 AC_SUBST([LC_NUMERIC_IMPLEMENTED])
304 AC_SUBST([LC_TIME_IMPLEMENTED])
305 AC_SUBST([LC_MONETARY_IMPLEMENTED])
253]) 306])
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
index 25901730..ee4309ed 100644
--- a/gl/m4/locale-ja.m4
+++ b/gl/m4/locale-ja.m4
@@ -1,13 +1,15 @@
1# locale-ja.m4 serial 15 1# locale-ja.m4
2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc. 2# serial 21
3dnl Copyright (C) 2003, 2005-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
9dnl Determine the name of a japanese locale with EUC-JP encoding. 11dnl Determine the name of a japanese locale with EUC-JP encoding.
10AC_DEFUN([gt_LOCALE_JA], 12AC_DEFUN_ONCE([gt_LOCALE_JA],
11[ 13[
12 AC_REQUIRE([AC_CANONICAL_HOST]) 14 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 15 AC_REQUIRE([AM_LANGINFO_CODESET])
@@ -85,12 +87,13 @@ int main ()
85 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 87 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
86 case "$host_os" in 88 case "$host_os" in
87 # Handle native Windows specially, because there setlocale() interprets 89 # Handle native Windows specially, because there setlocale() interprets
88 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", 90 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
91 # "en" or "eng" as "English" or "English_United States.1252",
89 # "fr" or "fra" as "French" or "French_France.1252", 92 # "fr" or "fra" as "French" or "French_France.1252",
90 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", 93 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
91 # "ja" as "Japanese" or "Japanese_Japan.932", 94 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
92 # and similar. 95 # and similar.
93 mingw*) 96 mingw* | windows*)
94 # Note that on native Windows, the Japanese locale is 97 # Note that on native Windows, the Japanese locale is
95 # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we 98 # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we
96 # cannot use it here. 99 # cannot use it here.
@@ -109,15 +112,15 @@ int main ()
109 if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 112 if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
110 gt_cv_locale_ja=ja_JP.EUC-JP 113 gt_cv_locale_ja=ja_JP.EUC-JP
111 else 114 else
112 # Test for the HP-UX, OSF/1, NetBSD locale name. 115 # Test for the HP-UX, NetBSD locale name.
113 if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 116 if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
114 gt_cv_locale_ja=ja_JP.eucJP 117 gt_cv_locale_ja=ja_JP.eucJP
115 else 118 else
116 # Test for the IRIX, FreeBSD locale name. 119 # Test for the FreeBSD locale name.
117 if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 120 if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
118 gt_cv_locale_ja=ja_JP.EUC 121 gt_cv_locale_ja=ja_JP.EUC
119 else 122 else
120 # Test for the Solaris 7 locale name. 123 # Test for the Solaris 10 locale name.
121 if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 124 if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
122 gt_cv_locale_ja=ja 125 gt_cv_locale_ja=ja
123 else 126 else
@@ -139,5 +142,11 @@ int main ()
139 rm -fr conftest* 142 rm -fr conftest*
140 ]) 143 ])
141 LOCALE_JA=$gt_cv_locale_ja 144 LOCALE_JA=$gt_cv_locale_ja
145 case $LOCALE_JA in #(
146 '' | *[[[:space:]\"\$\'*@<:@]]*)
147 dnl This locale name might cause trouble with sh or make.
148 AC_MSG_WARN([invalid locale "$LOCALE_JA"; assuming "none"])
149 LOCALE_JA=none;;
150 esac
142 AC_SUBST([LOCALE_JA]) 151 AC_SUBST([LOCALE_JA])
143]) 152])
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
index b9f9eef7..98975bdd 100644
--- a/gl/m4/locale-zh.m4
+++ b/gl/m4/locale-zh.m4
@@ -1,13 +1,15 @@
1# locale-zh.m4 serial 15 1# locale-zh.m4
2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc. 2# serial 20
3dnl Copyright (C) 2003, 2005-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
9dnl Determine the name of a chinese locale with GB18030 encoding. 11dnl Determine the name of a chinese locale with GB18030 encoding.
10AC_DEFUN([gt_LOCALE_ZH_CN], 12AC_DEFUN_ONCE([gt_LOCALE_ZH_CN],
11[ 13[
12 AC_REQUIRE([AC_CANONICAL_HOST]) 14 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 15 AC_REQUIRE([AM_LANGINFO_CODESET])
@@ -21,6 +23,7 @@ AC_DEFUN([gt_LOCALE_ZH_CN],
21#endif 23#endif
22#include <stdlib.h> 24#include <stdlib.h>
23#include <string.h> 25#include <string.h>
26#include <wchar.h>
24struct tm t; 27struct tm t;
25char buf[16]; 28char buf[16];
26int main () 29int main ()
@@ -79,6 +82,19 @@ int main ()
79 single wide character. This excludes the GB2312 and GBK encodings. */ 82 single wide character. This excludes the GB2312 and GBK encodings. */
80 if (mblen ("\203\062\332\066", 5) != 4) 83 if (mblen ("\203\062\332\066", 5) != 4)
81 return 1; 84 return 1;
85 /* Check whether mbrtowc accept this character one byte at a time.
86 This excludes NetBSD 10.0. */
87 if (sizeof (wchar_t) > 2)
88 {
89 wchar_t wc;
90 mbstate_t state;
91 memset (&state, 0, sizeof (state));
92 if (!(mbrtowc (&wc, "\203", 1, &state) == (size_t)(-2)
93 && mbrtowc (&wc, "\062", 1, &state) == (size_t)(-2)
94 && mbrtowc (&wc, "\332", 1, &state) == (size_t)(-2)
95 && mbrtowc (&wc, "\066", 1, &state) == 1))
96 return 1;
97 }
82 return 0; 98 return 0;
83#endif 99#endif
84} 100}
@@ -86,12 +102,13 @@ int main ()
86 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 102 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
87 case "$host_os" in 103 case "$host_os" in
88 # Handle native Windows specially, because there setlocale() interprets 104 # Handle native Windows specially, because there setlocale() interprets
89 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", 105 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
106 # "en" or "eng" as "English" or "English_United States.1252",
90 # "fr" or "fra" as "French" or "French_France.1252", 107 # "fr" or "fra" as "French" or "French_France.1252",
91 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", 108 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
92 # "ja" as "Japanese" or "Japanese_Japan.932", 109 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
93 # and similar. 110 # and similar.
94 mingw*) 111 mingw* | windows*)
95 # Test for the hypothetical native Windows locale name. 112 # Test for the hypothetical native Windows locale name.
96 if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 113 if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
97 gt_cv_locale_zh_CN=Chinese_China.54936 114 gt_cv_locale_zh_CN=Chinese_China.54936
@@ -133,5 +150,11 @@ int main ()
133 rm -fr conftest* 150 rm -fr conftest*
134 ]) 151 ])
135 LOCALE_ZH_CN=$gt_cv_locale_zh_CN 152 LOCALE_ZH_CN=$gt_cv_locale_zh_CN
153 case $LOCALE_ZH_CN in #(
154 '' | *[[[:space:]\"\$\'*@<:@]]*)
155 dnl This locale name might cause trouble with sh or make.
156 AC_MSG_WARN([invalid locale "$LOCALE_ZH_CN"; assuming "none"])
157 LOCALE_ZH_CN=none;;
158 esac
136 AC_SUBST([LOCALE_ZH_CN]) 159 AC_SUBST([LOCALE_ZH_CN])
137]) 160])
diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4
index a33a0a46..aeda9f9d 100644
--- a/gl/m4/locale_h.m4
+++ b/gl/m4/locale_h.m4
@@ -1,8 +1,10 @@
1# locale_h.m4 serial 28 1# locale_h.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 39
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_LOCALE_H], 9AC_DEFUN_ONCE([gl_LOCALE_H],
8[ 10[
@@ -18,6 +20,26 @@ AC_DEFUN_ONCE([gl_LOCALE_H],
18 AC_REQUIRE([gl_STDDEF_H]) 20 AC_REQUIRE([gl_STDDEF_H])
19 21
20 AC_REQUIRE([gl_LOCALE_T]) 22 AC_REQUIRE([gl_LOCALE_T])
23 dnl On native Windows, there is a type '_locale_t' that can be used to
24 dnl define locale_t.
25 AC_CACHE_CHECK([whether locale.h defines _locale_t],
26 [gl_cv_header_locale_has_windows_locale_t],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[#include <locale.h>
30 _locale_t x;]],
31 [[]])],
32 [gl_cv_header_locale_has_windows_locale_t=yes],
33 [gl_cv_header_locale_has_windows_locale_t=no])
34 ])
35 if test $gl_cv_header_locale_has_windows_locale_t = yes; then
36 HAVE_WINDOWS_LOCALE_T=1
37 AC_DEFINE([HAVE_WINDOWS_LOCALE_T], [1],
38 [Define to 1 if <locale.h> defines the _locale_t type.])
39 else
40 HAVE_WINDOWS_LOCALE_T=0
41 fi
42 AC_SUBST([HAVE_WINDOWS_LOCALE_T])
21 43
22 dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv' 44 dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
23 dnl only if _LCONV_C99 is defined. 45 dnl only if _LCONV_C99 is defined.
@@ -41,8 +63,8 @@ AC_DEFUN_ONCE([gl_LOCALE_H],
41 63
42 dnl Check whether 'struct lconv' is complete. 64 dnl Check whether 'struct lconv' is complete.
43 dnl Bionic libc's 'struct lconv' is just a dummy. 65 dnl Bionic libc's 'struct lconv' is just a dummy.
44 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, 66 dnl On OpenBSD 4.9, HP-UX 11, Solaris 9, Cygwin 1.5.x, mingw, MSVC 9,
45 dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members. 67 dnl it lacks the int_p_* and int_n_* members.
46 AC_CACHE_CHECK([whether struct lconv is properly defined], 68 AC_CACHE_CHECK([whether struct lconv is properly defined],
47 [gl_cv_sys_struct_lconv_ok], 69 [gl_cv_sys_struct_lconv_ok],
48 [AC_COMPILE_IFELSE( 70 [AC_COMPILE_IFELSE(
@@ -59,7 +81,9 @@ AC_DEFUN_ONCE([gl_LOCALE_H],
59 dnl On native Windows with MSVC, merely define these member names as macros. 81 dnl On native Windows with MSVC, merely define these member names as macros.
60 dnl This avoids trouble in C++ mode. 82 dnl This avoids trouble in C++ mode.
61 case "$host_os" in 83 case "$host_os" in
62 mingw*) 84 windows*-msvc*)
85 ;;
86 mingw* | windows*)
63 AC_EGREP_CPP([Special], [ 87 AC_EGREP_CPP([Special], [
64#ifdef _MSC_VER 88#ifdef _MSC_VER
65 Special 89 Special
@@ -83,7 +107,7 @@ AC_DEFUN_ONCE([gl_LOCALE_H],
83# include <xlocale.h> 107# include <xlocale.h>
84#endif 108#endif
85 ]], 109 ]],
86 [setlocale newlocale duplocale freelocale]) 110 [setlocale newlocale duplocale freelocale getlocalename_l])
87]) 111])
88 112
89dnl Checks to determine whether the system has the locale_t type, 113dnl Checks to determine whether the system has the locale_t type,
@@ -127,6 +151,7 @@ AC_DEFUN([gl_LOCALE_T],
127 fi 151 fi
128 fi 152 fi
129 AC_SUBST([HAVE_XLOCALE_H]) 153 AC_SUBST([HAVE_XLOCALE_H])
154 AC_SUBST([HAVE_LOCALE_T])
130]) 155])
131 156
132# gl_LOCALE_MODULE_INDICATOR([modulename]) 157# gl_LOCALE_MODULE_INDICATOR([modulename])
@@ -151,8 +176,12 @@ AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV]) 176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE]) 177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL]) 178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NEWLOCALE])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE]) 180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME]) 181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREELOCALE])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOCALENAME_L])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOCALENAME_L_UNSAFE])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME_UNSAFE])
156 ]) 185 ])
157 m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS]) 186 m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
158 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 187 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
@@ -161,14 +190,16 @@ AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
161AC_DEFUN([gl_LOCALE_H_DEFAULTS], 190AC_DEFUN([gl_LOCALE_H_DEFAULTS],
162[ 191[
163 dnl Assume proper GNU behavior unless another module says otherwise. 192 dnl Assume proper GNU behavior unless another module says otherwise.
164 HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE]) 193 HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
165 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) 194 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
166 HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE]) 195 HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
167 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV]) 196 HAVE_GETLOCALENAME_L=1; AC_SUBST([HAVE_GETLOCALENAME_L])
168 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE]) 197 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
169 REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE]) 198 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
170 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) 199 REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
171 REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE]) 200 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
172 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) 201 REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
202 REPLACE_GETLOCALENAME_L=0; AC_SUBST([REPLACE_GETLOCALENAME_L])
203 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
173 LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS]) 204 LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
174]) 205])
diff --git a/gl/m4/localeconv.m4 b/gl/m4/localeconv.m4
index ae225fed..9fa31de8 100644
--- a/gl/m4/localeconv.m4
+++ b/gl/m4/localeconv.m4
@@ -1,17 +1,54 @@
1# localeconv.m4 serial 1 1# localeconv.m4
2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. 2# serial 3
3dnl Copyright (C) 2012-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_LOCALECONV], 9AC_DEFUN([gl_FUNC_LOCALECONV],
8[ 10[
9 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
10 AC_REQUIRE([gl_LOCALE_H]) 12 AC_REQUIRE([gl_LOCALE_H])
13 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 14
12 if test $REPLACE_STRUCT_LCONV = 1; then 15 if test $REPLACE_STRUCT_LCONV = 1; then
13 REPLACE_LOCALECONV=1 16 REPLACE_LOCALECONV=1
14 fi 17 fi
18 if test $REPLACE_LOCALECONV = 0; then
19 dnl Test whether fields of type 'char' are filled correctly.
20 dnl This test fails on mingw 5.0.3.
21 AC_CACHE_CHECK([whether localeconv works],
22 [gl_cv_func_localeconv_works],
23 [AC_RUN_IFELSE(
24 [AC_LANG_SOURCE([[
25 #include <locale.h>
26 #include <limits.h>
27 int main ()
28 {
29 struct lconv *l = localeconv ();
30 return l->frac_digits != CHAR_MAX && l->frac_digits < 0;
31 }
32 ]])],
33 [gl_cv_func_localeconv_works=yes],
34 [gl_cv_func_localeconv_works=no],
35 [case "$host_os" in
36 # Guess yes on glibc systems.
37 *-gnu* | gnu*) gl_cv_func_localeconv_works="guessing yes" ;;
38 # Guess yes on musl systems.
39 *-musl* | midipix*) gl_cv_func_localeconv_works="guessing yes" ;;
40 # Guess no on native Windows.
41 mingw* | windows*) gl_cv_func_localeconv_works="guessing no" ;;
42 # If we don't know, obey --enable-cross-guesses.
43 *) gl_cv_func_localeconv_works="$gl_cross_guess_normal" ;;
44 esac
45 ])
46 ])
47 case "$gl_cv_func_localeconv_works" in
48 *yes) ;;
49 *) REPLACE_LOCALECONV=1 ;;
50 esac
51 fi
15]) 52])
16 53
17# Prerequisites of lib/localeconv.c. 54# Prerequisites of lib/localeconv.c.
@@ -19,4 +56,6 @@ AC_DEFUN([gl_PREREQ_LOCALECONV],
19[ 56[
20 AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [], 57 AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [],
21 [[#include <locale.h>]]) 58 [[#include <locale.h>]])
59 AC_CHECK_MEMBERS([struct lconv.int_p_cs_precedes], [], [],
60 [[#include <locale.h>]])
22]) 61])
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index 88cf5575..7058fb30 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,8 +1,10 @@
1# lock.m4 serial 14 1# lock.m4
2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. 2# serial 15
3dnl Copyright (C) 2005-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
@@ -10,8 +12,8 @@ AC_DEFUN([gl_LOCK],
10[ 12[
11 AC_REQUIRE([gl_THREADLIB]) 13 AC_REQUIRE([gl_THREADLIB])
12 if test "$gl_threads_api" = posix; then 14 if test "$gl_threads_api" = posix; then
13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the 15 # Mac OS X 10.1 lacks the pthread_rwlock_t type and the pthread_rwlock_*
14 # pthread_rwlock_* functions. 16 # functions.
15 has_rwlock=false 17 has_rwlock=false
16 AC_CHECK_TYPE([pthread_rwlock_t], 18 AC_CHECK_TYPE([pthread_rwlock_t],
17 [has_rwlock=true 19 [has_rwlock=true
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
index fd4f1f27..342fc55b 100644
--- a/gl/m4/lseek.m4
+++ b/gl/m4/lseek.m4
@@ -1,8 +1,10 @@
1# lseek.m4 serial 12 1# lseek.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 15
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_LSEEK], 9AC_DEFUN([gl_FUNC_LSEEK],
8[ 10[
@@ -13,13 +15,15 @@ AC_DEFUN([gl_FUNC_LSEEK],
13 AC_CHECK_HEADERS_ONCE([unistd.h]) 15 AC_CHECK_HEADERS_ONCE([unistd.h])
14 AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe], 16 AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
15 [case "$host_os" in 17 [case "$host_os" in
16 mingw*) 18 mingw* | windows*)
17 dnl Native Windows. 19 dnl Native Windows.
18 dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or 20 dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or
19 dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT) 21 dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT)
20 dnl for a pipe depends on the environment: In a Cygwin 1.5 22 dnl for a pipe depends on the environment:
21 dnl environment it succeeds (wrong); in a Cygwin 1.7 environment 23 dnl In a Cygwin 1.5 environment it succeeds (wrong);
22 dnl it fails with a wrong errno value. 24 dnl in a Cygwin 1.7 environment it fails with a wrong errno value;
25 dnl in a Cygwin 2.9.0 environment it fails correctly;
26 dnl in a Cygwin 3.4.6 environment it succeeds again (wrong).
23 gl_cv_func_lseek_pipe=no 27 gl_cv_func_lseek_pipe=no
24 ;; 28 ;;
25 *) 29 *)
@@ -70,9 +74,29 @@ AC_DEFUN([gl_FUNC_LSEEK],
70 REPLACE_LSEEK=1 74 REPLACE_LSEEK=1
71 fi 75 fi
72 76
73 dnl macOS SEEK_DATA is incompatible with other platforms. 77 AS_IF([test $REPLACE_LSEEK = 0],
74 case $host_os in 78 [AC_CACHE_CHECK([whether SEEK_DATA works but is incompatible with GNU],
75 darwin*) 79 [gl_cv_func_lseek_works_but_incompatible],
76 REPLACE_LSEEK=1;; 80 [AC_PREPROC_IFELSE(
77 esac 81 [AC_LANG_SOURCE(
82 dnl Use macOS "9999" to stand for a future fixed macOS version.
83 dnl See ../lib/unistd.in.h and <https://bugs.gnu.org/61386>.
84 [[#include <unistd.h>
85 #if defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
86 # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
87 # include <AvailabilityMacros.h>
88 # endif
89 # if 99990000 <= MAC_OS_X_VERSION_MIN_REQUIRED
90 # define LSEEK_WORKS_BUT_IS_INCOMPATIBLE_WITH_GNU
91 # endif
92 #endif
93 #ifndef LSEEK_WORKS_BUT_IS_INCOMPATIBLE_WITH_GNU
94 #error "No need to work around the bug"
95 #endif
96 ]])],
97 [gl_cv_func_lseek_works_but_incompatible=yes],
98 [gl_cv_func_lseek_works_but_incompatible=no])])
99 if test "$gl_cv_func_lseek_works_but_incompatible" = yes; then
100 REPLACE_LSEEK=1
101 fi])
78]) 102])
diff --git a/gl/m4/lstat.m4 b/gl/m4/lstat.m4
new file mode 100644
index 00000000..57df6fd9
--- /dev/null
+++ b/gl/m4/lstat.m4
@@ -0,0 +1,82 @@
1# lstat.m4
2# serial 36
3dnl Copyright (C) 1997-2001, 2003-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Jim Meyering.
10
11AC_DEFUN([gl_FUNC_LSTAT],
12[
13 AC_REQUIRE([AC_CANONICAL_HOST])
14 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
15 dnl If lstat does not exist, the replacement <sys/stat.h> does
16 dnl "#define lstat stat", and lstat.c is a no-op.
17 AC_CHECK_FUNCS_ONCE([lstat])
18 if test $ac_cv_func_lstat = yes; then
19 AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
20 case $host_os,$gl_cv_func_lstat_dereferences_slashed_symlink in
21 darwin* | solaris* | *no)
22 REPLACE_LSTAT=1
23 ;;
24 esac
25 else
26 HAVE_LSTAT=0
27 fi
28])
29
30# Prerequisites of lib/lstat.c.
31AC_DEFUN([gl_PREREQ_LSTAT], [:])
32
33AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
34[
35 dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it
36 dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ.
37 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
38 AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
39 [gl_cv_func_lstat_dereferences_slashed_symlink],
40 [rm -f conftest.sym conftest.file
41 echo >conftest.file
42 AC_RUN_IFELSE(
43 [AC_LANG_PROGRAM(
44 [AC_INCLUDES_DEFAULT],
45 [[struct stat sbuf;
46 if (symlink ("conftest.file", "conftest.sym") != 0)
47 return 1;
48 /* Linux will dereference the symlink and fail, as required by
49 POSIX. That is better in the sense that it means we will not
50 have to compile and use the lstat wrapper. */
51 return lstat ("conftest.sym/", &sbuf) == 0;
52 ]])],
53 [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
54 [gl_cv_func_lstat_dereferences_slashed_symlink=no],
55 [case "$host_os" in
56 linux-* | linux)
57 # Guess yes on Linux systems.
58 gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
59 midipix*)
60 # Guess yes on systems that emulate the Linux system calls.
61 gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
62 *-gnu* | gnu*)
63 # Guess yes on glibc systems.
64 gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
65 mingw* | windows*)
66 # Guess no on native Windows.
67 gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
68 *)
69 # If we don't know, obey --enable-cross-guesses.
70 gl_cv_func_lstat_dereferences_slashed_symlink="$gl_cross_guess_normal" ;;
71 esac
72 ])
73 rm -f conftest.sym conftest.file
74 ])
75 case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
76 *yes)
77 AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
78 [Define to 1 if 'lstat' dereferences a symlink specified
79 with a trailing slash.])
80 ;;
81 esac
82])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 55402924..a95e33db 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,11 +1,24 @@
1# malloc.m4 serial 28 1# malloc.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 46
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# This is adapted with modifications from upstream Autoconf here: 9m4_version_prereq([2.73], [], [
8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949 10# Modules that use this macro directly or indirectly should depend
11# on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined
12# before this macro gets invoked. This helps on AIX 7.2 and earlier
13# if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
14#
15# This is copied from upstream Autoconf here:
16# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=1f38316f6af7bf63e5e7dd187ff6456e07ad743e#n971
17# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME])
18# ------------------------------------------------------
19# If 'malloc (0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT.
20# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME,
21# which should end in "yes" or in something else (the latter is the default).
9AC_DEFUN([_AC_FUNC_MALLOC_IF], 22AC_DEFUN([_AC_FUNC_MALLOC_IF],
10[ 23[
11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles 24 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
@@ -14,55 +27,81 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
14 [AC_RUN_IFELSE( 27 [AC_RUN_IFELSE(
15 [AC_LANG_PROGRAM( 28 [AC_LANG_PROGRAM(
16 [[#include <stdlib.h> 29 [[#include <stdlib.h>
17 ]], 30 /* Use pmalloc to test; 'volatile' prevents the compiler
18 [[void *p = malloc (0); 31 from optimizing the malloc call away. */
32 void *(*volatile pmalloc) (size_t) = malloc;]],
33 [[void *p = pmalloc (0);
19 int result = !p; 34 int result = !p;
20 free (p); 35 free (p);
21 return result;]]) 36 return result;]])],
22 ],
23 [ac_cv_func_malloc_0_nonnull=yes], 37 [ac_cv_func_malloc_0_nonnull=yes],
24 [ac_cv_func_malloc_0_nonnull=no], 38 [ac_cv_func_malloc_0_nonnull=no],
25 [case "$host_os" in 39 [AS_CASE([$host_os],
26 # Guess yes on platforms where we know the result. 40 [# Guess yes on platforms where we know the result.
27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ 41 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
28 | gnu* | *-musl* | midnightbsd* \ 42 | gnu* | *-musl* | midipix* | midnightbsd* \
29 | hpux* | solaris* | cygwin* | mingw* | msys* ) 43 | hpux* | solaris* | cygwin* | mingw* | windows* | msys*],
30 ac_cv_func_malloc_0_nonnull="guessing yes" ;; 44 [ac_cv_func_malloc_0_nonnull="guessing yes"],
31 # If we don't know, obey --enable-cross-guesses. 45 [# Guess as follows if we don't know.
32 *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;; 46 ac_cv_func_malloc_0_nonnull=m4_default([$3], ["guessing no"])])])])
33 esac
34 ])
35 ])
36 AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2]) 47 AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
37])# _AC_FUNC_MALLOC_IF 48])# _AC_FUNC_MALLOC_IF
49])
50
51# gl_FUNC_MALLOC_0_NONNULL
52# ------------------------
53# If 'malloc (0)' returns nonnull define HAVE_MALLOC_0_NONNULL.
54# Also, set ac_cv_func_malloc_0_nonnull to a string that ends in
55# "yes", otherwise set it to something else. If unknown whether
56# malloc (0) works, guess as normal for cross-builds.
57AC_DEFUN([gl_FUNC_MALLOC_0_NONNULL],
58[
59 _AC_FUNC_MALLOC_IF(
60 [AC_DEFINE([HAVE_MALLOC_0_NONNULL], [1],
61 [Define to 1 if malloc (0) returns nonnull.])],
62 [],
63 ["$gl_cross_guess_normal"])
64])
38 65
39# gl_FUNC_MALLOC_GNU 66# gl_FUNC_MALLOC_GNU
40# ------------------ 67# ------------------
41# Replace malloc if it is not compatible with GNU libc. 68# Test whether malloc (0) is compatible with GNU libc.
69# Replace malloc if not.
70# Define HAVE_MALLOC_0_NONNULL if malloc (0) returns nonnull (except upon
71# out-of-memory).
72# Define HAVE_MALLOC_PTRDIFF if malloc (N) reliably fails when N exceeds
73# PTRDIFF_MAX.
42AC_DEFUN([gl_FUNC_MALLOC_GNU], 74AC_DEFUN([gl_FUNC_MALLOC_GNU],
43[ 75[
44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 76 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
45 AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) 77 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
46 REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX" 78 AC_REQUIRE([gl_FUNC_MALLOC_0_NONNULL])
47 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then 79
48 _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1]) 80 AS_CASE([$ac_cv_func_malloc_0_nonnull],
49 fi 81 [*yes],
82 [REPLACE_MALLOC_FOR_MALLOC_GNU=$REPLACE_MALLOC_FOR_MALLOC_POSIX],
83 [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
50]) 84])
51 85
52# gl_FUNC_MALLOC_PTRDIFF 86# gl_FUNC_MALLOC_PTRDIFF
53# ---------------------- 87# ----------------------
54# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX, 88# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX.
55# and replace malloc otherwise. 89# Define HAVE_MALLOC_PTRDIFF if yes.
90# Replace malloc if not.
56AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF], 91AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
57[ 92[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 93 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) 94 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
60 test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1 95 AS_IF([test "$gl_cv_malloc_ptrdiff" = yes],
96 [AC_DEFINE([HAVE_MALLOC_PTRDIFF], 1,
97 [Define to 1 if malloc-like functions do not allocate objects
98 larger than PTRDIFF_MAX bytes.])],
99 [REPLACE_MALLOC_FOR_MALLOC_POSIX=1])
61]) 100])
62 101
63# Test whether malloc, realloc, calloc refuse to create objects 102# Test whether malloc, calloc refuse to create objects
64# larger than what can be expressed in ptrdiff_t. 103# larger than what can be expressed in ptrdiff_t.
65# Set gl_cv_func_malloc_gnu to yes or no accordingly. 104# Set gl_cv_func_malloc_gnu.
66AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF], 105AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF],
67[ 106[
68 AC_CACHE_CHECK([whether malloc is ptrdiff_t safe], 107 AC_CACHE_CHECK([whether malloc is ptrdiff_t safe],
@@ -106,64 +145,84 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
106 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 145 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
107 AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF]) 146 AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF])
108 AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) 147 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
109 if test "$gl_cv_func_malloc_posix" = yes; then 148 case "$gl_cv_func_malloc_posix" in
110 AC_DEFINE([HAVE_MALLOC_POSIX], [1], 149 *yes)
111 [Define if malloc, realloc, and calloc set errno on allocation failure.]) 150 AC_DEFINE([HAVE_MALLOC_POSIX], [1],
112 else 151 [Define if malloc and calloc set errno on allocation failure.])
113 REPLACE_MALLOC_FOR_MALLOC_POSIX=1 152 ;;
114 fi 153 *)
154 REPLACE_MALLOC_FOR_MALLOC_POSIX=1
155 ;;
156 esac
115]) 157])
116 158
117# Test whether malloc, realloc, calloc set errno to ENOMEM on failure. 159# Test whether malloc, calloc set errno to ENOMEM on failure.
118# Set gl_cv_func_malloc_posix to yes or no accordingly. 160# Set gl_cv_func_malloc_posix to *yes or *no accordingly.
119AC_DEFUN([gl_CHECK_MALLOC_POSIX], 161AC_DEFUN([gl_CHECK_MALLOC_POSIX],
120[ 162[
121 AC_REQUIRE([AC_CANONICAL_HOST]) 163 AC_REQUIRE([AC_CANONICAL_HOST])
122 AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure], 164 AC_CACHE_CHECK([whether malloc, calloc set errno on failure],
123 [gl_cv_func_malloc_posix], 165 [gl_cv_func_malloc_posix],
124 [ 166 [
125 dnl It is too dangerous to try to allocate a large amount of memory: 167 dnl It is too dangerous to try to allocate a large amount of memory:
126 dnl some systems go to their knees when you do that. So assume that 168 dnl some systems go to their knees when you do that. So assume that
127 dnl all Unix implementations of the function set errno on failure, 169 dnl all Unix implementations of the function set errno on failure,
128 dnl except on those platforms where we have seen 'test-malloc-gnu', 170 dnl except on those platforms where we have seen 'test-malloc-gnu',
129 dnl 'test-realloc-gnu', 'test-calloc-gnu' fail. 171 dnl 'test-realloc-posix', 'test-calloc-gnu' fail. For platforms
172 dnl where only 'test-realloc-posix', see realloc.m4.
130 case "$host_os" in 173 case "$host_os" in
131 mingw*) 174 mingw* | windows*)
132 gl_cv_func_malloc_posix=no ;; 175 dnl Old MSVCRT from 2001 did not set errno=ENOMEM when malloc failed.
133 irix* | solaris*) 176 dnl More recent MSVCRT from 2019 does so.
134 dnl On IRIX 6.5, the three functions return NULL with errno unset 177 dnl UCRT is the successor of MSVCRT. Assume that UCRT does so as well.
135 dnl when the argument is larger than PTRDIFF_MAX. 178 AC_COMPILE_IFELSE(
136 dnl On Solaris 11.3, the three functions return NULL with errno set 179 [AC_LANG_PROGRAM(
180 [[#include <stdio.h>
181 #ifndef _UCRT
182 msvcrt yuck
183 #endif
184 ]],
185 [[]])
186 ],
187 [gl_cv_func_malloc_posix="guessing yes"],
188 [gl_cv_func_malloc_posix="guessing no"])
189 ;;
190 solaris*)
191 dnl On Solaris 11.3, the three functions might fail with errno set
137 dnl to EAGAIN, not ENOMEM, when the argument is larger than 192 dnl to EAGAIN, not ENOMEM, when the argument is larger than
138 dnl PTRDIFF_MAX. 193 dnl PTRDIFF_MAX. See:
194 dnl https://lists.gnu.org/r/bug-gnulib/2021-05/msg00052.html
139 dnl Here is a test program: 195 dnl Here is a test program:
196
140m4_divert_push([KILL]) 197m4_divert_push([KILL])
141#include <errno.h> 198#include <errno.h>
199#include <stddef.h>
142#include <stdio.h> 200#include <stdio.h>
201#include <stdint.h>
143#include <stdlib.h> 202#include <stdlib.h>
144#define ptrdiff_t long
145#ifndef PTRDIFF_MAX
146# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1))
147#endif
148
149int main ()
150{
151 void *p;
152
153 fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX);
154 203
155 errno = 0; 204#define TEST_CALL(call) \
156 p = malloc ((unsigned long) PTRDIFF_MAX + 1); 205 do { \
157 fprintf (stderr, "p=%p errno=%d\n", p, errno); 206 void *p = call; \
158 207 if (p) \
159 errno = 0; 208 fprintf (stderr, "returned %p (incorrect success)\n", p); \
160 p = calloc (PTRDIFF_MAX / 2 + 1, 2); 209 else if (errno == ENOMEM) \
161 fprintf (stderr, "p=%p errno=%d\n", p, errno); 210 perror ("correct failure"); \
162 211 else \
163 errno = 0; 212 perror ("incorrect failure (wrong errno)"); \
164 p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1); 213 free (p); \
165 fprintf (stderr, "p=%p errno=%d\n", p, errno); 214 } while (0)
166 215
216int
217main ()
218{
219 size_t big = PTRDIFF_MAX;
220 TEST_CALL (malloc (big + 1));
221 TEST_CALL (calloc (big / 2 + 1, 2));
222 TEST_CALL (realloc (NULL, big + 1));
223 void *small = malloc (1);
224 TEST_CALL (realloc (small, big + 1));
225 free (small);
167 return 0; 226 return 0;
168} 227}
169m4_divert_pop([KILL]) 228m4_divert_pop([KILL])
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
index 1d777ebe..2c0ed8ea 100644
--- a/gl/m4/malloca.m4
+++ b/gl/m4/malloca.m4
@@ -1,14 +1,16 @@
1# malloca.m4 serial 2 1# malloca.m4
2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation, 2# serial 3
3dnl Copyright (C) 2003-2004, 2006-2007, 2009-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8AC_DEFUN([gl_MALLOCA], 10AC_DEFUN([gl_MALLOCA],
9[ 11[
10 dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables 12 dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables
11 dnl @ALLOCA@ and @LTALLOCA@. 13 dnl @ALLOCA@ and @LTALLOCA@.
12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. 14 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies.
13 AC_REQUIRE([gl_EEMALLOC]) 15 AC_REQUIRE([gl_FUNC_MALLOC_GNU])
14]) 16])
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
index d2e90ff1..4cf59671 100644
--- a/gl/m4/math_h.m4
+++ b/gl/m4/math_h.m4
@@ -1,8 +1,10 @@
1# math_h.m4 serial 125 1# math_h.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 146
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_MATH_H], 9AC_DEFUN_ONCE([gl_MATH_H],
8[ 10[
@@ -42,15 +44,21 @@ AC_DEFUN_ONCE([gl_MATH_H],
42 cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf 44 cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf
43 expf expl exp2 exp2f exp2l expm1 expm1f expm1l 45 expf expl exp2 exp2f exp2l expm1 expm1f expm1l
44 fabsf fabsl floorf floorl fma fmaf fmal 46 fabsf fabsl floorf floorl fma fmaf fmal
45 fmod fmodf fmodl frexpf frexpl hypotf hypotl 47 fmod fmodf fmodl frexpf frexpl
48 getpayload getpayloadf getpayloadl
49 hypotf hypotl
46 ilogb ilogbf ilogbl 50 ilogb ilogbf ilogbl
47 ldexpf ldexpl 51 ldexpf ldexpl
48 log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l 52 log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l
49 logb logbf logbl 53 logb logbf logbl logp1 log1pf logp1l
50 modf modff modfl powf 54 modf modff modfl powf
51 remainder remainderf remainderl 55 remainder remainderf remainderl
52 rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl 56 rint rintf rintl round roundf roundl
53 tanf tanl tanhf trunc truncf truncl]) 57 setpayload setpayloadf setpayloadl
58 setpayloadsig setpayloadsigf setpayloadsigl
59 sinf sinl sinhf sqrtf sqrtl
60 tanf tanl tanhf totalorder totalorderf totalorderl totalordermag
61 totalordermagf totalordermagl trunc truncf truncl])
54]) 62])
55 63
56# gl_MATH_MODULE_INDICATOR([modulename]) 64# gl_MATH_MODULE_INDICATOR([modulename])
@@ -113,6 +121,9 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF]) 121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP]) 122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL]) 123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAYLOAD])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAYLOADF])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAYLOADL])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT]) 127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF]) 128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL]) 129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL])
@@ -120,11 +131,15 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBF]) 131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBF])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBL]) 132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBL])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE]) 133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE_NO_CXX])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF]) 135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF_NO_CXX])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN]) 137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN_NO_CXX])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF]) 139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND]) 140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL]) 141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXP])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF]) 143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL]) 144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG]) 145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG])
@@ -142,6 +157,9 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGB]) 157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGB])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF]) 158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL]) 159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGP1])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGP1F])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGP1L])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF]) 163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF]) 164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL]) 165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL])
@@ -155,7 +173,14 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND]) 173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF]) 174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL]) 175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOAD])
177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADF])
178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADL])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADSIG])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADSIGF])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETPAYLOADSIGL])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT]) 182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT_NO_CXX])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF]) 184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL]) 185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINHF]) 186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINHF])
@@ -164,6 +189,12 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF]) 189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL]) 190 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF]) 191 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF])
192 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDER])
193 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERF])
194 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERL])
195 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERMAG])
196 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERMAGF])
197 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOTALORDERMAGL])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC]) 198 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF]) 199 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL]) 200 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL])
@@ -193,14 +224,19 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
193 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF]) 224 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF])
194 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL]) 225 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL])
195 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN]) 226 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN])
227 HAVE_COPYSIGNF=1; AC_SUBST([HAVE_COPYSIGNF])
196 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL]) 228 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL])
197 HAVE_COSF=1; AC_SUBST([HAVE_COSF]) 229 HAVE_COSF=1; AC_SUBST([HAVE_COSF])
198 HAVE_COSL=1; AC_SUBST([HAVE_COSL]) 230 HAVE_COSL=1; AC_SUBST([HAVE_COSL])
199 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF]) 231 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF])
200 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF]) 232 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
201 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) 233 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
234 HAVE_EXP2=1; AC_SUBST([HAVE_EXP2])
235 HAVE_EXP2F=1; AC_SUBST([HAVE_EXP2F])
236 HAVE_EXP2L=1; AC_SUBST([HAVE_EXP2L])
202 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1]) 237 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1])
203 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F]) 238 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F])
239 HAVE_EXPM1L=1; AC_SUBST([HAVE_EXPM1L])
204 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF]) 240 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
205 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL]) 241 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL])
206 HAVE_FMA=1; AC_SUBST([HAVE_FMA]) 242 HAVE_FMA=1; AC_SUBST([HAVE_FMA])
@@ -209,6 +245,9 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
209 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) 245 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
210 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) 246 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
211 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) 247 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
248 HAVE_GETPAYLOAD=1; AC_SUBST([HAVE_GETPAYLOAD])
249 HAVE_GETPAYLOADF=1; AC_SUBST([HAVE_GETPAYLOADF])
250 HAVE_GETPAYLOADL=1; AC_SUBST([HAVE_GETPAYLOADL])
212 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) 251 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF])
213 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) 252 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL])
214 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) 253 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB])
@@ -225,15 +264,32 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
225 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) 264 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P])
226 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) 265 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF])
227 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL]) 266 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL])
267 HAVE_LOG2=1; AC_SUBST([HAVE_LOG2])
268 HAVE_LOG2F=1; AC_SUBST([HAVE_LOG2F])
269 HAVE_LOG2L=1; AC_SUBST([HAVE_LOG2L])
228 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF]) 270 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF])
229 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) 271 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL])
272 HAVE_LOGP1=1; AC_SUBST([HAVE_LOGP1])
273 HAVE_LOGP1F=1; AC_SUBST([HAVE_LOGP1F])
274 HAVE_LOGP1L=1; AC_SUBST([HAVE_LOGP1L])
230 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) 275 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
231 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) 276 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL])
232 HAVE_POWF=1; AC_SUBST([HAVE_POWF]) 277 HAVE_POWF=1; AC_SUBST([HAVE_POWF])
233 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER]) 278 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER])
234 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) 279 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF])
280 HAVE_REMAINDERL=1; AC_SUBST([HAVE_REMAINDERL])
235 HAVE_RINT=1; AC_SUBST([HAVE_RINT]) 281 HAVE_RINT=1; AC_SUBST([HAVE_RINT])
282 HAVE_RINTF=1; AC_SUBST([HAVE_RINTF])
236 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) 283 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
284 HAVE_ROUND=1; AC_SUBST([HAVE_ROUND])
285 HAVE_ROUNDF=1; AC_SUBST([HAVE_ROUNDF])
286 HAVE_ROUNDL=1; AC_SUBST([HAVE_ROUNDL])
287 HAVE_SETPAYLOAD=1; AC_SUBST([HAVE_SETPAYLOAD])
288 HAVE_SETPAYLOADF=1; AC_SUBST([HAVE_SETPAYLOADF])
289 HAVE_SETPAYLOADL=1; AC_SUBST([HAVE_SETPAYLOADL])
290 HAVE_SETPAYLOADSIG=1; AC_SUBST([HAVE_SETPAYLOADSIG])
291 HAVE_SETPAYLOADSIGF=1; AC_SUBST([HAVE_SETPAYLOADSIGF])
292 HAVE_SETPAYLOADSIGL=1; AC_SUBST([HAVE_SETPAYLOADSIGL])
237 HAVE_SINF=1; AC_SUBST([HAVE_SINF]) 293 HAVE_SINF=1; AC_SUBST([HAVE_SINF])
238 HAVE_SINL=1; AC_SUBST([HAVE_SINL]) 294 HAVE_SINL=1; AC_SUBST([HAVE_SINL])
239 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) 295 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF])
@@ -242,36 +298,26 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
242 HAVE_TANF=1; AC_SUBST([HAVE_TANF]) 298 HAVE_TANF=1; AC_SUBST([HAVE_TANF])
243 HAVE_TANL=1; AC_SUBST([HAVE_TANL]) 299 HAVE_TANL=1; AC_SUBST([HAVE_TANL])
244 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) 300 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF])
301 HAVE_TOTALORDER=1; AC_SUBST([HAVE_TOTALORDER])
302 HAVE_TOTALORDERF=1; AC_SUBST([HAVE_TOTALORDERF])
303 HAVE_TOTALORDERL=1; AC_SUBST([HAVE_TOTALORDERL])
304 HAVE_TOTALORDERMAG=1; AC_SUBST([HAVE_TOTALORDERMAG])
305 HAVE_TOTALORDERMAGF=1; AC_SUBST([HAVE_TOTALORDERMAGF])
306 HAVE_TOTALORDERMAGL=1; AC_SUBST([HAVE_TOTALORDERMAGL])
245 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) 307 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
246 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) 308 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
247 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) 309 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
248 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF])
249 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL])
250 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) 310 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF])
251 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) 311 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL])
252 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF])
253 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) 312 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL])
254 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) 313 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL])
255 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2])
256 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F])
257 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L])
258 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L])
259 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) 314 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF])
260 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) 315 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
261 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) 316 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL])
262 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) 317 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL])
263 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) 318 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL])
264 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) 319 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L])
265 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2])
266 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F])
267 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L])
268 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) 320 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
269 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER])
270 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL])
271 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF])
272 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND])
273 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF])
274 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL])
275 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) 321 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL])
276 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) 322 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL])
277 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) 323 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
@@ -309,6 +355,9 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
309 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) 355 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
310 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) 356 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
311 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) 357 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
358 REPLACE_GETPAYLOAD=0; AC_SUBST([REPLACE_GETPAYLOAD])
359 REPLACE_GETPAYLOADF=0; AC_SUBST([REPLACE_GETPAYLOADF])
360 REPLACE_GETPAYLOADL=0; AC_SUBST([REPLACE_GETPAYLOADL])
312 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) 361 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
313 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) 362 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT])
314 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) 363 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF])
@@ -319,6 +368,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
319 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) 368 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
320 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) 369 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
321 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) 370 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
371 REPLACE_LDEXP=0; AC_SUBST([REPLACE_LDEXP])
322 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) 372 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
323 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) 373 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG])
324 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) 374 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
@@ -350,10 +400,17 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
350 REPLACE_SIGNBIT_USING_BUILTINS=0; AC_SUBST([REPLACE_SIGNBIT_USING_BUILTINS]) 400 REPLACE_SIGNBIT_USING_BUILTINS=0; AC_SUBST([REPLACE_SIGNBIT_USING_BUILTINS])
351 REPLACE_SINF=0; AC_SUBST([REPLACE_SINF]) 401 REPLACE_SINF=0; AC_SUBST([REPLACE_SINF])
352 REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF]) 402 REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF])
403 REPLACE_SINL=0; AC_SUBST([REPLACE_SINL])
353 REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF]) 404 REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF])
354 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) 405 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL])
355 REPLACE_TANF=0; AC_SUBST([REPLACE_TANF]) 406 REPLACE_TANF=0; AC_SUBST([REPLACE_TANF])
356 REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF]) 407 REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF])
408 REPLACE_TOTALORDER=0; AC_SUBST([REPLACE_TOTALORDER])
409 REPLACE_TOTALORDERF=0; AC_SUBST([REPLACE_TOTALORDERF])
410 REPLACE_TOTALORDERL=0; AC_SUBST([REPLACE_TOTALORDERL])
411 REPLACE_TOTALORDERMAG=0; AC_SUBST([REPLACE_TOTALORDERMAG])
412 REPLACE_TOTALORDERMAGF=0; AC_SUBST([REPLACE_TOTALORDERMAGF])
413 REPLACE_TOTALORDERMAGL=0; AC_SUBST([REPLACE_TOTALORDERMAGL])
357 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) 414 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC])
358 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) 415 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF])
359 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) 416 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
@@ -364,7 +421,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
364# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines 421# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
365# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly. 422# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
366# The currently known platforms where this is the case are: 423# The currently known platforms where this is the case are:
367# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9. 424# Linux/HPPA, NetBSD/sparc32, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
368AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE], 425AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
369[ 426[
370 AC_CACHE_CHECK([whether long double and double are the same], 427 AC_CACHE_CHECK([whether long double and double are the same],
diff --git a/gl/m4/mbchar.m4 b/gl/m4/mbchar.m4
new file mode 100644
index 00000000..4251a84c
--- /dev/null
+++ b/gl/m4/mbchar.m4
@@ -0,0 +1,15 @@
1# mbchar.m4
2# serial 9
3dnl Copyright (C) 2005-2007, 2009-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl autoconf tests required for use of mbchar.m4
10dnl From Bruno Haible.
11
12AC_DEFUN([gl_MBCHAR],
13[
14 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
15])
diff --git a/gl/m4/mbiter.m4 b/gl/m4/mbiter.m4
new file mode 100644
index 00000000..927876bc
--- /dev/null
+++ b/gl/m4/mbiter.m4
@@ -0,0 +1,16 @@
1# mbiter.m4
2# serial 7
3dnl Copyright (C) 2005, 2008-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl autoconf tests required for use of mbiter.h
10dnl From Bruno Haible.
11
12AC_DEFUN([gl_MBITER],
13[
14 AC_REQUIRE([AC_TYPE_MBSTATE_T])
15 :
16])
diff --git a/gl/m4/mbrtoc32.m4 b/gl/m4/mbrtoc32.m4
new file mode 100644
index 00000000..d1690fb4
--- /dev/null
+++ b/gl/m4/mbrtoc32.m4
@@ -0,0 +1,326 @@
1# mbrtoc32.m4
2# serial 21
3dnl Copyright (C) 2014-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_MBRTOC32],
10[
11 AC_REQUIRE([gl_UCHAR_H_DEFAULTS])
12
13 AC_REQUIRE([AC_TYPE_MBSTATE_T])
14 dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is
15 dnl determined. It describes how our overridden mbrtowc is implemented.
16 dnl We then implement mbrtoc32 accordingly.
17 AC_REQUIRE([gl_MBSTATE_T_BROKEN])
18
19 AC_REQUIRE([gl_TYPE_CHAR32_T])
20 AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
21
22 AC_REQUIRE([gl_CHECK_FUNC_MBRTOC32])
23 if test $gl_cv_func_mbrtoc32 = no; then
24 HAVE_MBRTOC32=0
25 else
26 if test $GNULIBHEADERS_OVERRIDE_CHAR32_T = 1 || test $REPLACE_MBSTATE_T = 1; then
27 REPLACE_MBRTOC32=1
28 else
29 gl_MBRTOC32_EMPTY_INPUT
30 gl_MBRTOC32_C_LOCALE
31 gl_MBRTOC32_UTF8_LOCALE
32 case "$gl_cv_func_mbrtoc32_empty_input" in
33 *yes) ;;
34 *) AC_DEFINE([MBRTOC32_EMPTY_INPUT_BUG], [1],
35 [Define if the mbrtoc32 function does not return (size_t) -2 for empty input.])
36 REPLACE_MBRTOC32=1
37 ;;
38 esac
39 case "$gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ" in
40 *yes) ;;
41 *) AC_DEFINE([MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ], [1],
42 [Define if the mbrtoc32 function may signal encoding errors in the C locale.])
43 REPLACE_MBRTOC32=1
44 ;;
45 esac
46 case "$gl_cv_func_mbrtoc32_utf8_locale_works" in
47 *yes) ;;
48 *) AC_DEFINE([MBRTOC32_MULTIBYTE_LOCALE_BUG], [1],
49 [Define if the mbrtoc32 function does not accept the input bytes one-by-one.])
50 REPLACE_MBRTOC32=1
51 dnl Our replacement mbrtoc32 can handle UTF-8, but not GB18030.
52 LOCALE_ZH_CN=none
53 ;;
54 esac
55 fi
56 if test $HAVE_WORKING_MBRTOC32 = 0; then
57 REPLACE_MBRTOC32=1
58 fi
59 fi
60])
61
62AC_DEFUN([gl_CHECK_FUNC_MBRTOC32],
63[
64 dnl Cf. gl_CHECK_FUNCS_ANDROID
65 AC_CHECK_DECL([mbrtoc32], , ,
66 [[#ifdef __HAIKU__
67 #include <stdint.h>
68 #endif
69 #include <uchar.h>
70 ]])
71 if test $ac_cv_have_decl_mbrtoc32 = yes; then
72 dnl We can't use AC_CHECK_FUNC here, because mbrtoc32() is defined as a
73 dnl static inline function on Haiku 2020.
74 AC_CACHE_CHECK([for mbrtoc32], [gl_cv_func_mbrtoc32],
75 [AC_LINK_IFELSE(
76 [AC_LANG_PROGRAM(
77 [[#include <stdlib.h>
78 #ifdef __HAIKU__
79 #include <stdint.h>
80 #endif
81 #include <uchar.h>
82 ]],
83 [[char32_t c;
84 return mbrtoc32 (&c, "", 1, NULL) == 0;
85 ]])
86 ],
87 [gl_cv_func_mbrtoc32=yes],
88 [gl_cv_func_mbrtoc32=no])
89 ])
90 else
91 gl_cv_func_mbrtoc32=no
92 fi
93])
94
95dnl Test whether mbrtoc32 returns the correct value on empty input.
96
97AC_DEFUN([gl_MBRTOC32_EMPTY_INPUT],
98[
99 AC_REQUIRE([AC_PROG_CC])
100 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
101 AC_CACHE_CHECK([whether mbrtoc32 works on empty input],
102 [gl_cv_func_mbrtoc32_empty_input],
103 [
104 AC_RUN_IFELSE(
105 [AC_LANG_SOURCE([[
106 #ifdef __HAIKU__
107 #include <stdint.h>
108 #endif
109 #include <uchar.h>
110 static char32_t wc;
111 static mbstate_t mbs;
112 int
113 main (void)
114 {
115 return mbrtoc32 (&wc, "", 0, &mbs) != (size_t) -2;
116 }]])],
117 [gl_cv_func_mbrtoc32_empty_input=yes],
118 [gl_cv_func_mbrtoc32_empty_input=no],
119 [case "$host_os" in
120 # Guess no on glibc systems.
121 *-gnu* | gnu*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;;
122 # Guess no on Android.
123 linux*-android*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;;
124 # Guess no on native Windows.
125 mingw* | windows*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;;
126 *) gl_cv_func_mbrtoc32_empty_input="guessing yes" ;;
127 esac
128 ])
129 ])
130])
131
132dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html>
133dnl POSIX:2018 says regarding mbrtowc: "In the POSIX locale an [EILSEQ] error
134dnl cannot occur since all byte values are valid characters." It is reasonable
135dnl to expect mbrtoc32 to behave in the same way.
136
137AC_DEFUN([gl_MBRTOC32_C_LOCALE],
138[
139 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
140 AC_CACHE_CHECK([whether the C locale is free of encoding errors],
141 [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ],
142 [AC_RUN_IFELSE(
143 [AC_LANG_PROGRAM(
144 [[#include <limits.h>
145 #include <locale.h>
146 #ifdef __HAIKU__
147 #include <stdint.h>
148 #endif
149 #include <uchar.h>
150 ]], [[
151 int i;
152 char *locale = setlocale (LC_ALL, "C");
153 if (! locale)
154 return 2;
155 for (i = CHAR_MIN; i <= CHAR_MAX; i++)
156 {
157 char c = i;
158 char32_t wc;
159 mbstate_t mbs = { 0, };
160 size_t ss = mbrtoc32 (&wc, &c, 1, &mbs);
161 if (1 < ss)
162 return 3;
163 }
164 return 0;
165 ]])],
166 [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=yes],
167 [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=no],
168 [case "$host_os" in
169 # Guess yes on native Windows.
170 mingw* | windows*) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="guessing yes" ;;
171 *) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;;
172 esac
173 ])
174 ])
175])
176
177dnl Test whether mbrtoc32 works when it's fed the bytes one-by-one in an UTF-8
178dnl locale.
179
180AC_DEFUN([gl_MBRTOC32_UTF8_LOCALE],
181[
182 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
183 AC_CACHE_CHECK([whether mbrtoc32 works in an UTF-8 locale],
184 [gl_cv_func_mbrtoc32_utf8_locale_works],
185 [AC_RUN_IFELSE(
186 [AC_LANG_PROGRAM(
187 [[#include <locale.h>
188 #ifdef __HAIKU__
189 #include <stdint.h>
190 #endif
191 #include <uchar.h>
192 ]], [[
193 char *locale = setlocale (LC_ALL, "en_US.UTF-8");
194 if (locale)
195 {
196 /* This test fails on Cygwin 3.5.3. */
197 mbstate_t state = { 0, };
198 char32_t uc = 0xDEADBEEF;
199 /* \360\237\220\203 = U+0001F403 */
200 if (mbrtoc32 (&uc, "\360", 1, &state) != (size_t)-2)
201 return 1;
202 if (mbrtoc32 (&uc, "\237", 1, &state) != (size_t)-2)
203 return 2;
204 if (mbrtoc32 (&uc, "\220", 1, &state) != (size_t)-2)
205 return 3;
206 if (mbrtoc32 (&uc, "\203", 1, &state) != 1)
207 return 4;
208 if (uc != 0x0001F403)
209 return 5;
210 }
211 return 0;
212 ]])],
213 [gl_cv_func_mbrtoc32_utf8_locale_works=yes],
214 [gl_cv_func_mbrtoc32_utf8_locale_works=no],
215 [case "$host_os" in
216 # Guess no on Cygwin.
217 cygwin*) gl_cv_func_mbrtoc32_utf8_locale_works="guessing no" ;;
218 *) gl_cv_func_mbrtoc32_utf8_locale_works="$gl_cross_guess_normal" ;;
219 esac
220 ])
221 ])
222])
223
224dnl Test whether mbrtoc32 works not worse than mbrtowc.
225dnl Result is HAVE_WORKING_MBRTOC32.
226
227AC_DEFUN([gl_MBRTOC32_SANITYCHECK],
228[
229 AC_REQUIRE([AC_PROG_CC])
230 AC_REQUIRE([gl_TYPE_CHAR32_T])
231 AC_REQUIRE([gl_CHECK_FUNC_MBRTOC32])
232 AC_REQUIRE([gt_LOCALE_FR])
233 AC_REQUIRE([gt_LOCALE_ZH_CN])
234 AC_REQUIRE([AC_CANONICAL_HOST])
235 if test $GNULIBHEADERS_OVERRIDE_CHAR32_T = 1 || test $gl_cv_func_mbrtoc32 = no; then
236 HAVE_WORKING_MBRTOC32=0
237 else
238 AC_CACHE_CHECK([whether mbrtoc32 works as well as mbrtowc],
239 [gl_cv_func_mbrtoc32_sanitycheck],
240 [
241 dnl Initial guess, used when cross-compiling or when no suitable locale
242 dnl is present.
243changequote(,)dnl
244 case "$host_os" in
245 # Guess no on FreeBSD, Solaris, native Windows.
246 freebsd* | midnightbsd* | solaris* | mingw* | windows*)
247 gl_cv_func_mbrtoc32_sanitycheck="guessing no"
248 ;;
249 # Guess yes otherwise.
250 *)
251 gl_cv_func_mbrtoc32_sanitycheck="guessing yes"
252 ;;
253 esac
254changequote([,])dnl
255 if test $LOCALE_FR != none || test $LOCALE_ZH_CN != none; then
256 AC_RUN_IFELSE(
257 [AC_LANG_SOURCE([[
258#include <locale.h>
259#include <stdlib.h>
260#include <string.h>
261#include <wchar.h>
262#ifdef __HAIKU__
263 #include <stdint.h>
264#endif
265#include <uchar.h>
266int main ()
267{
268 int result = 0;
269 /* This fails on native Windows:
270 mbrtoc32 returns (size_t)-1.
271 mbrtowc returns 1 (correct). */
272 if (strcmp ("$LOCALE_FR", "none") != 0
273 && setlocale (LC_ALL, "$LOCALE_FR") != NULL)
274 {
275 mbstate_t state;
276 wchar_t wc = (wchar_t) 0xBADFACE;
277 memset (&state, '\0', sizeof (mbstate_t));
278 if (mbrtowc (&wc, "\374", 1, &state) == 1)
279 {
280 char32_t c32 = (wchar_t) 0xBADFACE;
281 memset (&state, '\0', sizeof (mbstate_t));
282 if (mbrtoc32 (&c32, "\374", 1, &state) != 1)
283 result |= 1;
284 }
285 }
286 /* This fails on FreeBSD 13.0 and Solaris 11.4:
287 mbrtoc32 returns (size_t)-2 or (size_t)-1.
288 mbrtowc returns 4 (correct). */
289 if (strcmp ("$LOCALE_ZH_CN", "none") != 0
290 && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
291 {
292 mbstate_t state;
293 wchar_t wc = (wchar_t) 0xBADFACE;
294 memset (&state, '\0', sizeof (mbstate_t));
295 if (mbrtowc (&wc, "\224\071\375\067", 4, &state) == 4)
296 {
297 char32_t c32 = (wchar_t) 0xBADFACE;
298 memset (&state, '\0', sizeof (mbstate_t));
299 if (mbrtoc32 (&c32, "\224\071\375\067", 4, &state) != 4)
300 result |= 2;
301 }
302 }
303 return result;
304}]])],
305 [gl_cv_func_mbrtoc32_sanitycheck=yes],
306 [gl_cv_func_mbrtoc32_sanitycheck=no],
307 [:])
308 fi
309 ])
310 case "$gl_cv_func_mbrtoc32_sanitycheck" in
311 *yes)
312 HAVE_WORKING_MBRTOC32=1
313 AC_DEFINE([HAVE_WORKING_MBRTOC32], [1],
314 [Define if the mbrtoc32 function basically works.])
315 ;;
316 *) HAVE_WORKING_MBRTOC32=0 ;;
317 esac
318 fi
319 AC_SUBST([HAVE_WORKING_MBRTOC32])
320])
321
322# Prerequisites of lib/mbrtoc32.c and lib/lc-charset-dispatch.c.
323AC_DEFUN([gl_PREREQ_MBRTOC32], [
324 AC_REQUIRE([gl_C32RTOMB_SANITYCHECK])
325 :
326])
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index bb393041..a49872fa 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,9 +1,11 @@
1# mbrtowc.m4 serial 38 -*- coding: utf-8 -*- 1# mbrtowc.m4
2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation, 2# serial 47
3dnl Copyright (C) 2001-2002, 2004-2005, 2008-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8AC_DEFUN([gl_FUNC_MBRTOWC], 10AC_DEFUN([gl_FUNC_MBRTOWC],
9[ 11[
@@ -31,7 +33,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
31 REPLACE_MBRTOWC=1 33 REPLACE_MBRTOWC=1
32 else 34 else
33 gl_MBRTOWC_NULL_ARG1 35 gl_MBRTOWC_NULL_ARG1
34 gl_MBRTOWC_NULL_ARG2
35 gl_MBRTOWC_RETVAL 36 gl_MBRTOWC_RETVAL
36 gl_MBRTOWC_NUL_RETVAL 37 gl_MBRTOWC_NUL_RETVAL
37 gl_MBRTOWC_STORES_INCOMPLETE 38 gl_MBRTOWC_STORES_INCOMPLETE
@@ -44,13 +45,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
44 REPLACE_MBRTOWC=1 45 REPLACE_MBRTOWC=1
45 ;; 46 ;;
46 esac 47 esac
47 case "$gl_cv_func_mbrtowc_null_arg2" in
48 *yes) ;;
49 *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
50 [Define if the mbrtowc function has the NULL string argument bug.])
51 REPLACE_MBRTOWC=1
52 ;;
53 esac
54 case "$gl_cv_func_mbrtowc_retval" in 48 case "$gl_cv_func_mbrtowc_retval" in
55 *yes) ;; 49 *yes) ;;
56 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], 50 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
@@ -91,20 +85,25 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
91 fi 85 fi
92 if test $REPLACE_MBSTATE_T = 1; then 86 if test $REPLACE_MBSTATE_T = 1; then
93 case "$host_os" in 87 case "$host_os" in
94 mingw*) LIB_MBRTOWC= ;; 88 mingw* | windows*)
89 MBRTOWC_LIB=
90 ;;
95 *) 91 *)
96 gl_WEAK_SYMBOLS 92 gl_WEAK_SYMBOLS
97 case "$gl_cv_have_weak" in 93 case "$gl_cv_have_weak" in
98 *yes) LIB_MBRTOWC= ;; 94 *yes) MBRTOWC_LIB= ;;
99 *) LIB_MBRTOWC="$LIBPTHREAD" ;; 95 *) MBRTOWC_LIB="$LIBPTHREAD" ;;
100 esac 96 esac
101 ;; 97 ;;
102 esac 98 esac
103 else 99 else
104 LIB_MBRTOWC= 100 MBRTOWC_LIB=
105 fi 101 fi
106 dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX 102 dnl MBRTOWC_LIB is expected to be '-pthread' or '-lpthread' on AIX
107 dnl with gcc or xlc, and empty otherwise. 103 dnl with gcc or xlc, and empty otherwise.
104 AC_SUBST([MBRTOWC_LIB])
105 dnl For backward compatibility.
106 LIB_MBRTOWC="$MBRTOWC_LIB"
108 AC_SUBST([LIB_MBRTOWC]) 107 AC_SUBST([LIB_MBRTOWC])
109]) 108])
110 109
@@ -114,7 +113,7 @@ dnl Result is REPLACE_MBSTATE_T.
114dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to 113dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
115dnl avoid inconsistencies. 114dnl avoid inconsistencies.
116 115
117AC_DEFUN([gl_MBSTATE_T_BROKEN], 116AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN],
118[ 117[
119 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 118 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
120 AC_REQUIRE([AC_CANONICAL_HOST]) 119 AC_REQUIRE([AC_CANONICAL_HOST])
@@ -126,7 +125,7 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN],
126 dnl to override it, even if - like on MSVC - mbsinit() is only defined as 125 dnl to override it, even if - like on MSVC - mbsinit() is only defined as
127 dnl an inline function, not as a global function. 126 dnl an inline function, not as a global function.
128 if case "$host_os" in 127 if case "$host_os" in
129 mingw*) true ;; 128 mingw* | windows*) true ;;
130 *) test $ac_cv_func_mbsinit = yes ;; 129 *) test $ac_cv_func_mbsinit = yes ;;
131 esac \ 130 esac \
132 && test $ac_cv_func_mbrtowc = yes; then 131 && test $ac_cv_func_mbrtowc = yes; then
@@ -154,7 +153,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
154[ 153[
155 AC_REQUIRE([AC_PROG_CC]) 154 AC_REQUIRE([AC_PROG_CC])
156 AC_REQUIRE([gt_LOCALE_JA]) 155 AC_REQUIRE([gt_LOCALE_JA])
157 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 156 AC_REQUIRE([gt_LOCALE_EN_UTF8])
158 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 157 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
159 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], 158 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
160 [gl_cv_func_mbrtowc_incomplete_state], 159 [gl_cv_func_mbrtowc_incomplete_state],
@@ -163,10 +162,10 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
163 dnl is present. 162 dnl is present.
164changequote(,)dnl 163changequote(,)dnl
165 case "$host_os" in 164 case "$host_os" in
166 # Guess no on AIX and OSF/1. 165 # Guess no on AIX.
167 aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; 166 aix*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
168 # Guess yes otherwise. 167 # Guess yes otherwise.
169 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; 168 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
170 esac 169 esac
171changequote([,])dnl 170changequote([,])dnl
172 if test $LOCALE_JA != none; then 171 if test $LOCALE_JA != none; then
@@ -194,7 +193,7 @@ int main ()
194 [gl_cv_func_mbrtowc_incomplete_state=no], 193 [gl_cv_func_mbrtowc_incomplete_state=no],
195 [:]) 194 [:])
196 else 195 else
197 if test $LOCALE_FR_UTF8 != none; then 196 if test "$LOCALE_EN_UTF8" != none; then
198 AC_RUN_IFELSE( 197 AC_RUN_IFELSE(
199 [AC_LANG_SOURCE([[ 198 [AC_LANG_SOURCE([[
200#include <locale.h> 199#include <locale.h>
@@ -202,7 +201,7 @@ int main ()
202#include <wchar.h> 201#include <wchar.h>
203int main () 202int main ()
204{ 203{
205 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 204 if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
206 { 205 {
207 const char input[] = "B\303\274\303\237er"; /* "Büßer" */ 206 const char input[] = "B\303\274\303\237er"; /* "Büßer" */
208 mbstate_t state; 207 mbstate_t state;
@@ -282,7 +281,7 @@ dnl Result is gl_cv_func_mbrtowc_null_arg1.
282AC_DEFUN([gl_MBRTOWC_NULL_ARG1], 281AC_DEFUN([gl_MBRTOWC_NULL_ARG1],
283[ 282[
284 AC_REQUIRE([AC_PROG_CC]) 283 AC_REQUIRE([AC_PROG_CC])
285 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 284 AC_REQUIRE([gt_LOCALE_EN_UTF8])
286 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 285 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
287 AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument], 286 AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument],
288 [gl_cv_func_mbrtowc_null_arg1], 287 [gl_cv_func_mbrtowc_null_arg1],
@@ -297,7 +296,7 @@ changequote(,)dnl
297 *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;; 296 *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
298 esac 297 esac
299changequote([,])dnl 298changequote([,])dnl
300 if test $LOCALE_FR_UTF8 != none; then 299 if test "$LOCALE_EN_UTF8" != none; then
301 AC_RUN_IFELSE( 300 AC_RUN_IFELSE(
302 [AC_LANG_SOURCE([[ 301 [AC_LANG_SOURCE([[
303#include <locale.h> 302#include <locale.h>
@@ -308,7 +307,7 @@ int main ()
308{ 307{
309 int result = 0; 308 int result = 0;
310 309
311 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 310 if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
312 { 311 {
313 char input[] = "\303\237er"; 312 char input[] = "\303\237er";
314 mbstate_t state; 313 mbstate_t state;
@@ -339,57 +338,6 @@ int main ()
339 ]) 338 ])
340]) 339])
341 340
342dnl Test whether mbrtowc supports a NULL string argument correctly.
343dnl Result is gl_cv_func_mbrtowc_null_arg2.
344
345AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
346[
347 AC_REQUIRE([AC_PROG_CC])
348 AC_REQUIRE([gt_LOCALE_FR_UTF8])
349 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
350 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
351 [gl_cv_func_mbrtowc_null_arg2],
352 [
353 dnl Initial guess, used when cross-compiling or when no suitable locale
354 dnl is present.
355changequote(,)dnl
356 case "$host_os" in
357 # Guess no on OSF/1.
358 osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
359 # Guess yes otherwise.
360 *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
361 esac
362changequote([,])dnl
363 if test $LOCALE_FR_UTF8 != none; then
364 AC_RUN_IFELSE(
365 [AC_LANG_SOURCE([[
366#include <locale.h>
367#include <string.h>
368#include <wchar.h>
369int main ()
370{
371 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
372 {
373 mbstate_t state;
374 wchar_t wc;
375 int ret;
376
377 memset (&state, '\0', sizeof (mbstate_t));
378 wc = (wchar_t) 0xBADFACE;
379 mbrtowc (&wc, NULL, 5, &state);
380 /* Check that wc was not modified. */
381 if (wc != (wchar_t) 0xBADFACE)
382 return 2;
383 }
384 return 0;
385}]])],
386 [gl_cv_func_mbrtowc_null_arg2=yes],
387 [gl_cv_func_mbrtowc_null_arg2=no],
388 [:])
389 fi
390 ])
391])
392
393dnl Test whether mbrtowc, when parsing the end of a multibyte character, 341dnl Test whether mbrtowc, when parsing the end of a multibyte character,
394dnl correctly returns the number of bytes that were needed to complete the 342dnl correctly returns the number of bytes that were needed to complete the
395dnl character (not the total number of bytes of the multibyte character). 343dnl character (not the total number of bytes of the multibyte character).
@@ -398,7 +346,7 @@ dnl Result is gl_cv_func_mbrtowc_retval.
398AC_DEFUN([gl_MBRTOWC_RETVAL], 346AC_DEFUN([gl_MBRTOWC_RETVAL],
399[ 347[
400 AC_REQUIRE([AC_PROG_CC]) 348 AC_REQUIRE([AC_PROG_CC])
401 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 349 AC_REQUIRE([gt_LOCALE_EN_UTF8])
402 AC_REQUIRE([gt_LOCALE_JA]) 350 AC_REQUIRE([gt_LOCALE_JA])
403 AC_REQUIRE([AC_CANONICAL_HOST]) 351 AC_REQUIRE([AC_CANONICAL_HOST])
404 AC_CACHE_CHECK([whether mbrtowc has a correct return value], 352 AC_CACHE_CHECK([whether mbrtowc has a correct return value],
@@ -408,14 +356,16 @@ AC_DEFUN([gl_MBRTOWC_RETVAL],
408 dnl is present. 356 dnl is present.
409changequote(,)dnl 357changequote(,)dnl
410 case "$host_os" in 358 case "$host_os" in
411 # Guess no on HP-UX, Solaris, native Windows. 359 # Guess no on HP-UX, Solaris, native Windows.
412 hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;; 360 hpux* | solaris* | mingw* | windows*)
413 # Guess yes otherwise. 361 gl_cv_func_mbrtowc_retval="guessing no" ;;
414 *) gl_cv_func_mbrtowc_retval="guessing yes" ;; 362 # Guess yes otherwise.
363 *)
364 gl_cv_func_mbrtowc_retval="guessing yes" ;;
415 esac 365 esac
416changequote([,])dnl 366changequote([,])dnl
417 if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \ 367 if test "$LOCALE_EN_UTF8" != none || test $LOCALE_JA != none \
418 || { case "$host_os" in mingw*) true;; *) false;; esac; }; then 368 || { case "$host_os" in mingw* | windows*) true;; *) false;; esac; }; then
419 AC_RUN_IFELSE( 369 AC_RUN_IFELSE(
420 [AC_LANG_SOURCE([[ 370 [AC_LANG_SOURCE([[
421#include <locale.h> 371#include <locale.h>
@@ -426,7 +376,8 @@ int main ()
426 int result = 0; 376 int result = 0;
427 int found_some_locale = 0; 377 int found_some_locale = 0;
428 /* This fails on Solaris. */ 378 /* This fails on Solaris. */
429 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 379 if (strcmp ("$LOCALE_EN_UTF8", "none") != 0
380 && setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
430 { 381 {
431 char input[] = "B\303\274\303\237er"; /* "Büßer" */ 382 char input[] = "B\303\274\303\237er"; /* "Büßer" */
432 mbstate_t state; 383 mbstate_t state;
@@ -442,7 +393,8 @@ int main ()
442 found_some_locale = 1; 393 found_some_locale = 1;
443 } 394 }
444 /* This fails on HP-UX 11.11. */ 395 /* This fails on HP-UX 11.11. */
445 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 396 if (strcmp ("$LOCALE_JA", "none") != 0
397 && setlocale (LC_ALL, "$LOCALE_JA") != NULL)
446 { 398 {
447 char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */ 399 char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
448 mbstate_t state; 400 mbstate_t state;
@@ -577,13 +529,13 @@ AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE],
577 dnl is present. 529 dnl is present.
578changequote(,)dnl 530changequote(,)dnl
579 case "$host_os" in 531 case "$host_os" in
580 # Guess yes on native Windows. 532 # Guess yes on native Windows.
581 mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;; 533 mingw* | windows*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
582 *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;; 534 *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
583 esac 535 esac
584changequote([,])dnl 536changequote([,])dnl
585 case "$host_os" in 537 case "$host_os" in
586 mingw*) 538 mingw* | windows*)
587 AC_RUN_IFELSE( 539 AC_RUN_IFELSE(
588 [AC_LANG_SOURCE([[ 540 [AC_LANG_SOURCE([[
589#include <locale.h> 541#include <locale.h>
@@ -639,8 +591,8 @@ int main ()
639 [:]) 591 [:])
640 ;; 592 ;;
641 *) 593 *)
642 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 594 AC_REQUIRE([gt_LOCALE_EN_UTF8])
643 if test $LOCALE_FR_UTF8 != none; then 595 if test "$LOCALE_EN_UTF8" != none; then
644 AC_RUN_IFELSE( 596 AC_RUN_IFELSE(
645 [AC_LANG_SOURCE([[ 597 [AC_LANG_SOURCE([[
646#include <locale.h> 598#include <locale.h>
@@ -648,7 +600,7 @@ int main ()
648#include <wchar.h> 600#include <wchar.h>
649int main () 601int main ()
650{ 602{
651 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 603 if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
652 { 604 {
653 wchar_t wc = (wchar_t) 0xBADFACE; 605 wchar_t wc = (wchar_t) 0xBADFACE;
654 mbstate_t state; 606 mbstate_t state;
@@ -677,50 +629,46 @@ AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
677 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 629 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
678 AC_CACHE_CHECK([whether mbrtowc works on empty input], 630 AC_CACHE_CHECK([whether mbrtowc works on empty input],
679 [gl_cv_func_mbrtowc_empty_input], 631 [gl_cv_func_mbrtowc_empty_input],
680 [ 632 [AC_RUN_IFELSE(
681 dnl Initial guess, used when cross-compiling or when no suitable locale 633 [AC_LANG_SOURCE([[
682 dnl is present. 634 #include <wchar.h>
683changequote(,)dnl 635 static wchar_t wc;
684 case "$host_os" in 636 static mbstate_t mbs;
685 # Guess no on AIX and glibc systems. 637 int
686 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;; 638 main (void)
687 # Guess yes on native Windows. 639 {
688 mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; 640 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
689 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; 641 }]])],
690 esac 642 [gl_cv_func_mbrtowc_empty_input=yes],
691changequote([,])dnl 643 [gl_cv_func_mbrtowc_empty_input=no],
692 AC_RUN_IFELSE( 644 [case "$host_os" in
693 [AC_LANG_SOURCE([[ 645 # Guess no on AIX and glibc systems.
694 #include <wchar.h> 646 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
695 static wchar_t wc; 647 # Guess no on Android.
696 static mbstate_t mbs; 648 linux*-android*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
697 int 649 # Guess no on native Windows.
698 main (void) 650 mingw* | windows*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
699 { 651 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
700 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2; 652 esac
701 }]])], 653 ])
702 [gl_cv_func_mbrtowc_empty_input=yes],
703 [gl_cv_func_mbrtowc_empty_input=no],
704 [:])
705 ]) 654 ])
706]) 655])
707 656
708dnl Test whether mbrtowc reports encoding errors in the C locale. 657dnl Test whether mbrtowc reports encoding errors in the C locale.
709dnl Although POSIX was never intended to allow this, the GNU C Library 658dnl Although POSIX was never intended to allow this, the GNU C Library
710dnl and other implementations do it. See: 659dnl and other implementations do it. See:
711dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 660dnl https://sourceware.org/PR19932
661dnl POSIX has now clarified it:
662dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html>
663dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte
664dnl values are valid characters."
712 665
713AC_DEFUN([gl_MBRTOWC_C_LOCALE], 666AC_DEFUN([gl_MBRTOWC_C_LOCALE],
714[ 667[
715 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 668 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
716 AC_CACHE_CHECK([whether the C locale is free of encoding errors], 669 AC_CACHE_CHECK([whether the C locale is free of encoding errors],
717 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ], 670 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ],
718 [ 671 [AC_RUN_IFELSE(
719 dnl Initial guess, used when cross-compiling or when no suitable locale
720 dnl is present.
721 gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal"
722
723 AC_RUN_IFELSE(
724 [AC_LANG_PROGRAM( 672 [AC_LANG_PROGRAM(
725 [[#include <limits.h> 673 [[#include <limits.h>
726 #include <locale.h> 674 #include <locale.h>
@@ -741,13 +689,14 @@ AC_DEFUN([gl_MBRTOWC_C_LOCALE],
741 } 689 }
742 return 0; 690 return 0;
743 ]])], 691 ]])],
744 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes], 692 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
745 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no], 693 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
746 [case "$host_os" in 694 [case "$host_os" in
747 # Guess yes on native Windows. 695 # Guess yes on native Windows.
748 mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; 696 mingw* | windows*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
749 esac 697 *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;;
750 ]) 698 esac
699 ])
751 ]) 700 ])
752]) 701])
753 702
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
index c388a8b9..757f2360 100644
--- a/gl/m4/mbsinit.m4
+++ b/gl/m4/mbsinit.m4
@@ -1,8 +1,10 @@
1# mbsinit.m4 serial 9 1# mbsinit.m4
2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. 2# serial 10
3dnl Copyright (C) 2008, 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_MBSINIT], 9AC_DEFUN([gl_FUNC_MBSINIT],
8[ 10[
@@ -32,7 +34,7 @@ AC_DEFUN([gl_FUNC_MBSINIT],
32 dnl states produced by mbrtowc() for an incomplete multibyte character 34 dnl states produced by mbrtowc() for an incomplete multibyte character
33 dnl in multibyte locales. 35 dnl in multibyte locales.
34 case "$host_os" in 36 case "$host_os" in
35 mingw*) REPLACE_MBSINIT=1 ;; 37 mingw* | windows*) REPLACE_MBSINIT=1 ;;
36 esac 38 esac
37 fi 39 fi
38 fi 40 fi
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index dcd66b96..88307d7a 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,8 +1,10 @@
1# mbstate_t.m4 serial 14 1# mbstate_t.m4
2dnl Copyright (C) 2000-2002, 2008-2023 Free Software Foundation, Inc. 2# serial 14
3dnl Copyright (C) 2000-2002, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# From Paul Eggert. 9# From Paul Eggert.
8 10
diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4
index 7823be0e..9c5887d3 100644
--- a/gl/m4/mbtowc.m4
+++ b/gl/m4/mbtowc.m4
@@ -1,16 +1,21 @@
1# mbtowc.m4 serial 3 1# mbtowc.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_MBTOWC], 9AC_DEFUN([gl_FUNC_MBTOWC],
8[ 10[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 12
11 AC_CHECK_FUNCS([mbtowc]) 13 gl_CHECK_FUNCS_ANDROID([mbtowc], [[#include <stdlib.h>]])
12 if test $ac_cv_func_mbtowc = no; then 14 if test $ac_cv_func_mbtowc = no; then
13 HAVE_MBTOWC=0 15 HAVE_MBTOWC=0
16 case "$gl_cv_onwards_func_mbtowc" in
17 future*) REPLACE_MBTOWC=1 ;;
18 esac
14 else 19 else
15 if false; then 20 if false; then
16 REPLACE_MBTOWC=1 21 REPLACE_MBTOWC=1
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index 4f1aed01..c5c74682 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,8 +1,10 @@
1# memchr.m4 serial 18 1# memchr.m4
2dnl Copyright (C) 2002-2004, 2009-2023 Free Software Foundation, Inc. 2# serial 21
3dnl Copyright (C) 2002-2004, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_FUNC_MEMCHR], 9AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
8[ 10[
@@ -19,7 +21,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
19 # https://bugzilla.redhat.com/show_bug.cgi?id=499689 21 # https://bugzilla.redhat.com/show_bug.cgi?id=499689
20 # memchr should not dereference overestimated length after a match 22 # memchr should not dereference overestimated length after a match
21 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 23 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
22 # https://sourceware.org/bugzilla/show_bug.cgi?id=10162 24 # https://sourceware.org/PR10162
23 # memchr should cast the second argument to 'unsigned char'. 25 # memchr should cast the second argument to 'unsigned char'.
24 # This bug exists in Android 4.3. 26 # This bug exists in Android 4.3.
25 # Assume that memchr works on platforms that lack mprotect. 27 # Assume that memchr works on platforms that lack mprotect.
@@ -31,31 +33,20 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
31# include <unistd.h> 33# include <unistd.h>
32# include <sys/types.h> 34# include <sys/types.h>
33# include <sys/mman.h> 35# include <sys/mman.h>
34# ifndef MAP_FILE
35# define MAP_FILE 0
36# endif
37#endif 36#endif
38]], [[ 37]], [[
39 int result = 0; 38 int result = 0;
40 char *fence = NULL; 39 char *fence = NULL;
41#if HAVE_SYS_MMAN_H && HAVE_MPROTECT 40#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
42# if HAVE_MAP_ANONYMOUS 41 {
43 const int flags = MAP_ANONYMOUS | MAP_PRIVATE; 42 long int pagesize = sysconf (_SC_PAGESIZE);
44 const int fd = -1; 43 char *two_pages =
45# else /* !HAVE_MAP_ANONYMOUS */ 44 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
46 const int flags = MAP_FILE | MAP_PRIVATE; 45 MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
47 int fd = open ("/dev/zero", O_RDONLY, 0666); 46 if (two_pages != (char *)(-1)
48 if (fd >= 0) 47 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
49# endif 48 fence = two_pages + pagesize;
50 { 49 }
51 int pagesize = getpagesize ();
52 char *two_pages =
53 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
54 flags, fd, 0);
55 if (two_pages != (char *)(-1)
56 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
57 fence = two_pages + pagesize;
58 }
59#endif 50#endif
60 if (fence) 51 if (fence)
61 { 52 {
@@ -85,12 +76,12 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
85 [gl_cv_func_memchr_works=yes], 76 [gl_cv_func_memchr_works=yes],
86 [gl_cv_func_memchr_works=no], 77 [gl_cv_func_memchr_works=no],
87 [case "$host_os" in 78 [case "$host_os" in
88 # Guess no on Android. 79 # Guess no on Android.
89 linux*-android*) gl_cv_func_memchr_works="guessing no" ;; 80 linux*-android*) gl_cv_func_memchr_works="guessing no" ;;
90 # Guess yes on native Windows. 81 # Guess yes on native Windows.
91 mingw*) gl_cv_func_memchr_works="guessing yes" ;; 82 mingw* | windows*) gl_cv_func_memchr_works="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses. 83 # If we don't know, obey --enable-cross-guesses.
93 *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;; 84 *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;;
94 esac 85 esac
95 ]) 86 ])
96 ]) 87 ])
diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4
index fd09846f..3344e3f7 100644
--- a/gl/m4/minmax.m4
+++ b/gl/m4/minmax.m4
@@ -1,8 +1,10 @@
1# minmax.m4 serial 4 1# minmax.m4
2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc. 2# serial 4
3dnl Copyright (C) 2005, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_PREREQ([2.53]) 9AC_PREREQ([2.53])
8 10
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index e9d31f35..fa32d138 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,9 +1,11 @@
1# serial 37 1# mktime.m4
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, 2# serial 43
3dnl Copyright (C) 2002-2003, 2005-2007, 2009-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8dnl From Jim Meyering. 10dnl From Jim Meyering.
9 11
@@ -111,22 +113,6 @@ mktime_test (time_t now)
111} 113}
112 114
113static int 115static int
114irix_6_4_bug ()
115{
116 /* Based on code from Ariel Faigon. */
117 struct tm tm;
118 tm.tm_year = 96;
119 tm.tm_mon = 3;
120 tm.tm_mday = 0;
121 tm.tm_hour = 0;
122 tm.tm_min = 0;
123 tm.tm_sec = 0;
124 tm.tm_isdst = -1;
125 mktime (&tm);
126 return tm.tm_mon == 2 && tm.tm_mday == 31;
127}
128
129static int
130bigtime_test (int j) 116bigtime_test (int j)
131{ 117{
132 struct tm tm; 118 struct tm tm;
@@ -253,20 +239,18 @@ main ()
253 if ((result & 8) == 0 && ! bigtime_test (INT_MAX)) 239 if ((result & 8) == 0 && ! bigtime_test (INT_MAX))
254 result |= 8; 240 result |= 8;
255 } 241 }
256 if (! irix_6_4_bug ())
257 result |= 16;
258 if (! spring_forward_gap ()) 242 if (! spring_forward_gap ())
259 result |= 32; 243 result |= 16;
260 if (! year_2050_test () || ! indiana_test ()) 244 if (! year_2050_test () || ! indiana_test ())
261 result |= 64; 245 result |= 32;
262 return result; 246 return result;
263}]])], 247}]])],
264 [gl_cv_func_working_mktime=yes], 248 [gl_cv_func_working_mktime=yes],
265 [gl_cv_func_working_mktime=no], 249 [gl_cv_func_working_mktime=no],
266 [case "$host_os" in 250 [case "$host_os" in
267 # Guess no on native Windows. 251 # Guess no on native Windows.
268 mingw*) gl_cv_func_working_mktime="guessing no" ;; 252 mingw* | windows*) gl_cv_func_working_mktime="guessing no" ;;
269 *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;; 253 *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;;
270 esac 254 esac
271 ]) 255 ])
272 fi 256 fi
@@ -280,7 +264,6 @@ AC_DEFUN([gl_FUNC_MKTIME],
280 AC_REQUIRE([AC_CANONICAL_HOST]) 264 AC_REQUIRE([AC_CANONICAL_HOST])
281 AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) 265 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
282 266
283 REPLACE_MKTIME=0
284 if test "$gl_cv_func_working_mktime" != yes; then 267 if test "$gl_cv_func_working_mktime" != yes; then
285 REPLACE_MKTIME=1 268 REPLACE_MKTIME=1
286 AC_DEFINE([NEED_MKTIME_WORKING], [1], 269 AC_DEFINE([NEED_MKTIME_WORKING], [1],
@@ -288,7 +271,7 @@ AC_DEFUN([gl_FUNC_MKTIME],
288 with the algorithmic workarounds.]) 271 with the algorithmic workarounds.])
289 fi 272 fi
290 case "$host_os" in 273 case "$host_os" in
291 mingw*) 274 mingw* | windows*)
292 REPLACE_MKTIME=1 275 REPLACE_MKTIME=1
293 AC_DEFINE([NEED_MKTIME_WINDOWS], [1], 276 AC_DEFINE([NEED_MKTIME_WINDOWS], [1],
294 [Define if the compilation of mktime.c should define 'mktime' 277 [Define if the compilation of mktime.c should define 'mktime'
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index d07d26e4..b5e323d4 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -1,17 +1,17 @@
1# mmap-anon.m4 serial 12 1# mmap-anon.m4
2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 15
3dnl Copyright (C) 2005, 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# Detect how mmap can be used to create anonymous (not file-backed) memory 9# Detect how mmap can be used to create anonymous (not file-backed) memory
8# mappings. 10# mappings.
9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS 11# - On Linux, AIX, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS and
10# and MAP_ANON exist and have the same value. 12# MAP_ANON exist and have the same value.
11# - On HP-UX, only MAP_ANONYMOUS exists. 13# - On HP-UX, only MAP_ANONYMOUS exists.
12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists. 14# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists.
13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
14# used.
15 15
16AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON], 16AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
17[ 17[
@@ -21,11 +21,13 @@ AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
21 # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it 21 # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
22 # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is 22 # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
23 # irrelevant for anonymous mappings. 23 # irrelevant for anonymous mappings.
24 AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no]) 24 # Instead, assume that mmap() exists if and only if <sys/mman.h> exists.
25 # Code needs to tests HAVE_SYS_MMAN_H, not HAVE_MMAP.
26 AC_CHECK_HEADERS_ONCE([sys/mman.h])
25 27
26 # Try to allow MAP_ANONYMOUS. 28 # Try to allow MAP_ANONYMOUS.
27 gl_have_mmap_anonymous=no 29 gl_have_mmap_anonymous=no
28 if test $gl_have_mmap = yes; then 30 if test $ac_cv_header_sys_mman_h = yes; then
29 AC_MSG_CHECKING([for MAP_ANONYMOUS]) 31 AC_MSG_CHECKING([for MAP_ANONYMOUS])
30 AC_EGREP_CPP([I cannot identify this map], [ 32 AC_EGREP_CPP([I cannot identify this map], [
31#include <sys/mman.h> 33#include <sys/mman.h>
@@ -46,10 +48,5 @@ AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
46 gl_have_mmap_anonymous=yes]) 48 gl_have_mmap_anonymous=yes])
47 fi 49 fi
48 AC_MSG_RESULT([$gl_have_mmap_anonymous]) 50 AC_MSG_RESULT([$gl_have_mmap_anonymous])
49 if test $gl_have_mmap_anonymous = yes; then
50 AC_DEFINE([HAVE_MAP_ANONYMOUS], [1],
51 [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including
52 config.h and <sys/mman.h>.])
53 fi
54 fi 51 fi
55]) 52])
diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4
index 82197c02..4621813d 100644
--- a/gl/m4/mode_t.m4
+++ b/gl/m4/mode_t.m4
@@ -1,8 +1,10 @@
1# mode_t.m4 serial 2 1# mode_t.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 2
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and 9# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
8# include <sys/types.h>. 10# include <sys/types.h>.
diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4
index a9b4edb9..311e00b2 100644
--- a/gl/m4/mountlist.m4
+++ b/gl/m4/mountlist.m4
@@ -1,8 +1,10 @@
1# serial 15 1# mountlist.m4
2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc. 2# serial 20
3dnl Copyright (C) 2002-2006, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Jim Meyering. 9dnl From Jim Meyering.
8 10
@@ -73,7 +75,7 @@ $ac_includes_default
73 # Determine whether it's the one-argument variant or the two-argument one. 75 # Determine whether it's the one-argument variant or the two-argument one.
74 76
75 if test -z "$ac_list_mounted_fs"; then 77 if test -z "$ac_list_mounted_fs"; then
76 # glibc, HP-UX, IRIX, Cygwin, Android, also (obsolete) 4.3BSD, SunOS. 78 # glibc, HP-UX, Cygwin, Android, also (obsolete) 4.3BSD, SunOS.
77 AC_CACHE_CHECK([for one-argument getmntent function], 79 AC_CACHE_CHECK([for one-argument getmntent function],
78 [fu_cv_sys_mounted_getmntent1], 80 [fu_cv_sys_mounted_getmntent1],
79 [AC_COMPILE_IFELSE( 81 [AC_COMPILE_IFELSE(
@@ -105,8 +107,19 @@ $ac_includes_default
105 AC_DEFINE([MOUNTED_GETMNTENT1], [1], 107 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
106 [Define if there is a function named getmntent for reading the list 108 [Define if there is a function named getmntent for reading the list
107 of mounted file systems, and that function takes a single argument. 109 of mounted file systems, and that function takes a single argument.
108 (4.3BSD, SunOS, HP-UX, Irix)]) 110 (4.3BSD, SunOS, HP-UX)])
109 AC_CHECK_FUNCS([setmntent endmntent hasmntopt]) 111 gl_CHECK_FUNCS_ANDROID([setmntent],
112 [[#include <stdio.h>
113 #include <mntent.h>
114 ]])
115 gl_CHECK_FUNCS_ANDROID([endmntent],
116 [[#include <stdio.h>
117 #include <mntent.h>
118 ]])
119 gl_CHECK_FUNCS_ANDROID([hasmntopt],
120 [[#include <stdio.h>
121 #include <mntent.h>
122 ]])
110 fi 123 fi
111 fi 124 fi
112 125
@@ -146,7 +159,7 @@ $ac_includes_default
146 fi 159 fi
147 160
148 if test -z "$ac_list_mounted_fs"; then 161 if test -z "$ac_list_mounted_fs"; then
149 # OSF/1, also (obsolete) Apple Darwin 1.3. 162 # (obsolete) Apple Darwin 1.3.
150 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h 163 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
151 164
152 AC_CACHE_CHECK([for getfsstat function], 165 AC_CACHE_CHECK([for getfsstat function],
@@ -172,7 +185,7 @@ $getfsstat_includes
172 ac_list_mounted_fs=found 185 ac_list_mounted_fs=found
173 AC_DEFINE([MOUNTED_GETFSSTAT], [1], 186 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
174 [Define if there is a function named getfsstat for reading the 187 [Define if there is a function named getfsstat for reading the
175 list of mounted file systems. (DEC Alpha running OSF/1)]) 188 list of mounted file systems. (obsolete Darwin)])
176 fi 189 fi
177 fi 190 fi
178 191
@@ -199,10 +212,9 @@ $getfsstat_includes
199 212
200 if test -z "$ac_list_mounted_fs"; then 213 if test -z "$ac_list_mounted_fs"; then
201 # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD. 214 # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD.
202 # OSF/1 also has getmntinfo but is already handled above.
203 # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker 215 # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker
204 # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64 216 # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64
205 # on Mac OS X, __getmntinfo13 on NetBSD and Minix, _F64_getmntinfo on OSF/1. 217 # on Mac OS X, __getmntinfo13 on NetBSD and Minix.
206 AC_CACHE_CHECK([for getmntinfo function], 218 AC_CACHE_CHECK([for getmntinfo function],
207 [fu_cv_sys_mounted_getmntinfo], 219 [fu_cv_sys_mounted_getmntinfo],
208 [AC_LINK_IFELSE( 220 [AC_LINK_IFELSE(
@@ -306,12 +318,17 @@ int getmntinfo (struct statfs **, int);
306 fi 318 fi
307 319
308 if test -z "$ac_list_mounted_fs"; then 320 if test -z "$ac_list_mounted_fs"; then
309 AC_MSG_ERROR([could not determine how to read list of mounted file systems]) 321 case "$host_os" in
310 # FIXME -- no need to abort building the whole package 322 mingw* | windows*) ac_list_mounted_fs=found ;;
311 # Can't build mountlist.c or anything that needs its functions 323 esac
324 fi
325
326 if test -z "$ac_list_mounted_fs"; then
327 AC_DEFINE([MOUNTED_NOT_PORTED], [1],
328 [Define if we don't know how to determine the list of mounted file systems.])
312 fi 329 fi
313 330
314 if test $ac_list_mounted_fs = found; then 331 if test "$ac_list_mounted_fs" = found; then
315 gl_cv_list_mounted_fs=yes 332 gl_cv_list_mounted_fs=yes
316 else 333 else
317 gl_cv_list_mounted_fs=no 334 gl_cv_list_mounted_fs=no
diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4
index 8d9d21b5..565c0d3a 100644
--- a/gl/m4/msvc-inval.m4
+++ b/gl/m4/msvc-inval.m4
@@ -1,8 +1,10 @@
1# msvc-inval.m4 serial 1 1# msvc-inval.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 1
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_MSVC_INVAL], 9AC_DEFUN([gl_MSVC_INVAL],
8[ 10[
diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4
index 0263e490..1c2b491e 100644
--- a/gl/m4/msvc-nothrow.m4
+++ b/gl/m4/msvc-nothrow.m4
@@ -1,8 +1,10 @@
1# msvc-nothrow.m4 serial 1 1# msvc-nothrow.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 1
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_MSVC_NOTHROW], 9AC_DEFUN([gl_MSVC_NOTHROW],
8[ 10[
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
index 3ba5b0f7..4fb642b7 100644
--- a/gl/m4/multiarch.m4
+++ b/gl/m4/multiarch.m4
@@ -1,8 +1,10 @@
1# multiarch.m4 serial 9 1# multiarch.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 9
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# Determine whether the compiler is or may be producing universal binaries. 9# Determine whether the compiler is or may be producing universal binaries.
8# 10#
diff --git a/gl/m4/musl.m4 b/gl/m4/musl.m4
new file mode 100644
index 00000000..15b34466
--- /dev/null
+++ b/gl/m4/musl.m4
@@ -0,0 +1,22 @@
1# musl.m4
2# serial 4
3dnl Copyright (C) 2019-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# Test for musl libc, despite the musl libc authors don't like it
10# <https://wiki.musl-libc.org/faq.html>
11# <https://lists.gnu.org/archive/html/bug-gnulib/2018-02/msg00079.html>.
12# From Bruno Haible.
13
14AC_DEFUN_ONCE([gl_MUSL_LIBC],
15[
16 AC_REQUIRE([AC_CANONICAL_HOST])
17 case "$host_os" in
18 *-musl* | midipix*)
19 AC_DEFINE([MUSL_LIBC], [1], [Define to 1 on musl libc.])
20 ;;
21 esac
22])
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index e6aa8925..bcf19b01 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,8 +1,10 @@
1# netdb_h.m4 serial 15 1# netdb_h.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 15
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_NETDB_H], 9AC_DEFUN_ONCE([gl_NETDB_H],
8[ 10[
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index 71154191..6d9eaf97 100644
--- a/gl/m4/netinet_in_h.m4
+++ b/gl/m4/netinet_in_h.m4
@@ -1,8 +1,10 @@
1# netinet_in_h.m4 serial 6 1# netinet_in_h.m4
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 2# serial 6
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_HEADER_NETINET_IN], 9AC_DEFUN([gl_HEADER_NETINET_IN],
8[ 10[
diff --git a/gl/m4/nl_langinfo.m4 b/gl/m4/nl_langinfo.m4
index 51e783ce..a3ec57f7 100644
--- a/gl/m4/nl_langinfo.m4
+++ b/gl/m4/nl_langinfo.m4
@@ -1,56 +1,33 @@
1# nl_langinfo.m4 serial 8 1# nl_langinfo.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 14
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_NL_LANGINFO], 9AC_DEFUN([gl_FUNC_NL_LANGINFO],
8[ 10[
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 11 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 AC_REQUIRE([gl_LANGINFO_H]) 12 AC_REQUIRE([gl_LANGINFO_H])
11 AC_CHECK_FUNCS_ONCE([nl_langinfo]) 13 gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include <langinfo.h>]])
12 AC_REQUIRE([AC_CANONICAL_HOST]) 14 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL]) 15 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
14 AC_REQUIRE([gl_PTHREADLIB]) 16 AC_REQUIRE([gl_PTHREADLIB])
15 AC_CHECK_HEADERS_ONCE([threads.h]) 17 AC_CHECK_HEADERS_ONCE([threads.h])
16 if test $ac_cv_func_nl_langinfo = yes; then 18 if test $ac_cv_func_nl_langinfo = yes; then
17 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. 19 # On macOS 26, Solaris 10, and Solaris 11.3, nl_langinfo is not
18 AC_CACHE_CHECK([whether YESEXPR works], 20 # multithread-safe.
19 [gl_cv_func_nl_langinfo_yesexpr_works],
20 [AC_RUN_IFELSE(
21 [AC_LANG_PROGRAM([[#include <langinfo.h>
22]], [[return !*nl_langinfo(YESEXPR);
23]])],
24 [gl_cv_func_nl_langinfo_yesexpr_works=yes],
25 [gl_cv_func_nl_langinfo_yesexpr_works=no],
26 [
27 case "$host_os" in
28 # Guess no on irix systems.
29 irix*) gl_cv_func_nl_langinfo_yesexpr_works="guessing no";;
30 # Guess yes elsewhere.
31 *) gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";;
32 esac
33 ])
34 ])
35 case $gl_cv_func_nl_langinfo_yesexpr_works in
36 *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;;
37 *) FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;;
38 esac
39 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
40 [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
41 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
42 # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe.
43 case "$host_os" in 21 case "$host_os" in
44 solaris*) NL_LANGINFO_MTSAFE=0 ;; 22 darwin* | solaris*) NL_LANGINFO_MTSAFE=0 ;;
45 *) NL_LANGINFO_MTSAFE=1 ;; 23 *) NL_LANGINFO_MTSAFE=1 ;;
46 esac 24 esac
47 AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE], 25 AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE],
48 [Define to 1 if nl_langinfo is multithread-safe.]) 26 [Define to 1 if nl_langinfo is multithread-safe.])
49 if test $HAVE_LANGINFO_CODESET = 1 \ 27 if test $HAVE_LANGINFO_CODESET = 1 \
50 && test $HAVE_LANGINFO_T_FMT_AMPM = 1 \
51 && test $HAVE_LANGINFO_ALTMON = 1 \ 28 && test $HAVE_LANGINFO_ALTMON = 1 \
29 && test $HAVE_LANGINFO_ABALTMON = 1 \
52 && test $HAVE_LANGINFO_ERA = 1 \ 30 && test $HAVE_LANGINFO_ERA = 1 \
53 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1 \
54 && test $NL_LANGINFO_MTSAFE = 1; then 31 && test $NL_LANGINFO_MTSAFE = 1; then
55 : 32 :
56 else 33 else
@@ -60,9 +37,12 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
60 fi 37 fi
61 else 38 else
62 HAVE_NL_LANGINFO=0 39 HAVE_NL_LANGINFO=0
40 case "$gl_cv_onwards_func_nl_langinfo" in
41 future*) REPLACE_NL_LANGINFO=1 ;;
42 esac
63 fi 43 fi
64 if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then 44 if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then
65 LIB_NL_LANGINFO="$LIB_SETLOCALE_NULL" 45 LIB_NL_LANGINFO="$SETLOCALE_NULL_LIB"
66 else 46 else
67 LIB_NL_LANGINFO= 47 LIB_NL_LANGINFO=
68 fi 48 fi
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
index 6a766387..5c1af8c7 100644
--- a/gl/m4/nocrash.m4
+++ b/gl/m4/nocrash.m4
@@ -1,8 +1,10 @@
1# nocrash.m4 serial 5 1# nocrash.m4
2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2005, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini. 9dnl Based on libsigsegv, from Bruno Haible and Paolo Bonzini.
8 10
diff --git a/gl/m4/off64_t.m4 b/gl/m4/off64_t.m4
new file mode 100644
index 00000000..93d9e37b
--- /dev/null
+++ b/gl/m4/off64_t.m4
@@ -0,0 +1,32 @@
1# off64_t.m4
2# serial 1
3dnl Copyright (C) 2024-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Check whether <sys/types.h> defines the 'off64_t' type.
10dnl Set HAVE_OFF64_T.
11
12AC_DEFUN([gl_TYPE_OFF64_T],
13[
14 dnl Persuade glibc <sys/types.h>, <stdio.h>, <fcntl.h>, <unistd.h>, <aio.h>
15 dnl to define off64_t.
16 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
17
18 AC_CACHE_CHECK([for off64_t], [gl_cv_off64_t],
19 [AC_COMPILE_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[#include <sys/types.h>]],
22 [[int x = sizeof (off64_t *) + sizeof (off64_t);
23 return !x;]])],
24 [gl_cv_off64_t=yes], [gl_cv_off64_t=no])])
25
26 if test $gl_cv_off64_t != no; then
27 HAVE_OFF64_T=1
28 else
29 HAVE_OFF64_T=0
30 fi
31 AC_SUBST([HAVE_OFF64_T])
32])
diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4
index 880f3472..d7d6aa0c 100644
--- a/gl/m4/off_t.m4
+++ b/gl/m4/off_t.m4
@@ -1,8 +1,10 @@
1# off_t.m4 serial 1 1# off_t.m4
2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. 2# serial 1
3dnl Copyright (C) 2012-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Check whether to override the 'off_t' type. 9dnl Check whether to override the 'off_t' type.
8dnl Set WINDOWS_64_BIT_OFF_T. 10dnl Set WINDOWS_64_BIT_OFF_T.
diff --git a/gl/m4/once.m4 b/gl/m4/once.m4
new file mode 100644
index 00000000..a478d81a
--- /dev/null
+++ b/gl/m4/once.m4
@@ -0,0 +1,14 @@
1# once.m4
2# serial 1
3dnl Copyright (C) 2024-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Bruno Haible.
10
11AC_DEFUN([gl_ONCE],
12[
13 AC_REQUIRE([gl_THREADLIB])
14])
diff --git a/gl/m4/open-cloexec.m4 b/gl/m4/open-cloexec.m4
index fd572fcd..9c9aef23 100644
--- a/gl/m4/open-cloexec.m4
+++ b/gl/m4/open-cloexec.m4
@@ -1,9 +1,12 @@
1# Test whether O_CLOEXEC is defined. 1# open-cloexec.m4
2 2# serial 1
3dnl Copyright 2017-2023 Free Software Foundation, Inc. 3dnl Copyright 2017-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# Test whether O_CLOEXEC is defined.
7 10
8AC_DEFUN([gl_PREPROC_O_CLOEXEC], 11AC_DEFUN([gl_PREPROC_O_CLOEXEC],
9[ 12[
diff --git a/gl/m4/open-slash.m4 b/gl/m4/open-slash.m4
index 1f731f8a..c36bdced 100644
--- a/gl/m4/open-slash.m4
+++ b/gl/m4/open-slash.m4
@@ -1,8 +1,10 @@
1# open-slash.m4 serial 2 1# open-slash.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 2
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Tests whether open() and creat() recognize a trailing slash. 9dnl Tests whether open() and creat() recognize a trailing slash.
8dnl Sets gl_cv_func_open_slash. 10dnl Sets gl_cv_func_open_slash.
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
index 94fa2bb7..f5b2a91c 100644
--- a/gl/m4/open.m4
+++ b/gl/m4/open.m4
@@ -1,15 +1,20 @@
1# open.m4 serial 15 1# open.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 17
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_OPEN], 9AC_DEFUN([gl_FUNC_OPEN],
8[ 10[
9 AC_REQUIRE([AC_CANONICAL_HOST]) 11 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PREPROC_O_CLOEXEC]) 12 AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
13 AC_REQUIRE([gl_FCNTL_O_FLAGS])
14 AS_CASE([$gl_cv_header_working_fcntl_h],
15 [*O_DIRECTORY* | *no], [REPLACE_OPEN=1])
11 case "$host_os" in 16 case "$host_os" in
12 mingw* | pw*) 17 mingw* | windows* | pw*)
13 REPLACE_OPEN=1 18 REPLACE_OPEN=1
14 ;; 19 ;;
15 *) 20 *)
diff --git a/gl/m4/pathmax.m4 b/gl/m4/pathmax.m4
index 6d47d2c0..d6bdf43e 100644
--- a/gl/m4/pathmax.m4
+++ b/gl/m4/pathmax.m4
@@ -1,9 +1,11 @@
1# pathmax.m4 serial 11 1# pathmax.m4
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation, 2# serial 11
3dnl Copyright (C) 2002-2003, 2005-2006, 2009-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8AC_DEFUN([gl_PATHMAX], 10AC_DEFUN([gl_PATHMAX],
9[ 11[
diff --git a/gl/m4/pid_t.m4 b/gl/m4/pid_t.m4
index 0fd7d0a1..314792ed 100644
--- a/gl/m4/pid_t.m4
+++ b/gl/m4/pid_t.m4
@@ -1,8 +1,10 @@
1# pid_t.m4 serial 4 1# pid_t.m4
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc. 2# serial 4
3dnl Copyright (C) 2020-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# The following implementation works around a problem in autoconf <= 2.69. 9# The following implementation works around a problem in autoconf <= 2.69.
8m4_version_prereq([2.70], [], [ 10m4_version_prereq([2.70], [], [
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index 4e65abc6..0de493b6 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,8 +1,10 @@
1# printf.m4 serial 73 1# printf.m4
2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc. 2# serial 98
3dnl Copyright (C) 2003, 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Test whether the *printf family of functions supports the 'j', 'z', 't', 9dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
8dnl 'L' size specifiers. (ISO C99, POSIX:2001) 10dnl 'L' size specifiers. (ISO C99, POSIX:2001)
@@ -63,7 +65,7 @@ changequote(,)dnl
63 # Guess yes on glibc systems. 65 # Guess yes on glibc systems.
64 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 66 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on musl systems. 67 # Guess yes on musl systems.
66 *-musl*) gl_cv_func_printf_sizes_c99="guessing yes";; 68 *-musl* | midipix*) gl_cv_func_printf_sizes_c99="guessing yes";;
67 # Guess yes on FreeBSD >= 5. 69 # Guess yes on FreeBSD >= 5.
68 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";; 70 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";;
69 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 71 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
@@ -86,7 +88,8 @@ changequote(,)dnl
86 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";; 88 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";;
87changequote([,])dnl 89changequote([,])dnl
88 # Guess yes on MSVC, no on mingw. 90 # Guess yes on MSVC, no on mingw.
89 mingw*) AC_EGREP_CPP([Known], [ 91 windows*-msvc*) gl_cv_func_printf_sizes_c99="guessing yes" ;;
92 mingw* | windows*) AC_EGREP_CPP([Known], [
90#ifdef _MSC_VER 93#ifdef _MSC_VER
91 Known 94 Known
92#endif 95#endif
@@ -101,6 +104,92 @@ changequote([,])dnl
101 ]) 104 ])
102]) 105])
103 106
107dnl Test whether the *printf family of functions supports the 'w8', 'w16',
108dnl 'w32', 'w64', 'wf8', 'wf16', 'wf32', 'wf64' size specifiers. (ISO C23)
109dnl Result is gl_cv_func_printf_sizes_c23.
110
111AC_DEFUN([gl_PRINTF_SIZES_C23],
112[
113 AC_REQUIRE([AC_PROG_CC])
114 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
115 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
116 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
117 AC_CACHE_CHECK([whether printf supports size specifiers as in C23],
118 [gl_cv_func_printf_sizes_c23],
119 [
120 AC_RUN_IFELSE(
121 [AC_LANG_SOURCE([[
122#include <stddef.h>
123#include <stdio.h>
124#include <string.h>
125#include <sys/types.h>
126#if HAVE_STDINT_H_WITH_UINTMAX
127# include <stdint.h>
128#endif
129#if HAVE_INTTYPES_H_WITH_UINTMAX
130# include <inttypes.h>
131#endif
132static char buf[100];
133int main ()
134{
135 int result = 0;
136 buf[0] = '\0';
137 if (sprintf (buf, "%w8u %d", (uint8_t) 123, 33, 44, 55) < 0
138 || strcmp (buf, "123 33") != 0)
139 result |= 1;
140 buf[0] = '\0';
141 if (sprintf (buf, "%wf8u %d", (uint_fast8_t) 123, 33, 44, 55) < 0
142 || strcmp (buf, "123 33") != 0)
143 result |= 1;
144 buf[0] = '\0';
145 if (sprintf (buf, "%w16u %d", (uint16_t) 12345, 33, 44, 55) < 0
146 || strcmp (buf, "12345 33") != 0)
147 result |= 2;
148 buf[0] = '\0';
149 if (sprintf (buf, "%wf16u %d", (uint_fast16_t) 12345, 33, 44, 55) < 0
150 || strcmp (buf, "12345 33") != 0)
151 result |= 2;
152 buf[0] = '\0';
153 if (sprintf (buf, "%w32u %d", (uint32_t) 12345671, 33, 44, 55) < 0
154 || strcmp (buf, "12345671 33") != 0)
155 result |= 4;
156 buf[0] = '\0';
157 if (sprintf (buf, "%wf32u %d", (uint_fast32_t) 12345671, 33, 44, 55) < 0
158 || strcmp (buf, "12345671 33") != 0)
159 result |= 4;
160#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
161 buf[0] = '\0';
162 if (sprintf (buf, "%w64u %d", (uint64_t) 12345671, 33, 44, 55) < 0
163 || strcmp (buf, "12345671 33") != 0)
164 result |= 8;
165 buf[0] = '\0';
166 if (sprintf (buf, "%wf64u %d", (uint_fast64_t) 12345671, 33, 44, 55) < 0
167 || strcmp (buf, "12345671 33") != 0)
168 result |= 8;
169#else
170 result |= 8;
171#endif
172 return result;
173}]])],
174 [gl_cv_func_printf_sizes_c23=yes],
175 [gl_cv_func_printf_sizes_c23=no],
176 [
177 case "$host_os" in
178 # Guess no on glibc systems.
179 *-gnu* | gnu*) gl_cv_func_printf_sizes_c23="guessing no";;
180 # Guess no on musl systems.
181 *-musl* | midipix*) gl_cv_func_printf_sizes_c23="guessing no";;
182 # Guess no on Android.
183 linux*-android*) gl_cv_func_printf_sizes_c23="guessing no";;
184 # Guess no on native Windows.
185 mingw* | windows*) gl_cv_func_printf_sizes_c23="guessing no";;
186 # If we don't know, obey --enable-cross-guesses.
187 *) gl_cv_func_printf_sizes_c23="$gl_cross_guess_normal";;
188 esac
189 ])
190 ])
191])
192
104dnl Test whether the *printf family of functions supports 'long double' 193dnl Test whether the *printf family of functions supports 'long double'
105dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001) 194dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
106dnl Result is gl_cv_func_printf_long_double. 195dnl Result is gl_cv_func_printf_long_double.
@@ -137,20 +226,21 @@ int main ()
137 [gl_cv_func_printf_long_double=yes], 226 [gl_cv_func_printf_long_double=yes],
138 [gl_cv_func_printf_long_double=no], 227 [gl_cv_func_printf_long_double=no],
139 [case "$host_os" in 228 [case "$host_os" in
140 # Guess no on BeOS. 229 # Guess no on BeOS.
141 beos*) gl_cv_func_printf_long_double="guessing no";; 230 beos*) gl_cv_func_printf_long_double="guessing no";;
142 # Guess yes on Android. 231 # Guess yes on Android.
143 linux*-android*) gl_cv_func_printf_long_double="guessing yes";; 232 linux*-android*) gl_cv_func_printf_long_double="guessing yes";;
144 # Guess yes on MSVC, no on mingw. 233 # Guess yes on MSVC, no on mingw.
145 mingw*) AC_EGREP_CPP([Known], [ 234 windows*-msvc*) gl_cv_func_printf_long_double="guessing yes" ;;
235 mingw* | windows*) AC_EGREP_CPP([Known], [
146#ifdef _MSC_VER 236#ifdef _MSC_VER
147 Known 237 Known
148#endif 238#endif
149 ], 239 ],
150 [gl_cv_func_printf_long_double="guessing yes"], 240 [gl_cv_func_printf_long_double="guessing yes"],
151 [gl_cv_func_printf_long_double="guessing no"]) 241 [gl_cv_func_printf_long_double="guessing no"])
152 ;; 242 ;;
153 *) gl_cv_func_printf_long_double="guessing yes";; 243 *) gl_cv_func_printf_long_double="guessing yes";;
154 esac 244 esac
155 ]) 245 ])
156 ]) 246 ])
@@ -244,7 +334,7 @@ changequote(,)dnl
244 # Guess yes on glibc systems. 334 # Guess yes on glibc systems.
245 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";; 335 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";;
246 # Guess yes on musl systems. 336 # Guess yes on musl systems.
247 *-musl*) gl_cv_func_printf_infinite="guessing yes";; 337 *-musl* | midipix*) gl_cv_func_printf_infinite="guessing yes";;
248 # Guess yes on FreeBSD >= 6. 338 # Guess yes on FreeBSD >= 6.
249 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";; 339 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
250 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 340 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
@@ -268,7 +358,8 @@ changequote(,)dnl
268 linux*-android*) gl_cv_func_printf_infinite="guessing no";; 358 linux*-android*) gl_cv_func_printf_infinite="guessing no";;
269changequote([,])dnl 359changequote([,])dnl
270 # Guess yes on MSVC, no on mingw. 360 # Guess yes on MSVC, no on mingw.
271 mingw*) AC_EGREP_CPP([Known], [ 361 windows*-msvc*) gl_cv_func_printf_infinite="guessing yes" ;;
362 mingw* | windows*) AC_EGREP_CPP([Known], [
272#ifdef _MSC_VER 363#ifdef _MSC_VER
273 Known 364 Known
274#endif 365#endif
@@ -467,7 +558,7 @@ changequote(,)dnl
467 # Guess yes on glibc systems. 558 # Guess yes on glibc systems.
468 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 559 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
469 # Guess yes on musl systems. 560 # Guess yes on musl systems.
470 *-musl*) gl_cv_func_printf_infinite_long_double="guessing yes";; 561 *-musl* | midipix*) gl_cv_func_printf_infinite_long_double="guessing yes";;
471 # Guess yes on FreeBSD >= 6. 562 # Guess yes on FreeBSD >= 6.
472 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";; 563 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
473 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 564 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
@@ -482,7 +573,8 @@ changequote(,)dnl
482 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";; 573 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";;
483changequote([,])dnl 574changequote([,])dnl
484 # Guess yes on MSVC, no on mingw. 575 # Guess yes on MSVC, no on mingw.
485 mingw*) AC_EGREP_CPP([Known], [ 576 windows*-msvc*) gl_cv_func_printf_infinite_long_double="guessing yes" ;;
577 mingw* | windows*) AC_EGREP_CPP([Known], [
486#ifdef _MSC_VER 578#ifdef _MSC_VER
487 Known 579 Known
488#endif 580#endif
@@ -525,6 +617,7 @@ static double zero = 0.0;
525int main () 617int main ()
526{ 618{
527 int result = 0; 619 int result = 0;
620 /* This fails on FreeBSD 5.2.1, Solaris 11.4. */
528 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 621 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
529 || (strcmp (buf, "0x1.922p+1 33") != 0 622 || (strcmp (buf, "0x1.922p+1 33") != 0
530 && strcmp (buf, "0x3.244p+0 33") != 0 623 && strcmp (buf, "0x3.244p+0 33") != 0
@@ -536,27 +629,29 @@ int main ()
536 && strcmp (buf, "-0X3.244P+0 33") != 0 629 && strcmp (buf, "-0X3.244P+0 33") != 0
537 && strcmp (buf, "-0X6.488P-1 33") != 0 630 && strcmp (buf, "-0X6.488P-1 33") != 0
538 && strcmp (buf, "-0XC.91P-2 33") != 0)) 631 && strcmp (buf, "-0XC.91P-2 33") != 0))
539 result |= 2; 632 result |= 1;
540 /* This catches a FreeBSD 13.0 bug: it doesn't round. */ 633 /* This catches a Mac OS X 10.5, FreeBSD 6.4, NetBSD 10.0 bug:
634 it doesn't round. */
541 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 635 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
542 || (strcmp (buf, "0x1.83p+0 33") != 0 636 || (strcmp (buf, "0x1.83p+0 33") != 0
543 && strcmp (buf, "0x3.05p-1 33") != 0 637 && strcmp (buf, "0x3.05p-1 33") != 0
544 && strcmp (buf, "0x6.0ap-2 33") != 0 638 && strcmp (buf, "0x6.0ap-2 33") != 0
545 && strcmp (buf, "0xc.14p-3 33") != 0)) 639 && strcmp (buf, "0xc.14p-3 33") != 0))
546 result |= 4; 640 result |= 2;
547 /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */ 641 /* This catches a macOS 14 (Darwin 23), FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
642 Solaris 11.4 bug: it doesn't round. */
548 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0 643 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
549 || (strcmp (buf, "0x2p+0 33") != 0 644 || (strcmp (buf, "0x2p+0 33") != 0
550 && strcmp (buf, "0x3p-1 33") != 0 645 && strcmp (buf, "0x3p-1 33") != 0
551 && strcmp (buf, "0x6p-2 33") != 0 646 && strcmp (buf, "0x6p-2 33") != 0
552 && strcmp (buf, "0xcp-3 33") != 0)) 647 && strcmp (buf, "0xcp-3 33") != 0))
553 result |= 4; 648 result |= 4;
554 /* This catches a FreeBSD 6.1 bug. See 649 /* This catches a Mac OS X 10.5, FreeBSD 6.4 bug. See
555 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */ 650 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */
556 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 651 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
557 || buf[0] == '0') 652 || buf[0] == '0')
558 result |= 8; 653 result |= 8;
559 /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */ 654 /* This catches a Mac OS X 10.3.9 (Darwin 7.9), FreeBSD 6.4 bug. */
560 if (sprintf (buf, "%.1a", 1.999) < 0 655 if (sprintf (buf, "%.1a", 1.999) < 0
561 || (strcmp (buf, "0x1.0p+1") != 0 656 || (strcmp (buf, "0x1.0p+1") != 0
562 && strcmp (buf, "0x2.0p+0") != 0 657 && strcmp (buf, "0x2.0p+0") != 0
@@ -564,7 +659,8 @@ int main ()
564 && strcmp (buf, "0x8.0p-2") != 0)) 659 && strcmp (buf, "0x8.0p-2") != 0))
565 result |= 16; 660 result |= 16;
566 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a 661 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
567 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 662 glibc 2.4 bug <https://sourceware.org/PR2908>
663 and a FreeBSD 6.4, NetBSD 10.0 bug. */
568 if (sprintf (buf, "%.1La", 1.999L) < 0 664 if (sprintf (buf, "%.1La", 1.999L) < 0
569 || (strcmp (buf, "0x1.0p+1") != 0 665 || (strcmp (buf, "0x1.0p+1") != 0
570 && strcmp (buf, "0x2.0p+0") != 0 666 && strcmp (buf, "0x2.0p+0") != 0
@@ -591,11 +687,11 @@ int main ()
591 [gl_cv_func_printf_directive_a="guessing no"]) 687 [gl_cv_func_printf_directive_a="guessing no"])
592 ;; 688 ;;
593 # Guess yes on musl systems. 689 # Guess yes on musl systems.
594 *-musl*) gl_cv_func_printf_directive_a="guessing yes";; 690 *-musl* | midipix*) gl_cv_func_printf_directive_a="guessing yes";;
595 # Guess no on Android. 691 # Guess no on Android.
596 linux*-android*) gl_cv_func_printf_directive_a="guessing no";; 692 linux*-android*) gl_cv_func_printf_directive_a="guessing no";;
597 # Guess no on native Windows. 693 # Guess no on native Windows.
598 mingw*) gl_cv_func_printf_directive_a="guessing no";; 694 mingw* | windows*) gl_cv_func_printf_directive_a="guessing no";;
599 # If we don't know, obey --enable-cross-guesses. 695 # If we don't know, obey --enable-cross-guesses.
600 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";; 696 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";;
601 esac 697 esac
@@ -603,6 +699,116 @@ int main ()
603 ]) 699 ])
604]) 700])
605 701
702dnl Test whether the *printf family of functions supports the 'b' conversion
703dnl specifier for binary output of integers.
704dnl (ISO C23)
705dnl Result is gl_cv_func_printf_directive_b.
706
707AC_DEFUN([gl_PRINTF_DIRECTIVE_B],
708[
709 AC_REQUIRE([AC_PROG_CC])
710 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
711 AC_CACHE_CHECK([whether printf supports the 'b' directive],
712 [gl_cv_func_printf_directive_b],
713 [
714 AC_RUN_IFELSE(
715 [AC_LANG_SOURCE([[
716#include <stdio.h>
717#include <string.h>
718static char buf[100];
719int main ()
720{
721 int result = 0;
722 if (sprintf (buf, "%b %d", 12345, 33, 44, 55) < 0
723 || strcmp (buf, "11000000111001 33") != 0)
724 result |= 1;
725 return result;
726}]])],
727 [gl_cv_func_printf_directive_b=yes],
728 [gl_cv_func_printf_directive_b=no],
729 [
730 case "$host_os" in
731 # Guess yes on glibc >= 2.35 systems.
732 *-gnu* | gnu*)
733 AC_EGREP_CPP([Lucky], [
734 #include <features.h>
735 #ifdef __GNU_LIBRARY__
736 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2)
737 Lucky user
738 #endif
739 #endif
740 ],
741 [gl_cv_func_printf_directive_uppercase_b="guessing yes"],
742 [gl_cv_func_printf_directive_uppercase_b="guessing no"])
743 ;;
744 # Guess no on musl systems.
745 *-musl* | midipix*) gl_cv_func_printf_directive_b="guessing no";;
746 # Guess no on Android.
747 linux*-android*) gl_cv_func_printf_directive_b="guessing no";;
748 # Guess no on native Windows.
749 mingw* | windows*) gl_cv_func_printf_directive_b="guessing no";;
750 # If we don't know, obey --enable-cross-guesses.
751 *) gl_cv_func_printf_directive_b="$gl_cross_guess_normal";;
752 esac
753 ])
754 ])
755])
756
757dnl Test whether the *printf family of functions supports the 'B' conversion
758dnl specifier for binary output of integers.
759dnl (GNU, encouraged by ISO C23 § 7.23.6.1)
760dnl Result is gl_cv_func_printf_directive_uppercase_b.
761
762AC_DEFUN([gl_PRINTF_DIRECTIVE_UPPERCASE_B],
763[
764 AC_REQUIRE([AC_PROG_CC])
765 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
766 AC_CACHE_CHECK([whether printf supports the 'B' directive],
767 [gl_cv_func_printf_directive_uppercase_b],
768 [
769 AC_RUN_IFELSE(
770 [AC_LANG_SOURCE([[
771#include <stdio.h>
772#include <string.h>
773static char buf[100];
774int main ()
775{
776 int result = 0;
777 if (sprintf (buf, "%#B %d", 12345, 33, 44, 55) < 0
778 || strcmp (buf, "0B11000000111001 33") != 0)
779 result |= 1;
780 return result;
781}]])],
782 [gl_cv_func_printf_directive_uppercase_b=yes],
783 [gl_cv_func_printf_directive_uppercase_b=no],
784 [
785 case "$host_os" in
786 # Guess yes on glibc >= 2.35 systems.
787 *-gnu* | gnu*)
788 AC_EGREP_CPP([Lucky], [
789 #include <features.h>
790 #ifdef __GNU_LIBRARY__
791 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35) || (__GLIBC__ > 2)
792 Lucky user
793 #endif
794 #endif
795 ],
796 [gl_cv_func_printf_directive_uppercase_b="guessing yes"],
797 [gl_cv_func_printf_directive_uppercase_b="guessing no"])
798 ;;
799 # Guess no on musl systems.
800 *-musl* | midipix*) gl_cv_func_printf_directive_uppercase_b="guessing no";;
801 # Guess no on Android.
802 linux*-android*) gl_cv_func_printf_directive_uppercase_b="guessing no";;
803 # Guess no on native Windows.
804 mingw* | windows*) gl_cv_func_printf_directive_uppercase_b="guessing no";;
805 # If we don't know, obey --enable-cross-guesses.
806 *) gl_cv_func_printf_directive_uppercase_b="$gl_cross_guess_normal";;
807 esac
808 ])
809 ])
810])
811
606dnl Test whether the *printf family of functions supports the %F format 812dnl Test whether the *printf family of functions supports the %F format
607dnl directive. (ISO C99, POSIX:2001) 813dnl directive. (ISO C99, POSIX:2001)
608dnl Result is gl_cv_func_printf_directive_f. 814dnl Result is gl_cv_func_printf_directive_f.
@@ -643,7 +849,7 @@ changequote(,)dnl
643 # Guess yes on glibc systems. 849 # Guess yes on glibc systems.
644 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";; 850 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";;
645 # Guess yes on musl systems. 851 # Guess yes on musl systems.
646 *-musl*) gl_cv_func_printf_directive_f="guessing yes";; 852 *-musl* | midipix*) gl_cv_func_printf_directive_f="guessing yes";;
647 # Guess yes on FreeBSD >= 6. 853 # Guess yes on FreeBSD >= 6.
648 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";; 854 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
649 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 855 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
@@ -661,7 +867,8 @@ changequote(,)dnl
661 linux*-android*) gl_cv_func_printf_directive_f="guessing no";; 867 linux*-android*) gl_cv_func_printf_directive_f="guessing no";;
662changequote([,])dnl 868changequote([,])dnl
663 # Guess yes on MSVC, no on mingw. 869 # Guess yes on MSVC, no on mingw.
664 mingw*) AC_EGREP_CPP([Known], [ 870 windows*-msvc*) gl_cv_func_printf_directive_f="guessing yes" ;;
871 mingw* | windows*) AC_EGREP_CPP([Known], [
665#ifdef _MSC_VER 872#ifdef _MSC_VER
666 Known 873 Known
667#endif 874#endif
@@ -689,10 +896,16 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
689 [ 896 [
690 AC_RUN_IFELSE( 897 AC_RUN_IFELSE(
691 [AC_LANG_SOURCE([[ 898 [AC_LANG_SOURCE([[
899#include <signal.h>
692#include <stdio.h> 900#include <stdio.h>
693#include <stdlib.h>
694#include <string.h> 901#include <string.h>
902#if defined _WIN32 && !defined __CYGWIN__
903# include <stdlib.h>
904#else
905# include <unistd.h>
906#endif
695#ifdef _MSC_VER 907#ifdef _MSC_VER
908#include <crtdbg.h>
696#include <inttypes.h> 909#include <inttypes.h>
697/* See page about "Parameter Validation" on msdn.microsoft.com. 910/* See page about "Parameter Validation" on msdn.microsoft.com.
698 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation> 911 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation>
@@ -706,6 +919,12 @@ invalid_parameter_handler (const wchar_t *expression,
706 exit (1); 919 exit (1);
707} 920}
708#endif 921#endif
922static void
923abort_handler (int sig)
924{
925 (void) sig;
926 _exit (1);
927}
709static char fmtstring[10]; 928static char fmtstring[10];
710static char buf[100]; 929static char buf[100];
711int main () 930int main ()
@@ -713,8 +932,12 @@ int main ()
713 int count = -1; 932 int count = -1;
714#ifdef _MSC_VER 933#ifdef _MSC_VER
715 _set_invalid_parameter_handler (invalid_parameter_handler); 934 _set_invalid_parameter_handler (invalid_parameter_handler);
935 /* Also avoid an Abort/Retry/Ignore dialog in debug builds.
936 <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode> */
937 _CrtSetReportMode (_CRT_ASSERT, 0);
716#endif 938#endif
717 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 939 signal (SIGABRT, abort_handler);
940 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE >= 2)
718 support %n in format strings in read-only memory but not in writable 941 support %n in format strings in read-only memory but not in writable
719 memory. */ 942 memory. */
720 strcpy (fmtstring, "%d %n"); 943 strcpy (fmtstring, "%d %n");
@@ -727,21 +950,21 @@ int main ()
727 [gl_cv_func_printf_directive_n=yes], 950 [gl_cv_func_printf_directive_n=yes],
728 [gl_cv_func_printf_directive_n=no], 951 [gl_cv_func_printf_directive_n=no],
729 [case "$host_os" in 952 [case "$host_os" in
730 # Guess no on glibc when _FORTIFY_SOURCE >= 2. 953 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
731 *-gnu* | gnu*) AC_COMPILE_IFELSE( 954 *-gnu* | gnu*) AC_COMPILE_IFELSE(
732 [AC_LANG_SOURCE( 955 [AC_LANG_SOURCE(
733 [[#if _FORTIFY_SOURCE >= 2 956 [[#if _FORTIFY_SOURCE >= 2
734 error fail 957 error fail
735 #endif 958 #endif
736 ]])], 959 ]])],
737 [gl_cv_func_printf_directive_n="guessing yes"], 960 [gl_cv_func_printf_directive_n="guessing yes"],
738 [gl_cv_func_printf_directive_n="guessing no"]) 961 [gl_cv_func_printf_directive_n="guessing no"])
739 ;; 962 ;;
740 # Guess no on Android. 963 # Guess no on Android.
741 linux*-android*) gl_cv_func_printf_directive_n="guessing no";; 964 linux*-android*) gl_cv_func_printf_directive_n="guessing no";;
742 # Guess no on native Windows. 965 # Guess no on native Windows.
743 mingw*) gl_cv_func_printf_directive_n="guessing no";; 966 mingw* | windows*) gl_cv_func_printf_directive_n="guessing no";;
744 *) gl_cv_func_printf_directive_n="guessing yes";; 967 *) gl_cv_func_printf_directive_n="guessing yes";;
745 esac 968 esac
746 ]) 969 ])
747 ]) 970 ])
@@ -771,7 +994,7 @@ int main ()
771 int result = 0; 994 int result = 0;
772 char buf[100]; 995 char buf[100];
773 /* Test whether %ls works at all. 996 /* Test whether %ls works at all.
774 This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on 997 This test fails on OpenBSD 4.0, Solaris 2.6, Haiku, but not on
775 Cygwin 1.5. */ 998 Cygwin 1.5. */
776 { 999 {
777 static const wchar_t wstring[] = { 'a', 'b', 'c', 0 }; 1000 static const wchar_t wstring[] = { 'a', 'b', 'c', 0 };
@@ -780,8 +1003,8 @@ int main ()
780 || strcmp (buf, "abc") != 0) 1003 || strcmp (buf, "abc") != 0)
781 result |= 1; 1004 result |= 1;
782 } 1005 }
783 /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an 1006 /* This test fails on Solaris 2.6, Cygwin 1.5, Haiku (with an assertion
784 assertion failure inside libc), but not on OpenBSD 4.0. */ 1007 failure inside libc), but not on OpenBSD 4.0. */
785 { 1008 {
786 static const wchar_t wstring[] = { 'a', 0 }; 1009 static const wchar_t wstring[] = { 'a', 0 };
787 buf[0] = '\0'; 1010 buf[0] = '\0';
@@ -811,18 +1034,63 @@ int main ()
811 [ 1034 [
812changequote(,)dnl 1035changequote(,)dnl
813 case "$host_os" in 1036 case "$host_os" in
814 # Guess yes on OpenBSD >= 6.0. 1037 # Guess yes on OpenBSD >= 6.0.
815 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";; 1038 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";;
816 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";; 1039 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";;
817 irix*) gl_cv_func_printf_directive_ls="guessing no";; 1040 solaris*) gl_cv_func_printf_directive_ls="guessing no";;
818 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 1041 cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
819 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 1042 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
820 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 1043 # Guess no on Android.
821 # Guess no on Android. 1044 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
822 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";; 1045 # Guess yes on native Windows.
823 # Guess yes on native Windows. 1046 mingw* | windows*) gl_cv_func_printf_directive_ls="guessing yes";;
824 mingw*) gl_cv_func_printf_directive_ls="guessing yes";; 1047 *) gl_cv_func_printf_directive_ls="guessing yes";;
825 *) gl_cv_func_printf_directive_ls="guessing yes";; 1048 esac
1049changequote([,])dnl
1050 ])
1051 ])
1052])
1053
1054dnl Test whether the *printf family of functions supports the %lc format
1055dnl directive and in particular, when the argument is a null wide character,
1056dnl whether the functions produce a NUL byte, as specified in ISO C 23
1057dnl after the issue GB-141 was fixed.
1058dnl Result is gl_cv_func_printf_directive_lc.
1059
1060AC_DEFUN([gl_PRINTF_DIRECTIVE_LC],
1061[
1062 AC_REQUIRE([AC_PROG_CC])
1063 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1064 AC_CACHE_CHECK([whether printf supports the 'lc' directive correctly],
1065 [gl_cv_func_printf_directive_lc],
1066 [
1067 AC_RUN_IFELSE(
1068 [AC_LANG_SOURCE([[
1069#include <stdio.h>
1070#include <wchar.h>
1071#include <string.h>
1072int main ()
1073{
1074 int result = 0;
1075 char buf[100];
1076 /* This test fails on musl libc 1.2.4. */
1077 {
1078 buf[0] = '\0';
1079 if (sprintf (buf, "%lc%lc%lc", (wint_t) 'a', (wint_t) 0, (wint_t) 'z') < 0
1080 || memcmp (buf, "a\0z", 4) != 0)
1081 result |= 1;
1082 }
1083 return result;
1084}]])],
1085 [gl_cv_func_printf_directive_lc=yes],
1086 [gl_cv_func_printf_directive_lc=no],
1087 [
1088changequote(,)dnl
1089 case "$host_os" in
1090 # Guess no on musl libc.
1091 *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing no";;
1092 # Guess yes otherwise.
1093 *) gl_cv_func_printf_directive_lc="guessing yes";;
826 esac 1094 esac
827changequote([,])dnl 1095changequote([,])dnl
828 ]) 1096 ])
@@ -833,7 +1101,7 @@ dnl Test whether the *printf family of functions supports POSIX/XSI format
833dnl strings with positions. (POSIX:2001) 1101dnl strings with positions. (POSIX:2001)
834dnl Result is gl_cv_func_printf_positions. 1102dnl Result is gl_cv_func_printf_positions.
835 1103
836AC_DEFUN([gl_PRINTF_POSITIONS], 1104AC_DEFUN_ONCE([gl_PRINTF_POSITIONS],
837[ 1105[
838 AC_REQUIRE([AC_PROG_CC]) 1106 AC_REQUIRE([AC_PROG_CC])
839 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1107 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -859,13 +1127,17 @@ int main ()
859changequote(,)dnl 1127changequote(,)dnl
860 case "$host_os" in 1128 case "$host_os" in
861 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 1129 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
862 gl_cv_func_printf_positions="guessing no";; 1130 gl_cv_func_printf_positions="guessing no";;
863 beos*) gl_cv_func_printf_positions="guessing no";; 1131 beos*)
864 # Guess yes on Android. 1132 gl_cv_func_printf_positions="guessing no";;
865 linux*-android*) gl_cv_func_printf_positions="guessing yes";; 1133 # Guess yes on Android.
866 # Guess no on native Windows. 1134 linux*-android*)
867 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 1135 gl_cv_func_printf_positions="guessing yes";;
868 *) gl_cv_func_printf_positions="guessing yes";; 1136 # Guess no on native Windows.
1137 mingw* | windows* | pw*)
1138 gl_cv_func_printf_positions="guessing no";;
1139 *)
1140 gl_cv_func_printf_positions="guessing yes";;
869 esac 1141 esac
870changequote([,])dnl 1142changequote([,])dnl
871 ]) 1143 ])
@@ -900,19 +1172,125 @@ int main ()
900 [ 1172 [
901changequote(,)dnl 1173changequote(,)dnl
902 case "$host_os" in 1174 case "$host_os" in
903 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 1175 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
904 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 1176 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
905 # Guess no on Android. 1177 # Guess no on Android.
906 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";; 1178 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";;
907 # Guess no on native Windows. 1179 # Guess no on native Windows.
908 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 1180 mingw* | windows* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
909 *) gl_cv_func_printf_flag_grouping="guessing yes";; 1181 *) gl_cv_func_printf_flag_grouping="guessing yes";;
910 esac 1182 esac
911changequote([,])dnl 1183changequote([,])dnl
912 ]) 1184 ])
913 ]) 1185 ])
914]) 1186])
915 1187
1188dnl Test whether the *printf family of functions supports POSIX/XSI format
1189dnl strings with the ' flag for grouping of decimal digits on integers,
1190dnl together with a precision.
1191dnl Result is gl_cv_func_printf_flag_grouping_int_precision.
1192
1193AC_DEFUN([gl_PRINTF_FLAG_GROUPING_INT_PRECISION],
1194[
1195 AC_REQUIRE([AC_PROG_CC])
1196 AC_REQUIRE([AC_CANONICAL_HOST])
1197 AC_CACHE_CHECK([whether printf supports grouping on integers with a precision],
1198 [gl_cv_func_printf_flag_grouping_int_precision],
1199 [
1200 dnl Prepare a guess, used when cross-compiling or when specific locales
1201 dnl are not available.
1202 case "$host_os" in
1203 # Guess no on FreeBSD, NetBSD, Solaris, Cygwin, Haiku.
1204 freebsd* | dragonfly* | netbsd* | solaris* | cygwin* | haiku*)
1205 gl_cv_func_printf_flag_grouping_int_precision="guessing no";;
1206 *)
1207 gl_cv_func_printf_flag_grouping_int_precision="guessing yes";;
1208 esac
1209 AC_RUN_IFELSE(
1210 [AC_LANG_SOURCE([[
1211#include <locale.h>
1212#include <stdio.h>
1213#include <string.h>
1214static char buf[100];
1215int main ()
1216{
1217 if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL
1218 || setlocale (LC_ALL, "fr_FR") != NULL
1219 || setlocale (LC_ALL, "fr_FR.ISO-8859-1") != NULL
1220 || setlocale (LC_ALL, "fr_FR.ISO8859-1") != NULL)
1221 {
1222 if (sprintf (buf, "%'.10d", 1000) < 0)
1223 return 1;
1224 if (strlen (buf) == 10 && strcmp (buf, "0000001000") != 0)
1225 /* The sprintf implementation has produced fewer than 10 digits. */
1226 return 2;
1227 else
1228 return 0;
1229 }
1230 return 3;
1231}]])],
1232 [gl_cv_func_printf_flag_grouping_int_precision=yes],
1233 [if test $? = 2; then
1234 gl_cv_func_printf_flag_grouping_int_precision=no
1235 fi
1236 ],
1237 [:])
1238 ])
1239])
1240
1241dnl Test whether the *printf family of functions supports POSIX/XSI format
1242dnl strings with the ' flag for grouping of decimal digits, when the thousands
1243dnl separator is a multibyte character (such as U+00A0 or U+202F in a UTF-8
1244dnl locale).
1245dnl Result is gl_cv_func_printf_flag_grouping_multibyte.
1246
1247AC_DEFUN([gl_PRINTF_FLAG_GROUPING_MULTIBYTE],
1248[
1249 AC_REQUIRE([AC_PROG_CC])
1250 AC_REQUIRE([AC_CANONICAL_HOST])
1251 AC_CACHE_CHECK([whether printf supports grouping with a multibyte separator],
1252 [gl_cv_func_printf_flag_grouping_multibyte],
1253 [
1254 dnl Prepare a guess, used when cross-compiling or when specific locales
1255 dnl are not available.
1256 case "$host_os" in
1257 # Guess no on NetBSD and Solaris 11 OpenIndiana.
1258 netbsd* | solaris*)
1259 gl_cv_func_printf_flag_grouping_multibyte="guessing no";;
1260 *)
1261 gl_cv_func_printf_flag_grouping_multibyte="guessing yes";;
1262 esac
1263 AC_RUN_IFELSE(
1264 [AC_LANG_SOURCE([[
1265#include <locale.h>
1266#include <stdio.h>
1267#include <string.h>
1268static char buf[100];
1269int main ()
1270{
1271 if (setlocale (LC_ALL, "fr_FR.UTF-8") == NULL)
1272 return 0;
1273 if (sprintf (buf, "%'.0f", 1000.0) < 0)
1274 return 1;
1275 if (strlen (localeconv ()->thousands_sep) > 1)
1276 {
1277 if (strlen (buf) <= 4 + 1)
1278 return 2;
1279 else
1280 return 3;
1281 }
1282 return 0;
1283}]])],
1284 [:],
1285 [case $? in
1286 2) gl_cv_func_printf_flag_grouping_multibyte=no ;;
1287 3) gl_cv_func_printf_flag_grouping_multibyte=yes ;;
1288 esac
1289 ],
1290 [:])
1291 ])
1292])
1293
916dnl Test whether the *printf family of functions supports the - flag correctly. 1294dnl Test whether the *printf family of functions supports the - flag correctly.
917dnl (ISO C99.) See 1295dnl (ISO C99.) See
918dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html> 1296dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html>
@@ -943,16 +1321,16 @@ int main ()
943 [ 1321 [
944changequote(,)dnl 1322changequote(,)dnl
945 case "$host_os" in 1323 case "$host_os" in
946 # Guess yes on HP-UX 11. 1324 # Guess yes on HP-UX 11.
947 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1325 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
948 # Guess no on HP-UX 10 and older. 1326 # Guess no on HP-UX 10 and older.
949 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; 1327 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
950 # Guess yes on Android. 1328 # Guess yes on Android.
951 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1329 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
952 # Guess yes on native Windows. 1330 # Guess yes on native Windows.
953 mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1331 mingw* | windows*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
954 # Guess yes otherwise. 1332 # Guess yes otherwise.
955 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; 1333 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
956 esac 1334 esac
957changequote([,])dnl 1335changequote([,])dnl
958 ]) 1336 ])
@@ -990,18 +1368,62 @@ int main ()
990 [ 1368 [
991changequote(,)dnl 1369changequote(,)dnl
992 case "$host_os" in 1370 case "$host_os" in
993 # Guess yes on glibc systems. 1371 # Guess yes on glibc systems.
994 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 1372 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
995 # Guess yes on musl systems. 1373 # Guess yes on musl systems.
996 *-musl*) gl_cv_func_printf_flag_zero="guessing yes";; 1374 *-musl* | midipix*) gl_cv_func_printf_flag_zero="guessing yes";;
997 # Guess yes on BeOS. 1375 # Guess yes on BeOS.
998 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 1376 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
999 # Guess no on Android. 1377 # Guess no on Android.
1000 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";; 1378 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";;
1001 # Guess no on native Windows. 1379 # Guess no on native Windows.
1002 mingw*) gl_cv_func_printf_flag_zero="guessing no";; 1380 mingw* | windows*) gl_cv_func_printf_flag_zero="guessing no";;
1003 # If we don't know, obey --enable-cross-guesses. 1381 # If we don't know, obey --enable-cross-guesses.
1004 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";; 1382 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";;
1383 esac
1384changequote([,])dnl
1385 ])
1386 ])
1387])
1388
1389dnl Test whether the *printf family of functions supports the # flag with a
1390dnl zero precision and a zero value in the 'x' and 'X' directives correctly.
1391dnl ISO C and POSIX specify that for the 'd', 'i', 'b', 'o', 'u', 'x', 'X'
1392dnl directives: "The result of converting a zero value with a precision of
1393dnl zero is no characters." But on Mac OS X 10.5, for the 'x', 'X' directives,
1394dnl when a # flag is present, the output is "0" instead of "".
1395dnl Result is gl_cv_func_printf_flag_alt_precision_zero.
1396
1397AC_DEFUN([gl_PRINTF_FLAG_ALT_PRECISION_ZERO],
1398[
1399 AC_REQUIRE([AC_PROG_CC])
1400 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1401 AC_CACHE_CHECK([whether printf supports the alternative flag with a zero precision],
1402 [gl_cv_func_printf_flag_alt_precision_zero],
1403 [
1404 AC_RUN_IFELSE(
1405 [AC_LANG_SOURCE([[
1406#include <stdio.h>
1407static char buf[10];
1408int main ()
1409{
1410 int result = 0;
1411 if (sprintf (buf, "%#.0x %d", 0, 33, 44) > 0 + 3)
1412 result |= 1;
1413 return result;
1414}]])],
1415 [gl_cv_func_printf_flag_alt_precision_zero=yes],
1416 [gl_cv_func_printf_flag_alt_precision_zero=no],
1417 [
1418changequote(,)dnl
1419 case "$host_os" in
1420 # Guess no only on macOS 10..12 systems.
1421 darwin[0-9] | darwin[0-9].* | \
1422 darwin1[0-9] | darwin1[0-9].* | \
1423 darwin2[0-1] | darwin2[0-1].*)
1424 gl_cv_func_printf_flag_alt_precision_zero="guessing no" ;;
1425 darwin*) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;;
1426 *) gl_cv_func_printf_flag_alt_precision_zero="guessing yes" ;;
1005 esac 1427 esac
1006changequote([,])dnl 1428changequote([,])dnl
1007 ]) 1429 ])
@@ -1054,12 +1476,12 @@ int main ()
1054changequote(,)dnl 1476changequote(,)dnl
1055 case "$host_os" in 1477 case "$host_os" in
1056 # Guess no only on Solaris, native Windows, and BeOS systems. 1478 # Guess no only on Solaris, native Windows, and BeOS systems.
1057 solaris*) gl_cv_func_printf_precision="guessing no" ;; 1479 solaris*) gl_cv_func_printf_precision="guessing no" ;;
1058 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 1480 mingw* | windows* | pw*) gl_cv_func_printf_precision="guessing no" ;;
1059 beos*) gl_cv_func_printf_precision="guessing no" ;; 1481 beos*) gl_cv_func_printf_precision="guessing no" ;;
1060 # Guess yes on Android. 1482 # Guess yes on Android.
1061 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;; 1483 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;;
1062 *) gl_cv_func_printf_precision="guessing yes" ;; 1484 *) gl_cv_func_printf_precision="guessing yes" ;;
1063 esac 1485 esac
1064changequote([,])dnl 1486changequote([,])dnl
1065 ]) 1487 ])
@@ -1166,10 +1588,6 @@ changequote(,)dnl
1166 *) gl_cv_func_printf_enomem="guessing no";; 1588 *) gl_cv_func_printf_enomem="guessing no";;
1167 esac 1589 esac
1168 ;; 1590 ;;
1169 # Guess yes on IRIX.
1170 irix*) gl_cv_func_printf_enomem="guessing yes";;
1171 # Guess yes on OSF/1.
1172 osf*) gl_cv_func_printf_enomem="guessing yes";;
1173 # Guess yes on BeOS. 1591 # Guess yes on BeOS.
1174 beos*) gl_cv_func_printf_enomem="guessing yes";; 1592 beos*) gl_cv_func_printf_enomem="guessing yes";;
1175 # Guess yes on Haiku. 1593 # Guess yes on Haiku.
@@ -1239,7 +1657,7 @@ changequote(,)dnl
1239 # Guess yes on glibc systems. 1657 # Guess yes on glibc systems.
1240 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1658 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1241 # Guess yes on musl systems. 1659 # Guess yes on musl systems.
1242 *-musl*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1660 *-musl* | midipix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1243 # Guess yes on FreeBSD >= 5. 1661 # Guess yes on FreeBSD >= 5.
1244 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1662 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1245 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1663 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
@@ -1261,11 +1679,6 @@ changequote(,)dnl
1261 # Guess yes on HP-UX >= 11. 1679 # Guess yes on HP-UX >= 11.
1262 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1680 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1263 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1681 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1264 # Guess yes on IRIX >= 6.5.
1265 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1266 # Guess yes on OSF/1 >= 5.
1267 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1268 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1269 # Guess yes on NetBSD >= 3. 1682 # Guess yes on NetBSD >= 3.
1270 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1683 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1271 gl_cv_func_snprintf_truncation_c99="guessing no";; 1684 gl_cv_func_snprintf_truncation_c99="guessing no";;
@@ -1275,7 +1688,7 @@ changequote(,)dnl
1275 # Guess yes on Android. 1688 # Guess yes on Android.
1276 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1689 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1277 # Guess no on native Windows. 1690 # Guess no on native Windows.
1278 mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1691 mingw* | windows*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1279 # If we don't know, obey --enable-cross-guesses. 1692 # If we don't know, obey --enable-cross-guesses.
1280 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";; 1693 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";;
1281 esac 1694 esac
@@ -1287,7 +1700,7 @@ changequote([,])dnl
1287dnl Test whether the return value of the snprintf function is the number 1700dnl Test whether the return value of the snprintf function is the number
1288dnl of bytes (excluding the terminating NUL) that would have been produced 1701dnl of bytes (excluding the terminating NUL) that would have been produced
1289dnl if the buffer had been large enough. (ISO C99, POSIX:2001) 1702dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
1290dnl For example, this test program fails on IRIX 6.5: 1703dnl For example, this test program fails on HP-UX 11.31 and Solaris 9:
1291dnl --------------------------------------------------------------------- 1704dnl ---------------------------------------------------------------------
1292dnl #include <stdio.h> 1705dnl #include <stdio.h>
1293dnl int main() 1706dnl int main()
@@ -1344,7 +1757,7 @@ changequote(,)dnl
1344 # Guess yes on glibc systems. 1757 # Guess yes on glibc systems.
1345 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1758 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1346 # Guess yes on musl systems. 1759 # Guess yes on musl systems.
1347 *-musl*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1760 *-musl* | midipix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1348 # Guess yes on FreeBSD >= 5. 1761 # Guess yes on FreeBSD >= 5.
1349 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1762 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1350 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1763 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
@@ -1372,7 +1785,8 @@ changequote(,)dnl
1372 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1785 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1373changequote([,])dnl 1786changequote([,])dnl
1374 # Guess yes on MSVC, no on mingw. 1787 # Guess yes on MSVC, no on mingw.
1375 mingw*) AC_EGREP_CPP([Known], [ 1788 windows*-msvc*) gl_cv_func_snprintf_retval_c99="guessing yes" ;;
1789 mingw* | windows*) AC_EGREP_CPP([Known], [
1376#ifdef _MSC_VER 1790#ifdef _MSC_VER
1377 Known 1791 Known
1378#endif 1792#endif
@@ -1401,8 +1815,14 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
1401 [ 1815 [
1402 AC_RUN_IFELSE( 1816 AC_RUN_IFELSE(
1403 [AC_LANG_SOURCE([[ 1817 [AC_LANG_SOURCE([[
1818#include <signal.h>
1404#include <stdio.h> 1819#include <stdio.h>
1405#include <string.h> 1820#include <string.h>
1821#if defined _WIN32 && !defined __CYGWIN__
1822# include <stdlib.h>
1823#else
1824# include <unistd.h>
1825#endif
1406#if HAVE_SNPRINTF 1826#if HAVE_SNPRINTF
1407# define my_snprintf snprintf 1827# define my_snprintf snprintf
1408#else 1828#else
@@ -1417,12 +1837,19 @@ static int my_snprintf (char *buf, int size, const char *format, ...)
1417 return ret; 1837 return ret;
1418} 1838}
1419#endif 1839#endif
1840static void
1841abort_handler (int sig)
1842{
1843 (void) sig;
1844 _exit (1);
1845}
1420static char fmtstring[10]; 1846static char fmtstring[10];
1421static char buf[100]; 1847static char buf[100];
1422int main () 1848int main ()
1423{ 1849{
1424 int count = -1; 1850 int count = -1;
1425 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 1851 signal (SIGABRT, abort_handler);
1852 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE >= 2)
1426 support %n in format strings in read-only memory but not in writable 1853 support %n in format strings in read-only memory but not in writable
1427 memory. */ 1854 memory. */
1428 strcpy (fmtstring, "%d %n"); 1855 strcpy (fmtstring, "%d %n");
@@ -1447,7 +1874,7 @@ int main ()
1447 ;; 1874 ;;
1448changequote(,)dnl 1875changequote(,)dnl
1449 # Guess yes on musl systems. 1876 # Guess yes on musl systems.
1450 *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";; 1877 *-musl* | midipix*) gl_cv_func_snprintf_directive_n="guessing yes";;
1451 # Guess yes on FreeBSD >= 5. 1878 # Guess yes on FreeBSD >= 5.
1452 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";; 1879 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";;
1453 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1880 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
@@ -1462,11 +1889,6 @@ changequote(,)dnl
1462 # Guess yes on AIX >= 4. 1889 # Guess yes on AIX >= 4.
1463 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; 1890 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
1464 aix*) gl_cv_func_snprintf_directive_n="guessing yes";; 1891 aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
1465 # Guess yes on IRIX >= 6.5.
1466 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
1467 # Guess yes on OSF/1 >= 5.
1468 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1469 osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
1470 # Guess yes on NetBSD >= 3. 1892 # Guess yes on NetBSD >= 3.
1471 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1893 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1472 gl_cv_func_snprintf_directive_n="guessing no";; 1894 gl_cv_func_snprintf_directive_n="guessing no";;
@@ -1476,7 +1898,7 @@ changequote(,)dnl
1476 # Guess no on Android. 1898 # Guess no on Android.
1477 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";; 1899 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";;
1478 # Guess no on native Windows. 1900 # Guess no on native Windows.
1479 mingw*) gl_cv_func_snprintf_directive_n="guessing no";; 1901 mingw* | windows*) gl_cv_func_snprintf_directive_n="guessing no";;
1480 # If we don't know, obey --enable-cross-guesses. 1902 # If we don't know, obey --enable-cross-guesses.
1481 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";; 1903 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";;
1482changequote([,])dnl 1904changequote([,])dnl
@@ -1524,11 +1946,11 @@ int main()
1524 [gl_cv_func_snprintf_size1=yes], 1946 [gl_cv_func_snprintf_size1=yes],
1525 [gl_cv_func_snprintf_size1=no], 1947 [gl_cv_func_snprintf_size1=no],
1526 [case "$host_os" in 1948 [case "$host_os" in
1527 # Guess yes on Android. 1949 # Guess yes on Android.
1528 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;; 1950 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;;
1529 # Guess yes on native Windows. 1951 # Guess yes on native Windows.
1530 mingw*) gl_cv_func_snprintf_size1="guessing yes" ;; 1952 mingw* | windows*) gl_cv_func_snprintf_size1="guessing yes" ;;
1531 *) gl_cv_func_snprintf_size1="guessing yes" ;; 1953 *) gl_cv_func_snprintf_size1="guessing yes" ;;
1532 esac 1954 esac
1533 ]) 1955 ])
1534 ]) 1956 ])
@@ -1601,128 +2023,322 @@ int main()
1601 [ 2023 [
1602changequote(,)dnl 2024changequote(,)dnl
1603 case "$host_os" in 2025 case "$host_os" in
1604 # Guess yes on glibc systems. 2026 # Guess yes on glibc systems.
1605 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2027 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1606 # Guess yes on musl systems. 2028 # Guess yes on musl systems.
1607 *-musl*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2029 *-musl* | midipix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1608 # Guess yes on FreeBSD >= 5. 2030 # Guess yes on FreeBSD >= 5.
1609 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2031 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1610 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2032 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1611 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2033 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1612 # Guess yes on Mac OS X >= 10.3. 2034 # Guess yes on Mac OS X >= 10.3.
1613 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2035 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1614 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2036 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1615 # Guess yes on Cygwin. 2037 # Guess yes on Cygwin.
1616 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2038 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1617 # Guess yes on Solaris >= 2.6. 2039 # Guess yes on Solaris >= 2.6.
1618 solaris2.[0-5] | solaris2.[0-5].*) 2040 solaris2.[0-5] | solaris2.[0-5].*)
1619 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2041 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1620 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2042 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1621 # Guess yes on AIX >= 4. 2043 # Guess yes on AIX >= 4.
1622 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2044 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1623 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2045 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1624 # Guess yes on IRIX >= 6.5. 2046 # Guess yes on NetBSD >= 3.
1625 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1626 # Guess yes on NetBSD >= 3.
1627 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 2047 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1628 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 2048 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1629 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2049 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1630 # Guess yes on BeOS. 2050 # Guess yes on BeOS.
1631 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2051 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1632 # Guess yes on Android. 2052 # Guess yes on Android.
1633 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2053 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1634 # Guess yes on native Windows. 2054 # Guess yes on native Windows.
1635 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 2055 mingw* | windows* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1636 # If we don't know, obey --enable-cross-guesses. 2056 # If we don't know, obey --enable-cross-guesses.
1637 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";; 2057 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";;
1638 esac 2058 esac
1639changequote([,])dnl 2059changequote([,])dnl
1640 ]) 2060 ])
1641 ]) 2061 ])
1642]) 2062])
1643 2063
2064dnl Test whether the swprintf function works correctly when it produces output
2065dnl that contains null wide characters.
2066dnl Result is gl_cv_func_swprintf_works.
2067
2068AC_DEFUN([gl_SWPRINTF_WORKS],
2069[
2070 AC_REQUIRE([AC_PROG_CC])
2071 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2072 AC_CHECK_FUNCS_ONCE([swprintf])
2073 AC_CACHE_CHECK([whether swprintf works],
2074 [gl_cv_func_swprintf_works],
2075 [
2076 AC_RUN_IFELSE(
2077 [AC_LANG_SOURCE([[
2078#ifndef __USE_MINGW_ANSI_STDIO
2079# define __USE_MINGW_ANSI_STDIO 1
2080#endif
2081#include <stdio.h>
2082#include <wchar.h>
2083int main()
2084{
2085 int result = 0;
2086 { /* This test fails on musl libc 1.2.3, FreeBSD, NetBSD, OpenBSD, macOS, AIX. */
2087 wchar_t buf[5] = { 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF };
2088 int ret = swprintf (buf, 4, L"%cz", '\0');
2089 /* Expected result:
2090 ret = 2, buf[0] = 0x0, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xbeef
2091 musl libc 1.2.3:
2092 ret = 2, buf[0] = 0x0, buf[1] = 0x0, buf[2] = 0x0, buf[3] = 0x0
2093 Reported at <https://www.openwall.com/lists/musl/2023/03/22/9>.
2094 FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2:
2095 ret = 2, buf[0] = 0x0, buf[1] = 0xbeef, buf[2] = 0xbeef, buf[3] = 0xbeef
2096 */
2097 if (ret < 0 || buf[1] != 'z')
2098 result |= 1;
2099 }
2100 { /* This test fails on mingw. */
2101 wchar_t buf[2];
2102 int ret = swprintf (buf, 2, L"%lc", (wint_t)0);
2103 /* Expected: ret = 1
2104 mingw: ret = 0
2105 */
2106 if (ret != 1)
2107 result |= 2;
2108 }
2109 return result;
2110}]])],
2111 [gl_cv_func_swprintf_works=yes],
2112 [gl_cv_func_swprintf_works=no],
2113 [case "$host_os" in
2114 # Guess yes on glibc systems.
2115 *-gnu* | gnu*) gl_cv_func_swprintf_works="guessing yes";;
2116 # Guess no on musl systems.
2117 *-musl* | midipix*) gl_cv_func_swprintf_works="guessing no";;
2118 # Guess no on FreeBSD, NetBSD, OpenBSD, macOS, AIX.
2119 freebsd* | midnightbsd* | netbsd* | openbsd* | darwin* | aix*)
2120 gl_cv_func_swprintf_works="guessing no";;
2121 # Guess no on native Windows.
2122 mingw* | windows* | pw*) gl_cv_func_swprintf_works="guessing no";;
2123 # If we don't know, obey --enable-cross-guesses.
2124 *) gl_cv_func_swprintf_works="$gl_cross_guess_normal";;
2125 esac
2126 ])
2127 ])
2128])
2129
2130dnl Test whether the *wprintf family of functions supports the 'a' and 'A'
2131dnl conversion specifier for hexadecimal output of 'long double' numbers.
2132dnl (ISO C99, POSIX:2001)
2133dnl Result is gl_cv_func_swprintf_directive_la.
2134
2135AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LA],
2136[
2137 AC_REQUIRE([AC_PROG_CC])
2138 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2139 AC_CACHE_CHECK([whether swprintf supports the 'La' and 'LA' directives],
2140 [gl_cv_func_swprintf_directive_la],
2141 [
2142 AC_RUN_IFELSE(
2143 [AC_LANG_SOURCE([[
2144#include <stdio.h>
2145#include <wchar.h>
2146static wchar_t buf[100];
2147int main ()
2148{
2149 int result = 0;
2150 /* This catches a glibc 2.15, Haiku 2022, NetBSD 10.0 bug. */
2151 if (swprintf (buf, sizeof (buf) / sizeof (wchar_t),
2152 L"%La %d", 3.1416015625L, 33, 44, 55) < 0
2153 || (wcscmp (buf, L"0x1.922p+1 33") != 0
2154 && wcscmp (buf, L"0x3.244p+0 33") != 0
2155 && wcscmp (buf, L"0x6.488p-1 33") != 0
2156 && wcscmp (buf, L"0xc.91p-2 33") != 0))
2157 result |= 1;
2158 return result;
2159}]])],
2160 [gl_cv_func_swprintf_directive_la=yes],
2161 [gl_cv_func_swprintf_directive_la=no],
2162 [case "$host_os" in
2163 # Guess yes on glibc >= 2.17 systems.
2164 *-gnu* | gnu*)
2165 AC_EGREP_CPP([Unlucky], [
2166 #include <features.h>
2167 #ifdef __GNU_LIBRARY__
2168 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16) || (__GLIBC__ > 2)) && !defined __UCLIBC__
2169 Unlucky
2170 #endif
2171 #endif
2172 ],
2173 [gl_cv_func_swprintf_directive_la="guessing yes"],
2174 [gl_cv_func_swprintf_directive_la="guessing no"])
2175 ;;
2176 # Guess yes on musl systems.
2177 *-musl* | midipix*) gl_cv_func_swprintf_directive_la="guessing yes";;
2178 # Guess yes on Android.
2179 linux*-android*) gl_cv_func_swprintf_directive_la="guessing yes";;
2180 # Guess no on NetBSD.
2181 netbsd*) gl_cv_func_swprintf_directive_la="guessing no";;
2182 # Guess no on native Windows.
2183 mingw* | windows*) gl_cv_func_swprintf_directive_la="guessing no";;
2184 # If we don't know, obey --enable-cross-guesses.
2185 *) gl_cv_func_swprintf_directive_la="$gl_cross_guess_normal";;
2186 esac
2187 ])
2188 ])
2189])
2190
2191dnl Test whether the *wprintf family of functions supports the 'lc' conversion
2192dnl specifier for all wide characters.
2193dnl (ISO C11, POSIX:2001)
2194dnl Result is gl_cv_func_swprintf_directive_lc.
2195
2196AC_DEFUN([gl_SWPRINTF_DIRECTIVE_LC],
2197[
2198 AC_REQUIRE([AC_PROG_CC])
2199 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
2200 AC_CACHE_CHECK([whether swprintf supports the 'lc' directive],
2201 [gl_cv_func_swprintf_directive_lc],
2202 [
2203 AC_RUN_IFELSE(
2204 [AC_LANG_SOURCE([[
2205#include <stdio.h>
2206#include <wchar.h>
2207static wchar_t buf[100];
2208static wint_t L_invalid = (wchar_t) 0x76543210;
2209int main ()
2210{
2211 int result = 0;
2212 /* This catches a musl libc 1.2.4, Android bug.
2213 Reported at <https://www.openwall.com/lists/musl/2023/06/12/3>. */
2214 if (swprintf (buf, sizeof (buf) / sizeof (wchar_t),
2215 L"%lc %d", L_invalid, 33, 44, 55) < 0)
2216 result |= 1;
2217 return result;
2218}]])],
2219 [gl_cv_func_swprintf_directive_lc=yes],
2220 [gl_cv_func_swprintf_directive_lc=no],
2221 [case "$host_os" in
2222 # Guess yes on glibc systems.
2223 *-gnu* | gnu*) gl_cv_func_swprintf_directive_lc="guessing yes";;
2224 # Guess no on musl systems.
2225 *-musl* | midipix*) gl_cv_func_swprintf_directive_lc="guessing no";;
2226 # Guess no on Android.
2227 linux*-android*) gl_cv_func_swprintf_directive_lc="guessing no";;
2228 # Guess yes on native Windows.
2229 mingw* | windows*) gl_cv_func_swprintf_directive_lc="guessing yes";;
2230 # If we don't know, obey --enable-cross-guesses.
2231 *) gl_cv_func_swprintf_directive_lc="$gl_cross_guess_normal";;
2232 esac
2233 ])
2234 ])
2235])
2236
1644dnl The results of these tests on various platforms are: 2237dnl The results of these tests on various platforms are:
1645dnl 2238dnl
1646dnl 1 = gl_PRINTF_SIZES_C99 2239dnl 1 = gl_PRINTF_SIZES_C99
1647dnl 2 = gl_PRINTF_LONG_DOUBLE 2240dnl 2 = gl_PRINTF_SIZES_C23
1648dnl 3 = gl_PRINTF_INFINITE 2241dnl 3 = gl_PRINTF_LONG_DOUBLE
1649dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE 2242dnl 4 = gl_PRINTF_INFINITE
1650dnl 5 = gl_PRINTF_DIRECTIVE_A 2243dnl 5 = gl_PRINTF_INFINITE_LONG_DOUBLE
1651dnl 6 = gl_PRINTF_DIRECTIVE_F 2244dnl 6 = gl_PRINTF_DIRECTIVE_A
1652dnl 7 = gl_PRINTF_DIRECTIVE_N 2245dnl 7 = gl_PRINTF_DIRECTIVE_B
1653dnl 8 = gl_PRINTF_DIRECTIVE_LS 2246dnl 8 = gl_PRINTF_DIRECTIVE_UPPERCASE_B
1654dnl 9 = gl_PRINTF_POSITIONS 2247dnl 9 = gl_PRINTF_DIRECTIVE_F
1655dnl 10 = gl_PRINTF_FLAG_GROUPING 2248dnl 10 = gl_PRINTF_DIRECTIVE_N
1656dnl 11 = gl_PRINTF_FLAG_LEFTADJUST 2249dnl 11 = gl_PRINTF_DIRECTIVE_LS
1657dnl 12 = gl_PRINTF_FLAG_ZERO 2250dnl 12 = gl_PRINTF_DIRECTIVE_LC
1658dnl 13 = gl_PRINTF_PRECISION 2251dnl 13 = gl_PRINTF_POSITIONS
1659dnl 14 = gl_PRINTF_ENOMEM 2252dnl 14 = gl_PRINTF_FLAG_GROUPING
1660dnl 15 = gl_SNPRINTF_PRESENCE 2253dnl 15 = gl_PRINTF_FLAG_GROUPING_INT_PRECISION
1661dnl 16 = gl_SNPRINTF_TRUNCATION_C99 2254dnl 16 = gl_PRINTF_FLAG_GROUPING_MULTIBYTE
1662dnl 17 = gl_SNPRINTF_RETVAL_C99 2255dnl 17 = gl_PRINTF_FLAG_LEFTADJUST
1663dnl 18 = gl_SNPRINTF_DIRECTIVE_N 2256dnl 18 = gl_PRINTF_FLAG_ZERO
1664dnl 19 = gl_SNPRINTF_SIZE1 2257dnl 19 = gl_PRINTF_FLAG_ALT_PRECISION_ZERO
1665dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99 2258dnl 20 = gl_PRINTF_PRECISION
2259dnl 21 = gl_PRINTF_ENOMEM
2260dnl 22 = gl_SNPRINTF_PRESENCE
2261dnl 23 = gl_SNPRINTF_TRUNCATION_C99
2262dnl 24 = gl_SNPRINTF_RETVAL_C99
2263dnl 25 = gl_SNPRINTF_DIRECTIVE_N
2264dnl 26 = gl_SNPRINTF_SIZE1
2265dnl 27 = gl_VSNPRINTF_ZEROSIZE_C99
2266dnl 28 = gl_SWPRINTF_WORKS
2267dnl 29 = gl_SWPRINTF_DIRECTIVE_LA
2268dnl 30 = gl_SWPRINTF_DIRECTIVE_LC
1666dnl 2269dnl
1667dnl 1 = checking whether printf supports size specifiers as in C99... 2270dnl 1 = checking whether printf supports size specifiers as in C99...
1668dnl 2 = checking whether printf supports 'long double' arguments... 2271dnl 2 = checking whether printf supports size specifiers as in C23...
1669dnl 3 = checking whether printf supports infinite 'double' arguments... 2272dnl 3 = checking whether printf supports 'long double' arguments...
1670dnl 4 = checking whether printf supports infinite 'long double' arguments... 2273dnl 4 = checking whether printf supports infinite 'double' arguments...
1671dnl 5 = checking whether printf supports the 'a' and 'A' directives... 2274dnl 5 = checking whether printf supports infinite 'long double' arguments...
1672dnl 6 = checking whether printf supports the 'F' directive... 2275dnl 6 = checking whether printf supports the 'a' and 'A' directives...
1673dnl 7 = checking whether printf supports the 'n' directive... 2276dnl 7 = checking whether printf supports the 'b' directive...
1674dnl 8 = checking whether printf supports the 'ls' directive... 2277dnl 8 = checking whether printf supports the 'B' directive...
1675dnl 9 = checking whether printf supports POSIX/XSI format strings with positions... 2278dnl 9 = checking whether printf supports the 'F' directive...
1676dnl 10 = checking whether printf supports the grouping flag... 2279dnl 10 = checking whether printf supports the 'n' directive...
1677dnl 11 = checking whether printf supports the left-adjust flag correctly... 2280dnl 11 = checking whether printf supports the 'ls' directive...
1678dnl 12 = checking whether printf supports the zero flag correctly... 2281dnl 12 = checking whether printf supports the 'lc' directive correctly...
1679dnl 13 = checking whether printf supports large precisions... 2282dnl 13 = checking whether printf supports POSIX/XSI format strings with positions...
1680dnl 14 = checking whether printf survives out-of-memory conditions... 2283dnl 14 = checking whether printf supports the grouping flag...
1681dnl 15 = checking for snprintf... 2284dnl 15 = checking whether printf supports grouping on integers with a precision...
1682dnl 16 = checking whether snprintf truncates the result as in C99... 2285dnl 16 = checking whether printf supports grouping with a multibyte separator...
1683dnl 17 = checking whether snprintf returns a byte count as in C99... 2286dnl 17 = checking whether printf supports the left-adjust flag correctly...
1684dnl 18 = checking whether snprintf fully supports the 'n' directive... 2287dnl 18 = checking whether printf supports the zero flag correctly...
1685dnl 19 = checking whether snprintf respects a size of 1... 2288dnl 19 = checking whether printf supports the alternative flag with a zero precision...
1686dnl 20 = checking whether vsnprintf respects a zero size as in C99... 2289dnl 20 = checking whether printf supports large precisions...
2290dnl 21 = checking whether printf survives out-of-memory conditions...
2291dnl 22 = checking for snprintf...
2292dnl 23 = checking whether snprintf truncates the result as in C99...
2293dnl 24 = checking whether snprintf returns a byte count as in C99...
2294dnl 25 = checking whether snprintf fully supports the 'n' directive...
2295dnl 26 = checking whether snprintf respects a size of 1...
2296dnl 27 = checking whether vsnprintf respects a zero size as in C99...
2297dnl 28 = checking whether swprintf works...
2298dnl 29 = checking whether swprintf supports the 'La' and 'LA' directives...
2299dnl 30 = checking whether swprintf supports the 'lc' directive...
1687dnl 2300dnl
1688dnl . = yes, # = no. 2301dnl . = yes, # = no.
1689dnl 2302dnl
1690dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2303dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
1691dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 2304dnl musl libc 1.2.3 . # . . . . # # . . . # . . . . . . . . . . . . . . . # . #
1692dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 2305dnl glibc 2.35 . # . . . . . . . . . . . . # . . . . . . . . . . . . . . .
1693dnl FreeBSD 13.0 . . . . # . . . . . . . . # . . . . . . 2306dnl glibc 2.5 . # . . . . # # . . . . . . # . . . . . . . . . . . . . # .
1694dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 2307dnl glibc 2.3.6 . # . . . # # # . . . . . . . . . . . . . . . . . . . . # .
1695dnl Mac OS X 10.13.5 . . . # # . # . . . . . . . . . . # . . 2308dnl FreeBSD 14.0 . . . . . # . . . . . . . . # . . . . . # . . . . . . # . #
1696dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . 2309dnl FreeBSD 13.0 . # . . . # # # . . . . . . # . . . . . # . . . . . . # . #
1697dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 2310dnl FreeBSD 5.4, 6.1 . # . . . # # # . . . . . . . . . # ? . # . . . . . . # ? ?
1698dnl OpenBSD 6.0, 6.7 . . . . # . . . . . . . . # . . . . . . 2311dnl Mac OS X 10.13.5 . # . . # # # # . # . . . . ? ? . . . . . . . . # . . # ? ?
1699dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 2312dnl Mac OS X 10.5.8 . # . . # # # # . . . . . . ? ? . # # . . . . . . . . # ? ?
1700dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 2313dnl Mac OS X 10.3.9 . # . . . # # # . . . . . . ? ? . # # . # . . . . . . # ? ?
1701dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 2314dnl OpenBSD 6.0, 6.7 . # . . . # # # . . . . . . . . . . . . # . . . . . . # . #
1702dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 2315dnl OpenBSD 3.9, 4.0 . # . # # # # # # . # . . # ? ? . # ? . # . . . . . . # ? ?
1703dnl Solaris 11.4 . . # # # . . # . . . # . . . . . . . . 2316dnl Cygwin 1.7.0 (2009) . # . . # . # # . . ? ? . . ? ? . . ? . ? . . . . . . ? ? ?
1704dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . . 2317dnl Cygwin 1.5.25 (2008) . # . . # # # # . . # ? . . ? ? . . ? . # . . . . . . ? ? ?
1705dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . . 2318dnl Cygwin 1.5.19 (2006) # # . . # # # # # . # ? . # ? ? . # ? # # . . . . . . ? ? ?
1706dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . 2319dnl Solaris 11.4 . # . # # # # # . . # . . . # # . # . . . . . . . . . . # .
1707dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . 2320dnl Solaris 11.3 . # . . . # # # . . # . . . ? ? . . . . . . . . . . . . # .
1708dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 2321dnl Solaris 11.0 . # . # # # # # . . # . . . ? ? . # . . . . . . . . . ? ? ?
1709dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . . 2322dnl Solaris 10 . # . # # # # # . . # . . . # # . # . # . . . . . . . . # .
1710dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . 2323dnl Solaris 2.6 ... 9 # # . # # # # # # . # . . . ? ? . # ? # . . . # . . . ? ? ?
1711dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . . 2324dnl Solaris 2.5.1 # # . # # # # # # . # . . . ? ? . # ? . . # # # # # # ? ? ?
1712dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . 2325dnl AIX 7.1 . # . # # # # # . . . . . . . . . # . # . . . . . . . # . .
1713dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # 2326dnl AIX 5.2 . # . # # # # # . . . . . . ? ? . # ? . . . . . . . . # ? ?
1714dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # 2327dnl AIX 4.3.2, 5.1 # # . # # # # # # . . . . . ? ? . # ? . . . . # . . . # ? ?
1715dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 2328dnl HP-UX 11.31 . # . . . # # # . . . ? . . ? ? . # ? . . . . # # . . ? ? ?
1716dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 2329dnl HP-UX 11.{00,11,23} # # . . . # # # # . . ? . . ? ? . # ? . . . . # # . # ? ? ?
1717dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 2330dnl HP-UX 10.20 # # . # . # # # # . ? ? . . ? ? # # ? . . . . # # ? # ? ? ?
1718dnl NetBSD 9.0 . . . . # . . . . . . . . . . . . . . . 2331dnl IRIX 6.5 # # . # # # # # # . # . . . ? ? . # ? . . . . # . . . # ? ?
1719dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . 2332dnl OSF/1 5.1 # # . # # # # # # . . ? . . ? ? . # ? . . . . # . . # ? ? ?
1720dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 2333dnl OSF/1 4.0d # # . # # # # # # . . ? . . ? ? . # ? . . # # # # # # ? ? ?
1721dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 2334dnl NetBSD 9.0 . # . . . # # # . . . . . . # # . . . . . . . . . . . # . #
1722dnl Haiku . . . # # # . # . . . . . ? . . ? . . . 2335dnl NetBSD 5.0 . # . . # # # # . . . . . . ? ? . # ? . # . . . . . . # ? ?
1723dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . 2336dnl NetBSD 4.0 . # ? ? ? ? # # ? . ? . . ? ? ? ? ? ? ? ? . . . ? ? ? # ? ?
1724dnl Android 4.3 . . # # # # # # . # . # . # . . . # . . 2337dnl NetBSD 3.0 . # . . . # # # # . ? . # # ? ? ? # ? . # . . . . . . # ? ?
1725dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . 2338dnl Haiku . # . . # # # # # . # ? . . # . . . ? . ? . . ? . . . . # .
1726dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . 2339dnl BeOS # # # . # # # # # . ? ? # . ? ? ? . ? # ? . . ? . . . ? ? ?
1727dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . 2340dnl Android 4.3 . # . # # # # # # # # ? . # ? ? . # ? . # . . . # . . ? ? ?
1728dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . . 2341dnl old mingw / msvcrt # # # # # # # # # . . ? # # ? ? . # ? # ? . # # # . . # ? ?
2342dnl MSVC 9 # # # # # # # # # # . ? # # ? ? . # ? # ? # # # # . . # ? ?
2343dnl mingw 2009-2011 . # # . # . # # . . . ? # # ? ? . . ? . ? . . . . . . # ? ?
2344dnl mingw-w64 2011 # # # # # # # # # . . ? # # ? ? . # ? # ? . # # # . . # ? ?
diff --git a/gl/m4/pthread-once.m4 b/gl/m4/pthread-once.m4
new file mode 100644
index 00000000..9080363d
--- /dev/null
+++ b/gl/m4/pthread-once.m4
@@ -0,0 +1,83 @@
1# pthread-once.m4
2# serial 6
3dnl Copyright (C) 2019-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_PTHREAD_ONCE],
10[
11 AC_REQUIRE([gl_PTHREAD_H])
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([gl_PTHREADLIB])
14
15 if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \
16 && test $gl_threads_api = windows; then
17 dnl Choose function names that don't conflict with the mingw-w64 winpthreads
18 dnl library.
19 REPLACE_PTHREAD_ONCE=1
20 PTHREAD_ONCE_LIB=
21 else
22 if test $HAVE_PTHREAD_H = 0; then
23 HAVE_PTHREAD_ONCE=0
24 PTHREAD_ONCE_LIB=
25 else
26 dnl Work around Cygwin 3.5.3 bug.
27 AC_CACHE_CHECK([whether pthread_once works],
28 [gl_cv_func_pthread_once_works],
29 [case "$host_os" in
30 cygwin*) gl_cv_func_pthread_once_works="guessing no" ;;
31 *) gl_cv_func_pthread_once_works="yes" ;;
32 esac
33 ])
34 case "$gl_cv_func_pthread_once_works" in
35 *yes) ;;
36 *) REPLACE_PTHREAD_ONCE=1 ;;
37 esac
38 dnl Determine whether linking requires $(LIBPMULTITHREAD) or only
39 dnl $(LIBPTHREAD).
40 if test -z "$LIBPTHREAD" && test -n "$LIBPMULTITHREAD"; then
41 AC_CACHE_CHECK([whether pthread_once can be used without linking with libpthread],
42 [gl_cv_func_pthread_once_no_lib],
43 [AC_RUN_IFELSE(
44 [AC_LANG_PROGRAM(
45 [[#include <pthread.h>
46 static pthread_once_t a_once = PTHREAD_ONCE_INIT;
47 static int a;
48 static void a_init (void) { a = 8647; }
49 ]],
50 [[if (pthread_once (&a_once, a_init)) return 1;
51 if (a != 8647) return 2;
52 return 0;
53 ]])],
54 [gl_cv_func_pthread_once_no_lib=yes],
55 [gl_cv_func_pthread_once_no_lib=no],
56 [case "$host_os" in
57 # Guess no on glibc.
58 *-gnu* | gnu*)
59 gl_cv_func_pthread_once_no_lib="guessing no" ;;
60 # Guess no on FreeBSD.
61 freebsd* | dragonfly* | midnightbsd*)
62 gl_cv_func_pthread_once_no_lib="guessing no" ;;
63 # Guess yes otherwise.
64 *)
65 gl_cv_func_pthread_once_no_lib="guessing yes" ;;
66 esac
67 ])
68 ])
69 case "$gl_cv_func_pthread_once_no_lib" in
70 *yes) PTHREAD_ONCE_LIB="$LIBPTHREAD" ;;
71 *) PTHREAD_ONCE_LIB="$LIBPMULTITHREAD" ;;
72 esac
73 dnl Expected result:
74 dnl PTHREAD_ONCE_LIB is $(LIBPMULTITHREAD) on glibc < 2.34, FreeBSD.
75 dnl PTHREAD_ONCE_LIB is $(LIBPTHREAD) in particular on
76 dnl musl libc, macOS, NetBSD, Solaris, Cygwin, Haiku, Android.
77 else
78 PTHREAD_ONCE_LIB="$LIBPTHREAD"
79 fi
80 fi
81 fi
82 AC_SUBST([PTHREAD_ONCE_LIB])
83])
diff --git a/gl/m4/pthread-spin.m4 b/gl/m4/pthread-spin.m4
new file mode 100644
index 00000000..17fa3b5e
--- /dev/null
+++ b/gl/m4/pthread-spin.m4
@@ -0,0 +1,72 @@
1# pthread-spin.m4
2# serial 8
3dnl Copyright (C) 2019-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_PTHREAD_SPIN],
10[
11 AC_REQUIRE([gl_PTHREAD_H_PART1])
12 AC_REQUIRE([AC_CANONICAL_HOST])
13
14 if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \
15 && test $gl_threads_api = windows; then
16 dnl Choose function names that don't conflict with the mingw-w64 winpthreads
17 dnl library.
18 REPLACE_PTHREAD_SPIN_INIT=1
19 REPLACE_PTHREAD_SPIN_LOCK=1
20 REPLACE_PTHREAD_SPIN_TRYLOCK=1
21 REPLACE_PTHREAD_SPIN_UNLOCK=1
22 REPLACE_PTHREAD_SPIN_DESTROY=1
23 else
24 if test $HAVE_PTHREAD_H = 0 || test $HAVE_PTHREAD_SPINLOCK_T = 0; then
25 HAVE_PTHREAD_SPIN_INIT=0
26 HAVE_PTHREAD_SPIN_LOCK=0
27 HAVE_PTHREAD_SPIN_TRYLOCK=0
28 HAVE_PTHREAD_SPIN_UNLOCK=0
29 HAVE_PTHREAD_SPIN_DESTROY=0
30 else
31 dnl Test whether the gnulib module 'threadlib' is in use.
32 dnl Some packages like Emacs use --avoid=threadlib.
33 dnl Write the symbol in such a way that it does not cause 'aclocal' to pick
34 dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/.
35 m4_ifdef([gl_][THREADLIB], [
36 AC_REQUIRE([gl_][THREADLIB])
37 dnl Test whether the functions actually exist.
38 dnl FreeBSD 5.2.1 declares them but does not define them.
39 AC_CACHE_CHECK([for pthread_spin_init],
40 [gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD],
41 [gl_saved_LIBS="$LIBS"
42 LIBS="$LIBS $LIBMULTITHREAD"
43 AC_LINK_IFELSE(
44 [AC_LANG_PROGRAM(
45 [[#include <pthread.h>
46 ]],
47 [[pthread_spinlock_t lock;
48 return pthread_spin_init (&lock, 0);
49 ]])
50 ],
51 [gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD=yes],
52 [gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD=no])
53 LIBS="$gl_saved_LIBS"
54 ])
55 if test $gl_cv_func_pthread_spin_init_in_LIBMULTITHREAD != yes; then
56 HAVE_PTHREAD_SPIN_INIT=0
57 REPLACE_PTHREAD_SPIN_INIT=1
58 HAVE_PTHREAD_SPIN_LOCK=0
59 REPLACE_PTHREAD_SPIN_LOCK=1
60 HAVE_PTHREAD_SPIN_TRYLOCK=0
61 REPLACE_PTHREAD_SPIN_TRYLOCK=1
62 HAVE_PTHREAD_SPIN_UNLOCK=0
63 REPLACE_PTHREAD_SPIN_UNLOCK=1
64 HAVE_PTHREAD_SPIN_DESTROY=0
65 REPLACE_PTHREAD_SPIN_DESTROY=1
66 fi
67 ], [
68 :
69 ])
70 fi
71 fi
72])
diff --git a/gl/m4/pthread_h.m4 b/gl/m4/pthread_h.m4
new file mode 100644
index 00000000..f01dc3d3
--- /dev/null
+++ b/gl/m4/pthread_h.m4
@@ -0,0 +1,293 @@
1# pthread_h.m4
2# serial 11
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_PTHREAD_H_PART1],
10[
11 dnl Ensure to expand the default settings once only, before all statements
12 dnl that occur in other macros.
13 AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
14
15 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_REQUIRE([gl_PTHREADLIB])
17
18 gl_CHECK_NEXT_HEADERS([pthread.h])
19 if test $ac_cv_header_pthread_h = yes; then
20 HAVE_PTHREAD_H=1
21 dnl On mingw, if --enable-threads=windows or gl_AVOID_WINPTHREAD is used,
22 dnl ignore the <pthread.h> from the mingw-w64 winpthreads library.
23 m4_ifdef([gl_][THREADLIB], [
24 AC_REQUIRE([gl_][THREADLIB])
25 if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \
26 && test $gl_threads_api = windows; then
27 HAVE_PTHREAD_H=0
28 fi
29 ])
30 else
31 HAVE_PTHREAD_H=0
32 fi
33 AC_SUBST([HAVE_PTHREAD_H])
34
35 AC_CHECK_TYPES([pthread_t, pthread_spinlock_t], [], [],
36 [AC_INCLUDES_DEFAULT[
37 #if HAVE_PTHREAD_H
38 #include <pthread.h>
39 #endif]])
40 if test $ac_cv_type_pthread_t != yes; then
41 HAVE_PTHREAD_T=0
42 fi
43 if test $ac_cv_type_pthread_spinlock_t != yes; then
44 HAVE_PTHREAD_SPINLOCK_T=0
45 fi
46])
47
48AC_DEFUN([gl_PTHREAD_H],
49[
50 AC_REQUIRE([gl_PTHREAD_H_PART1])
51
52 dnl Set HAVE_PTHREAD_SPIN_INIT, REPLACE_PTHREAD_SPIN_INIT.
53 gl_PTHREAD_SPIN
54
55 dnl Constants may be defined as C preprocessor macros or as enum items.
56
57 AC_CACHE_CHECK([for PTHREAD_CREATE_DETACHED],
58 [gl_cv_const_PTHREAD_CREATE_DETACHED],
59 [AC_COMPILE_IFELSE(
60 [AC_LANG_PROGRAM(
61 [[#include <pthread.h>
62 int x = PTHREAD_CREATE_DETACHED;
63 ]],
64 [[]])],
65 [gl_cv_const_PTHREAD_CREATE_DETACHED=yes],
66 [gl_cv_const_PTHREAD_CREATE_DETACHED=no])
67 ])
68 if test $gl_cv_const_PTHREAD_CREATE_DETACHED != yes; then
69 HAVE_PTHREAD_CREATE_DETACHED=0
70 fi
71
72 AC_CACHE_CHECK([for PTHREAD_MUTEX_RECURSIVE],
73 [gl_cv_const_PTHREAD_MUTEX_RECURSIVE],
74 [AC_COMPILE_IFELSE(
75 [AC_LANG_PROGRAM(
76 [[#include <pthread.h>
77 int x = PTHREAD_MUTEX_RECURSIVE;
78 ]],
79 [[]])],
80 [gl_cv_const_PTHREAD_MUTEX_RECURSIVE=yes],
81 [gl_cv_const_PTHREAD_MUTEX_RECURSIVE=no])
82 ])
83 if test $gl_cv_const_PTHREAD_MUTEX_RECURSIVE != yes; then
84 HAVE_PTHREAD_MUTEX_RECURSIVE=0
85 fi
86
87 AC_CACHE_CHECK([for PTHREAD_MUTEX_ROBUST],
88 [gl_cv_const_PTHREAD_MUTEX_ROBUST],
89 [AC_COMPILE_IFELSE(
90 [AC_LANG_PROGRAM(
91 [[#include <pthread.h>
92 int x = PTHREAD_MUTEX_ROBUST;
93 ]],
94 [[]])],
95 [gl_cv_const_PTHREAD_MUTEX_ROBUST=yes],
96 [gl_cv_const_PTHREAD_MUTEX_ROBUST=no])
97 ])
98 if test $gl_cv_const_PTHREAD_MUTEX_ROBUST != yes; then
99 HAVE_PTHREAD_MUTEX_ROBUST=0
100 fi
101
102 AC_CACHE_CHECK([for PTHREAD_PROCESS_SHARED],
103 [gl_cv_const_PTHREAD_PROCESS_SHARED],
104 [AC_COMPILE_IFELSE(
105 [AC_LANG_PROGRAM(
106 [[#include <pthread.h>
107 int x = PTHREAD_PROCESS_SHARED;
108 ]],
109 [[]])],
110 [gl_cv_const_PTHREAD_PROCESS_SHARED=yes],
111 [gl_cv_const_PTHREAD_PROCESS_SHARED=no])
112 ])
113 if test $gl_cv_const_PTHREAD_PROCESS_SHARED != yes; then
114 HAVE_PTHREAD_PROCESS_SHARED=0
115 fi
116
117 dnl Check for declarations of anything we want to poison if the
118 dnl corresponding gnulib module is not in use, if it is not common
119 dnl enough to be declared everywhere.
120 gl_WARN_ON_USE_PREPARE([[#include <pthread.h>
121 ]], [
122 pthread_create pthread_attr_init pthread_attr_getdetachstate
123 pthread_attr_setdetachstate pthread_attr_destroy pthread_self pthread_equal
124 pthread_detach pthread_join pthread_exit
125 pthread_once
126 pthread_mutex_init pthread_mutexattr_init pthread_mutexattr_gettype
127 pthread_mutexattr_settype pthread_mutexattr_getrobust
128 pthread_mutexattr_setrobust pthread_mutexattr_destroy pthread_mutex_lock
129 pthread_mutex_trylock pthread_mutex_timedlock pthread_mutex_unlock
130 pthread_mutex_destroy
131 pthread_rwlock_init pthread_rwlockattr_init pthread_rwlockattr_destroy
132 pthread_rwlock_rdlock pthread_rwlock_wrlock pthread_rwlock_tryrdlock
133 pthread_rwlock_trywrlock pthread_rwlock_timedrdlock
134 pthread_rwlock_timedwrlock pthread_rwlock_unlock pthread_rwlock_destroy
135 pthread_cond_init pthread_condattr_init pthread_condattr_destroy
136 pthread_cond_wait pthread_cond_timedwait pthread_cond_signal
137 pthread_cond_broadcast pthread_cond_destroy
138 pthread_key_create pthread_setspecific pthread_getspecific
139 pthread_key_delete
140 pthread_spin_init pthread_spin_lock pthread_spin_trylock pthread_spin_unlock
141 pthread_spin_destroy])
142
143 AC_REQUIRE([AC_C_RESTRICT])
144
145 dnl For backward compatibility with gnulib versions <= 2019-07.
146 LIB_PTHREAD="$LIBPMULTITHREAD"
147 AC_SUBST([LIB_PTHREAD])
148])
149
150# gl_PTHREAD_MODULE_INDICATOR([modulename])
151# sets the shell variable that indicates the presence of the given module
152# to a C preprocessor expression that will evaluate to 1.
153# This macro invocation must not occur in macros that are AC_REQUIREd.
154AC_DEFUN([gl_PTHREAD_MODULE_INDICATOR],
155[
156 dnl Ensure to expand the default settings once only.
157 gl_PTHREAD_H_REQUIRE_DEFAULTS
158 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
159 dnl Define it also as a C macro, for the benefit of the unit tests.
160 gl_MODULE_INDICATOR_FOR_TESTS([$1])
161])
162
163# Initializes the default values for AC_SUBSTed shell variables.
164# This macro must not be AC_REQUIREd. It must only be invoked, and only
165# outside of macros or in macros that are not AC_REQUIREd.
166AC_DEFUN([gl_PTHREAD_H_REQUIRE_DEFAULTS],
167[
168 m4_defun(GL_MODULE_INDICATOR_PREFIX[_PTHREAD_H_MODULE_INDICATOR_DEFAULTS], [
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_THREAD])
170 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_ONCE])
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_MUTEX])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_RWLOCK])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_COND])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_TSS])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_SPIN])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_MUTEX_TIMEDLOCK])
177 ])
178 m4_require(GL_MODULE_INDICATOR_PREFIX[_PTHREAD_H_MODULE_INDICATOR_DEFAULTS])
179 AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
180])
181
182AC_DEFUN([gl_PTHREAD_H_DEFAULTS],
183[
184 dnl Assume proper GNU behavior unless another module says otherwise.
185 HAVE_PTHREAD_T=1; AC_SUBST([HAVE_PTHREAD_T])
186 HAVE_PTHREAD_SPINLOCK_T=1; AC_SUBST([HAVE_PTHREAD_SPINLOCK_T])
187 HAVE_PTHREAD_CREATE_DETACHED=1; AC_SUBST([HAVE_PTHREAD_CREATE_DETACHED])
188 HAVE_PTHREAD_MUTEX_RECURSIVE=1; AC_SUBST([HAVE_PTHREAD_MUTEX_RECURSIVE])
189 HAVE_PTHREAD_MUTEX_ROBUST=1; AC_SUBST([HAVE_PTHREAD_MUTEX_ROBUST])
190 HAVE_PTHREAD_PROCESS_SHARED=1; AC_SUBST([HAVE_PTHREAD_PROCESS_SHARED])
191 HAVE_PTHREAD_CREATE=1; AC_SUBST([HAVE_PTHREAD_CREATE])
192 HAVE_PTHREAD_ATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_ATTR_INIT])
193 HAVE_PTHREAD_ATTR_GETDETACHSTATE=1; AC_SUBST([HAVE_PTHREAD_ATTR_GETDETACHSTATE])
194 HAVE_PTHREAD_ATTR_SETDETACHSTATE=1; AC_SUBST([HAVE_PTHREAD_ATTR_SETDETACHSTATE])
195 HAVE_PTHREAD_ATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_ATTR_DESTROY])
196 HAVE_PTHREAD_SELF=1; AC_SUBST([HAVE_PTHREAD_SELF])
197 HAVE_PTHREAD_EQUAL=1; AC_SUBST([HAVE_PTHREAD_EQUAL])
198 HAVE_PTHREAD_DETACH=1; AC_SUBST([HAVE_PTHREAD_DETACH])
199 HAVE_PTHREAD_JOIN=1; AC_SUBST([HAVE_PTHREAD_JOIN])
200 HAVE_PTHREAD_EXIT=1; AC_SUBST([HAVE_PTHREAD_EXIT])
201 HAVE_PTHREAD_ONCE=1; AC_SUBST([HAVE_PTHREAD_ONCE])
202 HAVE_PTHREAD_MUTEX_INIT=1; AC_SUBST([HAVE_PTHREAD_MUTEX_INIT])
203 HAVE_PTHREAD_MUTEXATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_INIT])
204 HAVE_PTHREAD_MUTEXATTR_GETTYPE=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_GETTYPE])
205 HAVE_PTHREAD_MUTEXATTR_SETTYPE=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_SETTYPE])
206 HAVE_PTHREAD_MUTEXATTR_GETROBUST=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_GETROBUST])
207 HAVE_PTHREAD_MUTEXATTR_SETROBUST=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_SETROBUST])
208 HAVE_PTHREAD_MUTEXATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_MUTEXATTR_DESTROY])
209 HAVE_PTHREAD_MUTEX_LOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_LOCK])
210 HAVE_PTHREAD_MUTEX_TRYLOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_TRYLOCK])
211 HAVE_PTHREAD_MUTEX_TIMEDLOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_TIMEDLOCK])
212 HAVE_PTHREAD_MUTEX_UNLOCK=1; AC_SUBST([HAVE_PTHREAD_MUTEX_UNLOCK])
213 HAVE_PTHREAD_MUTEX_DESTROY=1; AC_SUBST([HAVE_PTHREAD_MUTEX_DESTROY])
214 HAVE_PTHREAD_RWLOCK_INIT=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_INIT])
215 HAVE_PTHREAD_RWLOCKATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_RWLOCKATTR_INIT])
216 HAVE_PTHREAD_RWLOCKATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_RWLOCKATTR_DESTROY])
217 HAVE_PTHREAD_RWLOCK_RDLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_RDLOCK])
218 HAVE_PTHREAD_RWLOCK_WRLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_WRLOCK])
219 HAVE_PTHREAD_RWLOCK_TRYRDLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TRYRDLOCK])
220 HAVE_PTHREAD_RWLOCK_TRYWRLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TRYWRLOCK])
221 HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK])
222 HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK])
223 HAVE_PTHREAD_RWLOCK_UNLOCK=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_UNLOCK])
224 HAVE_PTHREAD_RWLOCK_DESTROY=1; AC_SUBST([HAVE_PTHREAD_RWLOCK_DESTROY])
225 HAVE_PTHREAD_COND_INIT=1; AC_SUBST([HAVE_PTHREAD_COND_INIT])
226 HAVE_PTHREAD_CONDATTR_INIT=1; AC_SUBST([HAVE_PTHREAD_CONDATTR_INIT])
227 HAVE_PTHREAD_CONDATTR_DESTROY=1; AC_SUBST([HAVE_PTHREAD_CONDATTR_DESTROY])
228 HAVE_PTHREAD_COND_WAIT=1; AC_SUBST([HAVE_PTHREAD_COND_WAIT])
229 HAVE_PTHREAD_COND_TIMEDWAIT=1; AC_SUBST([HAVE_PTHREAD_COND_TIMEDWAIT])
230 HAVE_PTHREAD_COND_SIGNAL=1; AC_SUBST([HAVE_PTHREAD_COND_SIGNAL])
231 HAVE_PTHREAD_COND_BROADCAST=1; AC_SUBST([HAVE_PTHREAD_COND_BROADCAST])
232 HAVE_PTHREAD_COND_DESTROY=1; AC_SUBST([HAVE_PTHREAD_COND_DESTROY])
233 HAVE_PTHREAD_KEY_CREATE=1; AC_SUBST([HAVE_PTHREAD_KEY_CREATE])
234 HAVE_PTHREAD_SETSPECIFIC=1; AC_SUBST([HAVE_PTHREAD_SETSPECIFIC])
235 HAVE_PTHREAD_GETSPECIFIC=1; AC_SUBST([HAVE_PTHREAD_GETSPECIFIC])
236 HAVE_PTHREAD_KEY_DELETE=1; AC_SUBST([HAVE_PTHREAD_KEY_DELETE])
237 HAVE_PTHREAD_SPIN_INIT=1; AC_SUBST([HAVE_PTHREAD_SPIN_INIT])
238 HAVE_PTHREAD_SPIN_LOCK=1; AC_SUBST([HAVE_PTHREAD_SPIN_LOCK])
239 HAVE_PTHREAD_SPIN_TRYLOCK=1; AC_SUBST([HAVE_PTHREAD_SPIN_TRYLOCK])
240 HAVE_PTHREAD_SPIN_UNLOCK=1; AC_SUBST([HAVE_PTHREAD_SPIN_UNLOCK])
241 HAVE_PTHREAD_SPIN_DESTROY=1; AC_SUBST([HAVE_PTHREAD_SPIN_DESTROY])
242 REPLACE_PTHREAD_CREATE=0; AC_SUBST([REPLACE_PTHREAD_CREATE])
243 REPLACE_PTHREAD_ATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_ATTR_INIT])
244 REPLACE_PTHREAD_ATTR_GETDETACHSTATE=0; AC_SUBST([REPLACE_PTHREAD_ATTR_GETDETACHSTATE])
245 REPLACE_PTHREAD_ATTR_SETDETACHSTATE=0; AC_SUBST([REPLACE_PTHREAD_ATTR_SETDETACHSTATE])
246 REPLACE_PTHREAD_ATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_ATTR_DESTROY])
247 REPLACE_PTHREAD_SELF=0; AC_SUBST([REPLACE_PTHREAD_SELF])
248 REPLACE_PTHREAD_EQUAL=0; AC_SUBST([REPLACE_PTHREAD_EQUAL])
249 REPLACE_PTHREAD_DETACH=0; AC_SUBST([REPLACE_PTHREAD_DETACH])
250 REPLACE_PTHREAD_JOIN=0; AC_SUBST([REPLACE_PTHREAD_JOIN])
251 REPLACE_PTHREAD_EXIT=0; AC_SUBST([REPLACE_PTHREAD_EXIT])
252 REPLACE_PTHREAD_ONCE=0; AC_SUBST([REPLACE_PTHREAD_ONCE])
253 REPLACE_PTHREAD_MUTEX_INIT=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_INIT])
254 REPLACE_PTHREAD_MUTEXATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_INIT])
255 REPLACE_PTHREAD_MUTEXATTR_GETTYPE=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_GETTYPE])
256 REPLACE_PTHREAD_MUTEXATTR_SETTYPE=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_SETTYPE])
257 REPLACE_PTHREAD_MUTEXATTR_GETROBUST=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_GETROBUST])
258 REPLACE_PTHREAD_MUTEXATTR_SETROBUST=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_SETROBUST])
259 REPLACE_PTHREAD_MUTEXATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_MUTEXATTR_DESTROY])
260 REPLACE_PTHREAD_MUTEX_LOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_LOCK])
261 REPLACE_PTHREAD_MUTEX_TRYLOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_TRYLOCK])
262 REPLACE_PTHREAD_MUTEX_TIMEDLOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_TIMEDLOCK])
263 REPLACE_PTHREAD_MUTEX_UNLOCK=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_UNLOCK])
264 REPLACE_PTHREAD_MUTEX_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_MUTEX_DESTROY])
265 REPLACE_PTHREAD_RWLOCK_INIT=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_INIT])
266 REPLACE_PTHREAD_RWLOCKATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_RWLOCKATTR_INIT])
267 REPLACE_PTHREAD_RWLOCKATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_RWLOCKATTR_DESTROY])
268 REPLACE_PTHREAD_RWLOCK_RDLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_RDLOCK])
269 REPLACE_PTHREAD_RWLOCK_WRLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_WRLOCK])
270 REPLACE_PTHREAD_RWLOCK_TRYRDLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TRYRDLOCK])
271 REPLACE_PTHREAD_RWLOCK_TRYWRLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TRYWRLOCK])
272 REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK])
273 REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK])
274 REPLACE_PTHREAD_RWLOCK_UNLOCK=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_UNLOCK])
275 REPLACE_PTHREAD_RWLOCK_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_RWLOCK_DESTROY])
276 REPLACE_PTHREAD_COND_INIT=0; AC_SUBST([REPLACE_PTHREAD_COND_INIT])
277 REPLACE_PTHREAD_CONDATTR_INIT=0; AC_SUBST([REPLACE_PTHREAD_CONDATTR_INIT])
278 REPLACE_PTHREAD_CONDATTR_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_CONDATTR_DESTROY])
279 REPLACE_PTHREAD_COND_WAIT=0; AC_SUBST([REPLACE_PTHREAD_COND_WAIT])
280 REPLACE_PTHREAD_COND_TIMEDWAIT=0; AC_SUBST([REPLACE_PTHREAD_COND_TIMEDWAIT])
281 REPLACE_PTHREAD_COND_SIGNAL=0; AC_SUBST([REPLACE_PTHREAD_COND_SIGNAL])
282 REPLACE_PTHREAD_COND_BROADCAST=0; AC_SUBST([REPLACE_PTHREAD_COND_BROADCAST])
283 REPLACE_PTHREAD_COND_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_COND_DESTROY])
284 REPLACE_PTHREAD_KEY_CREATE=0; AC_SUBST([REPLACE_PTHREAD_KEY_CREATE])
285 REPLACE_PTHREAD_SETSPECIFIC=0; AC_SUBST([REPLACE_PTHREAD_SETSPECIFIC])
286 REPLACE_PTHREAD_GETSPECIFIC=0; AC_SUBST([REPLACE_PTHREAD_GETSPECIFIC])
287 REPLACE_PTHREAD_KEY_DELETE=0; AC_SUBST([REPLACE_PTHREAD_KEY_DELETE])
288 REPLACE_PTHREAD_SPIN_INIT=0; AC_SUBST([REPLACE_PTHREAD_SPIN_INIT])
289 REPLACE_PTHREAD_SPIN_LOCK=0; AC_SUBST([REPLACE_PTHREAD_SPIN_LOCK])
290 REPLACE_PTHREAD_SPIN_TRYLOCK=0; AC_SUBST([REPLACE_PTHREAD_SPIN_TRYLOCK])
291 REPLACE_PTHREAD_SPIN_UNLOCK=0; AC_SUBST([REPLACE_PTHREAD_SPIN_UNLOCK])
292 REPLACE_PTHREAD_SPIN_DESTROY=0; AC_SUBST([REPLACE_PTHREAD_SPIN_DESTROY])
293])
diff --git a/gl/m4/pthread_rwlock_rdlock.m4 b/gl/m4/pthread_rwlock_rdlock.m4
index ae6a8853..c16c781d 100644
--- a/gl/m4/pthread_rwlock_rdlock.m4
+++ b/gl/m4/pthread_rwlock_rdlock.m4
@@ -1,8 +1,10 @@
1# pthread_rwlock_rdlock.m4 serial 4 1# pthread_rwlock_rdlock.m4
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc. 2# serial 8
3dnl Copyright (C) 2017-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8dnl Inspired by 10dnl Inspired by
@@ -30,15 +32,15 @@ dnl https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rd
30dnl but this test verifies the guarantee regardless of TPS and regardless of 32dnl but this test verifies the guarantee regardless of TPS and regardless of
31dnl scheduling policy. 33dnl scheduling policy.
32dnl Glibc does not provide this guarantee (and never will on Linux), see 34dnl Glibc does not provide this guarantee (and never will on Linux), see
33dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701 35dnl https://sourceware.org/PR13701
34dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052 36dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052
35AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], 37AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER],
36[ 38[
37 AC_REQUIRE([gl_THREADLIB_EARLY]) 39 AC_REQUIRE([gl_THREADLIB])
38 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 40 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
39 AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader], 41 AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader],
40 [gl_cv_pthread_rwlock_rdlock_prefer_writer], 42 [gl_cv_pthread_rwlock_rdlock_prefer_writer],
41 [save_LIBS="$LIBS" 43 [saved_LIBS="$LIBS"
42 LIBS="$LIBS $LIBMULTITHREAD" 44 LIBS="$LIBS $LIBMULTITHREAD"
43 AC_RUN_IFELSE( 45 AC_RUN_IFELSE(
44 [AC_LANG_SOURCE([[ 46 [AC_LANG_SOURCE([[
@@ -156,25 +158,25 @@ main ()
156 [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes], 158 [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes],
157 [gl_cv_pthread_rwlock_rdlock_prefer_writer=no], 159 [gl_cv_pthread_rwlock_rdlock_prefer_writer=no],
158 [case "$host_os" in 160 [case "$host_os" in
159 # Guess no on glibc systems. 161 # Guess no on glibc systems.
160 *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; 162 *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
161 # Guess no on musl systems. 163 # Guess no on musl systems.
162 *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; 164 *-musl* | midipix*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
163 # Guess no on bionic systems. 165 # Guess no on bionic systems.
164 *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; 166 *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
165 # Guess yes on native Windows with the mingw-w64 winpthreads library. 167 # Guess yes on native Windows with the mingw-w64 winpthreads library.
166 # Guess no on native Windows with the gnulib windows-rwlock module. 168 # Guess no on native Windows with the gnulib windows-rwlock module.
167 mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 169 mingw* | windows*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
168 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" 170 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"
169 else 171 else
170 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" 172 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no"
171 fi 173 fi
172 ;; 174 ;;
173 # If we don't know, obey --enable-cross-guesses. 175 # If we don't know, obey --enable-cross-guesses.
174 *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;; 176 *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;;
175 esac 177 esac
176 ]) 178 ])
177 LIBS="$save_LIBS" 179 LIBS="$saved_LIBS"
178 ]) 180 ])
179 case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in 181 case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in
180 *yes) 182 *yes)
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
index d22138fc..8938db92 100644
--- a/gl/m4/realloc.m4
+++ b/gl/m4/realloc.m4
@@ -1,52 +1,22 @@
1# realloc.m4 serial 26 1# realloc.m4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 40
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# This is adapted with modifications from upstream Autoconf here: 9# An an experimental option, the user can request a sanitized realloc()
8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455 10# implementation, i.e. one that aborts upon undefined behaviour,
9AC_DEFUN([_AC_FUNC_REALLOC_IF], 11# by setting
12# gl_cv_func_realloc_sanitize=yes
13# at configure time.
14AC_DEFUN([gl_FUNC_REALLOC_SANITIZED],
10[ 15[
11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles 16 AC_CACHE_CHECK([whether realloc should abort upon undefined behaviour],
12 AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull], 17 [gl_cv_func_realloc_sanitize],
13 [ac_cv_func_realloc_0_nonnull], 18 [test -n "$gl_cv_func_realloc_sanitize" || gl_cv_func_realloc_sanitize=no])
14 [AC_RUN_IFELSE( 19])
15 [AC_LANG_PROGRAM(
16 [[#include <stdlib.h>
17 ]],
18 [[void *p = realloc (0, 0);
19 int result = !p;
20 free (p);
21 return result;]])
22 ],
23 [ac_cv_func_realloc_0_nonnull=yes],
24 [ac_cv_func_realloc_0_nonnull=no],
25 [case "$host_os" in
26 # Guess yes on platforms where we know the result.
27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
28 | gnu* | *-musl* | midnightbsd* \
29 | hpux* | solaris* | cygwin* | mingw* | msys* )
30 ac_cv_func_realloc_0_nonnull="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
33 esac
34 ])
35 ])
36 AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
37])# AC_FUNC_REALLOC
38
39# gl_FUNC_REALLOC_GNU
40# -------------------
41# Replace realloc if it is not compatible with GNU libc.
42AC_DEFUN([gl_FUNC_REALLOC_GNU],
43[
44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
45 AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
46 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
47 _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
48 fi
49])# gl_FUNC_REALLOC_GNU
50 20
51# gl_FUNC_REALLOC_POSIX 21# gl_FUNC_REALLOC_POSIX
52# --------------------- 22# ---------------------
@@ -57,7 +27,100 @@ AC_DEFUN([gl_FUNC_REALLOC_POSIX],
57[ 27[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 28 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) 29 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
60 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then 30 AC_REQUIRE([AC_CANONICAL_HOST])
31 AC_CACHE_CHECK([whether realloc sets errno on failure],
32 [gl_cv_func_realloc_posix],
33 [
34 dnl FreeBSD 15.0 realloc() does not set errno when asked for more than
35 dnl 0x7000000000000000 bytes.
36 case "$host_os" in
37 darwin* | freebsd* | dragonfly* | midnightbsd* | netbsd* | openbsd*)
38 AC_RUN_IFELSE(
39 [AC_LANG_SOURCE(
40 [[#include <errno.h>
41 #include <stdlib.h>
42 int main (int argc, char **argv)
43 {
44 void *p;
45 errno = 1729;
46 p = realloc (malloc (1), (size_t)(-1) / 100 * 49);
47 return (!p && errno == 1729);
48 }
49 ]])
50 ],
51 [gl_cv_func_realloc_posix=yes],
52 [gl_cv_func_realloc_posix=no],
53 [case "$host_os" in
54 freebsd*) gl_cv_func_realloc_posix="guessing no" ;;
55 *) gl_cv_func_realloc_posix="guessing yes" ;;
56 esac
57 ])
58 ;;
59 *)
60 gl_cv_func_realloc_posix="$gl_cv_func_malloc_posix"
61 ;;
62 esac
63 ])
64 case "$gl_cv_func_realloc_posix" in
65 *yes)
66 AC_DEFINE([HAVE_REALLOC_POSIX], [1],
67 [Define if realloc sets errno on allocation failure.])
68 ;;
69 *)
70 REPLACE_REALLOC_FOR_REALLOC_POSIX=1
71 ;;
72 esac
73 AC_REQUIRE([gl_FUNC_REALLOC_SANITIZED])
74 if test "$gl_cv_func_realloc_sanitize" != no; then
61 REPLACE_REALLOC_FOR_REALLOC_POSIX=1 75 REPLACE_REALLOC_FOR_REALLOC_POSIX=1
76 AC_DEFINE([NEED_SANITIZED_REALLOC], [1],
77 [Define to 1 if realloc should abort upon undefined behaviour.])
62 fi 78 fi
63]) 79])
80
81# gl_FUNC_REALLOC_0_NONNULL
82# -------------------------
83# Replace realloc if realloc (..., 0) returns null.
84# Modules that use this macro directly or indirectly should depend
85# on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined
86# before this macro gets invoked. This helps if !(__VEC__ || __AIXVEC),
87# and doesn't hurt otherwise.
88AC_DEFUN([gl_FUNC_REALLOC_0_NONNULL],
89[
90 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
91 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
92 AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
93 AC_CACHE_CHECK([whether realloc (..., 0) returns nonnull],
94 [gl_cv_func_realloc_0_nonnull],
95 [AC_RUN_IFELSE(
96 [AC_LANG_PROGRAM(
97 [[#include <stdlib.h>
98 /* Use prealloc to test; "volatile" prevents the compiler
99 from optimizing the realloc call away. */
100 void *(*volatile prealloc) (void *, size_t) = realloc;]],
101 [[void *p = prealloc (0, 0);
102 int result = !p;
103 p = prealloc (p, 0);
104 result |= !p;
105 free (p);
106 return result;]])],
107 [gl_cv_func_realloc_0_nonnull=yes],
108 [gl_cv_func_realloc_0_nonnull=no],
109 [AS_CASE([$host_os],
110 [# Guess yes on platforms where we know the result.
111 freebsd* | netbsd* | openbsd* | darwin* | bitrig* \
112 | *-musl* | midipix* | midnightbsd* \
113 | hpux* | solaris* | cygwin*],
114 [gl_cv_func_realloc_0_nonnull="guessing yes"],
115 [# Guess as follows if we don't know.
116 gl_cv_func_realloc_0_nonnull=$gl_cross_guess_normal])])])
117 AS_CASE([$gl_cv_func_realloc_0_nonnull],
118 [*yes],
119 [AC_DEFINE([HAVE_REALLOC_0_NONNULL], [1],
120 [Define to 1 if realloc (..., 0) returns nonnull.])],
121 [AS_CASE([$gl_cv_func_realloc_sanitize,$gl_cv_malloc_ptrdiff,$gl_cv_func_malloc_posix,$host],
122 [yes,*,*,* | *,no,*,* | *,*,*no,* | *,*,*,aarch64c-*-freebsd*],
123 [REPLACE_REALLOC_FOR_REALLOC_POSIX=1],
124 [# Optimize for common case of glibc 2.1.1+ and compatibles.
125 REPLACE_REALLOC_FOR_REALLOC_POSIX=2])])
126])
diff --git a/gl/m4/reallocarray.m4 b/gl/m4/reallocarray.m4
index 1607b7a9..e789967c 100644
--- a/gl/m4/reallocarray.m4
+++ b/gl/m4/reallocarray.m4
@@ -1,8 +1,10 @@
1# reallocarray.m4 serial 3 1# reallocarray.m4
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc. 2# serial 7
3dnl Copyright (C) 2017-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_REALLOCARRAY], 9AC_DEFUN([gl_FUNC_REALLOCARRAY],
8[ 10[
@@ -11,11 +13,21 @@ AC_DEFUN([gl_FUNC_REALLOCARRAY],
11 13
12 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 14 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
13 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) 15 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
14 AC_CHECK_FUNCS([reallocarray]) 16 AC_REQUIRE([gl_FUNC_REALLOC_0_NONNULL])
17 gl_CHECK_FUNCS_ANDROID([reallocarray], [[#include <stdlib.h>]])
15 if test "$ac_cv_func_reallocarray" = no; then 18 if test "$ac_cv_func_reallocarray" = no; then
16 HAVE_REALLOCARRAY=0 19 HAVE_REALLOCARRAY=0
17 elif test "$gl_cv_malloc_ptrdiff" = no; then 20 case "$gl_cv_onwards_func_reallocarray" in
18 REPLACE_REALLOCARRAY=1 21 future*) REPLACE_REALLOCARRAY=1 ;;
22 esac
23 else
24 if test "$gl_cv_malloc_ptrdiff" = no; then
25 REPLACE_REALLOCARRAY=1
26 fi
27 case "$gl_cv_func_realloc_0_nonnull" in
28 *yes) ;;
29 *) REPLACE_REALLOCARRAY=1 ;;
30 esac
19 fi 31 fi
20]) 32])
21 33
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4
index c89a1432..45a10490 100644
--- a/gl/m4/regex.m4
+++ b/gl/m4/regex.m4
@@ -1,10 +1,10 @@
1# serial 73 1# regex.m4
2 2# serial 81
3# Copyright (C) 1996-2001, 2003-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 1996-2001, 2003-2026 Free Software Foundation, Inc.
4# 4dnl This file is free software; the Free Software Foundation
5# This file is free software; the Free Software Foundation 5dnl gives unlimited permission to copy and/or distribute it,
6# gives unlimited permission to copy and/or distribute it, 6dnl with or without modifications, as long as this notice is preserved.
7# with or without modifications, as long as this notice is preserved. 7dnl This file is offered as-is, without any warranty.
8 8
9dnl Initially derived from code in GNU grep. 9dnl Initially derived from code in GNU grep.
10dnl Mostly written by Jim Meyering. 10dnl Mostly written by Jim Meyering.
@@ -15,7 +15,7 @@ AC_DEFUN([gl_REGEX],
15[ 15[
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17 AC_ARG_WITH([included-regex], 17 AC_ARG_WITH([included-regex],
18 [AS_HELP_STRING([--without-included-regex], 18 [AS_HELP_STRING([[--without-included-regex]],
19 [don't compile regex; this is the default on systems 19 [don't compile regex; this is the default on systems
20 with recent-enough versions of the GNU C Library 20 with recent-enough versions of the GNU C Library
21 (use with caution on other systems).])]) 21 (use with caution on other systems).])])
@@ -40,19 +40,24 @@ AC_DEFUN([gl_REGEX],
40 #include <limits.h> 40 #include <limits.h>
41 #include <string.h> 41 #include <string.h>
42 42
43 #if defined M_CHECK_ACTION || HAVE_DECL_ALARM 43 #if HAVE_MALLOC_H
44 # include <signal.h> 44 # include <malloc.h> /* defines M_CHECK_ACTION on glibc */
45 # include <unistd.h>
46 #endif 45 #endif
47 46
48 #if HAVE_MALLOC_H 47 #if defined __HAIKU__ || defined M_CHECK_ACTION || HAVE_DECL_ALARM
49 # include <malloc.h> 48 # include <signal.h>
49 # include <unistd.h>
50 #endif 50 #endif
51 51
52 #ifdef M_CHECK_ACTION 52 #if defined __HAIKU__ || defined M_CHECK_ACTION
53 /* Exit with distinguishable exit code. */ 53 /* Exit with distinguishable exit code. */
54 static void sigabrt_no_core (int sig) { raise (SIGTERM); } 54 static void sigabrt_no_core (int sig) { raise (SIGTERM); }
55 #endif 55 #endif
56
57 /* There is no need to check whether RE_SYNTAX_EMACS is
58 (RE_CHAR_CLASSES | RE_INTERVALS), corresponding to
59 Emacs 21 (2001) and later, because Gnulib's lib/regex.h
60 is always used and has this value. */
56 ]], 61 ]],
57 [[int result = 0; 62 [[int result = 0;
58 static struct re_pattern_buffer regex; 63 static struct re_pattern_buffer regex;
@@ -68,6 +73,9 @@ AC_DEFUN([gl_REGEX],
68 signal (SIGALRM, SIG_DFL); 73 signal (SIGALRM, SIG_DFL);
69 alarm (2); 74 alarm (2);
70#endif 75#endif
76#ifdef __HAIKU__
77 signal (SIGABRT, sigabrt_no_core);
78#endif
71#ifdef M_CHECK_ACTION 79#ifdef M_CHECK_ACTION
72 signal (SIGABRT, sigabrt_no_core); 80 signal (SIGABRT, sigabrt_no_core);
73 mallopt (M_CHECK_ACTION, 2); 81 mallopt (M_CHECK_ACTION, 2);
@@ -327,10 +335,10 @@ AC_DEFUN([gl_REGEX],
327 [gl_cv_func_re_compile_pattern_working=yes], 335 [gl_cv_func_re_compile_pattern_working=yes],
328 [gl_cv_func_re_compile_pattern_working=no], 336 [gl_cv_func_re_compile_pattern_working=no],
329 [case "$host_os" in 337 [case "$host_os" in
330 # Guess no on native Windows. 338 # Guess no on native Windows.
331 mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;; 339 mingw* | windows*) gl_cv_func_re_compile_pattern_working="guessing no" ;;
332 # Otherwise obey --enable-cross-guesses. 340 # Otherwise obey --enable-cross-guesses.
333 *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;; 341 *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;;
334 esac 342 esac
335 ]) 343 ])
336 ]) 344 ])
@@ -389,7 +397,6 @@ AC_DEFUN([gl_PREREQ_REGEX],
389 AC_REQUIRE([AC_C_INLINE]) 397 AC_REQUIRE([AC_C_INLINE])
390 AC_REQUIRE([AC_C_RESTRICT]) 398 AC_REQUIRE([AC_C_RESTRICT])
391 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 399 AC_REQUIRE([AC_TYPE_MBSTATE_T])
392 AC_REQUIRE([gl_EEMALLOC])
393 AC_CHECK_HEADERS([libintl.h]) 400 AC_CHECK_HEADERS([libintl.h])
394 AC_CHECK_FUNCS_ONCE([isblank iswctype]) 401 AC_CHECK_FUNCS_ONCE([isblank iswctype])
395 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) 402 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
diff --git a/gl/m4/sched_h.m4 b/gl/m4/sched_h.m4
new file mode 100644
index 00000000..92ebe1b7
--- /dev/null
+++ b/gl/m4/sched_h.m4
@@ -0,0 +1,102 @@
1# sched_h.m4
2# serial 16
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Written by Bruno Haible.
10
11AC_DEFUN_ONCE([gl_SCHED_H],
12[
13 dnl Ensure to expand the default settings once only, before all statements
14 dnl that occur in other macros.
15 AC_REQUIRE([gl_SCHED_H_DEFAULTS])
16
17 AC_REQUIRE([AC_CANONICAL_HOST])
18
19 AC_REQUIRE([gl_CHECK_HEADER_SYS_CDEFS_H])
20
21 AC_CHECK_HEADERS([sched.h], [], [],
22 [[#if HAVE_SYS_CDEFS_H
23 #include <sys/cdefs.h>
24 #endif
25 ]])
26 gl_NEXT_HEADERS([sched.h])
27
28 if test "$ac_cv_header_sched_h" = yes; then
29 HAVE_SCHED_H=1
30 else
31 HAVE_SCHED_H=0
32 fi
33 AC_SUBST([HAVE_SCHED_H])
34
35 if test "$HAVE_SCHED_H" = 1; then
36 AC_CHECK_TYPE([struct sched_param],
37 [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0],
38 [[#if HAVE_SYS_CDEFS_H
39 #include <sys/cdefs.h>
40 #endif
41 #include <sched.h>
42 ]])
43 else
44 HAVE_STRUCT_SCHED_PARAM=0
45 case "$host_os" in
46 os2*)
47 dnl On OS/2 kLIBC, struct sched_param is in spawn.h.
48 AC_CHECK_TYPE([struct sched_param],
49 [HAVE_STRUCT_SCHED_PARAM=1], [],
50 [#include <spawn.h>])
51 ;;
52 vms)
53 dnl On OpenVMS 7.2 or newer, struct sched_param is in pthread.h.
54 AC_CHECK_TYPE([struct sched_param],
55 [HAVE_STRUCT_SCHED_PARAM=1], [],
56 [#include <pthread.h>])
57 ;;
58 esac
59 fi
60 AC_SUBST([HAVE_STRUCT_SCHED_PARAM])
61
62 dnl Ensure the type pid_t gets defined.
63 AC_REQUIRE([AC_TYPE_PID_T])
64
65 dnl Check for declarations of anything we want to poison if the
66 dnl corresponding gnulib module is not in use, if it is not common
67 dnl enough to be declared everywhere.
68 gl_WARN_ON_USE_PREPARE([[#include <sched.h>
69 ]], [sched_yield])
70])
71
72# gl_SCHED_MODULE_INDICATOR([modulename])
73# sets the shell variable that indicates the presence of the given module
74# to a C preprocessor expression that will evaluate to 1.
75# This macro invocation must not occur in macros that are AC_REQUIREd.
76AC_DEFUN([gl_SCHED_MODULE_INDICATOR],
77[
78 dnl Ensure to expand the default settings once only.
79 gl_SCHED_H_REQUIRE_DEFAULTS
80 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
81 dnl Define it also as a C macro, for the benefit of the unit tests.
82 gl_MODULE_INDICATOR_FOR_TESTS([$1])
83])
84
85# Initializes the default values for AC_SUBSTed shell variables.
86# This macro must not be AC_REQUIREd. It must only be invoked, and only
87# outside of macros or in macros that are not AC_REQUIREd.
88AC_DEFUN([gl_SCHED_H_REQUIRE_DEFAULTS],
89[
90 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS], [
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCHED_YIELD])
92 ])
93 m4_require(GL_MODULE_INDICATOR_PREFIX[_SCHED_H_MODULE_INDICATOR_DEFAULTS])
94 AC_REQUIRE([gl_SCHED_H_DEFAULTS])
95])
96
97AC_DEFUN([gl_SCHED_H_DEFAULTS],
98[
99 dnl Assume proper GNU behavior unless another module says otherwise.
100 HAVE_SCHED_YIELD=1; AC_SUBST([HAVE_SCHED_YIELD])
101 REPLACE_SCHED_YIELD=0; AC_SUBST([REPLACE_SCHED_YIELD])
102])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
index 0f35b8b8..97bcad0f 100644
--- a/gl/m4/servent.m4
+++ b/gl/m4/servent.m4
@@ -1,8 +1,10 @@
1# servent.m4 serial 4 1# servent.m4
2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2008, 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_SERVENT], 9AC_DEFUN([gl_SERVENT],
8[ 10[
@@ -28,7 +30,7 @@ AC_DEFUN([gl_SERVENT],
28 AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32], 30 AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
29 [gl_cv_w32_getservbyname], 31 [gl_cv_w32_getservbyname],
30 [gl_cv_w32_getservbyname=no 32 [gl_cv_w32_getservbyname=no
31 gl_save_LIBS="$LIBS" 33 gl_saved_LIBS="$LIBS"
32 LIBS="$LIBS -lws2_32" 34 LIBS="$LIBS -lws2_32"
33 AC_LINK_IFELSE( 35 AC_LINK_IFELSE(
34 [AC_LANG_PROGRAM( 36 [AC_LANG_PROGRAM(
@@ -40,7 +42,7 @@ AC_DEFUN([gl_SERVENT],
40 ]], 42 ]],
41 [[getservbyname(NULL,NULL);]])], 43 [[getservbyname(NULL,NULL);]])],
42 [gl_cv_w32_getservbyname=yes]) 44 [gl_cv_w32_getservbyname=yes])
43 LIBS="$gl_save_LIBS" 45 LIBS="$gl_saved_LIBS"
44 ]) 46 ])
45 if test "$gl_cv_w32_getservbyname" = "yes"; then 47 if test "$gl_cv_w32_getservbyname" = "yes"; then
46 SERVENT_LIB="-lws2_32" 48 SERVENT_LIB="-lws2_32"
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index 16f9eb55..5faf28d2 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,8 +1,10 @@
1# setenv.m4 serial 30 1# setenv.m4
2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc. 2# serial 36
3dnl Copyright (C) 2001-2004, 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_SETENV], 9AC_DEFUN([gl_FUNC_SETENV],
8[ 10[
@@ -35,12 +37,12 @@ AC_DEFUN([gl_FUNC_SETENV],
35 ]])], 37 ]])],
36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], 38 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
37 [case "$host_os" in 39 [case "$host_os" in
38 # Guess yes on glibc systems. 40 # Guess yes on glibc systems.
39 *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;; 41 *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;;
40 # Guess yes on musl systems. 42 # Guess yes on musl systems.
41 *-musl*) gl_cv_func_setenv_works="guessing yes" ;; 43 *-musl* | midipix*) gl_cv_func_setenv_works="guessing yes" ;;
42 # If we don't know, obey --enable-cross-guesses. 44 # If we don't know, obey --enable-cross-guesses.
43 *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;; 45 *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;;
44 esac 46 esac
45 ])]) 47 ])])
46 case "$gl_cv_func_setenv_works" in 48 case "$gl_cv_func_setenv_works" in
@@ -83,8 +85,6 @@ AC_DEFUN([gl_FUNC_UNSETENV],
83 [AC_COMPILE_IFELSE( 85 [AC_COMPILE_IFELSE(
84 [AC_LANG_PROGRAM( 86 [AC_LANG_PROGRAM(
85 [[ 87 [[
86#undef _BSD
87#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 <stdlib.h> */
88#include <stdlib.h> 88#include <stdlib.h>
89extern 89extern
90#ifdef __cplusplus 90#ifdef __cplusplus
@@ -151,11 +151,11 @@ int unsetenv (const char *name);
151# Prerequisites of lib/setenv.c. 151# Prerequisites of lib/setenv.c.
152AC_DEFUN([gl_PREREQ_SETENV], 152AC_DEFUN([gl_PREREQ_SETENV],
153[ 153[
154 AC_REQUIRE([AC_FUNC_ALLOCA])
155 AC_REQUIRE([gl_ENVIRON]) 154 AC_REQUIRE([gl_ENVIRON])
156 AC_CHECK_HEADERS_ONCE([unistd.h]) 155 AC_CHECK_HEADERS_ONCE([unistd.h])
157 AC_CHECK_HEADERS([search.h]) 156 AC_CHECK_HEADERS([search.h])
158 AC_CHECK_FUNCS([tsearch]) 157 AC_CHECK_DECLS_ONCE([_putenv])
158 gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]])
159]) 159])
160 160
161# Prerequisites of lib/unsetenv.c. 161# Prerequisites of lib/unsetenv.c.
@@ -163,4 +163,5 @@ AC_DEFUN([gl_PREREQ_UNSETENV],
163[ 163[
164 AC_REQUIRE([gl_ENVIRON]) 164 AC_REQUIRE([gl_ENVIRON])
165 AC_CHECK_HEADERS_ONCE([unistd.h]) 165 AC_CHECK_HEADERS_ONCE([unistd.h])
166 AC_CHECK_DECLS_ONCE([_putenv])
166]) 167])
diff --git a/gl/m4/setlocale_null.m4 b/gl/m4/setlocale_null.m4
index 032119d0..b6727245 100644
--- a/gl/m4/setlocale_null.m4
+++ b/gl/m4/setlocale_null.m4
@@ -1,10 +1,12 @@
1# setlocale_null.m4 serial 5 1# setlocale_null.m4
2dnl Copyright (C) 2019-2023 Free Software Foundation, Inc. 2# serial 11
3dnl Copyright (C) 2019-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_SETLOCALE_NULL], 9AC_DEFUN_ONCE([gl_FUNC_SETLOCALE_NULL],
8[ 10[
9 AC_REQUIRE([AC_CANONICAL_HOST]) 11 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PTHREADLIB]) 12 AC_REQUIRE([gl_PTHREADLIB])
@@ -13,11 +15,25 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
13 AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe], 15 AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe],
14 [gl_cv_func_setlocale_null_all_mtsafe], 16 [gl_cv_func_setlocale_null_all_mtsafe],
15 [case "$host_os" in 17 [case "$host_os" in
16 # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin. 18 # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku.
17 *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*) 19 *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku*)
18 gl_cv_func_setlocale_null_all_mtsafe=no ;; 20 gl_cv_func_setlocale_null_all_mtsafe=no ;;
19 # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows. 21 # Guess no on Cygwin < 3.4.6.
20 *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*) 22 cygwin*)
23 AC_EGREP_CPP([Lucky user],
24 [
25#if defined __CYGWIN__
26 #include <cygwin/version.h>
27 #if CYGWIN_VERSION_DLL_COMBINED >= CYGWIN_VERSION_DLL_MAKE_COMBINED (3004, 6)
28 Lucky user
29 #endif
30#endif
31 ],
32 [gl_cv_func_setlocale_null_all_mtsafe=yes],
33 [gl_cv_func_setlocale_null_all_mtsafe=no])
34 ;;
35 # Guess yes on glibc, HP-UX, Solaris, native Windows.
36 *-gnu* | gnu* | hpux* | solaris* | mingw* | windows*)
21 gl_cv_func_setlocale_null_all_mtsafe=yes ;; 37 gl_cv_func_setlocale_null_all_mtsafe=yes ;;
22 # If we don't know, obey --enable-cross-guesses. 38 # If we don't know, obey --enable-cross-guesses.
23 *) 39 *)
@@ -26,7 +42,7 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
26 ]) 42 ])
27 dnl On platforms without multithreading, there is no issue. 43 dnl On platforms without multithreading, there is no issue.
28 case "$host_os" in 44 case "$host_os" in
29 mingw*) ;; 45 mingw* | windows*) ;;
30 *) 46 *)
31 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then 47 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
32 gl_cv_func_setlocale_null_all_mtsafe="trivially yes" 48 gl_cv_func_setlocale_null_all_mtsafe="trivially yes"
@@ -47,8 +63,8 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
47 # Guess no on OpenBSD, AIX. 63 # Guess no on OpenBSD, AIX.
48 openbsd* | aix*) 64 openbsd* | aix*)
49 gl_cv_func_setlocale_null_one_mtsafe=no ;; 65 gl_cv_func_setlocale_null_one_mtsafe=no ;;
50 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows. 66 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, Solaris, Haiku, Cygwin, native Windows.
51 *-gnu* | gnu* | *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*) 67 *-gnu* | gnu* | *-musl* | midipix* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | solaris* | haiku* | cygwin* | mingw* | windows*)
52 gl_cv_func_setlocale_null_one_mtsafe=yes ;; 68 gl_cv_func_setlocale_null_one_mtsafe=yes ;;
53 # If we don't know, obey --enable-cross-guesses. 69 # If we don't know, obey --enable-cross-guesses.
54 *) 70 *)
@@ -57,7 +73,7 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
57 ]) 73 ])
58 dnl On platforms without multithreading, there is no issue. 74 dnl On platforms without multithreading, there is no issue.
59 case "$host_os" in 75 case "$host_os" in
60 mingw*) ;; 76 mingw* | windows*) ;;
61 *) 77 *)
62 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then 78 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
63 gl_cv_func_setlocale_null_one_mtsafe="trivially yes" 79 gl_cv_func_setlocale_null_one_mtsafe="trivially yes"
@@ -74,20 +90,25 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
74 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c. 90 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c.
75 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then 91 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then
76 case "$host_os" in 92 case "$host_os" in
77 mingw*) LIB_SETLOCALE_NULL= ;; 93 mingw* | windows*)
94 SETLOCALE_NULL_LIB=
95 ;;
78 *) 96 *)
79 gl_WEAK_SYMBOLS 97 gl_WEAK_SYMBOLS
80 case "$gl_cv_have_weak" in 98 case "$gl_cv_have_weak" in
81 *yes) LIB_SETLOCALE_NULL= ;; 99 *yes) SETLOCALE_NULL_LIB= ;;
82 *) LIB_SETLOCALE_NULL="$LIBPTHREAD" ;; 100 *) SETLOCALE_NULL_LIB="$LIBPTHREAD" ;;
83 esac 101 esac
84 ;; 102 ;;
85 esac 103 esac
86 else 104 else
87 LIB_SETLOCALE_NULL= 105 SETLOCALE_NULL_LIB=
88 fi 106 fi
89 dnl LIB_SETLOCALE_NULL is expected to be '-pthread' or '-lpthread' on AIX 107 dnl SETLOCALE_NULL_LIB is expected to be '-pthread' or '-lpthread' on AIX
90 dnl with gcc or xlc, and empty otherwise. 108 dnl with gcc or xlc, and empty otherwise.
109 AC_SUBST([SETLOCALE_NULL_LIB])
110 dnl For backward compatibility.
111 LIB_SETLOCALE_NULL="$SETLOCALE_NULL_LIB"
91 AC_SUBST([LIB_SETLOCALE_NULL]) 112 AC_SUBST([LIB_SETLOCALE_NULL])
92]) 113])
93 114
diff --git a/gl/m4/sha256.m4 b/gl/m4/sha256.m4
index 4d1d1dda..a9bd7857 100644
--- a/gl/m4/sha256.m4
+++ b/gl/m4/sha256.m4
@@ -1,8 +1,10 @@
1# sha256.m4 serial 8 1# sha256.m4
2dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc. 2# serial 8
3dnl Copyright (C) 2005, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_SHA256], 9AC_DEFUN([gl_SHA256],
8[ 10[
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index 0763366d..b7a5153a 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,8 +1,10 @@
1# size_max.m4 serial 12 1# size_max.m4
2dnl Copyright (C) 2003, 2005-2006, 2008-2023 Free Software Foundation, Inc. 2# serial 12
3dnl Copyright (C) 2003, 2005-2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4
index 4b5fbdbf..6de225c2 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,8 +1,10 @@
1# snprintf.m4 serial 7 1# snprintf.m4
2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc. 2# serial 7
3dnl Copyright (C) 2002-2004, 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Libintl 0.17 will replace snprintf only if it does not support %1$s, 9dnl Libintl 0.17 will replace snprintf only if it does not support %1$s,
8dnl but defers to any gnulib snprintf replacements. Therefore, gnulib 10dnl but defers to any gnulib snprintf replacements. Therefore, gnulib
diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4
index a556af1e..f62ffcfd 100644
--- a/gl/m4/socketlib.m4
+++ b/gl/m4/socketlib.m4
@@ -1,8 +1,10 @@
1# socketlib.m4 serial 3 1# socketlib.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 4
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl gl_SOCKETLIB 9dnl gl_SOCKETLIB
8dnl Determines the library to use for socket functions. 10dnl Determines the library to use for socket functions.
@@ -18,7 +20,7 @@ AC_DEFUN([gl_SOCKETLIB],
18 dnl defined through -lws2_32), we need to call it. 20 dnl defined through -lws2_32), we need to call it.
19 AC_CACHE_CHECK([for WSAStartup], 21 AC_CACHE_CHECK([for WSAStartup],
20 [gl_cv_func_wsastartup], [ 22 [gl_cv_func_wsastartup], [
21 gl_save_LIBS="$LIBS" 23 gl_saved_LIBS="$LIBS"
22 LIBS="$LIBS -lws2_32" 24 LIBS="$LIBS -lws2_32"
23 AC_LINK_IFELSE( 25 AC_LINK_IFELSE(
24 [AC_LANG_PROGRAM([[ 26 [AC_LANG_PROGRAM([[
@@ -33,7 +35,7 @@ AC_DEFUN([gl_SOCKETLIB],
33 ], 35 ],
34 [gl_cv_func_wsastartup=yes], 36 [gl_cv_func_wsastartup=yes],
35 [gl_cv_func_wsastartup=no]) 37 [gl_cv_func_wsastartup=no])
36 LIBS="$gl_save_LIBS" 38 LIBS="$gl_saved_LIBS"
37 ]) 39 ])
38 if test "$gl_cv_func_wsastartup" = "yes"; then 40 if test "$gl_cv_func_wsastartup" = "yes"; then
39 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) 41 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
@@ -56,8 +58,8 @@ AC_DEFUN([gl_SOCKETLIB],
56#endif 58#endif
57char setsockopt();]], [[setsockopt();]])], 59char setsockopt();]], [[setsockopt();]])],
58 [], 60 [],
59 [gl_save_LIBS="$LIBS" 61 [gl_saved_LIBS="$LIBS"
60 LIBS="$gl_save_LIBS -lsocket" 62 LIBS="$gl_saved_LIBS -lsocket"
61 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 63 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
62#ifdef __cplusplus 64#ifdef __cplusplus
63"C" 65"C"
@@ -65,7 +67,7 @@ char setsockopt();]], [[setsockopt();]])],
65char setsockopt();]], [[setsockopt();]])], 67char setsockopt();]], [[setsockopt();]])],
66 [gl_cv_lib_socket="-lsocket"]) 68 [gl_cv_lib_socket="-lsocket"])
67 if test -z "$gl_cv_lib_socket"; then 69 if test -z "$gl_cv_lib_socket"; then
68 LIBS="$gl_save_LIBS -lnetwork" 70 LIBS="$gl_saved_LIBS -lnetwork"
69 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 71 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
70#ifdef __cplusplus 72#ifdef __cplusplus
71"C" 73"C"
@@ -73,7 +75,7 @@ char setsockopt();]], [[setsockopt();]])],
73char setsockopt();]], [[setsockopt();]])], 75char setsockopt();]], [[setsockopt();]])],
74 [gl_cv_lib_socket="-lnetwork"]) 76 [gl_cv_lib_socket="-lnetwork"])
75 if test -z "$gl_cv_lib_socket"; then 77 if test -z "$gl_cv_lib_socket"; then
76 LIBS="$gl_save_LIBS -lnet" 78 LIBS="$gl_saved_LIBS -lnet"
77 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 79 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
78#ifdef __cplusplus 80#ifdef __cplusplus
79"C" 81"C"
@@ -82,7 +84,7 @@ char setsockopt();]], [[setsockopt();]])],
82 [gl_cv_lib_socket="-lnet"]) 84 [gl_cv_lib_socket="-lnet"])
83 fi 85 fi
84 fi 86 fi
85 LIBS="$gl_save_LIBS" 87 LIBS="$gl_saved_LIBS"
86 ]) 88 ])
87 if test -z "$gl_cv_lib_socket"; then 89 if test -z "$gl_cv_lib_socket"; then
88 gl_cv_lib_socket="none needed" 90 gl_cv_lib_socket="none needed"
diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4
index ed9cb873..95800d2e 100644
--- a/gl/m4/sockets.m4
+++ b/gl/m4/sockets.m4
@@ -1,8 +1,10 @@
1# sockets.m4 serial 7 1# sockets.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 7
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_SOCKETS], 9AC_DEFUN([gl_SOCKETS],
8[ 10[
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index 1c63a853..e5156511 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,15 +1,17 @@
1# socklen.m4 serial 11 1# socklen.m4
2dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. 2# serial 13
3dnl Copyright (C) 2005-2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Albert Chin, Windows fixes from Simon Josefsson. 9dnl From Albert Chin, Windows fixes from Simon Josefsson.
8 10
9dnl Check for socklen_t: historically on BSD it is an int, and in 11dnl Check for socklen_t: historically on BSD it is an int, and in
10dnl POSIX 1g it is a type of its own, but some platforms use different 12dnl POSIX 1g it is a type of its own, but some platforms use different
11dnl types for the argument to getsockopt, getpeername, etc.: 13dnl types for the argument to getsockopt, getpeername, etc.:
12dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS. 14dnl HP-UX 10.20, Interix 3.5, BeOS.
13dnl So we have to test to find something that will work. 15dnl So we have to test to find something that will work.
14 16
15AC_DEFUN([gl_TYPE_SOCKLEN_T], 17AC_DEFUN([gl_TYPE_SOCKLEN_T],
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 6c6dc2f7..6379766d 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,8 +1,10 @@
1# sockpfaf.m4 serial 10 1# sockpfaf.m4
2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc. 2# serial 11
3dnl Copyright (C) 2004, 2006, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Test for some common socket protocol families (PF_INET, PF_INET6, ...) 9dnl Test for some common socket protocol families (PF_INET, PF_INET6, ...)
8dnl and some common address families (AF_INET, AF_INET6, ...). 10dnl and some common address families (AF_INET, AF_INET6, ...).
@@ -63,6 +65,13 @@ AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
63 AC_REQUIRE([gl_SYS_SOCKET_H]) 65 AC_REQUIRE([gl_SYS_SOCKET_H])
64 AC_CHECK_HEADERS_ONCE([sys/un.h]) 66 AC_CHECK_HEADERS_ONCE([sys/un.h])
65 67
68 dnl Windows versions released after 2017 may have support for AF_UNIX.
69 dnl Including it requires types from <winsock2.h> to be defined.
70 dnl <https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/>.
71 if test "$ac_cv_header_winsock2_h" = yes; then
72 AC_CHECK_HEADERS([afunix.h], [], [], [#include <winsock2.h>])
73 fi
74
66 AC_CACHE_CHECK([for UNIX domain sockets], 75 AC_CACHE_CHECK([for UNIX domain sockets],
67 [gl_cv_socket_unix], 76 [gl_cv_socket_unix],
68 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 77 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
@@ -74,6 +83,9 @@ AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
74#endif 83#endif
75#ifdef HAVE_WINSOCK2_H 84#ifdef HAVE_WINSOCK2_H
76#include <winsock2.h> 85#include <winsock2.h>
86#endif
87#ifdef HAVE_AFUNIX_H
88#include <afunix.h>
77#endif]], 89#endif]],
78[[int x = AF_UNIX; struct sockaddr_un y; 90[[int x = AF_UNIX; struct sockaddr_un y;
79 if (&x && &y) return 0;]])], 91 if (&x && &y) return 0;]])],
diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4
index 1c12c33e..8710cb72 100644
--- a/gl/m4/ssize_t.m4
+++ b/gl/m4/ssize_t.m4
@@ -1,23 +1,39 @@
1# ssize_t.m4 serial 5 (gettext-0.18.2) 1# ssize_t.m4
2dnl Copyright (C) 2001-2003, 2006, 2010-2023 Free Software Foundation, Inc. 2# serial 6
3dnl Copyright (C) 2001-2003, 2006, 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8dnl Test whether ssize_t is defined. 10dnl Define ssize_t if it does not already exist.
9 11
10AC_DEFUN([gt_TYPE_SSIZE_T], 12AC_DEFUN([gt_TYPE_SSIZE_T],
11[ 13[
12 AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t], 14 AC_CACHE_CHECK([for ssize_t], [gl_cv_ssize_t],
13 [AC_COMPILE_IFELSE( 15 [AC_COMPILE_IFELSE(
14 [AC_LANG_PROGRAM( 16 [AC_LANG_PROGRAM(
15 [[#include <sys/types.h>]], 17 [[#include <sys/types.h>]],
16 [[int x = sizeof (ssize_t *) + sizeof (ssize_t); 18 [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
17 return !x;]])], 19 return !x;]])],
18 [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])]) 20 [gl_cv_ssize_t=yes], [gl_cv_ssize_t=no])])
19 if test $gt_cv_ssize_t = no; then 21 if test $gl_cv_ssize_t = no; then
20 AC_DEFINE([ssize_t], [int], 22 dnl On 64-bit native Windows, ssize_t needs to be defined as 'long long',
21 [Define as a signed type of the same size as size_t.]) 23 dnl for consistency with the 64-bit size_t.
24 AC_CACHE_CHECK([whether size_t is wider than 'long'], [gl_cv_size_t_large],
25 [AC_COMPILE_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <sys/types.h>
28 typedef int array [2 * (sizeof (size_t) > sizeof (long)) - 1];
29 ]])],
30 [gl_cv_size_t_large=yes], [gl_cv_size_t_large=no])])
31 if test $gl_cv_size_t_large = yes; then
32 gl_def_ssize_t='long long'
33 else
34 gl_def_ssize_t='long'
35 fi
36 AC_DEFINE_UNQUOTED([ssize_t], [$gl_def_ssize_t],
37 [Define as a signed type of the same size as size_t.])
22 fi 38 fi
23]) 39])
diff --git a/gl/m4/stat-time.m4 b/gl/m4/stat-time.m4
index 40993d57..10eb1dfa 100644
--- a/gl/m4/stat-time.m4
+++ b/gl/m4/stat-time.m4
@@ -1,11 +1,13 @@
1# Checks for stat-related time functions. 1# stat-time.m4
2 2# serial 1
3# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2023 Free Software 3dnl Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2026 Free Software
4# Foundation, Inc. 4dnl Foundation, Inc.
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
5 9
6# This file is free software; the Free Software Foundation 10# Checks for stat-related time functions.
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9 11
10dnl From Paul Eggert. 12dnl From Paul Eggert.
11 13
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
index 4d241e27..3764ec0b 100644
--- a/gl/m4/stat.m4
+++ b/gl/m4/stat.m4
@@ -1,10 +1,10 @@
1# serial 18 1# stat.m4
2 2# serial 21
3# Copyright (C) 2009-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
4# 4dnl This file is free software; the Free Software Foundation
5# This file is free software; the Free Software Foundation 5dnl gives unlimited permission to copy and/or distribute it,
6# gives unlimited permission to copy and/or distribute it, 6dnl with or without modifications, as long as this notice is preserved.
7# with or without modifications, as long as this notice is preserved. 7dnl This file is offered as-is, without any warranty.
8 8
9AC_DEFUN([gl_FUNC_STAT], 9AC_DEFUN([gl_FUNC_STAT],
10[ 10[
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_STAT],
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) 12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13 AC_CHECK_FUNCS_ONCE([lstat]) 13 AC_CHECK_FUNCS_ONCE([lstat])
14 case "$host_os" in 14 case "$host_os" in
15 mingw*) 15 mingw* | windows*)
16 dnl On this platform, the original stat() returns st_atime, st_mtime, 16 dnl On this platform, the original stat() returns st_atime, st_mtime,
17 dnl st_ctime values that are affected by the time zone. 17 dnl st_ctime values that are affected by the time zone.
18 REPLACE_STAT=1 18 REPLACE_STAT=1
@@ -45,6 +45,8 @@ AC_DEFUN([gl_FUNC_STAT],
45 [case "$host_os" in 45 [case "$host_os" in
46 # Guess yes on Linux systems. 46 # Guess yes on Linux systems.
47 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;; 47 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
48 # Guess yes on systems that emulate the Linux system calls.
49 midipix*) gl_cv_func_stat_file_slash="guessing yes" ;;
48 # Guess yes on glibc systems. 50 # Guess yes on glibc systems.
49 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; 51 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
50 # If we don't know, obey --enable-cross-guesses. 52 # If we don't know, obey --enable-cross-guesses.
@@ -59,8 +61,8 @@ AC_DEFUN([gl_FUNC_STAT],
59 help when passed a file name with a trailing slash]);; 61 help when passed a file name with a trailing slash]);;
60 esac 62 esac
61 case $host_os in 63 case $host_os in
62 dnl Solaris stat can return a negative tv_nsec. 64 dnl macOS and Solaris stat can return a negative tv_nsec.
63 solaris*) 65 darwin* | solaris*)
64 REPLACE_FSTAT=1 ;; 66 REPLACE_FSTAT=1 ;;
65 esac 67 esac
66 ;; 68 ;;
@@ -78,7 +80,7 @@ AC_DEFUN([gl_PREREQ_STAT], [
78AC_DEFUN([gl_PREREQ_STAT_W32], [ 80AC_DEFUN([gl_PREREQ_STAT_W32], [
79 AC_REQUIRE([AC_CANONICAL_HOST]) 81 AC_REQUIRE([AC_CANONICAL_HOST])
80 case "$host_os" in 82 case "$host_os" in
81 mingw*) 83 mingw* | windows*)
82 AC_CHECK_HEADERS([sdkddkver.h]) 84 AC_CHECK_HEADERS([sdkddkver.h])
83 ;; 85 ;;
84 esac 86 esac
diff --git a/gl/m4/std-gnu11.m4 b/gl/m4/std-gnu11.m4
index 4179470e..0868a43a 100644
--- a/gl/m4/std-gnu11.m4
+++ b/gl/m4/std-gnu11.m4
@@ -1,19 +1,27 @@
1# std-gnu11.m4
2# serial 3
3
1# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*- 4# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
2 5
6# The std-gnu23 module, which defines _AC_C_C23_OPTIONS, supersedes us.
7m4_ifndef([_AC_C_C23_OPTIONS], [
8
3# This implementation is taken from GNU Autoconf lib/autoconf/c.m4 9# This implementation is taken from GNU Autoconf lib/autoconf/c.m4
4# commit 017d5ddd82854911f0119691d91ea8a1438824d6 10# commit 017d5ddd82854911f0119691d91ea8a1438824d6
5# dated Sun Apr 3 13:57:17 2016 -0700 11# dated Sun Apr 3 13:57:17 2016 -0700
12# with minor changes to commentary.
6# This implementation will be obsolete once we can assume Autoconf 2.70 13# This implementation will be obsolete once we can assume Autoconf 2.70
7# or later is installed everywhere a Gnulib program might be developed. 14# or later is installed everywhere a Gnulib program might be developed.
8 15
9m4_version_prereq([2.70], [], [ 16m4_version_prereq([2.70], [], [
10 17
11 18
12# Copyright (C) 2001-2023 Free Software Foundation, Inc. 19# Copyright (C) 2001-2026 Free Software Foundation, Inc.
13 20
14# This program is free software; you can redistribute it and/or modify 21# This file is part of Autoconf. This program is free
15# it under the terms of the GNU General Public License as published by 22# software; you can redistribute it and/or modify it under the
16# the Free Software Foundation, either version 3 of the License, or 23# terms of the GNU General Public License as published by the
24# Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version. 25# (at your option) any later version.
18# 26#
19# This program is distributed in the hope that it will be useful, 27# This program is distributed in the hope that it will be useful,
@@ -21,8 +29,15 @@ m4_version_prereq([2.70], [], [
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details. 30# GNU General Public License for more details.
23# 31#
32# Under Section 7 of GPL version 3, you are granted additional
33# permissions described in the Autoconf Configure Script Exception,
34# version 3.0, as published by the Free Software Foundation.
35#
24# You should have received a copy of the GNU General Public License 36# You should have received a copy of the GNU General Public License
25# along with this program. If not, see <https://www.gnu.org/licenses/>. 37# and a copy of the Autoconf Configure Script Exception along with
38# this program; see the files COPYINGv3 and COPYING.EXCEPTION
39# respectively. If not, see <https://www.gnu.org/licenses/> and
40# <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>.
26 41
27# Written by David MacKenzie, with help from 42# Written by David MacKenzie, with help from
28# Akim Demaille, Paul Eggert, 43# Akim Demaille, Paul Eggert,
@@ -35,7 +50,7 @@ m4_version_prereq([2.70], [], [
35# COMPILER ... is a space separated list of C compilers to search for. 50# COMPILER ... is a space separated list of C compilers to search for.
36# This just gives the user an opportunity to specify an alternative 51# This just gives the user an opportunity to specify an alternative
37# search list for the C compiler. 52# search list for the C compiler.
38AC_DEFUN_ONCE([AC_PROG_CC], 53AC_DEFUN([AC_PROG_CC],
39[AC_LANG_PUSH(C)dnl 54[AC_LANG_PUSH(C)dnl
40AC_ARG_VAR([CC], [C compiler command])dnl 55AC_ARG_VAR([CC], [C compiler command])dnl
41AC_ARG_VAR([CFLAGS], [C compiler flags])dnl 56AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
@@ -762,7 +777,7 @@ AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
762} 777}
763{ 778{
764 // Unicode literals 779 // Unicode literals
765 char const *utf8 = u8"UTF-8 string \u2500"; 780 auto const *utf8 = u8"UTF-8 string \u2500"; // This is portable to C++20.
766 char16_t const *utf16 = u"UTF-8 string \u2500"; 781 char16_t const *utf16 = u"UTF-8 string \u2500";
767 char32_t const *utf32 = U"UTF-32 string \u2500"; 782 char32_t const *utf32 = U"UTF-32 string \u2500";
768} 783}
@@ -827,3 +842,4 @@ dnl with extended modes being tried first.
827 842
828 843
829])# m4_version_prereq 844])# m4_version_prereq
845])# !_AC_C_C23_OPTIONS
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
index dc297175..7177d034 100644
--- a/gl/m4/stdalign.m4
+++ b/gl/m4/stdalign.m4
@@ -1,20 +1,25 @@
1# Check for alignas and alignof that conform to C23. 1# stdalign.m4
2 2# serial 3
3dnl Copyright 2011-2023 Free Software Foundation, Inc. 3dnl Copyright 2011-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9# Check for alignas and alignof that conform to C23.
10
11dnl Written by Paul Eggert and Bruno Haible.
7 12
8# Prepare for substituting <stdalign.h> if it is not supported. 13# Prepare for substituting <stdalign.h> if it is not supported.
9 14
10AC_DEFUN([gl_STDALIGN_H], 15AC_DEFUN([gl_ALIGNASOF],
11[ 16[
12 AC_CACHE_CHECK([for alignas and alignof], 17 AC_CACHE_CHECK([for alignas and alignof],
13 [gl_cv_header_working_stdalign_h], 18 [gl_cv_header_working_stdalign_h],
14 [gl_save_CFLAGS=$CFLAGS 19 [gl_saved_CFLAGS=$CFLAGS
15 for gl_working in "yes, keywords" "yes, <stdalign.h> macros"; do 20 for gl_working in "yes, keywords" "yes, <stdalign.h> macros"; do
16 AS_CASE([$gl_working], 21 AS_CASE([$gl_working],
17 [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"]) 22 [*stdalign.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_STDALIGN_H"])
18 AC_COMPILE_IFELSE( 23 AC_COMPILE_IFELSE(
19 [AC_LANG_PROGRAM( 24 [AC_LANG_PROGRAM(
20 [[#include <stdint.h> 25 [[#include <stdint.h>
@@ -25,7 +30,7 @@ AC_DEFUN([gl_STDALIGN_H],
25 30
26 /* Test that alignof yields a result consistent with offsetof. 31 /* Test that alignof yields a result consistent with offsetof.
27 This catches GCC bug 52023 32 This catches GCC bug 52023
28 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ 33 <https://gcc.gnu.org/PR52023>. */
29 #ifdef __cplusplus 34 #ifdef __cplusplus
30 template <class t> struct alignof_helper { char a; t b; }; 35 template <class t> struct alignof_helper { char a; t b; };
31 # define ao(type) offsetof (alignof_helper<type>, b) 36 # define ao(type) offsetof (alignof_helper<type>, b)
@@ -54,85 +59,154 @@ AC_DEFUN([gl_STDALIGN_H],
54 [gl_cv_header_working_stdalign_h=$gl_working], 59 [gl_cv_header_working_stdalign_h=$gl_working],
55 [gl_cv_header_working_stdalign_h=no]) 60 [gl_cv_header_working_stdalign_h=no])
56 61
57 CFLAGS=$gl_save_CFLAGS 62 CFLAGS=$gl_saved_CFLAGS
58 test "$gl_cv_header_working_stdalign_h" != no && break 63 test "$gl_cv_header_working_stdalign_h" != no && break
59 done]) 64 done])
60 65
61 GL_GENERATE_STDALIGN_H=false
62 AS_CASE([$gl_cv_header_working_stdalign_h], 66 AS_CASE([$gl_cv_header_working_stdalign_h],
63 [no],
64 [GL_GENERATE_STDALIGN_H=true],
65 [yes*keyword*], 67 [yes*keyword*],
66 [AC_DEFINE([HAVE_C_ALIGNASOF], [1], 68 [AC_DEFINE([HAVE_C_ALIGNASOF], [1],
67 [Define to 1 if the alignas and alignof keywords work.])]) 69 [Define to 1 if the alignas and alignof keywords work.])])
68 70
69 AC_CHECK_HEADERS_ONCE([stdalign.h])
70
71 dnl The "zz" puts this toward config.h's end, to avoid potential 71 dnl The "zz" puts this toward config.h's end, to avoid potential
72 dnl collisions with other definitions. 72 dnl collisions with other definitions.
73 AH_VERBATIM([zzalignas], 73 AH_VERBATIM([zzalignas],
74[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof 74[#if !defined HAVE_C_ALIGNASOF \
75# if HAVE_STDALIGN_H 75 && !(defined __cplusplus && 201103 <= __cplusplus) \
76 && !defined alignof
77# if defined HAVE_STDALIGN_H
76# include <stdalign.h> 78# include <stdalign.h>
77# else 79# endif
78 /* Substitute. Keep consistent with gnulib/lib/stdalign.in.h. */ 80
79# ifndef _GL_STDALIGN_H 81/* ISO C23 alignas and alignof for platforms that lack it.
80# define _GL_STDALIGN_H 82
81# undef _Alignas 83 References:
82# undef _Alignof 84 ISO C23 (latest free draft
83# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ 85 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf>)
84 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ 86 sections 6.2.8, 6.7.6.
85 && !defined __clang__) \ 87 C++11 (latest free draft
86 || (defined __clang__ && __clang_major__ < 8)) 88 <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
87# ifdef __cplusplus 89 section 18.10. */
88# if (201103 <= __cplusplus || defined _MSC_VER) 90
89# define _Alignof(type) alignof (type) 91/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
90# else 92 requirement of a structure member (i.e., slot or field) that is of
91 template <class __t> struct __alignof_helper { char __a; __t __b; }; 93 type TYPE, as an integer constant expression.
92# define _Alignof(type) offsetof (__alignof_helper<type>, __b) 94
93# define _GL_STDALIGN_NEEDS_STDDEF 1 95 This differs from GCC's and clang's __alignof__ operator, which can
94# endif 96 yield a better-performing alignment for an object of that type. For
97 example, on x86 with GCC and on Linux/x86 with clang,
98 __alignof__ (double) and __alignof__ (long long) are 8, whereas
99 alignof (double) and alignof (long long) are 4 unless the option
100 '-malign-double' is used.
101
102 The result cannot be used as a value for an 'enum' constant, if you
103 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
104
105/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
106 <https://gcc.gnu.org/PR52023>.
107 clang versions < 8.0.0 have the same bug.
108 IBM XL C V16.1.0 cc (non-clang) has the same bug. */
109# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
110 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
111 && !defined __clang__) \
112 || (defined __clang__ && __clang_major__ < 8) \
113 || defined __xlC__)
114# undef/**/_Alignof
115# ifdef __cplusplus
116# if (201103 <= __cplusplus || defined _MSC_VER)
117# define _Alignof(type) alignof (type)
95# else 118# else
119 template <class __t> struct __alignof_helper { char __a; __t __b; };
96# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ 120# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
97# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) 121# define _Alignof(type) __builtin_offsetof (__alignof_helper<type>, __b)
98# else 122# else
99# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) 123# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
100# define _GL_STDALIGN_NEEDS_STDDEF 1
101# endif 124# endif
125# define _GL_STDALIGN_NEEDS_STDDEF 1
102# endif 126# endif
103# endif 127# else
104# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) 128# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
105# define alignof _Alignof 129# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
106# endif 130# else
107# define __alignof_is_defined 1 131# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
108# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 132# define _GL_STDALIGN_NEEDS_STDDEF 1
109# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
110# define _Alignas(a) alignas (a)
111# elif (!defined __attribute__ \
112 && ((defined __APPLE__ && defined __MACH__ \
113 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
114 : __GNUC__ && !defined __ibmxl__) \
115 || (4 <= __clang_major__) \
116 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
117 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
118# define _Alignas(a) __attribute__ ((__aligned__ (a)))
119# elif 1300 <= _MSC_VER
120# define _Alignas(a) __declspec (align (a))
121# endif 133# endif
122# endif 134# endif
123# if ((defined _Alignas \ 135# endif
124 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \ 136# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
125 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) 137# undef/**/alignof
126# define alignas _Alignas 138# define alignof _Alignof
127# endif 139# endif
128# if (defined alignas \ 140
129 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) 141/* alignas (A), also known as _Alignas (A), aligns a variable or type
130# define __alignas_is_defined 1 142 to the alignment A, where A is an integer constant expression. For
131# endif 143 example:
132# if _GL_STDALIGN_NEEDS_STDDEF 144
133# include <stddef.h> 145 int alignas (8) foo;
134# endif 146 struct s { int a; int alignas (8) bar; };
135# endif /* _GL_STDALIGN_H */ 147
148 aligns the address of FOO and the offset of BAR to be multiples of 8.
149
150 A should be a power of two that is at least the type's alignment
151 and at most the implementation's alignment limit. This limit is
152 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
153 to MSVC through at least version 10.0, A should be an integer
154 constant, as MSVC does not support expressions such as 1 << 3.
155 To be portable to Sun C 5.11, do not align auto variables to
156 anything stricter than their default alignment.
157
158 The following C23 requirements are not supported here:
159
160 - If A is zero, alignas has no effect.
161 - alignas can be used multiple times; the strictest one wins.
162 - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
163
164 */
165# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
166# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
167# define _Alignas(a) alignas (a)
168# elif (!defined __attribute__ \
169 && ((defined __APPLE__ && defined __MACH__ \
170 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
171 : __GNUC__ && !defined __ibmxl__) \
172 || (4 <= __clang_major__) \
173 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
174 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
175# define _Alignas(a) __attribute__ ((__aligned__ (a)))
176# elif 1300 <= _MSC_VER
177# define _Alignas(a) __declspec (align (a))
178# endif
179# endif
180# if !defined HAVE_STDALIGN_H
181# if ((defined _Alignas \
182 && !(defined __cplusplus \
183 && (201103 <= __cplusplus || defined _MSC_VER))) \
184 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__ \
185 && !defined __xlC__))
186# define alignas _Alignas
187# endif
188# endif
189
190# if defined _GL_STDALIGN_NEEDS_STDDEF
191# include <stddef.h>
136# endif 192# endif
137#endif]) 193#endif])
138]) 194])
195
196AC_DEFUN([gl_STDALIGN_H],
197[
198 AC_REQUIRE([gl_ALIGNASOF])
199 if test "$gl_cv_header_working_stdalign_h" = no; then
200 GL_GENERATE_STDALIGN_H=true
201 else
202 GL_GENERATE_STDALIGN_H=false
203 fi
204
205 gl_CHECK_NEXT_HEADERS([stdalign.h])
206 if test $ac_cv_header_stdalign_h = yes; then
207 HAVE_STDALIGN_H=1
208 else
209 HAVE_STDALIGN_H=0
210 fi
211 AC_SUBST([HAVE_STDALIGN_H])
212])
diff --git a/gl/m4/stdckdint_h.m4 b/gl/m4/stdckdint_h.m4
new file mode 100644
index 00000000..eb8c858a
--- /dev/null
+++ b/gl/m4/stdckdint_h.m4
@@ -0,0 +1,136 @@
1# stdckdint_h.m4
2# serial 1
3dnl Copyright 2025-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Written by Collin Funk.
10
11AC_DEFUN_ONCE([gl_STDCKDINT_H],
12[
13 gl_CHECK_NEXT_HEADERS([stdckdint.h])
14 if test $ac_cv_header_stdckdint_h = yes; then
15 HAVE_STDCKDINT_H=1
16 else
17 HAVE_STDCKDINT_H=0
18 fi
19 AC_SUBST([HAVE_STDCKDINT_H])
20
21 if test $HAVE_STDCKDINT_H = 1; then
22 AC_CACHE_CHECK([whether stdckdint.h can be included in C],
23 [gl_cv_header_c_stdckdint_h],
24 [AC_COMPILE_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[#include <stdckdint.h>
27 ]])],
28 [gl_cv_header_c_stdckdint_h=yes],
29 [gl_cv_header_c_stdckdint_h=no])])
30 if test $gl_cv_header_c_stdckdint_h = yes; then
31 HAVE_C_STDCKDINT_H=1
32 AC_CACHE_CHECK([checking for an ISO C23 compliant stdckdint.h in C],
33 [gl_cv_header_c_stdckdint_h_works],
34 [AC_COMPILE_IFELSE(
35 [AC_LANG_PROGRAM(
36 [[#include <stdckdint.h>
37 ]],
38 [[int r;
39 int a = 1;
40 int b = 1;
41 return !!(ckd_add (&r, a, b) || ckd_sub (&r, a, b)
42 || ckd_mul (&r, a, b));
43 ]])],
44 [gl_cv_header_c_stdckdint_h_works=yes],
45 [gl_cv_header_c_stdckdint_h_works=no])])
46 if test $gl_cv_header_c_stdckdint_h_works = yes; then
47 HAVE_WORKING_C_STDCKDINT_H=1
48 else
49 HAVE_WORKING_C_STDCKDINT_H=0
50 fi
51 else
52 HAVE_C_STDCKDINT_H=0
53 HAVE_WORKING_C_STDCKDINT_H=0
54 fi
55 if test "$CXX" != no; then
56 AC_CACHE_CHECK([whether stdckdint.h can be included in C++],
57 [gl_cv_header_cxx_stdckdint_h],
58 [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
59 dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
60 cat > conftest.cpp <<\EOF
61#include <stdckdint.h>
62EOF
63 gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
64 if AC_TRY_EVAL([gl_command]); then
65 gl_cv_header_cxx_stdckdint_h=yes
66 else
67 gl_cv_header_cxx_stdckdint_h=no
68 fi
69 rm -fr conftest*
70 ])
71 if test $gl_cv_header_cxx_stdckdint_h = yes; then
72 HAVE_CXX_STDCKDINT_H=1
73 AC_CACHE_CHECK([checking for an ISO C++26 compliant stdckdint.h in C++],
74 [gl_cv_header_cxx_stdckdint_h_works],
75 [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
76 dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
77 cat > conftest.cpp <<\EOF
78#include <stdckdint.h>
79int
80main (void)
81{
82 int r;
83 int a = 1;
84 int b = 1;
85 return !!(ckd_add (&r, a, b) || ckd_sub (&r, a, b) || ckd_mul (&r, a, b));
86}
87EOF
88 gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
89 if AC_TRY_EVAL([gl_command]); then
90 gl_cv_header_cxx_stdckdint_h_works=yes
91 else
92 gl_cv_header_cxx_stdckdint_h_works=no
93 fi
94 rm -fr conftest*
95 ])
96 if test $gl_cv_header_cxx_stdckdint_h_works = yes; then
97 HAVE_WORKING_CXX_STDCKDINT_H=1
98 else
99 HAVE_WORKING_CXX_STDCKDINT_H=0
100 fi
101 else
102 HAVE_CXX_STDCKDINT_H=0
103 HAVE_WORKING_CXX_STDCKDINT_H=0
104 fi
105 fi
106 else
107 HAVE_C_STDCKDINT_H=0
108 HAVE_WORKING_C_STDCKDINT_H=0
109 HAVE_CXX_STDCKDINT_H=0
110 HAVE_WORKING_CXX_STDCKDINT_H=0
111 fi
112 AC_SUBST([HAVE_C_STDCKDINT_H])
113 AC_SUBST([HAVE_WORKING_C_STDCKDINT_H])
114 AC_SUBST([HAVE_CXX_STDCKDINT_H])
115 AC_SUBST([HAVE_WORKING_CXX_STDCKDINT_H])
116
117 if test "$CXX" != no; then
118 dnl We might need the header for C or C++.
119 if test $HAVE_C_STDCKDINT_H = 1 \
120 && test $HAVE_WORKING_C_STDCKDINT_H = 1 \
121 && test $HAVE_CXX_STDCKDINT_H = 1 \
122 && test $HAVE_WORKING_CXX_STDCKDINT_H = 1; then
123 GL_GENERATE_STDCKDINT_H=false
124 else
125 GL_GENERATE_STDCKDINT_H=true
126 fi
127 else
128 dnl We don't care about C++ here.
129 if test $HAVE_C_STDCKDINT_H = 1 \
130 && test $HAVE_WORKING_C_STDCKDINT_H = 1; then
131 GL_GENERATE_STDCKDINT_H=false
132 else
133 GL_GENERATE_STDCKDINT_H=true
134 fi
135 fi
136])
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index a2322ebb..299472b1 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,15 +1,16 @@
1# stddef_h.m4 serial 13 1# stddef_h.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 23
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl A placeholder for <stddef.h>, for platforms that have issues. 9dnl A placeholder for <stddef.h>, for platforms that have issues.
8 10
9AC_DEFUN_ONCE([gl_STDDEF_H], 11AC_DEFUN_ONCE([gl_STDDEF_H],
10[ 12[
11 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 13 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
12 AC_REQUIRE([gt_TYPE_WCHAR_T])
13 14
14 dnl Persuade OpenBSD <stddef.h> to declare max_align_t. 15 dnl Persuade OpenBSD <stddef.h> to declare max_align_t.
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
@@ -51,11 +52,6 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
51 GL_GENERATE_STDDEF_H=true 52 GL_GENERATE_STDDEF_H=true
52 fi 53 fi
53 54
54 if test $gt_cv_c_wchar_t = no; then
55 HAVE_WCHAR_T=0
56 GL_GENERATE_STDDEF_H=true
57 fi
58
59 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], 55 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
60 [gl_cv_decl_null_works], 56 [gl_cv_decl_null_works],
61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> 57 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
@@ -68,6 +64,60 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
68 GL_GENERATE_STDDEF_H=true 64 GL_GENERATE_STDDEF_H=true
69 fi 65 fi
70 66
67 AC_CACHE_CHECK([for unreachable in C],
68 [gl_cv_c_func_unreachable],
69 [AC_LINK_IFELSE(
70 [AC_LANG_PROGRAM(
71 [[#include <stddef.h>
72 ]],
73 [[unreachable ();
74 ]])],
75 [gl_cv_c_func_unreachable=yes],
76 [gl_cv_c_func_unreachable=no])
77 ])
78 if test $gl_cv_c_func_unreachable = no; then
79 GL_GENERATE_STDDEF_H=true
80 HAVE_C_UNREACHABLE=0
81 else
82 HAVE_C_UNREACHABLE=1
83 fi
84 AC_SUBST([HAVE_C_UNREACHABLE])
85 dnl Provide gl_unreachable() unconditionally.
86 GL_GENERATE_STDDEF_H=true
87
88 dnl https://gcc.gnu.org/PR114869
89 AC_CACHE_CHECK([whether nullptr_t needs <stddef.h>],
90 [gl_cv_nullptr_t_needs_stddef],
91 [AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[nullptr_t x;]],
92 [gl_cv_nullptr_t_needs_stddef=no],
93 [gl_cv_nullptr_t_needs_stddef=yes])])
94 if test "$gl_cv_nullptr_t_needs_stddef" = no; then
95 NULLPTR_T_NEEDS_STDDEF=0
96 GL_GENERATE_STDDEF_H=true
97 fi
98
99 dnl https://gcc.gnu.org/PR114870
100 dnl affects GCC 13.3 and 14.2.
101 AC_CACHE_CHECK([whether <stddef.h> is idempotent],
102 [gl_cv_stddef_idempotent],
103 [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
104 [[
105 #if \
106 ((__GNUC__ == 13 && __GNUC_MINOR__ <= 3) \
107 || (__GNUC__ == 14 && __GNUC_MINOR__ <= 2))
108 #error "bug 114870 is present"
109 #endif
110 ]])],
111 [gl_cv_stddef_idempotent="guessing yes"],
112 [gl_cv_stddef_idempotent="guessing no"])
113 ])
114 case "$gl_cv_stddef_idempotent" in
115 *yes) ;;
116 *) STDDEF_NOT_IDEMPOTENT=1
117 GL_GENERATE_STDDEF_H=true
118 ;;
119 esac
120
71 if $GL_GENERATE_STDDEF_H; then 121 if $GL_GENERATE_STDDEF_H; then
72 gl_NEXT_HEADERS([stddef.h]) 122 gl_NEXT_HEADERS([stddef.h])
73 fi 123 fi
@@ -98,7 +148,8 @@ AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS],
98AC_DEFUN([gl_STDDEF_H_DEFAULTS], 148AC_DEFUN([gl_STDDEF_H_DEFAULTS],
99[ 149[
100 dnl Assume proper GNU behavior unless another module says otherwise. 150 dnl Assume proper GNU behavior unless another module says otherwise.
151 NULLPTR_T_NEEDS_STDDEF=1; AC_SUBST([NULLPTR_T_NEEDS_STDDEF])
152 STDDEF_NOT_IDEMPOTENT=0; AC_SUBST([STDDEF_NOT_IDEMPOTENT])
101 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 153 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
102 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T]) 154 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T])
103 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
104]) 155])
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index d6961b09..410da153 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,8 +1,10 @@
1# stdint.m4 serial 61 1# stdint.m4
2dnl Copyright (C) 2001-2023 Free Software Foundation, Inc. 2# serial 65
3dnl Copyright (C) 2001-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Paul Eggert and Bruno Haible. 9dnl From Paul Eggert and Bruno Haible.
8dnl Test whether <stdint.h> is supported or must be substituted. 10dnl Test whether <stdint.h> is supported or must be substituted.
@@ -150,10 +152,13 @@ intmax_t i = INTMAX_MAX;
150uintmax_t j = UINTMAX_MAX; 152uintmax_t j = UINTMAX_MAX;
151 153
152/* Check that SIZE_MAX has the correct type, if possible. */ 154/* Check that SIZE_MAX has the correct type, if possible. */
153#if 201112 <= __STDC_VERSION__ 155/* ISO C 11 mandates _Generic, but GCC versions < 4.9 lack it. */
156#if 201112 <= __STDC_VERSION__ \
157 && (!defined __GNUC__ || 4 < __GNUC__ + (9 <= __GNUC_MINOR__) \
158 || defined __clang__)
154int k = _Generic (SIZE_MAX, size_t: 0); 159int k = _Generic (SIZE_MAX, size_t: 0);
155#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \ 160#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
156 || (0x5110 <= __SUNPRO_C && !__STDC__)) 161 || (0x5110 <= __SUNPRO_C && !__STDC__) || 1939 <= _MSC_VER)
157extern size_t k; 162extern size_t k;
158extern __typeof__ (SIZE_MAX) k; 163extern __typeof__ (SIZE_MAX) k;
159#endif 164#endif
@@ -283,10 +288,10 @@ static const char *macro_values[] =
283 [gl_cv_header_working_stdint_h=yes], 288 [gl_cv_header_working_stdint_h=yes],
284 [], 289 [],
285 [case "$host_os" in 290 [case "$host_os" in
286 # Guess yes on native Windows. 291 # Guess yes on native Windows.
287 mingw*) gl_cv_header_working_stdint_h="guessing yes" ;; 292 mingw* | windows*) gl_cv_header_working_stdint_h="guessing yes" ;;
288 # In general, assume it works. 293 # In general, assume it works.
289 *) gl_cv_header_working_stdint_h="guessing yes" ;; 294 *) gl_cv_header_working_stdint_h="guessing yes" ;;
290 esac 295 esac
291 ]) 296 ])
292 ]) 297 ])
@@ -386,9 +391,9 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
386 ]) 391 ])
387 eval result=\$gl_cv_bitsizeof_${gltype} 392 eval result=\$gl_cv_bitsizeof_${gltype}
388 if test $result = unknown; then 393 if test $result = unknown; then
389 dnl Use a nonempty default, because some compilers, such as IRIX 5 cc, 394 dnl Use a nonempty default, because some old compilers do a syntax check
390 dnl do a syntax check even on unused #if conditions and give an error 395 dnl even on unused #if conditions and give an error on valid C code like
391 dnl on valid C code like this: 396 dnl this:
392 dnl #if 0 397 dnl #if 0
393 dnl # if > 32 398 dnl # if > 32
394 dnl # endif 399 dnl # endif
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index 70349f6c..7f60af20 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,8 +1,10 @@
1# stdint_h.m4 serial 9 1# stdint_h.m4
2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc. 2# serial 9
3dnl Copyright (C) 1997-2004, 2006, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Paul Eggert. 9dnl From Paul Eggert.
8 10
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index 94271e11..9d4126f5 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,12 +1,24 @@
1# stdio_h.m4 serial 59 1# stdio_h.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 75
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_STDIO_H], 9AC_DEFUN([gl_STDIO_H_EARLY],
8[ 10[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 11 dnl Defining __USE_MINGW_ANSI_STDIO to 1 must be done early, because
12 dnl the results of several configure tests depend on it: The tests
13 dnl - checking whether snprintf returns a byte count as in C99...
14 dnl - checking whether snprintf truncates the result as in C99...
15 dnl - checking whether printf supports the 'F' directive...
16 dnl - checking whether printf supports the grouping flag...
17 dnl - checking whether printf supports the zero flag correctly...
18 dnl - checking whether printf supports infinite 'double' arguments...
19 dnl - checking whether printf supports large precisions...
20 dnl report 'yes' if __USE_MINGW_ANSI_STDIO is 1 but 'no' if
21 dnl __USE_MINGW_ANSI_STDIO is not set.
10 AH_VERBATIM([MINGW_ANSI_STDIO], 22 AH_VERBATIM([MINGW_ANSI_STDIO],
11[/* Use GNU style printf and scanf. */ 23[/* Use GNU style printf and scanf. */
12#ifndef __USE_MINGW_ANSI_STDIO 24#ifndef __USE_MINGW_ANSI_STDIO
@@ -14,6 +26,11 @@ AC_DEFUN_ONCE([gl_STDIO_H],
14#endif 26#endif
15]) 27])
16 AC_DEFINE([__USE_MINGW_ANSI_STDIO]) 28 AC_DEFINE([__USE_MINGW_ANSI_STDIO])
29])
30
31AC_DEFUN_ONCE([gl_STDIO_H],
32[
33 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
17 gl_NEXT_HEADERS([stdio.h]) 34 gl_NEXT_HEADERS([stdio.h])
18 35
19 dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and 36 dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
@@ -40,6 +57,9 @@ AC_DEFUN_ONCE([gl_STDIO_H],
40 attribute "__gnu_printf__" instead of "__printf__"]) 57 attribute "__gnu_printf__" instead of "__printf__"])
41 fi 58 fi
42 59
60 dnl For defining _PRINTF_NAN_LEN_MAX.
61 gl_MUSL_LIBC
62
43 dnl This ifdef is an optimization, to avoid performing a configure check whose 63 dnl This ifdef is an optimization, to avoid performing a configure check whose
44 dnl result is not used. But it does not make the test of 64 dnl result is not used. But it does not make the test of
45 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant. 65 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
@@ -82,6 +102,16 @@ AC_DEFUN_ONCE([gl_STDIO_H],
82 if test $ac_cv_have_decl_fcloseall = no; then 102 if test $ac_cv_have_decl_fcloseall = no; then
83 HAVE_DECL_FCLOSEALL=0 103 HAVE_DECL_FCLOSEALL=0
84 fi 104 fi
105
106 AC_CHECK_DECLS_ONCE([getw])
107 if test $ac_cv_have_decl_getw = no; then
108 HAVE_DECL_GETW=0
109 fi
110
111 AC_CHECK_DECLS_ONCE([putw])
112 if test $ac_cv_have_decl_putw = no; then
113 HAVE_DECL_PUTW=0
114 fi
85]) 115])
86 116
87# gl_STDIO_MODULE_INDICATOR([modulename]) 117# gl_STDIO_MODULE_INDICATOR([modulename])
@@ -104,6 +134,7 @@ AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
104[ 134[
105 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [ 135 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF]) 136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DZPRINTF])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE]) 138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN]) 139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH]) 140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH])
@@ -124,12 +155,14 @@ AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL]) 155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO]) 156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE]) 157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FZPRINTF])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC]) 159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR]) 160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM]) 161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE]) 162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF]) 163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX]) 164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_ZPRINTF])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE]) 166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR]) 167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN]) 168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN])
@@ -143,20 +176,29 @@ AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT]) 176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF]) 177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF]) 178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNZPRINTF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX]) 180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING]) 181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE]) 182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SZPRINTF])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE]) 184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF]) 185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASZPRINTF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF]) 187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF]) 188 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF]) 189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF])
190 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDZPRINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF]) 191 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX]) 192 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX])
193 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFZPRINTF])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF]) 194 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX]) 195 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF]) 196 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF])
197 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNZPRINTF])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX]) 198 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX])
199 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSZPRINTF])
200 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VZPRINTF])
201 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ZPRINTF])
160 dnl Support Microsoft deprecated alias function names by default. 202 dnl Support Microsoft deprecated alias function names by default.
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1]) 203 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1]) 204 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1])
@@ -178,7 +220,9 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
178 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) 220 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
179 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) 221 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM])
180 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) 222 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE])
223 HAVE_DECL_GETW=1; AC_SUBST([HAVE_DECL_GETW])
181 HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF]) 224 HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
225 HAVE_DECL_PUTW=1; AC_SUBST([HAVE_DECL_PUTW])
182 HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) 226 HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
183 HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) 227 HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
184 HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) 228 HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index e96be22f..f35d6611 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,8 +1,10 @@
1# stdlib_h.m4 serial 66 1# stdlib_h.m4
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 2# serial 86
3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_STDLIB_H], 9AC_DEFUN_ONCE([gl_STDLIB_H],
8[ 10[
@@ -23,15 +25,65 @@ AC_DEFUN_ONCE([gl_STDLIB_H],
23# include <random.h> 25# include <random.h>
24#endif 26#endif
25 ]], [_Exit aligned_alloc atoll canonicalize_file_name free 27 ]], [_Exit aligned_alloc atoll canonicalize_file_name free
26 getloadavg getsubopt grantpt 28 getloadavg getprogname getsubopt grantpt
27 initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps 29 initstate initstate_r mbstowcs mbtowc mkdtemp mkostemp mkostemps mkstemp
28 posix_memalign posix_openpt ptsname ptsname_r qsort_r 30 mkstemps posix_memalign posix_openpt ptsname ptsname_r qsort_r
29 random random_r reallocarray realpath rpmatch secure_getenv setenv 31 random random_r reallocarray realpath rpmatch secure_getenv setenv
30 setstate setstate_r srandom srandom_r 32 setstate setstate_r srandom srandom_r
31 strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv]) 33 strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv])
32 34
33 AC_REQUIRE([AC_C_RESTRICT]) 35 AC_REQUIRE([AC_C_RESTRICT])
34 36
37 dnl Test whether MB_CUR_MAX needs to be overridden.
38 dnl On Solaris 10, in UTF-8 locales, its value is 3 but needs to be 4.
39 dnl Fortunately, we can do this because on this platform MB_LEN_MAX is 5.
40 AC_REQUIRE([AC_CANONICAL_HOST])
41 AC_REQUIRE([gt_LOCALE_EN_UTF8])
42 AC_CACHE_CHECK([whether MB_CUR_MAX is correct],
43 [gl_cv_macro_MB_CUR_MAX_good],
44 [AC_LINK_IFELSE(
45 [AC_LANG_PROGRAM([[#include <stdlib.h>
46 ]],
47 [[return !!MB_CUR_MAX;]])
48 ],
49 [dnl Initial guess, used when cross-compiling or when no suitable locale
50 dnl is present.
51 # Guess no on Solaris and Haiku, yes otherwise.
52 AS_CASE([$host_os],
53 [solaris* | haiku*],
54 [gl_cv_macro_MB_CUR_MAX_good="guessing no"],
55 [gl_cv_macro_MB_CUR_MAX_good="guessing yes"])
56 if test "$LOCALE_EN_UTF8" != none; then
57 AC_RUN_IFELSE(
58 [AC_LANG_SOURCE([[
59#include <locale.h>
60#include <stdlib.h>
61int main ()
62{
63 int result = 0;
64 if (setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
65 {
66 if (MB_CUR_MAX < 4)
67 result |= 1;
68 }
69 return result;
70}]])],
71 [gl_cv_macro_MB_CUR_MAX_good=yes],
72 [gl_cv_macro_MB_CUR_MAX_good=no],
73 [:])
74 fi
75 ],
76 [gl_cv_macro_MB_CUR_MAX_good="link failed - so no"])
77 ])
78 AS_CASE([$gl_cv_macro_MB_CUR_MAX_good],
79 [*yes],
80 [],
81 ["link failed - so no"],
82 [# 4 suffices as a workaround in Android NDK 16,
83 # the only known platform with the bug.
84 REPLACE_MB_CUR_MAX=4],
85 [REPLACE_MB_CUR_MAX="(-1)"])
86
35 AC_CHECK_DECLS_ONCE([ecvt]) 87 AC_CHECK_DECLS_ONCE([ecvt])
36 if test $ac_cv_have_decl_ecvt = no; then 88 if test $ac_cv_have_decl_ecvt = no; then
37 HAVE_DECL_ECVT=0 89 HAVE_DECL_ECVT=0
@@ -66,6 +118,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
66[ 118[
67 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [ 119 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT]) 120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ABORT_DEBUG])
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC]) 122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL]) 123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU]) 124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
@@ -73,10 +126,12 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME]) 126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX]) 127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG]) 128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPROGNAME])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT]) 130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT]) 131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU]) 132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX]) 133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOWCS])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC]) 135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP]) 136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP]) 137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP])
@@ -89,16 +144,18 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R]) 144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV]) 145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R]) 146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAND])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM]) 148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R]) 149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY]) 150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX]) 151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH]) 152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH]) 153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV]) 154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV]) 155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STACK_TRACE])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD]) 157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOF])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL]) 159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD]) 160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL]) 161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL])
@@ -130,6 +187,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
130 HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT]) 187 HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT])
131 HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT]) 188 HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT])
132 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) 189 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
190 HAVE_DECL_PROGRAM_INVOCATION_NAME=1; AC_SUBST([HAVE_DECL_PROGRAM_INVOCATION_NAME])
191 HAVE_GETPROGNAME=1; AC_SUBST([HAVE_GETPROGNAME])
133 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) 192 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
134 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) 193 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
135 HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE]) 194 HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE])
@@ -146,7 +205,6 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
146 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R]) 205 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R])
147 HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R]) 206 HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R])
148 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM]) 207 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM])
149 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
150 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) 208 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
151 HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY]) 209 HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY])
152 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) 210 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
@@ -157,6 +215,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
157 HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE]) 215 HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE])
158 HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE]) 216 HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE])
159 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) 217 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
218 HAVE_STRTOF=1; AC_SUBST([HAVE_STRTOF])
160 HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL]) 219 HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL])
161 HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD]) 220 HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD])
162 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) 221 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
@@ -164,32 +223,44 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
164 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) 223 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
165 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) 224 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
166 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) 225 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
226 HAVE_SYS_PROCESS_H=0; AC_SUBST([HAVE_SYS_PROCESS_H])
167 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) 227 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
168 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) 228 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
229 REPLACE__EXIT=0; AC_SUBST([REPLACE__EXIT])
230 REPLACE_ABORT=0; AC_SUBST([REPLACE_ABORT])
169 REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC]) 231 REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC])
170 REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU]) 232 REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
171 REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX]) 233 REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
172 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) 234 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
173 REPLACE_FREE=0; AC_SUBST([REPLACE_FREE]) 235 REPLACE_FREE=0; AC_SUBST([REPLACE_FREE])
236 REPLACE_GETLOADAVG=0; AC_SUBST([REPLACE_GETLOADAVG])
237 REPLACE_GETPROGNAME=0; AC_SUBST([REPLACE_GETPROGNAME])
238 REPLACE_GETSUBOPT=0; AC_SUBST([REPLACE_GETSUBOPT])
174 REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE]) 239 REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE])
175 REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU]) 240 REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
176 REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX]) 241 REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
242 REPLACE_MB_CUR_MAX=0; AC_SUBST([REPLACE_MB_CUR_MAX])
243 REPLACE_MBSTOWCS=0; AC_SUBST([REPLACE_MBSTOWCS])
177 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) 244 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
245 REPLACE_MKOSTEMP=0; AC_SUBST([REPLACE_MKOSTEMP])
246 REPLACE_MKOSTEMPS=0; AC_SUBST([REPLACE_MKOSTEMPS])
178 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) 247 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
179 REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN]) 248 REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN])
249 REPLACE_POSIX_OPENPT=0; AC_SUBST([REPLACE_POSIX_OPENPT])
180 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) 250 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
181 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) 251 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
182 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) 252 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
183 REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R]) 253 REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R])
254 REPLACE_RAND=0; AC_SUBST([REPLACE_RAND])
184 REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM]) 255 REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM])
185 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) 256 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
186 REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
187 REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX]) 257 REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
188 REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY]) 258 REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY])
189 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) 259 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
190 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) 260 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
191 REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE]) 261 REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE])
192 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) 262 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
263 REPLACE_STRTOF=0; AC_SUBST([REPLACE_STRTOF])
193 REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL]) 264 REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL])
194 REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD]) 265 REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD])
195 REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL]) 266 REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL])
@@ -197,4 +268,5 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
197 REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL]) 268 REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL])
198 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) 269 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
199 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) 270 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB])
271 CAN_PRINT_STACK_TRACE=0; AC_SUBST([CAN_PRINT_STACK_TRACE])
200]) 272])
diff --git a/gl/m4/strcasecmp.m4 b/gl/m4/strcasecmp.m4
new file mode 100644
index 00000000..f9f90928
--- /dev/null
+++ b/gl/m4/strcasecmp.m4
@@ -0,0 +1,67 @@
1# strcasecmp.m4
2# serial 3
3dnl Copyright (C) 2002-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_STRCASECMP],
10[
11 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
12 AC_CHECK_FUNCS([strcasecmp])
13 if test $ac_cv_func_strcasecmp = yes; then
14 gl_STRCASECMP_WORKS
15 case "$gl_cv_func_strcasecmp_works" in
16 *yes) ;;
17 *) REPLACE_STRCASECMP=1 ;;
18 esac
19 else
20 HAVE_STRCASECMP=0
21 fi
22])
23
24AC_DEFUN([gl_STRCASECMP_WORKS],
25[
26 AC_REQUIRE([AC_CANONICAL_HOST])
27 AC_CACHE_CHECK([whether strcasecmp works],
28 [gl_cv_func_strcasecmp_works],
29 [dnl Prepare a guess, used when cross-compiling or when specific locales
30 dnl are not available.
31 case "$host_os" in
32 solaris* | cygwin*)
33 gl_cv_func_strcasecmp_works="guessing no" ;;
34 *)
35 gl_cv_func_strcasecmp_works="guessing yes" ;;
36 esac
37 AC_RUN_IFELSE(
38 [AC_LANG_SOURCE([[
39#include <stdio.h>
40#include <ctype.h>
41#include <locale.h>
42#include <strings.h>
43int main ()
44{
45 if (setlocale (LC_ALL, "fr_FR.ISO-8859-1") != NULL
46 || setlocale (LC_ALL, "fr_FR.ISO8859-1") != NULL)
47 {
48 int c1 = (unsigned char) '\311';
49 int c2 = (unsigned char) '\351';
50 if (tolower (c1) == c2 && toupper (c2) == c1)
51 return strcasecmp ("Fej\311r", "Fej\351r") != 0;
52 }
53 return 2;
54}]])],
55 [gl_cv_func_strcasecmp_works=yes],
56 [if test $? = 1; then
57 gl_cv_func_strcasecmp_works=no
58 fi
59 ],
60 [:])
61 ])
62])
63
64# Prerequisites of lib/strcasecmp.c.
65AC_DEFUN([gl_PREREQ_STRCASECMP], [
66 :
67])
diff --git a/gl/m4/strcasestr.m4 b/gl/m4/strcasestr.m4
index 971e0b23..f56eed58 100644
--- a/gl/m4/strcasestr.m4
+++ b/gl/m4/strcasestr.m4
@@ -1,8 +1,10 @@
1# strcasestr.m4 serial 28 1# strcasestr.m4
2dnl Copyright (C) 2005, 2007-2023 Free Software Foundation, Inc. 2# serial 29
3dnl Copyright (C) 2005, 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Check that strcasestr is present and works. 9dnl Check that strcasestr is present and works.
8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE], 10AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
@@ -20,8 +22,8 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
20 if test $REPLACE_MEMCHR = 1; then 22 if test $REPLACE_MEMCHR = 1; then
21 REPLACE_STRCASESTR=1 23 REPLACE_STRCASESTR=1
22 else 24 else
23 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092 25 dnl Detect https://sourceware.org/PR12092
24 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637. 26 dnl and https://sourceware.org/PR23637.
25 AC_CACHE_CHECK([whether strcasestr works], 27 AC_CACHE_CHECK([whether strcasestr works],
26 [gl_cv_func_strcasestr_works_always], 28 [gl_cv_func_strcasestr_works_always],
27 [AC_RUN_IFELSE( 29 [AC_RUN_IFELSE(
@@ -97,7 +99,7 @@ static void quit (int sig) { _exit (sig + 128); }
97 char *haystack = (char *) malloc (2 * m + 2); 99 char *haystack = (char *) malloc (2 * m + 2);
98 char *needle = (char *) malloc (m + 2); 100 char *needle = (char *) malloc (m + 2);
99 /* Failure to compile this test due to missing alarm is okay, 101 /* Failure to compile this test due to missing alarm is okay,
100 since all such platforms (mingw) also lack strcasestr. */ 102 since all such platforms (mingw, MSVC) also lack strcasestr. */
101 signal (SIGALRM, quit); 103 signal (SIGALRM, quit);
102 alarm (5); 104 alarm (5);
103 /* Check for quadratic performance. */ 105 /* Check for quadratic performance. */
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index 8879eb08..9bb60c3f 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,8 +1,10 @@
1# strerror.m4 serial 23 1# strerror.m4
2dnl Copyright (C) 2002, 2007-2023 Free Software Foundation, Inc. 2# serial 25
3dnl Copyright (C) 2002, 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_STRERROR], 9AC_DEFUN([gl_FUNC_STRERROR],
8[ 10[
@@ -24,12 +26,12 @@ AC_DEFUN([gl_FUNC_STRERROR],
24 [gl_cv_func_working_strerror=yes], 26 [gl_cv_func_working_strerror=yes],
25 [gl_cv_func_working_strerror=no], 27 [gl_cv_func_working_strerror=no],
26 [case "$host_os" in 28 [case "$host_os" in
27 # Guess yes on glibc systems. 29 # Guess yes on glibc systems.
28 *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;; 30 *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;;
29 # Guess yes on musl systems. 31 # Guess yes on musl systems.
30 *-musl*) gl_cv_func_working_strerror="guessing yes" ;; 32 *-musl* | midipix*) gl_cv_func_working_strerror="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses. 33 # If we don't know, obey --enable-cross-guesses.
32 *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;; 34 *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;;
33 esac 35 esac
34 ]) 36 ])
35 ]) 37 ])
@@ -80,14 +82,14 @@ AC_DEFUN([gl_FUNC_STRERROR_0],
80 [gl_cv_func_strerror_0_works=yes], 82 [gl_cv_func_strerror_0_works=yes],
81 [gl_cv_func_strerror_0_works=no], 83 [gl_cv_func_strerror_0_works=no],
82 [case "$host_os" in 84 [case "$host_os" in
83 # Guess yes on glibc systems. 85 # Guess yes on glibc systems.
84 *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; 86 *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
85 # Guess yes on musl systems. 87 # Guess yes on musl systems.
86 *-musl*) gl_cv_func_strerror_0_works="guessing yes" ;; 88 *-musl* | midipix*) gl_cv_func_strerror_0_works="guessing yes" ;;
87 # Guess yes on native Windows. 89 # Guess yes on native Windows.
88 mingw*) gl_cv_func_strerror_0_works="guessing yes" ;; 90 mingw* | windows*) gl_cv_func_strerror_0_works="guessing yes" ;;
89 # If we don't know, obey --enable-cross-guesses. 91 # If we don't know, obey --enable-cross-guesses.
90 *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;; 92 *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;;
91 esac 93 esac
92 ]) 94 ])
93 ]) 95 ])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index 5da3cc25..2a6e4db4 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -1,11 +1,12 @@
1# Configure a GNU-like replacement for <string.h>. 1# string_h.m4
2 2# serial 46
3# Copyright (C) 2007-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8# serial 35 9# Configure a GNU-like replacement for <string.h>.
9 10
10# Written by Paul Eggert. 11# Written by Paul Eggert.
11 12
@@ -23,8 +24,9 @@ AC_DEFUN_ONCE([gl_STRING_H],
23 ]], 24 ]],
24 [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit 25 [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit
25 rawmemchr stpcpy stpncpy strchrnul 26 rawmemchr stpcpy stpncpy strchrnul
26 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r 27 strdup strncat strncpy strndup strnlen strpbrk strsep strcasestr strtok_r
27 strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp]) 28 strerror_l strerror_r strerrorname_np
29 sigabbrev_np sigdescr_np strsignal strverscmp])
28 30
29 AC_REQUIRE([AC_C_RESTRICT]) 31 AC_REQUIRE([AC_C_RESTRICT])
30]) 32])
@@ -61,7 +63,9 @@ AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY]) 63 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY])
62 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL]) 64 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL])
63 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP]) 65 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP])
66 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRINGEQ])
64 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT]) 67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT])
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCPY])
65 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP]) 69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP])
66 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN]) 70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN])
67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK]) 71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK])
@@ -69,6 +73,8 @@ AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR]) 73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR]) 74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R]) 75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STR_STARTSWITH])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STR_ENDSWITH])
72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN]) 78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN])
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN]) 79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR]) 80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR])
@@ -83,8 +89,11 @@ AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN]) 89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP]) 90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R]) 91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBS_STARTSWITH])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBS_ENDSWITH])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR]) 94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R]) 95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_L])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP]) 97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP]) 98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP]) 99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP])
@@ -107,6 +116,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
107 HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO]) 116 HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO])
108 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) 117 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
109 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) 118 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
119 HAVE_DECL_MEMEQ=0; AC_SUBST([HAVE_DECL_MEMEQ])
110 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) 120 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
111 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) 121 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
112 HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT]) 122 HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT])
@@ -116,6 +126,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
116 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) 126 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
117 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) 127 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
118 HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) 128 HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
129 HAVE_DECL_STREQ=0; AC_SUBST([HAVE_DECL_STREQ])
119 HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) 130 HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
120 HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) 131 HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
121 HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) 132 HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
@@ -123,6 +134,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
123 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) 134 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
124 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) 135 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
125 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) 136 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
137 HAVE_STRERROR_L=1; AC_SUBST([HAVE_STRERROR_L])
126 HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP]) 138 HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP])
127 HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP]) 139 HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
128 HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP]) 140 HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP])
@@ -131,10 +143,14 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
131 REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL]) 143 REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL])
132 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) 144 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
133 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) 145 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
146 REPLACE_MEMPCPY=0; AC_SUBST([REPLACE_MEMPCPY])
147 REPLACE_MEMSET_EXPLICIT=0; AC_SUBST([REPLACE_MEMSET_EXPLICIT])
148 REPLACE_STPCPY=0; AC_SUBST([REPLACE_STPCPY])
134 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) 149 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
135 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) 150 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
136 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) 151 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
137 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) 152 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
153 REPLACE_STRNCPY=0; AC_SUBST([REPLACE_STRNCPY])
138 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) 154 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
139 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) 155 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
140 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) 156 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
@@ -142,7 +158,9 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
142 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) 158 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
143 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 159 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
144 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) 160 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
161 REPLACE_STRERROR_L=0; AC_SUBST([REPLACE_STRERROR_L])
145 REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP]) 162 REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP])
146 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) 163 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
164 REPLACE_STRVERSCMP=0; AC_SUBST([REPLACE_STRVERSCMP])
147 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) 165 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
148]) 166])
diff --git a/gl/m4/stringeq.m4 b/gl/m4/stringeq.m4
new file mode 100644
index 00000000..ffea8afc
--- /dev/null
+++ b/gl/m4/stringeq.m4
@@ -0,0 +1,25 @@
1# stringeq.m4
2# serial 1
3dnl Copyright (C) 2025-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_STREQ],
10[
11 AC_REQUIRE([gl_STRING_H_DEFAULTS])
12 AC_CHECK_DECLS_ONCE([streq])
13 if test $ac_cv_have_decl_streq != no; then
14 HAVE_DECL_STREQ=1
15 fi
16])
17
18AC_DEFUN([gl_FUNC_MEMEQ],
19[
20 AC_REQUIRE([gl_STRING_H_DEFAULTS])
21 AC_CHECK_DECLS_ONCE([memeq])
22 if test $ac_cv_have_decl_memeq != no; then
23 HAVE_DECL_MEMEQ=1
24 fi
25])
diff --git a/gl/m4/strings_h.m4 b/gl/m4/strings_h.m4
index 4c41221b..aec4f715 100644
--- a/gl/m4/strings_h.m4
+++ b/gl/m4/strings_h.m4
@@ -1,10 +1,12 @@
1# Configure a replacement for <strings.h>. 1# strings_h.m4
2# serial 9 2# serial 14
3dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
3 8
4# Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc. 9# Configure a replacement for <strings.h>.
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8 10
9AC_DEFUN_ONCE([gl_STRINGS_H], 11AC_DEFUN_ONCE([gl_STRINGS_H],
10[ 12[
@@ -27,7 +29,7 @@ AC_DEFUN_ONCE([gl_STRINGS_H],
27 <strings.h>. */ 29 <strings.h>. */
28 #include <sys/types.h> 30 #include <sys/types.h>
29 #include <strings.h> 31 #include <strings.h>
30 ]], [ffs strcasecmp strncasecmp]) 32 ]], [ffs strcasecmp strcasecmp_l strncasecmp strncasecmp_l])
31]) 33])
32 34
33# gl_STRINGS_MODULE_INDICATOR([modulename]) 35# gl_STRINGS_MODULE_INDICATOR([modulename])
@@ -48,6 +50,10 @@ AC_DEFUN([gl_STRINGS_H_REQUIRE_DEFAULTS],
48[ 50[
49 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [ 51 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS]) 52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS])
53 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASECMP])
54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASECMP_L])
55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCASECMP])
56 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCASECMP_L])
51 ]) 57 ])
52 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS]) 58 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS])
53 AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) 59 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
@@ -58,5 +64,12 @@ AC_DEFUN([gl_STRINGS_H_DEFAULTS],
58 dnl Assume proper GNU behavior unless another module says otherwise. 64 dnl Assume proper GNU behavior unless another module says otherwise.
59 HAVE_FFS=1; AC_SUBST([HAVE_FFS]) 65 HAVE_FFS=1; AC_SUBST([HAVE_FFS])
60 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) 66 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
67 HAVE_STRCASECMP_L=1; AC_SUBST([HAVE_STRCASECMP_L])
68 HAVE_STRNCASECMP=1; AC_SUBST([HAVE_STRNCASECMP])
69 HAVE_STRNCASECMP_L=1; AC_SUBST([HAVE_STRNCASECMP_L])
61 HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP]) 70 HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP])
71 REPLACE_STRCASECMP=0; AC_SUBST([REPLACE_STRCASECMP])
72 REPLACE_STRCASECMP_L=0; AC_SUBST([REPLACE_STRCASECMP_L])
73 REPLACE_STRNCASECMP=0; AC_SUBST([REPLACE_STRNCASECMP])
74 REPLACE_STRNCASECMP_L=0; AC_SUBST([REPLACE_STRNCASECMP_L])
62]) 75])
diff --git a/gl/m4/strcase.m4 b/gl/m4/strncasecmp.m4
index 3cf740d2..4314b603 100644
--- a/gl/m4/strcase.m4
+++ b/gl/m4/strncasecmp.m4
@@ -1,30 +1,22 @@
1# strcase.m4 serial 12 1# strncasecmp.m4
2dnl Copyright (C) 2002, 2005-2023 Free Software Foundation, Inc. 2# serial 2
3dnl Copyright (C) 2002-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
6 7dnl This file is offered as-is, without any warranty.
7AC_DEFUN([gl_STRCASE],
8[
9 gl_FUNC_STRCASECMP
10 gl_FUNC_STRNCASECMP
11])
12
13AC_DEFUN([gl_FUNC_STRCASECMP],
14[
15 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
16 AC_CHECK_FUNCS([strcasecmp])
17 if test $ac_cv_func_strcasecmp = no; then
18 HAVE_STRCASECMP=0
19 fi
20])
21 8
22AC_DEFUN([gl_FUNC_STRNCASECMP], 9AC_DEFUN([gl_FUNC_STRNCASECMP],
23[ 10[
24 AC_REQUIRE([gl_STRINGS_H_DEFAULTS]) 11 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
25 AC_CHECK_FUNCS([strncasecmp]) 12 AC_CHECK_FUNCS([strncasecmp])
26 if test $ac_cv_func_strncasecmp = yes; then 13 if test $ac_cv_func_strncasecmp = yes; then
27 HAVE_STRNCASECMP=1 14 dnl Assume that strncasecmp and strcasecmp share the same bugs.
15 gl_STRCASECMP_WORKS
16 case "$gl_cv_func_strcasecmp_works" in
17 *yes) ;;
18 *) REPLACE_STRNCASECMP=1 ;;
19 esac
28 else 20 else
29 HAVE_STRNCASECMP=0 21 HAVE_STRNCASECMP=0
30 fi 22 fi
@@ -34,11 +26,6 @@ AC_DEFUN([gl_FUNC_STRNCASECMP],
34 fi 26 fi
35]) 27])
36 28
37# Prerequisites of lib/strcasecmp.c.
38AC_DEFUN([gl_PREREQ_STRCASECMP], [
39 :
40])
41
42# Prerequisites of lib/strncasecmp.c. 29# Prerequisites of lib/strncasecmp.c.
43AC_DEFUN([gl_PREREQ_STRNCASECMP], [ 30AC_DEFUN([gl_PREREQ_STRNCASECMP], [
44 : 31 :
diff --git a/gl/m4/strncpy.m4 b/gl/m4/strncpy.m4
new file mode 100644
index 00000000..b94abede
--- /dev/null
+++ b/gl/m4/strncpy.m4
@@ -0,0 +1,94 @@
1# strncpy.m4
2# serial 1
3dnl Copyright (C) 2002-2004, 2009-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_FUNC_STRNCPY],
10[
11 AC_REQUIRE([gl_STRING_H_DEFAULTS])
12 AC_REQUIRE([AC_PROG_CC])
13 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
14
15 dnl Check for prerequisites for memory fence checks.
16 gl_FUNC_MMAP_ANON
17 AC_CHECK_HEADERS_ONCE([sys/mman.h])
18 AC_CHECK_FUNCS_ONCE([mprotect])
19
20 dnl Detect bug in FreeBSD 15.0 on x86_64:
21 dnl strncpy should not dereference more than n bytes, but always dereferences
22 dnl n+1 bytes if the first n bytes don't contain a NUL byte.
23 dnl Assume that strncpy works on platforms that lack mprotect.
24 AC_CACHE_CHECK([whether strncpy works], [gl_cv_func_strncpy_works],
25 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26#include <string.h>
27#if HAVE_SYS_MMAN_H
28# include <fcntl.h>
29# include <unistd.h>
30# include <sys/types.h>
31# include <sys/mman.h>
32#endif
33]GL_MDA_DEFINES],
34[[
35 char *fence = NULL;
36#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
37 {
38 long int pagesize = sysconf (_SC_PAGESIZE);
39 char *two_pages =
40 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
41 MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
42 if (two_pages != (char *)(-1)
43 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
44 fence = two_pages + pagesize;
45 }
46#endif
47 if (fence)
48 {
49 char dest[8];
50
51 dest[0] = 'a';
52 dest[1] = 'b';
53 dest[2] = 'c';
54 dest[3] = 'd';
55 dest[4] = 'e';
56 dest[5] = 'f';
57 dest[6] = 'g';
58
59 *(fence - 3) = '7';
60 *(fence - 2) = '2';
61 *(fence - 1) = '9';
62
63 if (strncpy (dest + 1, fence - 3, 3) != dest + 1)
64 return 1;
65 if (dest[0] != 'a')
66 return 2;
67 if (dest[1] != '7' || dest[2] != '2' || dest[3] != '9')
68 return 3;
69 if (dest[4] != 'e')
70 return 4;
71 }
72 return 0;
73]])], [gl_cv_func_strncpy_works=yes], [gl_cv_func_strncpy_works=no],
74 [
75 case "$host_os" in
76 # Guess no on FreeBSD.
77 freebsd* | dragonfly*) gl_cv_func_strncpy_works="guessing no" ;;
78 # Guess yes on native Windows.
79 mingw* | windows*) gl_cv_func_strncpy_works="guessing yes" ;;
80 # Guess yes otherwise.
81 *) gl_cv_func_strncpy_works="guessing yes" ;;
82 esac
83 ])
84 ])
85 case "$gl_cv_func_strncpy_works" in
86 *yes) ;;
87 *) REPLACE_STRNCPY=1 ;;
88 esac
89])
90
91# Prerequisites of lib/strncpy.c.
92AC_DEFUN([gl_PREREQ_STRNCPY], [
93 :
94])
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4
index e0da09a3..6afd34a9 100644
--- a/gl/m4/strsep.m4
+++ b/gl/m4/strsep.m4
@@ -1,8 +1,10 @@
1# strsep.m4 serial 11 1# strsep.m4
2dnl Copyright (C) 2002-2004, 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 11
3dnl Copyright (C) 2002-2004, 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_STRSEP], 9AC_DEFUN([gl_FUNC_STRSEP],
8[ 10[
diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4
index 7de203a7..3a9e9c60 100644
--- a/gl/m4/strstr.m4
+++ b/gl/m4/strstr.m4
@@ -1,8 +1,10 @@
1# strstr.m4 serial 24 1# strstr.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 25
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Check that strstr works. 9dnl Check that strstr works.
8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], 10AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
@@ -12,8 +14,8 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
12 if test $REPLACE_MEMCHR = 1; then 14 if test $REPLACE_MEMCHR = 1; then
13 REPLACE_STRSTR=1 15 REPLACE_STRSTR=1
14 else 16 else
15 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092 17 dnl Detect https://sourceware.org/PR12092
16 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637. 18 dnl and https://sourceware.org/PR23637.
17 AC_CACHE_CHECK([whether strstr works], 19 AC_CACHE_CHECK([whether strstr works],
18 [gl_cv_func_strstr_works_always], 20 [gl_cv_func_strstr_works_always],
19 [AC_RUN_IFELSE( 21 [AC_RUN_IFELSE(
@@ -94,7 +96,7 @@ static void quit (int sig) { _exit (sig + 128); }
94 char *haystack = (char *) malloc (2 * m + 2); 96 char *haystack = (char *) malloc (2 * m + 2);
95 char *needle = (char *) malloc (m + 2); 97 char *needle = (char *) malloc (m + 2);
96 /* Failure to compile this test due to missing alarm is okay, 98 /* Failure to compile this test due to missing alarm is okay,
97 since all such platforms (mingw) also have quadratic strstr. */ 99 since all such platforms (mingw, MSVC) also have quadratic strstr. */
98 signal (SIGALRM, quit); 100 signal (SIGALRM, quit);
99 alarm (5); 101 alarm (5);
100 /* Check for quadratic performance. */ 102 /* Check for quadratic performance. */
diff --git a/gl/m4/sys_cdefs_h.m4 b/gl/m4/sys_cdefs_h.m4
new file mode 100644
index 00000000..a1398a29
--- /dev/null
+++ b/gl/m4/sys_cdefs_h.m4
@@ -0,0 +1,26 @@
1# sys_cdefs_h.m4 - Is <sys/cdefs.h> compatible enough with glibc?
2# serial 2
3dnl Copyright 2024-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Written by Paul Eggert.
10
11AC_DEFUN_ONCE([gl_CHECK_HEADER_SYS_CDEFS_H],
12 [AC_CACHE_CHECK([for glibc-compatible sys/cdefs.h],
13 [gl_cv_header_sys_cdefs_h],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_DEFINES_PROVIDED
16 [#include <sys/cdefs.h>
17 enum { foo = __GNUC_PREREQ (14, 1) } bar;
18 ]],
19 [gl_cv_header_sys_cdefs_h=yes],
20 [gl_cv_header_sys_cdefs_h=no])])
21 if test "$gl_cv_header_sys_cdefs_h" = yes; then
22 HAVE_SYS_CDEFS_H=1
23 else
24 HAVE_SYS_CDEFS_H=0
25 fi
26 AC_SUBST([HAVE_SYS_CDEFS_H])])
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index 98a10416..cdc374e4 100644
--- a/gl/m4/sys_socket_h.m4
+++ b/gl/m4/sys_socket_h.m4
@@ -1,8 +1,10 @@
1# sys_socket_h.m4 serial 29 1# sys_socket_h.m4
2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. 2# serial 32
3dnl Copyright (C) 2005-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Simon Josefsson. 9dnl From Simon Josefsson.
8 10
@@ -11,17 +13,6 @@ AC_DEFUN_ONCE([gl_SYS_SOCKET_H],
11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 13 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) 14 AC_REQUIRE([AC_CANONICAL_HOST])
13 15
14 dnl On OSF/1, the functions recv(), send(), recvfrom(), sendto() have
15 dnl old-style declarations (with return type 'int' instead of 'ssize_t')
16 dnl unless _POSIX_PII_SOCKET is defined.
17 case "$host_os" in
18 osf*)
19 AC_DEFINE([_POSIX_PII_SOCKET], [1],
20 [Define to 1 in order to get the POSIX compatible declarations
21 of socket functions.])
22 ;;
23 esac
24
25 GL_GENERATE_SYS_SOCKET_H=false 16 GL_GENERATE_SYS_SOCKET_H=false
26 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], 17 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
27 [gl_cv_header_sys_socket_h_selfcontained], 18 [gl_cv_header_sys_socket_h_selfcontained],
@@ -51,24 +42,10 @@ AC_DEFUN_ONCE([gl_SYS_SOCKET_H],
51 fi 42 fi
52 # We need to check for ws2tcpip.h now. 43 # We need to check for ws2tcpip.h now.
53 gl_PREREQ_SYS_H_SOCKET 44 gl_PREREQ_SYS_H_SOCKET
54 AC_CHECK_TYPES([struct sockaddr_storage, sa_family_t],,,[ 45 gl_PREREQ_SYS_SA_FAMILY
55 /* sys/types.h is not needed according to POSIX, but the
56 sys/socket.h in i386-unknown-freebsd4.10 and
57 powerpc-apple-darwin5.5 required it. */
58#include <sys/types.h>
59#ifdef HAVE_SYS_SOCKET_H
60#include <sys/socket.h>
61#endif
62#ifdef HAVE_WS2TCPIP_H
63#include <ws2tcpip.h>
64#endif
65])
66 if test $ac_cv_type_struct_sockaddr_storage = no; then 46 if test $ac_cv_type_struct_sockaddr_storage = no; then
67 HAVE_STRUCT_SOCKADDR_STORAGE=0 47 HAVE_STRUCT_SOCKADDR_STORAGE=0
68 fi 48 fi
69 if test $ac_cv_type_sa_family_t = no; then
70 HAVE_SA_FAMILY_T=0
71 fi
72 if test $ac_cv_type_struct_sockaddr_storage != no; then 49 if test $ac_cv_type_struct_sockaddr_storage != no; then
73 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], 50 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],
74 [], 51 [],
@@ -157,6 +134,32 @@ AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP],
157 AC_SUBST([HAVE_WS2TCPIP_H]) 134 AC_SUBST([HAVE_WS2TCPIP_H])
158]) 135])
159 136
137# Common prerequisites of the <sys/socket.h> replacement and of the <sys/un.h>
138# replacement.
139# Sets and substitutes HAVE_SA_FAMILY_T.
140AC_DEFUN([gl_PREREQ_SYS_SA_FAMILY],
141[
142 AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
143 AC_CHECK_TYPES([struct sockaddr_storage, sa_family_t],,,[
144 /* sys/types.h is not needed according to POSIX, but the
145 sys/socket.h in i386-unknown-freebsd4.10 and
146 powerpc-apple-darwin5.5 required it. */
147#include <sys/types.h>
148#ifdef HAVE_SYS_SOCKET_H
149#include <sys/socket.h>
150#endif
151#ifdef HAVE_WS2TCPIP_H
152#include <ws2tcpip.h>
153#endif
154])
155 if test $ac_cv_type_sa_family_t = yes; then
156 HAVE_SA_FAMILY_T=1
157 else
158 HAVE_SA_FAMILY_T=0
159 fi
160 AC_SUBST([HAVE_SA_FAMILY_T])
161])
162
160# gl_SYS_SOCKET_MODULE_INDICATOR([modulename]) 163# gl_SYS_SOCKET_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module 164# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1. 165# to a C preprocessor expression that will evaluate to 1.
@@ -201,6 +204,5 @@ AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
201 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) 204 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
202 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; 205 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
203 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) 206 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
204 HAVE_SA_FAMILY_T=1; AC_SUBST([HAVE_SA_FAMILY_T])
205 HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4]) 207 HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4])
206]) 208])
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
index ca57398a..04dfce7e 100644
--- a/gl/m4/sys_stat_h.m4
+++ b/gl/m4/sys_stat_h.m4
@@ -1,8 +1,10 @@
1# sys_stat_h.m4 serial 42 -*- Autoconf -*- 1# sys_stat_h.m4
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 2# serial 44 -*- Autoconf -*-
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Eric Blake. 9dnl From Eric Blake.
8dnl Provide a GNU-like <sys/stat.h>. 10dnl Provide a GNU-like <sys/stat.h>.
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
index 627671fb..b284e08e 100644
--- a/gl/m4/sys_types_h.m4
+++ b/gl/m4/sys_types_h.m4
@@ -1,8 +1,10 @@
1# sys_types_h.m4 serial 13 1# sys_types_h.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 15
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_SYS_TYPES_H], 9AC_DEFUN_ONCE([gl_SYS_TYPES_H],
8[ 10[
@@ -22,6 +24,9 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
22 dnl Whether to override the 'off_t' type. 24 dnl Whether to override the 'off_t' type.
23 AC_REQUIRE([gl_TYPE_OFF_T]) 25 AC_REQUIRE([gl_TYPE_OFF_T])
24 26
27 dnl Whether to define the 'off64_t' type.
28 AC_REQUIRE([gl_TYPE_OFF64_T])
29
25 dnl Whether to override the 'dev_t' and 'ino_t' types. 30 dnl Whether to override the 'dev_t' and 'ino_t' types.
26 m4_ifdef([gl_WINDOWS_STAT_INODES], [ 31 m4_ifdef([gl_WINDOWS_STAT_INODES], [
27 AC_REQUIRE([gl_WINDOWS_STAT_INODES]) 32 AC_REQUIRE([gl_WINDOWS_STAT_INODES])
@@ -29,6 +34,14 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
29 WINDOWS_STAT_INODES=0 34 WINDOWS_STAT_INODES=0
30 ]) 35 ])
31 AC_SUBST([WINDOWS_STAT_INODES]) 36 AC_SUBST([WINDOWS_STAT_INODES])
37
38 dnl Test whether the 'blksize_t' type is defined.
39 AC_CHECK_TYPE([blksize_t], [HAVE_BLKSIZE_T=1], [HAVE_BLKSIZE_T=0])
40 AC_SUBST([HAVE_BLKSIZE_T])
41
42 dnl Test whether the 'blkcnt_t' type is defined.
43 AC_CHECK_TYPE([blkcnt_t], [HAVE_BLKCNT_T=1], [HAVE_BLKCNT_T=0])
44 AC_SUBST([HAVE_BLKCNT_T])
32]) 45])
33 46
34# Initializes the default values for AC_SUBSTed shell variables. 47# Initializes the default values for AC_SUBSTed shell variables.
diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4
index 93a65d26..59496e01 100644
--- a/gl/m4/sys_uio_h.m4
+++ b/gl/m4/sys_uio_h.m4
@@ -1,8 +1,10 @@
1# sys_uio_h.m4 serial 3 1# sys_uio_h.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc. 2# serial 3
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_SYS_UIO_H], 9AC_DEFUN_ONCE([gl_SYS_UIO_H],
8[ 10[
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index b536b047..bdea4b97 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,8 +1,10 @@
1# threadlib.m4 serial 32a 1# threadlib.m4
2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc. 2# serial 49
3dnl Copyright (C) 2005-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
@@ -55,24 +57,12 @@ AC_DEFUN([gl_ANYTHREADLIB_EARLY],
55[ 57[
56 AC_REQUIRE([AC_CANONICAL_HOST]) 58 AC_REQUIRE([AC_CANONICAL_HOST])
57 if test -z "$gl_anythreadlib_early_done"; then 59 if test -z "$gl_anythreadlib_early_done"; then
58 case "$host_os" in
59 osf*)
60 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
61 # groks <pthread.h>. cc also understands the flag -pthread, but
62 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
63 # 2. putting a flag into CPPFLAGS that has an effect on the linker
64 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
65 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
66 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
67 ;;
68 esac
69 # Some systems optimize for single-threaded programs by default, and 60 # Some systems optimize for single-threaded programs by default, and
70 # need special flags to disable these optimizations. For example, the 61 # need special flags to disable these optimizations. For example, the
71 # definition of 'errno' in <errno.h>. 62 # definition of errno in <errno.h>.
72 case "$host_os" in 63 AS_CASE([$host_os],
73 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; 64 [aix* | freebsd*], [CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"],
74 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; 65 [hpux* | solaris*], [CPPFLAGS="$CPPFLAGS -D_REENTRANT"])
75 esac
76 gl_anythreadlib_early_done=done 66 gl_anythreadlib_early_done=done
77 fi 67 fi
78]) 68])
@@ -84,23 +74,26 @@ AC_DEFUN([gl_WEAK_SYMBOLS],
84 AC_REQUIRE([AC_CANONICAL_HOST]) 74 AC_REQUIRE([AC_CANONICAL_HOST])
85 AC_CACHE_CHECK([whether imported symbols can be declared weak], 75 AC_CACHE_CHECK([whether imported symbols can be declared weak],
86 [gl_cv_have_weak], 76 [gl_cv_have_weak],
87 [case "$host_os" in 77 [AS_CASE([$host_os],
88 cygwin*) 78 [cygwin* | mingw* | windows*],
89 dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but 79 [
90 dnl programs that use pthread_in_use() with weak symbol references 80 dnl On Cygwin 3.2.0 with gcc 10.2, and likewise on mingw 10.0.0 with
91 dnl crash miserably at runtime. 81 dnl gcc 11.3, the test below would succeed, but programs that use
82 dnl pthread_in_use() with weak symbol references crash miserably at
83 dnl runtime.
92 gl_cv_have_weak="guessing no" 84 gl_cv_have_weak="guessing no"
93 ;; 85 ],
94 *) 86 [
95 gl_cv_have_weak=no 87 gl_cv_have_weak=no
96 dnl First, test whether the compiler accepts it syntactically. 88 dnl First, test whether the compiler accepts it syntactically.
97 AC_LINK_IFELSE( 89 AC_LINK_IFELSE(
98 [AC_LANG_PROGRAM( 90 [AC_LANG_PROGRAM(
99 [[extern void xyzzy (); 91 [[extern void xyzzy ();
100#pragma weak xyzzy]], 92#pragma weak xyzzy
93 ]],
101 [[xyzzy();]])], 94 [[xyzzy();]])],
102 [gl_cv_have_weak=maybe]) 95 [gl_cv_have_weak=maybe])
103 if test $gl_cv_have_weak = maybe; then 96 AS_IF([test $gl_cv_have_weak = maybe], [
104 dnl Second, test whether it actually works. On Cygwin 1.7.2, with 97 dnl Second, test whether it actually works. On Cygwin 1.7.2, with
105 dnl gcc 4.3, symbols declared weak always evaluate to the address 0. 98 dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
106 AC_RUN_IFELSE( 99 AC_RUN_IFELSE(
@@ -123,20 +116,19 @@ int main ()
123 [gl_cv_have_weak="guessing yes"], 116 [gl_cv_have_weak="guessing yes"],
124 [gl_cv_have_weak="guessing no"]) 117 [gl_cv_have_weak="guessing no"])
125 ]) 118 ])
126 fi 119 ])
127 ;; 120 ])
128 esac 121 dnl But when linking statically, weak symbols do not work.
129 dnl But when linking statically, weak symbols don't work. 122 AS_CASE([" $LDFLAGS "],
130 case " $LDFLAGS " in 123 [*" -static "*], [gl_cv_have_weak=no])
131 *" -static "*) gl_cv_have_weak=no ;;
132 esac
133 dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak 124 dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
134 dnl symbol and linking against a shared library that has a dependency on 125 dnl symbol and linking against a shared library that has a dependency on
135 dnl the shared library that defines the symbol. 126 dnl the shared library that defines the symbol.
136 case "$gl_cv_have_weak" in 127 AS_CASE([$gl_cv_have_weak],
137 *yes) 128 [*yes],
138 case "$host_os" in 129 [AS_CASE([$host_os],
139 freebsd* | dragonfly* | midnightbsd*) 130 [freebsd* | dragonfly* | midnightbsd*],
131 [
140 : > conftest1.c 132 : > conftest1.c
141 $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1 133 $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
142 cat <<EOF > conftest2.c 134 cat <<EOF > conftest2.c
@@ -150,17 +142,15 @@ EOF
150 $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \ 142 $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
151 || gl_cv_have_weak=no 143 || gl_cv_have_weak=no
152 rm -f conftest1.c libempty.so conftest2.c conftest 144 rm -f conftest1.c libempty.so conftest2.c conftest
153 ;; 145 ])
154 esac 146 ])
155 ;;
156 esac
157 ]) 147 ])
158 case "$gl_cv_have_weak" in 148 AS_CASE([$gl_cv_have_weak],
159 *yes) 149 [*yes],
150 [
160 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], 151 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
161 [Define to 1 if the compiler and linker support weak declarations of symbols.]) 152 [Define to 1 if the compiler and linker support weak declarations of symbols.])
162 ;; 153 ])
163 esac
164]) 154])
165 155
166dnl ============================================================================ 156dnl ============================================================================
@@ -174,7 +164,7 @@ dnl Sets the variable LIBPMULTITHREAD, for programs that really need
174dnl multithread functionality. The difference between LIBPTHREAD and 164dnl multithread functionality. The difference between LIBPTHREAD and
175dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically 165dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically
176dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not. 166dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not.
177dnl Sets the variable LIB_SCHED_YIELD to the linker options needed to use the 167dnl Sets the variable SCHED_YIELD_LIB to the linker options needed to use the
178dnl sched_yield() function. 168dnl sched_yield() function.
179dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for 169dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
180dnl multithread-safe programs. 170dnl multithread-safe programs.
@@ -186,40 +176,34 @@ dnl The guts of gl_PTHREADLIB. Needs to be expanded only once.
186AC_DEFUN([gl_PTHREADLIB_BODY], 176AC_DEFUN([gl_PTHREADLIB_BODY],
187[ 177[
188 AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) 178 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
189 if test -z "$gl_pthreadlib_body_done"; then 179 AS_IF([test -z "$gl_pthreadlib_body_done"], [
190 gl_pthread_api=no 180 gl_pthread_api=no
191 LIBPTHREAD= 181 LIBPTHREAD=
192 LIBPMULTITHREAD= 182 LIBPMULTITHREAD=
193 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
194 # it groks <pthread.h>. It's added above, in gl_ANYTHREADLIB_EARLY.
195 AC_CHECK_HEADER([pthread.h], 183 AC_CHECK_HEADER([pthread.h],
196 [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) 184 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
197 if test "$gl_have_pthread_h" = yes; then 185 AS_IF([test "$gl_have_pthread_h" = yes], [
198 # Other possible tests: 186 # Other possible tests:
199 # -lpthreads (FSU threads, PCthreads) 187 # -lpthreads (FSU threads, PCthreads)
200 # -lgthreads 188 # -lgthreads
201 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist 189 # Test whether both pthread_mutex_lock exists in libc.
202 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
203 # the second one only in libpthread, and lock.c needs it.
204 # 190 #
205 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 191 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
206 # needs -pthread for some reason. See: 192 # needs -pthread for some reason. See:
207 # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html 193 # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html
208 save_LIBS=$LIBS 194 saved_LIBS="$LIBS"
209 for gl_pthread in '' '-pthread'; do 195 for gl_pthread in "" "-pthread"; do
210 LIBS="$LIBS $gl_pthread" 196 LIBS="$LIBS $gl_pthread"
211 AC_LINK_IFELSE( 197 AC_LINK_IFELSE(
212 [AC_LANG_PROGRAM( 198 [AC_LANG_PROGRAM(
213 [[#include <pthread.h> 199 [[#include <pthread.h>
214 pthread_mutex_t m; 200 pthread_mutex_t m;
215 pthread_mutexattr_t ma;
216 ]], 201 ]],
217 [[pthread_mutex_lock (&m); 202 [[pthread_mutex_lock (&m);]])],
218 pthread_mutexattr_init (&ma);]])],
219 [gl_pthread_api=yes 203 [gl_pthread_api=yes
220 LIBPTHREAD=$gl_pthread 204 LIBPTHREAD=$gl_pthread
221 LIBPMULTITHREAD=$gl_pthread]) 205 LIBPMULTITHREAD=$gl_pthread])
222 LIBS=$save_LIBS 206 LIBS="$saved_LIBS"
223 test $gl_pthread_api = yes && break 207 test $gl_pthread_api = yes && break
224 done 208 done
225 echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD 209 echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD
@@ -228,8 +212,9 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
228 gl_pthread_in_glibc=no 212 gl_pthread_in_glibc=no
229 # On Linux with glibc >= 2.34, libc contains the fully functional 213 # On Linux with glibc >= 2.34, libc contains the fully functional
230 # pthread functions. 214 # pthread functions.
231 case "$host_os" in 215 AS_CASE([$host_os],
232 linux*) 216 [linux*],
217 [
233 AC_EGREP_CPP([Lucky user], 218 AC_EGREP_CPP([Lucky user],
234 [#include <features.h> 219 [#include <features.h>
235 #ifdef __GNU_LIBRARY__ 220 #ifdef __GNU_LIBRARY__
@@ -240,19 +225,17 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
240 ], 225 ],
241 [gl_pthread_in_glibc=yes], 226 [gl_pthread_in_glibc=yes],
242 []) 227 [])
243 ;; 228 ])
244 esac
245 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD 229 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD
246 230
247 # Test for libpthread by looking for pthread_kill. (Not pthread_self, 231 # Test for libpthread by looking for pthread_kill.
248 # since it is defined as a macro on OSF/1.) 232 AS_IF([test $gl_pthread_api = yes && test -z "$LIBPTHREAD"], [
249 if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then
250 # The program links fine without libpthread. But it may actually 233 # The program links fine without libpthread. But it may actually
251 # need to link with libpthread in order to create multiple threads. 234 # need to link with libpthread in order to create multiple threads.
252 AC_CHECK_LIB([pthread], [pthread_kill], 235 AC_CHECK_LIB([pthread], [pthread_kill],
253 [if test $gl_pthread_in_glibc = yes; then 236 [AS_IF([test $gl_pthread_in_glibc = yes], [
254 LIBPMULTITHREAD= 237 LIBPMULTITHREAD=
255 else 238 ], [
256 LIBPMULTITHREAD=-lpthread 239 LIBPMULTITHREAD=-lpthread
257 # On Solaris and HP-UX, most pthread functions exist also in libc. 240 # On Solaris and HP-UX, most pthread functions exist also in libc.
258 # Therefore pthread_in_use() needs to actually try to create a 241 # Therefore pthread_in_use() needs to actually try to create a
@@ -260,56 +243,68 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
260 # pthread_create will actually create a thread. 243 # pthread_create will actually create a thread.
261 # On Solaris 10 or newer, this test is no longer needed, because 244 # On Solaris 10 or newer, this test is no longer needed, because
262 # libc contains the fully functional pthread functions. 245 # libc contains the fully functional pthread functions.
263 case "$host_os" in 246 AS_CASE([$host_os],
264changequote(,)dnl 247 [[solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*]],
265 solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*) 248 [
266changequote([,])dnl 249 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
267 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], 250 [Define if the pthread_in_use() detection is hard.])
268 [Define if the pthread_in_use() detection is hard.]) 251 ])
269 esac 252 ])
270 fi 253 ],
254 [dnl This is needed on FreeBSD 5.2.1.
255 AC_CHECK_LIB([thr], [pthread_kill],
256 [if test $gl_pthread_in_glibc = yes; then
257 LIBPMULTITHREAD=
258 else
259 LIBPMULTITHREAD=-lthr
260 fi
261 ])
271 ]) 262 ])
272 elif test $gl_pthread_api != yes; then 263 ], [test $gl_pthread_api != yes], [
273 # Some library is needed. Try libpthread and libc_r. 264 # Some library is needed. Try libpthread and libc_r.
274 AC_CHECK_LIB([pthread], [pthread_kill], 265 AC_CHECK_LIB([pthread], [pthread_kill],
275 [gl_pthread_api=yes 266 [gl_pthread_api=yes
276 LIBPTHREAD=-lpthread 267 LIBPTHREAD=-lpthread
277 LIBPMULTITHREAD=-lpthread]) 268 LIBPMULTITHREAD=-lpthread])
278 if test $gl_pthread_api != yes; then 269 AS_IF([test $gl_pthread_api != yes], [
279 # For FreeBSD 4. 270 # For FreeBSD 4.
280 AC_CHECK_LIB([c_r], [pthread_kill], 271 AC_CHECK_LIB([c_r], [pthread_kill],
281 [gl_pthread_api=yes 272 [gl_pthread_api=yes
282 LIBPTHREAD=-lc_r 273 LIBPTHREAD=-lc_r
283 LIBPMULTITHREAD=-lc_r]) 274 LIBPMULTITHREAD=-lc_r])
284 fi 275 ])
285 fi 276 ])
286 echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD 277 echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD
287 fi 278 ])
288 AC_MSG_CHECKING([whether POSIX threads API is available]) 279 AC_MSG_CHECKING([whether POSIX threads API is available])
289 AC_MSG_RESULT([$gl_pthread_api]) 280 AC_MSG_RESULT([$gl_pthread_api])
290 AC_SUBST([LIBPTHREAD]) 281 AC_SUBST([LIBPTHREAD])
291 AC_SUBST([LIBPMULTITHREAD]) 282 AC_SUBST([LIBPMULTITHREAD])
292 if test $gl_pthread_api = yes; then 283 AS_IF([test $gl_pthread_api = yes], [
293 AC_DEFINE([HAVE_PTHREAD_API], [1], 284 AC_DEFINE([HAVE_PTHREAD_API], [1],
294 [Define if you have the <pthread.h> header and the POSIX threads API.]) 285 [Define if you have the <pthread.h> header and the POSIX threads API.])
295 fi 286 ])
296 287
297 dnl On some systems, sched_yield is in librt, rather than in libpthread. 288 dnl On some systems, sched_yield is in librt, rather than in libpthread.
298 AC_LINK_IFELSE( 289 AC_LINK_IFELSE(
299 [AC_LANG_PROGRAM( 290 [AC_LANG_PROGRAM(
300 [[#include <sched.h>]], 291 [[#include <sched.h>
292 ]],
301 [[sched_yield ();]])], 293 [[sched_yield ();]])],
302 [LIB_SCHED_YIELD= 294 [SCHED_YIELD_LIB=
303 ], 295 ],
304 [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc. 296 [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
305 AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt], 297 AC_CHECK_LIB([rt], [sched_yield], [SCHED_YIELD_LIB=-lrt],
306 [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt. 298 [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
307 AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])]) 299 AC_CHECK_LIB([posix4], [sched_yield], [SCHED_YIELD_LIB=-lposix4])])
308 ]) 300 ])
301 AC_SUBST([SCHED_YIELD_LIB])
302 dnl For backward compatibility.
303 LIB_SCHED_YIELD="$SCHED_YIELD_LIB"
309 AC_SUBST([LIB_SCHED_YIELD]) 304 AC_SUBST([LIB_SCHED_YIELD])
310 305
311 gl_pthreadlib_body_done=done 306 gl_pthreadlib_body_done=done
312 fi 307 ])
313]) 308])
314 309
315AC_DEFUN([gl_PTHREADLIB], 310AC_DEFUN([gl_PTHREADLIB],
@@ -336,44 +331,45 @@ AC_DEFUN([gl_STDTHREADLIB_BODY],
336[ 331[
337 AC_REQUIRE([gl_ANYTHREADLIB_EARLY]) 332 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
338 AC_REQUIRE([AC_CANONICAL_HOST]) 333 AC_REQUIRE([AC_CANONICAL_HOST])
339 if test -z "$gl_stdthreadlib_body_done"; then 334 AS_IF([test -z "$gl_stdthreadlib_body_done"], [
340 AC_CHECK_HEADERS_ONCE([threads.h]) 335 AC_CHECK_HEADERS_ONCE([threads.h])
341 336
342 case "$host_os" in 337 AS_CASE([$host_os],
343 mingw*) 338 [mingw* | windows*],
339 [
344 LIBSTDTHREAD= 340 LIBSTDTHREAD=
345 ;; 341 ],
346 *) 342 [
347 gl_PTHREADLIB_BODY 343 gl_PTHREADLIB_BODY
348 if test $ac_cv_header_threads_h = yes; then 344 AS_IF([test $ac_cv_header_threads_h = yes], [
349 dnl glibc >= 2.29 has thrd_create in libpthread. 345 dnl glibc >= 2.29 has thrd_create in libpthread.
350 dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends 346 dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends
351 dnl on libpthread (for the symbol 'pthread_mutexattr_gettype'). 347 dnl on libpthread (for the symbol pthread_mutexattr_gettype).
352 dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in 348 dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in
353 dnl libc. 349 dnl libc.
354 AC_CHECK_FUNCS([thrd_create]) 350 gl_CHECK_FUNCS_ANDROID([thrd_create], [[#include <threads.h>
355 if test $ac_cv_func_thrd_create = yes; then 351 ]])
352 AS_IF([test $ac_cv_func_thrd_create = yes], [
356 LIBSTDTHREAD= 353 LIBSTDTHREAD=
357 else 354 ], [
358 AC_CHECK_LIB([stdthreads], [thrd_create], [ 355 AC_CHECK_LIB([stdthreads], [thrd_create], [
359 LIBSTDTHREAD='-lstdthreads -lpthread' 356 LIBSTDTHREAD="-lstdthreads -lpthread"
360 ], [ 357 ], [
361 dnl Guess that thrd_create is in libpthread. 358 dnl Guess that thrd_create is in libpthread.
362 LIBSTDTHREAD="$LIBPMULTITHREAD" 359 LIBSTDTHREAD="$LIBPMULTITHREAD"
363 ]) 360 ])
364 fi 361 ])
365 else 362 ], [
366 dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c. 363 dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c.
367 LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD" 364 LIBSTDTHREAD="$LIBPMULTITHREAD $SCHED_YIELD_LIB"
368 fi 365 ])
369 ;; 366 ])
370 esac
371 AC_SUBST([LIBSTDTHREAD]) 367 AC_SUBST([LIBSTDTHREAD])
372 368
373 AC_MSG_CHECKING([whether ISO C threads API is available]) 369 AC_MSG_CHECKING([whether ISO C threads API is available])
374 AC_MSG_RESULT([$ac_cv_header_threads_h]) 370 AC_MSG_RESULT([$ac_cv_header_threads_h])
375 gl_stdthreadlib_body_done=done 371 gl_stdthreadlib_body_done=done
376 fi 372 ])
377]) 373])
378 374
379AC_DEFUN([gl_STDTHREADLIB], 375AC_DEFUN([gl_STDTHREADLIB],
@@ -390,7 +386,7 @@ dnl ------------
390dnl Tests for a multithreading library to be used. 386dnl Tests for a multithreading library to be used.
391dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO 387dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO
392dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the 388dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
393dnl default is 'no', otherwise it is system dependent. In both cases, the user 389dnl default is "no", otherwise it is system dependent. In both cases, the user
394dnl can change the choice through the options --enable-threads=choice or 390dnl can change the choice through the options --enable-threads=choice or
395dnl --disable-threads. 391dnl --disable-threads.
396dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS, 392dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS,
@@ -435,49 +431,46 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
435 m4_ifdef([gl_THREADLIB_DEFAULT_NO], 431 m4_ifdef([gl_THREADLIB_DEFAULT_NO],
436 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], 432 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
437 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) 433 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
438 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=]) 434 dnl gl_use_winpthreads_default defaults to "no", because in mingw 10, like
435 dnl in mingw 5, the use of libwinpthread still makes test-pthread-tss crash.
436 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=no])
437 dnl Don't display the --disable-threads option
438 dnl - if the package builds one or more libraries, because libraries must
439 dnl always be multithread-safe (as far as possible),
440 dnl - if the package defines gl_THREADLIB_DEFAULT_NO, because the option
441 dnl would then be a no-op.
439 AC_ARG_ENABLE([threads], 442 AC_ARG_ENABLE([threads],
440AS_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ 443AS_HELP_STRING([[--enable-threads={isoc|posix|isoc+posix|windows}]], [specify multithreading API])m4_ifdef([LT_INIT], [], [m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
441AS_HELP_STRING([--disable-threads], [build without multithread safety])]), 444AS_HELP_STRING([[--disable-threads]], [build without multithread safety])])]),
442 [gl_use_threads=$enableval], 445 [gl_use_threads=$enableval],
443 [if test -n "$gl_use_threads_default"; then 446 [if test -n "$gl_use_threads_default"; then
444 gl_use_threads="$gl_use_threads_default" 447 gl_use_threads="$gl_use_threads_default"
445 else 448 else
446changequote(,)dnl 449 AS_CASE([$host_os],
447 case "$host_os" in
448 dnl Disable multithreading by default on OSF/1, because it interferes
449 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
450 dnl child process gets an endless segmentation fault inside execvp().
451 osf*) gl_use_threads=no ;;
452 dnl Disable multithreading by default on Cygwin 1.5.x, because it has 450 dnl Disable multithreading by default on Cygwin 1.5.x, because it has
453 dnl bugs that lead to endless loops or crashes. See 451 dnl bugs that lead to endless loops or crashes. See
454 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>. 452 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
455 cygwin*) 453 [cygwin*],
456 case `uname -r` in 454 [AS_CASE([$(uname -r)],
457 1.[0-5].*) gl_use_threads=no ;; 455 [[1.[0-5].*]], [gl_use_threads=no],
458 *) gl_use_threads=yes ;; 456 [gl_use_threads=yes])
459 esac 457 ],
460 ;;
461 dnl Obey gl_AVOID_WINPTHREAD on mingw. 458 dnl Obey gl_AVOID_WINPTHREAD on mingw.
462 mingw*) 459 [mingw* | windows*],
463 case "$gl_use_winpthreads_default" in 460 [AS_CASE([$gl_use_winpthreads_default],
464 yes) gl_use_threads=posix ;; 461 [yes], [gl_use_threads=posix],
465 no) gl_use_threads=windows ;; 462 [no], [gl_use_threads=windows],
466 *) gl_use_threads=yes ;; 463 [gl_use_threads=yes])
467 esac 464 ],
468 ;; 465 [gl_use_threads=yes])
469 *) gl_use_threads=yes ;;
470 esac
471changequote([,])dnl
472 fi 466 fi
473 ]) 467 ])
474 if test "$gl_use_threads" = yes \ 468 AS_CASE([$gl_use_threads],
475 || test "$gl_use_threads" = isoc \ 469 [yes | isoc | posix | isoc+posix],
476 || test "$gl_use_threads" = posix \ 470 [
477 || test "$gl_use_threads" = isoc+posix; then 471 # For using <threads.h> or <pthread.h>:
478 # For using <threads.h> or <pthread.h>: 472 gl_ANYTHREADLIB_EARLY
479 gl_ANYTHREADLIB_EARLY 473 ])
480 fi
481]) 474])
482 475
483dnl The guts of gl_THREADLIB. Needs to be expanded only once. 476dnl The guts of gl_THREADLIB. Needs to be expanded only once.
@@ -490,86 +483,95 @@ AC_DEFUN([gl_THREADLIB_BODY],
490 LTLIBTHREAD= 483 LTLIBTHREAD=
491 LIBMULTITHREAD= 484 LIBMULTITHREAD=
492 LTLIBMULTITHREAD= 485 LTLIBMULTITHREAD=
493 if test "$gl_use_threads" != no; then 486 AS_IF([test "$gl_use_threads" = no],
487 [AC_DEFINE([AVOID_ANY_THREADS], [1],
488 [Define if no multithread safety and no multithreading is desired.])],
489 [
494 dnl Check whether the compiler and linker support weak declarations. 490 dnl Check whether the compiler and linker support weak declarations.
495 gl_WEAK_SYMBOLS 491 gl_WEAK_SYMBOLS
496 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 492 AS_CASE([$gl_cv_have_weak],
497 dnl If we use weak symbols to implement pthread_in_use / pth_in_use / 493 [*yes],
498 dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create 494 [
499 dnl facility is in use. 495 dnl If we use weak symbols to implement pthread_in_use / pth_in_use /
500 AC_CHECK_HEADERS_ONCE([threads.h]) 496 dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create
501 : 497 dnl facility is in use.
502 fi 498 AC_CHECK_HEADERS_ONCE([threads.h])
503 if test "$gl_use_threads" = isoc || test "$gl_use_threads" = isoc+posix; then 499 :
504 AC_CHECK_HEADERS_ONCE([threads.h]) 500 ])
505 gl_have_isoc_threads="$ac_cv_header_threads_h" 501 AS_CASE([$gl_use_threads],
506 fi 502 [isoc | isoc+posix],
507 if test "$gl_use_threads" = yes \ 503 [
508 || test "$gl_use_threads" = posix \ 504 AC_CHECK_HEADERS_ONCE([threads.h])
509 || test "$gl_use_threads" = isoc+posix; then 505 gl_have_isoc_threads="$ac_cv_header_threads_h"
510 gl_PTHREADLIB_BODY 506 ])
511 LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD 507 AS_CASE([$gl_use_threads],
512 LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD 508 [yes | posix | isoc+posix],
513 if test $gl_pthread_api = yes; then 509 [
514 if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then 510 gl_PTHREADLIB_BODY
515 gl_threads_api='isoc+posix' 511 LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD
516 AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1], 512 LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD
517 [Define if the combination of the ISO C and POSIX multithreading APIs can be used.]) 513 AS_IF([test $gl_pthread_api = yes], [
518 LIBTHREAD= LTLIBTHREAD= 514 AS_IF([test "$gl_use_threads" = isoc+posix &&
519 else 515 test "$gl_have_isoc_threads" = yes], [
520 gl_threads_api=posix 516 gl_threads_api="isoc+posix"
521 AC_DEFINE([USE_POSIX_THREADS], [1], 517 AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1],
522 [Define if the POSIX multithreading library can be used.]) 518 [Define if the combination of the ISO C and POSIX multithreading APIs can be used.])
523 if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then 519 LIBTHREAD= LTLIBTHREAD=
524 AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1], 520 ], [
525 [Define if references to the POSIX multithreading library are satisfied by libc.]) 521 gl_threads_api=posix
526 else 522 AC_DEFINE([USE_POSIX_THREADS], [1],
527 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 523 [Define if the POSIX multithreading library can be used.])
528 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], 524 AS_IF([test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"], [
529 [Define if references to the POSIX multithreading library should be made weak.]) 525 AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1],
530 LIBTHREAD= LTLIBTHREAD= 526 [Define if references to the POSIX multithreading library are satisfied by libc.])
531 else 527 ], [
532 case "$host_os" in 528 AS_CASE([$gl_cv_have_weak],
533 freebsd* | dragonfly* | midnightbsd*) 529 [*yes],
534 if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then 530 [
535 dnl If weak symbols can't tell whether pthread_create(), pthread_key_create() 531 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
536 dnl etc. will succeed, we need a runtime test. 532 [Define if references to the POSIX multithreading library should be made weak.])
537 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], 533 LIBTHREAD= LTLIBTHREAD=
538 [Define if the pthread_in_use() detection is hard.]) 534 ],
539 fi 535 [AS_CASE([$host_os],
540 ;; 536 [freebsd* | dragonfly* | midnightbsd*],
541 esac 537 [
542 fi 538 AS_IF([test "x$LIBTHREAD" != "x$LIBMULTITHREAD"], [
543 fi 539 dnl If weak symbols cannot tell whether
544 fi 540 dnl pthread_create(), dnl pthread_key_create()
545 fi 541 dnl etc. will succeed, we need a runtime test.
546 fi 542 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
547 if test $gl_threads_api = none; then 543 [Define if the pthread_in_use() detection is hard.])
548 if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then 544 ])
545 ])
546 ])
547 ])
548 ])
549 ])
550 ])
551 AS_IF([test $gl_threads_api = none], [
552 AS_IF([test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes], [
549 gl_STDTHREADLIB_BODY 553 gl_STDTHREADLIB_BODY
550 LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD 554 LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD
551 LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD 555 LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD
552 gl_threads_api=isoc 556 gl_threads_api=isoc
553 AC_DEFINE([USE_ISOC_THREADS], [1], 557 AC_DEFINE([USE_ISOC_THREADS], [1],
554 [Define if the ISO C multithreading library can be used.]) 558 [Define if the ISO C multithreading library can be used.])
555 fi 559 ])
556 fi 560 ])
557 if test $gl_threads_api = none; then 561 AS_IF([test $gl_threads_api = none], [
558 case "$gl_use_threads" in 562 # The "win32" is for backward compatibility.
559 yes | windows | win32) # The 'win32' is for backward compatibility. 563 AS_CASE([$gl_use_threads],
560 if { case "$host_os" in 564 [yes | windows | win32],
561 mingw*) true;; 565 [AS_CASE([$host_os],
562 *) false;; 566 [mingw* | windows*],
563 esac 567 [
564 }; then 568 gl_threads_api=windows
565 gl_threads_api=windows 569 AC_DEFINE([USE_WINDOWS_THREADS], [1],
566 AC_DEFINE([USE_WINDOWS_THREADS], [1], 570 [Define if the native Windows multithreading API can be used.])
567 [Define if the native Windows multithreading API can be used.]) 571 ])
568 fi 572 ])
569 ;; 573 ])
570 esac 574 ])
571 fi
572 fi
573 AC_MSG_CHECKING([for multithread API to use]) 575 AC_MSG_CHECKING([for multithread API to use])
574 AC_MSG_RESULT([$gl_threads_api]) 576 AC_MSG_RESULT([$gl_threads_api])
575 AC_SUBST([LIBTHREAD]) 577 AC_SUBST([LIBTHREAD])
@@ -589,7 +591,7 @@ dnl gl_DISABLE_THREADS
589dnl ------------------ 591dnl ------------------
590dnl Sets the gl_THREADLIB default so that threads are not used by default. 592dnl Sets the gl_THREADLIB default so that threads are not used by default.
591dnl The user can still override it at installation time, by using the 593dnl The user can still override it at installation time, by using the
592dnl configure option '--enable-threads'. 594dnl configure option "--enable-threads".
593 595
594AC_DEFUN([gl_DISABLE_THREADS], [ 596AC_DEFUN([gl_DISABLE_THREADS], [
595 m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) 597 m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
@@ -601,7 +603,8 @@ dnl -------------------
601dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the 603dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the
602dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided. 604dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided.
603dnl The user can still override it at installation time, by using the 605dnl The user can still override it at installation time, by using the
604dnl configure option '--enable-threads'. 606dnl configure option "--enable-threads=posix".
607dnl As of 2023, this is now the default.
605 608
606AC_DEFUN([gl_AVOID_WINPTHREAD], [ 609AC_DEFUN([gl_AVOID_WINPTHREAD], [
607 m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no]) 610 m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no])
@@ -646,13 +649,8 @@ dnl
646dnl HP-UX 11 posix -lpthread N (cc) OK 649dnl HP-UX 11 posix -lpthread N (cc) OK
647dnl Y (gcc) 650dnl Y (gcc)
648dnl 651dnl
649dnl IRIX 6.5 posix -lpthread Y 0.5
650dnl
651dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK 652dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK
652dnl 653dnl
653dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK
654dnl -lpthread (gcc) Y
655dnl
656dnl Cygwin posix -lpthread Y OK 654dnl Cygwin posix -lpthread Y OK
657dnl 655dnl
658dnl Mingw windows N OK 656dnl Mingw windows N OK
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index f6bf3a4f..8d896ea5 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,12 +1,13 @@
1# Configure a more-standard replacement for <time.h>. 1# time_h.m4
2 2# serial 27
3# Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2000-2001, 2003-2007, 2009-2026 Free Software Foundation,
4 4dnl Inc.
5# serial 20 5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
6 9
7# This file is free software; the Free Software Foundation 10# Configure a more-standard replacement for <time.h>.
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10 11
11# Written by Paul Eggert and Jim Meyering. 12# Written by Paul Eggert and Jim Meyering.
12 13
@@ -23,7 +24,10 @@ AC_DEFUN_ONCE([gl_TIME_H],
23 dnl corresponding gnulib module is not in use. 24 dnl corresponding gnulib module is not in use.
24 gl_WARN_ON_USE_PREPARE([[ 25 gl_WARN_ON_USE_PREPARE([[
25#include <time.h> 26#include <time.h>
26 ]], [asctime_r ctime_r]) 27 ]], [
28 asctime asctime_r ctime ctime_r gmtime_r localtime localtime_r mktime
29 nanosleep strftime strptime time timegm timespec_get timespec_getres tzset
30 ])
27 31
28 AC_REQUIRE([AC_C_RESTRICT]) 32 AC_REQUIRE([AC_C_RESTRICT])
29 33
@@ -137,11 +141,13 @@ AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS],
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP]) 141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME]) 142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) 143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) 145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) 146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) 147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R]) 148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ]) 149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZNAME])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET]) 151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET])
146 dnl Support Microsoft deprecated alias function names by default. 152 dnl Support Microsoft deprecated alias function names by default.
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1]) 153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1])
@@ -159,25 +165,21 @@ AC_DEFUN([gl_TIME_H_DEFAULTS],
159 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 165 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
160 HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET]) 166 HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET])
161 HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES]) 167 HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES])
162 dnl Even GNU libc does not have timezone_t yet. 168 dnl Even GNU libc does not have timezone_t and tzalloc() yet.
163 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) 169 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
164 dnl If another module says to replace or to not replace, do that. 170 HAVE_TZALLOC=0; AC_SUBST([HAVE_TZALLOC])
165 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 171 REPLACE_CTIME=0; AC_SUBST([REPLACE_CTIME])
166 dnl this lets maintainers check for portability.
167 REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
168 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
169 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
170 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
171 REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME])
172 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
173 REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET])
174
175 dnl Hack so that the time module doesn't depend on the sys_time module.
176 dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
177 : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY])
178 dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
179 dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
180 dnl is no longer a big deal.
181 REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) 172 REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
182 REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) 173 REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
174 REPLACE_LOCALTIME_R=0; AC_SUBST([REPLACE_LOCALTIME_R])
175 REPLACE_LOCALTIME_RZ=0; AC_SUBST([REPLACE_LOCALTIME_RZ])
176 REPLACE_MKTIME=0; AC_SUBST([REPLACE_MKTIME])
177 REPLACE_MKTIME_Z=0; AC_SUBST([REPLACE_MKTIME_Z])
178 REPLACE_NANOSLEEP=0; AC_SUBST([REPLACE_NANOSLEEP])
179 REPLACE_STRFTIME=0; AC_SUBST([REPLACE_STRFTIME])
180 REPLACE_TIME=0; AC_SUBST([REPLACE_TIME])
181 REPLACE_TIMEGM=0; AC_SUBST([REPLACE_TIMEGM])
182 REPLACE_TIMESPEC_GET=0; AC_SUBST([REPLACE_TIMESPEC_GET])
183 REPLACE_TIMESPEC_GETRES=0; AC_SUBST([REPLACE_TIMESPEC_GETRES])
184 REPLACE_TZSET=0; AC_SUBST([REPLACE_TZSET])
183]) 185])
diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4
index adce438a..59477e3b 100644
--- a/gl/m4/time_r.m4
+++ b/gl/m4/time_r.m4
@@ -1,9 +1,12 @@
1dnl Reentrant time functions: localtime_r, gmtime_r. 1# time_r.m4
2 2# serial 1
3dnl Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2003, 2006-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl Reentrant time functions: localtime_r, gmtime_r.
7 10
8dnl Written by Paul Eggert. 11dnl Written by Paul Eggert.
9 12
@@ -57,9 +60,7 @@ AC_DEFUN([gl_TIME_R],
57 [gl_cv_time_r_posix=yes], 60 [gl_cv_time_r_posix=yes],
58 [gl_cv_time_r_posix=no]) 61 [gl_cv_time_r_posix=no])
59 ]) 62 ])
60 if test $gl_cv_time_r_posix = yes; then 63 if test $gl_cv_time_r_posix != yes; then
61 REPLACE_LOCALTIME_R=0
62 else
63 REPLACE_LOCALTIME_R=1 64 REPLACE_LOCALTIME_R=1
64 fi 65 fi
65 else 66 else
diff --git a/gl/m4/timegm.m4 b/gl/m4/timegm.m4
index 6079f1a3..50a98b25 100644
--- a/gl/m4/timegm.m4
+++ b/gl/m4/timegm.m4
@@ -1,15 +1,16 @@
1# timegm.m4 serial 13 1# timegm.m4
2dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc. 2# serial 16
3dnl Copyright (C) 2003, 2007, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_TIMEGM], 9AC_DEFUN([gl_FUNC_TIMEGM],
8[ 10[
9 AC_REQUIRE([gl_TIME_H_DEFAULTS]) 11 AC_REQUIRE([gl_TIME_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_MKTIME_WORKS]) 12 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
11 REPLACE_TIMEGM=0 13 gl_CHECK_FUNCS_ANDROID([timegm], [[#include <time.h>]])
12 AC_CHECK_FUNCS_ONCE([timegm])
13 if test $ac_cv_func_timegm = yes; then 14 if test $ac_cv_func_timegm = yes; then
14 if test "$gl_cv_func_working_mktime" != yes; then 15 if test "$gl_cv_func_working_mktime" != yes; then
15 # Assume that timegm is buggy if mktime is. 16 # Assume that timegm is buggy if mktime is.
@@ -17,6 +18,9 @@ AC_DEFUN([gl_FUNC_TIMEGM],
17 fi 18 fi
18 else 19 else
19 HAVE_TIMEGM=0 20 HAVE_TIMEGM=0
21 case "$gl_cv_onwards_func_timegm" in
22 future*) REPLACE_TIMEGM=1 ;;
23 esac
20 fi 24 fi
21]) 25])
22 26
diff --git a/gl/m4/uchar_h.m4 b/gl/m4/uchar_h.m4
new file mode 100644
index 00000000..20b63b6c
--- /dev/null
+++ b/gl/m4/uchar_h.m4
@@ -0,0 +1,279 @@
1# uchar_h.m4
2# serial 32
3dnl Copyright (C) 2019-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9dnl From Bruno Haible.
10dnl Prepare the overridden <uchar.h>.
11
12AC_DEFUN_ONCE([gl_UCHAR_H],
13[
14 AC_REQUIRE([gl_UCHAR_H_DEFAULTS])
15
16 gl_CHECK_NEXT_HEADERS([uchar.h])
17 if test $ac_cv_header_uchar_h = yes; then
18 HAVE_UCHAR_H=1
19 else
20 HAVE_UCHAR_H=0
21 fi
22 AC_SUBST([HAVE_UCHAR_H])
23
24 dnl On macOS 15, in C mode, <uchar.h> does not exist. But in C++ mode,
25 dnl it exists, and we need to #include_next it, otherwise we get an error
26 dnl "<cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h>
27 dnl header."
28 m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])])
29 CXX_HAVE_UCHAR_H=0
30 if test "$CXX" != no; then
31 AC_CACHE_CHECK([whether the C++ compiler has <uchar.h>],
32 [gl_cv_cxx_have_uchar_h],
33 [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
34 dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
35 cat > conftest.cpp <<\EOF
36#include <uchar.h>
37EOF
38 gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
39 if AC_TRY_EVAL([gl_command]); then
40 gl_cv_cxx_have_uchar_h=yes
41 else
42 gl_cv_cxx_have_uchar_h=no
43 fi
44 rm -fr conftest*
45 ])
46 if test $gl_cv_cxx_have_uchar_h = yes; then
47 CXX_HAVE_UCHAR_H=1
48 fi
49 fi
50 AC_SUBST([CXX_HAVE_UCHAR_H])
51
52 gl_TYPE_CHAR8_T
53 gl_TYPE_CHAR16_T
54 gl_TYPE_CHAR32_T
55
56 dnl In C++ mode, clang defines 'char16_t' and 'char32_t' as built-in types
57 dnl on some platforms (e.g. OpenBSD 6.7), and as types defined by many
58 dnl header files (<limits.h>, <stddef.h>, <stdint.h>, <stdio.h>, <stdlib.h>
59 dnl and others) on some platforms (e.g. Mac OS X 10.13).
60 dnl The same thing may also happen for 'char8_t'; so, be prepared for it.
61 m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])])
62 CXX_HAS_UCHAR_TYPES=0
63 if test $HAVE_UCHAR_H = 0; then
64 if test "$CXX" != no; then
65 AC_CACHE_CHECK([whether the C++ compiler predefines the <uchar.h> types],
66 [gl_cv_cxx_has_uchar_types],
67 [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
68 dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
69 cat > conftest.cpp <<\EOF
70#include <stddef.h>
71char16_t a;
72char32_t b;
73EOF
74 gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
75 if AC_TRY_EVAL([gl_command]); then
76 gl_cv_cxx_has_uchar_types=yes
77 else
78 gl_cv_cxx_has_uchar_types=no
79 fi
80 rm -fr conftest*
81 ])
82 if test $gl_cv_cxx_has_uchar_types = yes; then
83 CXX_HAS_UCHAR_TYPES=1
84 fi
85 fi
86 fi
87 AC_SUBST([CXX_HAS_UCHAR_TYPES])
88 CXX_HAS_CHAR8_TYPE=0
89 if test $HAVE_UCHAR_H = 0; then
90 if test "$CXX" != no; then
91 AC_CACHE_CHECK([whether the C++ compiler predefines the char8_t type],
92 [gl_cv_cxx_has_char8_type],
93 [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
94 dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
95 cat > conftest.cpp <<\EOF
96#include <stddef.h>
97char8_t a;
98EOF
99 gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
100 if AC_TRY_EVAL([gl_command]); then
101 gl_cv_cxx_has_char8_type=yes
102 else
103 gl_cv_cxx_has_char8_type=no
104 fi
105 rm -fr conftest*
106 ])
107 if test $gl_cv_cxx_has_char8_type = yes; then
108 CXX_HAS_CHAR8_TYPE=1
109 fi
110 fi
111 fi
112 AC_SUBST([CXX_HAS_CHAR8_TYPE])
113
114 dnl Test whether a 'char32_t' can hold more characters than a 'wchar_t'.
115 gl_STDINT_BITSIZEOF([wchar_t], [gl_STDINT_INCLUDES])
116 if test $BITSIZEOF_WCHAR_T -lt 32; then
117 SMALL_WCHAR_T=1
118 else
119 SMALL_WCHAR_T=0
120 fi
121 dnl SMALL_WCHAR_T is expected to be 1 on 32-bit AIX, Cygwin, native Windows.
122 AC_SUBST([SMALL_WCHAR_T])
123
124 dnl Check for declarations of anything we want to poison if the
125 dnl corresponding gnulib module is not in use, and which is not
126 dnl guaranteed by C11.
127 gl_WARN_ON_USE_PREPARE([[
128 #ifdef __HAIKU__
129 #include <stdint.h>
130 #endif
131 #include <uchar.h>
132 ]], [c32rtomb mbrtoc16 mbrtoc32])
133])
134
135AC_DEFUN_ONCE([gl_TYPE_CHAR8_T],
136[
137 dnl Determine whether gnulib's <uchar.h> would, if present, override char8_t.
138 AC_CACHE_CHECK([whether char8_t is correctly defined],
139 [gl_cv_type_char8_t_works],
140 [AC_COMPILE_IFELSE(
141 [AC_LANG_PROGRAM([[
142 #ifdef __HAIKU__
143 #include <stdint.h>
144 #endif
145 #include <uchar.h>
146 int verify[(char8_t)(-1) >= 0 && sizeof (char8_t) == sizeof (unsigned char) ? 1 : -1];
147 ]])
148 ],
149 [gl_cv_type_char8_t_works=yes],
150 [gl_cv_type_char8_t_works=no])
151 ])
152 if test $gl_cv_type_char8_t_works = no; then
153 GNULIBHEADERS_OVERRIDE_CHAR8_T=1
154 else
155 GNULIBHEADERS_OVERRIDE_CHAR8_T=0
156 fi
157 AC_SUBST([GNULIBHEADERS_OVERRIDE_CHAR8_T])
158])
159
160dnl On Haiku 2020, char16_t and char32_t are incorrectly defined.
161dnl See <https://dev.haiku-os.org/ticket/15990>.
162AC_DEFUN_ONCE([gl_TYPE_CHAR16_T],
163[
164 dnl Determine whether gnulib's <uchar.h> would, if present, override char16_t.
165 AC_CACHE_CHECK([whether char16_t is correctly defined],
166 [gl_cv_type_char16_t_works],
167 [AC_COMPILE_IFELSE(
168 [AC_LANG_PROGRAM([[
169 #ifdef __HAIKU__
170 #include <stdint.h>
171 #endif
172 #include <uchar.h>
173 /* For simplicity, assume that uint16_least_t is equivalent to
174 'unsigned short'. */
175 int verify[(char16_t)(-1) >= 0 && sizeof (char16_t) == sizeof (unsigned short) ? 1 : -1];
176 ]])
177 ],
178 [gl_cv_type_char16_t_works=yes],
179 [gl_cv_type_char16_t_works=no])
180 ])
181 if test $gl_cv_type_char16_t_works = no; then
182 GNULIBHEADERS_OVERRIDE_CHAR16_T=1
183 else
184 GNULIBHEADERS_OVERRIDE_CHAR16_T=0
185 fi
186 AC_SUBST([GNULIBHEADERS_OVERRIDE_CHAR16_T])
187])
188AC_DEFUN_ONCE([gl_TYPE_CHAR32_T],
189[
190 dnl Determine whether gnulib's <uchar.h> would, if present, override char32_t.
191 AC_CACHE_CHECK([whether char32_t is correctly defined],
192 [gl_cv_type_char32_t_works],
193 [AC_COMPILE_IFELSE(
194 [AC_LANG_PROGRAM([[
195 #ifdef __HAIKU__
196 #include <stdint.h>
197 #endif
198 #include <uchar.h>
199 /* For simplicity, assume that uint32_least_t is equivalent to
200 'unsigned int'. */
201 int verify[(char32_t)(-1) >= 0 && sizeof (char32_t) == sizeof (unsigned int) ? 1 : -1];
202 ]])
203 ],
204 [gl_cv_type_char32_t_works=yes],
205 [gl_cv_type_char32_t_works=no])
206 ])
207 if test $gl_cv_type_char32_t_works = no; then
208 GNULIBHEADERS_OVERRIDE_CHAR32_T=1
209 else
210 GNULIBHEADERS_OVERRIDE_CHAR32_T=0
211 fi
212 AC_SUBST([GNULIBHEADERS_OVERRIDE_CHAR32_T])
213])
214
215# gl_UCHAR_MODULE_INDICATOR([modulename])
216# sets the shell variable that indicates the presence of the given module
217# to a C preprocessor expression that will evaluate to 1.
218# This macro invocation must not occur in macros that are AC_REQUIREd.
219AC_DEFUN([gl_UCHAR_MODULE_INDICATOR],
220[
221 dnl Ensure to expand the default settings once only.
222 gl_UCHAR_H_REQUIRE_DEFAULTS
223 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
224 dnl Define it also as a C macro, for the benefit of the unit tests.
225 gl_MODULE_INDICATOR_FOR_TESTS([$1])
226])
227
228# Initializes the default values for AC_SUBSTed shell variables.
229# This macro must not be AC_REQUIREd. It must only be invoked, and only
230# outside of macros or in macros that are not AC_REQUIREd.
231AC_DEFUN([gl_UCHAR_H_REQUIRE_DEFAULTS],
232[
233 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UCHAR_H_MODULE_INDICATOR_DEFAULTS], [
234 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOC32])
235 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISALNUM])
236 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISALPHA])
237 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISBLANK])
238 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISCNTRL])
239 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISDIGIT])
240 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISGRAPH])
241 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISLOWER])
242 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISPRINT])
243 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISPUNCT])
244 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISSPACE])
245 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISUPPER])
246 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32ISXDIGIT])
247 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOLOWER])
248 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOUPPER])
249 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32WIDTH])
250 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32RTOMB])
251 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SNRTOMBS])
252 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SRTOMBS])
253 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32STOMBS])
254 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32SWIDTH])
255 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32TOB])
256 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_MAPPING])
257 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_APPLY_TYPE_TEST])
258 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_MAPPING])
259 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_C32_GET_TYPE_TEST])
260 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOC16])
261 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOC32])
262 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNRTOC32S])
263 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOC32S])
264 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOC32S])
265 ])
266 m4_require(GL_MODULE_INDICATOR_PREFIX[_UCHAR_H_MODULE_INDICATOR_DEFAULTS])
267 AC_REQUIRE([gl_UCHAR_H_DEFAULTS])
268])
269
270AC_DEFUN([gl_UCHAR_H_DEFAULTS],
271[
272 dnl Assume proper GNU behavior unless another module says otherwise.
273 HAVE_C32RTOMB=1; AC_SUBST([HAVE_C32RTOMB])
274 HAVE_MBRTOC16=1; AC_SUBST([HAVE_MBRTOC16])
275 HAVE_MBRTOC32=1; AC_SUBST([HAVE_MBRTOC32])
276 REPLACE_C32RTOMB=0; AC_SUBST([REPLACE_C32RTOMB])
277 REPLACE_MBRTOC16=0; AC_SUBST([REPLACE_MBRTOC16])
278 REPLACE_MBRTOC32=0; AC_SUBST([REPLACE_MBRTOC32])
279])
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
index 8977a346..299c43f2 100644
--- a/gl/m4/ungetc.m4
+++ b/gl/m4/ungetc.m4
@@ -1,8 +1,10 @@
1# ungetc.m4 serial 10 1# ungetc.m4
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. 2# serial 12
3dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS], 9AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
8[ 10[
@@ -42,16 +44,16 @@ AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
42 ]])], 44 ]])],
43 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no], 45 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
44 [case "$host_os" in 46 [case "$host_os" in
45 # Guess yes on glibc systems. 47 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;; 48 *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;;
47 # Guess yes on musl systems. 49 # Guess yes on musl systems.
48 *-musl*) gl_cv_func_ungetc_works="guessing yes" ;; 50 *-musl* | midipix*) gl_cv_func_ungetc_works="guessing yes" ;;
49 # Guess yes on bionic systems. 51 # Guess yes on bionic systems.
50 *-android*) gl_cv_func_ungetc_works="guessing yes" ;; 52 *-android*) gl_cv_func_ungetc_works="guessing yes" ;;
51 # Guess yes on native Windows. 53 # Guess yes on native Windows.
52 mingw*) gl_cv_func_ungetc_works="guessing yes" ;; 54 mingw* | windows*) gl_cv_func_ungetc_works="guessing yes" ;;
53 # If we don't know, obey --enable-cross-guesses. 55 # If we don't know, obey --enable-cross-guesses.
54 *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;; 56 *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;;
55 esac 57 esac
56 ]) 58 ])
57 ]) 59 ])
diff --git a/gl/m4/unicase_h.m4 b/gl/m4/unicase_h.m4
new file mode 100644
index 00000000..71dccf06
--- /dev/null
+++ b/gl/m4/unicase_h.m4
@@ -0,0 +1,45 @@
1# unicase_h.m4
2# serial 1
3dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_UNICASE_H],
10[
11 dnl Ensure to expand the default settings once only, before all statements
12 dnl that occur in other macros.
13 AC_REQUIRE([gl_UNICASE_H_DEFAULTS])
14])
15
16# gl_UNICASE_MODULE_INDICATOR([modulename])
17# sets the shell variable that indicates the presence of the given module
18# to a C preprocessor expression that will evaluate to 1.
19# This macro invocation must not occur in macros that are AC_REQUIREd.
20AC_DEFUN([gl_UNICASE_MODULE_INDICATOR],
21[
22 dnl Ensure to expand the default settings once only.
23 gl_UNICASE_H_REQUIRE_DEFAULTS
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27])
28
29# Initializes the default values for AC_SUBSTed shell variables.
30# This macro must not be AC_REQUIREd. It must only be invoked, and only
31# outside of macros or in macros that are not AC_REQUIREd.
32AC_DEFUN([gl_UNICASE_H_REQUIRE_DEFAULTS],
33[
34 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNICASE_H_MODULE_INDICATOR_DEFAULTS], [
35 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
36 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
37 ])
38 m4_require(GL_MODULE_INDICATOR_PREFIX[_UNICASE_H_MODULE_INDICATOR_DEFAULTS])
39 AC_REQUIRE([gl_UNICASE_H_DEFAULTS])
40])
41
42AC_DEFUN([gl_UNICASE_H_DEFAULTS],
43[
44 dnl Assume proper GNU behavior unless another module says otherwise.
45])
diff --git a/gl/m4/unictype_h.m4 b/gl/m4/unictype_h.m4
new file mode 100644
index 00000000..ba5a3688
--- /dev/null
+++ b/gl/m4/unictype_h.m4
@@ -0,0 +1,179 @@
1# unictype_h.m4
2# serial 4
3dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_UNICTYPE_H],
10[
11 dnl Ensure to expand the default settings once only, before all statements
12 dnl that occur in other macros.
13 AC_REQUIRE([gl_UNICTYPE_H_DEFAULTS])
14])
15
16# gl_UNICTYPE_MODULE_INDICATOR([modulename])
17# sets the shell variable that indicates the presence of the given module
18# to a C preprocessor expression that will evaluate to 1.
19# This macro invocation must not occur in macros that are AC_REQUIREd.
20AC_DEFUN([gl_UNICTYPE_MODULE_INDICATOR],
21[
22 dnl Ensure to expand the default settings once only.
23 gl_UNICTYPE_H_REQUIRE_DEFAULTS
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27])
28
29# Initializes the default values for AC_SUBSTed shell variables.
30# This macro must not be AC_REQUIREd. It must only be invoked, and only
31# outside of macros or in macros that are not AC_REQUIREd.
32AC_DEFUN([gl_UNICTYPE_H_REQUIRE_DEFAULTS],
33[
34 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNICTYPE_H_MODULE_INDICATOR_DEFAULTS], [
35 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
36 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
37 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
38 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
39 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
40 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
41 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
42 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
43 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
44 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
45 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
46 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
47 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
48 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
49 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
53 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
56 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
57 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
58 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
59 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
62 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
63 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
64 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
65 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
66 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_START_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_CONTINUE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_MODIFIER_COMBINING_MARK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDS_UNARY_OPERATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PREPENDED_CONCATENATION_MARK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
170 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
171 ])
172 m4_require(GL_MODULE_INDICATOR_PREFIX[_UNICTYPE_H_MODULE_INDICATOR_DEFAULTS])
173 AC_REQUIRE([gl_UNICTYPE_H_DEFAULTS])
174])
175
176AC_DEFUN([gl_UNICTYPE_H_DEFAULTS],
177[
178 dnl Assume proper GNU behavior unless another module says otherwise.
179])
diff --git a/gl/m4/uninorm_h.m4 b/gl/m4/uninorm_h.m4
new file mode 100644
index 00000000..5ec9ea67
--- /dev/null
+++ b/gl/m4/uninorm_h.m4
@@ -0,0 +1,47 @@
1# uninorm_h.m4
2# serial 1
3dnl Copyright (C) 2023-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_UNINORM_H],
10[
11 dnl Ensure to expand the default settings once only, before all statements
12 dnl that occur in other macros.
13 AC_REQUIRE([gl_UNINORM_H_DEFAULTS])
14])
15
16# gl_UNINORM_MODULE_INDICATOR([modulename])
17# sets the shell variable that indicates the presence of the given module
18# to a C preprocessor expression that will evaluate to 1.
19# This macro invocation must not occur in macros that are AC_REQUIREd.
20AC_DEFUN([gl_UNINORM_MODULE_INDICATOR],
21[
22 dnl Ensure to expand the default settings once only.
23 gl_UNINORM_H_REQUIRE_DEFAULTS
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27])
28
29# Initializes the default values for AC_SUBSTed shell variables.
30# This macro must not be AC_REQUIREd. It must only be invoked, and only
31# outside of macros or in macros that are not AC_REQUIREd.
32AC_DEFUN([gl_UNINORM_H_REQUIRE_DEFAULTS],
33[
34 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNINORM_H_MODULE_INDICATOR_DEFAULTS], [
35 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFD_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
36 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
37 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFKD_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
38 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNINORM_NFKC_DLL_VARIABLE], ['LIBUNISTRING_DLL_VARIABLE'])
39 ])
40 m4_require(GL_MODULE_INDICATOR_PREFIX[_UNINORM_H_MODULE_INDICATOR_DEFAULTS])
41 AC_REQUIRE([gl_UNINORM_H_DEFAULTS])
42])
43
44AC_DEFUN([gl_UNINORM_H_DEFAULTS],
45[
46 dnl Assume proper GNU behavior unless another module says otherwise.
47])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index f4384027..8000e888 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,8 +1,10 @@
1# unistd_h.m4 serial 90 1# unistd_h.m4
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 2# serial 97
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Written by Simon Josefsson, Bruno Haible. 9dnl Written by Simon Josefsson, Bruno Haible.
8 10
@@ -225,6 +227,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
225 REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE]) 227 REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE])
226 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) 228 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
227 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) 229 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
230 REPLACE_DUP3=0; AC_SUBST([REPLACE_DUP3])
228 REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL]) 231 REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL])
229 REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE]) 232 REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE])
230 REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP]) 233 REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP])
@@ -233,27 +236,34 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
233 REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP]) 236 REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP])
234 REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE]) 237 REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE])
235 REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT]) 238 REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT])
239 REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
236 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) 240 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
241 REPLACE_FDATASYNC=0; AC_SUBST([REPLACE_FDATASYNC])
237 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) 242 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
238 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 243 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
239 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) 244 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
240 REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE]) 245 REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
246 REPLACE_GETENTROPY=0; AC_SUBST([REPLACE_GETENTROPY])
247 REPLACE_GETLOGIN=0; AC_SUBST([REPLACE_GETLOGIN])
241 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) 248 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
242 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) 249 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
243 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 250 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
244 REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS]) 251 REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
245 REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU]) 252 REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
253 REPLACE_GETUSERSHELL=0; AC_SUBST([REPLACE_GETUSERSHELL])
246 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) 254 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
247 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) 255 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
248 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) 256 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
249 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) 257 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
250 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 258 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
259 REPLACE_PIPE2=0; AC_SUBST([REPLACE_PIPE2])
251 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) 260 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
252 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) 261 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
253 REPLACE_READ=0; AC_SUBST([REPLACE_READ]) 262 REPLACE_READ=0; AC_SUBST([REPLACE_READ])
254 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) 263 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
255 REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT]) 264 REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT])
256 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) 265 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
266 REPLACE_SETHOSTNAME=0; AC_SUBST([REPLACE_SETHOSTNAME])
257 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 267 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
258 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) 268 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
259 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) 269 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
diff --git a/gl/m4/unitypes_h.m4 b/gl/m4/unitypes_h.m4
new file mode 100644
index 00000000..733b9ee2
--- /dev/null
+++ b/gl/m4/unitypes_h.m4
@@ -0,0 +1,26 @@
1# unitypes_h.m4
2# serial 1
3dnl Copyright (C) 2021-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_UNITYPES_H],
10[
11 AH_VERBATIM([unitypes_restrict], [
12/* This definition is a duplicate of the one in unitypes.h.
13 It is here so that we can cope with an older version of unitypes.h
14 that does not contain this definition and that is pre-installed among
15 the public header files. */
16# if defined __restrict \
17 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
18 || __clang_major__ >= 3
19# define _UC_RESTRICT __restrict
20# elif 199901L <= __STDC_VERSION__ || defined restrict
21# define _UC_RESTRICT restrict
22# else
23# define _UC_RESTRICT
24# endif
25])
26])
diff --git a/gl/m4/unlocked-io.m4 b/gl/m4/unlocked-io.m4
index 407c0bac..16ab6e9a 100644
--- a/gl/m4/unlocked-io.m4
+++ b/gl/m4/unlocked-io.m4
@@ -1,10 +1,10 @@
1# unlocked-io.m4 serial 16 1# unlocked-io.m4
2 2# serial 17
3# Copyright (C) 1998-2006, 2009-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 1998-2006, 2009-2026 Free Software Foundation, Inc.
4# 4dnl This file is free software; the Free Software Foundation
5# This file is free software; the Free Software Foundation 5dnl gives unlimited permission to copy and/or distribute it,
6# gives unlimited permission to copy and/or distribute it, 6dnl with or without modifications, as long as this notice is preserved.
7# with or without modifications, as long as this notice is preserved. 7dnl This file is offered as-is, without any warranty.
8 8
9dnl From Jim Meyering. 9dnl From Jim Meyering.
10dnl 10dnl
@@ -25,6 +25,7 @@ AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
25 AC_CHECK_DECLS_ONCE([ferror_unlocked]) 25 AC_CHECK_DECLS_ONCE([ferror_unlocked])
26 AC_CHECK_DECLS_ONCE([fflush_unlocked]) 26 AC_CHECK_DECLS_ONCE([fflush_unlocked])
27 AC_CHECK_DECLS_ONCE([fgets_unlocked]) 27 AC_CHECK_DECLS_ONCE([fgets_unlocked])
28 AC_CHECK_DECLS_ONCE([fileno_unlocked])
28 AC_CHECK_DECLS_ONCE([fputc_unlocked]) 29 AC_CHECK_DECLS_ONCE([fputc_unlocked])
29 AC_CHECK_DECLS_ONCE([fputs_unlocked]) 30 AC_CHECK_DECLS_ONCE([fputs_unlocked])
30 AC_CHECK_DECLS_ONCE([fread_unlocked]) 31 AC_CHECK_DECLS_ONCE([fread_unlocked])
diff --git a/gl/m4/vararrays.m4 b/gl/m4/vararrays.m4
index fd6230c2..3dd8e68f 100644
--- a/gl/m4/vararrays.m4
+++ b/gl/m4/vararrays.m4
@@ -1,13 +1,14 @@
1# Check for variable-length arrays. 1# vararrays.m4
2
3# serial 6 2# serial 6
3dnl Copyright (C) 2001, 2009-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
4 8
5# From Paul Eggert 9# Check for variable-length arrays.
6 10
7# Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc. 11# From Paul Eggert
8# This file is free software; the Free Software Foundation
9# gives unlimited permission to copy and/or distribute it,
10# with or without modifications, as long as this notice is preserved.
11 12
12m4_version_prereq([2.70], [], [ 13m4_version_prereq([2.70], [], [
13 14
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index 6361c843..4e01fbc9 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,13 +1,47 @@
1# vasnprintf.m4 serial 38 1# vasnprintf.m4
2dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc. 2# serial 56
3dnl Copyright (C) 2002-2004, 2006-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_VASNPRINTF], 9AC_DEFUN([gl_FUNC_VASNPRINTF],
8[ 10[
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
9 AC_CHECK_FUNCS_ONCE([vasnprintf]) 12 AC_CHECK_FUNCS_ONCE([vasnprintf])
10 if test $ac_cv_func_vasnprintf = no; then 13 if test $ac_cv_func_vasnprintf = yes; then
14 dnl On Cygwin, in directives with a huge width, the width is ignored, and
15 dnl the function returns a wrong result.
16 AC_CACHE_CHECK([whether vasnprintf works],
17 [gl_cv_func_vasnprintf_works],
18 [AC_RUN_IFELSE(
19 [AC_LANG_SOURCE(
20 [[#include <stdio.h>
21 ]],
22 [[size_t len;
23 char *res = vasnprintf (NULL, &len, "x%03000000000dy\n", -17);
24 /* On Cygwin 3.4.6, res is "x-17y\n" and len == 6: wrong. */
25 return (res != NULL && len < 10);
26 ]])
27 ],
28 [gl_cv_func_vasnprintf_works=yes],
29 [gl_cv_func_vasnprintf_works=no],
30 [case "$host_os" in
31 # Guess no on Cygwin.
32 cygwin*) gl_cv_func_vasnprintf_works="guessing no";;
33 # If we don't know, obey --enable-cross-guesses.
34 *) gl_cv_func_vasnprintf_works="$gl_cross_guess_normal";;
35 esac
36 ])
37 ])
38 fi
39 if test $ac_cv_func_vasnprintf != yes \
40 || case "$gl_cv_func_vasnprintf_works" in
41 *yes) false;;
42 *) true;;
43 esac
44 then
11 gl_REPLACE_VASNPRINTF 45 gl_REPLACE_VASNPRINTF
12 fi 46 fi
13]) 47])
@@ -29,18 +63,26 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
29 gl_PREREQ_ASNPRINTF 63 gl_PREREQ_ASNPRINTF
30]) 64])
31 65
66AC_DEFUN([gl_FUNC_VASNWPRINTF],
67[
68 AC_LIBOBJ([printf-args])
69 gl_PREREQ_PRINTF_ARGS
70 gl_PREREQ_PRINTF_PARSE
71 gl_PREREQ_VASNWPRINTF
72 gl_PREREQ_ASNPRINTF
73])
74
32# Prerequisites of lib/printf-args.h, lib/printf-args.c. 75# Prerequisites of lib/printf-args.h, lib/printf-args.c.
33AC_DEFUN([gl_PREREQ_PRINTF_ARGS], 76AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
34[ 77[
35 AC_REQUIRE([gt_TYPE_WCHAR_T])
36 AC_REQUIRE([gt_TYPE_WINT_T]) 78 AC_REQUIRE([gt_TYPE_WINT_T])
37]) 79])
38 80
39# Prerequisites of lib/printf-parse.h, lib/printf-parse.c. 81# Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
82# Prerequisites of lib/wprintf-parse.h, lib/wprintf-parse.c.
40AC_DEFUN([gl_PREREQ_PRINTF_PARSE], 83AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
41[ 84[
42 AC_REQUIRE([gl_FEATURES_H]) 85 AC_REQUIRE([gl_FEATURES_H])
43 AC_REQUIRE([gt_TYPE_WCHAR_T])
44 AC_REQUIRE([gt_TYPE_WINT_T]) 86 AC_REQUIRE([gt_TYPE_WINT_T])
45 AC_REQUIRE([AC_TYPE_SIZE_T]) 87 AC_REQUIRE([AC_TYPE_SIZE_T])
46 AC_CHECK_TYPE([ptrdiff_t], , 88 AC_CHECK_TYPE([ptrdiff_t], ,
@@ -50,19 +92,13 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
50 AC_REQUIRE([gt_AC_TYPE_INTMAX_T]) 92 AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
51]) 93])
52 94
53# Prerequisites of lib/vasnprintf.c. 95# Prerequisites of lib/vasnprintf.c if !WIDE_CHAR_VERSION.
54AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 96AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
55[ 97[
56 AC_REQUIRE([AC_FUNC_ALLOCA]) 98 AC_CHECK_FUNCS([snprintf strnlen wcrtomb])
57 AC_REQUIRE([gt_TYPE_WCHAR_T])
58 AC_REQUIRE([gt_TYPE_WINT_T])
59 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
60 dnl Use the _snprintf function only if it is declared (because on NetBSD it 99 dnl Use the _snprintf function only if it is declared (because on NetBSD it
61 dnl is defined as a weak alias of snprintf; we prefer to use the latter). 100 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
62 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]]) 101 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
63 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
64 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
65 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
66 dnl We can avoid a lot of code by assuming that snprintf's return value 102 dnl We can avoid a lot of code by assuming that snprintf's return value
67 dnl conforms to ISO C99. So check that. 103 dnl conforms to ISO C99. So check that.
68 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) 104 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
@@ -84,6 +120,107 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
84 terminated.]) 120 terminated.])
85 ;; 121 ;;
86 esac 122 esac
123 gl_PREREQ_VASNXPRINTF
124])
125
126# Prerequisites of lib/vasnwprintf.c.
127AC_DEFUN_ONCE([gl_PREREQ_VASNWPRINTF],
128[
129 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
130 AC_CHECK_FUNCS_ONCE([swprintf wcsnlen mbrtowc])
131 AC_CHECK_DECLS([_snwprintf], , , [[#include <stdio.h>]])
132 AC_CHECK_DECLS([wcsnlen], , , [[#include <wchar.h>]])
133 gl_SWPRINTF_WORKS
134 case "$gl_cv_func_swprintf_works" in
135 *yes)
136 AC_DEFINE([HAVE_WORKING_SWPRINTF], [1],
137 [Define if the swprintf function works correctly when it produces output
138 that contains null wide characters.])
139 ;;
140 esac
141 gl_MBRTOWC_C_LOCALE
142 case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
143 *yes)
144 AC_CACHE_CHECK([whether swprintf in the C locale is free of encoding errors],
145 [gl_cv_func_swprintf_C_locale_sans_EILSEQ],
146 [
147 AC_RUN_IFELSE(
148 [AC_LANG_SOURCE([[
149#ifndef __USE_MINGW_ANSI_STDIO
150# define __USE_MINGW_ANSI_STDIO 1
151#endif
152#include <stdio.h>
153#include <wchar.h>
154int main()
155{
156 int result = 0;
157 { /* This test fails on glibc 2.35, musl libc 1.2.4, FreeBSD 13.2, NetBSD 9.3,
158 OpenBSD 7.2, Cygwin 2.9.0.
159 Reported at <https://www.openwall.com/lists/musl/2023/06/12/2>. */
160 wchar_t buf[12];
161 int ret = swprintf (buf, 12, L"%c", '\377');
162 if (ret < 0)
163 result |= 1;
164 }
165 return result;
166}]])],
167 [gl_cv_func_swprintf_C_locale_sans_EILSEQ=yes],
168 [gl_cv_func_swprintf_C_locale_sans_EILSEQ=no],
169 [case "$host_os" in
170 # Guess no on glibc systems.
171 *-gnu* | gnu*) gl_cv_func_swprintf_C_locale_sans_EILSEQ="guessing yes";;
172 # Guess no on musl systems.
173 *-musl* | midipix*) gl_cv_func_swprintf_C_locale_sans_EILSEQ="guessing no";;
174 # If we don't know, obey --enable-cross-guesses.
175 *) gl_cv_func_swprintf_C_locale_sans_EILSEQ="$gl_cross_guess_normal";;
176 esac
177 ])
178 ])
179 ;;
180 esac
181 if case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
182 *yes) false ;;
183 *) true ;;
184 esac \
185 || case "$gl_cv_func_swprintf_C_locale_sans_EILSEQ" in
186 *yes) false ;;
187 *) true ;;
188 esac; then
189 AC_DEFINE([NEED_WPRINTF_DIRECTIVE_C], [1],
190 [Define if the vasnwprintf implementation needs special code for
191 the 'c' directive.])
192 fi
193 gl_SWPRINTF_DIRECTIVE_LA
194 case "$gl_cv_func_swprintf_directive_la" in
195 *yes) ;;
196 *)
197 AC_DEFINE([NEED_WPRINTF_DIRECTIVE_LA], [1],
198 [Define if the vasnwprintf implementation needs special code for
199 the 'a' directive with 'long double' arguments.])
200 ;;
201 esac
202 gl_SWPRINTF_DIRECTIVE_LC
203 case "$gl_cv_func_swprintf_directive_lc" in
204 *yes) ;;
205 *)
206 AC_DEFINE([NEED_WPRINTF_DIRECTIVE_LC], [1],
207 [Define if the vasnwprintf implementation needs special code for
208 the 'lc' directive.])
209 ;;
210 esac
211 gl_MUSL_LIBC
212 gl_PREREQ_VASNXPRINTF
213])
214
215# Common prerequisites of lib/vasnprintf.c and lib/vasnwprintf.c.
216AC_DEFUN_ONCE([gl_PREREQ_VASNXPRINTF],
217[
218 AC_REQUIRE([AC_FUNC_ALLOCA])
219 AC_REQUIRE([gt_TYPE_WINT_T])
220 AC_CHECK_FUNCS([wcslen])
221 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
222 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
223 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
87]) 224])
88 225
89# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' 226# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
@@ -152,7 +289,22 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
152 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1], 289 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
153 [Define if the vasnprintf implementation needs special code for 290 [Define if the vasnprintf implementation needs special code for
154 the 'a' and 'A' directives.]) 291 the 'a' and 'A' directives.])
155 AC_CHECK_FUNCS([nl_langinfo]) 292 gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include <langinfo.h>]])
293 ;;
294 esac
295])
296
297# Extra prerequisites of lib/vasnprintf.c for supporting the 'b' directive.
298AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_B],
299[
300 AC_REQUIRE([gl_PRINTF_DIRECTIVE_B])
301 case "$gl_cv_func_printf_directive_b" in
302 *yes)
303 ;;
304 *)
305 AC_DEFINE([NEED_PRINTF_DIRECTIVE_B], [1],
306 [Define if the vasnprintf implementation needs special code for
307 the 'b' directive.])
156 ;; 308 ;;
157 esac 309 esac
158]) 310])
@@ -187,18 +339,57 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
187 esac 339 esac
188]) 340])
189 341
190# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag. 342# Extra prerequisites of lib/vasnprintf.c for supporting the 'lc' directive.
191AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING], 343AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LC],
192[ 344[
193 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING]) 345 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LC])
194 case "$gl_cv_func_printf_flag_grouping" in 346 case "$gl_cv_func_printf_directive_lc" in
195 *yes) 347 *yes)
196 ;; 348 ;;
197 *) 349 *)
350 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LC], [1],
351 [Define if the vasnprintf implementation needs special code for
352 the 'lc' directive.])
353 ;;
354 esac
355])
356
357# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
358AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
359[
360 AC_REQUIRE([AC_CANONICAL_HOST])
361 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
362 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING_INT_PRECISION])
363 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING_MULTIBYTE])
364 case "$host_os" in
365 mingw* | windows*)
366 dnl MSVC does not support the ' flag at all.
367 dnl mingw does not support it, unless __USE_MINGW_ANSI_STDIO is defined.
368 dnl mingw also has other bugs regarding the ' flag.
198 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1], 369 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
199 [Define if the vasnprintf implementation needs special code for the 370 [Define if the vasnprintf implementation needs special code for the
200 ' flag.]) 371 ' flag.])
201 ;; 372 ;;
373 *)
374 case "$gl_cv_func_printf_flag_grouping,$gl_cv_func_printf_flag_grouping_multibyte" in
375 *yes,*yes)
376 case "$gl_cv_func_printf_flag_grouping_int_precision" in
377 *yes)
378 ;;
379 *)
380 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING_INT], [1],
381 [Define if the vasnprintf implementation needs special code for the
382 ' flag, for integer directives only.])
383 ;;
384 esac
385 ;;
386 *)
387 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
388 [Define if the vasnprintf implementation needs special code for the
389 ' flag.])
390 ;;
391 esac
392 ;;
202 esac 393 esac
203]) 394])
204 395
@@ -232,6 +423,22 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
232 esac 423 esac
233]) 424])
234 425
426# Extra prerequisites of lib/vasnprintf.c for supporting the # flag with a
427# zero precision and a zero value in the 'x' and 'X' directives.
428AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO],
429[
430 AC_REQUIRE([gl_PRINTF_FLAG_ALT_PRECISION_ZERO])
431 case "$gl_cv_func_printf_flag_alt_precision_zero" in
432 *yes)
433 ;;
434 *)
435 AC_DEFINE([NEED_PRINTF_FLAG_ALT_PRECISION_ZERO], [1],
436 [Define if the vasnprintf implementation needs special code for the
437 # flag with a zero precision and a zero value in the 'x' and 'X' directives.])
438 ;;
439 esac
440])
441
235# Extra prerequisites of lib/vasnprintf.c for supporting large precisions. 442# Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
236AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION], 443AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
237[ 444[
@@ -276,23 +483,53 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
276]) 483])
277 484
278# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance. 485# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
279AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS], 486AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS],
280[ 487[
281 AC_REQUIRE([gl_PREREQ_VASNPRINTF]) 488 AC_REQUIRE([gl_PREREQ_VASNPRINTF])
282 gl_PREREQ_VASNPRINTF_LONG_DOUBLE 489 gl_PREREQ_VASNPRINTF_LONG_DOUBLE
283 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE 490 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
284 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE 491 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
285 gl_PREREQ_VASNPRINTF_DIRECTIVE_A 492 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
493 gl_PREREQ_VASNPRINTF_DIRECTIVE_B
286 gl_PREREQ_VASNPRINTF_DIRECTIVE_F 494 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
287 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS 495 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
496 gl_PREREQ_VASNPRINTF_DIRECTIVE_LC
288 gl_PREREQ_VASNPRINTF_FLAG_GROUPING 497 gl_PREREQ_VASNPRINTF_FLAG_GROUPING
289 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST 498 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
290 gl_PREREQ_VASNPRINTF_FLAG_ZERO 499 gl_PREREQ_VASNPRINTF_FLAG_ZERO
500 gl_PREREQ_VASNPRINTF_FLAG_ALT_PRECISION_ZERO
291 gl_PREREQ_VASNPRINTF_PRECISION 501 gl_PREREQ_VASNPRINTF_PRECISION
292 gl_PREREQ_VASNPRINTF_ENOMEM 502 gl_PREREQ_VASNPRINTF_ENOMEM
293]) 503])
294 504
505# Extra prerequisites of lib/vasnprintf.c for supporting the 'B' directive.
506AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_UPPERCASE_B],
507[
508 AC_REQUIRE([gl_PRINTF_DIRECTIVE_UPPERCASE_B])
509 case "$gl_cv_func_printf_directive_uppercase_b" in
510 *yes)
511 ;;
512 *)
513 AC_DEFINE([NEED_PRINTF_DIRECTIVE_UPPERCASE_B], [1],
514 [Define if the vasnprintf implementation needs special code for
515 the 'B' directive.])
516 ;;
517 esac
518])
519
520# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance
521# and GNU compatibility.
522AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS],
523[
524 gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
525 AC_DEFINE([SUPPORT_GNU_PRINTF_DIRECTIVES], [1],
526 [Define if the vasnprintf implementation should support GNU compatible
527 printf directives.])
528 gl_PREREQ_VASNPRINTF_DIRECTIVE_UPPERCASE_B
529])
530
295# Prerequisites of lib/asnprintf.c. 531# Prerequisites of lib/asnprintf.c.
532# Prerequisites of lib/asnwprintf.c.
296AC_DEFUN([gl_PREREQ_ASNPRINTF], 533AC_DEFUN([gl_PREREQ_ASNPRINTF],
297[ 534[
298]) 535])
diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4
index 6e6156a7..3e6913e2 100644
--- a/gl/m4/vasprintf.m4
+++ b/gl/m4/vasprintf.m4
@@ -1,9 +1,11 @@
1# vasprintf.m4 serial 6 1# vasprintf.m4
2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2023 Free Software Foundation, 2# serial 6
3dnl Copyright (C) 2002-2003, 2006-2007, 2009-2026 Free Software Foundation,
3dnl Inc. 4dnl Inc.
4dnl This file is free software; the Free Software Foundation 5dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 6dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 7dnl with or without modifications, as long as this notice is preserved.
8dnl This file is offered as-is, without any warranty.
7 9
8AC_DEFUN([gl_FUNC_VASPRINTF], 10AC_DEFUN([gl_FUNC_VASPRINTF],
9[ 11[
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index f0468e89..55ceb672 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,8 +1,10 @@
1# visibility.m4 serial 8 1# visibility.m4
2dnl Copyright (C) 2005, 2008, 2010-2023 Free Software Foundation, Inc. 2# serial 9
3dnl Copyright (C) 2005, 2008, 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8 10
@@ -31,18 +33,18 @@ AC_DEFUN([gl_VISIBILITY],
31 dnl user has put into $CC $CFLAGS $CPPFLAGS. 33 dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 AC_CACHE_CHECK([whether the -Werror option is usable], 34 AC_CACHE_CHECK([whether the -Werror option is usable],
33 [gl_cv_cc_vis_werror], 35 [gl_cv_cc_vis_werror],
34 [gl_save_CFLAGS="$CFLAGS" 36 [gl_saved_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror" 37 CFLAGS="$CFLAGS -Werror"
36 AC_COMPILE_IFELSE( 38 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([[]], [[]])], 39 [AC_LANG_PROGRAM([[]], [[]])],
38 [gl_cv_cc_vis_werror=yes], 40 [gl_cv_cc_vis_werror=yes],
39 [gl_cv_cc_vis_werror=no]) 41 [gl_cv_cc_vis_werror=no])
40 CFLAGS="$gl_save_CFLAGS" 42 CFLAGS="$gl_saved_CFLAGS"
41 ]) 43 ])
42 dnl Now check whether visibility declarations are supported. 44 dnl Now check whether visibility declarations are supported.
43 AC_CACHE_CHECK([for simple visibility declarations], 45 AC_CACHE_CHECK([for simple visibility declarations],
44 [gl_cv_cc_visibility], 46 [gl_cv_cc_visibility],
45 [gl_save_CFLAGS="$CFLAGS" 47 [gl_saved_CFLAGS="$CFLAGS"
46 CFLAGS="$CFLAGS -fvisibility=hidden" 48 CFLAGS="$CFLAGS -fvisibility=hidden"
47 dnl We use the option -Werror and a function dummyfunc, because on some 49 dnl We use the option -Werror and a function dummyfunc, because on some
48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning 50 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
@@ -68,7 +70,7 @@ AC_DEFUN([gl_VISIBILITY],
68 [[]])], 70 [[]])],
69 [gl_cv_cc_visibility=yes], 71 [gl_cv_cc_visibility=yes],
70 [gl_cv_cc_visibility=no]) 72 [gl_cv_cc_visibility=no])
71 CFLAGS="$gl_save_CFLAGS" 73 CFLAGS="$gl_saved_CFLAGS"
72 ]) 74 ])
73 if test $gl_cv_cc_visibility = yes; then 75 if test $gl_cv_cc_visibility = yes; then
74 CFLAG_VISIBILITY="-fvisibility=hidden" 76 CFLAG_VISIBILITY="-fvisibility=hidden"
diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4
index 7fbb11c4..df767486 100644
--- a/gl/m4/vsnprintf.m4
+++ b/gl/m4/vsnprintf.m4
@@ -1,8 +1,10 @@
1# vsnprintf.m4 serial 7 1# vsnprintf.m4
2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc. 2# serial 7
3dnl Copyright (C) 2002-2004, 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl Libintl 0.17 will replace vsnprintf only if it does not support %1$s, 9dnl Libintl 0.17 will replace vsnprintf only if it does not support %1$s,
8dnl but defers to any gnulib vsnprintf replacements. Therefore, gnulib 10dnl but defers to any gnulib vsnprintf replacements. Therefore, gnulib
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index 10649c5c..3765368c 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,8 +1,10 @@
1# warn-on-use.m4 serial 10 1# warn-on-use.m4
2dnl Copyright (C) 2010-2023 Free Software Foundation, Inc. 2# serial 11
3dnl Copyright (C) 2010-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) 9# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
8# --------------------------------------- 10# ---------------------------------------
@@ -36,7 +38,7 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
36 dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead 38 dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead
37 dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC 39 dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC
38 dnl in zzgnulib.m4 is inactive, use the original ac_compile. 40 dnl in zzgnulib.m4 is inactive, use the original ac_compile.
39 ac_save_ac_compile="$ac_compile" 41 ac_saved_ac_compile="$ac_compile"
40 if test -n "$ac_compile_for_check_decl"; then 42 if test -n "$ac_compile_for_check_decl"; then
41 ac_compile="$ac_compile_for_check_decl" 43 ac_compile="$ac_compile_for_check_decl"
42 fi 44 fi
@@ -46,7 +48,7 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
46[[#undef $gl_func 48[[#undef $gl_func
47 (void) $gl_func;]])], 49 (void) $gl_func;]])],
48 [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])]) 50 [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
49 ac_compile="$ac_save_ac_compile" 51 ac_compile="$ac_saved_ac_compile"
50 AS_VAR_IF([gl_Symbol], [yes], 52 AS_VAR_IF([gl_Symbol], [yes],
51 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) 53 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
52 dnl Shortcut for an AC_CHECK_DECL invocation that may come later: 54 dnl Shortcut for an AC_CHECK_DECL invocation that may come later:
diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4
index 8ec66193..42338a00 100644
--- a/gl/m4/wchar_h.m4
+++ b/gl/m4/wchar_h.m4
@@ -1,13 +1,14 @@
1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. 1# wchar_h.m4
2 2# serial 66
3dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
7 8
8dnl Written by Eric Blake. 9dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
9 10
10# wchar_h.m4 serial 55 11dnl Written by Eric Blake.
11 12
12AC_DEFUN_ONCE([gl_WCHAR_H], 13AC_DEFUN_ONCE([gl_WCHAR_H],
13[ 14[
@@ -64,8 +65,8 @@ dnl Check whether <wchar.h> is usable at all.
64AC_DEFUN([gl_WCHAR_H_INLINE_OK], 65AC_DEFUN([gl_WCHAR_H_INLINE_OK],
65[ 66[
66 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to 67 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
67 dnl 'gnu_inline'. See <https://sourceware.org/bugzilla/show_bug.cgi?id=4022> 68 dnl 'gnu_inline'. See <https://sourceware.org/PR4022>
68 dnl and <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary, 69 dnl and <https://gcc.gnu.org/PR42440>. In summary,
69 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and 70 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
70 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>. 71 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
71 AC_REQUIRE([AC_CANONICAL_HOST]) 72 AC_REQUIRE([AC_CANONICAL_HOST])
@@ -86,8 +87,8 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK],
86 dnl z/OS when using the XPLINK object format (due to duplicate 87 dnl z/OS when using the XPLINK object format (due to duplicate
87 dnl CSECT names). Instead, temporarily redefine $ac_compile so 88 dnl CSECT names). Instead, temporarily redefine $ac_compile so
88 dnl that the object file has the latter name from the start. 89 dnl that the object file has the latter name from the start.
89 save_ac_compile="$ac_compile" 90 saved_ac_compile="$ac_compile"
90 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/` 91 ac_compile=`echo "$saved_ac_compile" | sed s/conftest/conftest1/`
91 if echo '#include "conftest.c"' >conftest1.c \ 92 if echo '#include "conftest.c"' >conftest1.c \
92 && AC_TRY_EVAL([ac_compile]); then 93 && AC_TRY_EVAL([ac_compile]); then
93 AC_LANG_CONFTEST([ 94 AC_LANG_CONFTEST([
@@ -97,7 +98,7 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK],
97 int zero (void) { return 0; } 98 int zero (void) { return 0; }
98 ]])]) 99 ]])])
99 dnl See note above about renaming object files. 100 dnl See note above about renaming object files.
100 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/` 101 ac_compile=`echo "$saved_ac_compile" | sed s/conftest/conftest2/`
101 if echo '#include "conftest.c"' >conftest2.c \ 102 if echo '#include "conftest.c"' >conftest2.c \
102 && AC_TRY_EVAL([ac_compile]); then 103 && AC_TRY_EVAL([ac_compile]); then
103 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then 104 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
@@ -107,7 +108,7 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK],
107 fi 108 fi
108 fi 109 fi
109 fi 110 fi
110 ac_compile="$save_ac_compile" 111 ac_compile="$saved_ac_compile"
111 rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext 112 rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext
112 ;; 113 ;;
113 esac 114 esac
@@ -147,6 +148,7 @@ AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS],
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC]) 148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB]) 149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT]) 150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSZERO])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC]) 152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN]) 153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS]) 154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS])
@@ -185,6 +187,7 @@ AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS],
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK]) 187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH]) 188 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME]) 189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME])
190 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WGETCWD])
188 dnl Support Microsoft deprecated alias function names by default. 191 dnl Support Microsoft deprecated alias function names by default.
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1]) 192 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1])
190 ]) 193 ])
@@ -236,7 +239,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
236 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) 239 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
237 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) 240 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
238 HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME]) 241 HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME])
239 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) 242 HAVE_WCTOB=1; AC_SUBST([HAVE_WCTOB])
240 HAVE_DECL_WCSDUP=1; AC_SUBST([HAVE_DECL_WCSDUP]) 243 HAVE_DECL_WCSDUP=1; AC_SUBST([HAVE_DECL_WCSDUP])
241 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) 244 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
242 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) 245 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
@@ -253,5 +256,11 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
253 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) 256 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
254 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) 257 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
255 REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME]) 258 REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME])
259 REPLACE_WCSCMP=0; AC_SUBST([REPLACE_WCSCMP])
260 REPLACE_WCSNCAT=0; AC_SUBST([REPLACE_WCSNCAT])
261 REPLACE_WCSNCMP=0; AC_SUBST([REPLACE_WCSNCMP])
262 REPLACE_WCSSTR=0; AC_SUBST([REPLACE_WCSSTR])
256 REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK]) 263 REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK])
264 REPLACE_WMEMCMP=0; AC_SUBST([REPLACE_WMEMCMP])
265 REPLACE_WMEMPCPY=0; AC_SUBST([REPLACE_WMEMPCPY])
257]) 266])
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
deleted file mode 100644
index 50bde08a..00000000
--- a/gl/m4/wchar_t.m4
+++ /dev/null
@@ -1,24 +0,0 @@
1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether <stddef.h> has the 'wchar_t' type.
9dnl Prerequisite: AC_PROG_CC
10
11AC_DEFUN([gt_TYPE_WCHAR_T],
12[
13 AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stddef.h>
17 wchar_t foo = (wchar_t)'\0';]],
18 [[]])],
19 [gt_cv_c_wchar_t=yes],
20 [gt_cv_c_wchar_t=no])])
21 if test $gt_cv_c_wchar_t = yes; then
22 AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
23 fi
24])
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index d51b36e1..a69f17c4 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,8 +1,10 @@
1# wcrtomb.m4 serial 17 1# wcrtomb.m4
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. 2# serial 22
3dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_FUNC_WCRTOMB], 9AC_DEFUN([gl_FUNC_WCRTOMB],
8[ 10[
@@ -31,11 +33,11 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
31 dnl fi 33 dnl fi
32 if test $REPLACE_WCRTOMB = 0; then 34 if test $REPLACE_WCRTOMB = 0; then
33 dnl On Android 4.3, wcrtomb produces wrong characters in the C locale. 35 dnl On Android 4.3, wcrtomb produces wrong characters in the C locale.
34 dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL) 36 dnl On AIX 4.3 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL)
35 dnl sometimes returns 0 instead of 1. 37 dnl sometimes returns 0 instead of 1.
36 AC_REQUIRE([AC_PROG_CC]) 38 AC_REQUIRE([AC_PROG_CC])
37 AC_REQUIRE([gt_LOCALE_FR]) 39 AC_REQUIRE([gt_LOCALE_FR])
38 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 40 AC_REQUIRE([gt_LOCALE_EN_UTF8])
39 AC_REQUIRE([gt_LOCALE_JA]) 41 AC_REQUIRE([gt_LOCALE_JA])
40 AC_REQUIRE([gt_LOCALE_ZH_CN]) 42 AC_REQUIRE([gt_LOCALE_ZH_CN])
41 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 43 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -81,13 +83,15 @@ int main ()
81 dnl is present. 83 dnl is present.
82changequote(,)dnl 84changequote(,)dnl
83 case "$host_os" in 85 case "$host_os" in
84 # Guess no on AIX 4, OSF/1, Solaris, native Windows. 86 # Guess no on AIX 4, Solaris, native Windows.
85 aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;; 87 aix4* | solaris* | mingw* | windows*)
88 gl_cv_func_wcrtomb_retval="guessing no" ;;
86 # Guess yes otherwise. 89 # Guess yes otherwise.
87 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; 90 *)
91 gl_cv_func_wcrtomb_retval="guessing yes" ;;
88 esac 92 esac
89changequote([,])dnl 93changequote([,])dnl
90 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 94 if test $LOCALE_FR != none || test "$LOCALE_EN_UTF8" != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
91 AC_RUN_IFELSE( 95 AC_RUN_IFELSE(
92 [AC_LANG_SOURCE([[ 96 [AC_LANG_SOURCE([[
93#include <locale.h> 97#include <locale.h>
@@ -97,12 +101,14 @@ changequote([,])dnl
97int main () 101int main ()
98{ 102{
99 int result = 0; 103 int result = 0;
100 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) 104 if (strcmp ("$LOCALE_FR", "none") != 0
105 && setlocale (LC_ALL, "$LOCALE_FR") != NULL)
101 { 106 {
102 if (wcrtomb (NULL, 0, NULL) != 1) 107 if (wcrtomb (NULL, 0, NULL) != 1)
103 result |= 1; 108 result |= 1;
104 } 109 }
105 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 110 if (strcmp ("$LOCALE_EN_UTF8", "none") != 0
111 && setlocale (LC_ALL, "$LOCALE_EN_UTF8") != NULL)
106 { 112 {
107 if (wcrtomb (NULL, 0, NULL) != 1) 113 if (wcrtomb (NULL, 0, NULL) != 1)
108 result |= 2; 114 result |= 2;
@@ -113,12 +119,14 @@ int main ()
113 result |= 2; 119 result |= 2;
114 } 120 }
115 } 121 }
116 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 122 if (strcmp ("$LOCALE_JA", "none") != 0
123 && setlocale (LC_ALL, "$LOCALE_JA") != NULL)
117 { 124 {
118 if (wcrtomb (NULL, 0, NULL) != 1) 125 if (wcrtomb (NULL, 0, NULL) != 1)
119 result |= 4; 126 result |= 4;
120 } 127 }
121 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) 128 if (strcmp ("$LOCALE_ZH_CN", "none") != 0
129 && setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
122 { 130 {
123 if (wcrtomb (NULL, 0, NULL) != 1) 131 if (wcrtomb (NULL, 0, NULL) != 1)
124 result |= 8; 132 result |= 8;
diff --git a/gl/m4/wctype.m4 b/gl/m4/wctype.m4
new file mode 100644
index 00000000..6a6cb3a4
--- /dev/null
+++ b/gl/m4/wctype.m4
@@ -0,0 +1,53 @@
1# wctype.m4
2# serial 6
3dnl Copyright (C) 2011-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN_ONCE([gl_FUNC_WCTYPE],
10[
11 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
12 AC_REQUIRE([gl_WCTYPE_H])
13 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
14 HAVE_WCTYPE=$HAVE_WCTYPE_T
15 if test $HAVE_WCTYPE = 1; then
16 AC_CACHE_CHECK([whether wctype supports the "blank" and "punct" character classes],
17 [gl_cv_func_wctype_works],
18 [AC_RUN_IFELSE(
19 [AC_LANG_SOURCE([[
20 #include <ctype.h>
21 #include <wchar.h>
22 #include <wctype.h>
23 int main ()
24 {
25 /* This test fails on mingw. */
26 if (wctype ("blank") == (wctype_t)0)
27 return 1;
28 /* This test fails on MSVC 14. */
29 if ((! iswctype ('\t', wctype ("blank"))) != (! iswblank ('\t')))
30 return 2;
31 /* This test fails on Android 11. */
32 if ((! iswctype ('\`', wctype ("punct"))) != (! ispunct ('\`')))
33 return 4;
34 return 0;
35 }
36 ]])],
37 [gl_cv_func_wctype_works=yes], [gl_cv_func_wctype_works=no],
38 [case "$host_os" in
39 # Guess no on native Windows.
40 mingw* | windows*) gl_cv_func_wctype_works="guessing no" ;;
41 # Guess no on Android.
42 android*) gl_cv_func_wctype_works="guessing no" ;;
43 # Guess yes otherwise.
44 *) gl_cv_func_wctype_works="guessing yes" ;;
45 esac
46 ])
47 ])
48 case "$gl_cv_func_wctype_works" in
49 *yes) ;;
50 *) REPLACE_WCTYPE=1 ;;
51 esac
52 fi
53])
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index 6856a735..12b4c618 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,11 +1,13 @@
1# wctype_h.m4 serial 30 1# wctype_h.m4
2# serial 33
2 3
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it. 4dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4 5
5dnl Copyright (C) 2006-2023 Free Software Foundation, Inc. 6dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation 7dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 8dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 9dnl with or without modifications, as long as this notice is preserved.
10dnl This file is offered as-is, without any warranty.
9 11
10dnl Written by Paul Eggert. 12dnl Written by Paul Eggert.
11 13
@@ -178,6 +180,7 @@ AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS],
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [ 180 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK]) 181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT]) 182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWPUNCT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT]) 184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE]) 185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE]) 186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE])
@@ -196,5 +199,8 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
196 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) 199 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
197 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) 200 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
198 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT]) 201 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
202 REPLACE_ISWPUNCT=0; AC_SUBST([REPLACE_ISWPUNCT])
199 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT]) 203 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
204 REPLACE_WCTRANS=0; AC_SUBST([REPLACE_WCTRANS])
205 REPLACE_WCTYPE=0; AC_SUBST([REPLACE_WCTYPE])
200]) 206])
diff --git a/gl/m4/wcwidth.m4 b/gl/m4/wcwidth.m4
new file mode 100644
index 00000000..515076ba
--- /dev/null
+++ b/gl/m4/wcwidth.m4
@@ -0,0 +1,116 @@
1# wcwidth.m4
2# serial 39
3dnl Copyright (C) 2006-2026 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
8
9AC_DEFUN([gl_FUNC_WCWIDTH],
10[
11 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13
14 dnl Persuade glibc <wchar.h> to declare wcwidth().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_REQUIRE([gt_TYPE_WINT_T])
18
19 AC_CHECK_HEADERS_ONCE([wchar.h])
20 AC_CHECK_FUNCS_ONCE([wcwidth])
21
22 AC_CHECK_DECLS([wcwidth], [], [], [[
23 #include <wchar.h>
24 ]])
25 if test $ac_cv_have_decl_wcwidth != yes; then
26 HAVE_DECL_WCWIDTH=0
27 fi
28
29 if test $ac_cv_func_wcwidth != yes; then
30 AC_CACHE_CHECK([whether wcwidth is a macro],
31 [gl_cv_func_wcwidth_macro],
32 [AC_EGREP_CPP([wchar_header_defines_wcwidth], [
33#include <wchar.h>
34#ifdef wcwidth
35 wchar_header_defines_wcwidth
36#endif],
37 [gl_cv_func_wcwidth_macro=yes],
38 [gl_cv_func_wcwidth_macro=no])
39 ])
40 fi
41
42 if test $ac_cv_func_wcwidth = yes || test $gl_cv_func_wcwidth_macro = yes; then
43 HAVE_WCWIDTH=1
44 dnl On Mac OS X 10.3, wcwidth(0x0301) (COMBINING ACUTE ACCENT) returns 1.
45 dnl On macOS 12.5, NetBSD 9.3, OpenBSD 5.0, MidnightBSD 1.1,
46 dnl wcwidth(0x05B0) (HEBREW POINT SHEVA) returns 1.
47 dnl On macOS 12.5, NetBSD 9.3, MidnightBSD 1.1,
48 dnl wcwidth(0x200B) (ZERO WIDTH SPACE) returns 1.
49 dnl On OpenBSD 5.8, wcwidth(0xFF1A) (FULLWIDTH COLON) returns 0.
50 dnl This leads to bugs in 'ls' (coreutils).
51 dnl On Solaris 11.4, wcwidth(0x2202) (PARTIAL DIFFERENTIAL) returns 2,
52 dnl even in Western locales.
53 AC_CACHE_CHECK([whether wcwidth works reasonably in UTF-8 locales],
54 [gl_cv_func_wcwidth_works],
55 [
56 AC_RUN_IFELSE(
57 [AC_LANG_SOURCE([[
58#include <locale.h>
59#include <wchar.h>
60#if !HAVE_DECL_WCWIDTH
61extern
62# ifdef __cplusplus
63"C"
64# endif
65int wcwidth (int);
66#endif
67int main ()
68{
69 int result = 0;
70 if (setlocale (LC_ALL, "en_US.UTF-8") != NULL)
71 {
72 if (wcwidth (0x0301) > 0)
73 result |= 1;
74 if (wcwidth (0x05B0) > 0)
75 result |= 2;
76 if (wcwidth (0x200B) > 0)
77 result |= 4;
78 if (wcwidth (0xFF1A) == 0)
79 result |= 8;
80 if (wcwidth (0x2202) > 1)
81 result |= 16;
82 }
83 return result;
84}]])],
85 [gl_cv_func_wcwidth_works=yes],
86 [gl_cv_func_wcwidth_works=no],
87 [
88changequote(,)dnl
89 case "$host_os" in
90 # Guess yes on glibc systems.
91 *-gnu* | gnu*) gl_cv_func_wcwidth_works="guessing yes";;
92 # Guess yes on musl systems.
93 *-musl* | midipix*) gl_cv_func_wcwidth_works="guessing yes";;
94 # Guess yes on AIX 7 systems.
95 aix[7-9]*) gl_cv_func_wcwidth_works="guessing yes";;
96 *) gl_cv_func_wcwidth_works="$gl_cross_guess_normal";;
97 esac
98changequote([,])dnl
99 ])
100 ])
101 case "$gl_cv_func_wcwidth_works" in
102 *yes) ;;
103 *no) REPLACE_WCWIDTH=1 ;;
104 esac
105 else
106 HAVE_WCWIDTH=0
107 fi
108 dnl We don't substitute HAVE_WCWIDTH. We assume that if the system does not
109 dnl have the wcwidth function, then it does not declare it.
110])
111
112# Prerequisites of lib/wcwidth.c.
113AC_DEFUN([gl_PREREQ_WCWIDTH], [
114 AC_REQUIRE([AC_C_INLINE])
115 :
116])
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index dfd743b3..384462d2 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,8 +1,10 @@
1# wint_t.m4 serial 11 1# wint_t.m4
2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc. 2# serial 11
3dnl Copyright (C) 2003, 2007-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl From Bruno Haible. 9dnl From Bruno Haible.
8dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's 10dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
diff --git a/gl/m4/xalloc.m4 b/gl/m4/xalloc.m4
index fc56f59a..a0d0f060 100644
--- a/gl/m4/xalloc.m4
+++ b/gl/m4/xalloc.m4
@@ -1,7 +1,9 @@
1# xalloc.m4 serial 18 1# xalloc.m4
2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc. 2# serial 18
3dnl Copyright (C) 2002-2006, 2009-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_XALLOC], [:]) 9AC_DEFUN([gl_XALLOC], [:])
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index 649db9c5..4e35a5fe 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,8 +1,10 @@
1# xsize.m4 serial 5 1# xsize.m4
2dnl Copyright (C) 2003-2004, 2008-2023 Free Software Foundation, Inc. 2# serial 5
3dnl Copyright (C) 2003-2004, 2008-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_XSIZE], 9AC_DEFUN([gl_XSIZE],
8[ 10[
diff --git a/gl/m4/zzgnulib.m4 b/gl/m4/zzgnulib.m4
index 362102b6..fed091ca 100644
--- a/gl/m4/zzgnulib.m4
+++ b/gl/m4/zzgnulib.m4
@@ -1,8 +1,10 @@
1# zzgnulib.m4 serial 1 1# zzgnulib.m4
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc. 2# serial 1
3dnl Copyright (C) 2020-2026 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7dnl This file must be named something that sorts after all other 9dnl This file must be named something that sorts after all other
8dnl package- or gnulib-provided .m4 files - at least for those packages 10dnl package- or gnulib-provided .m4 files - at least for those packages
diff --git a/gl/malloc.c b/gl/malloc.c
index 3ade35cb..f7d11921 100644
--- a/gl/malloc.c
+++ b/gl/malloc.c
@@ -1,6 +1,6 @@
1/* malloc() function that is glibc compatible. 1/* malloc() function that is glibc compatible.
2 2
3 Copyright (C) 1997-1998, 2006-2007, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 1997-1998, 2006-2007, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -17,28 +17,33 @@
17 17
18/* written by Jim Meyering and Bruno Haible */ 18/* written by Jim Meyering and Bruno Haible */
19 19
20/* Ensure that we call the system's malloc() below. */
20#define _GL_USE_STDLIB_ALLOC 1 21#define _GL_USE_STDLIB_ALLOC 1
21#include <config.h> 22#include <config.h>
22 23
23#include <stdlib.h> 24#include <stdlib.h>
24 25
25#include <errno.h> 26#include <errno.h>
26 27#include <stdckdint.h>
27#include "xalloc-oversized.h"
28 28
29/* Allocate an N-byte block of memory from the heap, even if N is 0. */ 29/* Allocate an N-byte block of memory from the heap, even if N is 0. */
30 30
31void * 31void *
32rpl_malloc (size_t n) 32rpl_malloc (size_t n)
33{ 33{
34#if !HAVE_MALLOC_0_NONNULL
34 if (n == 0) 35 if (n == 0)
35 n = 1; 36 n = 1;
37#endif
36 38
37 if (xalloc_oversized (n, 1)) 39#if !HAVE_MALLOC_PTRDIFF
40 ptrdiff_t signed_n;
41 if (ckd_add (&signed_n, n, 0))
38 { 42 {
39 errno = ENOMEM; 43 errno = ENOMEM;
40 return NULL; 44 return NULL;
41 } 45 }
46#endif
42 47
43 void *result = malloc (n); 48 void *result = malloc (n);
44 49
diff --git a/gl/malloc/dynarray-skeleton.c b/gl/malloc/dynarray-skeleton.c
index 580c278b..9d83658e 100644
--- a/gl/malloc/dynarray-skeleton.c
+++ b/gl/malloc/dynarray-skeleton.c
@@ -1,5 +1,5 @@
1/* Type-safe arrays which grow dynamically. 1/* Type-safe arrays which grow dynamically.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
diff --git a/gl/malloc/dynarray.h b/gl/malloc/dynarray.h
index a9a3b085..e6a998d3 100644
--- a/gl/malloc/dynarray.h
+++ b/gl/malloc/dynarray.h
@@ -1,5 +1,5 @@
1/* Type-safe arrays which grow dynamically. Shared definitions. 1/* Type-safe arrays which grow dynamically. Shared definitions.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
diff --git a/gl/malloc/dynarray_at_failure.c b/gl/malloc/dynarray_at_failure.c
index ebc93109..c05807f0 100644
--- a/gl/malloc/dynarray_at_failure.c
+++ b/gl/malloc/dynarray_at_failure.c
@@ -1,5 +1,5 @@
1/* Report an dynamic array index out of bounds condition. 1/* Report an dynamic array index out of bounds condition.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
diff --git a/gl/malloc/dynarray_emplace_enlarge.c b/gl/malloc/dynarray_emplace_enlarge.c
index 7da53931..d3bb0447 100644
--- a/gl/malloc/dynarray_emplace_enlarge.c
+++ b/gl/malloc/dynarray_emplace_enlarge.c
@@ -1,5 +1,5 @@
1/* Increase the size of a dynamic array in preparation of an emplace operation. 1/* Increase the size of a dynamic array in preparation of an emplace operation.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
@@ -22,7 +22,7 @@
22 22
23#include <dynarray.h> 23#include <dynarray.h>
24#include <errno.h> 24#include <errno.h>
25#include <intprops.h> 25#include <stdckdint.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28 28
@@ -56,7 +56,7 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list,
56 } 56 }
57 57
58 size_t new_size; 58 size_t new_size;
59 if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size)) 59 if (ckd_mul (&new_size, new_allocated, element_size))
60 return false; 60 return false;
61 void *new_array; 61 void *new_array;
62 if (list->array == scratch) 62 if (list->array == scratch)
diff --git a/gl/malloc/dynarray_finalize.c b/gl/malloc/dynarray_finalize.c
index 673595a5..b2e37837 100644
--- a/gl/malloc/dynarray_finalize.c
+++ b/gl/malloc/dynarray_finalize.c
@@ -1,5 +1,5 @@
1/* Copy the dynamically-allocated area to an explicitly-sized heap allocation. 1/* Copy the dynamically-allocated area to an explicitly-sized heap allocation.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
diff --git a/gl/malloc/dynarray_resize.c b/gl/malloc/dynarray_resize.c
index 7ecd4de6..d890b253 100644
--- a/gl/malloc/dynarray_resize.c
+++ b/gl/malloc/dynarray_resize.c
@@ -1,5 +1,5 @@
1/* Increase the size of a dynamic array. 1/* Increase the size of a dynamic array.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
@@ -22,7 +22,7 @@
22 22
23#include <dynarray.h> 23#include <dynarray.h>
24#include <errno.h> 24#include <errno.h>
25#include <intprops.h> 25#include <stdckdint.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28 28
@@ -42,7 +42,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
42 over-allocation here. */ 42 over-allocation here. */
43 43
44 size_t new_size_bytes; 44 size_t new_size_bytes;
45 if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes)) 45 if (ckd_mul (&new_size_bytes, size, element_size))
46 { 46 {
47 /* Overflow. */ 47 /* Overflow. */
48 __set_errno (ENOMEM); 48 __set_errno (ENOMEM);
diff --git a/gl/malloc/dynarray_resize_clear.c b/gl/malloc/dynarray_resize_clear.c
index bb23c522..34d01062 100644
--- a/gl/malloc/dynarray_resize_clear.c
+++ b/gl/malloc/dynarray_resize_clear.c
@@ -1,5 +1,5 @@
1/* Increase the size of a dynamic array and clear the new part. 1/* Increase the size of a dynamic array and clear the new part.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
diff --git a/gl/malloca.c b/gl/malloca.c
index f055b1e5..943140c8 100644
--- a/gl/malloca.c
+++ b/gl/malloca.c
@@ -1,5 +1,5 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003, 2006-2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2003, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003, 2018. 3 Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -22,6 +22,9 @@
22#include "malloca.h" 22#include "malloca.h"
23 23
24#include <stdckdint.h> 24#include <stdckdint.h>
25#if defined __CHERI_PURE_CAPABILITY__
26# include <cheri.h>
27#endif
25 28
26#include "idx.h" 29#include "idx.h"
27 30
@@ -36,10 +39,15 @@
36 allocation. 39 allocation.
37 - NULL comes from a failed heap allocation. */ 40 - NULL comes from a failed heap allocation. */
38 41
42#if defined __CHERI_PURE_CAPABILITY__
43/* Type for holding the original malloc() result. */
44typedef uintptr_t small_t;
45#else
39/* Type for holding very small pointer differences. */ 46/* Type for holding very small pointer differences. */
40typedef unsigned char small_t; 47typedef unsigned char small_t;
41/* Verify that it is wide enough. */ 48/* Verify that it is wide enough. */
42static_assert (2 * sa_alignment_max - 1 <= (small_t) -1); 49static_assert (2 * sa_alignment_max - 1 <= (small_t) -1);
50#endif
43 51
44void * 52void *
45mmalloca (size_t n) 53mmalloca (size_t n)
@@ -56,20 +64,28 @@ mmalloca (size_t n)
56 64
57 if (mem != NULL) 65 if (mem != NULL)
58 { 66 {
59 uintptr_t umem = (uintptr_t)mem, umemplus; 67 uintptr_t umem = (uintptr_t) mem;
60 /* The ckd_add avoids signed integer overflow on 68 /* The ckd_add avoids signed integer overflow on
61 theoretical platforms where UINTPTR_MAX <= INT_MAX. */ 69 theoretical platforms where UINTPTR_MAX <= INT_MAX. */
70 uintptr_t umemplus;
62 ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1); 71 ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
63 idx_t offset = ((umemplus & ~alignment2_mask) 72 idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max)
64 + sa_alignment_max - umem); 73 + sa_alignment_max - umem);
65 void *vp = mem + offset; 74 void *p = mem + offset;
66 small_t *p = vp;
67 /* Here p >= mem + sizeof (small_t), 75 /* Here p >= mem + sizeof (small_t),
68 and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1 76 and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
69 hence p + n <= mem + nplus. 77 hence p + n <= mem + nplus.
70 So, the memory range [p, p+n) lies in the allocated memory range 78 So, the memory range [p, p+n) lies in the allocated memory range
71 [mem, mem + nplus). */ 79 [mem, mem + nplus). */
72 p[-1] = offset; 80 small_t *sp = p;
81# if defined __CHERI_PURE_CAPABILITY__
82 sp[-1] = umem;
83 p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t),
84 sizeof (small_t) + n)
85 + sizeof (small_t);
86# else
87 sp[-1] = offset;
88# endif
73 /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ 89 /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
74 return p; 90 return p;
75 } 91 }
@@ -77,7 +93,7 @@ mmalloca (size_t n)
77 /* Out of memory. */ 93 /* Out of memory. */
78 return NULL; 94 return NULL;
79#else 95#else
80# if !MALLOC_0_IS_NONNULL 96# if !HAVE_MALLOC_0_NONNULL
81 if (n == 0) 97 if (n == 0)
82 n = 1; 98 n = 1;
83# endif 99# endif
@@ -90,15 +106,22 @@ void
90freea (void *p) 106freea (void *p)
91{ 107{
92 /* Check argument. */ 108 /* Check argument. */
93 if ((uintptr_t) p & (sa_alignment_max - 1)) 109 uintptr_t u = (uintptr_t) p;
110 if (u & (sa_alignment_max - 1))
94 { 111 {
95 /* p was not the result of a malloca() call. Invalid argument. */ 112 /* p was not the result of a malloca() call. Invalid argument. */
96 abort (); 113 abort ();
97 } 114 }
98 /* Determine whether p was a non-NULL pointer returned by mmalloca(). */ 115 /* Determine whether p was a non-NULL pointer returned by mmalloca(). */
99 if ((uintptr_t) p & sa_alignment_max) 116 if (u & sa_alignment_max)
100 { 117 {
101 void *mem = (char *) p - ((small_t *) p)[-1]; 118 char *cp = p;
119 small_t *sp = p;
120# if defined __CHERI_PURE_CAPABILITY__
121 void *mem = (void *) sp[-1];
122# else
123 void *mem = cp - sp[-1];
124# endif
102 free (mem); 125 free (mem);
103 } 126 }
104} 127}
diff --git a/gl/malloca.h b/gl/malloca.h
index 325c7277..1ebe6916 100644
--- a/gl/malloca.h
+++ b/gl/malloca.h
@@ -1,5 +1,5 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2003-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -18,10 +18,19 @@
18#ifndef _MALLOCA_H 18#ifndef _MALLOCA_H
19#define _MALLOCA_H 19#define _MALLOCA_H
20 20
21/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_DEALLOC,
22 _GL_ATTRIBUTE_MALLOC, HAVE_ALLOCA. */
23#if !_GL_CONFIG_H_INCLUDED
24 #error "Please include config.h first."
25#endif
26
21#include <alloca.h> 27#include <alloca.h>
22#include <stddef.h> 28#include <stddef.h>
23#include <stdlib.h> 29#include <stdlib.h>
24#include <stdint.h> 30#include <stdint.h>
31#if defined __CHERI_PURE_CAPABILITY__
32# include <cheri.h>
33#endif
25 34
26#include "xalloc-oversized.h" 35#include "xalloc-oversized.h"
27 36
@@ -62,12 +71,24 @@ extern void freea (void *p);
62 memory allocated on the stack, that must be freed using freea() before 71 memory allocated on the stack, that must be freed using freea() before
63 the function returns. Upon failure, it returns NULL. */ 72 the function returns. Upon failure, it returns NULL. */
64#if HAVE_ALLOCA 73#if HAVE_ALLOCA
65# define malloca(N) \ 74# if defined __CHERI_PURE_CAPABILITY__
66 ((N) < 4032 - (2 * sa_alignment_max - 1) \ 75# define malloca(N) \
67 ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ 76 ((N) < 4032 - (2 * sa_alignment_max - 1) \
68 + (2 * sa_alignment_max - 1)) \ 77 ? cheri_bounds_set ((void *) (((uintptr_t) \
69 & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ 78 (char *) \
70 : mmalloca (N)) 79 alloca ((N) + 2 * sa_alignment_max - 1) \
80 + (2 * sa_alignment_max - 1)) \
81 & ~(uintptr_t)(2 * sa_alignment_max - 1)), \
82 (N)) \
83 : mmalloca (N))
84# else
85# define malloca(N) \
86 ((N) < 4032 - (2 * sa_alignment_max - 1) \
87 ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
88 + (2 * sa_alignment_max - 1)) \
89 & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
90 : mmalloca (N))
91# endif
71#else 92#else
72# define malloca(N) \ 93# define malloca(N) \
73 mmalloca (N) 94 mmalloca (N)
diff --git a/gl/math.c b/gl/math.c
index 67cabbcf..8f0c9d78 100644
--- a/gl/math.c
+++ b/gl/math.c
@@ -1,6 +1,6 @@
1/* Inline functions for <math.h>. 1/* Inline functions for <math.h>.
2 2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc. 3 Copyright (C) 2012-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,8 +15,8 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#define _GL_MATH_INLINE _GL_EXTERN_INLINE
18#include <config.h> 19#include <config.h>
19 20
20#define _GL_MATH_INLINE _GL_EXTERN_INLINE 21#include <math.h>
21#include "math.h"
22typedef int dummy; 22typedef int dummy;
diff --git a/gl/math.in.h b/gl/math.in.h
index f3d58afc..14218ea0 100644
--- a/gl/math.in.h
+++ b/gl/math.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <math.h>. 1/* A GNU-like <math.h>.
2 2
3 Copyright (C) 2002-2003, 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,6 +15,11 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* On Android, in C++ mode, when /usr/include/c++/v1/math.h is being included
19 and /usr/include/math.h has not yet been included, skip this file, since it
20 would lead to many syntax errors. */
21#if !(defined __ANDROID__ && defined _LIBCPP_MATH_H && !defined INFINITY)
22
18#ifndef _@GUARD_PREFIX@_MATH_H 23#ifndef _@GUARD_PREFIX@_MATH_H
19 24
20#if __GNUC__ >= 3 25#if __GNUC__ >= 3
@@ -43,14 +48,17 @@
43#ifndef _@GUARD_PREFIX@_MATH_H 48#ifndef _@GUARD_PREFIX@_MATH_H
44#define _@GUARD_PREFIX@_MATH_H 49#define _@GUARD_PREFIX@_MATH_H
45 50
51/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST,
52 GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
53#if !_GL_CONFIG_H_INCLUDED
54 #error "Please include config.h first."
55#endif
56
46/* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in <fp.h>. */ 57/* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in <fp.h>. */
47#if defined __VMS && ! defined NAN 58#if defined __VMS && ! defined NAN
48# include <fp.h> 59# include <fp.h>
49#endif 60#endif
50 61
51#ifndef _GL_INLINE_HEADER_BEGIN
52 #error "Please include config.h first."
53#endif
54_GL_INLINE_HEADER_BEGIN 62_GL_INLINE_HEADER_BEGIN
55#ifndef _GL_MATH_INLINE 63#ifndef _GL_MATH_INLINE
56# define _GL_MATH_INLINE _GL_INLINE 64# define _GL_MATH_INLINE _GL_INLINE
@@ -152,12 +160,23 @@ static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq;
152#endif 160#endif
153 161
154 162
163/* Ensure that INFINITY is a constant expression, of type 'float'. */
164#if !defined INFINITY || (defined __FreeBSD__ && __FreeBSD__ < 8) || defined _AIX || defined __MINGW32__
165# undef INFINITY
166# if defined __GNUC__ || defined __clang__
167# define INFINITY (__builtin_inff ())
168# else
169# define INFINITY (1.0f / 0.0f)
170# endif
171#endif
172
155/* POSIX allows platforms that don't support NAN. But all major 173/* POSIX allows platforms that don't support NAN. But all major
156 machines in the past 15 years have supported something close to 174 machines in the past 15 years have supported something close to
157 IEEE NaN, so we define this unconditionally. We also must define 175 IEEE NaN, so we define this unconditionally. We also must define
158 it on platforms like Solaris 10, where NAN is present but defined 176 it on platforms like Solaris 10, where NAN is present but defined
159 as a function pointer rather than a floating point constant. */ 177 as a function pointer rather than a floating point constant.
160#if !defined NAN || @REPLACE_NAN@ 178 Also ensure that it is a constant expression, of type 'float'. */
179#if !defined NAN || @REPLACE_NAN@ || (defined __FreeBSD__ && __FreeBSD__ < 8) || defined _AIX || defined __MINGW32__
161# if !GNULIB_defined_NAN 180# if !GNULIB_defined_NAN
162# undef NAN 181# undef NAN
163 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler 182 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler
@@ -170,6 +189,8 @@ _NaN ()
170 return zero / zero; 189 return zero / zero;
171} 190}
172# define NAN (_NaN()) 191# define NAN (_NaN())
192# elif defined __GNUC__ || defined __clang__
193# define NAN (__builtin_nanf (""))
173# else 194# else
174# define NAN (0.0f / 0.0f) 195# define NAN (0.0f / 0.0f)
175# endif 196# endif
@@ -189,49 +210,49 @@ _NaN ()
189#endif 210#endif
190 211
191/* HUGE_VALF is a 'float' Infinity. */ 212/* HUGE_VALF is a 'float' Infinity. */
192#ifndef HUGE_VALF 213#if !defined HUGE_VALF || (defined __FreeBSD__ && __FreeBSD__ < 6)
214# undef HUGE_VALF
193# if defined _MSC_VER 215# if defined _MSC_VER
194/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */ 216/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */
195# define HUGE_VALF (1e25f * 1e25f) 217# define HUGE_VALF (1e25f * 1e25f)
218# elif defined __GNUC__ || defined __clang__
219# define HUGE_VALF (__builtin_inff ())
196# else 220# else
197# define HUGE_VALF (1.0f / 0.0f) 221# define HUGE_VALF (1.0f / 0.0f)
198# endif 222# endif
199#endif 223#endif
200 224
201/* HUGE_VAL is a 'double' Infinity. */ 225/* HUGE_VAL is a 'double' Infinity. */
202#ifndef HUGE_VAL 226#if !defined HUGE_VAL || (defined __FreeBSD__ && __FreeBSD__ < 6) || defined _AIX
227# undef HUGE_VAL
203# if defined _MSC_VER 228# if defined _MSC_VER
204/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */ 229/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */
205# define HUGE_VAL (1e250 * 1e250) 230# define HUGE_VAL (1e250 * 1e250)
231# elif defined __GNUC__ || defined __clang__
232# define HUGE_VAL (__builtin_inf ())
206# else 233# else
207# define HUGE_VAL (1.0 / 0.0) 234# define HUGE_VAL (1.0 / 0.0)
208# endif 235# endif
209#endif 236#endif
210 237
211/* HUGE_VALL is a 'long double' Infinity. */ 238/* HUGE_VALL is a 'long double' Infinity. */
212#ifndef HUGE_VALL 239#if !defined HUGE_VALL || (defined __FreeBSD__ && __FreeBSD__ < 6) || defined _AIX
240# undef HUGE_VALL
213# if defined _MSC_VER 241# if defined _MSC_VER
214/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */ 242/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */
215# define HUGE_VALL (1e250L * 1e250L) 243# define HUGE_VALL (1e250L * 1e250L)
244# elif defined __GNUC__ || defined __clang__
245# define HUGE_VALL (__builtin_infl ())
216# else 246# else
217# define HUGE_VALL (1.0L / 0.0L) 247# define HUGE_VALL (1.0L / 0.0L)
218# endif 248# endif
219#endif 249#endif
220 250
221 251
222#if defined FP_ILOGB0 && defined FP_ILOGBNAN 252#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
223 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are correct. */
224# if defined __HAIKU__
225 /* Haiku: match what ilogb() does */
226# undef FP_ILOGB0
227# undef FP_ILOGBNAN
228# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
229# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
230# endif
231#else
232 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */ 253 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
233# if defined __NetBSD__ || defined __sgi 254# if defined __NetBSD__
234 /* NetBSD, IRIX 6.5: match what ilogb() does */ 255 /* NetBSD: match what ilogb() does */
235# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ 256# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
236# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */ 257# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
237# elif defined _AIX 258# elif defined _AIX
@@ -256,18 +277,17 @@ _NaN ()
256# undef acosf 277# undef acosf
257# define acosf rpl_acosf 278# define acosf rpl_acosf
258# endif 279# endif
259_GL_FUNCDECL_RPL (acosf, float, (float x)); 280_GL_FUNCDECL_RPL (acosf, float, (float x), );
260_GL_CXXALIAS_RPL (acosf, float, (float x)); 281_GL_CXXALIAS_RPL (acosf, float, (float x));
261# else 282# else
262# if !@HAVE_ACOSF@ 283# if !@HAVE_ACOSF@
263# undef acosf 284# undef acosf
264_GL_FUNCDECL_SYS (acosf, float, (float x)); 285_GL_FUNCDECL_SYS (acosf, float, (float x), );
265# endif 286# endif
266_GL_CXXALIAS_SYS (acosf, float, (float x)); 287_GL_CXXALIAS_SYS (acosf, float, (float x));
267# endif 288# endif
268_GL_CXXALIASWARN (acosf); 289_GL_CXXALIASWARN (acosf);
269#elif defined GNULIB_POSIXCHECK 290#elif defined GNULIB_POSIXCHECK
270# undef acosf
271# if HAVE_RAW_DECL_ACOSF 291# if HAVE_RAW_DECL_ACOSF
272_GL_WARN_ON_USE (acosf, "acosf is unportable - " 292_GL_WARN_ON_USE (acosf, "acosf is unportable - "
273 "use gnulib module acosf for portability"); 293 "use gnulib module acosf for portability");
@@ -277,14 +297,13 @@ _GL_WARN_ON_USE (acosf, "acosf is unportable - "
277#if @GNULIB_ACOSL@ 297#if @GNULIB_ACOSL@
278# if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@ 298# if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
279# undef acosl 299# undef acosl
280_GL_FUNCDECL_SYS (acosl, long double, (long double x)); 300_GL_FUNCDECL_SYS (acosl, long double, (long double x), );
281# endif 301# endif
282_GL_CXXALIAS_SYS (acosl, long double, (long double x)); 302_GL_CXXALIAS_SYS (acosl, long double, (long double x));
283# if __GLIBC__ >= 2 303# if __GLIBC__ >= 2
284_GL_CXXALIASWARN (acosl); 304_GL_CXXALIASWARN (acosl);
285# endif 305# endif
286#elif defined GNULIB_POSIXCHECK 306#elif defined GNULIB_POSIXCHECK
287# undef acosl
288# if HAVE_RAW_DECL_ACOSL 307# if HAVE_RAW_DECL_ACOSL
289_GL_WARN_ON_USE (acosl, "acosl is unportable - " 308_GL_WARN_ON_USE (acosl, "acosl is unportable - "
290 "use gnulib module acosl for portability"); 309 "use gnulib module acosl for portability");
@@ -298,18 +317,17 @@ _GL_WARN_ON_USE (acosl, "acosl is unportable - "
298# undef asinf 317# undef asinf
299# define asinf rpl_asinf 318# define asinf rpl_asinf
300# endif 319# endif
301_GL_FUNCDECL_RPL (asinf, float, (float x)); 320_GL_FUNCDECL_RPL (asinf, float, (float x), );
302_GL_CXXALIAS_RPL (asinf, float, (float x)); 321_GL_CXXALIAS_RPL (asinf, float, (float x));
303# else 322# else
304# if !@HAVE_ASINF@ 323# if !@HAVE_ASINF@
305# undef asinf 324# undef asinf
306_GL_FUNCDECL_SYS (asinf, float, (float x)); 325_GL_FUNCDECL_SYS (asinf, float, (float x), );
307# endif 326# endif
308_GL_CXXALIAS_SYS (asinf, float, (float x)); 327_GL_CXXALIAS_SYS (asinf, float, (float x));
309# endif 328# endif
310_GL_CXXALIASWARN (asinf); 329_GL_CXXALIASWARN (asinf);
311#elif defined GNULIB_POSIXCHECK 330#elif defined GNULIB_POSIXCHECK
312# undef asinf
313# if HAVE_RAW_DECL_ASINF 331# if HAVE_RAW_DECL_ASINF
314_GL_WARN_ON_USE (asinf, "asinf is unportable - " 332_GL_WARN_ON_USE (asinf, "asinf is unportable - "
315 "use gnulib module asinf for portability"); 333 "use gnulib module asinf for portability");
@@ -319,14 +337,13 @@ _GL_WARN_ON_USE (asinf, "asinf is unportable - "
319#if @GNULIB_ASINL@ 337#if @GNULIB_ASINL@
320# if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@ 338# if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@
321# undef asinl 339# undef asinl
322_GL_FUNCDECL_SYS (asinl, long double, (long double x)); 340_GL_FUNCDECL_SYS (asinl, long double, (long double x), );
323# endif 341# endif
324_GL_CXXALIAS_SYS (asinl, long double, (long double x)); 342_GL_CXXALIAS_SYS (asinl, long double, (long double x));
325# if __GLIBC__ >= 2 343# if __GLIBC__ >= 2
326_GL_CXXALIASWARN (asinl); 344_GL_CXXALIASWARN (asinl);
327# endif 345# endif
328#elif defined GNULIB_POSIXCHECK 346#elif defined GNULIB_POSIXCHECK
329# undef asinl
330# if HAVE_RAW_DECL_ASINL 347# if HAVE_RAW_DECL_ASINL
331_GL_WARN_ON_USE (asinl, "asinl is unportable - " 348_GL_WARN_ON_USE (asinl, "asinl is unportable - "
332 "use gnulib module asinl for portability"); 349 "use gnulib module asinl for portability");
@@ -340,18 +357,17 @@ _GL_WARN_ON_USE (asinl, "asinl is unportable - "
340# undef atanf 357# undef atanf
341# define atanf rpl_atanf 358# define atanf rpl_atanf
342# endif 359# endif
343_GL_FUNCDECL_RPL (atanf, float, (float x)); 360_GL_FUNCDECL_RPL (atanf, float, (float x), );
344_GL_CXXALIAS_RPL (atanf, float, (float x)); 361_GL_CXXALIAS_RPL (atanf, float, (float x));
345# else 362# else
346# if !@HAVE_ATANF@ 363# if !@HAVE_ATANF@
347# undef atanf 364# undef atanf
348_GL_FUNCDECL_SYS (atanf, float, (float x)); 365_GL_FUNCDECL_SYS (atanf, float, (float x), );
349# endif 366# endif
350_GL_CXXALIAS_SYS (atanf, float, (float x)); 367_GL_CXXALIAS_SYS (atanf, float, (float x));
351# endif 368# endif
352_GL_CXXALIASWARN (atanf); 369_GL_CXXALIASWARN (atanf);
353#elif defined GNULIB_POSIXCHECK 370#elif defined GNULIB_POSIXCHECK
354# undef atanf
355# if HAVE_RAW_DECL_ATANF 371# if HAVE_RAW_DECL_ATANF
356_GL_WARN_ON_USE (atanf, "atanf is unportable - " 372_GL_WARN_ON_USE (atanf, "atanf is unportable - "
357 "use gnulib module atanf for portability"); 373 "use gnulib module atanf for portability");
@@ -361,14 +377,13 @@ _GL_WARN_ON_USE (atanf, "atanf is unportable - "
361#if @GNULIB_ATANL@ 377#if @GNULIB_ATANL@
362# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@ 378# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@
363# undef atanl 379# undef atanl
364_GL_FUNCDECL_SYS (atanl, long double, (long double x)); 380_GL_FUNCDECL_SYS (atanl, long double, (long double x), );
365# endif 381# endif
366_GL_CXXALIAS_SYS (atanl, long double, (long double x)); 382_GL_CXXALIAS_SYS (atanl, long double, (long double x));
367# if __GLIBC__ >= 2 383# if __GLIBC__ >= 2
368_GL_CXXALIASWARN (atanl); 384_GL_CXXALIASWARN (atanl);
369# endif 385# endif
370#elif defined GNULIB_POSIXCHECK 386#elif defined GNULIB_POSIXCHECK
371# undef atanl
372# if HAVE_RAW_DECL_ATANL 387# if HAVE_RAW_DECL_ATANL
373_GL_WARN_ON_USE (atanl, "atanl is unportable - " 388_GL_WARN_ON_USE (atanl, "atanl is unportable - "
374 "use gnulib module atanl for portability"); 389 "use gnulib module atanl for portability");
@@ -382,18 +397,17 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
382# undef atan2f 397# undef atan2f
383# define atan2f rpl_atan2f 398# define atan2f rpl_atan2f
384# endif 399# endif
385_GL_FUNCDECL_RPL (atan2f, float, (float y, float x)); 400_GL_FUNCDECL_RPL (atan2f, float, (float y, float x), );
386_GL_CXXALIAS_RPL (atan2f, float, (float y, float x)); 401_GL_CXXALIAS_RPL (atan2f, float, (float y, float x));
387# else 402# else
388# if !@HAVE_ATAN2F@ 403# if !@HAVE_ATAN2F@
389# undef atan2f 404# undef atan2f
390_GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); 405_GL_FUNCDECL_SYS (atan2f, float, (float y, float x), );
391# endif 406# endif
392_GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); 407_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
393# endif 408# endif
394_GL_CXXALIASWARN (atan2f); 409_GL_CXXALIASWARN (atan2f);
395#elif defined GNULIB_POSIXCHECK 410#elif defined GNULIB_POSIXCHECK
396# undef atan2f
397# if HAVE_RAW_DECL_ATAN2F 411# if HAVE_RAW_DECL_ATAN2F
398_GL_WARN_ON_USE (atan2f, "atan2f is unportable - " 412_GL_WARN_ON_USE (atan2f, "atan2f is unportable - "
399 "use gnulib module atan2f for portability"); 413 "use gnulib module atan2f for portability");
@@ -407,17 +421,16 @@ _GL_WARN_ON_USE (atan2f, "atan2f is unportable - "
407# undef cbrtf 421# undef cbrtf
408# define cbrtf rpl_cbrtf 422# define cbrtf rpl_cbrtf
409# endif 423# endif
410_GL_FUNCDECL_RPL (cbrtf, float, (float x)); 424_GL_FUNCDECL_RPL (cbrtf, float, (float x), );
411_GL_CXXALIAS_RPL (cbrtf, float, (float x)); 425_GL_CXXALIAS_RPL (cbrtf, float, (float x));
412# else 426# else
413# if !@HAVE_DECL_CBRTF@ 427# if !@HAVE_CBRTF@
414_GL_FUNCDECL_SYS (cbrtf, float, (float x)); 428_GL_FUNCDECL_SYS (cbrtf, float, (float x), );
415# endif 429# endif
416_GL_CXXALIAS_SYS (cbrtf, float, (float x)); 430_GL_CXXALIAS_SYS (cbrtf, float, (float x));
417# endif 431# endif
418_GL_CXXALIASWARN (cbrtf); 432_GL_CXXALIASWARN (cbrtf);
419#elif defined GNULIB_POSIXCHECK 433#elif defined GNULIB_POSIXCHECK
420# undef cbrtf
421# if HAVE_RAW_DECL_CBRTF 434# if HAVE_RAW_DECL_CBRTF
422_GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - " 435_GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - "
423 "use gnulib module cbrtf for portability"); 436 "use gnulib module cbrtf for portability");
@@ -426,14 +439,13 @@ _GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - "
426 439
427#if @GNULIB_CBRT@ 440#if @GNULIB_CBRT@
428# if !@HAVE_CBRT@ 441# if !@HAVE_CBRT@
429_GL_FUNCDECL_SYS (cbrt, double, (double x)); 442_GL_FUNCDECL_SYS (cbrt, double, (double x), );
430# endif 443# endif
431_GL_CXXALIAS_SYS (cbrt, double, (double x)); 444_GL_CXXALIAS_SYS (cbrt, double, (double x));
432# if __GLIBC__ >= 2 445# if __GLIBC__ >= 2
433_GL_CXXALIASWARN1 (cbrt, double, (double x)); 446_GL_CXXALIASWARN1 (cbrt, double, (double x));
434# endif 447# endif
435#elif defined GNULIB_POSIXCHECK 448#elif defined GNULIB_POSIXCHECK
436# undef cbrt
437# if HAVE_RAW_DECL_CBRT 449# if HAVE_RAW_DECL_CBRT
438_GL_WARN_ON_USE (cbrt, "cbrt is unportable - " 450_GL_WARN_ON_USE (cbrt, "cbrt is unportable - "
439 "use gnulib module cbrt for portability"); 451 "use gnulib module cbrt for portability");
@@ -446,11 +458,11 @@ _GL_WARN_ON_USE (cbrt, "cbrt is unportable - "
446# undef cbrtl 458# undef cbrtl
447# define cbrtl rpl_cbrtl 459# define cbrtl rpl_cbrtl
448# endif 460# endif
449_GL_FUNCDECL_RPL (cbrtl, long double, (long double x)); 461_GL_FUNCDECL_RPL (cbrtl, long double, (long double x), );
450_GL_CXXALIAS_RPL (cbrtl, long double, (long double x)); 462_GL_CXXALIAS_RPL (cbrtl, long double, (long double x));
451# else 463# else
452# if !@HAVE_DECL_CBRTL@ 464# if !@HAVE_CBRTL@
453_GL_FUNCDECL_SYS (cbrtl, long double, (long double x)); 465_GL_FUNCDECL_SYS (cbrtl, long double, (long double x), );
454# endif 466# endif
455_GL_CXXALIAS_SYS (cbrtl, long double, (long double x)); 467_GL_CXXALIAS_SYS (cbrtl, long double, (long double x));
456# endif 468# endif
@@ -458,7 +470,6 @@ _GL_CXXALIAS_SYS (cbrtl, long double, (long double x));
458_GL_CXXALIASWARN (cbrtl); 470_GL_CXXALIASWARN (cbrtl);
459# endif 471# endif
460#elif defined GNULIB_POSIXCHECK 472#elif defined GNULIB_POSIXCHECK
461# undef cbrtl
462# if HAVE_RAW_DECL_CBRTL 473# if HAVE_RAW_DECL_CBRTL
463_GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - " 474_GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - "
464 "use gnulib module cbrtl for portability"); 475 "use gnulib module cbrtl for portability");
@@ -472,18 +483,17 @@ _GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - "
472# undef ceilf 483# undef ceilf
473# define ceilf rpl_ceilf 484# define ceilf rpl_ceilf
474# endif 485# endif
475_GL_FUNCDECL_RPL (ceilf, float, (float x)); 486_GL_FUNCDECL_RPL (ceilf, float, (float x), );
476_GL_CXXALIAS_RPL (ceilf, float, (float x)); 487_GL_CXXALIAS_RPL (ceilf, float, (float x));
477# else 488# else
478# if !@HAVE_DECL_CEILF@ 489# if !@HAVE_DECL_CEILF@
479# undef ceilf 490# undef ceilf
480_GL_FUNCDECL_SYS (ceilf, float, (float x)); 491_GL_FUNCDECL_SYS (ceilf, float, (float x), );
481# endif 492# endif
482_GL_CXXALIAS_SYS (ceilf, float, (float x)); 493_GL_CXXALIAS_SYS (ceilf, float, (float x));
483# endif 494# endif
484_GL_CXXALIASWARN (ceilf); 495_GL_CXXALIASWARN (ceilf);
485#elif defined GNULIB_POSIXCHECK 496#elif defined GNULIB_POSIXCHECK
486# undef ceilf
487# if HAVE_RAW_DECL_CEILF 497# if HAVE_RAW_DECL_CEILF
488_GL_WARN_ON_USE (ceilf, "ceilf is unportable - " 498_GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
489 "use gnulib module ceilf for portability"); 499 "use gnulib module ceilf for portability");
@@ -496,7 +506,7 @@ _GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
496# undef ceil 506# undef ceil
497# define ceil rpl_ceil 507# define ceil rpl_ceil
498# endif 508# endif
499_GL_FUNCDECL_RPL (ceil, double, (double x)); 509_GL_FUNCDECL_RPL (ceil, double, (double x), );
500_GL_CXXALIAS_RPL (ceil, double, (double x)); 510_GL_CXXALIAS_RPL (ceil, double, (double x));
501# else 511# else
502_GL_CXXALIAS_SYS (ceil, double, (double x)); 512_GL_CXXALIAS_SYS (ceil, double, (double x));
@@ -512,12 +522,12 @@ _GL_CXXALIASWARN1 (ceil, double, (double x));
512# undef ceill 522# undef ceill
513# define ceill rpl_ceill 523# define ceill rpl_ceill
514# endif 524# endif
515_GL_FUNCDECL_RPL (ceill, long double, (long double x)); 525_GL_FUNCDECL_RPL (ceill, long double, (long double x), );
516_GL_CXXALIAS_RPL (ceill, long double, (long double x)); 526_GL_CXXALIAS_RPL (ceill, long double, (long double x));
517# else 527# else
518# if !@HAVE_DECL_CEILL@ 528# if !@HAVE_DECL_CEILL@
519# undef ceill 529# undef ceill
520_GL_FUNCDECL_SYS (ceill, long double, (long double x)); 530_GL_FUNCDECL_SYS (ceill, long double, (long double x), );
521# endif 531# endif
522_GL_CXXALIAS_SYS (ceill, long double, (long double x)); 532_GL_CXXALIAS_SYS (ceill, long double, (long double x));
523# endif 533# endif
@@ -525,7 +535,6 @@ _GL_CXXALIAS_SYS (ceill, long double, (long double x));
525_GL_CXXALIASWARN (ceill); 535_GL_CXXALIASWARN (ceill);
526# endif 536# endif
527#elif defined GNULIB_POSIXCHECK 537#elif defined GNULIB_POSIXCHECK
528# undef ceill
529# if HAVE_RAW_DECL_CEILL 538# if HAVE_RAW_DECL_CEILL
530_GL_WARN_ON_USE (ceill, "ceill is unportable - " 539_GL_WARN_ON_USE (ceill, "ceill is unportable - "
531 "use gnulib module ceill for portability"); 540 "use gnulib module ceill for portability");
@@ -534,14 +543,13 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - "
534 543
535 544
536#if @GNULIB_COPYSIGNF@ 545#if @GNULIB_COPYSIGNF@
537# if !@HAVE_DECL_COPYSIGNF@ 546# if !@HAVE_COPYSIGNF@
538# undef copysignf 547# undef copysignf
539_GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); 548_GL_FUNCDECL_SYS (copysignf, float, (float x, float y), );
540# endif 549# endif
541_GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); 550_GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
542_GL_CXXALIASWARN (copysignf); 551_GL_CXXALIASWARN (copysignf);
543#elif defined GNULIB_POSIXCHECK 552#elif defined GNULIB_POSIXCHECK
544# undef copysignf
545# if HAVE_RAW_DECL_COPYSIGNF 553# if HAVE_RAW_DECL_COPYSIGNF
546_GL_WARN_ON_USE (copysignf, "copysignf is unportable - " 554_GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
547 "use gnulib module copysignf for portability"); 555 "use gnulib module copysignf for portability");
@@ -550,14 +558,13 @@ _GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
550 558
551#if @GNULIB_COPYSIGN@ 559#if @GNULIB_COPYSIGN@
552# if !@HAVE_COPYSIGN@ 560# if !@HAVE_COPYSIGN@
553_GL_FUNCDECL_SYS (copysign, double, (double x, double y)); 561_GL_FUNCDECL_SYS (copysign, double, (double x, double y), );
554# endif 562# endif
555_GL_CXXALIAS_SYS (copysign, double, (double x, double y)); 563_GL_CXXALIAS_SYS (copysign, double, (double x, double y));
556# if __GLIBC__ >= 2 564# if __GLIBC__ >= 2
557_GL_CXXALIASWARN1 (copysign, double, (double x, double y)); 565_GL_CXXALIASWARN1 (copysign, double, (double x, double y));
558# endif 566# endif
559#elif defined GNULIB_POSIXCHECK 567#elif defined GNULIB_POSIXCHECK
560# undef copysign
561# if HAVE_RAW_DECL_COPYSIGN 568# if HAVE_RAW_DECL_COPYSIGN
562_GL_WARN_ON_USE (copysign, "copysign is unportable - " 569_GL_WARN_ON_USE (copysign, "copysign is unportable - "
563 "use gnulib module copysign for portability"); 570 "use gnulib module copysign for portability");
@@ -566,14 +573,13 @@ _GL_WARN_ON_USE (copysign, "copysign is unportable - "
566 573
567#if @GNULIB_COPYSIGNL@ 574#if @GNULIB_COPYSIGNL@
568# if !@HAVE_COPYSIGNL@ 575# if !@HAVE_COPYSIGNL@
569_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); 576_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y), );
570# endif 577# endif
571_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); 578_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
572# if __GLIBC__ >= 2 579# if __GLIBC__ >= 2
573_GL_CXXALIASWARN (copysignl); 580_GL_CXXALIASWARN (copysignl);
574# endif 581# endif
575#elif defined GNULIB_POSIXCHECK 582#elif defined GNULIB_POSIXCHECK
576# undef copysignl
577# if HAVE_RAW_DECL_COPYSIGNL 583# if HAVE_RAW_DECL_COPYSIGNL
578_GL_WARN_ON_USE (copysign, "copysignl is unportable - " 584_GL_WARN_ON_USE (copysign, "copysignl is unportable - "
579 "use gnulib module copysignl for portability"); 585 "use gnulib module copysignl for portability");
@@ -587,18 +593,17 @@ _GL_WARN_ON_USE (copysign, "copysignl is unportable - "
587# undef cosf 593# undef cosf
588# define cosf rpl_cosf 594# define cosf rpl_cosf
589# endif 595# endif
590_GL_FUNCDECL_RPL (cosf, float, (float x)); 596_GL_FUNCDECL_RPL (cosf, float, (float x), );
591_GL_CXXALIAS_RPL (cosf, float, (float x)); 597_GL_CXXALIAS_RPL (cosf, float, (float x));
592# else 598# else
593# if !@HAVE_COSF@ 599# if !@HAVE_COSF@
594# undef cosf 600# undef cosf
595_GL_FUNCDECL_SYS (cosf, float, (float x)); 601_GL_FUNCDECL_SYS (cosf, float, (float x), );
596# endif 602# endif
597_GL_CXXALIAS_SYS (cosf, float, (float x)); 603_GL_CXXALIAS_SYS (cosf, float, (float x));
598# endif 604# endif
599_GL_CXXALIASWARN (cosf); 605_GL_CXXALIASWARN (cosf);
600#elif defined GNULIB_POSIXCHECK 606#elif defined GNULIB_POSIXCHECK
601# undef cosf
602# if HAVE_RAW_DECL_COSF 607# if HAVE_RAW_DECL_COSF
603_GL_WARN_ON_USE (cosf, "cosf is unportable - " 608_GL_WARN_ON_USE (cosf, "cosf is unportable - "
604 "use gnulib module cosf for portability"); 609 "use gnulib module cosf for portability");
@@ -608,14 +613,13 @@ _GL_WARN_ON_USE (cosf, "cosf is unportable - "
608#if @GNULIB_COSL@ 613#if @GNULIB_COSL@
609# if !@HAVE_COSL@ || !@HAVE_DECL_COSL@ 614# if !@HAVE_COSL@ || !@HAVE_DECL_COSL@
610# undef cosl 615# undef cosl
611_GL_FUNCDECL_SYS (cosl, long double, (long double x)); 616_GL_FUNCDECL_SYS (cosl, long double, (long double x), );
612# endif 617# endif
613_GL_CXXALIAS_SYS (cosl, long double, (long double x)); 618_GL_CXXALIAS_SYS (cosl, long double, (long double x));
614# if __GLIBC__ >= 2 619# if __GLIBC__ >= 2
615_GL_CXXALIASWARN (cosl); 620_GL_CXXALIASWARN (cosl);
616# endif 621# endif
617#elif defined GNULIB_POSIXCHECK 622#elif defined GNULIB_POSIXCHECK
618# undef cosl
619# if HAVE_RAW_DECL_COSL 623# if HAVE_RAW_DECL_COSL
620_GL_WARN_ON_USE (cosl, "cosl is unportable - " 624_GL_WARN_ON_USE (cosl, "cosl is unportable - "
621 "use gnulib module cosl for portability"); 625 "use gnulib module cosl for portability");
@@ -629,18 +633,17 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - "
629# undef coshf 633# undef coshf
630# define coshf rpl_coshf 634# define coshf rpl_coshf
631# endif 635# endif
632_GL_FUNCDECL_RPL (coshf, float, (float x)); 636_GL_FUNCDECL_RPL (coshf, float, (float x), );
633_GL_CXXALIAS_RPL (coshf, float, (float x)); 637_GL_CXXALIAS_RPL (coshf, float, (float x));
634# else 638# else
635# if !@HAVE_COSHF@ 639# if !@HAVE_COSHF@
636# undef coshf 640# undef coshf
637_GL_FUNCDECL_SYS (coshf, float, (float x)); 641_GL_FUNCDECL_SYS (coshf, float, (float x), );
638# endif 642# endif
639_GL_CXXALIAS_SYS (coshf, float, (float x)); 643_GL_CXXALIAS_SYS (coshf, float, (float x));
640# endif 644# endif
641_GL_CXXALIASWARN (coshf); 645_GL_CXXALIASWARN (coshf);
642#elif defined GNULIB_POSIXCHECK 646#elif defined GNULIB_POSIXCHECK
643# undef coshf
644# if HAVE_RAW_DECL_COSHF 647# if HAVE_RAW_DECL_COSHF
645_GL_WARN_ON_USE (coshf, "coshf is unportable - " 648_GL_WARN_ON_USE (coshf, "coshf is unportable - "
646 "use gnulib module coshf for portability"); 649 "use gnulib module coshf for portability");
@@ -654,18 +657,17 @@ _GL_WARN_ON_USE (coshf, "coshf is unportable - "
654# undef expf 657# undef expf
655# define expf rpl_expf 658# define expf rpl_expf
656# endif 659# endif
657_GL_FUNCDECL_RPL (expf, float, (float x)); 660_GL_FUNCDECL_RPL (expf, float, (float x), );
658_GL_CXXALIAS_RPL (expf, float, (float x)); 661_GL_CXXALIAS_RPL (expf, float, (float x));
659# else 662# else
660# if !@HAVE_EXPF@ 663# if !@HAVE_EXPF@
661# undef expf 664# undef expf
662_GL_FUNCDECL_SYS (expf, float, (float x)); 665_GL_FUNCDECL_SYS (expf, float, (float x), );
663# endif 666# endif
664_GL_CXXALIAS_SYS (expf, float, (float x)); 667_GL_CXXALIAS_SYS (expf, float, (float x));
665# endif 668# endif
666_GL_CXXALIASWARN (expf); 669_GL_CXXALIASWARN (expf);
667#elif defined GNULIB_POSIXCHECK 670#elif defined GNULIB_POSIXCHECK
668# undef expf
669# if HAVE_RAW_DECL_EXPF 671# if HAVE_RAW_DECL_EXPF
670_GL_WARN_ON_USE (expf, "expf is unportable - " 672_GL_WARN_ON_USE (expf, "expf is unportable - "
671 "use gnulib module expf for portability"); 673 "use gnulib module expf for portability");
@@ -678,12 +680,12 @@ _GL_WARN_ON_USE (expf, "expf is unportable - "
678# undef expl 680# undef expl
679# define expl rpl_expl 681# define expl rpl_expl
680# endif 682# endif
681_GL_FUNCDECL_RPL (expl, long double, (long double x)); 683_GL_FUNCDECL_RPL (expl, long double, (long double x), );
682_GL_CXXALIAS_RPL (expl, long double, (long double x)); 684_GL_CXXALIAS_RPL (expl, long double, (long double x));
683# else 685# else
684# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@ 686# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
685# undef expl 687# undef expl
686_GL_FUNCDECL_SYS (expl, long double, (long double x)); 688_GL_FUNCDECL_SYS (expl, long double, (long double x), );
687# endif 689# endif
688_GL_CXXALIAS_SYS (expl, long double, (long double x)); 690_GL_CXXALIAS_SYS (expl, long double, (long double x));
689# endif 691# endif
@@ -691,7 +693,6 @@ _GL_CXXALIAS_SYS (expl, long double, (long double x));
691_GL_CXXALIASWARN (expl); 693_GL_CXXALIASWARN (expl);
692# endif 694# endif
693#elif defined GNULIB_POSIXCHECK 695#elif defined GNULIB_POSIXCHECK
694# undef expl
695# if HAVE_RAW_DECL_EXPL 696# if HAVE_RAW_DECL_EXPL
696_GL_WARN_ON_USE (expl, "expl is unportable - " 697_GL_WARN_ON_USE (expl, "expl is unportable - "
697 "use gnulib module expl for portability"); 698 "use gnulib module expl for portability");
@@ -700,13 +701,12 @@ _GL_WARN_ON_USE (expl, "expl is unportable - "
700 701
701 702
702#if @GNULIB_EXP2F@ 703#if @GNULIB_EXP2F@
703# if !@HAVE_DECL_EXP2F@ 704# if !@HAVE_EXP2F@
704_GL_FUNCDECL_SYS (exp2f, float, (float x)); 705_GL_FUNCDECL_SYS (exp2f, float, (float x), );
705# endif 706# endif
706_GL_CXXALIAS_SYS (exp2f, float, (float x)); 707_GL_CXXALIAS_SYS (exp2f, float, (float x));
707_GL_CXXALIASWARN (exp2f); 708_GL_CXXALIASWARN (exp2f);
708#elif defined GNULIB_POSIXCHECK 709#elif defined GNULIB_POSIXCHECK
709# undef exp2f
710# if HAVE_RAW_DECL_EXP2F 710# if HAVE_RAW_DECL_EXP2F
711_GL_WARN_ON_USE (exp2f, "exp2f is unportable - " 711_GL_WARN_ON_USE (exp2f, "exp2f is unportable - "
712 "use gnulib module exp2f for portability"); 712 "use gnulib module exp2f for portability");
@@ -719,11 +719,11 @@ _GL_WARN_ON_USE (exp2f, "exp2f is unportable - "
719# undef exp2 719# undef exp2
720# define exp2 rpl_exp2 720# define exp2 rpl_exp2
721# endif 721# endif
722_GL_FUNCDECL_RPL (exp2, double, (double x)); 722_GL_FUNCDECL_RPL (exp2, double, (double x), );
723_GL_CXXALIAS_RPL (exp2, double, (double x)); 723_GL_CXXALIAS_RPL (exp2, double, (double x));
724# else 724# else
725# if !@HAVE_DECL_EXP2@ 725# if !@HAVE_EXP2@
726_GL_FUNCDECL_SYS (exp2, double, (double x)); 726_GL_FUNCDECL_SYS (exp2, double, (double x), );
727# endif 727# endif
728_GL_CXXALIAS_SYS (exp2, double, (double x)); 728_GL_CXXALIAS_SYS (exp2, double, (double x));
729# endif 729# endif
@@ -731,7 +731,6 @@ _GL_CXXALIAS_SYS (exp2, double, (double x));
731_GL_CXXALIASWARN1 (exp2, double, (double x)); 731_GL_CXXALIASWARN1 (exp2, double, (double x));
732# endif 732# endif
733#elif defined GNULIB_POSIXCHECK 733#elif defined GNULIB_POSIXCHECK
734# undef exp2
735# if HAVE_RAW_DECL_EXP2 734# if HAVE_RAW_DECL_EXP2
736_GL_WARN_ON_USE (exp2, "exp2 is unportable - " 735_GL_WARN_ON_USE (exp2, "exp2 is unportable - "
737 "use gnulib module exp2 for portability"); 736 "use gnulib module exp2 for portability");
@@ -744,12 +743,12 @@ _GL_WARN_ON_USE (exp2, "exp2 is unportable - "
744# undef exp2l 743# undef exp2l
745# define exp2l rpl_exp2l 744# define exp2l rpl_exp2l
746# endif 745# endif
747_GL_FUNCDECL_RPL (exp2l, long double, (long double x)); 746_GL_FUNCDECL_RPL (exp2l, long double, (long double x), );
748_GL_CXXALIAS_RPL (exp2l, long double, (long double x)); 747_GL_CXXALIAS_RPL (exp2l, long double, (long double x));
749# else 748# else
750# if !@HAVE_DECL_EXP2L@ 749# if !@HAVE_EXP2L@
751# undef exp2l 750# undef exp2l
752_GL_FUNCDECL_SYS (exp2l, long double, (long double x)); 751_GL_FUNCDECL_SYS (exp2l, long double, (long double x), );
753# endif 752# endif
754_GL_CXXALIAS_SYS (exp2l, long double, (long double x)); 753_GL_CXXALIAS_SYS (exp2l, long double, (long double x));
755# endif 754# endif
@@ -757,7 +756,6 @@ _GL_CXXALIAS_SYS (exp2l, long double, (long double x));
757_GL_CXXALIASWARN (exp2l); 756_GL_CXXALIASWARN (exp2l);
758# endif 757# endif
759#elif defined GNULIB_POSIXCHECK 758#elif defined GNULIB_POSIXCHECK
760# undef exp2l
761# if HAVE_RAW_DECL_EXP2L 759# if HAVE_RAW_DECL_EXP2L
762_GL_WARN_ON_USE (exp2l, "exp2l is unportable - " 760_GL_WARN_ON_USE (exp2l, "exp2l is unportable - "
763 "use gnulib module exp2l for portability"); 761 "use gnulib module exp2l for portability");
@@ -771,17 +769,16 @@ _GL_WARN_ON_USE (exp2l, "exp2l is unportable - "
771# undef expm1f 769# undef expm1f
772# define expm1f rpl_expm1f 770# define expm1f rpl_expm1f
773# endif 771# endif
774_GL_FUNCDECL_RPL (expm1f, float, (float x)); 772_GL_FUNCDECL_RPL (expm1f, float, (float x), );
775_GL_CXXALIAS_RPL (expm1f, float, (float x)); 773_GL_CXXALIAS_RPL (expm1f, float, (float x));
776# else 774# else
777# if !@HAVE_EXPM1F@ 775# if !@HAVE_EXPM1F@
778_GL_FUNCDECL_SYS (expm1f, float, (float x)); 776_GL_FUNCDECL_SYS (expm1f, float, (float x), );
779# endif 777# endif
780_GL_CXXALIAS_SYS (expm1f, float, (float x)); 778_GL_CXXALIAS_SYS (expm1f, float, (float x));
781# endif 779# endif
782_GL_CXXALIASWARN (expm1f); 780_GL_CXXALIASWARN (expm1f);
783#elif defined GNULIB_POSIXCHECK 781#elif defined GNULIB_POSIXCHECK
784# undef expm1f
785# if HAVE_RAW_DECL_EXPM1F 782# if HAVE_RAW_DECL_EXPM1F
786_GL_WARN_ON_USE (expm1f, "expm1f is unportable - " 783_GL_WARN_ON_USE (expm1f, "expm1f is unportable - "
787 "use gnulib module expm1f for portability"); 784 "use gnulib module expm1f for portability");
@@ -794,11 +791,11 @@ _GL_WARN_ON_USE (expm1f, "expm1f is unportable - "
794# undef expm1 791# undef expm1
795# define expm1 rpl_expm1 792# define expm1 rpl_expm1
796# endif 793# endif
797_GL_FUNCDECL_RPL (expm1, double, (double x)); 794_GL_FUNCDECL_RPL (expm1, double, (double x), );
798_GL_CXXALIAS_RPL (expm1, double, (double x)); 795_GL_CXXALIAS_RPL (expm1, double, (double x));
799# else 796# else
800# if !@HAVE_EXPM1@ 797# if !@HAVE_EXPM1@
801_GL_FUNCDECL_SYS (expm1, double, (double x)); 798_GL_FUNCDECL_SYS (expm1, double, (double x), );
802# endif 799# endif
803_GL_CXXALIAS_SYS (expm1, double, (double x)); 800_GL_CXXALIAS_SYS (expm1, double, (double x));
804# endif 801# endif
@@ -806,7 +803,6 @@ _GL_CXXALIAS_SYS (expm1, double, (double x));
806_GL_CXXALIASWARN1 (expm1, double, (double x)); 803_GL_CXXALIASWARN1 (expm1, double, (double x));
807# endif 804# endif
808#elif defined GNULIB_POSIXCHECK 805#elif defined GNULIB_POSIXCHECK
809# undef expm1
810# if HAVE_RAW_DECL_EXPM1 806# if HAVE_RAW_DECL_EXPM1
811_GL_WARN_ON_USE (expm1, "expm1 is unportable - " 807_GL_WARN_ON_USE (expm1, "expm1 is unportable - "
812 "use gnulib module expm1 for portability"); 808 "use gnulib module expm1 for portability");
@@ -819,13 +815,13 @@ _GL_WARN_ON_USE (expm1, "expm1 is unportable - "
819# undef expm1l 815# undef expm1l
820# define expm1l rpl_expm1l 816# define expm1l rpl_expm1l
821# endif 817# endif
822_GL_FUNCDECL_RPL (expm1l, long double, (long double x)); 818_GL_FUNCDECL_RPL (expm1l, long double, (long double x), );
823_GL_CXXALIAS_RPL (expm1l, long double, (long double x)); 819_GL_CXXALIAS_RPL (expm1l, long double, (long double x));
824# else 820# else
825# if !@HAVE_DECL_EXPM1L@ 821# if !@HAVE_EXPM1L@
826# undef expm1l 822# undef expm1l
827# if !(defined __cplusplus && defined _AIX) 823# if !(defined __cplusplus && defined _AIX)
828_GL_FUNCDECL_SYS (expm1l, long double, (long double x)); 824_GL_FUNCDECL_SYS (expm1l, long double, (long double x), );
829# endif 825# endif
830# endif 826# endif
831_GL_CXXALIAS_SYS (expm1l, long double, (long double x)); 827_GL_CXXALIAS_SYS (expm1l, long double, (long double x));
@@ -834,7 +830,6 @@ _GL_CXXALIAS_SYS (expm1l, long double, (long double x));
834_GL_CXXALIASWARN (expm1l); 830_GL_CXXALIASWARN (expm1l);
835# endif 831# endif
836#elif defined GNULIB_POSIXCHECK 832#elif defined GNULIB_POSIXCHECK
837# undef expm1l
838# if HAVE_RAW_DECL_EXPM1L 833# if HAVE_RAW_DECL_EXPM1L
839_GL_WARN_ON_USE (expm1l, "expm1l is unportable - " 834_GL_WARN_ON_USE (expm1l, "expm1l is unportable - "
840 "use gnulib module expm1l for portability"); 835 "use gnulib module expm1l for portability");
@@ -845,14 +840,13 @@ _GL_WARN_ON_USE (expm1l, "expm1l is unportable - "
845#if @GNULIB_FABSF@ 840#if @GNULIB_FABSF@
846# if !@HAVE_FABSF@ 841# if !@HAVE_FABSF@
847# undef fabsf 842# undef fabsf
848_GL_FUNCDECL_SYS (fabsf, float, (float x)); 843_GL_FUNCDECL_SYS (fabsf, float, (float x), );
849# endif 844# endif
850_GL_CXXALIAS_SYS (fabsf, float, (float x)); 845_GL_CXXALIAS_SYS (fabsf, float, (float x));
851# if __GLIBC__ >= 2 846# if __GLIBC__ >= 2
852_GL_CXXALIASWARN (fabsf); 847_GL_CXXALIASWARN (fabsf);
853# endif 848# endif
854#elif defined GNULIB_POSIXCHECK 849#elif defined GNULIB_POSIXCHECK
855# undef fabsf
856# if HAVE_RAW_DECL_FABSF 850# if HAVE_RAW_DECL_FABSF
857_GL_WARN_ON_USE (fabsf, "fabsf is unportable - " 851_GL_WARN_ON_USE (fabsf, "fabsf is unportable - "
858 "use gnulib module fabsf for portability"); 852 "use gnulib module fabsf for portability");
@@ -865,12 +859,12 @@ _GL_WARN_ON_USE (fabsf, "fabsf is unportable - "
865# undef fabsl 859# undef fabsl
866# define fabsl rpl_fabsl 860# define fabsl rpl_fabsl
867# endif 861# endif
868_GL_FUNCDECL_RPL (fabsl, long double, (long double x)); 862_GL_FUNCDECL_RPL (fabsl, long double, (long double x), );
869_GL_CXXALIAS_RPL (fabsl, long double, (long double x)); 863_GL_CXXALIAS_RPL (fabsl, long double, (long double x));
870# else 864# else
871# if !@HAVE_FABSL@ 865# if !@HAVE_FABSL@
872# undef fabsl 866# undef fabsl
873_GL_FUNCDECL_SYS (fabsl, long double, (long double x)); 867_GL_FUNCDECL_SYS (fabsl, long double, (long double x), );
874# endif 868# endif
875_GL_CXXALIAS_SYS (fabsl, long double, (long double x)); 869_GL_CXXALIAS_SYS (fabsl, long double, (long double x));
876# endif 870# endif
@@ -878,7 +872,6 @@ _GL_CXXALIAS_SYS (fabsl, long double, (long double x));
878_GL_CXXALIASWARN (fabsl); 872_GL_CXXALIASWARN (fabsl);
879# endif 873# endif
880#elif defined GNULIB_POSIXCHECK 874#elif defined GNULIB_POSIXCHECK
881# undef fabsl
882# if HAVE_RAW_DECL_FABSL 875# if HAVE_RAW_DECL_FABSL
883_GL_WARN_ON_USE (fabsl, "fabsl is unportable - " 876_GL_WARN_ON_USE (fabsl, "fabsl is unportable - "
884 "use gnulib module fabsl for portability"); 877 "use gnulib module fabsl for portability");
@@ -892,18 +885,17 @@ _GL_WARN_ON_USE (fabsl, "fabsl is unportable - "
892# undef floorf 885# undef floorf
893# define floorf rpl_floorf 886# define floorf rpl_floorf
894# endif 887# endif
895_GL_FUNCDECL_RPL (floorf, float, (float x)); 888_GL_FUNCDECL_RPL (floorf, float, (float x), );
896_GL_CXXALIAS_RPL (floorf, float, (float x)); 889_GL_CXXALIAS_RPL (floorf, float, (float x));
897# else 890# else
898# if !@HAVE_DECL_FLOORF@ 891# if !@HAVE_DECL_FLOORF@
899# undef floorf 892# undef floorf
900_GL_FUNCDECL_SYS (floorf, float, (float x)); 893_GL_FUNCDECL_SYS (floorf, float, (float x), );
901# endif 894# endif
902_GL_CXXALIAS_SYS (floorf, float, (float x)); 895_GL_CXXALIAS_SYS (floorf, float, (float x));
903# endif 896# endif
904_GL_CXXALIASWARN (floorf); 897_GL_CXXALIASWARN (floorf);
905#elif defined GNULIB_POSIXCHECK 898#elif defined GNULIB_POSIXCHECK
906# undef floorf
907# if HAVE_RAW_DECL_FLOORF 899# if HAVE_RAW_DECL_FLOORF
908_GL_WARN_ON_USE (floorf, "floorf is unportable - " 900_GL_WARN_ON_USE (floorf, "floorf is unportable - "
909 "use gnulib module floorf for portability"); 901 "use gnulib module floorf for portability");
@@ -916,7 +908,7 @@ _GL_WARN_ON_USE (floorf, "floorf is unportable - "
916# undef floor 908# undef floor
917# define floor rpl_floor 909# define floor rpl_floor
918# endif 910# endif
919_GL_FUNCDECL_RPL (floor, double, (double x)); 911_GL_FUNCDECL_RPL (floor, double, (double x), );
920_GL_CXXALIAS_RPL (floor, double, (double x)); 912_GL_CXXALIAS_RPL (floor, double, (double x));
921# else 913# else
922_GL_CXXALIAS_SYS (floor, double, (double x)); 914_GL_CXXALIAS_SYS (floor, double, (double x));
@@ -932,12 +924,12 @@ _GL_CXXALIASWARN1 (floor, double, (double x));
932# undef floorl 924# undef floorl
933# define floorl rpl_floorl 925# define floorl rpl_floorl
934# endif 926# endif
935_GL_FUNCDECL_RPL (floorl, long double, (long double x)); 927_GL_FUNCDECL_RPL (floorl, long double, (long double x), );
936_GL_CXXALIAS_RPL (floorl, long double, (long double x)); 928_GL_CXXALIAS_RPL (floorl, long double, (long double x));
937# else 929# else
938# if !@HAVE_DECL_FLOORL@ 930# if !@HAVE_DECL_FLOORL@
939# undef floorl 931# undef floorl
940_GL_FUNCDECL_SYS (floorl, long double, (long double x)); 932_GL_FUNCDECL_SYS (floorl, long double, (long double x), );
941# endif 933# endif
942_GL_CXXALIAS_SYS (floorl, long double, (long double x)); 934_GL_CXXALIAS_SYS (floorl, long double, (long double x));
943# endif 935# endif
@@ -945,7 +937,6 @@ _GL_CXXALIAS_SYS (floorl, long double, (long double x));
945_GL_CXXALIASWARN (floorl); 937_GL_CXXALIASWARN (floorl);
946# endif 938# endif
947#elif defined GNULIB_POSIXCHECK 939#elif defined GNULIB_POSIXCHECK
948# undef floorl
949# if HAVE_RAW_DECL_FLOORL 940# if HAVE_RAW_DECL_FLOORL
950_GL_WARN_ON_USE (floorl, "floorl is unportable - " 941_GL_WARN_ON_USE (floorl, "floorl is unportable - "
951 "use gnulib module floorl for portability"); 942 "use gnulib module floorl for portability");
@@ -959,18 +950,17 @@ _GL_WARN_ON_USE (floorl, "floorl is unportable - "
959# undef fmaf 950# undef fmaf
960# define fmaf rpl_fmaf 951# define fmaf rpl_fmaf
961# endif 952# endif
962_GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z)); 953_GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z), );
963_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); 954_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z));
964# else 955# else
965# if !@HAVE_FMAF@ 956# if !@HAVE_FMAF@
966# undef fmaf 957# undef fmaf
967_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); 958_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z), );
968# endif 959# endif
969_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); 960_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z));
970# endif 961# endif
971_GL_CXXALIASWARN (fmaf); 962_GL_CXXALIASWARN (fmaf);
972#elif defined GNULIB_POSIXCHECK 963#elif defined GNULIB_POSIXCHECK
973# undef fmaf
974# if HAVE_RAW_DECL_FMAF 964# if HAVE_RAW_DECL_FMAF
975_GL_WARN_ON_USE (fmaf, "fmaf is unportable - " 965_GL_WARN_ON_USE (fmaf, "fmaf is unportable - "
976 "use gnulib module fmaf for portability"); 966 "use gnulib module fmaf for portability");
@@ -983,12 +973,12 @@ _GL_WARN_ON_USE (fmaf, "fmaf is unportable - "
983# undef fma 973# undef fma
984# define fma rpl_fma 974# define fma rpl_fma
985# endif 975# endif
986_GL_FUNCDECL_RPL (fma, double, (double x, double y, double z)); 976_GL_FUNCDECL_RPL (fma, double, (double x, double y, double z), );
987_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); 977_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z));
988# else 978# else
989# if !@HAVE_FMA@ 979# if !@HAVE_FMA@
990# undef fma 980# undef fma
991_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); 981_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z), );
992# endif 982# endif
993_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); 983_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z));
994# endif 984# endif
@@ -996,7 +986,6 @@ _GL_CXXALIAS_SYS (fma, double, (double x, double y, double z));
996_GL_CXXALIASWARN1 (fma, double, (double x, double y, double z)); 986_GL_CXXALIASWARN1 (fma, double, (double x, double y, double z));
997# endif 987# endif
998#elif defined GNULIB_POSIXCHECK 988#elif defined GNULIB_POSIXCHECK
999# undef fma
1000# if HAVE_RAW_DECL_FMA 989# if HAVE_RAW_DECL_FMA
1001_GL_WARN_ON_USE (fma, "fma is unportable - " 990_GL_WARN_ON_USE (fma, "fma is unportable - "
1002 "use gnulib module fma for portability"); 991 "use gnulib module fma for portability");
@@ -1010,7 +999,7 @@ _GL_WARN_ON_USE (fma, "fma is unportable - "
1010# define fmal rpl_fmal 999# define fmal rpl_fmal
1011# endif 1000# endif
1012_GL_FUNCDECL_RPL (fmal, long double, 1001_GL_FUNCDECL_RPL (fmal, long double,
1013 (long double x, long double y, long double z)); 1002 (long double x, long double y, long double z), );
1014_GL_CXXALIAS_RPL (fmal, long double, 1003_GL_CXXALIAS_RPL (fmal, long double,
1015 (long double x, long double y, long double z)); 1004 (long double x, long double y, long double z));
1016# else 1005# else
@@ -1018,7 +1007,7 @@ _GL_CXXALIAS_RPL (fmal, long double,
1018# undef fmal 1007# undef fmal
1019# if !(defined __cplusplus && defined _AIX) 1008# if !(defined __cplusplus && defined _AIX)
1020_GL_FUNCDECL_SYS (fmal, long double, 1009_GL_FUNCDECL_SYS (fmal, long double,
1021 (long double x, long double y, long double z)); 1010 (long double x, long double y, long double z), );
1022# endif 1011# endif
1023# endif 1012# endif
1024_GL_CXXALIAS_SYS (fmal, long double, 1013_GL_CXXALIAS_SYS (fmal, long double,
@@ -1028,7 +1017,6 @@ _GL_CXXALIAS_SYS (fmal, long double,
1028_GL_CXXALIASWARN (fmal); 1017_GL_CXXALIASWARN (fmal);
1029# endif 1018# endif
1030#elif defined GNULIB_POSIXCHECK 1019#elif defined GNULIB_POSIXCHECK
1031# undef fmal
1032# if HAVE_RAW_DECL_FMAL 1020# if HAVE_RAW_DECL_FMAL
1033_GL_WARN_ON_USE (fmal, "fmal is unportable - " 1021_GL_WARN_ON_USE (fmal, "fmal is unportable - "
1034 "use gnulib module fmal for portability"); 1022 "use gnulib module fmal for portability");
@@ -1042,18 +1030,17 @@ _GL_WARN_ON_USE (fmal, "fmal is unportable - "
1042# undef fmodf 1030# undef fmodf
1043# define fmodf rpl_fmodf 1031# define fmodf rpl_fmodf
1044# endif 1032# endif
1045_GL_FUNCDECL_RPL (fmodf, float, (float x, float y)); 1033_GL_FUNCDECL_RPL (fmodf, float, (float x, float y), );
1046_GL_CXXALIAS_RPL (fmodf, float, (float x, float y)); 1034_GL_CXXALIAS_RPL (fmodf, float, (float x, float y));
1047# else 1035# else
1048# if !@HAVE_FMODF@ 1036# if !@HAVE_FMODF@
1049# undef fmodf 1037# undef fmodf
1050_GL_FUNCDECL_SYS (fmodf, float, (float x, float y)); 1038_GL_FUNCDECL_SYS (fmodf, float, (float x, float y), );
1051# endif 1039# endif
1052_GL_CXXALIAS_SYS (fmodf, float, (float x, float y)); 1040_GL_CXXALIAS_SYS (fmodf, float, (float x, float y));
1053# endif 1041# endif
1054_GL_CXXALIASWARN (fmodf); 1042_GL_CXXALIASWARN (fmodf);
1055#elif defined GNULIB_POSIXCHECK 1043#elif defined GNULIB_POSIXCHECK
1056# undef fmodf
1057# if HAVE_RAW_DECL_FMODF 1044# if HAVE_RAW_DECL_FMODF
1058_GL_WARN_ON_USE (fmodf, "fmodf is unportable - " 1045_GL_WARN_ON_USE (fmodf, "fmodf is unportable - "
1059 "use gnulib module fmodf for portability"); 1046 "use gnulib module fmodf for portability");
@@ -1066,7 +1053,7 @@ _GL_WARN_ON_USE (fmodf, "fmodf is unportable - "
1066# undef fmod 1053# undef fmod
1067# define fmod rpl_fmod 1054# define fmod rpl_fmod
1068# endif 1055# endif
1069_GL_FUNCDECL_RPL (fmod, double, (double x, double y)); 1056_GL_FUNCDECL_RPL (fmod, double, (double x, double y), );
1070_GL_CXXALIAS_RPL (fmod, double, (double x, double y)); 1057_GL_CXXALIAS_RPL (fmod, double, (double x, double y));
1071# else 1058# else
1072_GL_CXXALIAS_SYS (fmod, double, (double x, double y)); 1059_GL_CXXALIAS_SYS (fmod, double, (double x, double y));
@@ -1075,7 +1062,6 @@ _GL_CXXALIAS_SYS (fmod, double, (double x, double y));
1075_GL_CXXALIASWARN1 (fmod, double, (double x, double y)); 1062_GL_CXXALIASWARN1 (fmod, double, (double x, double y));
1076# endif 1063# endif
1077#elif defined GNULIB_POSIXCHECK 1064#elif defined GNULIB_POSIXCHECK
1078# undef fmod
1079# if HAVE_RAW_DECL_FMOD 1065# if HAVE_RAW_DECL_FMOD
1080_GL_WARN_ON_USE (fmod, "fmod has portability problems - " 1066_GL_WARN_ON_USE (fmod, "fmod has portability problems - "
1081 "use gnulib module fmod for portability"); 1067 "use gnulib module fmod for portability");
@@ -1088,12 +1074,12 @@ _GL_WARN_ON_USE (fmod, "fmod has portability problems - "
1088# undef fmodl 1074# undef fmodl
1089# define fmodl rpl_fmodl 1075# define fmodl rpl_fmodl
1090# endif 1076# endif
1091_GL_FUNCDECL_RPL (fmodl, long double, (long double x, long double y)); 1077_GL_FUNCDECL_RPL (fmodl, long double, (long double x, long double y), );
1092_GL_CXXALIAS_RPL (fmodl, long double, (long double x, long double y)); 1078_GL_CXXALIAS_RPL (fmodl, long double, (long double x, long double y));
1093# else 1079# else
1094# if !@HAVE_FMODL@ 1080# if !@HAVE_FMODL@
1095# undef fmodl 1081# undef fmodl
1096_GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y)); 1082_GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y), );
1097# endif 1083# endif
1098_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y)); 1084_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y));
1099# endif 1085# endif
@@ -1101,7 +1087,6 @@ _GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y));
1101_GL_CXXALIASWARN (fmodl); 1087_GL_CXXALIASWARN (fmodl);
1102# endif 1088# endif
1103#elif defined GNULIB_POSIXCHECK 1089#elif defined GNULIB_POSIXCHECK
1104# undef fmodl
1105# if HAVE_RAW_DECL_FMODL 1090# if HAVE_RAW_DECL_FMODL
1106_GL_WARN_ON_USE (fmodl, "fmodl is unportable - " 1091_GL_WARN_ON_USE (fmodl, "fmodl is unportable - "
1107 "use gnulib module fmodl for portability"); 1092 "use gnulib module fmodl for portability");
@@ -1122,12 +1107,12 @@ _GL_WARN_ON_USE (fmodl, "fmodl is unportable - "
1122# undef frexpf 1107# undef frexpf
1123# define frexpf rpl_frexpf 1108# define frexpf rpl_frexpf
1124# endif 1109# endif
1125_GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); 1110_GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr), _GL_ARG_NONNULL ((2)));
1126_GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr)); 1111_GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr));
1127# else 1112# else
1128# if !@HAVE_FREXPF@ 1113# if !@HAVE_FREXPF@
1129# undef frexpf 1114# undef frexpf
1130_GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2))); 1115_GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr), _GL_ARG_NONNULL ((2)));
1131# endif 1116# endif
1132_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr)); 1117_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
1133# endif 1118# endif
@@ -1135,7 +1120,6 @@ _GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
1135_GL_CXXALIASWARN (frexpf); 1120_GL_CXXALIASWARN (frexpf);
1136# endif 1121# endif
1137#elif defined GNULIB_POSIXCHECK 1122#elif defined GNULIB_POSIXCHECK
1138# undef frexpf
1139# if HAVE_RAW_DECL_FREXPF 1123# if HAVE_RAW_DECL_FREXPF
1140_GL_WARN_ON_USE (frexpf, "frexpf is unportable - " 1124_GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
1141 "use gnulib module frexpf for portability"); 1125 "use gnulib module frexpf for portability");
@@ -1155,7 +1139,8 @@ _GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
1155# undef frexp 1139# undef frexp
1156# define frexp rpl_frexp 1140# define frexp rpl_frexp
1157# endif 1141# endif
1158_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2))); 1142_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr),
1143 _GL_ARG_NONNULL ((2)));
1159_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr)); 1144_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
1160# else 1145# else
1161_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); 1146_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
@@ -1166,8 +1151,10 @@ _GL_CXXALIASWARN1 (frexp, double, (double x, int *expptr));
1166#elif defined GNULIB_POSIXCHECK 1151#elif defined GNULIB_POSIXCHECK
1167# undef frexp 1152# undef frexp
1168/* Assume frexp is always declared. */ 1153/* Assume frexp is always declared. */
1169_GL_WARN_ON_USE (frexp, "frexp is unportable - " 1154_GL_WARN_ON_USE_CXX (frexp,
1170 "use gnulib module frexp for portability"); 1155 double, double, (double, int *),
1156 "frexp is unportable - "
1157 "use gnulib module frexp for portability");
1171#endif 1158#endif
1172 1159
1173/* Write x as 1160/* Write x as
@@ -1183,12 +1170,12 @@ _GL_WARN_ON_USE (frexp, "frexp is unportable - "
1183# define frexpl rpl_frexpl 1170# define frexpl rpl_frexpl
1184# endif 1171# endif
1185_GL_FUNCDECL_RPL (frexpl, long double, 1172_GL_FUNCDECL_RPL (frexpl, long double,
1186 (long double x, int *expptr) _GL_ARG_NONNULL ((2))); 1173 (long double x, int *expptr), _GL_ARG_NONNULL ((2)));
1187_GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr)); 1174_GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr));
1188#else 1175#else
1189# if !@HAVE_DECL_FREXPL@ 1176# if !@HAVE_DECL_FREXPL@
1190_GL_FUNCDECL_SYS (frexpl, long double, 1177_GL_FUNCDECL_SYS (frexpl, long double,
1191 (long double x, int *expptr) _GL_ARG_NONNULL ((2))); 1178 (long double x, int *expptr), _GL_ARG_NONNULL ((2)));
1192# endif 1179# endif
1193# if @GNULIB_FREXPL@ 1180# if @GNULIB_FREXPL@
1194_GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr)); 1181_GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr));
@@ -1200,7 +1187,6 @@ _GL_CXXALIASWARN (frexpl);
1200# endif 1187# endif
1201#endif 1188#endif
1202#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK 1189#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
1203# undef frexpl
1204# if HAVE_RAW_DECL_FREXPL 1190# if HAVE_RAW_DECL_FREXPL
1205_GL_WARN_ON_USE (frexpl, "frexpl is unportable - " 1191_GL_WARN_ON_USE (frexpl, "frexpl is unportable - "
1206 "use gnulib module frexpl for portability"); 1192 "use gnulib module frexpl for portability");
@@ -1215,11 +1201,11 @@ _GL_WARN_ON_USE (frexpl, "frexpl is unportable - "
1215# undef hypotf 1201# undef hypotf
1216# define hypotf rpl_hypotf 1202# define hypotf rpl_hypotf
1217# endif 1203# endif
1218_GL_FUNCDECL_RPL (hypotf, float, (float x, float y)); 1204_GL_FUNCDECL_RPL (hypotf, float, (float x, float y), );
1219_GL_CXXALIAS_RPL (hypotf, float, (float x, float y)); 1205_GL_CXXALIAS_RPL (hypotf, float, (float x, float y));
1220# else 1206# else
1221# if !@HAVE_HYPOTF@ 1207# if !@HAVE_HYPOTF@
1222_GL_FUNCDECL_SYS (hypotf, float, (float x, float y)); 1208_GL_FUNCDECL_SYS (hypotf, float, (float x, float y), );
1223# endif 1209# endif
1224_GL_CXXALIAS_SYS (hypotf, float, (float x, float y)); 1210_GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
1225# endif 1211# endif
@@ -1227,7 +1213,6 @@ _GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
1227_GL_CXXALIASWARN (hypotf); 1213_GL_CXXALIASWARN (hypotf);
1228# endif 1214# endif
1229#elif defined GNULIB_POSIXCHECK 1215#elif defined GNULIB_POSIXCHECK
1230# undef hypotf
1231# if HAVE_RAW_DECL_HYPOTF 1216# if HAVE_RAW_DECL_HYPOTF
1232_GL_WARN_ON_USE (hypotf, "hypotf is unportable - " 1217_GL_WARN_ON_USE (hypotf, "hypotf is unportable - "
1233 "use gnulib module hypotf for portability"); 1218 "use gnulib module hypotf for portability");
@@ -1241,7 +1226,7 @@ _GL_WARN_ON_USE (hypotf, "hypotf is unportable - "
1241# undef hypot 1226# undef hypot
1242# define hypot rpl_hypot 1227# define hypot rpl_hypot
1243# endif 1228# endif
1244_GL_FUNCDECL_RPL (hypot, double, (double x, double y)); 1229_GL_FUNCDECL_RPL (hypot, double, (double x, double y), );
1245_GL_CXXALIAS_RPL (hypot, double, (double x, double y)); 1230_GL_CXXALIAS_RPL (hypot, double, (double x, double y));
1246# else 1231# else
1247_GL_CXXALIAS_SYS (hypot, double, (double x, double y)); 1232_GL_CXXALIAS_SYS (hypot, double, (double x, double y));
@@ -1250,7 +1235,6 @@ _GL_CXXALIAS_SYS (hypot, double, (double x, double y));
1250_GL_CXXALIASWARN1 (hypot, double, (double x, double y)); 1235_GL_CXXALIASWARN1 (hypot, double, (double x, double y));
1251# endif 1236# endif
1252#elif defined GNULIB_POSIXCHECK 1237#elif defined GNULIB_POSIXCHECK
1253# undef hypot
1254# if HAVE_RAW_DECL_HYPOT 1238# if HAVE_RAW_DECL_HYPOT
1255_GL_WARN_ON_USE (hypotf, "hypot has portability problems - " 1239_GL_WARN_ON_USE (hypotf, "hypot has portability problems - "
1256 "use gnulib module hypot for portability"); 1240 "use gnulib module hypot for portability");
@@ -1264,11 +1248,11 @@ _GL_WARN_ON_USE (hypotf, "hypot has portability problems - "
1264# undef hypotl 1248# undef hypotl
1265# define hypotl rpl_hypotl 1249# define hypotl rpl_hypotl
1266# endif 1250# endif
1267_GL_FUNCDECL_RPL (hypotl, long double, (long double x, long double y)); 1251_GL_FUNCDECL_RPL (hypotl, long double, (long double x, long double y), );
1268_GL_CXXALIAS_RPL (hypotl, long double, (long double x, long double y)); 1252_GL_CXXALIAS_RPL (hypotl, long double, (long double x, long double y));
1269# else 1253# else
1270# if !@HAVE_HYPOTL@ 1254# if !@HAVE_HYPOTL@
1271_GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y)); 1255_GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y), );
1272# endif 1256# endif
1273_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y)); 1257_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y));
1274# endif 1258# endif
@@ -1276,7 +1260,6 @@ _GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y));
1276_GL_CXXALIASWARN (hypotl); 1260_GL_CXXALIASWARN (hypotl);
1277# endif 1261# endif
1278#elif defined GNULIB_POSIXCHECK 1262#elif defined GNULIB_POSIXCHECK
1279# undef hypotl
1280# if HAVE_RAW_DECL_HYPOTL 1263# if HAVE_RAW_DECL_HYPOTL
1281_GL_WARN_ON_USE (hypotl, "hypotl is unportable - " 1264_GL_WARN_ON_USE (hypotl, "hypotl is unportable - "
1282 "use gnulib module hypotl for portability"); 1265 "use gnulib module hypotl for portability");
@@ -1290,17 +1273,16 @@ _GL_WARN_ON_USE (hypotl, "hypotl is unportable - "
1290# undef ilogbf 1273# undef ilogbf
1291# define ilogbf rpl_ilogbf 1274# define ilogbf rpl_ilogbf
1292# endif 1275# endif
1293_GL_FUNCDECL_RPL (ilogbf, int, (float x)); 1276_GL_FUNCDECL_RPL (ilogbf, int, (float x), );
1294_GL_CXXALIAS_RPL (ilogbf, int, (float x)); 1277_GL_CXXALIAS_RPL (ilogbf, int, (float x));
1295# else 1278# else
1296# if !@HAVE_ILOGBF@ 1279# if !@HAVE_ILOGBF@
1297_GL_FUNCDECL_SYS (ilogbf, int, (float x)); 1280_GL_FUNCDECL_SYS (ilogbf, int, (float x), );
1298# endif 1281# endif
1299_GL_CXXALIAS_SYS (ilogbf, int, (float x)); 1282_GL_CXXALIAS_SYS (ilogbf, int, (float x));
1300# endif 1283# endif
1301_GL_CXXALIASWARN (ilogbf); 1284_GL_CXXALIASWARN (ilogbf);
1302#elif defined GNULIB_POSIXCHECK 1285#elif defined GNULIB_POSIXCHECK
1303# undef ilogbf
1304# if HAVE_RAW_DECL_ILOGBF 1286# if HAVE_RAW_DECL_ILOGBF
1305_GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - " 1287_GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - "
1306 "use gnulib module ilogbf for portability"); 1288 "use gnulib module ilogbf for portability");
@@ -1313,11 +1295,11 @@ _GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - "
1313# undef ilogb 1295# undef ilogb
1314# define ilogb rpl_ilogb 1296# define ilogb rpl_ilogb
1315# endif 1297# endif
1316_GL_FUNCDECL_RPL (ilogb, int, (double x)); 1298_GL_FUNCDECL_RPL (ilogb, int, (double x), );
1317_GL_CXXALIAS_RPL (ilogb, int, (double x)); 1299_GL_CXXALIAS_RPL (ilogb, int, (double x));
1318# else 1300# else
1319# if !@HAVE_ILOGB@ 1301# if !@HAVE_ILOGB@
1320_GL_FUNCDECL_SYS (ilogb, int, (double x)); 1302_GL_FUNCDECL_SYS (ilogb, int, (double x), );
1321# endif 1303# endif
1322_GL_CXXALIAS_SYS (ilogb, int, (double x)); 1304_GL_CXXALIAS_SYS (ilogb, int, (double x));
1323# endif 1305# endif
@@ -1325,7 +1307,6 @@ _GL_CXXALIAS_SYS (ilogb, int, (double x));
1325_GL_CXXALIASWARN1 (ilogb, int, (double x)); 1307_GL_CXXALIASWARN1 (ilogb, int, (double x));
1326# endif 1308# endif
1327#elif defined GNULIB_POSIXCHECK 1309#elif defined GNULIB_POSIXCHECK
1328# undef ilogb
1329# if HAVE_RAW_DECL_ILOGB 1310# if HAVE_RAW_DECL_ILOGB
1330_GL_WARN_ON_USE (ilogb, "ilogb is unportable - " 1311_GL_WARN_ON_USE (ilogb, "ilogb is unportable - "
1331 "use gnulib module ilogb for portability"); 1312 "use gnulib module ilogb for portability");
@@ -1338,12 +1319,12 @@ _GL_WARN_ON_USE (ilogb, "ilogb is unportable - "
1338# undef ilogbl 1319# undef ilogbl
1339# define ilogbl rpl_ilogbl 1320# define ilogbl rpl_ilogbl
1340# endif 1321# endif
1341_GL_FUNCDECL_RPL (ilogbl, int, (long double x)); 1322_GL_FUNCDECL_RPL (ilogbl, int, (long double x), );
1342_GL_CXXALIAS_RPL (ilogbl, int, (long double x)); 1323_GL_CXXALIAS_RPL (ilogbl, int, (long double x));
1343# else 1324# else
1344# if !@HAVE_ILOGBL@ 1325# if !@HAVE_ILOGBL@
1345# undef ilogbl 1326# undef ilogbl
1346_GL_FUNCDECL_SYS (ilogbl, int, (long double x)); 1327_GL_FUNCDECL_SYS (ilogbl, int, (long double x), );
1347# endif 1328# endif
1348_GL_CXXALIAS_SYS (ilogbl, int, (long double x)); 1329_GL_CXXALIAS_SYS (ilogbl, int, (long double x));
1349# endif 1330# endif
@@ -1351,7 +1332,6 @@ _GL_CXXALIAS_SYS (ilogbl, int, (long double x));
1351_GL_CXXALIASWARN (ilogbl); 1332_GL_CXXALIASWARN (ilogbl);
1352# endif 1333# endif
1353#elif defined GNULIB_POSIXCHECK 1334#elif defined GNULIB_POSIXCHECK
1354# undef ilogbl
1355# if HAVE_RAW_DECL_ILOGBL 1335# if HAVE_RAW_DECL_ILOGBL
1356_GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - " 1336_GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
1357 "use gnulib module ilogbl for portability"); 1337 "use gnulib module ilogbl for portability");
@@ -1412,14 +1392,13 @@ _GL_CXXALIASWARN (jn);
1412#if @GNULIB_LDEXPF@ 1392#if @GNULIB_LDEXPF@
1413# if !@HAVE_LDEXPF@ 1393# if !@HAVE_LDEXPF@
1414# undef ldexpf 1394# undef ldexpf
1415_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp)); 1395_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp), );
1416# endif 1396# endif
1417_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp)); 1397_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp));
1418# if __GLIBC__ >= 2 1398# if __GLIBC__ >= 2
1419_GL_CXXALIASWARN (ldexpf); 1399_GL_CXXALIASWARN (ldexpf);
1420# endif 1400# endif
1421#elif defined GNULIB_POSIXCHECK 1401#elif defined GNULIB_POSIXCHECK
1422# undef ldexpf
1423# if HAVE_RAW_DECL_LDEXPF 1402# if HAVE_RAW_DECL_LDEXPF
1424_GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - " 1403_GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - "
1425 "use gnulib module ldexpf for portability"); 1404 "use gnulib module ldexpf for portability");
@@ -1427,16 +1406,41 @@ _GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - "
1427#endif 1406#endif
1428 1407
1429/* Return x * 2^exp. */ 1408/* Return x * 2^exp. */
1409#if @GNULIB_LDEXP@
1410# if @REPLACE_LDEXP@
1411# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1412# undef ldexp
1413# define ldexp rpl_ldexp
1414# endif
1415_GL_FUNCDECL_RPL (ldexp, double, (double x, int exp), );
1416_GL_CXXALIAS_RPL (ldexp, double, (double x, int exp));
1417# else
1418/* Assume ldexp is always declared. */
1419_GL_CXXALIAS_SYS (ldexp, double, (double x, int exp));
1420# endif
1421# if __GLIBC__ >= 2
1422_GL_CXXALIASWARN1 (ldexp, double, (double x, int exp));
1423# endif
1424#elif defined GNULIB_POSIXCHECK
1425# undef ldexp
1426/* Assume ldexp is always declared. */
1427_GL_WARN_ON_USE_CXX (ldexp,
1428 double, double, (double, int),
1429 "ldexp is unportable - "
1430 "use gnulib module ldexp for portability");
1431#endif
1432
1433/* Return x * 2^exp. */
1430#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ 1434#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
1431# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1435# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1432# undef ldexpl 1436# undef ldexpl
1433# define ldexpl rpl_ldexpl 1437# define ldexpl rpl_ldexpl
1434# endif 1438# endif
1435_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp)); 1439_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp), );
1436_GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp)); 1440_GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp));
1437#else 1441#else
1438# if !@HAVE_DECL_LDEXPL@ 1442# if !@HAVE_DECL_LDEXPL@
1439_GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp)); 1443_GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp), );
1440# endif 1444# endif
1441# if @GNULIB_LDEXPL@ 1445# if @GNULIB_LDEXPL@
1442_GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp)); 1446_GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp));
@@ -1448,7 +1452,6 @@ _GL_CXXALIASWARN (ldexpl);
1448# endif 1452# endif
1449#endif 1453#endif
1450#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK 1454#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
1451# undef ldexpl
1452# if HAVE_RAW_DECL_LDEXPL 1455# if HAVE_RAW_DECL_LDEXPL
1453_GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - " 1456_GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - "
1454 "use gnulib module ldexpl for portability"); 1457 "use gnulib module ldexpl for portability");
@@ -1462,18 +1465,17 @@ _GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - "
1462# undef logf 1465# undef logf
1463# define logf rpl_logf 1466# define logf rpl_logf
1464# endif 1467# endif
1465_GL_FUNCDECL_RPL (logf, float, (float x)); 1468_GL_FUNCDECL_RPL (logf, float, (float x), );
1466_GL_CXXALIAS_RPL (logf, float, (float x)); 1469_GL_CXXALIAS_RPL (logf, float, (float x));
1467# else 1470# else
1468# if !@HAVE_LOGF@ 1471# if !@HAVE_LOGF@
1469# undef logf 1472# undef logf
1470_GL_FUNCDECL_SYS (logf, float, (float x)); 1473_GL_FUNCDECL_SYS (logf, float, (float x), );
1471# endif 1474# endif
1472_GL_CXXALIAS_SYS (logf, float, (float x)); 1475_GL_CXXALIAS_SYS (logf, float, (float x));
1473# endif 1476# endif
1474_GL_CXXALIASWARN (logf); 1477_GL_CXXALIASWARN (logf);
1475#elif defined GNULIB_POSIXCHECK 1478#elif defined GNULIB_POSIXCHECK
1476# undef logf
1477# if HAVE_RAW_DECL_LOGF 1479# if HAVE_RAW_DECL_LOGF
1478_GL_WARN_ON_USE (logf, "logf is unportable - " 1480_GL_WARN_ON_USE (logf, "logf is unportable - "
1479 "use gnulib module logf for portability"); 1481 "use gnulib module logf for portability");
@@ -1486,7 +1488,7 @@ _GL_WARN_ON_USE (logf, "logf is unportable - "
1486# undef log 1488# undef log
1487# define log rpl_log 1489# define log rpl_log
1488# endif 1490# endif
1489_GL_FUNCDECL_RPL (log, double, (double x)); 1491_GL_FUNCDECL_RPL (log, double, (double x), );
1490_GL_CXXALIAS_RPL (log, double, (double x)); 1492_GL_CXXALIAS_RPL (log, double, (double x));
1491# else 1493# else
1492_GL_CXXALIAS_SYS (log, double, (double x)); 1494_GL_CXXALIAS_SYS (log, double, (double x));
@@ -1495,7 +1497,6 @@ _GL_CXXALIAS_SYS (log, double, (double x));
1495_GL_CXXALIASWARN1 (log, double, (double x)); 1497_GL_CXXALIASWARN1 (log, double, (double x));
1496# endif 1498# endif
1497#elif defined GNULIB_POSIXCHECK 1499#elif defined GNULIB_POSIXCHECK
1498# undef log
1499# if HAVE_RAW_DECL_LOG 1500# if HAVE_RAW_DECL_LOG
1500_GL_WARN_ON_USE (log, "log has portability problems - " 1501_GL_WARN_ON_USE (log, "log has portability problems - "
1501 "use gnulib module log for portability"); 1502 "use gnulib module log for portability");
@@ -1508,12 +1509,12 @@ _GL_WARN_ON_USE (log, "log has portability problems - "
1508# undef logl 1509# undef logl
1509# define logl rpl_logl 1510# define logl rpl_logl
1510# endif 1511# endif
1511_GL_FUNCDECL_RPL (logl, long double, (long double x)); 1512_GL_FUNCDECL_RPL (logl, long double, (long double x), );
1512_GL_CXXALIAS_RPL (logl, long double, (long double x)); 1513_GL_CXXALIAS_RPL (logl, long double, (long double x));
1513# else 1514# else
1514# if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@ 1515# if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@
1515# undef logl 1516# undef logl
1516_GL_FUNCDECL_SYS (logl, long double, (long double x)); 1517_GL_FUNCDECL_SYS (logl, long double, (long double x), );
1517# endif 1518# endif
1518_GL_CXXALIAS_SYS (logl, long double, (long double x)); 1519_GL_CXXALIAS_SYS (logl, long double, (long double x));
1519# endif 1520# endif
@@ -1521,7 +1522,6 @@ _GL_CXXALIAS_SYS (logl, long double, (long double x));
1521_GL_CXXALIASWARN (logl); 1522_GL_CXXALIASWARN (logl);
1522# endif 1523# endif
1523#elif defined GNULIB_POSIXCHECK 1524#elif defined GNULIB_POSIXCHECK
1524# undef logl
1525# if HAVE_RAW_DECL_LOGL 1525# if HAVE_RAW_DECL_LOGL
1526_GL_WARN_ON_USE (logl, "logl is unportable - " 1526_GL_WARN_ON_USE (logl, "logl is unportable - "
1527 "use gnulib module logl for portability"); 1527 "use gnulib module logl for portability");
@@ -1535,18 +1535,17 @@ _GL_WARN_ON_USE (logl, "logl is unportable - "
1535# undef log10f 1535# undef log10f
1536# define log10f rpl_log10f 1536# define log10f rpl_log10f
1537# endif 1537# endif
1538_GL_FUNCDECL_RPL (log10f, float, (float x)); 1538_GL_FUNCDECL_RPL (log10f, float, (float x), );
1539_GL_CXXALIAS_RPL (log10f, float, (float x)); 1539_GL_CXXALIAS_RPL (log10f, float, (float x));
1540# else 1540# else
1541# if !@HAVE_LOG10F@ 1541# if !@HAVE_LOG10F@
1542# undef log10f 1542# undef log10f
1543_GL_FUNCDECL_SYS (log10f, float, (float x)); 1543_GL_FUNCDECL_SYS (log10f, float, (float x), );
1544# endif 1544# endif
1545_GL_CXXALIAS_SYS (log10f, float, (float x)); 1545_GL_CXXALIAS_SYS (log10f, float, (float x));
1546# endif 1546# endif
1547_GL_CXXALIASWARN (log10f); 1547_GL_CXXALIASWARN (log10f);
1548#elif defined GNULIB_POSIXCHECK 1548#elif defined GNULIB_POSIXCHECK
1549# undef log10f
1550# if HAVE_RAW_DECL_LOG10F 1549# if HAVE_RAW_DECL_LOG10F
1551_GL_WARN_ON_USE (log10f, "log10f is unportable - " 1550_GL_WARN_ON_USE (log10f, "log10f is unportable - "
1552 "use gnulib module log10f for portability"); 1551 "use gnulib module log10f for portability");
@@ -1559,7 +1558,7 @@ _GL_WARN_ON_USE (log10f, "log10f is unportable - "
1559# undef log10 1558# undef log10
1560# define log10 rpl_log10 1559# define log10 rpl_log10
1561# endif 1560# endif
1562_GL_FUNCDECL_RPL (log10, double, (double x)); 1561_GL_FUNCDECL_RPL (log10, double, (double x), );
1563_GL_CXXALIAS_RPL (log10, double, (double x)); 1562_GL_CXXALIAS_RPL (log10, double, (double x));
1564# else 1563# else
1565_GL_CXXALIAS_SYS (log10, double, (double x)); 1564_GL_CXXALIAS_SYS (log10, double, (double x));
@@ -1568,7 +1567,6 @@ _GL_CXXALIAS_SYS (log10, double, (double x));
1568_GL_CXXALIASWARN1 (log10, double, (double x)); 1567_GL_CXXALIASWARN1 (log10, double, (double x));
1569# endif 1568# endif
1570#elif defined GNULIB_POSIXCHECK 1569#elif defined GNULIB_POSIXCHECK
1571# undef log10
1572# if HAVE_RAW_DECL_LOG10 1570# if HAVE_RAW_DECL_LOG10
1573_GL_WARN_ON_USE (log10, "log10 has portability problems - " 1571_GL_WARN_ON_USE (log10, "log10 has portability problems - "
1574 "use gnulib module log10 for portability"); 1572 "use gnulib module log10 for portability");
@@ -1581,12 +1579,12 @@ _GL_WARN_ON_USE (log10, "log10 has portability problems - "
1581# undef log10l 1579# undef log10l
1582# define log10l rpl_log10l 1580# define log10l rpl_log10l
1583# endif 1581# endif
1584_GL_FUNCDECL_RPL (log10l, long double, (long double x)); 1582_GL_FUNCDECL_RPL (log10l, long double, (long double x), );
1585_GL_CXXALIAS_RPL (log10l, long double, (long double x)); 1583_GL_CXXALIAS_RPL (log10l, long double, (long double x));
1586# else 1584# else
1587# if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@ 1585# if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@
1588# undef log10l 1586# undef log10l
1589_GL_FUNCDECL_SYS (log10l, long double, (long double x)); 1587_GL_FUNCDECL_SYS (log10l, long double, (long double x), );
1590# endif 1588# endif
1591_GL_CXXALIAS_SYS (log10l, long double, (long double x)); 1589_GL_CXXALIAS_SYS (log10l, long double, (long double x));
1592# endif 1590# endif
@@ -1594,7 +1592,6 @@ _GL_CXXALIAS_SYS (log10l, long double, (long double x));
1594_GL_CXXALIASWARN (log10l); 1592_GL_CXXALIASWARN (log10l);
1595# endif 1593# endif
1596#elif defined GNULIB_POSIXCHECK 1594#elif defined GNULIB_POSIXCHECK
1597# undef log10l
1598# if HAVE_RAW_DECL_LOG10L 1595# if HAVE_RAW_DECL_LOG10L
1599_GL_WARN_ON_USE (log10l, "log10l is unportable - " 1596_GL_WARN_ON_USE (log10l, "log10l is unportable - "
1600 "use gnulib module log10l for portability"); 1597 "use gnulib module log10l for portability");
@@ -1608,17 +1605,16 @@ _GL_WARN_ON_USE (log10l, "log10l is unportable - "
1608# undef log1pf 1605# undef log1pf
1609# define log1pf rpl_log1pf 1606# define log1pf rpl_log1pf
1610# endif 1607# endif
1611_GL_FUNCDECL_RPL (log1pf, float, (float x)); 1608_GL_FUNCDECL_RPL (log1pf, float, (float x), );
1612_GL_CXXALIAS_RPL (log1pf, float, (float x)); 1609_GL_CXXALIAS_RPL (log1pf, float, (float x));
1613# else 1610# else
1614# if !@HAVE_LOG1PF@ 1611# if !@HAVE_LOG1PF@
1615_GL_FUNCDECL_SYS (log1pf, float, (float x)); 1612_GL_FUNCDECL_SYS (log1pf, float, (float x), );
1616# endif 1613# endif
1617_GL_CXXALIAS_SYS (log1pf, float, (float x)); 1614_GL_CXXALIAS_SYS (log1pf, float, (float x));
1618# endif 1615# endif
1619_GL_CXXALIASWARN (log1pf); 1616_GL_CXXALIASWARN (log1pf);
1620#elif defined GNULIB_POSIXCHECK 1617#elif defined GNULIB_POSIXCHECK
1621# undef log1pf
1622# if HAVE_RAW_DECL_LOG1PF 1618# if HAVE_RAW_DECL_LOG1PF
1623_GL_WARN_ON_USE (log1pf, "log1pf is unportable - " 1619_GL_WARN_ON_USE (log1pf, "log1pf is unportable - "
1624 "use gnulib module log1pf for portability"); 1620 "use gnulib module log1pf for portability");
@@ -1631,11 +1627,11 @@ _GL_WARN_ON_USE (log1pf, "log1pf is unportable - "
1631# undef log1p 1627# undef log1p
1632# define log1p rpl_log1p 1628# define log1p rpl_log1p
1633# endif 1629# endif
1634_GL_FUNCDECL_RPL (log1p, double, (double x)); 1630_GL_FUNCDECL_RPL (log1p, double, (double x), );
1635_GL_CXXALIAS_RPL (log1p, double, (double x)); 1631_GL_CXXALIAS_RPL (log1p, double, (double x));
1636# else 1632# else
1637# if !@HAVE_LOG1P@ 1633# if !@HAVE_LOG1P@
1638_GL_FUNCDECL_SYS (log1p, double, (double x)); 1634_GL_FUNCDECL_SYS (log1p, double, (double x), );
1639# endif 1635# endif
1640_GL_CXXALIAS_SYS (log1p, double, (double x)); 1636_GL_CXXALIAS_SYS (log1p, double, (double x));
1641# endif 1637# endif
@@ -1643,7 +1639,6 @@ _GL_CXXALIAS_SYS (log1p, double, (double x));
1643_GL_CXXALIASWARN1 (log1p, double, (double x)); 1639_GL_CXXALIASWARN1 (log1p, double, (double x));
1644# endif 1640# endif
1645#elif defined GNULIB_POSIXCHECK 1641#elif defined GNULIB_POSIXCHECK
1646# undef log1p
1647# if HAVE_RAW_DECL_LOG1P 1642# if HAVE_RAW_DECL_LOG1P
1648_GL_WARN_ON_USE (log1p, "log1p has portability problems - " 1643_GL_WARN_ON_USE (log1p, "log1p has portability problems - "
1649 "use gnulib module log1p for portability"); 1644 "use gnulib module log1p for portability");
@@ -1656,11 +1651,11 @@ _GL_WARN_ON_USE (log1p, "log1p has portability problems - "
1656# undef log1pl 1651# undef log1pl
1657# define log1pl rpl_log1pl 1652# define log1pl rpl_log1pl
1658# endif 1653# endif
1659_GL_FUNCDECL_RPL (log1pl, long double, (long double x)); 1654_GL_FUNCDECL_RPL (log1pl, long double, (long double x), );
1660_GL_CXXALIAS_RPL (log1pl, long double, (long double x)); 1655_GL_CXXALIAS_RPL (log1pl, long double, (long double x));
1661# else 1656# else
1662# if !@HAVE_LOG1PL@ 1657# if !@HAVE_LOG1PL@
1663_GL_FUNCDECL_SYS (log1pl, long double, (long double x)); 1658_GL_FUNCDECL_SYS (log1pl, long double, (long double x), );
1664# endif 1659# endif
1665_GL_CXXALIAS_SYS (log1pl, long double, (long double x)); 1660_GL_CXXALIAS_SYS (log1pl, long double, (long double x));
1666# endif 1661# endif
@@ -1668,7 +1663,6 @@ _GL_CXXALIAS_SYS (log1pl, long double, (long double x));
1668_GL_CXXALIASWARN (log1pl); 1663_GL_CXXALIASWARN (log1pl);
1669# endif 1664# endif
1670#elif defined GNULIB_POSIXCHECK 1665#elif defined GNULIB_POSIXCHECK
1671# undef log1pl
1672# if HAVE_RAW_DECL_LOG1PL 1666# if HAVE_RAW_DECL_LOG1PL
1673_GL_WARN_ON_USE (log1pl, "log1pl has portability problems - " 1667_GL_WARN_ON_USE (log1pl, "log1pl has portability problems - "
1674 "use gnulib module log1pl for portability"); 1668 "use gnulib module log1pl for portability");
@@ -1682,18 +1676,19 @@ _GL_WARN_ON_USE (log1pl, "log1pl has portability problems - "
1682# undef log2f 1676# undef log2f
1683# define log2f rpl_log2f 1677# define log2f rpl_log2f
1684# endif 1678# endif
1685_GL_FUNCDECL_RPL (log2f, float, (float x)); 1679_GL_FUNCDECL_RPL (log2f, float, (float x), );
1686_GL_CXXALIAS_RPL (log2f, float, (float x)); 1680_GL_CXXALIAS_RPL (log2f, float, (float x));
1687# else 1681# else
1688# if !@HAVE_DECL_LOG2F@ 1682# if !@HAVE_LOG2F@
1689# undef log2f 1683# undef log2f
1690_GL_FUNCDECL_SYS (log2f, float, (float x)); 1684_GL_FUNCDECL_SYS (log2f, float, (float x), );
1691# endif 1685# endif
1692_GL_CXXALIAS_SYS (log2f, float, (float x)); 1686_GL_CXXALIAS_SYS (log2f, float, (float x));
1693# endif 1687# endif
1688# if __GLIBC__ >= 2
1694_GL_CXXALIASWARN (log2f); 1689_GL_CXXALIASWARN (log2f);
1690# endif
1695#elif defined GNULIB_POSIXCHECK 1691#elif defined GNULIB_POSIXCHECK
1696# undef log2f
1697# if HAVE_RAW_DECL_LOG2F 1692# if HAVE_RAW_DECL_LOG2F
1698_GL_WARN_ON_USE (log2f, "log2f is unportable - " 1693_GL_WARN_ON_USE (log2f, "log2f is unportable - "
1699 "use gnulib module log2f for portability"); 1694 "use gnulib module log2f for portability");
@@ -1706,12 +1701,12 @@ _GL_WARN_ON_USE (log2f, "log2f is unportable - "
1706# undef log2 1701# undef log2
1707# define log2 rpl_log2 1702# define log2 rpl_log2
1708# endif 1703# endif
1709_GL_FUNCDECL_RPL (log2, double, (double x)); 1704_GL_FUNCDECL_RPL (log2, double, (double x), );
1710_GL_CXXALIAS_RPL (log2, double, (double x)); 1705_GL_CXXALIAS_RPL (log2, double, (double x));
1711# else 1706# else
1712# if !@HAVE_DECL_LOG2@ 1707# if !@HAVE_LOG2@
1713# undef log2 1708# undef log2
1714_GL_FUNCDECL_SYS (log2, double, (double x)); 1709_GL_FUNCDECL_SYS (log2, double, (double x), );
1715# endif 1710# endif
1716_GL_CXXALIAS_SYS (log2, double, (double x)); 1711_GL_CXXALIAS_SYS (log2, double, (double x));
1717# endif 1712# endif
@@ -1719,7 +1714,6 @@ _GL_CXXALIAS_SYS (log2, double, (double x));
1719_GL_CXXALIASWARN1 (log2, double, (double x)); 1714_GL_CXXALIASWARN1 (log2, double, (double x));
1720# endif 1715# endif
1721#elif defined GNULIB_POSIXCHECK 1716#elif defined GNULIB_POSIXCHECK
1722# undef log2
1723# if HAVE_RAW_DECL_LOG2 1717# if HAVE_RAW_DECL_LOG2
1724_GL_WARN_ON_USE (log2, "log2 is unportable - " 1718_GL_WARN_ON_USE (log2, "log2 is unportable - "
1725 "use gnulib module log2 for portability"); 1719 "use gnulib module log2 for portability");
@@ -1732,11 +1726,11 @@ _GL_WARN_ON_USE (log2, "log2 is unportable - "
1732# undef log2l 1726# undef log2l
1733# define log2l rpl_log2l 1727# define log2l rpl_log2l
1734# endif 1728# endif
1735_GL_FUNCDECL_RPL (log2l, long double, (long double x)); 1729_GL_FUNCDECL_RPL (log2l, long double, (long double x), );
1736_GL_CXXALIAS_RPL (log2l, long double, (long double x)); 1730_GL_CXXALIAS_RPL (log2l, long double, (long double x));
1737# else 1731# else
1738# if !@HAVE_DECL_LOG2L@ 1732# if !@HAVE_LOG2L@
1739_GL_FUNCDECL_SYS (log2l, long double, (long double x)); 1733_GL_FUNCDECL_SYS (log2l, long double, (long double x), );
1740# endif 1734# endif
1741_GL_CXXALIAS_SYS (log2l, long double, (long double x)); 1735_GL_CXXALIAS_SYS (log2l, long double, (long double x));
1742# endif 1736# endif
@@ -1744,7 +1738,6 @@ _GL_CXXALIAS_SYS (log2l, long double, (long double x));
1744_GL_CXXALIASWARN (log2l); 1738_GL_CXXALIASWARN (log2l);
1745# endif 1739# endif
1746#elif defined GNULIB_POSIXCHECK 1740#elif defined GNULIB_POSIXCHECK
1747# undef log2l
1748# if HAVE_RAW_DECL_LOG2L 1741# if HAVE_RAW_DECL_LOG2L
1749_GL_WARN_ON_USE (log2l, "log2l is unportable - " 1742_GL_WARN_ON_USE (log2l, "log2l is unportable - "
1750 "use gnulib module log2l for portability"); 1743 "use gnulib module log2l for portability");
@@ -1758,17 +1751,16 @@ _GL_WARN_ON_USE (log2l, "log2l is unportable - "
1758# undef logbf 1751# undef logbf
1759# define logbf rpl_logbf 1752# define logbf rpl_logbf
1760# endif 1753# endif
1761_GL_FUNCDECL_RPL (logbf, float, (float x)); 1754_GL_FUNCDECL_RPL (logbf, float, (float x), );
1762_GL_CXXALIAS_RPL (logbf, float, (float x)); 1755_GL_CXXALIAS_RPL (logbf, float, (float x));
1763# else 1756# else
1764# if !@HAVE_LOGBF@ 1757# if !@HAVE_LOGBF@
1765_GL_FUNCDECL_SYS (logbf, float, (float x)); 1758_GL_FUNCDECL_SYS (logbf, float, (float x), );
1766# endif 1759# endif
1767_GL_CXXALIAS_SYS (logbf, float, (float x)); 1760_GL_CXXALIAS_SYS (logbf, float, (float x));
1768# endif 1761# endif
1769_GL_CXXALIASWARN (logbf); 1762_GL_CXXALIASWARN (logbf);
1770#elif defined GNULIB_POSIXCHECK 1763#elif defined GNULIB_POSIXCHECK
1771# undef logbf
1772# if HAVE_RAW_DECL_LOGBF 1764# if HAVE_RAW_DECL_LOGBF
1773_GL_WARN_ON_USE (logbf, "logbf is unportable - " 1765_GL_WARN_ON_USE (logbf, "logbf is unportable - "
1774 "use gnulib module logbf for portability"); 1766 "use gnulib module logbf for portability");
@@ -1781,11 +1773,11 @@ _GL_WARN_ON_USE (logbf, "logbf is unportable - "
1781# undef logb 1773# undef logb
1782# define logb rpl_logb 1774# define logb rpl_logb
1783# endif 1775# endif
1784_GL_FUNCDECL_RPL (logb, double, (double x)); 1776_GL_FUNCDECL_RPL (logb, double, (double x), );
1785_GL_CXXALIAS_RPL (logb, double, (double x)); 1777_GL_CXXALIAS_RPL (logb, double, (double x));
1786# else 1778# else
1787# if !@HAVE_DECL_LOGB@ 1779# if !@HAVE_DECL_LOGB@
1788_GL_FUNCDECL_SYS (logb, double, (double x)); 1780_GL_FUNCDECL_SYS (logb, double, (double x), );
1789# endif 1781# endif
1790_GL_CXXALIAS_SYS (logb, double, (double x)); 1782_GL_CXXALIAS_SYS (logb, double, (double x));
1791# endif 1783# endif
@@ -1793,7 +1785,6 @@ _GL_CXXALIAS_SYS (logb, double, (double x));
1793_GL_CXXALIASWARN1 (logb, double, (double x)); 1785_GL_CXXALIASWARN1 (logb, double, (double x));
1794# endif 1786# endif
1795#elif defined GNULIB_POSIXCHECK 1787#elif defined GNULIB_POSIXCHECK
1796# undef logb
1797# if HAVE_RAW_DECL_LOGB 1788# if HAVE_RAW_DECL_LOGB
1798_GL_WARN_ON_USE (logb, "logb is unportable - " 1789_GL_WARN_ON_USE (logb, "logb is unportable - "
1799 "use gnulib module logb for portability"); 1790 "use gnulib module logb for portability");
@@ -1806,11 +1797,11 @@ _GL_WARN_ON_USE (logb, "logb is unportable - "
1806# undef logbl 1797# undef logbl
1807# define logbl rpl_logbl 1798# define logbl rpl_logbl
1808# endif 1799# endif
1809_GL_FUNCDECL_RPL (logbl, long double, (long double x)); 1800_GL_FUNCDECL_RPL (logbl, long double, (long double x), );
1810_GL_CXXALIAS_RPL (logbl, long double, (long double x)); 1801_GL_CXXALIAS_RPL (logbl, long double, (long double x));
1811# else 1802# else
1812# if !@HAVE_LOGBL@ 1803# if !@HAVE_LOGBL@
1813_GL_FUNCDECL_SYS (logbl, long double, (long double x)); 1804_GL_FUNCDECL_SYS (logbl, long double, (long double x), );
1814# endif 1805# endif
1815_GL_CXXALIAS_SYS (logbl, long double, (long double x)); 1806_GL_CXXALIAS_SYS (logbl, long double, (long double x));
1816# endif 1807# endif
@@ -1818,7 +1809,6 @@ _GL_CXXALIAS_SYS (logbl, long double, (long double x));
1818_GL_CXXALIASWARN (logbl); 1809_GL_CXXALIASWARN (logbl);
1819# endif 1810# endif
1820#elif defined GNULIB_POSIXCHECK 1811#elif defined GNULIB_POSIXCHECK
1821# undef logbl
1822# if HAVE_RAW_DECL_LOGBL 1812# if HAVE_RAW_DECL_LOGBL
1823_GL_WARN_ON_USE (logbl, "logbl is unportable - " 1813_GL_WARN_ON_USE (logbl, "logbl is unportable - "
1824 "use gnulib module logbl for portability"); 1814 "use gnulib module logbl for portability");
@@ -1826,24 +1816,69 @@ _GL_WARN_ON_USE (logbl, "logbl is unportable - "
1826#endif 1816#endif
1827 1817
1828 1818
1819#if @GNULIB_LOGP1F@
1820# if !@HAVE_LOGP1F@
1821_GL_FUNCDECL_SYS (logp1f, float, (float x), );
1822# endif
1823_GL_CXXALIAS_SYS (logp1f, float, (float x));
1824# if __GLIBC__ >= 2
1825_GL_CXXALIASWARN1 (logp1f, float, (float x));
1826# endif
1827#elif defined GNULIB_POSIXCHECK
1828# if HAVE_RAW_DECL_LOGP1F
1829_GL_WARN_ON_USE (logp1f, "logp1f is unportable - "
1830 "use gnulib module logp1f for portability");
1831# endif
1832#endif
1833
1834#if @GNULIB_LOGP1@
1835# if !@HAVE_LOGP1@
1836_GL_FUNCDECL_SYS (logp1, double, (double x), );
1837# endif
1838_GL_CXXALIAS_SYS (logp1, double, (double x));
1839# if __GLIBC__ >= 2
1840_GL_CXXALIASWARN1 (logp1, double, (double x));
1841# endif
1842#elif defined GNULIB_POSIXCHECK
1843# if HAVE_RAW_DECL_LOGP1
1844_GL_WARN_ON_USE (logp1, "logp1 is unportable - "
1845 "use gnulib module logp1 for portability");
1846# endif
1847#endif
1848
1849#if @GNULIB_LOGP1L@
1850# if !@HAVE_LOGP1L@
1851_GL_FUNCDECL_SYS (logp1l, long double, (long double x), );
1852# endif
1853_GL_CXXALIAS_SYS (logp1l, long double, (long double x));
1854# if __GLIBC__ >= 2
1855_GL_CXXALIASWARN1 (logp1l, long double, (long double x));
1856# endif
1857#elif defined GNULIB_POSIXCHECK
1858# if HAVE_RAW_DECL_LOGP1L
1859_GL_WARN_ON_USE (logp1l, "logp1l is unportable - "
1860 "use gnulib module logp1l for portability");
1861# endif
1862#endif
1863
1864
1829#if @GNULIB_MODFF@ 1865#if @GNULIB_MODFF@
1830# if @REPLACE_MODFF@ 1866# if @REPLACE_MODFF@
1831# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1867# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1832# undef modff 1868# undef modff
1833# define modff rpl_modff 1869# define modff rpl_modff
1834# endif 1870# endif
1835_GL_FUNCDECL_RPL (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); 1871_GL_FUNCDECL_RPL (modff, float, (float x, float *iptr), _GL_ARG_NONNULL ((2)));
1836_GL_CXXALIAS_RPL (modff, float, (float x, float *iptr)); 1872_GL_CXXALIAS_RPL (modff, float, (float x, float *iptr));
1837# else 1873# else
1838# if !@HAVE_MODFF@ 1874# if !@HAVE_MODFF@
1839# undef modff 1875# undef modff
1840_GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2))); 1876_GL_FUNCDECL_SYS (modff, float, (float x, float *iptr), _GL_ARG_NONNULL ((2)));
1841# endif 1877# endif
1842_GL_CXXALIAS_SYS (modff, float, (float x, float *iptr)); 1878_GL_CXXALIAS_SYS (modff, float, (float x, float *iptr));
1843# endif 1879# endif
1844_GL_CXXALIASWARN (modff); 1880_GL_CXXALIASWARN (modff);
1845#elif defined GNULIB_POSIXCHECK 1881#elif defined GNULIB_POSIXCHECK
1846# undef modff
1847# if HAVE_RAW_DECL_MODFF 1882# if HAVE_RAW_DECL_MODFF
1848_GL_WARN_ON_USE (modff, "modff is unportable - " 1883_GL_WARN_ON_USE (modff, "modff is unportable - "
1849 "use gnulib module modff for portability"); 1884 "use gnulib module modff for portability");
@@ -1856,7 +1891,8 @@ _GL_WARN_ON_USE (modff, "modff is unportable - "
1856# undef modf 1891# undef modf
1857# define modf rpl_modf 1892# define modf rpl_modf
1858# endif 1893# endif
1859_GL_FUNCDECL_RPL (modf, double, (double x, double *iptr) _GL_ARG_NONNULL ((2))); 1894_GL_FUNCDECL_RPL (modf, double, (double x, double *iptr),
1895 _GL_ARG_NONNULL ((2)));
1860_GL_CXXALIAS_RPL (modf, double, (double x, double *iptr)); 1896_GL_CXXALIAS_RPL (modf, double, (double x, double *iptr));
1861# else 1897# else
1862_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr)); 1898_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr));
@@ -1865,7 +1901,6 @@ _GL_CXXALIAS_SYS (modf, double, (double x, double *iptr));
1865_GL_CXXALIASWARN1 (modf, double, (double x, double *iptr)); 1901_GL_CXXALIASWARN1 (modf, double, (double x, double *iptr));
1866# endif 1902# endif
1867#elif defined GNULIB_POSIXCHECK 1903#elif defined GNULIB_POSIXCHECK
1868# undef modf
1869# if HAVE_RAW_DECL_MODF 1904# if HAVE_RAW_DECL_MODF
1870_GL_WARN_ON_USE (modf, "modf has portability problems - " 1905_GL_WARN_ON_USE (modf, "modf has portability problems - "
1871 "use gnulib module modf for portability"); 1906 "use gnulib module modf for portability");
@@ -1878,13 +1913,13 @@ _GL_WARN_ON_USE (modf, "modf has portability problems - "
1878# undef modfl 1913# undef modfl
1879# define modfl rpl_modfl 1914# define modfl rpl_modfl
1880# endif 1915# endif
1881_GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr) 1916_GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr),
1882 _GL_ARG_NONNULL ((2))); 1917 _GL_ARG_NONNULL ((2)));
1883_GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr)); 1918_GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr));
1884# else 1919# else
1885# if !@HAVE_MODFL@ 1920# if !@HAVE_MODFL@
1886# undef modfl 1921# undef modfl
1887_GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr) 1922_GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr),
1888 _GL_ARG_NONNULL ((2))); 1923 _GL_ARG_NONNULL ((2)));
1889# endif 1924# endif
1890_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); 1925_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
@@ -1893,7 +1928,6 @@ _GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
1893_GL_CXXALIASWARN (modfl); 1928_GL_CXXALIASWARN (modfl);
1894# endif 1929# endif
1895#elif defined GNULIB_POSIXCHECK 1930#elif defined GNULIB_POSIXCHECK
1896# undef modfl
1897# if HAVE_RAW_DECL_MODFL 1931# if HAVE_RAW_DECL_MODFL
1898_GL_WARN_ON_USE (modfl, "modfl is unportable - " 1932_GL_WARN_ON_USE (modfl, "modfl is unportable - "
1899 "use gnulib module modfl for portability"); 1933 "use gnulib module modfl for portability");
@@ -1904,12 +1938,11 @@ _GL_WARN_ON_USE (modfl, "modfl is unportable - "
1904#if @GNULIB_POWF@ 1938#if @GNULIB_POWF@
1905# if !@HAVE_POWF@ 1939# if !@HAVE_POWF@
1906# undef powf 1940# undef powf
1907_GL_FUNCDECL_SYS (powf, float, (float x, float y)); 1941_GL_FUNCDECL_SYS (powf, float, (float x, float y), );
1908# endif 1942# endif
1909_GL_CXXALIAS_SYS (powf, float, (float x, float y)); 1943_GL_CXXALIAS_SYS (powf, float, (float x, float y));
1910_GL_CXXALIASWARN (powf); 1944_GL_CXXALIASWARN (powf);
1911#elif defined GNULIB_POSIXCHECK 1945#elif defined GNULIB_POSIXCHECK
1912# undef powf
1913# if HAVE_RAW_DECL_POWF 1946# if HAVE_RAW_DECL_POWF
1914_GL_WARN_ON_USE (powf, "powf is unportable - " 1947_GL_WARN_ON_USE (powf, "powf is unportable - "
1915 "use gnulib module powf for portability"); 1948 "use gnulib module powf for portability");
@@ -1923,17 +1956,16 @@ _GL_WARN_ON_USE (powf, "powf is unportable - "
1923# undef remainderf 1956# undef remainderf
1924# define remainderf rpl_remainderf 1957# define remainderf rpl_remainderf
1925# endif 1958# endif
1926_GL_FUNCDECL_RPL (remainderf, float, (float x, float y)); 1959_GL_FUNCDECL_RPL (remainderf, float, (float x, float y), );
1927_GL_CXXALIAS_RPL (remainderf, float, (float x, float y)); 1960_GL_CXXALIAS_RPL (remainderf, float, (float x, float y));
1928# else 1961# else
1929# if !@HAVE_REMAINDERF@ 1962# if !@HAVE_REMAINDERF@
1930_GL_FUNCDECL_SYS (remainderf, float, (float x, float y)); 1963_GL_FUNCDECL_SYS (remainderf, float, (float x, float y), );
1931# endif 1964# endif
1932_GL_CXXALIAS_SYS (remainderf, float, (float x, float y)); 1965_GL_CXXALIAS_SYS (remainderf, float, (float x, float y));
1933# endif 1966# endif
1934_GL_CXXALIASWARN (remainderf); 1967_GL_CXXALIASWARN (remainderf);
1935#elif defined GNULIB_POSIXCHECK 1968#elif defined GNULIB_POSIXCHECK
1936# undef remainderf
1937# if HAVE_RAW_DECL_REMAINDERF 1969# if HAVE_RAW_DECL_REMAINDERF
1938_GL_WARN_ON_USE (remainderf, "remainderf is unportable - " 1970_GL_WARN_ON_USE (remainderf, "remainderf is unportable - "
1939 "use gnulib module remainderf for portability"); 1971 "use gnulib module remainderf for portability");
@@ -1946,11 +1978,11 @@ _GL_WARN_ON_USE (remainderf, "remainderf is unportable - "
1946# undef remainder 1978# undef remainder
1947# define remainder rpl_remainder 1979# define remainder rpl_remainder
1948# endif 1980# endif
1949_GL_FUNCDECL_RPL (remainder, double, (double x, double y)); 1981_GL_FUNCDECL_RPL (remainder, double, (double x, double y), );
1950_GL_CXXALIAS_RPL (remainder, double, (double x, double y)); 1982_GL_CXXALIAS_RPL (remainder, double, (double x, double y));
1951# else 1983# else
1952# if !@HAVE_REMAINDER@ || !@HAVE_DECL_REMAINDER@ 1984# if !@HAVE_REMAINDER@
1953_GL_FUNCDECL_SYS (remainder, double, (double x, double y)); 1985_GL_FUNCDECL_SYS (remainder, double, (double x, double y), );
1954# endif 1986# endif
1955_GL_CXXALIAS_SYS (remainder, double, (double x, double y)); 1987_GL_CXXALIAS_SYS (remainder, double, (double x, double y));
1956# endif 1988# endif
@@ -1958,7 +1990,6 @@ _GL_CXXALIAS_SYS (remainder, double, (double x, double y));
1958_GL_CXXALIASWARN1 (remainder, double, (double x, double y)); 1990_GL_CXXALIASWARN1 (remainder, double, (double x, double y));
1959# endif 1991# endif
1960#elif defined GNULIB_POSIXCHECK 1992#elif defined GNULIB_POSIXCHECK
1961# undef remainder
1962# if HAVE_RAW_DECL_REMAINDER 1993# if HAVE_RAW_DECL_REMAINDER
1963_GL_WARN_ON_USE (remainder, "remainder is unportable - " 1994_GL_WARN_ON_USE (remainder, "remainder is unportable - "
1964 "use gnulib module remainder for portability"); 1995 "use gnulib module remainder for portability");
@@ -1971,13 +2002,13 @@ _GL_WARN_ON_USE (remainder, "remainder is unportable - "
1971# undef remainderl 2002# undef remainderl
1972# define remainderl rpl_remainderl 2003# define remainderl rpl_remainderl
1973# endif 2004# endif
1974_GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y)); 2005_GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y), );
1975_GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y)); 2006_GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y));
1976# else 2007# else
1977# if !@HAVE_DECL_REMAINDERL@ 2008# if !@HAVE_REMAINDERL@
1978# undef remainderl 2009# undef remainderl
1979# if !(defined __cplusplus && defined _AIX) 2010# if !(defined __cplusplus && defined _AIX)
1980_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); 2011_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y), );
1981# endif 2012# endif
1982# endif 2013# endif
1983_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); 2014_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
@@ -1986,7 +2017,6 @@ _GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
1986_GL_CXXALIASWARN (remainderl); 2017_GL_CXXALIASWARN (remainderl);
1987# endif 2018# endif
1988#elif defined GNULIB_POSIXCHECK 2019#elif defined GNULIB_POSIXCHECK
1989# undef remainderl
1990# if HAVE_RAW_DECL_REMAINDERL 2020# if HAVE_RAW_DECL_REMAINDERL
1991_GL_WARN_ON_USE (remainderl, "remainderl is unportable - " 2021_GL_WARN_ON_USE (remainderl, "remainderl is unportable - "
1992 "use gnulib module remainderl for portability"); 2022 "use gnulib module remainderl for portability");
@@ -1995,13 +2025,12 @@ _GL_WARN_ON_USE (remainderl, "remainderl is unportable - "
1995 2025
1996 2026
1997#if @GNULIB_RINTF@ 2027#if @GNULIB_RINTF@
1998# if !@HAVE_DECL_RINTF@ 2028# if !@HAVE_RINTF@
1999_GL_FUNCDECL_SYS (rintf, float, (float x)); 2029_GL_FUNCDECL_SYS (rintf, float, (float x), );
2000# endif 2030# endif
2001_GL_CXXALIAS_SYS (rintf, float, (float x)); 2031_GL_CXXALIAS_SYS (rintf, float, (float x));
2002_GL_CXXALIASWARN (rintf); 2032_GL_CXXALIASWARN (rintf);
2003#elif defined GNULIB_POSIXCHECK 2033#elif defined GNULIB_POSIXCHECK
2004# undef rintf
2005# if HAVE_RAW_DECL_RINTF 2034# if HAVE_RAW_DECL_RINTF
2006_GL_WARN_ON_USE (rintf, "rintf is unportable - " 2035_GL_WARN_ON_USE (rintf, "rintf is unportable - "
2007 "use gnulib module rintf for portability"); 2036 "use gnulib module rintf for portability");
@@ -2010,14 +2039,13 @@ _GL_WARN_ON_USE (rintf, "rintf is unportable - "
2010 2039
2011#if @GNULIB_RINT@ 2040#if @GNULIB_RINT@
2012# if !@HAVE_RINT@ 2041# if !@HAVE_RINT@
2013_GL_FUNCDECL_SYS (rint, double, (double x)); 2042_GL_FUNCDECL_SYS (rint, double, (double x), );
2014# endif 2043# endif
2015_GL_CXXALIAS_SYS (rint, double, (double x)); 2044_GL_CXXALIAS_SYS (rint, double, (double x));
2016# if __GLIBC__ >= 2 2045# if __GLIBC__ >= 2
2017_GL_CXXALIASWARN1 (rint, double, (double x)); 2046_GL_CXXALIASWARN1 (rint, double, (double x));
2018# endif 2047# endif
2019#elif defined GNULIB_POSIXCHECK 2048#elif defined GNULIB_POSIXCHECK
2020# undef rint
2021# if HAVE_RAW_DECL_RINT 2049# if HAVE_RAW_DECL_RINT
2022_GL_WARN_ON_USE (rint, "rint is unportable - " 2050_GL_WARN_ON_USE (rint, "rint is unportable - "
2023 "use gnulib module rint for portability"); 2051 "use gnulib module rint for portability");
@@ -2030,11 +2058,11 @@ _GL_WARN_ON_USE (rint, "rint is unportable - "
2030# undef rintl 2058# undef rintl
2031# define rintl rpl_rintl 2059# define rintl rpl_rintl
2032# endif 2060# endif
2033_GL_FUNCDECL_RPL (rintl, long double, (long double x)); 2061_GL_FUNCDECL_RPL (rintl, long double, (long double x), );
2034_GL_CXXALIAS_RPL (rintl, long double, (long double x)); 2062_GL_CXXALIAS_RPL (rintl, long double, (long double x));
2035# else 2063# else
2036# if !@HAVE_RINTL@ 2064# if !@HAVE_RINTL@
2037_GL_FUNCDECL_SYS (rintl, long double, (long double x)); 2065_GL_FUNCDECL_SYS (rintl, long double, (long double x), );
2038# endif 2066# endif
2039_GL_CXXALIAS_SYS (rintl, long double, (long double x)); 2067_GL_CXXALIAS_SYS (rintl, long double, (long double x));
2040# endif 2068# endif
@@ -2042,7 +2070,6 @@ _GL_CXXALIAS_SYS (rintl, long double, (long double x));
2042_GL_CXXALIASWARN (rintl); 2070_GL_CXXALIASWARN (rintl);
2043# endif 2071# endif
2044#elif defined GNULIB_POSIXCHECK 2072#elif defined GNULIB_POSIXCHECK
2045# undef rintl
2046# if HAVE_RAW_DECL_RINTL 2073# if HAVE_RAW_DECL_RINTL
2047_GL_WARN_ON_USE (rintl, "rintl is unportable - " 2074_GL_WARN_ON_USE (rintl, "rintl is unportable - "
2048 "use gnulib module rintl for portability"); 2075 "use gnulib module rintl for portability");
@@ -2056,17 +2083,16 @@ _GL_WARN_ON_USE (rintl, "rintl is unportable - "
2056# undef roundf 2083# undef roundf
2057# define roundf rpl_roundf 2084# define roundf rpl_roundf
2058# endif 2085# endif
2059_GL_FUNCDECL_RPL (roundf, float, (float x)); 2086_GL_FUNCDECL_RPL (roundf, float, (float x), );
2060_GL_CXXALIAS_RPL (roundf, float, (float x)); 2087_GL_CXXALIAS_RPL (roundf, float, (float x));
2061# else 2088# else
2062# if !@HAVE_DECL_ROUNDF@ 2089# if !@HAVE_ROUNDF@
2063_GL_FUNCDECL_SYS (roundf, float, (float x)); 2090_GL_FUNCDECL_SYS (roundf, float, (float x), );
2064# endif 2091# endif
2065_GL_CXXALIAS_SYS (roundf, float, (float x)); 2092_GL_CXXALIAS_SYS (roundf, float, (float x));
2066# endif 2093# endif
2067_GL_CXXALIASWARN (roundf); 2094_GL_CXXALIASWARN (roundf);
2068#elif defined GNULIB_POSIXCHECK 2095#elif defined GNULIB_POSIXCHECK
2069# undef roundf
2070# if HAVE_RAW_DECL_ROUNDF 2096# if HAVE_RAW_DECL_ROUNDF
2071_GL_WARN_ON_USE (roundf, "roundf is unportable - " 2097_GL_WARN_ON_USE (roundf, "roundf is unportable - "
2072 "use gnulib module roundf for portability"); 2098 "use gnulib module roundf for portability");
@@ -2079,11 +2105,11 @@ _GL_WARN_ON_USE (roundf, "roundf is unportable - "
2079# undef round 2105# undef round
2080# define round rpl_round 2106# define round rpl_round
2081# endif 2107# endif
2082_GL_FUNCDECL_RPL (round, double, (double x)); 2108_GL_FUNCDECL_RPL (round, double, (double x), );
2083_GL_CXXALIAS_RPL (round, double, (double x)); 2109_GL_CXXALIAS_RPL (round, double, (double x));
2084# else 2110# else
2085# if !@HAVE_DECL_ROUND@ 2111# if !@HAVE_ROUND@
2086_GL_FUNCDECL_SYS (round, double, (double x)); 2112_GL_FUNCDECL_SYS (round, double, (double x), );
2087# endif 2113# endif
2088_GL_CXXALIAS_SYS (round, double, (double x)); 2114_GL_CXXALIAS_SYS (round, double, (double x));
2089# endif 2115# endif
@@ -2091,7 +2117,6 @@ _GL_CXXALIAS_SYS (round, double, (double x));
2091_GL_CXXALIASWARN1 (round, double, (double x)); 2117_GL_CXXALIASWARN1 (round, double, (double x));
2092# endif 2118# endif
2093#elif defined GNULIB_POSIXCHECK 2119#elif defined GNULIB_POSIXCHECK
2094# undef round
2095# if HAVE_RAW_DECL_ROUND 2120# if HAVE_RAW_DECL_ROUND
2096_GL_WARN_ON_USE (round, "round is unportable - " 2121_GL_WARN_ON_USE (round, "round is unportable - "
2097 "use gnulib module round for portability"); 2122 "use gnulib module round for portability");
@@ -2104,13 +2129,13 @@ _GL_WARN_ON_USE (round, "round is unportable - "
2104# undef roundl 2129# undef roundl
2105# define roundl rpl_roundl 2130# define roundl rpl_roundl
2106# endif 2131# endif
2107_GL_FUNCDECL_RPL (roundl, long double, (long double x)); 2132_GL_FUNCDECL_RPL (roundl, long double, (long double x), );
2108_GL_CXXALIAS_RPL (roundl, long double, (long double x)); 2133_GL_CXXALIAS_RPL (roundl, long double, (long double x));
2109# else 2134# else
2110# if !@HAVE_DECL_ROUNDL@ 2135# if !@HAVE_ROUNDL@
2111# undef roundl 2136# undef roundl
2112# if !(defined __cplusplus && defined _AIX) 2137# if !(defined __cplusplus && defined _AIX)
2113_GL_FUNCDECL_SYS (roundl, long double, (long double x)); 2138_GL_FUNCDECL_SYS (roundl, long double, (long double x), );
2114# endif 2139# endif
2115# endif 2140# endif
2116_GL_CXXALIAS_SYS (roundl, long double, (long double x)); 2141_GL_CXXALIAS_SYS (roundl, long double, (long double x));
@@ -2119,7 +2144,6 @@ _GL_CXXALIAS_SYS (roundl, long double, (long double x));
2119_GL_CXXALIASWARN (roundl); 2144_GL_CXXALIASWARN (roundl);
2120# endif 2145# endif
2121#elif defined GNULIB_POSIXCHECK 2146#elif defined GNULIB_POSIXCHECK
2122# undef roundl
2123# if HAVE_RAW_DECL_ROUNDL 2147# if HAVE_RAW_DECL_ROUNDL
2124_GL_WARN_ON_USE (roundl, "roundl is unportable - " 2148_GL_WARN_ON_USE (roundl, "roundl is unportable - "
2125 "use gnulib module roundl for portability"); 2149 "use gnulib module roundl for portability");
@@ -2133,18 +2157,17 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - "
2133# undef sinf 2157# undef sinf
2134# define sinf rpl_sinf 2158# define sinf rpl_sinf
2135# endif 2159# endif
2136_GL_FUNCDECL_RPL (sinf, float, (float x)); 2160_GL_FUNCDECL_RPL (sinf, float, (float x), );
2137_GL_CXXALIAS_RPL (sinf, float, (float x)); 2161_GL_CXXALIAS_RPL (sinf, float, (float x));
2138# else 2162# else
2139# if !@HAVE_SINF@ 2163# if !@HAVE_SINF@
2140# undef sinf 2164# undef sinf
2141_GL_FUNCDECL_SYS (sinf, float, (float x)); 2165_GL_FUNCDECL_SYS (sinf, float, (float x), );
2142# endif 2166# endif
2143_GL_CXXALIAS_SYS (sinf, float, (float x)); 2167_GL_CXXALIAS_SYS (sinf, float, (float x));
2144# endif 2168# endif
2145_GL_CXXALIASWARN (sinf); 2169_GL_CXXALIASWARN (sinf);
2146#elif defined GNULIB_POSIXCHECK 2170#elif defined GNULIB_POSIXCHECK
2147# undef sinf
2148# if HAVE_RAW_DECL_SINF 2171# if HAVE_RAW_DECL_SINF
2149_GL_WARN_ON_USE (sinf, "sinf is unportable - " 2172_GL_WARN_ON_USE (sinf, "sinf is unportable - "
2150 "use gnulib module sinf for portability"); 2173 "use gnulib module sinf for portability");
@@ -2152,16 +2175,24 @@ _GL_WARN_ON_USE (sinf, "sinf is unportable - "
2152#endif 2175#endif
2153 2176
2154#if @GNULIB_SINL@ 2177#if @GNULIB_SINL@
2155# if !@HAVE_SINL@ || !@HAVE_DECL_SINL@ 2178# if @REPLACE_SINL@
2156# undef sinl 2179# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2157_GL_FUNCDECL_SYS (sinl, long double, (long double x)); 2180# undef sinl
2158# endif 2181# define sinl rpl_sinl
2182# endif
2183_GL_FUNCDECL_RPL (sinl, long double, (long double x), );
2184_GL_CXXALIAS_RPL (sinl, long double, (long double x));
2185# else
2186# if !@HAVE_SINL@ || !@HAVE_DECL_SINL@
2187# undef sinl
2188_GL_FUNCDECL_SYS (sinl, long double, (long double x), );
2189# endif
2159_GL_CXXALIAS_SYS (sinl, long double, (long double x)); 2190_GL_CXXALIAS_SYS (sinl, long double, (long double x));
2191# endif
2160# if __GLIBC__ >= 2 2192# if __GLIBC__ >= 2
2161_GL_CXXALIASWARN (sinl); 2193_GL_CXXALIASWARN (sinl);
2162# endif 2194# endif
2163#elif defined GNULIB_POSIXCHECK 2195#elif defined GNULIB_POSIXCHECK
2164# undef sinl
2165# if HAVE_RAW_DECL_SINL 2196# if HAVE_RAW_DECL_SINL
2166_GL_WARN_ON_USE (sinl, "sinl is unportable - " 2197_GL_WARN_ON_USE (sinl, "sinl is unportable - "
2167 "use gnulib module sinl for portability"); 2198 "use gnulib module sinl for portability");
@@ -2175,18 +2206,17 @@ _GL_WARN_ON_USE (sinl, "sinl is unportable - "
2175# undef sinhf 2206# undef sinhf
2176# define sinhf rpl_sinhf 2207# define sinhf rpl_sinhf
2177# endif 2208# endif
2178_GL_FUNCDECL_RPL (sinhf, float, (float x)); 2209_GL_FUNCDECL_RPL (sinhf, float, (float x), );
2179_GL_CXXALIAS_RPL (sinhf, float, (float x)); 2210_GL_CXXALIAS_RPL (sinhf, float, (float x));
2180# else 2211# else
2181# if !@HAVE_SINHF@ 2212# if !@HAVE_SINHF@
2182# undef sinhf 2213# undef sinhf
2183_GL_FUNCDECL_SYS (sinhf, float, (float x)); 2214_GL_FUNCDECL_SYS (sinhf, float, (float x), );
2184# endif 2215# endif
2185_GL_CXXALIAS_SYS (sinhf, float, (float x)); 2216_GL_CXXALIAS_SYS (sinhf, float, (float x));
2186# endif 2217# endif
2187_GL_CXXALIASWARN (sinhf); 2218_GL_CXXALIASWARN (sinhf);
2188#elif defined GNULIB_POSIXCHECK 2219#elif defined GNULIB_POSIXCHECK
2189# undef sinhf
2190# if HAVE_RAW_DECL_SINHF 2220# if HAVE_RAW_DECL_SINHF
2191_GL_WARN_ON_USE (sinhf, "sinhf is unportable - " 2221_GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
2192 "use gnulib module sinhf for portability"); 2222 "use gnulib module sinhf for portability");
@@ -2200,18 +2230,17 @@ _GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
2200# undef sqrtf 2230# undef sqrtf
2201# define sqrtf rpl_sqrtf 2231# define sqrtf rpl_sqrtf
2202# endif 2232# endif
2203_GL_FUNCDECL_RPL (sqrtf, float, (float x)); 2233_GL_FUNCDECL_RPL (sqrtf, float, (float x), );
2204_GL_CXXALIAS_RPL (sqrtf, float, (float x)); 2234_GL_CXXALIAS_RPL (sqrtf, float, (float x));
2205# else 2235# else
2206# if !@HAVE_SQRTF@ 2236# if !@HAVE_SQRTF@
2207# undef sqrtf 2237# undef sqrtf
2208_GL_FUNCDECL_SYS (sqrtf, float, (float x)); 2238_GL_FUNCDECL_SYS (sqrtf, float, (float x), );
2209# endif 2239# endif
2210_GL_CXXALIAS_SYS (sqrtf, float, (float x)); 2240_GL_CXXALIAS_SYS (sqrtf, float, (float x));
2211# endif 2241# endif
2212_GL_CXXALIASWARN (sqrtf); 2242_GL_CXXALIASWARN (sqrtf);
2213#elif defined GNULIB_POSIXCHECK 2243#elif defined GNULIB_POSIXCHECK
2214# undef sqrtf
2215# if HAVE_RAW_DECL_SQRTF 2244# if HAVE_RAW_DECL_SQRTF
2216_GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - " 2245_GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - "
2217 "use gnulib module sqrtf for portability"); 2246 "use gnulib module sqrtf for portability");
@@ -2224,12 +2253,12 @@ _GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - "
2224# undef sqrtl 2253# undef sqrtl
2225# define sqrtl rpl_sqrtl 2254# define sqrtl rpl_sqrtl
2226# endif 2255# endif
2227_GL_FUNCDECL_RPL (sqrtl, long double, (long double x)); 2256_GL_FUNCDECL_RPL (sqrtl, long double, (long double x), );
2228_GL_CXXALIAS_RPL (sqrtl, long double, (long double x)); 2257_GL_CXXALIAS_RPL (sqrtl, long double, (long double x));
2229# else 2258# else
2230# if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@ 2259# if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@
2231# undef sqrtl 2260# undef sqrtl
2232_GL_FUNCDECL_SYS (sqrtl, long double, (long double x)); 2261_GL_FUNCDECL_SYS (sqrtl, long double, (long double x), );
2233# endif 2262# endif
2234_GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); 2263_GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
2235# endif 2264# endif
@@ -2237,7 +2266,6 @@ _GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
2237_GL_CXXALIASWARN (sqrtl); 2266_GL_CXXALIASWARN (sqrtl);
2238# endif 2267# endif
2239#elif defined GNULIB_POSIXCHECK 2268#elif defined GNULIB_POSIXCHECK
2240# undef sqrtl
2241# if HAVE_RAW_DECL_SQRTL 2269# if HAVE_RAW_DECL_SQRTL
2242_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " 2270_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
2243 "use gnulib module sqrtl for portability"); 2271 "use gnulib module sqrtl for portability");
@@ -2251,18 +2279,17 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
2251# undef tanf 2279# undef tanf
2252# define tanf rpl_tanf 2280# define tanf rpl_tanf
2253# endif 2281# endif
2254_GL_FUNCDECL_RPL (tanf, float, (float x)); 2282_GL_FUNCDECL_RPL (tanf, float, (float x), );
2255_GL_CXXALIAS_RPL (tanf, float, (float x)); 2283_GL_CXXALIAS_RPL (tanf, float, (float x));
2256# else 2284# else
2257# if !@HAVE_TANF@ 2285# if !@HAVE_TANF@
2258# undef tanf 2286# undef tanf
2259_GL_FUNCDECL_SYS (tanf, float, (float x)); 2287_GL_FUNCDECL_SYS (tanf, float, (float x), );
2260# endif 2288# endif
2261_GL_CXXALIAS_SYS (tanf, float, (float x)); 2289_GL_CXXALIAS_SYS (tanf, float, (float x));
2262# endif 2290# endif
2263_GL_CXXALIASWARN (tanf); 2291_GL_CXXALIASWARN (tanf);
2264#elif defined GNULIB_POSIXCHECK 2292#elif defined GNULIB_POSIXCHECK
2265# undef tanf
2266# if HAVE_RAW_DECL_TANF 2293# if HAVE_RAW_DECL_TANF
2267_GL_WARN_ON_USE (tanf, "tanf is unportable - " 2294_GL_WARN_ON_USE (tanf, "tanf is unportable - "
2268 "use gnulib module tanf for portability"); 2295 "use gnulib module tanf for portability");
@@ -2272,14 +2299,13 @@ _GL_WARN_ON_USE (tanf, "tanf is unportable - "
2272#if @GNULIB_TANL@ 2299#if @GNULIB_TANL@
2273# if !@HAVE_TANL@ || !@HAVE_DECL_TANL@ 2300# if !@HAVE_TANL@ || !@HAVE_DECL_TANL@
2274# undef tanl 2301# undef tanl
2275_GL_FUNCDECL_SYS (tanl, long double, (long double x)); 2302_GL_FUNCDECL_SYS (tanl, long double, (long double x), );
2276# endif 2303# endif
2277_GL_CXXALIAS_SYS (tanl, long double, (long double x)); 2304_GL_CXXALIAS_SYS (tanl, long double, (long double x));
2278# if __GLIBC__ >= 2 2305# if __GLIBC__ >= 2
2279_GL_CXXALIASWARN (tanl); 2306_GL_CXXALIASWARN (tanl);
2280# endif 2307# endif
2281#elif defined GNULIB_POSIXCHECK 2308#elif defined GNULIB_POSIXCHECK
2282# undef tanl
2283# if HAVE_RAW_DECL_TANL 2309# if HAVE_RAW_DECL_TANL
2284_GL_WARN_ON_USE (tanl, "tanl is unportable - " 2310_GL_WARN_ON_USE (tanl, "tanl is unportable - "
2285 "use gnulib module tanl for portability"); 2311 "use gnulib module tanl for portability");
@@ -2293,18 +2319,17 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - "
2293# undef tanhf 2319# undef tanhf
2294# define tanhf rpl_tanhf 2320# define tanhf rpl_tanhf
2295# endif 2321# endif
2296_GL_FUNCDECL_RPL (tanhf, float, (float x)); 2322_GL_FUNCDECL_RPL (tanhf, float, (float x), );
2297_GL_CXXALIAS_RPL (tanhf, float, (float x)); 2323_GL_CXXALIAS_RPL (tanhf, float, (float x));
2298# else 2324# else
2299# if !@HAVE_TANHF@ 2325# if !@HAVE_TANHF@
2300# undef tanhf 2326# undef tanhf
2301_GL_FUNCDECL_SYS (tanhf, float, (float x)); 2327_GL_FUNCDECL_SYS (tanhf, float, (float x), );
2302# endif 2328# endif
2303_GL_CXXALIAS_SYS (tanhf, float, (float x)); 2329_GL_CXXALIAS_SYS (tanhf, float, (float x));
2304# endif 2330# endif
2305_GL_CXXALIASWARN (tanhf); 2331_GL_CXXALIASWARN (tanhf);
2306#elif defined GNULIB_POSIXCHECK 2332#elif defined GNULIB_POSIXCHECK
2307# undef tanhf
2308# if HAVE_RAW_DECL_TANHF 2333# if HAVE_RAW_DECL_TANHF
2309_GL_WARN_ON_USE (tanhf, "tanhf is unportable - " 2334_GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
2310 "use gnulib module tanhf for portability"); 2335 "use gnulib module tanhf for portability");
@@ -2318,17 +2343,16 @@ _GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
2318# undef truncf 2343# undef truncf
2319# define truncf rpl_truncf 2344# define truncf rpl_truncf
2320# endif 2345# endif
2321_GL_FUNCDECL_RPL (truncf, float, (float x)); 2346_GL_FUNCDECL_RPL (truncf, float, (float x), );
2322_GL_CXXALIAS_RPL (truncf, float, (float x)); 2347_GL_CXXALIAS_RPL (truncf, float, (float x));
2323# else 2348# else
2324# if !@HAVE_DECL_TRUNCF@ 2349# if !@HAVE_DECL_TRUNCF@
2325_GL_FUNCDECL_SYS (truncf, float, (float x)); 2350_GL_FUNCDECL_SYS (truncf, float, (float x), );
2326# endif 2351# endif
2327_GL_CXXALIAS_SYS (truncf, float, (float x)); 2352_GL_CXXALIAS_SYS (truncf, float, (float x));
2328# endif 2353# endif
2329_GL_CXXALIASWARN (truncf); 2354_GL_CXXALIASWARN (truncf);
2330#elif defined GNULIB_POSIXCHECK 2355#elif defined GNULIB_POSIXCHECK
2331# undef truncf
2332# if HAVE_RAW_DECL_TRUNCF 2356# if HAVE_RAW_DECL_TRUNCF
2333_GL_WARN_ON_USE (truncf, "truncf is unportable - " 2357_GL_WARN_ON_USE (truncf, "truncf is unportable - "
2334 "use gnulib module truncf for portability"); 2358 "use gnulib module truncf for portability");
@@ -2341,11 +2365,11 @@ _GL_WARN_ON_USE (truncf, "truncf is unportable - "
2341# undef trunc 2365# undef trunc
2342# define trunc rpl_trunc 2366# define trunc rpl_trunc
2343# endif 2367# endif
2344_GL_FUNCDECL_RPL (trunc, double, (double x)); 2368_GL_FUNCDECL_RPL (trunc, double, (double x), );
2345_GL_CXXALIAS_RPL (trunc, double, (double x)); 2369_GL_CXXALIAS_RPL (trunc, double, (double x));
2346# else 2370# else
2347# if !@HAVE_DECL_TRUNC@ 2371# if !@HAVE_DECL_TRUNC@
2348_GL_FUNCDECL_SYS (trunc, double, (double x)); 2372_GL_FUNCDECL_SYS (trunc, double, (double x), );
2349# endif 2373# endif
2350_GL_CXXALIAS_SYS (trunc, double, (double x)); 2374_GL_CXXALIAS_SYS (trunc, double, (double x));
2351# endif 2375# endif
@@ -2353,7 +2377,6 @@ _GL_CXXALIAS_SYS (trunc, double, (double x));
2353_GL_CXXALIASWARN1 (trunc, double, (double x)); 2377_GL_CXXALIASWARN1 (trunc, double, (double x));
2354# endif 2378# endif
2355#elif defined GNULIB_POSIXCHECK 2379#elif defined GNULIB_POSIXCHECK
2356# undef trunc
2357# if HAVE_RAW_DECL_TRUNC 2380# if HAVE_RAW_DECL_TRUNC
2358_GL_WARN_ON_USE (trunc, "trunc is unportable - " 2381_GL_WARN_ON_USE (trunc, "trunc is unportable - "
2359 "use gnulib module trunc for portability"); 2382 "use gnulib module trunc for portability");
@@ -2366,11 +2389,11 @@ _GL_WARN_ON_USE (trunc, "trunc is unportable - "
2366# undef truncl 2389# undef truncl
2367# define truncl rpl_truncl 2390# define truncl rpl_truncl
2368# endif 2391# endif
2369_GL_FUNCDECL_RPL (truncl, long double, (long double x)); 2392_GL_FUNCDECL_RPL (truncl, long double, (long double x), );
2370_GL_CXXALIAS_RPL (truncl, long double, (long double x)); 2393_GL_CXXALIAS_RPL (truncl, long double, (long double x));
2371# else 2394# else
2372# if !@HAVE_DECL_TRUNCL@ 2395# if !@HAVE_DECL_TRUNCL@
2373_GL_FUNCDECL_SYS (truncl, long double, (long double x)); 2396_GL_FUNCDECL_SYS (truncl, long double, (long double x), );
2374# endif 2397# endif
2375_GL_CXXALIAS_SYS (truncl, long double, (long double x)); 2398_GL_CXXALIAS_SYS (truncl, long double, (long double x));
2376# endif 2399# endif
@@ -2378,7 +2401,6 @@ _GL_CXXALIAS_SYS (truncl, long double, (long double x));
2378_GL_CXXALIASWARN (truncl); 2401_GL_CXXALIASWARN (truncl);
2379# endif 2402# endif
2380#elif defined GNULIB_POSIXCHECK 2403#elif defined GNULIB_POSIXCHECK
2381# undef truncl
2382# if HAVE_RAW_DECL_TRUNCL 2404# if HAVE_RAW_DECL_TRUNCL
2383_GL_WARN_ON_USE (truncl, "truncl is unportable - " 2405_GL_WARN_ON_USE (truncl, "truncl is unportable - "
2384 "use gnulib module truncl for portability"); 2406 "use gnulib module truncl for portability");
@@ -2439,22 +2461,29 @@ _GL_CXXALIASWARN (yn);
2439 declarations. */ 2461 declarations. */
2440 2462
2441 2463
2442#if @GNULIB_ISFINITE@ 2464#if @GNULIB_ISFINITE@ || @GNULIB_ISFINITE_NO_CXX@
2443# if @REPLACE_ISFINITE@ 2465# if @REPLACE_ISFINITE@
2444_GL_EXTERN_C int gl_isfinitef (float x); 2466_GL_EXTERN_C int gl_isfinitef (float x);
2445_GL_EXTERN_C int gl_isfinited (double x); 2467_GL_EXTERN_C int gl_isfinited (double x);
2446_GL_EXTERN_C int gl_isfinitel (long double x); 2468_GL_EXTERN_C int gl_isfinitel (long double x);
2447# undef isfinite 2469# ifdef __cplusplus
2448# define isfinite(x) \ 2470template <typename T> int isfinite (T);
2449 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ 2471template <> inline int isfinite<float> (float x) { return gl_isfinitef (x); }
2450 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ 2472template <> inline int isfinite<double> (double x) { return gl_isfinited (x); }
2451 gl_isfinitef (x)) 2473template <> inline int isfinite<long double> (long double x) { return gl_isfinitel (x); }
2474# else
2475# undef isfinite
2476# define isfinite(x) \
2477 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \
2478 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \
2479 gl_isfinitef (x))
2480# endif
2452# endif 2481# endif
2453# ifdef __cplusplus 2482# if @GNULIB_ISFINITE@ && defined __cplusplus
2454# if defined isfinite || defined GNULIB_NAMESPACE 2483# if defined isfinite || defined GNULIB_NAMESPACE
2455_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) 2484_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
2456# undef isfinite 2485# undef isfinite
2457# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))) 2486# if __GNUC__ >= 6 || (defined __clang__ && (__clang_major__ >= 19 || !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))))
2458 /* This platform's <cmath> possibly defines isfinite through a set of inline 2487 /* This platform's <cmath> possibly defines isfinite through a set of inline
2459 functions. */ 2488 functions. */
2460_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool) 2489_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
@@ -2474,18 +2503,25 @@ _GL_WARN_REAL_FLOATING_DECL (isfinite);
2474#endif 2503#endif
2475 2504
2476 2505
2477#if @GNULIB_ISINF@ 2506#if @GNULIB_ISINF@ || @GNULIB_ISINF_NO_CXX@
2478# if @REPLACE_ISINF@ 2507# if @REPLACE_ISINF@
2479_GL_EXTERN_C int gl_isinff (float x); 2508_GL_EXTERN_C int gl_isinff (float x);
2480_GL_EXTERN_C int gl_isinfd (double x); 2509_GL_EXTERN_C int gl_isinfd (double x);
2481_GL_EXTERN_C int gl_isinfl (long double x); 2510_GL_EXTERN_C int gl_isinfl (long double x);
2482# undef isinf 2511# ifdef __cplusplus
2483# define isinf(x) \ 2512template <typename T> int isinf (T);
2484 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ 2513template <> inline int isinf<float> (float x) { return gl_isinff (x); }
2485 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ 2514template <> inline int isinf<double> (double x) { return gl_isinfd (x); }
2486 gl_isinff (x)) 2515template <> inline int isinf<long double> (long double x) { return gl_isinfl (x); }
2516# else
2517# undef isinf
2518# define isinf(x) \
2519 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
2520 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
2521 gl_isinff (x))
2522# endif
2487# endif 2523# endif
2488# ifdef __cplusplus 2524# if @GNULIB_ISINF@ && defined __cplusplus
2489# if defined isinf || defined GNULIB_NAMESPACE 2525# if defined isinf || defined GNULIB_NAMESPACE
2490_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) 2526_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
2491# undef isinf 2527# undef isinf
@@ -2512,16 +2548,22 @@ _GL_WARN_REAL_FLOATING_DECL (isinf);
2512#if @GNULIB_ISNANF@ 2548#if @GNULIB_ISNANF@
2513/* Test for NaN for 'float' numbers. */ 2549/* Test for NaN for 'float' numbers. */
2514# if @HAVE_ISNANF@ 2550# if @HAVE_ISNANF@
2551# if defined __sun
2552/* Solaris has isnanf() and declares it in <ieeefp.h>. We cannot define isnanf
2553 as a macro, because that would conflict with <ieeefp.h>. */
2554_GL_EXTERN_C int isnanf (float x);
2555# else
2515/* The original <math.h> included above provides a declaration of isnan macro 2556/* The original <math.h> included above provides a declaration of isnan macro
2516 or (older) isnanf function. */ 2557 or (older) isnanf function. */
2517# if (__GNUC__ >= 4) || (__clang_major__ >= 4) 2558# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2518 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. 2559 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
2519 GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */ 2560 GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */
2520# undef isnanf 2561# undef isnanf
2521# define isnanf(x) __builtin_isnan ((float)(x)) 2562# define isnanf(x) __builtin_isnan ((float)(x))
2522# elif defined isnan 2563# elif defined isnan && !defined HAVE_ISNANF_NOLIBM
2523# undef isnanf 2564# undef isnanf
2524# define isnanf(x) isnan ((float)(x)) 2565# define isnanf(x) isnan ((float)(x))
2566# endif
2525# endif 2567# endif
2526# else 2568# else
2527/* Test whether X is a NaN. */ 2569/* Test whether X is a NaN. */
@@ -2536,15 +2578,21 @@ _GL_EXTERN_C int isnanf (float x);
2536 This function is a gnulib extension, unlike isnan() which applied only 2578 This function is a gnulib extension, unlike isnan() which applied only
2537 to 'double' numbers earlier but now is a type-generic macro. */ 2579 to 'double' numbers earlier but now is a type-generic macro. */
2538# if @HAVE_ISNAND@ 2580# if @HAVE_ISNAND@
2581# if defined __sun
2582/* Solaris has isnand() and declares it in <ieeefp.h>. We cannot define isnand
2583 as a macro, because that would conflict with <ieeefp.h>. */
2584_GL_EXTERN_C int isnand (double x);
2585# else
2539/* The original <math.h> included above provides a declaration of isnan 2586/* The original <math.h> included above provides a declaration of isnan
2540 macro. */ 2587 macro. */
2541# if (__GNUC__ >= 4) || (__clang_major__ >= 4) 2588# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2542 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */ 2589 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */
2543# undef isnand 2590# undef isnand
2544# define isnand(x) __builtin_isnan ((double)(x)) 2591# define isnand(x) __builtin_isnan ((double)(x))
2545# else 2592# elif !defined HAVE_ISNAND_NOLIBM
2546# undef isnand 2593# undef isnand
2547# define isnand(x) isnan ((double)(x)) 2594# define isnand(x) isnan ((double)(x))
2595# endif
2548# endif 2596# endif
2549# else 2597# else
2550/* Test whether X is a NaN. */ 2598/* Test whether X is a NaN. */
@@ -2564,7 +2612,7 @@ _GL_EXTERN_C int isnand (double x);
2564 GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */ 2612 GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */
2565# undef isnanl 2613# undef isnanl
2566# define isnanl(x) __builtin_isnan ((long double)(x)) 2614# define isnanl(x) __builtin_isnan ((long double)(x))
2567# elif defined isnan 2615# elif defined isnan && !defined HAVE_ISNANL_NOLIBM
2568# undef isnanl 2616# undef isnanl
2569# define isnanl(x) isnan ((long double)(x)) 2617# define isnanl(x) isnan ((long double)(x))
2570# endif 2618# endif
@@ -2577,7 +2625,7 @@ _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
2577#endif 2625#endif
2578 2626
2579/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ 2627/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */
2580#if @GNULIB_ISNAN@ 2628#if @GNULIB_ISNAN@ || @GNULIB_ISNAN_NO_CXX@
2581# if @REPLACE_ISNAN@ 2629# if @REPLACE_ISNAN@
2582/* We can't just use the isnanf macro (e.g.) as exposed by 2630/* We can't just use the isnanf macro (e.g.) as exposed by
2583 isnanf.h (e.g.) here, because those may end up being macros 2631 isnanf.h (e.g.) here, because those may end up being macros
@@ -2601,28 +2649,49 @@ _GL_EXTERN_C int rpl_isnand (double x);
2601_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; 2649_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
2602# define gl_isnan_l(x) rpl_isnanl (x) 2650# define gl_isnan_l(x) rpl_isnanl (x)
2603# endif 2651# endif
2604# undef isnan 2652# ifdef __cplusplus
2605# define isnan(x) \ 2653# undef isnan
2606 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ 2654template <typename T> int isnan (T);
2607 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ 2655template <> inline int isnan<float> (float x) { return gl_isnan_f (x); }
2608 gl_isnan_f (x)) 2656template <> inline int isnan<double> (double x) { return gl_isnan_d (x); }
2657template <> inline int isnan<long double> (long double x) { return gl_isnan_l (x); }
2658# else
2659# undef isnan
2660# define isnan(x) \
2661 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
2662 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
2663 gl_isnan_f (x))
2664# endif
2609# elif (__GNUC__ >= 4) || (__clang_major__ >= 4) 2665# elif (__GNUC__ >= 4) || (__clang_major__ >= 4)
2610# undef isnan 2666# ifdef __cplusplus
2611# define isnan(x) \ 2667# undef isnan
2612 (sizeof (x) == sizeof (long double) ? __builtin_isnan ((long double)(x)) : \ 2668template <typename T> int isnan (T);
2613 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ 2669template <> inline int isnan<float> (float x) { return __builtin_isnan (x); }
2614 __builtin_isnan ((float)(x))) 2670template <> inline int isnan<double> (double x) { return __builtin_isnan (x); }
2671template <> inline int isnan<long double> (long double x) { return __builtin_isnan (x); }
2672# else
2673# undef isnan
2674# define isnan(x) \
2675 (sizeof (x) == sizeof (long double) ? __builtin_isnan ((long double)(x)) : \
2676 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
2677 __builtin_isnan ((float)(x)))
2678# endif
2615# endif 2679# endif
2616# ifdef __cplusplus 2680# if @GNULIB_ISNAN@ && defined __cplusplus
2617# if defined isnan || defined GNULIB_NAMESPACE 2681# if defined isnan || defined GNULIB_NAMESPACE
2618_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) 2682_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
2619# undef isnan 2683# undef isnan
2620# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ < 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__))) 2684# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ != 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__)))
2621 /* This platform's <cmath> possibly defines isnan through a set of inline 2685 /* This platform's <cmath> possibly defines isnan through a set of inline
2622 functions. */ 2686 functions. */
2623_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool) 2687_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
2624# define isnan rpl_isnan 2688# define isnan rpl_isnan
2625# define GNULIB_NAMESPACE_LACKS_ISNAN 1 2689# define GNULIB_NAMESPACE_LACKS_ISNAN 1
2690# elif __clang_major__ >= 14
2691 /* Neither of the two possible _GL_MATH_CXX_REAL_FLOATING_DECL_2 invocations
2692 works. Inline functions are already present in /usr/include/c++/v1/math.h,
2693 which comes from LLVM. */
2694# define GNULIB_NAMESPACE_LACKS_ISNAN 1
2626# else 2695# else
2627_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool) 2696_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
2628# endif 2697# endif
@@ -2642,27 +2711,35 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
2642#endif 2711#endif
2643 2712
2644 2713
2645#if @GNULIB_SIGNBIT@ 2714#if @GNULIB_SIGNBIT@ || @GNULIB_SIGNBIT_NO_CXX@
2646# if (@REPLACE_SIGNBIT_USING_BUILTINS@ \ 2715# if (@REPLACE_SIGNBIT_USING_BUILTINS@ \
2647 && (!defined __cplusplus || __cplusplus < 201103)) 2716 && (!defined __cplusplus || __cplusplus < 201103))
2648# undef signbit 2717# undef signbit
2649 /* GCC >= 4.0 and clang provide three built-ins for signbit. */ 2718 /* GCC >= 4.0 and clang provide three built-ins for signbit. */
2650# define signbit(x) \ 2719# if defined __cplusplus && !defined __clang__
2651 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ 2720template <typename T> int signbit (T);
2652 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ 2721template <> inline int signbit<float> (float x) { return __builtin_signbitf (x); }
2653 __builtin_signbitf (x)) 2722template <> inline int signbit<double> (double x) { return __builtin_signbit (x); }
2723template <> inline int signbit<long double> (long double x) { return __builtin_signbitl (x); }
2724# else
2725# define signbit(x) \
2726 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
2727 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
2728 __builtin_signbitf (x))
2729# endif
2654# endif 2730# endif
2655# if @REPLACE_SIGNBIT@ && !GNULIB_defined_signbit 2731# if @REPLACE_SIGNBIT@ && !GNULIB_defined_signbit
2656# undef signbit 2732# undef signbit
2657_GL_EXTERN_C int gl_signbitf (float arg); 2733_GL_EXTERN_C int gl_signbitf (float arg);
2658_GL_EXTERN_C int gl_signbitd (double arg); 2734_GL_EXTERN_C int gl_signbitd (double arg);
2659_GL_EXTERN_C int gl_signbitl (long double arg); 2735_GL_EXTERN_C int gl_signbitl (long double arg);
2660# if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__ 2736# if __GNUC__ >= 2 || defined __clang__
2661# define _GL_NUM_UINT_WORDS(type) \ 2737# define _GL_NUM_UINT_WORDS(type) \
2662 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) 2738 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
2663# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf 2739# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
2664# define gl_signbitf_OPTIMIZED_MACRO 2740# define gl_signbitf_OPTIMIZED_MACRO
2665# define gl_signbitf(arg) \ 2741# define gl_signbitf(arg) \
2742 __extension__ \
2666 ({ union { float _value; \ 2743 ({ union { float _value; \
2667 unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \ 2744 unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \
2668 } _m; \ 2745 } _m; \
@@ -2673,6 +2750,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
2673# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd 2750# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd
2674# define gl_signbitd_OPTIMIZED_MACRO 2751# define gl_signbitd_OPTIMIZED_MACRO
2675# define gl_signbitd(arg) \ 2752# define gl_signbitd(arg) \
2753 __extension__ \
2676 ({ union { double _value; \ 2754 ({ union { double _value; \
2677 unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \ 2755 unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \
2678 } _m; \ 2756 } _m; \
@@ -2683,6 +2761,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
2683# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl 2761# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl
2684# define gl_signbitl_OPTIMIZED_MACRO 2762# define gl_signbitl_OPTIMIZED_MACRO
2685# define gl_signbitl(arg) \ 2763# define gl_signbitl(arg) \
2764 __extension__ \
2686 ({ union { long double _value; \ 2765 ({ union { long double _value; \
2687 unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \ 2766 unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \
2688 } _m; \ 2767 } _m; \
@@ -2691,17 +2770,24 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
2691 }) 2770 })
2692# endif 2771# endif
2693# endif 2772# endif
2694# define signbit(x) \ 2773# if defined __cplusplus && !defined __clang__
2695 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ 2774template <typename T> int signbit (T);
2696 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ 2775template <> inline int signbit<float> (float x) { return gl_signbitf (x); }
2697 gl_signbitf (x)) 2776template <> inline int signbit<double> (double x) { return gl_signbitd (x); }
2777template <> inline int signbit<long double> (long double x) { return gl_signbitl (x); }
2778# else
2779# define signbit(x) \
2780 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
2781 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
2782 gl_signbitf (x))
2783# endif
2698# define GNULIB_defined_signbit 1 2784# define GNULIB_defined_signbit 1
2699# endif 2785# endif
2700# ifdef __cplusplus 2786# if @GNULIB_SIGNBIT@ && defined __cplusplus
2701# if defined signbit || defined GNULIB_NAMESPACE 2787# if defined signbit || defined GNULIB_NAMESPACE
2702_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) 2788_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
2703# undef signbit 2789# undef signbit
2704# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))) 2790# if __cplusplus >= 201103L || __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__)))
2705 /* This platform's <cmath> possibly defines signbit through a set of inline 2791 /* This platform's <cmath> possibly defines signbit through a set of inline
2706 functions. */ 2792 functions. */
2707_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool) 2793_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)
@@ -2720,8 +2806,308 @@ _GL_WARN_REAL_FLOATING_DECL (signbit);
2720# endif 2806# endif
2721#endif 2807#endif
2722 2808
2809
2810#if @GNULIB_GETPAYLOADF@
2811# if @REPLACE_GETPAYLOADF@
2812# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2813# undef getpayloadf
2814# define getpayloadf rpl_getpayloadf
2815# endif
2816_GL_FUNCDECL_RPL (getpayloadf, float, (const float *), );
2817_GL_CXXALIAS_RPL (getpayloadf, float, (const float *));
2818# else
2819# if !@HAVE_GETPAYLOADF@
2820_GL_FUNCDECL_SYS (getpayloadf, float, (const float *), );
2821# endif
2822_GL_CXXALIAS_SYS (getpayloadf, float, (const float *));
2823# endif
2824_GL_CXXALIASWARN (getpayloadf);
2825#elif defined GNULIB_POSIXCHECK
2826# if HAVE_RAW_DECL_GETPAYLOADF
2827_GL_WARN_ON_USE (getpayloadf, "getpayloadf is unportable - "
2828 "use gnulib module getpayloadf for portability");
2829# endif
2830#endif
2831
2832#if @GNULIB_GETPAYLOAD@
2833# if @REPLACE_GETPAYLOAD@
2834# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2835# undef getpayload
2836# define getpayload rpl_getpayload
2837# endif
2838_GL_FUNCDECL_RPL (getpayload, double, (const double *), );
2839_GL_CXXALIAS_RPL (getpayload, double, (const double *));
2840# else
2841# if !@HAVE_GETPAYLOAD@
2842_GL_FUNCDECL_SYS (getpayload, double, (const double *), );
2843# endif
2844_GL_CXXALIAS_SYS (getpayload, double, (const double *));
2845# endif
2846_GL_CXXALIASWARN (getpayload);
2847#elif defined GNULIB_POSIXCHECK
2848# if HAVE_RAW_DECL_GETPAYLOAD
2849_GL_WARN_ON_USE (getpayload, "getpayload is unportable - "
2850 "use gnulib module getpayload for portability");
2851# endif
2852#endif
2853
2854#if @GNULIB_GETPAYLOADL@
2855# if @REPLACE_GETPAYLOADL@
2856# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2857# undef getpayloadl
2858# define getpayloadl rpl_getpayloadl
2859# endif
2860_GL_FUNCDECL_RPL (getpayloadl, long double, (const long double *), );
2861_GL_CXXALIAS_RPL (getpayloadl, long double, (const long double *));
2862# else
2863# if !@HAVE_GETPAYLOADL@
2864_GL_FUNCDECL_SYS (getpayloadl, long double, (const long double *), );
2865# endif
2866_GL_CXXALIAS_SYS (getpayloadl, long double, (const long double *));
2867# endif
2868_GL_CXXALIASWARN (getpayloadl);
2869#elif defined GNULIB_POSIXCHECK
2870# if HAVE_RAW_DECL_GETPAYLOADL
2871_GL_WARN_ON_USE (getpayloadl, "getpayloadl is unportable - "
2872 "use gnulib module getpayloadl for portability");
2873# endif
2874#endif
2875
2876
2877#if @GNULIB_SETPAYLOADF@
2878# if !@HAVE_SETPAYLOADF@
2879_GL_FUNCDECL_SYS (setpayloadf, int, (float *, float), );
2880# endif
2881_GL_CXXALIAS_SYS (setpayloadf, int, (float *, float));
2882_GL_CXXALIASWARN (setpayloadf);
2883#elif defined GNULIB_POSIXCHECK
2884# if HAVE_RAW_DECL_SETPAYLOADF
2885_GL_WARN_ON_USE (setpayloadf, "setpayloadf is unportable - "
2886 "use gnulib module setpayloadf for portability");
2887# endif
2888#endif
2889
2890#if @GNULIB_SETPAYLOAD@
2891# if !@HAVE_SETPAYLOAD@
2892_GL_FUNCDECL_SYS (setpayload, int, (double *, double), );
2893# endif
2894_GL_CXXALIAS_SYS (setpayload, int, (double *, double));
2895_GL_CXXALIASWARN (setpayload);
2896#elif defined GNULIB_POSIXCHECK
2897# if HAVE_RAW_DECL_SETPAYLOAD
2898_GL_WARN_ON_USE (setpayload, "setpayload is unportable - "
2899 "use gnulib module setpayload for portability");
2900# endif
2901#endif
2902
2903#if @GNULIB_SETPAYLOADL@
2904# if !@HAVE_SETPAYLOADL@
2905_GL_FUNCDECL_SYS (setpayloadl, int, (long double *, long double), );
2906# endif
2907_GL_CXXALIAS_SYS (setpayloadl, int, (long double *, long double));
2908_GL_CXXALIASWARN (setpayloadl);
2909#elif defined GNULIB_POSIXCHECK
2910# if HAVE_RAW_DECL_SETPAYLOADL
2911_GL_WARN_ON_USE (setpayloadl, "setpayloadl is unportable - "
2912 "use gnulib module setpayloadl for portability");
2913# endif
2914#endif
2915
2916
2917#if @GNULIB_SETPAYLOADSIGF@
2918# if !@HAVE_SETPAYLOADSIGF@
2919_GL_FUNCDECL_SYS (setpayloadsigf, int, (float *, float), );
2920# endif
2921_GL_CXXALIAS_SYS (setpayloadsigf, int, (float *, float));
2922_GL_CXXALIASWARN (setpayloadsigf);
2923#elif defined GNULIB_POSIXCHECK
2924# if HAVE_RAW_DECL_SETPAYLOADSIGF
2925_GL_WARN_ON_USE (setpayloadsigf, "setpayloadsigf is unportable - "
2926 "use gnulib module setpayloadsigf for portability");
2927# endif
2928#endif
2929
2930#if @GNULIB_SETPAYLOADSIG@
2931# if !@HAVE_SETPAYLOADSIG@
2932_GL_FUNCDECL_SYS (setpayloadsig, int, (double *, double), );
2933# endif
2934_GL_CXXALIAS_SYS (setpayloadsig, int, (double *, double));
2935_GL_CXXALIASWARN (setpayloadsig);
2936#elif defined GNULIB_POSIXCHECK
2937# if HAVE_RAW_DECL_SETPAYLOADSIG
2938_GL_WARN_ON_USE (setpayloadsig, "setpayloadsig is unportable - "
2939 "use gnulib module setpayloadsig for portability");
2940# endif
2941#endif
2942
2943#if @GNULIB_SETPAYLOADSIGL@
2944# if !@HAVE_SETPAYLOADSIGL@
2945_GL_FUNCDECL_SYS (setpayloadsigl, int, (long double *, long double), );
2946# endif
2947_GL_CXXALIAS_SYS (setpayloadsigl, int, (long double *, long double));
2948_GL_CXXALIASWARN (setpayloadsigl);
2949#elif defined GNULIB_POSIXCHECK
2950# if HAVE_RAW_DECL_SETPAYLOADSIGL
2951_GL_WARN_ON_USE (setpayloadsigl, "setpayloadsigl is unportable - "
2952 "use gnulib module setpayloadsigl for portability");
2953# endif
2954#endif
2955
2956
2957#if @GNULIB_TOTALORDERF@
2958# if @REPLACE_TOTALORDERF@
2959# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2960# undef totalorderf
2961# define totalorderf rpl_totalorderf
2962# endif
2963_GL_FUNCDECL_RPL (totalorderf, int, (float const *, float const *), );
2964_GL_CXXALIAS_RPL (totalorderf, int, (float const *, float const *));
2965# else
2966# if !@HAVE_TOTALORDERF@
2967_GL_FUNCDECL_SYS (totalorderf, int, (float const *, float const *), );
2968# endif
2969_GL_CXXALIAS_SYS (totalorderf, int, (float const *, float const *));
2970# endif
2971_GL_CXXALIASWARN (totalorderf);
2972#elif defined GNULIB_POSIXCHECK
2973# if HAVE_RAW_DECL_TOTALORDERF
2974_GL_WARN_ON_USE (totalorderf, "totalorderf is unportable - "
2975 "use gnulib module totalorderf for portability");
2976# endif
2977#endif
2978
2979#if @GNULIB_TOTALORDER@
2980# if @REPLACE_TOTALORDER@
2981# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2982# undef totalorder
2983# define totalorder rpl_totalorder
2984# endif
2985_GL_FUNCDECL_RPL (totalorder, int, (double const *, double const *), );
2986_GL_CXXALIAS_RPL (totalorder, int, (double const *, double const *));
2987# else
2988# if !@HAVE_TOTALORDER@
2989_GL_FUNCDECL_SYS (totalorder, int, (double const *, double const *), );
2990# endif
2991_GL_CXXALIAS_SYS (totalorder, int, (double const *, double const *));
2992# endif
2993# if __GLIBC__ >= 2
2994_GL_CXXALIASWARN1 (totalorder, int, (double const *, double const *));
2995# endif
2996#elif defined GNULIB_POSIXCHECK
2997# if HAVE_RAW_DECL_TOTALORDER
2998_GL_WARN_ON_USE (totalorder, "totalorder is unportable - "
2999 "use gnulib module totalorder for portability");
3000# endif
3001#endif
3002
3003#if @GNULIB_TOTALORDERL@
3004# if @REPLACE_TOTALORDERL@
3005# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
3006# undef totalorderl
3007# define totalorderl rpl_totalorderl
3008# endif
3009_GL_FUNCDECL_RPL (totalorderl, int,
3010 (long double const *, long double const *), );
3011_GL_CXXALIAS_RPL (totalorderl, int,
3012 (long double const *, long double const *));
3013# else
3014# if !@HAVE_TOTALORDERL@
3015_GL_FUNCDECL_SYS (totalorderl, int,
3016 (long double const *, long double const *), );
3017# endif
3018_GL_CXXALIAS_SYS (totalorderl, int,
3019 (long double const *, long double const *));
3020# endif
3021_GL_CXXALIASWARN (totalorderl);
3022#elif defined GNULIB_POSIXCHECK
3023# if HAVE_RAW_DECL_TOTALORDERL
3024_GL_WARN_ON_USE (totalorderl, "totalorderl is unportable - "
3025 "use gnulib module totalorderl for portability");
3026# endif
3027#endif
3028
3029
3030#if @GNULIB_TOTALORDERMAGF@
3031# if @REPLACE_TOTALORDERMAGF@
3032# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
3033# undef totalordermagf
3034# define totalordermagf rpl_totalordermagf
3035# endif
3036_GL_FUNCDECL_RPL (totalordermagf, int, (float const *, float const *), );
3037_GL_CXXALIAS_RPL (totalordermagf, int, (float const *, float const *));
3038# else
3039# if !@HAVE_TOTALORDERMAGF@
3040_GL_FUNCDECL_SYS (totalordermagf, int, (float const *, float const *), );
3041# endif
3042_GL_CXXALIAS_SYS (totalordermagf, int, (float const *, float const *));
3043# endif
3044# if __GLIBC__ >= 2
3045_GL_CXXALIASWARN1 (totalordermagf, int, (float const *, float const *));
3046# endif
3047#elif defined GNULIB_POSIXCHECK
3048# if HAVE_RAW_DECL_TOTALORDERMAGF
3049_GL_WARN_ON_USE (totalordermagf, "totalordermagf is unportable - "
3050 "use gnulib module totalordermagf for portability");
3051# endif
3052#endif
3053
3054#if @GNULIB_TOTALORDERMAG@
3055# if @REPLACE_TOTALORDERMAG@
3056# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
3057# undef totalordermag
3058# define totalordermag rpl_totalordermag
3059# endif
3060_GL_FUNCDECL_RPL (totalordermag, int, (double const *, double const *), );
3061_GL_CXXALIAS_RPL (totalordermag, int, (double const *, double const *));
3062# else
3063# if !@HAVE_TOTALORDERMAG@
3064_GL_FUNCDECL_SYS (totalordermag, int, (double const *, double const *), );
3065# endif
3066_GL_CXXALIAS_SYS (totalordermag, int, (double const *, double const *));
3067# endif
3068# if __GLIBC__ >= 2
3069_GL_CXXALIASWARN1 (totalordermag, int, (double const *, double const *));
3070# endif
3071#elif defined GNULIB_POSIXCHECK
3072# if HAVE_RAW_DECL_TOTALORDERMAG
3073_GL_WARN_ON_USE (totalordermag, "totalordermag is unportable - "
3074 "use gnulib module totalordermag for portability");
3075# endif
3076#endif
3077
3078#if @GNULIB_TOTALORDERMAGL@
3079# if @REPLACE_TOTALORDERMAGL@
3080# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
3081# undef totalordermagl
3082# define totalordermagl rpl_totalordermagl
3083# endif
3084_GL_FUNCDECL_RPL (totalordermagl, int,
3085 (long double const *, long double const *), );
3086_GL_CXXALIAS_RPL (totalordermagl, int,
3087 (long double const *, long double const *));
3088# else
3089# if !@HAVE_TOTALORDERMAGL@
3090_GL_FUNCDECL_SYS (totalordermagl, int,
3091 (long double const *, long double const *), );
3092# endif
3093_GL_CXXALIAS_SYS (totalordermagl, int,
3094 (long double const *, long double const *));
3095# endif
3096# if __GLIBC__ >= 2
3097_GL_CXXALIASWARN1 (totalordermagl, int,
3098 (long double const *, long double const *));
3099# endif
3100#elif defined GNULIB_POSIXCHECK
3101# if HAVE_RAW_DECL_TOTALORDERMAGL
3102_GL_WARN_ON_USE (totalordermagl, "totalordermagl is unportable - "
3103 "use gnulib module totalordermagl for portability");
3104# endif
3105#endif
3106
3107
2723_GL_INLINE_HEADER_END 3108_GL_INLINE_HEADER_END
2724 3109
2725#endif /* _@GUARD_PREFIX@_MATH_H */ 3110#endif /* _@GUARD_PREFIX@_MATH_H */
2726#endif /* _GL_INCLUDING_MATH_H */ 3111#endif /* _GL_INCLUDING_MATH_H */
2727#endif /* _@GUARD_PREFIX@_MATH_H */ 3112#endif /* _@GUARD_PREFIX@_MATH_H */
3113#endif
diff --git a/gl/mbchar.c b/gl/mbchar.c
new file mode 100644
index 00000000..db9e2718
--- /dev/null
+++ b/gl/mbchar.c
@@ -0,0 +1,22 @@
1/* Copyright (C) 2001, 2006, 2009-2026 Free Software Foundation, Inc.
2
3 This file is free software: you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) any later version.
7
8 This file is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU Lesser General Public License for more details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program. If not, see <https://www.gnu.org/licenses/>. */
15
16
17#define MBCHAR_INLINE _GL_EXTERN_INLINE
18#include <config.h>
19
20#include <limits.h>
21
22#include "mbchar.h"
diff --git a/gl/mbchar.h b/gl/mbchar.h
new file mode 100644
index 00000000..20e28e5f
--- /dev/null
+++ b/gl/mbchar.h
@@ -0,0 +1,388 @@
1/* Multibyte character data type.
2 Copyright (C) 2001, 2005-2007, 2009-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>. */
18
19/* A multibyte character is a short subsequence of a char* string,
20 representing a single 32-bit wide character.
21
22 We use multibyte characters instead of 32-bit wide characters because
23 of the following goals:
24 1) correct multibyte handling, i.e. operate according to the LC_CTYPE
25 locale,
26 2) ease of maintenance, i.e. the maintainer needs not know all details
27 of the ISO C 99 standard,
28 3) don't fail grossly if the input is not in the encoding set by the
29 locale, because often different encodings are in use in the same
30 countries (ISO-8859-1/UTF-8, EUC-JP/Shift_JIS, ...),
31 4) fast in the case of ASCII characters.
32
33 Multibyte characters are only accessed through the mb* macros.
34
35 mb_ptr (mbc)
36 return a pointer to the beginning of the multibyte sequence.
37
38 mb_len (mbc)
39 returns the number of bytes occupied by the multibyte sequence.
40 Always > 0.
41
42 mb_iseq (mbc, sc)
43 returns true if mbc is the standard ASCII character sc.
44
45 mb_isnul (mbc)
46 returns true if mbc is the nul character.
47
48 mb_cmp (mbc1, mbc2)
49 returns a positive, zero, or negative value depending on whether mbc1
50 sorts after, same or before mbc2.
51
52 mb_casecmp (mbc1, mbc2)
53 returns a positive, zero, or negative value depending on whether mbc1
54 sorts after, same or before mbc2, modulo upper/lowercase conversion.
55
56 mb_equal (mbc1, mbc2)
57 returns true if mbc1 and mbc2 are equal.
58
59 mb_caseequal (mbc1, mbc2)
60 returns true if mbc1 and mbc2 are equal modulo upper/lowercase conversion.
61
62 mb_isalnum (mbc)
63 returns true if mbc is alphanumeric.
64
65 mb_isalpha (mbc)
66 returns true if mbc is alphabetic.
67
68 mb_isascii(mbc)
69 returns true if mbc is plain ASCII.
70
71 mb_isblank (mbc)
72 returns true if mbc is a blank.
73
74 mb_iscntrl (mbc)
75 returns true if mbc is a control character.
76
77 mb_isdigit (mbc)
78 returns true if mbc is a decimal digit.
79
80 mb_isgraph (mbc)
81 returns true if mbc is a graphic character.
82
83 mb_islower (mbc)
84 returns true if mbc is lowercase.
85
86 mb_isprint (mbc)
87 returns true if mbc is a printable character.
88
89 mb_ispunct (mbc)
90 returns true if mbc is a punctuation character.
91
92 mb_isspace (mbc)
93 returns true if mbc is a space character.
94
95 mb_isupper (mbc)
96 returns true if mbc is uppercase.
97
98 mb_isxdigit (mbc)
99 returns true if mbc is a hexadecimal digit.
100
101 mb_width (mbc)
102 returns the number of columns on the output device occupied by mbc.
103 Always >= 0.
104
105 mb_putc (mbc, stream)
106 outputs mbc on stream, a byte oriented FILE stream opened for output.
107
108 mb_setascii (&mbc, sc)
109 assigns the standard ASCII character sc to mbc.
110 (Only available if the 'mbfile' module is in use.)
111
112 mb_copy (&destmbc, &srcmbc)
113 copies srcmbc to destmbc.
114
115 Here are the function prototypes of the macros.
116
117 extern const char * mb_ptr (const mbchar_t mbc);
118 extern size_t mb_len (const mbchar_t mbc);
119 extern bool mb_iseq (const mbchar_t mbc, char sc);
120 extern bool mb_isnul (const mbchar_t mbc);
121 extern int mb_cmp (const mbchar_t mbc1, const mbchar_t mbc2);
122 extern int mb_casecmp (const mbchar_t mbc1, const mbchar_t mbc2);
123 extern bool mb_equal (const mbchar_t mbc1, const mbchar_t mbc2);
124 extern bool mb_caseequal (const mbchar_t mbc1, const mbchar_t mbc2);
125 extern bool mb_isalnum (const mbchar_t mbc);
126 extern bool mb_isalpha (const mbchar_t mbc);
127 extern bool mb_isascii (const mbchar_t mbc);
128 extern bool mb_isblank (const mbchar_t mbc);
129 extern bool mb_iscntrl (const mbchar_t mbc);
130 extern bool mb_isdigit (const mbchar_t mbc);
131 extern bool mb_isgraph (const mbchar_t mbc);
132 extern bool mb_islower (const mbchar_t mbc);
133 extern bool mb_isprint (const mbchar_t mbc);
134 extern bool mb_ispunct (const mbchar_t mbc);
135 extern bool mb_isspace (const mbchar_t mbc);
136 extern bool mb_isupper (const mbchar_t mbc);
137 extern bool mb_isxdigit (const mbchar_t mbc);
138 extern int mb_width (const mbchar_t mbc);
139 extern void mb_putc (const mbchar_t mbc, FILE *stream);
140 extern void mb_setascii (mbchar_t *new, char sc);
141 extern void mb_copy (mbchar_t *new, const mbchar_t *old);
142 */
143
144#ifndef _MBCHAR_H
145#define _MBCHAR_H 1
146
147/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
148#if !_GL_CONFIG_H_INCLUDED
149 #error "Please include config.h first."
150#endif
151
152#include <string.h>
153#include <uchar.h>
154
155_GL_INLINE_HEADER_BEGIN
156#ifndef MBCHAR_INLINE
157# define MBCHAR_INLINE _GL_INLINE
158#endif
159
160#ifdef __cplusplus
161extern "C" {
162#endif
163
164
165/* The longest multibyte characters, nowadays, are 4 bytes long.
166 Regardless of the values of MB_CUR_MAX and MB_LEN_MAX. */
167#define MBCHAR_BUF_SIZE 4
168
169struct mbchar
170{
171 const char *ptr; /* pointer to current character */
172 size_t bytes; /* number of bytes of current character, > 0 */
173 bool wc_valid; /* true if wc is a valid 32-bit wide character */
174 char32_t wc; /* if wc_valid: the current character */
175#if defined GNULIB_MBFILE
176 char buf[MBCHAR_BUF_SIZE]; /* room for the bytes, used for file input only */
177#endif
178};
179
180/* EOF (not a real character) is represented with bytes = 0 and
181 wc_valid = false. */
182
183typedef struct mbchar mbchar_t;
184
185/* Access the current character. */
186#define mb_ptr(mbc) ((mbc).ptr)
187#define mb_len(mbc) ((mbc).bytes)
188
189/* Comparison of characters. */
190#define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc))
191#define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0)
192#define mb_cmp(mbc1, mbc2) \
193 ((mbc1).wc_valid \
194 ? ((mbc2).wc_valid \
195 ? _GL_CMP ((mbc1).wc, (mbc2).wc) \
196 : -1) \
197 : ((mbc2).wc_valid \
198 ? 1 \
199 : (mbc1).bytes == (mbc2).bytes \
200 ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \
201 : (mbc1).bytes < (mbc2).bytes \
202 ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
203 : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)))
204#define mb_casecmp(mbc1, mbc2) \
205 ((mbc1).wc_valid \
206 ? ((mbc2).wc_valid \
207 ? _GL_CMP (c32tolower ((mbc1).wc), c32tolower ((mbc2).wc)) \
208 : -1) \
209 : ((mbc2).wc_valid \
210 ? 1 \
211 : (mbc1).bytes == (mbc2).bytes \
212 ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \
213 : (mbc1).bytes < (mbc2).bytes \
214 ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
215 : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)))
216#define mb_equal(mbc1, mbc2) \
217 ((mbc1).wc_valid && (mbc2).wc_valid \
218 ? (mbc1).wc == (mbc2).wc \
219 : (mbc1).bytes == (mbc2).bytes \
220 && memeq ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes))
221#define mb_caseequal(mbc1, mbc2) \
222 ((mbc1).wc_valid && (mbc2).wc_valid \
223 ? c32tolower ((mbc1).wc) == c32tolower ((mbc2).wc) \
224 : (mbc1).bytes == (mbc2).bytes \
225 && memeq ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes))
226
227/* <ctype.h>, <wctype.h> classification. */
228#define mb_isascii(mbc) \
229 ((mbc).wc_valid && (mbc).wc >= 0 && (mbc).wc <= 127)
230#define mb_isalnum(mbc) ((mbc).wc_valid && c32isalnum ((mbc).wc))
231#define mb_isalpha(mbc) ((mbc).wc_valid && c32isalpha ((mbc).wc))
232#define mb_isblank(mbc) ((mbc).wc_valid && c32isblank ((mbc).wc))
233#define mb_iscntrl(mbc) ((mbc).wc_valid && c32iscntrl ((mbc).wc))
234#define mb_isdigit(mbc) ((mbc).wc_valid && c32isdigit ((mbc).wc))
235#define mb_isgraph(mbc) ((mbc).wc_valid && c32isgraph ((mbc).wc))
236#define mb_islower(mbc) ((mbc).wc_valid && c32islower ((mbc).wc))
237#define mb_isprint(mbc) ((mbc).wc_valid && c32isprint ((mbc).wc))
238#define mb_ispunct(mbc) ((mbc).wc_valid && c32ispunct ((mbc).wc))
239#define mb_isspace(mbc) ((mbc).wc_valid && c32isspace ((mbc).wc))
240#define mb_isupper(mbc) ((mbc).wc_valid && c32isupper ((mbc).wc))
241#define mb_isxdigit(mbc) ((mbc).wc_valid && c32isxdigit ((mbc).wc))
242
243/* Extra <wchar.h> function. */
244
245/* Unprintable characters appear as a small box of width 1. */
246#define MB_UNPRINTABLE_WIDTH 1
247
248MBCHAR_INLINE int
249mb_width_aux (char32_t wc)
250{
251 int w = c32width (wc);
252 /* For unprintable characters, arbitrarily return 0 for control characters
253 and MB_UNPRINTABLE_WIDTH otherwise. */
254 return (w >= 0 ? w : c32iscntrl (wc) ? 0 : MB_UNPRINTABLE_WIDTH);
255}
256
257#define mb_width(mbc) \
258 ((mbc).wc_valid ? mb_width_aux ((mbc).wc) : MB_UNPRINTABLE_WIDTH)
259
260/* Output. */
261#define mb_putc(mbc, stream) fwrite ((mbc).ptr, 1, (mbc).bytes, (stream))
262
263#if defined GNULIB_MBFILE
264/* Assignment. */
265MBCHAR_INLINE void
266mb_setascii (mbchar_t *mbc, char sc)
267{
268 mbc->ptr = mbc->buf;
269 mbc->bytes = 1;
270 mbc->wc_valid = true;
271 mbc->wc = mbc->buf[0] = sc;
272}
273#endif
274
275/* Copying a character. */
276MBCHAR_INLINE void
277mb_copy (mbchar_t *new_mbc, const mbchar_t *old_mbc)
278{
279#if defined GNULIB_MBFILE
280 if (old_mbc->ptr == &old_mbc->buf[0])
281 {
282 memcpy (&new_mbc->buf[0], &old_mbc->buf[0], old_mbc->bytes);
283 new_mbc->ptr = &new_mbc->buf[0];
284 }
285 else
286#endif
287 new_mbc->ptr = old_mbc->ptr;
288 new_mbc->bytes = old_mbc->bytes;
289 if ((new_mbc->wc_valid = old_mbc->wc_valid))
290 new_mbc->wc = old_mbc->wc;
291}
292
293
294/* is_basic(c) tests whether the single-byte character c is
295 - in the ISO C "basic character set" or is one of '@', '$', and '`'
296 which ISO C 23 § 5.2.1.1.(1) guarantees to be single-byte and in
297 practice are safe to treat as basic in the execution character set,
298 or
299 - in the POSIX "portable character set", which
300 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap06.html>
301 equally guarantees to be single-byte.
302 This is a convenience function, and is in this file only to share code
303 between mbiter.h, mbuiter.h, and mbfile.h. */
304#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
305 && ('$' == 36) && ('%' == 37) && ('&' == 38) && ('\'' == 39) \
306 && ('(' == 40) && (')' == 41) && ('*' == 42) && ('+' == 43) \
307 && (',' == 44) && ('-' == 45) && ('.' == 46) && ('/' == 47) \
308 && ('0' == 48) && ('1' == 49) && ('2' == 50) && ('3' == 51) \
309 && ('4' == 52) && ('5' == 53) && ('6' == 54) && ('7' == 55) \
310 && ('8' == 56) && ('9' == 57) && (':' == 58) && (';' == 59) \
311 && ('<' == 60) && ('=' == 61) && ('>' == 62) && ('?' == 63) \
312 && ('@' == 64) && ('A' == 65) && ('B' == 66) && ('C' == 67) \
313 && ('D' == 68) && ('E' == 69) && ('F' == 70) && ('G' == 71) \
314 && ('H' == 72) && ('I' == 73) && ('J' == 74) && ('K' == 75) \
315 && ('L' == 76) && ('M' == 77) && ('N' == 78) && ('O' == 79) \
316 && ('P' == 80) && ('Q' == 81) && ('R' == 82) && ('S' == 83) \
317 && ('T' == 84) && ('U' == 85) && ('V' == 86) && ('W' == 87) \
318 && ('X' == 88) && ('Y' == 89) && ('Z' == 90) && ('[' == 91) \
319 && ('\\' == 92) && (']' == 93) && ('^' == 94) && ('_' == 95) \
320 && ('`' == 96) && ('a' == 97) && ('b' == 98) && ('c' == 99) \
321 && ('d' == 100) && ('e' == 101) && ('f' == 102) && ('g' == 103) \
322 && ('h' == 104) && ('i' == 105) && ('j' == 106) && ('k' == 107) \
323 && ('l' == 108) && ('m' == 109) && ('n' == 110) && ('o' == 111) \
324 && ('p' == 112) && ('q' == 113) && ('r' == 114) && ('s' == 115) \
325 && ('t' == 116) && ('u' == 117) && ('v' == 118) && ('w' == 119) \
326 && ('x' == 120) && ('y' == 121) && ('z' == 122) && ('{' == 123) \
327 && ('|' == 124) && ('}' == 125) && ('~' == 126)
328/* The character set is ISO-646, not EBCDIC. */
329# define IS_BASIC_ASCII 1
330
331/* All locale encodings (see localcharset.h) map the characters 0x00..0x7F
332 to U+0000..U+007F, like ASCII, except for
333 CP864 different mapping of '%'
334 SHIFT_JIS different mappings of 0x5C, 0x7E
335 JOHAB different mapping of 0x5C
336 However, these characters in the range 0x20..0x7E are in the ISO C
337 "basic character set" and in the POSIX "portable character set", which
338 ISO C and POSIX guarantee to be single-byte. Thus, locales with these
339 encodings are not POSIX compliant. And they are most likely not in use
340 any more (as of 2023). */
341# define is_basic(c) ((unsigned char) (c) < 0x80)
342
343#else
344
345MBCHAR_INLINE bool
346is_basic (char c)
347{
348 switch (c)
349 {
350 case '\0':
351 case '\007': case '\010':
352 case '\t': case '\n': case '\v': case '\f': case '\r':
353 case ' ': case '!': case '"': case '#': case '$': case '%':
354 case '&': case '\'': case '(': case ')': case '*':
355 case '+': case ',': case '-': case '.': case '/':
356 case '0': case '1': case '2': case '3': case '4':
357 case '5': case '6': case '7': case '8': case '9':
358 case ':': case ';': case '<': case '=': case '>':
359 case '?': case '@':
360 case 'A': case 'B': case 'C': case 'D': case 'E':
361 case 'F': case 'G': case 'H': case 'I': case 'J':
362 case 'K': case 'L': case 'M': case 'N': case 'O':
363 case 'P': case 'Q': case 'R': case 'S': case 'T':
364 case 'U': case 'V': case 'W': case 'X': case 'Y':
365 case 'Z':
366 case '[': case '\\': case ']': case '^': case '_': case '`':
367 case 'a': case 'b': case 'c': case 'd': case 'e':
368 case 'f': case 'g': case 'h': case 'i': case 'j':
369 case 'k': case 'l': case 'm': case 'n': case 'o':
370 case 'p': case 'q': case 'r': case 's': case 't':
371 case 'u': case 'v': case 'w': case 'x': case 'y':
372 case 'z': case '{': case '|': case '}': case '~':
373 return 1;
374 default:
375 return 0;
376 }
377}
378
379#endif
380
381
382#ifdef __cplusplus
383}
384#endif
385
386_GL_INLINE_HEADER_END
387
388#endif /* _MBCHAR_H */
diff --git a/gl/mbiterf.c b/gl/mbiterf.c
new file mode 100644
index 00000000..bb0a5cc3
--- /dev/null
+++ b/gl/mbiterf.c
@@ -0,0 +1,20 @@
1/* Iterating through multibyte strings: macros for multi-byte encodings.
2
3 Copyright (C) 2023-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#define MBITERF_INLINE _GL_EXTERN_INLINE
19#include <config.h>
20#include "mbiterf.h"
diff --git a/gl/mbiterf.h b/gl/mbiterf.h
new file mode 100644
index 00000000..50a39c0f
--- /dev/null
+++ b/gl/mbiterf.h
@@ -0,0 +1,214 @@
1/* Iterating through multibyte strings, faster: macros for multi-byte encodings.
2 Copyright (C) 2001, 2005, 2007, 2009-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>,
18 with insights from Paul Eggert. */
19
20/* The macros in this file implement forward iteration through a
21 multi-byte string.
22
23 With these macros, an iteration loop that looks like
24
25 char *iter;
26 for (iter = buf; iter < buf + buflen; iter++)
27 {
28 do_something (*iter);
29 }
30
31 becomes
32
33 const char *buf_end = buf + buflen;
34 mbif_state_t state;
35 [const] char *iter;
36 for (mbif_init (state), iter = buf; mbif_avail (state, iter, buf_end); )
37 {
38 mbchar_t cur = mbif_next (state, iter, buf_end);
39 // Note: Here always mb_ptr (cur) == iter.
40 do_something (iter, mb_len (cur));
41 iter += mb_len (cur);
42 }
43
44 The benefit of these macros over plain use of mbrtowc or mbrtoc32 is:
45 - Handling of invalid multibyte sequences is possible without
46 making the code more complicated, while still preserving the
47 invalid multibyte sequences.
48
49 The benefit of these macros over those from mbiter.h is that it
50 produces faster code with today's optimizing compilers (because mbif_next
51 returns its result by value).
52
53 mbif_state_t
54 is a type usable for variable declarations.
55
56 mbif_init (state)
57 initializes the state.
58
59 mbif_avail (state, iter, endptr)
60 returns true if another loop round is needed.
61
62 mbif_next (state, iter, endptr)
63 returns the next multibyte character.
64 It assumes that the state is initialized and that iter < endptr.
65
66 Here are the function prototypes of the macros.
67
68 extern void mbif_init (mbif_state_t state);
69 extern bool mbif_avail (mbif_state_t state, const char *iter, const char *endptr);
70 extern mbchar_t mbif_next (mbif_state_t state, const char *iter, const char *endptr);
71 */
72
73#ifndef _MBITERF_H
74#define _MBITERF_H 1
75
76/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE,
77 _GL_ATTRIBUTE_ALWAYS_INLINE. */
78#if !_GL_CONFIG_H_INCLUDED
79 #error "Please include config.h first."
80#endif
81
82#include <assert.h>
83#include <stddef.h>
84#include <string.h>
85#include <uchar.h>
86#include <wchar.h>
87
88#include "mbchar.h"
89
90_GL_INLINE_HEADER_BEGIN
91#ifndef MBITERF_INLINE
92# define MBITERF_INLINE _GL_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
93#endif
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
99
100struct mbif_state
101{
102 #if !GNULIB_MBRTOC32_REGULAR
103 bool in_shift; /* true if next byte may not be interpreted as ASCII */
104 /* If GNULIB_MBRTOC32_REGULAR, it is always false,
105 so optimize it away. */
106 #endif
107 mbstate_t state; /* if in_shift: current shift state */
108 /* If GNULIB_MBRTOC32_REGULAR, it is in an initial state
109 before and after every mbiterf_next invocation.
110 */
111};
112
113MBITERF_INLINE mbchar_t
114mbiterf_next (struct mbif_state *ps, const char *iter, const char *endptr)
115{
116 #if !GNULIB_MBRTOC32_REGULAR
117 if (ps->in_shift)
118 goto with_shift;
119 #endif
120 /* Handle most ASCII characters quickly, without calling mbrtowc(). */
121 if (is_basic (*iter))
122 {
123 /* These characters are part of the POSIX portable character set.
124 For most of them, namely those in the ISO C basic character set,
125 ISO C 99 guarantees that their wide character code is identical to
126 their char code. For the few other ones, this is the case as well,
127 in all locale encodings that are in use. The 32-bit wide character
128 code is the same as well. */
129 return (mbchar_t) { .ptr = iter, .bytes = 1, .wc_valid = true, .wc = *iter };
130 }
131 else
132 {
133 assert (mbsinit (&ps->state));
134 #if !GNULIB_MBRTOC32_REGULAR
135 ps->in_shift = true;
136 with_shift:;
137 #endif
138 size_t bytes;
139 char32_t wc;
140 bytes = mbrtoc32 (&wc, iter, endptr - iter, &ps->state);
141 if (bytes == (size_t) -1)
142 {
143 /* An invalid multibyte sequence was encountered. */
144 /* Allow the next invocation to continue from a sane state. */
145 #if !GNULIB_MBRTOC32_REGULAR
146 ps->in_shift = false;
147 #endif
148 mbszero (&ps->state);
149 return (mbchar_t) { .ptr = iter, .bytes = 1, .wc_valid = false };
150 }
151 else if (bytes == (size_t) -2)
152 {
153 /* An incomplete multibyte character at the end. */
154 #if !GNULIB_MBRTOC32_REGULAR
155 ps->in_shift = false;
156 #endif
157 /* Whether to reset ps->state or not is not important; the string end
158 is reached anyway. */
159 return (mbchar_t) { .ptr = iter, .bytes = endptr - iter, .wc_valid = false };
160 }
161 else
162 {
163 if (bytes == 0)
164 {
165 /* A null wide character was encountered. */
166 bytes = 1;
167 assert (*iter == '\0');
168 assert (wc == 0);
169 }
170 #if !GNULIB_MBRTOC32_REGULAR
171 else if (bytes == (size_t) -3)
172 /* The previous multibyte sequence produced an additional 32-bit
173 wide character. */
174 bytes = 0;
175 #endif
176
177 /* When in an initial state, we can go back treating ASCII
178 characters more quickly. */
179 #if !GNULIB_MBRTOC32_REGULAR
180 if (mbsinit (&ps->state))
181 ps->in_shift = false;
182 #endif
183 return (mbchar_t) { .ptr = iter, .bytes = bytes, .wc_valid = true, .wc = wc };
184 }
185 }
186}
187
188/* Iteration macros. */
189typedef struct mbif_state mbif_state_t;
190#if !GNULIB_MBRTOC32_REGULAR
191#define mbif_init(st) \
192 ((st).in_shift = false, mbszero (&(st).state))
193#else
194/* Optimized: no in_shift. */
195#define mbif_init(st) \
196 (mbszero (&(st).state))
197#endif
198#if !GNULIB_MBRTOC32_REGULAR
199#define mbif_avail(st, iter, endptr) ((st).in_shift || ((iter) < (endptr)))
200#else
201/* Optimized: no in_shift. */
202#define mbif_avail(st, iter, endptr) ((iter) < (endptr))
203#endif
204#define mbif_next(st, iter, endptr) \
205 mbiterf_next (&(st), (iter), (endptr))
206
207
208#ifdef __cplusplus
209}
210#endif
211
212_GL_INLINE_HEADER_END
213
214#endif /* _MBITERF_H */
diff --git a/gl/mbrtoc32.c b/gl/mbrtoc32.c
new file mode 100644
index 00000000..4c8f5267
--- /dev/null
+++ b/gl/mbrtoc32.c
@@ -0,0 +1,288 @@
1/* Convert multibyte character to 32-bit wide character.
2 Copyright (C) 2020-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
18
19#include <config.h>
20
21/* Specification. */
22#include <uchar.h>
23
24#include "attribute.h"
25
26#include <errno.h>
27#include <stdlib.h>
28
29#if GL_CHAR32_T_IS_UNICODE
30# include "lc-charset-unicode.h"
31#endif
32
33#if GNULIB_defined_mbstate_t /* AIX */
34/* Implement mbrtoc32() on top of mbtowc() for the non-UTF-8 locales
35 and directly for the UTF-8 locales. */
36
37/* Note: On AIX (64-bit) we can implement mbrtoc32 in two equivalent ways:
38 - in a way that parallels the override of mbrtowc; this is the code branch
39 here;
40 - in a way that invokes the overridden mbrtowc; this would be the #else
41 branch below.
42 They are equivalent. */
43
44# if AVOID_ANY_THREADS
45
46/* The option '--disable-threads' explicitly requests no locking. */
47
48# elif defined _WIN32 && !defined __CYGWIN__
49
50# define WIN32_LEAN_AND_MEAN /* avoid including junk */
51# include <windows.h>
52
53# elif HAVE_PTHREAD_API
54
55# include <pthread.h>
56# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
57# include <threads.h>
58# pragma weak thrd_exit
59# define c11_threads_in_use() (thrd_exit != NULL)
60# else
61# define c11_threads_in_use() 0
62# endif
63
64# elif HAVE_THREADS_H
65
66# include <threads.h>
67
68# endif
69
70# include "lc-charset-dispatch.h"
71# include "mbtowc-lock.h"
72
73static_assert (sizeof (mbstate_t) >= 4);
74static char internal_state[4];
75
76size_t
77mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
78{
79# define FITS_IN_CHAR_TYPE(wc) 1
80# include "mbrtowc-impl.h"
81}
82
83#else /* glibc, macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Cygwin, mingw, MSVC, Minix, Android */
84
85/* Implement mbrtoc32() based on the original mbrtoc32() or on mbrtowc(). */
86
87# include <wchar.h>
88
89# include "localcharset.h"
90# include "streq.h"
91
92# if MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ
93# include "hard-locale.h"
94# include <locale.h>
95# endif
96
97static mbstate_t internal_state;
98
99size_t
100mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
101# undef mbrtoc32
102{
103 /* It's simpler to handle the case s == NULL upfront, than to worry about
104 this case later, before every test of pwc and n. */
105 if (s == NULL)
106 {
107 pwc = NULL;
108 s = "";
109 n = 1;
110 }
111
112# if MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T
113 if (n == 0)
114 return (size_t) -2;
115# endif
116
117 if (ps == NULL)
118 ps = &internal_state;
119
120# if HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB && !MBRTOC32_MULTIBYTE_LOCALE_BUG
121 /* mbrtoc32() may produce different values for wc than mbrtowc(). Therefore
122 use mbrtoc32(). */
123
124# if defined _WIN32 && !defined __CYGWIN__
125 char32_t wc;
126 size_t ret = mbrtoc32 (&wc, s, n, ps);
127 if (ret < (size_t) -2 && pwc != NULL)
128 *pwc = wc;
129# else
130 size_t ret = mbrtoc32 (pwc, s, n, ps);
131# endif
132
133# if GNULIB_MBRTOC32_REGULAR
134 /* Verify that mbrtoc32 is regular. */
135 if (ret < (size_t) -3 && ! mbsinit (ps))
136 /* This occurs on glibc 2.36. */
137 mbszero (ps);
138 if (ret == (size_t) -3)
139 abort ();
140# endif
141
142# if MBRTOC32_IN_C_LOCALE_MAYBE_EILSEQ
143 if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
144 {
145 if (pwc != NULL)
146 *pwc = (unsigned char) *s;
147 return 1;
148 }
149# endif
150
151 return ret;
152
153# elif _GL_SMALL_WCHAR_T
154
155 /* Special-case all encodings that may produce wide character values
156 > WCHAR_MAX. */
157 const char *encoding = locale_charset ();
158 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
159 {
160 /* Special-case the UTF-8 encoding. Assume that the wide-character
161 encoding in a UTF-8 locale is UCS-2 or, equivalently, UTF-16. */
162 /* Here n > 0. */
163 char *pstate = (char *)ps;
164 size_t nstate = pstate[0];
165 char buf[4];
166 const char *p;
167 size_t m;
168
169 switch (nstate)
170 {
171 case 0:
172 p = s;
173 m = n;
174 break;
175 case 3:
176 buf[2] = pstate[3];
177 FALLTHROUGH;
178 case 2:
179 buf[1] = pstate[2];
180 FALLTHROUGH;
181 case 1:
182 buf[0] = pstate[1];
183 p = buf;
184 m = nstate;
185 buf[m++] = s[0];
186 if (n >= 2 && m < 4)
187 {
188 buf[m++] = s[1];
189 if (n >= 3 && m < 4)
190 buf[m++] = s[2];
191 }
192 break;
193 default:
194 errno = EINVAL;
195 return (size_t)(-1);
196 }
197
198 /* Here m > 0. */
199
200 int res;
201 {
202# define FITS_IN_CHAR_TYPE(wc) 1
203# include "mbrtowc-impl-utf8.h"
204 }
205
206 success:
207 if (nstate >= (res > 0 ? res : 1))
208 abort ();
209 res -= nstate;
210 /* Set *ps to an initial state. */
211# if defined _WIN32 && !defined __CYGWIN__
212 /* Native Windows. */
213 /* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4 bytes matter.
214 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
215 as an 8-byte struct, of which the first 4 bytes matter. */
216 *(unsigned int *)pstate = 0;
217# elif defined __CYGWIN__
218 /* Cygwin defines 'mbstate_t' as an 8-byte struct; the first 4 bytes
219 matter. */
220 ps->__count = 0;
221# else
222 pstate[0] = 0;
223# endif
224 return res;
225
226 incomplete:
227 {
228 size_t k = nstate;
229 /* Here 0 <= k < m < 4. */
230 pstate[++k] = s[0];
231 if (k < m)
232 {
233 pstate[++k] = s[1];
234 if (k < m)
235 pstate[++k] = s[2];
236 }
237 if (k != m)
238 abort ();
239 }
240 pstate[0] = m;
241 return (size_t)(-2);
242
243 invalid:
244 errno = EILSEQ;
245 /* The conversion state is undefined, says POSIX. */
246 return (size_t)(-1);
247 }
248 else
249 {
250 wchar_t wc;
251 size_t ret = mbrtowc (&wc, s, n, ps);
252 if (ret < (size_t) -2 && pwc != NULL)
253 *pwc = wc;
254 return ret;
255 }
256
257# else
258
259 /* char32_t and wchar_t are equivalent. Use mbrtowc(). */
260 wchar_t wc;
261 size_t ret = mbrtowc (&wc, s, n, ps);
262
263# if GNULIB_MBRTOC32_REGULAR
264 /* Ensure that mbrtoc32 is regular. */
265 if (ret < (size_t) -2 && ! mbsinit (ps))
266 /* This occurs on glibc 2.12. */
267 mbszero (ps);
268# endif
269
270# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
271 if (ret < (size_t) -2 && wc != 0)
272 {
273 wc = locale_encoding_to_unicode (wc);
274 if (wc == 0)
275 {
276 ret = (size_t) -1;
277 errno = EILSEQ;
278 }
279 }
280# endif
281 if (ret < (size_t) -2 && pwc != NULL)
282 *pwc = wc;
283 return ret;
284
285# endif
286}
287
288#endif
diff --git a/gl/mbrtowc-impl-utf8.h b/gl/mbrtowc-impl-utf8.h
index 4fdd65d8..ad96ca84 100644
--- a/gl/mbrtowc-impl-utf8.h
+++ b/gl/mbrtowc-impl-utf8.h
@@ -1,5 +1,5 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999-2002, 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/mbrtowc-impl.h b/gl/mbrtowc-impl.h
index e9c04ed7..21a3998c 100644
--- a/gl/mbrtowc-impl.h
+++ b/gl/mbrtowc-impl.h
@@ -1,5 +1,5 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999-2002, 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -41,8 +41,6 @@
41 char buf[4]; 41 char buf[4];
42 const char *p; 42 const char *p;
43 size_t m; 43 size_t m;
44 enc_t enc;
45 int res;
46 44
47 switch (nstate) 45 switch (nstate)
48 { 46 {
@@ -75,7 +73,8 @@
75 73
76 /* Here m > 0. */ 74 /* Here m > 0. */
77 75
78 enc = locale_encoding_classification (); 76 enc_t enc = locale_encoding_classification ();
77 int res;
79 78
80 if (enc == enc_utf8) /* UTF-8 */ 79 if (enc == enc_utf8) /* UTF-8 */
81 { 80 {
@@ -89,17 +88,19 @@
89 { 88 {
90 /* The hidden internal state of mbtowc would make this function not 89 /* The hidden internal state of mbtowc would make this function not
91 multi-thread safe. Achieve multi-thread safety through a lock. */ 90 multi-thread safe. Achieve multi-thread safety through a lock. */
92 wchar_t wc; 91 {
93 res = mbtowc_with_lock (&wc, p, m); 92 wchar_t wc;
93 res = mbtowc_with_lock (&wc, p, m);
94 94
95 if (res >= 0) 95 if (res >= 0)
96 { 96 {
97 if ((wc == 0) != (res == 0)) 97 if ((wc == 0) != (res == 0))
98 abort (); 98 abort ();
99 if (pwc != NULL) 99 if (pwc != NULL)
100 *pwc = wc; 100 *pwc = wc;
101 goto success; 101 goto success;
102 } 102 }
103 }
103 104
104 /* mbtowc does not distinguish between invalid and incomplete multibyte 105 /* mbtowc does not distinguish between invalid and incomplete multibyte
105 sequences. But mbrtowc needs to make this distinction. 106 sequences. But mbrtowc needs to make this distinction.
diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c
index c1a689a2..49831706 100644
--- a/gl/mbrtowc.c
+++ b/gl/mbrtowc.c
@@ -1,5 +1,5 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999-2002, 2005-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -28,7 +28,11 @@
28# include <stdint.h> 28# include <stdint.h>
29# include <stdlib.h> 29# include <stdlib.h>
30 30
31# if defined _WIN32 && !defined __CYGWIN__ 31# if AVOID_ANY_THREADS
32
33/* The option '--disable-threads' explicitly requests no locking. */
34
35# elif defined _WIN32 && !defined __CYGWIN__
32 36
33# define WIN32_LEAN_AND_MEAN /* avoid including junk */ 37# define WIN32_LEAN_AND_MEAN /* avoid including junk */
34# include <windows.h> 38# include <windows.h>
@@ -77,10 +81,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
77size_t 81size_t
78rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) 82rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
79{ 83{
80 size_t ret; 84# if MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
81 wchar_t wc;
82
83# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
84 if (s == NULL) 85 if (s == NULL)
85 { 86 {
86 pwc = NULL; 87 pwc = NULL;
@@ -94,6 +95,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
94 return (size_t) -2; 95 return (size_t) -2;
95# endif 96# endif
96 97
98 wchar_t wc;
97 if (! pwc) 99 if (! pwc)
98 pwc = &wc; 100 pwc = &wc;
99 101
@@ -112,7 +114,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
112 size_t count = 0; 114 size_t count = 0;
113 for (; n > 0; s++, n--) 115 for (; n > 0; s++, n--)
114 { 116 {
115 ret = mbrtowc (&wc, s, 1, ps); 117 size_t ret = mbrtowc (&wc, s, 1, ps);
116 118
117 if (ret == (size_t)(-1)) 119 if (ret == (size_t)(-1))
118 return (size_t)(-1); 120 return (size_t)(-1);
@@ -129,6 +131,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
129 } 131 }
130# endif 132# endif
131 133
134 size_t ret;
132# if MBRTOWC_STORES_INCOMPLETE_BUG 135# if MBRTOWC_STORES_INCOMPLETE_BUG
133 ret = mbrtowc (&wc, s, n, ps); 136 ret = mbrtowc (&wc, s, n, ps);
134 if (ret < (size_t) -2 && pwc != NULL) 137 if (ret < (size_t) -2 && pwc != NULL)
diff --git a/gl/mbsinit.c b/gl/mbsinit.c
index 6e600798..6252aa7a 100644
--- a/gl/mbsinit.c
+++ b/gl/mbsinit.c
@@ -1,5 +1,5 @@
1/* Test for initial conversion state. 1/* Test for initial conversion state.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -36,7 +36,7 @@
36 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. 36 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
37 See mbrtowc.c. 37 See mbrtowc.c.
38 - In wc -> mb direction, mbstate_t contains no information. In other 38 - In wc -> mb direction, mbstate_t contains no information. In other
39 words, it is always in the initial state. */ 39 words, it is always in an initial state. */
40 40
41static_assert (sizeof (mbstate_t) >= 4); 41static_assert (sizeof (mbstate_t) >= 4);
42 42
diff --git a/gl/mbsnlen.c b/gl/mbsnlen.c
new file mode 100644
index 00000000..bcca569b
--- /dev/null
+++ b/gl/mbsnlen.c
@@ -0,0 +1,60 @@
1/* Counting the multibyte characters in a string.
2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2007.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <string.h>
22
23#include <stdlib.h>
24
25#if GNULIB_MCEL_PREFER
26# include "mcel.h"
27#else
28# include "mbiterf.h"
29#endif
30
31/* Return the number of multibyte characters in the character string starting
32 at STRING and ending at STRING + LEN. */
33size_t
34mbsnlen (const char *string, size_t len)
35{
36 if (MB_CUR_MAX > 1)
37 {
38 size_t count = 0;
39
40 const char *string_end = string + len;
41
42#if GNULIB_MCEL_PREFER
43 for (; string < string_end; string += mcel_scan (string, string_end).len)
44 count++;
45#else
46 mbif_state_t state;
47 const char *iter;
48 for (mbif_init (state), iter = string; mbif_avail (state, iter, string_end); )
49 {
50 mbchar_t cur = mbif_next (state, iter, string_end);
51 count++;
52 iter += mb_len (cur);
53 }
54#endif
55
56 return count;
57 }
58 else
59 return len;
60}
diff --git a/gl/mbszero.c b/gl/mbszero.c
new file mode 100644
index 00000000..b63b2c04
--- /dev/null
+++ b/gl/mbszero.c
@@ -0,0 +1,23 @@
1/* Put an mbstate_t into an initial conversion state.
2 Copyright (C) 2023-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
18
19#include <config.h>
20
21#define IN_MBSZERO
22/* Specification and implementation. */
23#include <wchar.h>
diff --git a/gl/mbtowc-impl.h b/gl/mbtowc-impl.h
index 39b977be..c6d61968 100644
--- a/gl/mbtowc-impl.h
+++ b/gl/mbtowc-impl.h
@@ -1,5 +1,5 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -27,11 +27,10 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
27 else 27 else
28 { 28 {
29 mbstate_t state; 29 mbstate_t state;
30 wchar_t wc; 30 mbszero (&state);
31 size_t result;
32 31
33 memset (&state, 0, sizeof (mbstate_t)); 32 wchar_t wc;
34 result = mbrtowc (&wc, s, n, &state); 33 size_t result = mbrtowc (&wc, s, n, &state);
35 if (result == (size_t)-1 || result == (size_t)-2) 34 if (result == (size_t)-1 || result == (size_t)-2)
36 { 35 {
37 errno = EILSEQ; 36 errno = EILSEQ;
diff --git a/gl/mbtowc-lock.c b/gl/mbtowc-lock.c
index 6ca6e10f..14106188 100644
--- a/gl/mbtowc-lock.c
+++ b/gl/mbtowc-lock.c
@@ -1,5 +1,5 @@
1/* Return the internal lock used by mbrtowc and mbrtoc32. 1/* Return the internal lock used by mbrtowc and mbrtoc32.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc. 2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -18,9 +18,10 @@
18 18
19#include <config.h> 19#include <config.h>
20 20
21/* The option '--disable-threads' explicitly requests no locking. */
21/* When it is known that the gl_get_mbtowc_lock function is defined 22/* When it is known that the gl_get_mbtowc_lock function is defined
22 by a dependency library, it should not be defined here. */ 23 by a dependency library, it should not be defined here. */
23#if OMIT_MBTOWC_LOCK 24#if AVOID_ANY_THREADS || OMIT_MBTOWC_LOCK
24 25
25/* This declaration is solely to ensure that after preprocessing 26/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */ 27 this file is never empty. */
@@ -37,14 +38,14 @@ typedef int dummy;
37 38
38/* Macro for exporting a symbol (function, not variable) defined in this file, 39/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */ 40 when compiled into a shared library. */
40# ifndef DLL_EXPORTED 41# ifndef SHLIB_EXPORTED
41# if HAVE_VISIBILITY 42# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */ 43 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default"))) 44# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__ 45# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport) 46# define SHLIB_EXPORTED __declspec(dllexport)
46# else 47# else
47# define DLL_EXPORTED 48# define SHLIB_EXPORTED
48# endif 49# endif
49# endif 50# endif
50 51
@@ -59,7 +60,7 @@ typedef int dummy;
59 because the latter is not guaranteed to be a stable ABI in the future. */ 60 because the latter is not guaranteed to be a stable ABI in the future. */
60 61
61/* Make sure the function gets exported from DLLs. */ 62/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void); 63SHLIB_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
63 64
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; 65static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock; 66static CRITICAL_SECTION lock;
@@ -96,7 +97,7 @@ gl_get_mbtowc_lock (void)
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 97static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97 98
98/* Make sure the function gets exported from shared libraries. */ 99/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void); 100SHLIB_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
100 101
101/* Returns the internal lock used by mbrtowc and mbrtoc32. */ 102/* Returns the internal lock used by mbrtowc and mbrtoc32. */
102pthread_mutex_t * 103pthread_mutex_t *
@@ -123,7 +124,7 @@ atomic_init (void)
123} 124}
124 125
125/* Make sure the function gets exported from shared libraries. */ 126/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void); 127SHLIB_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
127 128
128/* Returns the internal lock used by mbrtowc and mbrtoc32. */ 129/* Returns the internal lock used by mbrtowc and mbrtoc32. */
129mtx_t * 130mtx_t *
diff --git a/gl/mbtowc-lock.h b/gl/mbtowc-lock.h
index 2dc22ace..b3e4e28e 100644
--- a/gl/mbtowc-lock.h
+++ b/gl/mbtowc-lock.h
@@ -1,5 +1,5 @@
1/* Use the internal lock used by mbrtowc and mbrtoc32. 1/* Use the internal lock used by mbrtowc and mbrtoc32.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc. 2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -21,9 +21,9 @@
21static inline int 21static inline int
22mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m) 22mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
23{ 23{
24 /* Put the hidden internal state of mbtowc into its initial state. 24 /* Put the hidden internal state of mbtowc into an initial state.
25 This is needed at least with glibc, uClibc, and MSVC CRT. 25 This is needed at least with glibc, uClibc, and MSVC CRT.
26 See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>. */ 26 See <https://sourceware.org/PR9674>. */
27 mbtowc (NULL, NULL, 0); 27 mbtowc (NULL, NULL, 0);
28 28
29 return mbtowc (pwc, p, m); 29 return mbtowc (pwc, p, m);
@@ -32,7 +32,7 @@ mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
32/* Prohibit renaming this symbol. */ 32/* Prohibit renaming this symbol. */
33#undef gl_get_mbtowc_lock 33#undef gl_get_mbtowc_lock
34 34
35#if GNULIB_MBRTOWC_SINGLE_THREAD 35#if AVOID_ANY_THREADS || GNULIB_MBRTOWC_SINGLE_THREAD
36 36
37/* All uses of this function are in a single thread. No locking needed. */ 37/* All uses of this function are in a single thread. No locking needed. */
38 38
@@ -50,16 +50,15 @@ static int
50mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m) 50mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
51{ 51{
52 CRITICAL_SECTION *lock = gl_get_mbtowc_lock (); 52 CRITICAL_SECTION *lock = gl_get_mbtowc_lock ();
53 int ret;
54 53
55 EnterCriticalSection (lock); 54 EnterCriticalSection (lock);
56 ret = mbtowc_unlocked (pwc, p, m); 55 int ret = mbtowc_unlocked (pwc, p, m);
57 LeaveCriticalSection (lock); 56 LeaveCriticalSection (lock);
58 57
59 return ret; 58 return ret;
60} 59}
61 60
62#elif HAVE_PTHREAD_API /* AIX, IRIX, Cygwin */ 61#elif HAVE_PTHREAD_API /* AIX, Cygwin */
63 62
64extern 63extern
65# if defined _WIN32 || defined __CYGWIN__ 64# if defined _WIN32 || defined __CYGWIN__
@@ -67,7 +66,7 @@ extern
67# endif 66# endif
68 pthread_mutex_t *gl_get_mbtowc_lock (void); 67 pthread_mutex_t *gl_get_mbtowc_lock (void);
69 68
70# if HAVE_WEAK_SYMBOLS /* IRIX */ 69# if HAVE_WEAK_SYMBOLS
71 70
72 /* Avoid the need to link with '-lpthread'. */ 71 /* Avoid the need to link with '-lpthread'. */
73# pragma weak pthread_mutex_lock 72# pragma weak pthread_mutex_lock
@@ -89,11 +88,10 @@ mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
89 if (pthread_in_use()) 88 if (pthread_in_use())
90 { 89 {
91 pthread_mutex_t *lock = gl_get_mbtowc_lock (); 90 pthread_mutex_t *lock = gl_get_mbtowc_lock ();
92 int ret;
93 91
94 if (pthread_mutex_lock (lock)) 92 if (pthread_mutex_lock (lock))
95 abort (); 93 abort ();
96 ret = mbtowc_unlocked (pwc, p, m); 94 int ret = mbtowc_unlocked (pwc, p, m);
97 if (pthread_mutex_unlock (lock)) 95 if (pthread_mutex_unlock (lock))
98 abort (); 96 abort ();
99 97
@@ -111,11 +109,10 @@ static int
111mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m) 109mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
112{ 110{
113 mtx_t *lock = gl_get_mbtowc_lock (); 111 mtx_t *lock = gl_get_mbtowc_lock ();
114 int ret;
115 112
116 if (mtx_lock (lock) != thrd_success) 113 if (mtx_lock (lock) != thrd_success)
117 abort (); 114 abort ();
118 ret = mbtowc_unlocked (pwc, p, m); 115 int ret = mbtowc_unlocked (pwc, p, m);
119 if (mtx_unlock (lock) != thrd_success) 116 if (mtx_unlock (lock) != thrd_success)
120 abort (); 117 abort ();
121 118
diff --git a/gl/mbtowc.c b/gl/mbtowc.c
index 8d9b06d2..2f30b9fb 100644
--- a/gl/mbtowc.c
+++ b/gl/mbtowc.c
@@ -1,5 +1,5 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
diff --git a/gl/memchr.c b/gl/memchr.c
index 8e955793..6adac7e1 100644
--- a/gl/memchr.c
+++ b/gl/memchr.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2023 1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2026
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 3
4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se), 4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
@@ -65,105 +65,103 @@ __memchr (void const *s, int c_in, size_t n)
65 performance. */ 65 performance. */
66 typedef unsigned long int longword; 66 typedef unsigned long int longword;
67 67
68 const unsigned char *char_ptr; 68 unsigned reg_char c = (unsigned char) c_in;
69 const longword *longword_ptr;
70 longword repeated_one;
71 longword repeated_c;
72 unsigned reg_char c;
73 69
74 c = (unsigned char) c_in; 70 const longword *longword_ptr;
75 71
76 /* Handle the first few bytes by reading one byte at a time. 72 /* Handle the first few bytes by reading one byte at a time.
77 Do this until CHAR_PTR is aligned on a longword boundary. */ 73 Do this until CHAR_PTR is aligned on a longword boundary. */
78 for (char_ptr = (const unsigned char *) s; 74 {
79 n > 0 && (size_t) char_ptr % sizeof (longword) != 0; 75 const unsigned char *char_ptr;
80 --n, ++char_ptr) 76 for (char_ptr = (const unsigned char *) s;
81 if (*char_ptr == c) 77 n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
82 return (void *) char_ptr; 78 --n, ++char_ptr)
79 if (*char_ptr == c)
80 return (void *) char_ptr;
83 81
84 longword_ptr = (const longword *) char_ptr; 82 longword_ptr = (const longword *) char_ptr;
83 }
85 84
86 /* All these elucidatory comments refer to 4-byte longwords, 85 /* All these elucidatory comments refer to 4-byte longwords,
87 but the theory applies equally well to any size longwords. */ 86 but the theory applies equally well to any size longwords. */
88 87 {
89 /* Compute auxiliary longword values: 88 /* Compute auxiliary longword values:
90 repeated_one is a value which has a 1 in every byte. 89 repeated_one is a value which has a 1 in every byte.
91 repeated_c has c in every byte. */ 90 repeated_c has c in every byte. */
92 repeated_one = 0x01010101; 91 longword repeated_one = 0x01010101;
93 repeated_c = c | (c << 8); 92 longword repeated_c = c | (c << 8);
94 repeated_c |= repeated_c << 16; 93 repeated_c |= repeated_c << 16;
95 if (0xffffffffU < (longword) -1) 94 if (0xffffffffU < (longword) -1)
96 { 95 {
97 repeated_one |= repeated_one << 31 << 1; 96 repeated_one |= repeated_one << 31 << 1;
98 repeated_c |= repeated_c << 31 << 1; 97 repeated_c |= repeated_c << 31 << 1;
99 if (8 < sizeof (longword)) 98 if (8 < sizeof (longword))
100 { 99 for (size_t i = 64; i < sizeof (longword) * 8; i *= 2)
101 size_t i;
102
103 for (i = 64; i < sizeof (longword) * 8; i *= 2)
104 { 100 {
105 repeated_one |= repeated_one << i; 101 repeated_one |= repeated_one << i;
106 repeated_c |= repeated_c << i; 102 repeated_c |= repeated_c << i;
107 } 103 }
108 } 104 }
109 } 105
110 106 /* Instead of the traditional loop which tests each byte, we will test a
111 /* Instead of the traditional loop which tests each byte, we will test a 107 longword at a time. The tricky part is testing if *any of the four*
112 longword at a time. The tricky part is testing if *any of the four* 108 bytes in the longword in question are equal to c. We first use an xor
113 bytes in the longword in question are equal to c. We first use an xor 109 with repeated_c. This reduces the task to testing whether *any of the
114 with repeated_c. This reduces the task to testing whether *any of the 110 four* bytes in longword1 is zero.
115 four* bytes in longword1 is zero. 111
116 112 We compute tmp =
117 We compute tmp = 113 ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
118 ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). 114 That is, we perform the following operations:
119 That is, we perform the following operations: 115 1. Subtract repeated_one.
120 1. Subtract repeated_one. 116 2. & ~longword1.
121 2. & ~longword1. 117 3. & a mask consisting of 0x80 in every byte.
122 3. & a mask consisting of 0x80 in every byte. 118 Consider what happens in each byte:
123 Consider what happens in each byte: 119 - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
124 - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, 120 and step 3 transforms it into 0x80. A carry can also be propagated
125 and step 3 transforms it into 0x80. A carry can also be propagated 121 to more significant bytes.
126 to more significant bytes. 122 - If a byte of longword1 is nonzero, let its lowest 1 bit be at
127 - If a byte of longword1 is nonzero, let its lowest 1 bit be at 123 position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
128 position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, 124 the byte ends in a single bit of value 0 and k bits of value 1.
129 the byte ends in a single bit of value 0 and k bits of value 1. 125 After step 2, the result is just k bits of value 1: 2^k - 1. After
130 After step 2, the result is just k bits of value 1: 2^k - 1. After 126 step 3, the result is 0. And no carry is produced.
131 step 3, the result is 0. And no carry is produced. 127 So, if longword1 has only non-zero bytes, tmp is zero.
132 So, if longword1 has only non-zero bytes, tmp is zero. 128 Whereas if longword1 has a zero byte, call j the position of the least
133 Whereas if longword1 has a zero byte, call j the position of the least 129 significant zero byte. Then the result has a zero at positions 0, ...,
134 significant zero byte. Then the result has a zero at positions 0, ..., 130 j-1 and a 0x80 at position j. We cannot predict the result at the more
135 j-1 and a 0x80 at position j. We cannot predict the result at the more 131 significant bytes (positions j+1..3), but it does not matter since we
136 significant bytes (positions j+1..3), but it does not matter since we 132 already have a non-zero bit at position 8*j+7.
137 already have a non-zero bit at position 8*j+7. 133
138 134 So, the test whether any byte in longword1 is zero is equivalent to
139 So, the test whether any byte in longword1 is zero is equivalent to 135 testing whether tmp is nonzero. */
140 testing whether tmp is nonzero. */ 136
141 137 while (n >= sizeof (longword))
142 while (n >= sizeof (longword)) 138 {
143 { 139 longword longword1 = *longword_ptr ^ repeated_c;
144 longword longword1 = *longword_ptr ^ repeated_c; 140
145 141 if ((((longword1 - repeated_one) & ~longword1)
146 if ((((longword1 - repeated_one) & ~longword1) 142 & (repeated_one << 7)) != 0)
147 & (repeated_one << 7)) != 0) 143 break;
148 break; 144 longword_ptr++;
149 longword_ptr++; 145 n -= sizeof (longword);
150 n -= sizeof (longword); 146 }
151 } 147 }
152 148
153 char_ptr = (const unsigned char *) longword_ptr; 149 {
154 150 const unsigned char *char_ptr = (const unsigned char *) longword_ptr;
155 /* At this point, we know that either n < sizeof (longword), or one of the 151
156 sizeof (longword) bytes starting at char_ptr is == c. On little-endian 152 /* At this point, we know that either n < sizeof (longword), or one of the
157 machines, we could determine the first such byte without any further 153 sizeof (longword) bytes starting at char_ptr is == c. On little-endian
158 memory accesses, just by looking at the tmp result from the last loop 154 machines, we could determine the first such byte without any further
159 iteration. But this does not work on big-endian machines. Choose code 155 memory accesses, just by looking at the tmp result from the last loop
160 that works in both cases. */ 156 iteration. But this does not work on big-endian machines. Choose code
161 157 that works in both cases. */
162 for (; n > 0; --n, ++char_ptr) 158
163 { 159 for (; n > 0; --n, ++char_ptr)
164 if (*char_ptr == c) 160 {
165 return (void *) char_ptr; 161 if (*char_ptr == c)
166 } 162 return (void *) char_ptr;
163 }
164 }
167 165
168 return NULL; 166 return NULL;
169} 167}
diff --git a/gl/memchr.valgrind b/gl/memchr.valgrind
index 97690f2c..7ab1f6ff 100644
--- a/gl/memchr.valgrind
+++ b/gl/memchr.valgrind
@@ -1,6 +1,6 @@
1# Suppress a valgrind message about use of uninitialized memory in memchr(). 1# Suppress a valgrind message about use of uninitialized memory in memchr().
2 2
3# Copyright (C) 2009-2023 Free Software Foundation, Inc. 3# Copyright (C) 2009-2026 Free Software Foundation, Inc.
4# 4#
5# This file is free software: you can redistribute it and/or modify 5# This file is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as 6# it under the terms of the GNU Lesser General Public License as
diff --git a/gl/minmax.h b/gl/minmax.h
index 1fbfc661..fd731fb7 100644
--- a/gl/minmax.h
+++ b/gl/minmax.h
@@ -1,5 +1,5 @@
1/* MIN, MAX macros. 1/* MIN, MAX macros.
2 Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2023 Free Software 2 Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2026 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -19,10 +19,15 @@
19#define _MINMAX_H 19#define _MINMAX_H
20 20
21/* Note: MIN, MAX are also defined in <sys/param.h> on some systems 21/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
22 (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about 22 (glibc, HP-UX). Therefore you might get warnings about MIN, MAX
23 MIN, MAX macro redefinitions on some systems; the workaround is to 23 macro redefinitions on some systems; the workaround is to
24 #include this file as the last one among the #include list. */ 24 #include this file as the last one among the #include list. */
25 25
26/* This file uses HAVE_MINMAX_IN_LIMITS_H, HAVE_MINMAX_IN_SYS_PARAM_H. */
27#if !_GL_CONFIG_H_INCLUDED
28 #error "Please include config.h first."
29#endif
30
26/* Before we define the following symbols we get the <limits.h> file 31/* Before we define the following symbols we get the <limits.h> file
27 since otherwise we get redefinitions on some systems if <limits.h> is 32 since otherwise we get redefinitions on some systems if <limits.h> is
28 included after this file. Likewise for <sys/param.h>. 33 included after this file. Likewise for <sys/param.h>.
diff --git a/gl/mktime-internal.h b/gl/mktime-internal.h
index 709c36bd..6ccf651c 100644
--- a/gl/mktime-internal.h
+++ b/gl/mktime-internal.h
@@ -1,5 +1,5 @@
1/* Internals of mktime and related functions 1/* Internals of mktime and related functions
2 Copyright 2016-2023 Free Software Foundation, Inc. 2 Copyright 2016-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@cs.ucla.edu>. 4 Contributed by Paul Eggert <eggert@cs.ucla.edu>.
5 5
@@ -19,6 +19,9 @@
19 19
20#ifndef _LIBC 20#ifndef _LIBC
21# include <time.h> 21# include <time.h>
22# define __libc_lock_lock(lock) ((void) 0)
23# define __libc_lock_unlock(lock) ((void) 0)
24# define __tzset_unlocked() tzset ()
22#endif 25#endif
23 26
24/* mktime_offset_t is a signed type wide enough to hold a UTC offset 27/* mktime_offset_t is a signed type wide enough to hold a UTC offset
@@ -71,9 +74,10 @@ typedef int mktime_offset_t;
71#endif 74#endif
72 75
73/* Subroutine of mktime. Return the time_t representation of TP and 76/* Subroutine of mktime. Return the time_t representation of TP and
74 normalize TP, given that a struct tm * maps to a time_t as performed 77 normalize TP, given that a struct tm * maps to a time_t. If
75 by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ 78 LOCAL, the mapping is performed by localtime_r, otherwise by gmtime_r.
76extern __time64_t __mktime_internal (struct tm *tp, 79 Record next guess for localtime-gmtime offset in *OFFSET.
77 struct tm *(*func) (__time64_t const *, 80
78 struct tm *), 81 If _LIBC, the caller must lock __tzset_lock. */
82extern __time64_t __mktime_internal (struct tm *tp, bool local,
79 mktime_offset_t *offset) attribute_hidden; 83 mktime_offset_t *offset) attribute_hidden;
diff --git a/gl/mktime.c b/gl/mktime.c
index 94a4320e..c56c6f9a 100644
--- a/gl/mktime.c
+++ b/gl/mktime.c
@@ -1,5 +1,5 @@
1/* Convert a 'struct tm' to a time_t value. 1/* Convert a 'struct tm' to a time_t value.
2 Copyright (C) 1993-2023 Free Software Foundation, Inc. 2 Copyright (C) 1993-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@twinsun.com>. 4 Contributed by Paul Eggert <eggert@twinsun.com>.
5 5
@@ -46,11 +46,11 @@
46#include <errno.h> 46#include <errno.h>
47#include <limits.h> 47#include <limits.h>
48#include <stdbool.h> 48#include <stdbool.h>
49#include <stdckdint.h>
49#include <stdlib.h> 50#include <stdlib.h>
50#include <string.h> 51#include <string.h>
51 52
52#include <intprops.h> 53#include <intprops.h>
53#include <verify.h>
54 54
55#ifndef NEED_MKTIME_INTERNAL 55#ifndef NEED_MKTIME_INTERNAL
56# define NEED_MKTIME_INTERNAL 0 56# define NEED_MKTIME_INTERNAL 0
@@ -62,6 +62,9 @@
62# define NEED_MKTIME_WORKING 0 62# define NEED_MKTIME_WORKING 0
63#endif 63#endif
64 64
65#ifdef _LIBC
66# include <tzset.h>
67#endif
65#include "mktime-internal.h" 68#include "mktime-internal.h"
66 69
67#if !defined _LIBC && (NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS) 70#if !defined _LIBC && (NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS)
@@ -98,8 +101,8 @@ my_tzset (void)
98 tzset (); 101 tzset ();
99# endif 102# endif
100} 103}
101# undef __tzset 104# undef tzset
102# define __tzset() my_tzset () 105# define tzset() my_tzset ()
103#endif 106#endif
104 107
105#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL 108#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL
@@ -118,12 +121,12 @@ my_tzset (void)
118 __time64_t values that mktime can generate even on platforms where 121 __time64_t values that mktime can generate even on platforms where
119 __time64_t is wider than the int components of struct tm. */ 122 __time64_t is wider than the int components of struct tm. */
120 123
121#if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60 124# if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60
122typedef long int long_int; 125typedef long int long_int;
123#else 126# else
124typedef long long int long_int; 127typedef long long int long_int;
125#endif 128# endif
126verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60); 129static_assert (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60);
127 130
128/* Shift A right by B bits portably, by dividing A by 2**B and 131/* Shift A right by B bits portably, by dividing A by 2**B and
129 truncating towards minus infinity. B should be in the range 0 <= B 132 truncating towards minus infinity. B should be in the range 0 <= B
@@ -154,9 +157,9 @@ static long_int const mktime_max
154 = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t) 157 = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t)
155 ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t)); 158 ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t));
156 159
157#define EPOCH_YEAR 1970 160# define EPOCH_YEAR 1970
158#define TM_YEAR_BASE 1900 161# define TM_YEAR_BASE 1900
159verify (TM_YEAR_BASE % 100 == 0); 162static_assert (TM_YEAR_BASE % 100 == 0);
160 163
161/* Is YEAR + TM_YEAR_BASE a leap year? */ 164/* Is YEAR + TM_YEAR_BASE a leap year? */
162static bool 165static bool
@@ -171,9 +174,9 @@ leapyear (long_int year)
171} 174}
172 175
173/* How many days come before each month (0-12). */ 176/* How many days come before each month (0-12). */
174#ifndef _LIBC 177# ifndef _LIBC
175static 178static
176#endif 179# endif
177const unsigned short int __mon_yday[2][13] = 180const unsigned short int __mon_yday[2][13] =
178 { 181 {
179 /* Normal years. */ 182 /* Normal years. */
@@ -205,7 +208,7 @@ static long_int
205ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, 208ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
206 int year0, int yday0, int hour0, int min0, int sec0) 209 int year0, int yday0, int hour0, int min0, int sec0)
207{ 210{
208 verify (-1 / 2 == 0); 211 static_assert (-1 / 2 == 0);
209 212
210 /* Compute intervening leap days correctly even if year is negative. 213 /* Compute intervening leap days correctly even if year is negative.
211 Take care to avoid integer overflow here. */ 214 Take care to avoid integer overflow here. */
@@ -250,29 +253,34 @@ tm_diff (long_int year, long_int yday, int hour, int min, int sec,
250 tp->tm_hour, tp->tm_min, tp->tm_sec); 253 tp->tm_hour, tp->tm_min, tp->tm_sec);
251} 254}
252 255
253/* Use CONVERT to convert T to a struct tm value in *TM. T must be in 256#ifndef _LIBC
254 range for __time64_t. Return TM if successful, NULL (setting errno) on 257/* Convert T to a struct tm value in *TM. Use localtime64_r if LOCAL,
255 failure. */ 258 otherwise gmtime64_r. T must be in range for __time64_t. Return
259 TM if successful, NULL (setting errno) on failure. */
256static struct tm * 260static struct tm *
257convert_time (struct tm *(*convert) (const __time64_t *, struct tm *), 261convert_time (long_int t, bool local, struct tm *tm)
258 long_int t, struct tm *tm)
259{ 262{
260 __time64_t x = t; 263 __time64_t x = t;
261 return convert (&x, tm); 264 if (local)
265 return __localtime64_r (&x, tm);
266 else
267 return __gmtime64_r (&x, tm);
262} 268}
269# define __tz_convert convert_time
270#endif
263 271
264/* Use CONVERT to convert *T to a broken down time in *TP. 272/* Convert *T to a broken down time in *TP (as if by localtime if
265 If *T is out of range for conversion, adjust it so that 273 LOCAL, otherwise as if by gmtime). If *T is out of range for
266 it is the nearest in-range value and then convert that. 274 conversion, adjust it so that it is the nearest in-range value and
267 A value is in range if it fits in both __time64_t and long_int. 275 then convert that. A value is in range if it fits in both
268 Return TP on success, NULL (setting errno) on failure. */ 276 __time64_t and long_int. Return TP on success, NULL (setting
277 errno) on failure. */
269static struct tm * 278static struct tm *
270ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), 279ranged_convert (bool local, long_int *t, struct tm *tp)
271 long_int *t, struct tm *tp)
272{ 280{
273 long_int t1 = (*t < mktime_min ? mktime_min 281 long_int t1 = (*t < mktime_min ? mktime_min
274 : *t <= mktime_max ? *t : mktime_max); 282 : *t <= mktime_max ? *t : mktime_max);
275 struct tm *r = convert_time (convert, t1, tp); 283 struct tm *r = __tz_convert (t1, local, tp);
276 if (r) 284 if (r)
277 { 285 {
278 *t = t1; 286 *t = t1;
@@ -293,7 +301,7 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
293 long_int mid = long_int_avg (ok, bad); 301 long_int mid = long_int_avg (ok, bad);
294 if (mid == ok || mid == bad) 302 if (mid == ok || mid == bad)
295 break; 303 break;
296 if (convert_time (convert, mid, tp)) 304 if (__tz_convert (mid, local, tp))
297 ok = mid, oktm = *tp; 305 ok = mid, oktm = *tp;
298 else if (errno != EOVERFLOW) 306 else if (errno != EOVERFLOW)
299 return NULL; 307 return NULL;
@@ -309,29 +317,38 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
309} 317}
310 318
311 319
312/* Convert *TP to a __time64_t value, inverting 320/* Convert *TP to a __time64_t value. If LOCAL, the reverse mapping
313 the monotonic and mostly-unit-linear conversion function CONVERT. 321 is performed as if localtime, otherwise as if by gmtime. Use
314 Use *OFFSET to keep track of a guess at the offset of the result, 322 *OFFSET to keep track of a guess at the offset of the result,
315 compared to what the result would be for UTC without leap seconds. 323 compared to what the result would be for UTC without leap seconds.
316 If *OFFSET's guess is correct, only one CONVERT call is needed. 324 If *OFFSET's guess is correct, only one reverse mapping call is
317 If successful, set *TP to the canonicalized struct tm; 325 needed. If successful, set *TP to the canonicalized struct tm;
318 otherwise leave *TP alone, return ((time_t) -1) and set errno. 326 otherwise leave *TP alone, return ((time_t) -1) and set errno.
319 This function is external because it is used also by timegm.c. */ 327 This function is external because it is used also by timegm.c.
328
329 If _LIBC, the caller must lock __tzset_lock. */
320__time64_t 330__time64_t
321__mktime_internal (struct tm *tp, 331__mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset)
322 struct tm *(*convert) (const __time64_t *, struct tm *),
323 mktime_offset_t *offset)
324{ 332{
325 struct tm tm; 333 struct tm tm;
326 334
327 /* The maximum number of probes (calls to CONVERT) should be enough 335 /* The maximum number of probes should be enough to handle any
328 to handle any combinations of time zone rule changes, solar time, 336 combinations of time zone rule changes, solar time, leap seconds,
329 leap seconds, and oscillations around a spring-forward gap. 337 and oscillations around a spring-forward gap. POSIX.1 prohibits
330 POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ 338 leap seconds, but some hosts have them anyway. */
331 int remaining_probes = 6; 339 int remaining_probes = 6;
332 340
333 /* Time requested. Copy it in case CONVERT modifies *TP; this can 341#ifndef _LIBC
334 occur if TP is localtime's returned value and CONVERT is localtime. */ 342 /* Gnulib mktime doesn't lock the tz state, so it may need to probe
343 more often if some other thread changes local time while
344 __mktime_internal is probing. Double the number of probes; this
345 should suffice for practical cases that are at all likely. */
346 remaining_probes *= 2;
347#endif
348
349 /* Time requested. Copy it in case gmtime/localtime modify *TP;
350 this can occur if TP is localtime's returned value and CONVERT is
351 localtime. */
335 int sec = tp->tm_sec; 352 int sec = tp->tm_sec;
336 int min = tp->tm_min; 353 int min = tp->tm_min;
337 int hour = tp->tm_hour; 354 int hour = tp->tm_hour;
@@ -340,8 +357,8 @@ __mktime_internal (struct tm *tp,
340 int year_requested = tp->tm_year; 357 int year_requested = tp->tm_year;
341 int isdst = tp->tm_isdst; 358 int isdst = tp->tm_isdst;
342 359
343 /* 1 if the previous probe was DST. */ 360 /* True if the previous probe was DST. */
344 int dst2 = 0; 361 bool dst2 = false;
345 362
346 /* Ensure that mon is in range, and set year accordingly. */ 363 /* Ensure that mon is in range, and set year accordingly. */
347 int mon_remainder = mon % 12; 364 int mon_remainder = mon % 12;
@@ -379,7 +396,7 @@ __mktime_internal (struct tm *tp,
379 /* Invert CONVERT by probing. First assume the same offset as last 396 /* Invert CONVERT by probing. First assume the same offset as last
380 time. */ 397 time. */
381 398
382 INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess); 399 ckd_sub (&negative_offset_guess, 0, off);
383 long_int t0 = ydhms_diff (year, yday, hour, min, sec, 400 long_int t0 = ydhms_diff (year, yday, hour, min, sec,
384 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, 401 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0,
385 negative_offset_guess); 402 negative_offset_guess);
@@ -389,7 +406,7 @@ __mktime_internal (struct tm *tp,
389 406
390 while (true) 407 while (true)
391 { 408 {
392 if (! ranged_convert (convert, &t, &tm)) 409 if (! ranged_convert (local, &t, &tm))
393 return -1; 410 return -1;
394 long_int dt = tm_diff (year, yday, hour, min, sec, &tm); 411 long_int dt = tm_diff (year, yday, hour, min, sec, &tm);
395 if (dt == 0) 412 if (dt == 0)
@@ -430,13 +447,10 @@ __mktime_internal (struct tm *tp,
430 447
431 Heuristic: probe the adjacent timestamps in both directions, 448 Heuristic: probe the adjacent timestamps in both directions,
432 looking for the desired isdst. If none is found within a 449 looking for the desired isdst. If none is found within a
433 reasonable duration bound, assume a one-hour DST difference. 450 reasonable duration bound, ignore the disagreement.
434 This should work for all real time zone histories in the tz 451 This should work for all real time zone histories in the tz
435 database. */ 452 database. */
436 453
437 /* +1 if we wanted standard time but got DST, -1 if the reverse. */
438 int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
439
440 /* Distance between probes when looking for a DST boundary. In 454 /* Distance between probes when looking for a DST boundary. In
441 tzdata2003a, the shortest period of DST is 601200 seconds 455 tzdata2003a, the shortest period of DST is 601200 seconds
442 (e.g., America/Recife starting 2000-10-08 01:00), and the 456 (e.g., America/Recife starting 2000-10-08 01:00), and the
@@ -446,29 +460,23 @@ __mktime_internal (struct tm *tp,
446 periods when probing. */ 460 periods when probing. */
447 int stride = 601200; 461 int stride = 601200;
448 462
449 /* In TZDB 2021e, the longest period of DST (or of non-DST), in 463 /* Do not probe too far away from the requested time,
450 which the DST (or adjacent DST) difference is not one hour, 464 by striding until at least a year has passed, but then giving up.
451 is 457243209 seconds: e.g., America/Cambridge_Bay with leap 465 This helps avoid unexpected results in (for example) Asia/Kolkata,
452 seconds, starting 1965-10-31 00:00 in a switch from 466 for which today's users expect to see no DST even though it
453 double-daylight time (-05) to standard time (-07), and 467 did observe DST long ago. */
454 continuing to 1980-04-27 02:00 in a switch from standard time 468 int year_seconds_bound = 366 * 24 * 60 * 60 + 1;
455 (-07) to daylight time (-06). */ 469 int delta_bound = year_seconds_bound + stride;
456 int duration_max = 457243209; 470
457 471 /* Search in both directions, closest first. */
458 /* Search in both directions, so the maximum distance is half 472 for (int delta = stride; delta < delta_bound; delta += stride)
459 the duration; add the stride to avoid off-by-1 problems. */ 473 for (int direction = -1; direction <= 1; direction += 2)
460 int delta_bound = duration_max / 2 + stride;
461
462 int delta, direction;
463
464 for (delta = stride; delta < delta_bound; delta += stride)
465 for (direction = -1; direction <= 1; direction += 2)
466 { 474 {
467 long_int ot; 475 long_int ot;
468 if (! INT_ADD_WRAPV (t, delta * direction, &ot)) 476 if (! ckd_add (&ot, t, delta * direction))
469 { 477 {
470 struct tm otm; 478 struct tm otm;
471 if (! ranged_convert (convert, &ot, &otm)) 479 if (! ranged_convert (local, &ot, &otm))
472 return -1; 480 return -1;
473 if (! isdst_differ (isdst, otm.tm_isdst)) 481 if (! isdst_differ (isdst, otm.tm_isdst))
474 { 482 {
@@ -478,7 +486,7 @@ __mktime_internal (struct tm *tp,
478 &otm); 486 &otm);
479 if (mktime_min <= gt && gt <= mktime_max) 487 if (mktime_min <= gt && gt <= mktime_max)
480 { 488 {
481 if (convert_time (convert, gt, &tm)) 489 if (__tz_convert (gt, local, &tm))
482 { 490 {
483 t = gt; 491 t = gt;
484 goto offset_found; 492 goto offset_found;
@@ -490,21 +498,16 @@ __mktime_internal (struct tm *tp,
490 } 498 }
491 } 499 }
492 500
493 /* No unusual DST offset was found nearby. Assume one-hour DST. */ 501 /* No probe with the requested tm_isdst was found nearby.
494 t += 60 * 60 * dst_difference; 502 Ignore the requested tm_isdst. */
495 if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
496 goto offset_found;
497
498 __set_errno (EOVERFLOW);
499 return -1;
500 } 503 }
501 504
502 offset_found: 505 offset_found:
503 /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS. 506 /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS.
504 This is just a heuristic to speed up the next mktime call, and 507 This is just a heuristic to speed up the next mktime call, and
505 correctness is unaffected if integer overflow occurs here. */ 508 correctness is unaffected if integer overflow occurs here. */
506 INT_SUBTRACT_WRAPV (t, t0, offset); 509 ckd_sub (offset, t, t0);
507 INT_SUBTRACT_WRAPV (*offset, negative_offset_guess, offset); 510 ckd_sub (offset, *offset, negative_offset_guess);
508 511
509 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) 512 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
510 { 513 {
@@ -513,13 +516,13 @@ __mktime_internal (struct tm *tp,
513 long_int sec_adjustment = sec == 0 && tm.tm_sec == 60; 516 long_int sec_adjustment = sec == 0 && tm.tm_sec == 60;
514 sec_adjustment -= sec; 517 sec_adjustment -= sec;
515 sec_adjustment += sec_requested; 518 sec_adjustment += sec_requested;
516 if (INT_ADD_WRAPV (t, sec_adjustment, &t) 519 if (ckd_add (&t, t, sec_adjustment)
517 || ! (mktime_min <= t && t <= mktime_max)) 520 || ! (mktime_min <= t && t <= mktime_max))
518 { 521 {
519 __set_errno (EOVERFLOW); 522 __set_errno (EOVERFLOW);
520 return -1; 523 return -1;
521 } 524 }
522 if (! convert_time (convert, t, &tm)) 525 if (! __tz_convert (t, local, &tm))
523 return -1; 526 return -1;
524 } 527 }
525 528
@@ -535,18 +538,19 @@ __mktime_internal (struct tm *tp,
535__time64_t 538__time64_t
536__mktime64 (struct tm *tp) 539__mktime64 (struct tm *tp)
537{ 540{
538 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the 541 __libc_lock_lock (__tzset_lock);
539 time zone names contained in the external variable 'tzname' shall 542 __tzset_unlocked ();
540 be set as if the tzset() function had been called. */
541 __tzset ();
542 543
543# if defined _LIBC || NEED_MKTIME_WORKING 544# if defined _LIBC || NEED_MKTIME_WORKING
544 static mktime_offset_t localtime_offset; 545 static mktime_offset_t localtime_offset;
545 return __mktime_internal (tp, __localtime64_r, &localtime_offset); 546 __time64_t result = __mktime_internal (tp, true, &localtime_offset);
546# else 547# else
547# undef mktime 548# undef mktime
548 return mktime (tp); 549 __time64_t result = mktime (tp);
549# endif 550# endif
551
552 __libc_lock_unlock (__tzset_lock);
553 return result;
550} 554}
551#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ 555#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */
552 556
diff --git a/gl/mountlist.c b/gl/mountlist.c
index 6d384812..66b3f3d5 100644
--- a/gl/mountlist.c
+++ b/gl/mountlist.c
@@ -1,6 +1,6 @@
1/* mountlist.c -- return a list of mounted file systems 1/* mountlist.c -- return a list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1997-2023 Free Software Foundation, Inc. 3 Copyright (C) 1991-1992, 1997-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -19,20 +19,18 @@
19 19
20#include "mountlist.h" 20#include "mountlist.h"
21 21
22#include <errno.h>
23#include <fcntl.h>
22#include <limits.h> 24#include <limits.h>
23#include <stdio.h> 25#include <stdio.h>
24#include <stdlib.h> 26#include <stdlib.h>
25#include <string.h> 27#include <string.h>
26#include <stdint.h> 28#include <stdint.h>
29#include <unistd.h>
27 30
31#include "c-ctype.h"
28#include "xalloc.h" 32#include "xalloc.h"
29 33
30#include <errno.h>
31
32#include <fcntl.h>
33
34#include <unistd.h>
35
36#if HAVE_SYS_PARAM_H 34#if HAVE_SYS_PARAM_H
37# include <sys/param.h> 35# include <sys/param.h>
38#endif 36#endif
@@ -43,7 +41,7 @@
43# include <sys/sysmacros.h> 41# include <sys/sysmacros.h>
44#endif 42#endif
45 43
46#if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */ 44#if defined MOUNTED_GETFSSTAT /* (obsolete) Apple Darwin 1.3 */
47# if HAVE_SYS_UCRED_H 45# if HAVE_SYS_UCRED_H
48# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS, 46# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS,
49 NGROUPS is used as an array dimension in ucred.h */ 47 NGROUPS is used as an array dimension in ucred.h */
@@ -62,7 +60,7 @@
62# endif 60# endif
63#endif /* MOUNTED_GETFSSTAT */ 61#endif /* MOUNTED_GETFSSTAT */
64 62
65#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android, 63#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, Cygwin, Android,
66 also (obsolete) 4.3BSD, SunOS */ 64 also (obsolete) 4.3BSD, SunOS */
67# include <mntent.h> 65# include <mntent.h>
68# include <sys/types.h> 66# include <sys/types.h>
@@ -132,6 +130,10 @@
132# endif 130# endif
133#endif 131#endif
134 132
133#if defined _WIN32 && !defined __CYGWIN__
134# include <windows.h>
135#endif
136
135#ifndef HAVE_HASMNTOPT 137#ifndef HAVE_HASMNTOPT
136# define hasmntopt(mnt, opt) ((char *) 0) 138# define hasmntopt(mnt, opt) ((char *) 0)
137#endif 139#endif
@@ -154,43 +156,48 @@
154 156
155/* The results of opendir() in this file are not used with dirfd and fchdir, 157/* The results of opendir() in this file are not used with dirfd and fchdir,
156 therefore save some unnecessary work in fchdir.c. */ 158 therefore save some unnecessary work in fchdir.c. */
157#ifdef GNULIB_defined_opendir 159#ifdef GNULIB_defined_DIR
160# undef DIR
158# undef opendir 161# undef opendir
159#endif
160#ifdef GNULIB_defined_closedir
161# undef closedir 162# undef closedir
163# undef readdir
164#else
165# ifdef GNULIB_defined_opendir
166# undef opendir
167# endif
168# ifdef GNULIB_defined_closedir
169# undef closedir
170# endif
162#endif 171#endif
163 172
164#define ME_DUMMY_0(Fs_name, Fs_type) \ 173#define ME_DUMMY_0(Fs_name, Fs_type) \
165 (strcmp (Fs_type, "autofs") == 0 \ 174 (streq (Fs_type, "autofs") \
166 || strcmp (Fs_type, "proc") == 0 \ 175 || streq (Fs_type, "proc") \
167 || strcmp (Fs_type, "subfs") == 0 \ 176 || streq (Fs_type, "subfs") \
168 /* for Linux 2.6/3.x */ \ 177 /* for Linux 2.6/3.x */ \
169 || strcmp (Fs_type, "debugfs") == 0 \ 178 || streq (Fs_type, "debugfs") \
170 || strcmp (Fs_type, "devpts") == 0 \ 179 || streq (Fs_type, "devpts") \
171 || strcmp (Fs_type, "fusectl") == 0 \ 180 || streq (Fs_type, "fusectl") \
172 || strcmp (Fs_type, "fuse.portal") == 0 \ 181 || streq (Fs_type, "fuse.portal") \
173 || strcmp (Fs_type, "mqueue") == 0 \ 182 || streq (Fs_type, "mqueue") \
174 || strcmp (Fs_type, "rpc_pipefs") == 0 \ 183 || streq (Fs_type, "rpc_pipefs") \
175 || strcmp (Fs_type, "sysfs") == 0 \ 184 || streq (Fs_type, "sysfs") \
176 /* FreeBSD, Linux 2.4 */ \ 185 /* FreeBSD, Linux 2.4 */ \
177 || strcmp (Fs_type, "devfs") == 0 \ 186 || streq (Fs_type, "devfs") \
178 /* for NetBSD 3.0 */ \ 187 /* for NetBSD 3.0 */ \
179 || strcmp (Fs_type, "kernfs") == 0 \ 188 || streq (Fs_type, "kernfs"))
180 /* for Irix 6.5 */ \
181 || strcmp (Fs_type, "ignore") == 0)
182 189
183/* Historically, we have marked as "dummy" any file system of type "none", 190/* Historically, we have marked as "dummy" any file system of type "none",
184 but now that programs like du need to know about bind-mounted directories, 191 but now that programs like du need to know about bind-mounted directories,
185 we grant an exception to any with "bind" in its list of mount options. 192 we grant an exception to any with "bind" in its list of mount options.
186 I.e., those are *not* dummy entries. */ 193 I.e., those are *not* dummy entries. */
187#ifdef MOUNTED_GETMNTENT1 194#ifdef MOUNTED_GETMNTENT1
188# define ME_DUMMY(Fs_name, Fs_type, Bind) \ 195# define ME_DUMMY(Fs_name, Fs_type, Bind) \
189 (ME_DUMMY_0 (Fs_name, Fs_type) \ 196 (ME_DUMMY_0 (Fs_name, Fs_type) \
190 || (strcmp (Fs_type, "none") == 0 && !Bind)) 197 || (streq (Fs_type, "none") && !Bind))
191#else 198#else
192# define ME_DUMMY(Fs_name, Fs_type) \ 199# define ME_DUMMY(Fs_name, Fs_type) \
193 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0) 200 (ME_DUMMY_0 (Fs_name, Fs_type) || streq (Fs_type, "none"))
194#endif 201#endif
195 202
196#ifdef __CYGWIN__ 203#ifdef __CYGWIN__
@@ -231,19 +238,19 @@ me_remote (char const *fs_name, _GL_UNUSED char const *fs_type)
231 (strchr (Fs_name, ':') != NULL \ 238 (strchr (Fs_name, ':') != NULL \
232 || ((Fs_name)[0] == '/' \ 239 || ((Fs_name)[0] == '/' \
233 && (Fs_name)[1] == '/' \ 240 && (Fs_name)[1] == '/' \
234 && (strcmp (Fs_type, "smbfs") == 0 \ 241 && (streq (Fs_type, "smbfs") \
235 || strcmp (Fs_type, "smb3") == 0 \ 242 || streq (Fs_type, "smb3") \
236 || strcmp (Fs_type, "cifs") == 0)) \ 243 || streq (Fs_type, "cifs"))) \
237 || strcmp (Fs_type, "acfs") == 0 \ 244 || streq (Fs_type, "acfs") \
238 || strcmp (Fs_type, "afs") == 0 \ 245 || streq (Fs_type, "afs") \
239 || strcmp (Fs_type, "coda") == 0 \ 246 || streq (Fs_type, "coda") \
240 || strcmp (Fs_type, "auristorfs") == 0 \ 247 || streq (Fs_type, "auristorfs") \
241 || strcmp (Fs_type, "fhgfs") == 0 \ 248 || streq (Fs_type, "fhgfs") \
242 || strcmp (Fs_type, "gpfs") == 0 \ 249 || streq (Fs_type, "gpfs") \
243 || strcmp (Fs_type, "ibrix") == 0 \ 250 || streq (Fs_type, "ibrix") \
244 || strcmp (Fs_type, "ocfs2") == 0 \ 251 || streq (Fs_type, "ocfs2") \
245 || strcmp (Fs_type, "vxfs") == 0 \ 252 || streq (Fs_type, "vxfs") \
246 || strcmp ("-hosts", Fs_name) == 0) 253 || streq ("-hosts", Fs_name))
247#endif 254#endif
248 255
249#if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ 256#if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
@@ -360,9 +367,7 @@ fsp_to_string (const struct statfs *fsp)
360static char * 367static char *
361fstype_to_string (int t) 368fstype_to_string (int t)
362{ 369{
363 struct vfs_ent *e; 370 struct vfs_ent *e = getvfsbytype (t);
364
365 e = getvfsbytype (t);
366 if (!e || !e->vfsent_name) 371 if (!e || !e->vfsent_name)
367 return "none"; 372 return "none";
368 else 373 else
@@ -389,15 +394,17 @@ dev_from_mount_options (char const *mount_options)
389 if (devopt) 394 if (devopt)
390 { 395 {
391 char const *optval = devopt + sizeof dev_pattern - 1; 396 char const *optval = devopt + sizeof dev_pattern - 1;
392 char *optvalend; 397 if (c_isxdigit (*optval))
393 unsigned long int dev; 398 {
394 errno = 0; 399 errno = 0;
395 dev = strtoul (optval, &optvalend, 16); 400 char *optvalend;
396 if (optval != optvalend 401 unsigned long int dev = strtoul (optval, &optvalend, 16);
397 && (*optvalend == '\0' || *optvalend == ',') 402 if (optval != optvalend
398 && ! (dev == ULONG_MAX && errno == ERANGE) 403 && (*optvalend == '\0' || *optvalend == ',')
399 && dev == (dev_t) dev) 404 && ! (dev == ULONG_MAX && errno == ERANGE)
400 return dev; 405 && dev == (dev_t) dev)
406 return dev;
407 }
401 } 408 }
402 409
403# endif 410# endif
@@ -415,9 +422,9 @@ dev_from_mount_options (char const *mount_options)
415static void 422static void
416unescape_tab (char *str) 423unescape_tab (char *str)
417{ 424{
418 size_t i, j = 0; 425 size_t j = 0;
419 size_t len = strlen (str) + 1; 426 size_t len = strlen (str) + 1;
420 for (i = 0; i < len; i++) 427 for (size_t i = 0; i < len; i++)
421 { 428 {
422 if (str[i] == '\\' && (i + 4 < len) 429 if (str[i] == '\\' && (i + 4 < len)
423 && str[i + 1] >= '0' && str[i + 1] <= '3' 430 && str[i + 1] >= '0' && str[i + 1] <= '3'
@@ -445,12 +452,8 @@ terminate_at_blank (char *str)
445 *s = '\0'; 452 *s = '\0';
446 return s; 453 return s;
447} 454}
448#endif
449 455
450/* Return a list of the currently mounted file systems, or NULL on error. 456#endif
451 Add each entry to the tail of the list so that they stay in order.
452 If NEED_FS_TYPE is true, ensure that the file system type fields in
453 the returned list are valid. Otherwise, they might not be. */
454 457
455struct mount_entry * 458struct mount_entry *
456read_file_system_list (bool need_fs_type) 459read_file_system_list (bool need_fs_type)
@@ -460,18 +463,16 @@ read_file_system_list (bool need_fs_type)
460 struct mount_entry **mtail = &mount_list; 463 struct mount_entry **mtail = &mount_list;
461 (void) need_fs_type; 464 (void) need_fs_type;
462 465
463#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android, 466#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, Cygwin, Android,
464 also (obsolete) 4.3BSD, SunOS */ 467 also (obsolete) 4.3BSD, SunOS */
465 { 468 {
466 FILE *fp;
467
468# if defined __linux__ || defined __ANDROID__ 469# if defined __linux__ || defined __ANDROID__
469 /* Try parsing mountinfo first, as that make device IDs available. 470 /* Try parsing mountinfo first, as that make device IDs available.
470 Note we could use libmount routines to simplify this parsing a little 471 Note we could use libmount routines to simplify this parsing a little
471 (and that code is in previous versions of this function), however 472 (and that code is in previous versions of this function), however
472 libmount depends on libselinux which pulls in many dependencies. */ 473 libmount depends on libselinux which pulls in many dependencies. */
473 char const *mountinfo = "/proc/self/mountinfo"; 474 char const *mountinfo = "/proc/self/mountinfo";
474 fp = fopen (mountinfo, "re"); 475 FILE *fp = fopen (mountinfo, "re");
475 if (fp != NULL) 476 if (fp != NULL)
476 { 477 {
477 char *line = NULL; 478 char *line = NULL;
@@ -489,61 +490,61 @@ read_file_system_list (bool need_fs_type)
489 &devmaj, &devmin, 490 &devmaj, &devmin,
490 &mntroot_s); 491 &mntroot_s);
491 492
492 if (rc != 2 && rc != 3) /* 3 if %n included in count. */ 493 if (rc == 2 || rc == 3) /* 3 if %n included in count. */
493 continue; 494 {
494 495 /* find end of MNTROOT. */
495 /* find end of MNTROOT. */ 496 char *mntroot = line + mntroot_s;
496 char *mntroot = line + mntroot_s; 497 char *blank = terminate_at_blank (mntroot);
497 char *blank = terminate_at_blank (mntroot); 498 if (blank)
498 if (! blank) 499 {
499 continue; 500 /* find end of TARGET. */
500 501 char *target = blank + 1;
501 /* find end of TARGET. */ 502 blank = terminate_at_blank (target);
502 char *target = blank + 1; 503 if (blank)
503 blank = terminate_at_blank (target); 504 {
504 if (! blank) 505 /* skip optional fields, terminated by " - " */
505 continue; 506 char *dash = strstr (blank + 1, " - ");
506 507 if (dash)
507 /* skip optional fields, terminated by " - " */ 508 {
508 char *dash = strstr (blank + 1, " - "); 509 /* advance past the " - " separator. */
509 if (! dash) 510 char *fstype = dash + 3;
510 continue; 511 blank = terminate_at_blank (fstype);
511 512 if (blank)
512 /* advance past the " - " separator. */ 513 {
513 char *fstype = dash + 3; 514 /* find end of SOURCE. */
514 blank = terminate_at_blank (fstype); 515 char *source = blank + 1;
515 if (! blank) 516 if (terminate_at_blank (source))
516 continue; 517 {
517 518 /* manipulate the sub-strings in place. */
518 /* find end of SOURCE. */ 519 unescape_tab (source);
519 char *source = blank + 1; 520 unescape_tab (target);
520 if (! terminate_at_blank (source)) 521 unescape_tab (mntroot);
521 continue; 522 unescape_tab (fstype);
522 523
523 /* manipulate the sub-strings in place. */ 524 me = xmalloc (sizeof *me);
524 unescape_tab (source); 525
525 unescape_tab (target); 526 me->me_devname = xstrdup (source);
526 unescape_tab (mntroot); 527 me->me_mountdir = xstrdup (target);
527 unescape_tab (fstype); 528 me->me_mntroot = xstrdup (mntroot);
528 529 me->me_type = xstrdup (fstype);
529 me = xmalloc (sizeof *me); 530 me->me_type_malloced = 1;
530 531 me->me_dev = makedev (devmaj, devmin);
531 me->me_devname = xstrdup (source); 532 /* we pass "false" for the "Bind" option as that's only
532 me->me_mountdir = xstrdup (target); 533 significant when the Fs_type is "none" which will not be
533 me->me_mntroot = xstrdup (mntroot); 534 the case when parsing "/proc/self/mountinfo", and only
534 me->me_type = xstrdup (fstype); 535 applies for static /etc/mtab files. */
535 me->me_type_malloced = 1; 536 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, false);
536 me->me_dev = makedev (devmaj, devmin); 537 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
537 /* we pass "false" for the "Bind" option as that's only 538
538 significant when the Fs_type is "none" which will not be 539 /* Add to the linked list. */
539 the case when parsing "/proc/self/mountinfo", and only 540 *mtail = me;
540 applies for static /etc/mtab files. */ 541 mtail = &me->me_next;
541 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, false); 542 }
542 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 543 }
543 544 }
544 /* Add to the linked list. */ 545 }
545 *mtail = me; 546 }
546 mtail = &me->me_next; 547 }
547 } 548 }
548 549
549 free (line); 550 free (line);
@@ -560,16 +561,16 @@ read_file_system_list (bool need_fs_type)
560 goto free_then_fail; 561 goto free_then_fail;
561 } 562 }
562 else /* fallback to /proc/self/mounts (/etc/mtab). */ 563 else /* fallback to /proc/self/mounts (/etc/mtab). */
563# endif /* __linux __ || __ANDROID__ */ 564# endif /* __linux__ || __ANDROID__ */
564 { 565 {
565 struct mntent *mnt;
566 char const *table = MOUNTED; 566 char const *table = MOUNTED;
567 567
568 fp = setmntent (table, "r"); 568 FILE *mfp = setmntent (table, "r");
569 if (fp == NULL) 569 if (mfp == NULL)
570 return NULL; 570 return NULL;
571 571
572 while ((mnt = getmntent (fp))) 572 struct mntent *mnt;
573 while ((mnt = getmntent (mfp)))
573 { 574 {
574 bool bind = hasmntopt (mnt, "bind"); 575 bool bind = hasmntopt (mnt, "bind");
575 576
@@ -588,7 +589,7 @@ read_file_system_list (bool need_fs_type)
588 mtail = &me->me_next; 589 mtail = &me->me_next;
589 } 590 }
590 591
591 if (endmntent (fp) == 0) 592 if (endmntent (mfp) == 0)
592 goto free_then_fail; 593 goto free_then_fail;
593 } 594 }
594 } 595 }
@@ -597,9 +598,7 @@ read_file_system_list (bool need_fs_type)
597#ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */ 598#ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
598 { 599 {
599 struct statfs *fsp; 600 struct statfs *fsp;
600 int entries; 601 int entries = getmntinfo (&fsp, MNT_NOWAIT);
601
602 entries = getmntinfo (&fsp, MNT_NOWAIT);
603 if (entries < 0) 602 if (entries < 0)
604 return NULL; 603 return NULL;
605 for (; entries-- > 0; fsp++) 604 for (; entries-- > 0; fsp++)
@@ -626,9 +625,7 @@ read_file_system_list (bool need_fs_type)
626#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */ 625#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */
627 { 626 {
628 struct statvfs *fsp; 627 struct statvfs *fsp;
629 int entries; 628 int entries = getmntinfo (&fsp, MNT_NOWAIT);
630
631 entries = getmntinfo (&fsp, MNT_NOWAIT);
632 if (entries < 0) 629 if (entries < 0)
633 return NULL; 630 return NULL;
634 for (; entries-- > 0; fsp++) 631 for (; entries-- > 0; fsp++)
@@ -662,7 +659,6 @@ read_file_system_list (bool need_fs_type)
662 We therefore get the list of subdirectories of /, and the list 659 We therefore get the list of subdirectories of /, and the list
663 of all file systems, and match the two lists. */ 660 of all file systems, and match the two lists. */
664 661
665 DIR *dirp;
666 struct rootdir_entry 662 struct rootdir_entry
667 { 663 {
668 char *name; 664 char *name;
@@ -670,16 +666,11 @@ read_file_system_list (bool need_fs_type)
670 ino_t ino; 666 ino_t ino;
671 struct rootdir_entry *next; 667 struct rootdir_entry *next;
672 }; 668 };
673 struct rootdir_entry *rootdir_list;
674 struct rootdir_entry **rootdir_tail;
675 int32 pos;
676 dev_t dev;
677 fs_info fi;
678 669
679 /* All volumes are mounted in the rootfs, directly under /. */ 670 /* All volumes are mounted in the rootfs, directly under /. */
680 rootdir_list = NULL; 671 struct rootdir_entry *rootdir_list = NULL;
681 rootdir_tail = &rootdir_list; 672 struct rootdir_entry **rootdir_tail = &rootdir_list;
682 dirp = opendir ("/"); 673 DIR *dirp = opendir ("/");
683 if (dirp) 674 if (dirp)
684 { 675 {
685 struct dirent *d; 676 struct dirent *d;
@@ -689,61 +680,64 @@ read_file_system_list (bool need_fs_type)
689 char *name; 680 char *name;
690 struct stat statbuf; 681 struct stat statbuf;
691 682
692 if (strcmp (d->d_name, "..") == 0) 683 if (! streq (d->d_name, ".."))
693 continue;
694
695 if (strcmp (d->d_name, ".") == 0)
696 name = xstrdup ("/");
697 else
698 {
699 name = xmalloc (1 + strlen (d->d_name) + 1);
700 name[0] = '/';
701 strcpy (name + 1, d->d_name);
702 }
703
704 if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
705 { 684 {
706 struct rootdir_entry *re = xmalloc (sizeof *re); 685 if (streq (d->d_name, "."))
707 re->name = name; 686 name = xstrdup ("/");
708 re->dev = statbuf.st_dev; 687 else
709 re->ino = statbuf.st_ino; 688 {
710 689 name = xmalloc (1 + strlen (d->d_name) + 1);
711 /* Add to the linked list. */ 690 name[0] = '/';
712 *rootdir_tail = re; 691 strcpy (name + 1, d->d_name);
713 rootdir_tail = &re->next; 692 }
693
694 if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
695 {
696 struct rootdir_entry *re = xmalloc (sizeof *re);
697 re->name = name;
698 re->dev = statbuf.st_dev;
699 re->ino = statbuf.st_ino;
700
701 /* Add to the linked list. */
702 *rootdir_tail = re;
703 rootdir_tail = &re->next;
704 }
705 else
706 free (name);
714 } 707 }
715 else
716 free (name);
717 } 708 }
718 closedir (dirp); 709 closedir (dirp);
719 } 710 }
720 *rootdir_tail = NULL; 711 *rootdir_tail = NULL;
721 712
722 for (pos = 0; (dev = next_dev (&pos)) >= 0; ) 713 dev_t dev;
723 if (fs_stat_dev (dev, &fi) >= 0) 714 for (int32 pos = 0; (dev = next_dev (&pos)) >= 0; )
724 { 715 {
725 /* Note: fi.dev == dev. */ 716 fs_info fi;
726 struct rootdir_entry *re; 717 if (fs_stat_dev (dev, &fi) >= 0)
727 718 {
728 for (re = rootdir_list; re; re = re->next) 719 /* Note: fi.dev == dev. */
729 if (re->dev == fi.dev && re->ino == fi.root) 720 struct rootdir_entry *re;
730 break; 721 for (re = rootdir_list; re; re = re->next)
731 722 if (re->dev == fi.dev && re->ino == fi.root)
732 me = xmalloc (sizeof *me); 723 break;
733 me->me_devname = xstrdup (fi.device_name[0] != '\0' 724
734 ? fi.device_name : fi.fsh_name); 725 me = xmalloc (sizeof *me);
735 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); 726 me->me_devname = xstrdup (fi.device_name[0] != '\0'
736 me->me_mntroot = NULL; 727 ? fi.device_name : fi.fsh_name);
737 me->me_type = xstrdup (fi.fsh_name); 728 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
738 me->me_type_malloced = 1; 729 me->me_mntroot = NULL;
739 me->me_dev = fi.dev; 730 me->me_type = xstrdup (fi.fsh_name);
740 me->me_dummy = 0; 731 me->me_type_malloced = 1;
741 me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0; 732 me->me_dev = fi.dev;
742 733 me->me_dummy = 0;
743 /* Add to the linked list. */ 734 me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0;
744 *mtail = me; 735
745 mtail = &me->me_next; 736 /* Add to the linked list. */
746 } 737 *mtail = me;
738 mtail = &me->me_next;
739 }
740 }
747 *mtail = NULL; 741 *mtail = NULL;
748 742
749 while (rootdir_list != NULL) 743 while (rootdir_list != NULL)
@@ -756,19 +750,17 @@ read_file_system_list (bool need_fs_type)
756 } 750 }
757#endif /* MOUNTED_FS_STAT_DEV */ 751#endif /* MOUNTED_FS_STAT_DEV */
758 752
759#if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */ 753#if defined MOUNTED_GETFSSTAT /* (obsolete) Apple Darwin 1.3 */
760 { 754 {
761 int numsys, counter;
762 size_t bufsize;
763 struct statfs *stats;
764 755
765 numsys = getfsstat (NULL, 0L, MNT_NOWAIT); 756 int numsys = getfsstat (NULL, 0L, MNT_NOWAIT);
766 if (numsys < 0) 757 if (numsys < 0)
767 return NULL; 758 return NULL;
759
760 struct statfs *stats;
768 if (SIZE_MAX / sizeof *stats <= numsys) 761 if (SIZE_MAX / sizeof *stats <= numsys)
769 xalloc_die (); 762 xalloc_die ();
770 763 size_t bufsize = (1 + numsys) * sizeof *stats;
771 bufsize = (1 + numsys) * sizeof *stats;
772 stats = xmalloc (bufsize); 764 stats = xmalloc (bufsize);
773 numsys = getfsstat (stats, bufsize, MNT_NOWAIT); 765 numsys = getfsstat (stats, bufsize, MNT_NOWAIT);
774 766
@@ -778,7 +770,7 @@ read_file_system_list (bool need_fs_type)
778 return NULL; 770 return NULL;
779 } 771 }
780 772
781 for (counter = 0; counter < numsys; counter++) 773 for (int counter = 0; counter < numsys; counter++)
782 { 774 {
783 me = xmalloc (sizeof *me); 775 me = xmalloc (sizeof *me);
784 me->me_devname = xstrdup (stats[counter].f_mntfromname); 776 me->me_devname = xstrdup (stats[counter].f_mntfromname);
@@ -801,14 +793,13 @@ read_file_system_list (bool need_fs_type)
801 793
802#if defined MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */ 794#if defined MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */
803 { 795 {
804 struct mnttab mnt;
805 char *table = "/etc/mnttab"; 796 char *table = "/etc/mnttab";
806 FILE *fp;
807 797
808 fp = fopen (table, "re"); 798 FILE *fp = fopen (table, "re");
809 if (fp == NULL) 799 if (fp == NULL)
810 return NULL; 800 return NULL;
811 801
802 struct mnttab mnt;
812 while (fread (&mnt, sizeof mnt, 1, fp) > 0) 803 while (fread (&mnt, sizeof mnt, 1, fp) > 0)
813 { 804 {
814 me = xmalloc (sizeof *me); 805 me = xmalloc (sizeof *me);
@@ -854,20 +845,19 @@ read_file_system_list (bool need_fs_type)
854 845
855#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */ 846#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
856 { 847 {
857 struct extmnttab mnt;
858 const char *table = MNTTAB; 848 const char *table = MNTTAB;
859 FILE *fp;
860 int ret;
861 849
862 /* No locking is needed, because the contents of /etc/mnttab is generated 850 /* No locking is needed, because the contents of /etc/mnttab is generated
863 by the kernel. */ 851 by the kernel. */
864 852
865 errno = 0; 853 errno = 0;
866 fp = fopen (table, "re"); 854 FILE *fp = fopen (table, "re");
855 int ret;
867 if (fp == NULL) 856 if (fp == NULL)
868 ret = errno; 857 ret = errno;
869 else 858 else
870 { 859 {
860 struct extmnttab mnt;
871 while ((ret = getextmntent (fp, &mnt, 1)) == 0) 861 while ((ret = getextmntent (fp, &mnt, 1)) == 0)
872 { 862 {
873 me = xmalloc (sizeof *me); 863 me = xmalloc (sizeof *me);
@@ -876,7 +866,9 @@ read_file_system_list (bool need_fs_type)
876 me->me_mntroot = NULL; 866 me->me_mntroot = NULL;
877 me->me_type = xstrdup (mnt.mnt_fstype); 867 me->me_type = xstrdup (mnt.mnt_fstype);
878 me->me_type_malloced = 1; 868 me->me_type_malloced = 1;
879 me->me_dummy = MNT_IGNORE (&mnt) != 0; 869 /* The cast from 'struct extmnttab *' to 'struct mnttab *' is OK
870 because 'struct extmnttab' extends 'struct mnttab'. */
871 me->me_dummy = MNT_IGNORE ((struct mnttab *) &mnt) != 0;
880 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 872 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
881 me->me_dev = makedev (mnt.mnt_major, mnt.mnt_minor); 873 me->me_dev = makedev (mnt.mnt_major, mnt.mnt_minor);
882 874
@@ -899,10 +891,7 @@ read_file_system_list (bool need_fs_type)
899 891
900#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */ 892#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
901 { 893 {
902 struct mnttab mnt;
903 const char *table = MNTTAB; 894 const char *table = MNTTAB;
904 FILE *fp;
905 int ret;
906 int lockfd = -1; 895 int lockfd = -1;
907 896
908# if defined F_RDLCK && defined F_SETLKW 897# if defined F_RDLCK && defined F_SETLKW
@@ -935,11 +924,13 @@ read_file_system_list (bool need_fs_type)
935# endif 924# endif
936 925
937 errno = 0; 926 errno = 0;
938 fp = fopen (table, "re"); 927 FILE *fp = fopen (table, "re");
928 int ret;
939 if (fp == NULL) 929 if (fp == NULL)
940 ret = errno; 930 ret = errno;
941 else 931 else
942 { 932 {
933 struct mnttab mnt;
943 while ((ret = getmntent (fp, &mnt)) == 0) 934 while ((ret = getmntent (fp, &mnt)) == 0)
944 { 935 {
945 me = xmalloc (sizeof *me); 936 me = xmalloc (sizeof *me);
@@ -974,34 +965,24 @@ read_file_system_list (bool need_fs_type)
974 965
975#ifdef MOUNTED_VMOUNT /* AIX */ 966#ifdef MOUNTED_VMOUNT /* AIX */
976 { 967 {
977 int bufsize;
978 void *entries;
979 char *thisent;
980 struct vmount *vmp;
981 int n_entries;
982 int i;
983
984 /* Ask how many bytes to allocate for the mounted file system info. */ 968 /* Ask how many bytes to allocate for the mounted file system info. */
985 entries = &bufsize; 969 int bufsize;
986 if (mntctl (MCTL_QUERY, sizeof bufsize, entries) != 0) 970 if (mntctl (MCTL_QUERY, sizeof bufsize, &bufsize) != 0)
987 return NULL; 971 return NULL;
988 entries = xmalloc (bufsize); 972 void *entries = xmalloc (bufsize);
989 973
990 /* Get the list of mounted file systems. */ 974 /* Get the list of mounted file systems. */
991 n_entries = mntctl (MCTL_QUERY, bufsize, entries); 975 int n_entries = mntctl (MCTL_QUERY, bufsize, entries);
992 if (n_entries < 0) 976 if (n_entries < 0)
993 { 977 {
994 free (entries); 978 free (entries);
995 return NULL; 979 return NULL;
996 } 980 }
997 981
998 for (i = 0, thisent = entries; 982 char *thisent = entries;
999 i < n_entries; 983 for (int i = 0; i < n_entries; i++)
1000 i++, thisent += vmp->vmt_length)
1001 { 984 {
1002 char *options, *ignore; 985 struct vmount *vmp = (struct vmount *) thisent;
1003
1004 vmp = (struct vmount *) thisent;
1005 me = xmalloc (sizeof *me); 986 me = xmalloc (sizeof *me);
1006 if (vmp->vmt_flags & MNT_REMOTE) 987 if (vmp->vmt_flags & MNT_REMOTE)
1007 { 988 {
@@ -1026,8 +1007,8 @@ read_file_system_list (bool need_fs_type)
1026 me->me_mntroot = NULL; 1007 me->me_mntroot = NULL;
1027 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); 1008 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
1028 me->me_type_malloced = 1; 1009 me->me_type_malloced = 1;
1029 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; 1010 char *options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
1030 ignore = strstr (options, "ignore"); 1011 char *ignore = strstr (options, "ignore");
1031 me->me_dummy = (ignore 1012 me->me_dummy = (ignore
1032 && (ignore == options || ignore[-1] == ',') 1013 && (ignore == options || ignore[-1] == ',')
1033 && (ignore[sizeof "ignore" - 1] == ',' 1014 && (ignore[sizeof "ignore" - 1] == ','
@@ -1037,6 +1018,8 @@ read_file_system_list (bool need_fs_type)
1037 /* Add to the linked list. */ 1018 /* Add to the linked list. */
1038 *mtail = me; 1019 *mtail = me;
1039 mtail = &me->me_next; 1020 mtail = &me->me_next;
1021
1022 thisent += vmp->vmt_length;
1040 } 1023 }
1041 free (entries); 1024 free (entries);
1042 } 1025 }
@@ -1045,25 +1028,23 @@ read_file_system_list (bool need_fs_type)
1045#ifdef MOUNTED_INTERIX_STATVFS /* Interix */ 1028#ifdef MOUNTED_INTERIX_STATVFS /* Interix */
1046 { 1029 {
1047 DIR *dirp = opendir ("/dev/fs"); 1030 DIR *dirp = opendir ("/dev/fs");
1048 char node[9 + NAME_MAX];
1049
1050 if (!dirp) 1031 if (!dirp)
1051 goto free_then_fail; 1032 goto free_then_fail;
1052 1033
1053 while (1) 1034 while (1)
1054 { 1035 {
1055 struct statvfs dev;
1056 struct dirent entry;
1057 struct dirent *result;
1058
1059 /* FIXME: readdir_r is planned to be withdrawn from POSIX and 1036 /* FIXME: readdir_r is planned to be withdrawn from POSIX and
1060 marked obsolescent in glibc. Use readdir instead. */ 1037 marked obsolescent in glibc. Use readdir instead. */
1038 struct dirent entry;
1039 struct dirent *result;
1061 if (readdir_r (dirp, &entry, &result) || result == NULL) 1040 if (readdir_r (dirp, &entry, &result) || result == NULL)
1062 break; 1041 break;
1063 1042
1043 char node[9 + NAME_MAX];
1064 strcpy (node, "/dev/fs/"); 1044 strcpy (node, "/dev/fs/");
1065 strcat (node, entry.d_name); 1045 strcat (node, entry.d_name);
1066 1046
1047 struct statvfs dev;
1067 if (statvfs (node, &dev) == 0) 1048 if (statvfs (node, &dev) == 0)
1068 { 1049 {
1069 me = xmalloc (sizeof *me); 1050 me = xmalloc (sizeof *me);
@@ -1085,6 +1066,201 @@ read_file_system_list (bool need_fs_type)
1085 } 1066 }
1086#endif /* MOUNTED_INTERIX_STATVFS */ 1067#endif /* MOUNTED_INTERIX_STATVFS */
1087 1068
1069#if defined _WIN32 && !defined __CYGWIN__ /* native Windows */
1070/* Don't assume that UNICODE is not defined. */
1071# undef GetDriveType
1072# define GetDriveType GetDriveTypeA
1073# undef GetVolumeInformation
1074# define GetVolumeInformation GetVolumeInformationA
1075 {
1076 /* Windows has drive prefixes which are similar to mount points.
1077 GetLogicalDrives returns a bitmask where the i-th bit is set
1078 if ASCII 'A' + i is an available drive. See:
1079 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getlogicaldrives>. */
1080 DWORD value = GetLogicalDrives ();
1081
1082 for (unsigned int i = 0; i < 26; ++i)
1083 {
1084 if (value & (1U << i))
1085 {
1086 char mountdir[4];
1087 mountdir[0] = 'A' + i;
1088 mountdir[1] = ':';
1089 mountdir[2] = '\\';
1090 mountdir[3] = '\0';
1091
1092 char fs_name[MAX_PATH + 1];
1093 /* Test whether the drive actually exists, and
1094 get the name of the file system. See:
1095 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa>. */
1096 if (GetVolumeInformation (mountdir, NULL, 0, NULL, NULL, NULL,
1097 fs_name, sizeof fs_name))
1098 {
1099 me = xmalloc (sizeof *me);
1100 me->me_mountdir = xstrdup (mountdir);
1101 /* Check if drive is remote. See:
1102 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdrivetypea>. */
1103 me->me_remote = GetDriveType (mountdir) == DRIVE_REMOTE;
1104 /* Here we could use
1105 QueryDosDeviceW -> returns something like '\Device\HarddiskVolume2'
1106 GetVolumeNameForVolumeMountPointW -> return something like '\\?\Volume{...}'
1107 */
1108 me->me_devname = NULL;
1109 {
1110 /* Find the SUBST or NET USE mapping of the given drive.
1111 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-querydosdevicew>
1112 For testing of SUBST: <https://ss64.com/nt/subst.html>
1113 For testing of NET USE: <https://ss64.com/nt/net-use.html> */
1114 wchar_t drive[3];
1115 drive[0] = L'A' + i;
1116 drive[1] = L':';
1117 drive[2] = L'\0';
1118 wchar_t mapping[MAX_PATH + 1];
1119 DWORD mapping_len = QueryDosDeviceW (drive, mapping, sizeof (mapping) / sizeof (mapping[0]));
1120 if (mapping_len > 4 && wcsncmp (mapping, L"\\??\\", 4) == 0)
1121 {
1122 /* It's a SUBSTed drive. */
1123 char subst_dir[MAX_PATH + 1];
1124 size_t subst_dir_len = wcstombs (subst_dir, mapping + 4, sizeof (subst_dir));
1125 if (subst_dir_len > 0 && subst_dir_len <= MAX_PATH)
1126 me->me_mntroot = xstrdup (subst_dir);
1127 else
1128 /* mapping is too long or not convertible to the
1129 locale encoding. */
1130 me->me_mntroot = NULL;
1131 }
1132 else if (mapping_len > 26
1133 && wcsncmp (mapping, L"\\Device\\LanmanRedirector\\;", 26) == 0)
1134 {
1135 wchar_t *next_backslash = wcschr (mapping + 26, L'\\');
1136 if (next_backslash != NULL)
1137 {
1138 *--next_backslash = L'\\';
1139 char share_dir[MAX_PATH + 1];
1140 size_t share_dir_len = wcstombs (share_dir, next_backslash, sizeof (share_dir));
1141 if (share_dir_len > 0 && share_dir_len <= MAX_PATH)
1142 me->me_mntroot = xstrdup (share_dir);
1143 else
1144 /* mapping is too long or not convertible to the
1145 locale encoding. */
1146 me->me_mntroot = NULL;
1147 }
1148 else
1149 /* mapping does not have the expected form. */
1150 me->me_mntroot = NULL;
1151 }
1152 else
1153 /* It's neither a SUBSTed nor a NET USEd drive. */
1154 me->me_mntroot = NULL;
1155 }
1156 me->me_dev = (dev_t) -1;
1157 me->me_dummy = 0;
1158 me->me_type = xstrdup (fs_name);
1159 me->me_type_malloced = 1;
1160
1161 /* Add to the linked list. */
1162 *mtail = me;
1163 mtail = &me->me_next;
1164 }
1165 }
1166 }
1167 }
1168 {
1169 /* Windows also has true mount points, called "mounted folders". See
1170 <https://learn.microsoft.com/en-us/windows/win32/fileio/volume-mount-points>
1171 For testing: <https://learn.microsoft.com/en-us/windows-server/storage/disk-management/assign-a-mount-point-folder-path-to-a-drive> */
1172 /* Enumerate the volumes. See
1173 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstvolumew>
1174 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextvolumew>
1175 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findvolumeclose> */
1176 wchar_t vol_name[MAX_PATH + 1];
1177 HANDLE h = FindFirstVolumeW (vol_name, sizeof (vol_name) / sizeof (vol_name[0]));
1178 if (h != INVALID_HANDLE_VALUE)
1179 {
1180 do
1181 {
1182 /* Look where the volume vol_name is mounted.
1183 There are two APIs for doing this:
1184 - FindFirstVolumeMountPointW, FindNextVolumeMountPointW,
1185 FindVolumeMountPointClose. This API always fails with
1186 error code ERROR_ACCESS_DENIED.
1187 - GetVolumePathNamesForVolumeNameW. This API works but
1188 may require a significantly larger buffer.
1189 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumepathnamesforvolumenamew> */
1190 wchar_t stack_buf[MAX_PATH + 2];
1191 wchar_t *malloced_buf = NULL;
1192 wchar_t *buf = stack_buf;
1193 DWORD bufsize = sizeof (stack_buf) / sizeof (wchar_t);
1194 BOOL success;
1195 for (;;)
1196 {
1197 success = GetVolumePathNamesForVolumeNameW (vol_name, buf, bufsize, &bufsize);
1198 if (!success && GetLastError () == ERROR_MORE_DATA)
1199 {
1200 free (malloced_buf);
1201 malloced_buf = (wchar_t *) xmalloc (bufsize * sizeof (wchar_t));
1202 buf = malloced_buf;
1203 }
1204 else
1205 break;
1206 }
1207 if (success)
1208 {
1209 wchar_t *mount_dir = buf;
1210 while (*mount_dir != L'\0')
1211 {
1212 /* Drive mounts are already handled above. */
1213 if (!(mount_dir[0] >= L'A' && mount_dir[0] <= L'Z'
1214 && mount_dir[1] == L':' && mount_dir[2] == L'\\'
1215 && mount_dir[3] == L'\0'))
1216 {
1217 char mountdir[MAX_PATH + 1];
1218 size_t mountdir_len = wcstombs (mountdir, mount_dir, sizeof (mountdir));
1219 if (mountdir_len > 0 && mountdir_len <= MAX_PATH)
1220 {
1221 char fs_name[MAX_PATH + 1];
1222 /* Get the name of the file system. See:
1223 <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa>. */
1224 if (GetVolumeInformation (mountdir, NULL, 0, NULL, NULL, NULL,
1225 fs_name, sizeof fs_name))
1226 {
1227 me = xmalloc (sizeof *me);
1228 me->me_mountdir = xstrdup (mountdir);
1229 me->me_remote = false;
1230 /* Here we could use vol_name, something like '\\?\Volume{...}'. */
1231 me->me_devname = NULL;
1232 me->me_mntroot = NULL;
1233 me->me_dev = (dev_t) -1;
1234 me->me_dummy = 0;
1235 me->me_type = xstrdup (fs_name);
1236 me->me_type_malloced = 1;
1237
1238 /* Add to the linked list. */
1239 *mtail = me;
1240 mtail = &me->me_next;
1241 }
1242 }
1243 else
1244 {
1245 /* mount_dir is too long or not convertible to the
1246 locale encoding. */
1247 }
1248 }
1249 mount_dir += wcslen (mount_dir) + 1;
1250 }
1251 }
1252 free (malloced_buf);
1253 }
1254 while (FindNextVolumeW (h, vol_name, sizeof (vol_name) / sizeof (vol_name[0])));
1255 FindVolumeClose (h);
1256 }
1257 }
1258#endif
1259
1260#if MOUNTED_NOT_PORTED
1261# error "Please port gnulib mountlist.c to your platform!"
1262#endif
1263
1088 *mtail = NULL; 1264 *mtail = NULL;
1089 return mount_list; 1265 return mount_list;
1090 1266
diff --git a/gl/mountlist.h b/gl/mountlist.h
index aed7f887..de1ff712 100644
--- a/gl/mountlist.h
+++ b/gl/mountlist.h
@@ -1,6 +1,6 @@
1/* mountlist.h -- declarations for list of mounted file systems 1/* mountlist.h -- declarations for list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2023 Free Software 3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
@@ -17,9 +17,19 @@
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef MOUNTLIST_H_ 19#ifndef MOUNTLIST_H_
20# define MOUNTLIST_H_ 20#define MOUNTLIST_H_
21
22/* This file uses _GL_ATTRIBUTE_MALLOC. */
23#if !_GL_CONFIG_H_INCLUDED
24# error "Please include config.h first."
25#endif
26
27#include <sys/types.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
21 32
22# include <sys/types.h>
23 33
24/* A mount table entry. */ 34/* A mount table entry. */
25struct mount_entry 35struct mount_entry
@@ -36,8 +46,18 @@ struct mount_entry
36 struct mount_entry *me_next; 46 struct mount_entry *me_next;
37}; 47};
38 48
49/* Return a list of the currently mounted file systems, or NULL on error.
50 Add each entry to the tail of the list so that they stay in order.
51 If NEED_FS_TYPE is true, ensure that the file system type fields in
52 the returned list are valid. Otherwise, they might not be. */
39struct mount_entry *read_file_system_list (bool need_fs_type) 53struct mount_entry *read_file_system_list (bool need_fs_type)
40 _GL_ATTRIBUTE_MALLOC; 54 _GL_ATTRIBUTE_MALLOC;
55
41void free_mount_entry (struct mount_entry *entry); 56void free_mount_entry (struct mount_entry *entry);
42 57
58
59#ifdef __cplusplus
60}
61#endif
62
43#endif 63#endif
diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c
index c5149a8f..774447b6 100644
--- a/gl/msvc-inval.c
+++ b/gl/msvc-inval.c
@@ -1,5 +1,5 @@
1/* Invalid parameter handler for MSVC runtime libraries. 1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h
index ed00461f..25bb6a3a 100644
--- a/gl/msvc-inval.h
+++ b/gl/msvc-inval.h
@@ -1,5 +1,5 @@
1/* Invalid parameter handler for MSVC runtime libraries. 1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -52,6 +52,11 @@
52 AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING]) 52 AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING])
53 */ 53 */
54 54
55/* This file uses HAVE_MSVC_INVALID_PARAMETER_HANDLER. */
56#if !_GL_CONFIG_H_INCLUDED
57 #error "Please include config.h first."
58#endif
59
55#define DEFAULT_HANDLING 0 60#define DEFAULT_HANDLING 0
56#define HAIRY_LIBRARY_HANDLING 1 61#define HAIRY_LIBRARY_HANDLING 1
57#define SANE_LIBRARY_HANDLING 2 62#define SANE_LIBRARY_HANDLING 2
@@ -174,9 +179,9 @@ extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void);
174# define TRY_MSVC_INVAL \ 179# define TRY_MSVC_INVAL \
175 do \ 180 do \
176 { \ 181 { \
177 struct gl_msvc_inval_per_thread *msvc_inval_current; \
178 gl_msvc_inval_ensure_handler (); \ 182 gl_msvc_inval_ensure_handler (); \
179 msvc_inval_current = gl_msvc_inval_current (); \ 183 struct gl_msvc_inval_per_thread *msvc_inval_current = \
184 gl_msvc_inval_current (); \
180 /* First, initialize gl_msvc_inval_restart. */ \ 185 /* First, initialize gl_msvc_inval_restart. */ \
181 if (setjmp (msvc_inval_current->restart) == 0) \ 186 if (setjmp (msvc_inval_current->restart) == 0) \
182 { \ 187 { \
diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c
index f729fe66..dea273d5 100644
--- a/gl/msvc-nothrow.c
+++ b/gl/msvc-nothrow.c
@@ -1,6 +1,6 @@
1/* Wrappers that don't throw invalid parameter notifications 1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries. 2 with MSVC runtime libraries.
3 Copyright (C) 2011-2023 Free Software Foundation, Inc. 3 Copyright (C) 2011-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h
index 82d3f6a2..f059d2d9 100644
--- a/gl/msvc-nothrow.h
+++ b/gl/msvc-nothrow.h
@@ -1,6 +1,6 @@
1/* Wrappers that don't throw invalid parameter notifications 1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries. 2 with MSVC runtime libraries.
3 Copyright (C) 2011-2023 Free Software Foundation, Inc. 3 Copyright (C) 2011-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -25,11 +25,20 @@
25 This file defines wrappers that turn such an invalid parameter notification 25 This file defines wrappers that turn such an invalid parameter notification
26 into an error code. */ 26 into an error code. */
27 27
28/* This file uses HAVE_MSVC_INVALID_PARAMETER_HANDLER. */
29#if !_GL_CONFIG_H_INCLUDED
30 #error "Please include config.h first."
31#endif
32
28#if defined _WIN32 && ! defined __CYGWIN__ 33#if defined _WIN32 && ! defined __CYGWIN__
29 34
30/* Get original declaration of _get_osfhandle. */ 35/* Get original declaration of _get_osfhandle. */
31# include <io.h> 36# include <io.h>
32 37
38# ifdef __cplusplus
39extern "C" {
40# endif
41
33# if HAVE_MSVC_INVALID_PARAMETER_HANDLER 42# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
34 43
35/* Override _get_osfhandle. */ 44/* Override _get_osfhandle. */
@@ -38,6 +47,10 @@ extern intptr_t _gl_nothrow_get_osfhandle (int fd);
38 47
39# endif 48# endif
40 49
50# ifdef __cplusplus
51}
52# endif
53
41#endif 54#endif
42 55
43#endif /* _MSVC_NOTHROW_H */ 56#endif /* _MSVC_NOTHROW_H */
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
index 9549cd73..92f1220c 100644
--- a/gl/netdb.in.h
+++ b/gl/netdb.in.h
@@ -1,5 +1,5 @@
1/* Provide a netdb.h header file for systems lacking it (read: MinGW). 1/* Provide a netdb.h header file for systems lacking it (read: MinGW).
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -36,8 +36,13 @@
36#ifndef _@GUARD_PREFIX@_NETDB_H 36#ifndef _@GUARD_PREFIX@_NETDB_H
37#define _@GUARD_PREFIX@_NETDB_H 37#define _@GUARD_PREFIX@_NETDB_H
38 38
39/* Get <netdb.h> definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and 39/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
40 'struct hostent' on MinGW. */ 40#if !_GL_CONFIG_H_INCLUDED
41 #error "Please include config.h first."
42#endif
43
44/* Get <netdb.h> definitions such as 'socklen_t' and 'struct hostent'
45 on MinGW. */
41#include <sys/socket.h> 46#include <sys/socket.h>
42 47
43/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 48/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -49,6 +54,14 @@
49/* Declarations for a platform that lacks <netdb.h>, or where it is 54/* Declarations for a platform that lacks <netdb.h>, or where it is
50 incomplete. */ 55 incomplete. */
51 56
57/* Maximum length of a fully-qualified domain name. */
58#undef NI_MAXHOST
59#define NI_MAXHOST 1025
60
61/* Maximum length of a service. */
62#undef NI_MAXSERV
63#define NI_MAXSERV 32
64
52#if @GNULIB_GETADDRINFO@ 65#if @GNULIB_GETADDRINFO@
53 66
54# if !@HAVE_STRUCT_ADDRINFO@ 67# if !@HAVE_STRUCT_ADDRINFO@
@@ -86,12 +99,11 @@ struct addrinfo
86# ifndef AI_CANONNAME 99# ifndef AI_CANONNAME
87# define AI_CANONNAME 0x0002 /* Request for canonical name. */ 100# define AI_CANONNAME 0x0002 /* Request for canonical name. */
88# endif 101# endif
89# ifndef AI_NUMERICSERV 102# ifndef AI_NUMERICHOST
90# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ 103# define AI_NUMERICHOST 0x0004 /* Return numeric host address as name. */
91# endif 104# endif
92 105# ifndef AI_NUMERICSERV
93# if 0 106# define AI_NUMERICSERV 0x0400 /* Return service number as service name. */
94# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
95# endif 107# endif
96 108
97/* These symbolic constants are required to be present by POSIX, but 109/* These symbolic constants are required to be present by POSIX, but
@@ -171,7 +183,7 @@ _GL_FUNCDECL_RPL (getaddrinfo, int,
171 (const char *restrict nodename, 183 (const char *restrict nodename,
172 const char *restrict servname, 184 const char *restrict servname,
173 const struct addrinfo *restrict hints, 185 const struct addrinfo *restrict hints,
174 struct addrinfo **restrict res) 186 struct addrinfo **restrict res),
175 _GL_ARG_NONNULL ((4))); 187 _GL_ARG_NONNULL ((4)));
176_GL_CXXALIAS_RPL (getaddrinfo, int, 188_GL_CXXALIAS_RPL (getaddrinfo, int,
177 (const char *restrict nodename, 189 (const char *restrict nodename,
@@ -184,7 +196,7 @@ _GL_FUNCDECL_SYS (getaddrinfo, int,
184 (const char *restrict nodename, 196 (const char *restrict nodename,
185 const char *restrict servname, 197 const char *restrict servname,
186 const struct addrinfo *restrict hints, 198 const struct addrinfo *restrict hints,
187 struct addrinfo **restrict res) 199 struct addrinfo **restrict res),
188 _GL_ARG_NONNULL ((4))); 200 _GL_ARG_NONNULL ((4)));
189# endif 201# endif
190_GL_CXXALIAS_SYS (getaddrinfo, int, 202_GL_CXXALIAS_SYS (getaddrinfo, int,
@@ -203,12 +215,12 @@ _GL_CXXALIASWARN (getaddrinfo);
203# undef freeaddrinfo 215# undef freeaddrinfo
204# define freeaddrinfo rpl_freeaddrinfo 216# define freeaddrinfo rpl_freeaddrinfo
205# endif 217# endif
206_GL_FUNCDECL_RPL (freeaddrinfo, void, (struct addrinfo *ai) 218_GL_FUNCDECL_RPL (freeaddrinfo, void, (struct addrinfo *ai),
207 _GL_ARG_NONNULL ((1))); 219 _GL_ARG_NONNULL ((1)));
208_GL_CXXALIAS_RPL (freeaddrinfo, void, (struct addrinfo *ai)); 220_GL_CXXALIAS_RPL (freeaddrinfo, void, (struct addrinfo *ai));
209# else 221# else
210# if !@HAVE_DECL_FREEADDRINFO@ 222# if !@HAVE_DECL_FREEADDRINFO@
211_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai) 223_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai),
212 _GL_ARG_NONNULL ((1))); 224 _GL_ARG_NONNULL ((1)));
213# endif 225# endif
214_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai)); 226_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai));
@@ -220,14 +232,14 @@ _GL_CXXALIASWARN (freeaddrinfo);
220# undef gai_strerror 232# undef gai_strerror
221# define gai_strerror rpl_gai_strerror 233# define gai_strerror rpl_gai_strerror
222# endif 234# endif
223_GL_FUNCDECL_RPL (gai_strerror, const char *, (int ecode)); 235_GL_FUNCDECL_RPL (gai_strerror, const char *, (int ecode), );
224_GL_CXXALIAS_RPL (gai_strerror, const char *, (int ecode)); 236_GL_CXXALIAS_RPL (gai_strerror, const char *, (int ecode));
225# else 237# else
226# if !@HAVE_DECL_GAI_STRERROR@ 238# if !@HAVE_DECL_GAI_STRERROR@
227/* Convert error return from getaddrinfo() to a string. 239/* Convert error return from getaddrinfo() to a string.
228 For more details, see the POSIX:2008 specification 240 For more details, see the POSIX:2008 specification
229 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html>. */ 241 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html>. */
230_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode)); 242_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode), );
231# endif 243# endif
232_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode)); 244_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode));
233# endif 245# endif
@@ -243,7 +255,7 @@ _GL_FUNCDECL_SYS (getnameinfo, int,
243 (const struct sockaddr *restrict sa, socklen_t salen, 255 (const struct sockaddr *restrict sa, socklen_t salen,
244 char *restrict node, socklen_t nodelen, 256 char *restrict node, socklen_t nodelen,
245 char *restrict service, socklen_t servicelen, 257 char *restrict service, socklen_t servicelen,
246 int flags) 258 int flags),
247 _GL_ARG_NONNULL ((1))); 259 _GL_ARG_NONNULL ((1)));
248# endif 260# endif
249/* Need to cast, because on glibc systems, the seventh parameter is 261/* Need to cast, because on glibc systems, the seventh parameter is
@@ -265,25 +277,21 @@ _GL_CXXALIASWARN (getnameinfo);
265 277
266#elif defined GNULIB_POSIXCHECK 278#elif defined GNULIB_POSIXCHECK
267 279
268# undef getaddrinfo
269# if HAVE_RAW_DECL_GETADDRINFO 280# if HAVE_RAW_DECL_GETADDRINFO
270_GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - " 281_GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - "
271 "use gnulib module getaddrinfo for portability"); 282 "use gnulib module getaddrinfo for portability");
272# endif 283# endif
273 284
274# undef freeaddrinfo
275# if HAVE_RAW_DECL_FREEADDRINFO 285# if HAVE_RAW_DECL_FREEADDRINFO
276_GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - " 286_GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - "
277 "use gnulib module getaddrinfo for portability"); 287 "use gnulib module getaddrinfo for portability");
278# endif 288# endif
279 289
280# undef gai_strerror
281# if HAVE_RAW_DECL_GAI_STRERROR 290# if HAVE_RAW_DECL_GAI_STRERROR
282_GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - " 291_GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - "
283 "use gnulib module getaddrinfo for portability"); 292 "use gnulib module getaddrinfo for portability");
284# endif 293# endif
285 294
286# undef getnameinfo
287# if HAVE_RAW_DECL_GETNAMEINFO 295# if HAVE_RAW_DECL_GETNAMEINFO
288_GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - " 296_GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - "
289 "use gnulib module getaddrinfo for portability"); 297 "use gnulib module getaddrinfo for portability");
diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h
index f88923a3..933f5823 100644
--- a/gl/netinet_in.in.h
+++ b/gl/netinet_in.in.h
@@ -1,5 +1,5 @@
1/* Substitute for <netinet/in.h>. 1/* Substitute for <netinet/in.h>.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/nl_langinfo-lock.c b/gl/nl_langinfo-lock.c
index e5cdcd3e..810a510d 100644
--- a/gl/nl_langinfo-lock.c
+++ b/gl/nl_langinfo-lock.c
@@ -1,5 +1,5 @@
1/* Return the internal lock used by nl_langinfo. 1/* Return the internal lock used by nl_langinfo.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc. 2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -18,9 +18,10 @@
18 18
19#include <config.h> 19#include <config.h>
20 20
21/* The option '--disable-threads' explicitly requests no locking. */
21/* When it is known that the gl_get_nl_langinfo_lock function is defined 22/* When it is known that the gl_get_nl_langinfo_lock function is defined
22 by a dependency library, it should not be defined here. */ 23 by a dependency library, it should not be defined here. */
23#if OMIT_NL_LANGINFO_LOCK 24#if AVOID_ANY_THREADS || OMIT_NL_LANGINFO_LOCK
24 25
25/* This declaration is solely to ensure that after preprocessing 26/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */ 27 this file is never empty. */
@@ -37,14 +38,14 @@ typedef int dummy;
37 38
38/* Macro for exporting a symbol (function, not variable) defined in this file, 39/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */ 40 when compiled into a shared library. */
40# ifndef DLL_EXPORTED 41# ifndef SHLIB_EXPORTED
41# if HAVE_VISIBILITY 42# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */ 43 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default"))) 44# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__ 45# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport) 46# define SHLIB_EXPORTED __declspec(dllexport)
46# else 47# else
47# define DLL_EXPORTED 48# define SHLIB_EXPORTED
48# endif 49# endif
49# endif 50# endif
50 51
@@ -59,7 +60,7 @@ typedef int dummy;
59 because the latter is not guaranteed to be a stable ABI in the future. */ 60 because the latter is not guaranteed to be a stable ABI in the future. */
60 61
61/* Make sure the function gets exported from DLLs. */ 62/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); 63SHLIB_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
63 64
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; 65static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock; 66static CRITICAL_SECTION lock;
@@ -96,7 +97,7 @@ gl_get_nl_langinfo_lock (void)
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 97static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97 98
98/* Make sure the function gets exported from shared libraries. */ 99/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void); 100SHLIB_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void);
100 101
101/* Returns the internal lock used by nl_langinfo. */ 102/* Returns the internal lock used by nl_langinfo. */
102pthread_mutex_t * 103pthread_mutex_t *
@@ -123,7 +124,7 @@ atomic_init (void)
123} 124}
124 125
125/* Make sure the function gets exported from shared libraries. */ 126/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void); 127SHLIB_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void);
127 128
128/* Returns the internal lock used by nl_langinfo. */ 129/* Returns the internal lock used by nl_langinfo. */
129mtx_t * 130mtx_t *
diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c
index 131166fd..ff8fd89e 100644
--- a/gl/nl_langinfo.c
+++ b/gl/nl_langinfo.c
@@ -1,6 +1,6 @@
1/* nl_langinfo() replacement: query locale dependent information. 1/* nl_langinfo() replacement: query locale dependent information.
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -30,7 +30,12 @@
30#endif 30#endif
31 31
32#if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE 32#if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE
33# if defined _WIN32 && !defined __CYGWIN__ 33
34# if AVOID_ANY_THREADS
35
36/* The option '--disable-threads' explicitly requests no locking. */
37
38# elif defined _WIN32 && !defined __CYGWIN__
34 39
35# define WIN32_LEAN_AND_MEAN /* avoid including junk */ 40# define WIN32_LEAN_AND_MEAN /* avoid including junk */
36# include <windows.h> 41# include <windows.h>
@@ -51,6 +56,7 @@
51# include <threads.h> 56# include <threads.h>
52 57
53# endif 58# endif
59
54#endif 60#endif
55 61
56/* nl_langinfo() must be multithread-safe. To achieve this without using 62/* nl_langinfo() must be multithread-safe. To achieve this without using
@@ -70,16 +76,16 @@
70static char * 76static char *
71ctype_codeset (void) 77ctype_codeset (void)
72{ 78{
79 /* This function is only used on platforms which don't have uselocale().
80 Therefore we don't need to look at the per-thread locale first, here. */
73 static char result[2 + 10 + 1]; 81 static char result[2 + 10 + 1];
74 char buf[2 + 10 + 1];
75 char locale[SETLOCALE_NULL_MAX];
76 char *codeset;
77 size_t codesetlen;
78 82
83 char locale[SETLOCALE_NULL_MAX];
79 if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale))) 84 if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale)))
80 locale[0] = '\0'; 85 locale[0] = '\0';
81 86
82 codeset = buf; 87 char buf[2 + 10 + 1];
88 char *codeset = buf;
83 codeset[0] = '\0'; 89 codeset[0] = '\0';
84 90
85 if (locale[0]) 91 if (locale[0])
@@ -97,7 +103,7 @@ ctype_codeset (void)
97 codeset = codeset_start; 103 codeset = codeset_start;
98 else 104 else
99 { 105 {
100 codesetlen = modifier - codeset_start; 106 size_t codesetlen = modifier - codeset_start;
101 if (codesetlen < sizeof buf) 107 if (codesetlen < sizeof buf)
102 { 108 {
103 codeset = memcpy (buf, codeset_start, codesetlen); 109 codeset = memcpy (buf, codeset_start, codesetlen);
@@ -113,14 +119,14 @@ ctype_codeset (void)
113 GetACP, which returns the locale's codepage as a number (although 119 GetACP, which returns the locale's codepage as a number (although
114 this doesn't change according to what the 'setlocale' call specified). 120 this doesn't change according to what the 'setlocale' call specified).
115 Either way, prepend "CP" to make it a valid codeset name. */ 121 Either way, prepend "CP" to make it a valid codeset name. */
116 codesetlen = strlen (codeset); 122 size_t codesetlen = strlen (codeset);
117 if (0 < codesetlen && codesetlen < sizeof buf - 2) 123 if (0 < codesetlen && codesetlen < sizeof buf - 2)
118 memmove (buf + 2, codeset, codesetlen + 1); 124 memmove (buf + 2, codeset, codesetlen + 1);
119 else 125 else
120 sprintf (buf + 2, "%u", GetACP ()); 126 sprintf (buf + 2, "%u", GetACP ());
121 /* For a locale name such as "French_France.65001", in Windows 10, 127 /* For a locale name such as "French_France.65001", in Windows 10,
122 setlocale now returns "French_France.utf8" instead. */ 128 setlocale now returns "French_France.utf8" instead. */
123 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) 129 if (streq (buf + 2, "65001") || streq (buf + 2, "utf8"))
124 return (char *) "UTF-8"; 130 return (char *) "UTF-8";
125 else 131 else
126 { 132 {
@@ -146,11 +152,15 @@ ctype_codeset (void)
146 "thread5 disturbed by threadN!", even when threadN invokes only 152 "thread5 disturbed by threadN!", even when threadN invokes only
147 nl_langinfo (CODESET); 153 nl_langinfo (CODESET);
148 nl_langinfo (CRNCYSTR); 154 nl_langinfo (CRNCYSTR);
149 Similarly on Solaris 10. */ 155 Similarly on Solaris 10 and macOS 26. */
150 156
151# if !NL_LANGINFO_MTSAFE /* Solaris */ 157# if !NL_LANGINFO_MTSAFE /* macOS, Solaris */
152 158
153# define ITEMS (MAXSTRMSG + 1) 159# ifdef __sun /* Solaris */
160# define ITEMS (MAXSTRMSG + 1)
161# else /* macOS */
162# define ITEMS (CRNCYSTR + 20)
163# endif
154# define MAX_RESULT_LEN 80 164# define MAX_RESULT_LEN 80
155 165
156static char * 166static char *
@@ -184,7 +194,12 @@ nl_langinfo_unlocked (nl_item item)
184/* Prohibit renaming this symbol. */ 194/* Prohibit renaming this symbol. */
185# undef gl_get_nl_langinfo_lock 195# undef gl_get_nl_langinfo_lock
186 196
187# if defined _WIN32 && !defined __CYGWIN__ 197# if AVOID_ANY_THREADS
198
199/* The option '--disable-threads' explicitly requests no locking. */
200# define nl_langinfo_with_lock nl_langinfo_unlocked
201
202# elif defined _WIN32 && !defined __CYGWIN__
188 203
189extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void); 204extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
190 205
@@ -192,10 +207,9 @@ static char *
192nl_langinfo_with_lock (nl_item item) 207nl_langinfo_with_lock (nl_item item)
193{ 208{
194 CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock (); 209 CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock ();
195 char *ret;
196 210
197 EnterCriticalSection (lock); 211 EnterCriticalSection (lock);
198 ret = nl_langinfo_unlocked (item); 212 char *ret = nl_langinfo_unlocked (item);
199 LeaveCriticalSection (lock); 213 LeaveCriticalSection (lock);
200 214
201 return ret; 215 return ret;
@@ -231,11 +245,10 @@ nl_langinfo_with_lock (nl_item item)
231 if (pthread_in_use()) 245 if (pthread_in_use())
232 { 246 {
233 pthread_mutex_t *lock = gl_get_nl_langinfo_lock (); 247 pthread_mutex_t *lock = gl_get_nl_langinfo_lock ();
234 char *ret;
235 248
236 if (pthread_mutex_lock (lock)) 249 if (pthread_mutex_lock (lock))
237 abort (); 250 abort ();
238 ret = nl_langinfo_unlocked (item); 251 char *ret = nl_langinfo_unlocked (item);
239 if (pthread_mutex_unlock (lock)) 252 if (pthread_mutex_unlock (lock))
240 abort (); 253 abort ();
241 254
@@ -253,11 +266,10 @@ static char *
253nl_langinfo_with_lock (nl_item item) 266nl_langinfo_with_lock (nl_item item)
254{ 267{
255 mtx_t *lock = gl_get_nl_langinfo_lock (); 268 mtx_t *lock = gl_get_nl_langinfo_lock ();
256 char *ret;
257 269
258 if (mtx_lock (lock) != thrd_success) 270 if (mtx_lock (lock) != thrd_success)
259 abort (); 271 abort ();
260 ret = nl_langinfo_unlocked (item); 272 char *ret = nl_langinfo_unlocked (item);
261 if (mtx_unlock (lock) != thrd_success) 273 if (mtx_unlock (lock) != thrd_success)
262 abort (); 274 abort ();
263 275
@@ -282,10 +294,6 @@ rpl_nl_langinfo (nl_item item)
282 case CODESET: 294 case CODESET:
283 return ctype_codeset (); 295 return ctype_codeset ();
284# endif 296# endif
285# if GNULIB_defined_T_FMT_AMPM
286 case T_FMT_AMPM:
287 return (char *) "%I:%M:%S %p";
288# endif
289# if GNULIB_defined_ALTMON 297# if GNULIB_defined_ALTMON
290 case ALTMON_1: 298 case ALTMON_1:
291 case ALTMON_2: 299 case ALTMON_2:
@@ -304,6 +312,24 @@ rpl_nl_langinfo (nl_item item)
304 item = item - ALTMON_1 + MON_1; 312 item = item - ALTMON_1 + MON_1;
305 break; 313 break;
306# endif 314# endif
315# if GNULIB_defined_ABALTMON
316 case ABALTMON_1:
317 case ABALTMON_2:
318 case ABALTMON_3:
319 case ABALTMON_4:
320 case ABALTMON_5:
321 case ABALTMON_6:
322 case ABALTMON_7:
323 case ABALTMON_8:
324 case ABALTMON_9:
325 case ABALTMON_10:
326 case ABALTMON_11:
327 case ABALTMON_12:
328 /* We don't ship the appropriate localizations with gnulib. Therefore,
329 treat ABALTMON_i like ABMON_i. */
330 item = item - ABALTMON_1 + ABMON_1;
331 break;
332# endif
307# if GNULIB_defined_ERA 333# if GNULIB_defined_ERA
308 case ERA: 334 case ERA:
309 /* The format is not standardized. In glibc it is a sequence of strings 335 /* The format is not standardized. In glibc it is a sequence of strings
@@ -330,12 +356,6 @@ rpl_nl_langinfo (nl_item item)
330 strings, appended in memory. */ 356 strings, appended in memory. */
331 return (char *) "\0\0\0\0\0\0\0\0\0\0"; 357 return (char *) "\0\0\0\0\0\0\0\0\0\0";
332# endif 358# endif
333# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
334 case YESEXPR:
335 return (char *) "^[yY]";
336 case NOEXPR:
337 return (char *) "^[nN]";
338# endif
339 default: 359 default:
340 break; 360 break;
341 } 361 }
@@ -449,7 +469,7 @@ nl_langinfo (nl_item item)
449 { 469 {
450 static char const months[][sizeof "September"] = { 470 static char const months[][sizeof "September"] = {
451 "January", "February", "March", "April", "May", "June", "July", 471 "January", "February", "March", "April", "May", "June", "July",
452 "September", "October", "November", "December" 472 "August", "September", "October", "November", "December"
453 }; 473 };
454 case MON_1: 474 case MON_1:
455 case MON_2: 475 case MON_2:
@@ -497,30 +517,57 @@ nl_langinfo (nl_item item)
497 return result[item - ALTMON_1]; 517 return result[item - ALTMON_1];
498 } 518 }
499 } 519 }
500 case ABMON_1: 520 {
501 case ABMON_2: 521 static char const abmonths[][sizeof "Jan"] = {
502 case ABMON_3: 522 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
503 case ABMON_4: 523 "Aug", "Sep", "Oct", "Nov", "Dec"
504 case ABMON_5: 524 };
505 case ABMON_6: 525 case ABMON_1:
506 case ABMON_7: 526 case ABMON_2:
507 case ABMON_8: 527 case ABMON_3:
508 case ABMON_9: 528 case ABMON_4:
509 case ABMON_10: 529 case ABMON_5:
510 case ABMON_11: 530 case ABMON_6:
511 case ABMON_12: 531 case ABMON_7:
512 { 532 case ABMON_8:
513 static char result[12][30]; 533 case ABMON_9:
514 static char const abmonths[][sizeof "Jan"] = { 534 case ABMON_10:
515 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", 535 case ABMON_11:
516 "Sep", "Oct", "Nov", "Dec" 536 case ABMON_12:
517 }; 537 {
518 tmm.tm_mon = item - ABMON_1; 538 static char result[12][30];
519 if (!strftime (buf, sizeof result[0], "%b", &tmm)) 539 tmm.tm_mon = item - ABMON_1;
520 return (char *) abmonths[item - ABMON_1]; 540 if (!strftime (buf, sizeof result[0], "%b", &tmm))
521 strcpy (result[item - ABMON_1], buf); 541 return (char *) abmonths[item - ABMON_1];
522 return result[item - ABMON_1]; 542 strcpy (result[item - ABMON_1], buf);
523 } 543 return result[item - ABMON_1];
544 }
545 case ABALTMON_1:
546 case ABALTMON_2:
547 case ABALTMON_3:
548 case ABALTMON_4:
549 case ABALTMON_5:
550 case ABALTMON_6:
551 case ABALTMON_7:
552 case ABALTMON_8:
553 case ABALTMON_9:
554 case ABALTMON_10:
555 case ABALTMON_11:
556 case ABALTMON_12:
557 {
558 static char result[12][50];
559 tmm.tm_mon = item - ABALTMON_1;
560 /* The platforms without nl_langinfo() don't support strftime with
561 %Ob. We don't even need to try. */
562 #if 0
563 if (!strftime (buf, sizeof result[0], "%Ob", &tmm))
564 #endif
565 if (!strftime (buf, sizeof result[0], "%b", &tmm))
566 return (char *) abmonths[item - ABALTMON_1];
567 strcpy (result[item - ABALTMON_1], buf);
568 return result[item - ABALTMON_1];
569 }
570 }
524 case ERA: 571 case ERA:
525 return (char *) ""; 572 return (char *) "";
526 case ALT_DIGITS: 573 case ALT_DIGITS:
diff --git a/gl/open.c b/gl/open.c
index 7ec8fdc3..c3b5648e 100644
--- a/gl/open.c
+++ b/gl/open.c
@@ -1,5 +1,5 @@
1/* Open a descriptor to a file. 1/* Open a descriptor to a file.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -38,9 +38,7 @@ orig_open (const char *filename, int flags, mode_t mode)
38} 38}
39 39
40/* Specification. */ 40/* Specification. */
41/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates 41#include <fcntl.h>
42 this include because of the preliminary #include <fcntl.h> above. */
43#include "fcntl.h"
44 42
45#include "cloexec.h" 43#include "cloexec.h"
46 44
@@ -51,24 +49,29 @@ orig_open (const char *filename, int flags, mode_t mode)
51#include <sys/stat.h> 49#include <sys/stat.h>
52#include <unistd.h> 50#include <unistd.h>
53 51
52#ifndef HAVE_WORKING_O_DIRECTORY
53# define HAVE_WORKING_O_DIRECTORY false
54#endif
55
56#ifndef OPEN_TRAILING_SLASH_BUG
57# define OPEN_TRAILING_SLASH_BUG false
58#endif
59
54#ifndef REPLACE_OPEN_DIRECTORY 60#ifndef REPLACE_OPEN_DIRECTORY
55# define REPLACE_OPEN_DIRECTORY 0 61# define REPLACE_OPEN_DIRECTORY false
56#endif 62#endif
57 63
64static int
65lstatif (char const *filename, struct stat *st, int flags)
66{
67 return flags & O_NOFOLLOW ? lstat (filename, st) : stat (filename, st);
68}
69
58int 70int
59open (const char *filename, int flags, ...) 71open (const char *filename, int flags, ...)
60{ 72{
61 /* 0 = unknown, 1 = yes, -1 = no. */ 73 mode_t mode = 0;
62#if GNULIB_defined_O_CLOEXEC
63 int have_cloexec = -1;
64#else
65 static int have_cloexec;
66#endif
67 74
68 mode_t mode;
69 int fd;
70
71 mode = 0;
72 if (flags & O_CREAT) 75 if (flags & O_CREAT)
73 { 76 {
74 va_list arg; 77 va_list arg;
@@ -91,11 +94,10 @@ open (const char *filename, int flags, ...)
91#endif 94#endif
92 95
93#if defined _WIN32 && ! defined __CYGWIN__ 96#if defined _WIN32 && ! defined __CYGWIN__
94 if (strcmp (filename, "/dev/null") == 0) 97 if (streq (filename, "/dev/null"))
95 filename = "NUL"; 98 filename = "NUL";
96#endif 99#endif
97 100
98#if OPEN_TRAILING_SLASH_BUG
99 /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename 101 /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename
100 ends in a slash, as POSIX says such a filename must name a directory 102 ends in a slash, as POSIX says such a filename must name a directory
101 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>: 103 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
@@ -114,21 +116,55 @@ open (const char *filename, int flags, ...)
114 directories, 116 directories,
115 - if O_WRONLY or O_RDWR is specified, open() must fail because the 117 - if O_WRONLY or O_RDWR is specified, open() must fail because the
116 file does not contain a '.' directory. */ 118 file does not contain a '.' directory. */
117 if ((flags & O_CREAT) 119 bool check_for_slash_bug;
118 || (flags & O_ACCMODE) == O_RDWR 120 if (OPEN_TRAILING_SLASH_BUG)
119 || (flags & O_ACCMODE) == O_WRONLY)
120 { 121 {
121 size_t len = strlen (filename); 122 size_t len = strlen (filename);
122 if (len > 0 && filename[len - 1] == '/') 123 check_for_slash_bug = len && filename[len - 1] == '/';
124 }
125 else
126 check_for_slash_bug = false;
127
128 if (check_for_slash_bug
129 && (flags & O_CREAT
130 || (flags & O_ACCMODE) == O_RDWR
131 || (flags & O_ACCMODE) == O_WRONLY))
132 {
133 errno = EISDIR;
134 return -1;
135 }
136
137 /* With the trailing slash bug or without working O_DIRECTORY, check with
138 stat first lest we hang trying to open a fifo. Although there is
139 a race between this and opening the file, we can do no better.
140 After opening the file we will check again with fstat. */
141 bool check_directory =
142 (check_for_slash_bug
143 || (!HAVE_WORKING_O_DIRECTORY && flags & O_DIRECTORY));
144 if (check_directory)
145 {
146 struct stat statbuf;
147 if (lstatif (filename, &statbuf, flags) < 0)
148 {
149 if (! (flags & O_CREAT && errno == ENOENT))
150 return -1;
151 }
152 else if (!S_ISDIR (statbuf.st_mode))
123 { 153 {
124 errno = EISDIR; 154 errno = ENOTDIR;
125 return -1; 155 return -1;
126 } 156 }
127 } 157 }
158
159 /* 0 = unknown, 1 = yes, -1 = no. */
160#if GNULIB_defined_O_CLOEXEC
161 int have_cloexec = -1;
162#else
163 static int have_cloexec;
128#endif 164#endif
129 165
130 fd = orig_open (filename, 166 int fd = orig_open (filename,
131 flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode); 167 flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode);
132 168
133 if (flags & O_CLOEXEC) 169 if (flags & O_CLOEXEC)
134 { 170 {
@@ -150,19 +186,21 @@ open (const char *filename, int flags, ...)
150#if REPLACE_FCHDIR 186#if REPLACE_FCHDIR
151 /* Implementing fchdir and fdopendir requires the ability to open a 187 /* Implementing fchdir and fdopendir requires the ability to open a
152 directory file descriptor. If open doesn't support that (as on 188 directory file descriptor. If open doesn't support that (as on
153 mingw), we use a dummy file that behaves the same as directories 189 mingw), use a dummy file that behaves the same as directories
154 on Linux (ie. always reports EOF on attempts to read()), and 190 on Linux (ie. always reports EOF on attempts to read()), and
155 override fstat() in fchdir.c to hide the fact that we have a 191 override fstat in fchdir.c to hide the dummy. */
156 dummy. */
157 if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES 192 if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
158 && ((flags & O_ACCMODE) == O_RDONLY 193 && ((flags & (O_ACCMODE | O_CREAT)) == O_RDONLY
159 || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH))) 194 || (O_SEARCH != O_RDONLY
195 && (flags & (O_ACCMODE | O_CREAT)) == O_SEARCH)))
160 { 196 {
161 struct stat statbuf; 197 struct stat statbuf;
162 if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) 198 if (check_directory
199 || (lstatif (filename, &statbuf, flags) == 0
200 && S_ISDIR (statbuf.st_mode)))
163 { 201 {
164 /* Maximum recursion depth of 1. */ 202 /* Maximum recursion depth of 1. */
165 fd = open ("/dev/null", flags, mode); 203 fd = open ("/dev/null", flags & ~O_DIRECTORY, mode);
166 if (0 <= fd) 204 if (0 <= fd)
167 fd = _gl_register_fd (fd, filename); 205 fd = _gl_register_fd (fd, filename);
168 } 206 }
@@ -171,10 +209,8 @@ open (const char *filename, int flags, ...)
171 } 209 }
172#endif 210#endif
173 211
174#if OPEN_TRAILING_SLASH_BUG 212 /* If checking for directories, fail if fd does not refer to a directory.
175 /* If the filename ends in a slash and fd does not refer to a directory, 213 Rationale: A filename ending in slash cannot name a non-directory
176 then fail.
177 Rationale: POSIX says such a filename must name a directory
178 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>: 214 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
179 "A pathname that contains at least one non-<slash> character and that 215 "A pathname that contains at least one non-<slash> character and that
180 ends with one or more trailing <slash> characters shall not be resolved 216 ends with one or more trailing <slash> characters shall not be resolved
@@ -182,23 +218,18 @@ open (const char *filename, int flags, ...)
182 <slash> characters names an existing directory" 218 <slash> characters names an existing directory"
183 If the named file without the slash is not a directory, open() must fail 219 If the named file without the slash is not a directory, open() must fail
184 with ENOTDIR. */ 220 with ENOTDIR. */
185 if (fd >= 0) 221 if (check_directory && 0 <= fd)
186 { 222 {
187 /* We know len is positive, since open did not fail with ENOENT. */ 223 struct stat statbuf;
188 size_t len = strlen (filename); 224 int r = fstat (fd, &statbuf);
189 if (filename[len - 1] == '/') 225 if (r < 0 || !S_ISDIR (statbuf.st_mode))
190 { 226 {
191 struct stat statbuf; 227 int err = r < 0 ? errno : ENOTDIR;
192 228 close (fd);
193 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) 229 errno = err;
194 { 230 return -1;
195 close (fd);
196 errno = ENOTDIR;
197 return -1;
198 }
199 } 231 }
200 } 232 }
201#endif
202 233
203#if REPLACE_FCHDIR 234#if REPLACE_FCHDIR
204 if (!REPLACE_OPEN_DIRECTORY && 0 <= fd) 235 if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
diff --git a/gl/pathmax.h b/gl/pathmax.h
index 0dd8f3bc..11c13592 100644
--- a/gl/pathmax.h
+++ b/gl/pathmax.h
@@ -1,5 +1,5 @@
1/* Define PATH_MAX somehow. Requires sys/types.h. 1/* Define PATH_MAX somehow. Requires sys/types.h.
2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2023 Free Software 2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2026 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -39,6 +39,11 @@
39 #endif 39 #endif
40 */ 40 */
41 41
42/* This file uses HAVE_SYS_PARAM_H. */
43# if !_GL_CONFIG_H_INCLUDED
44# error "Please include config.h first."
45# endif
46
42# include <unistd.h> 47# include <unistd.h>
43 48
44# include <limits.h> 49# include <limits.h>
diff --git a/gl/printf-args.c b/gl/printf-args.c
index 5e14f654..2f7bf3da 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,5 +1,5 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2023 Free Software 2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2026 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -29,6 +29,12 @@
29# include "printf-args.h" 29# include "printf-args.h"
30#endif 30#endif
31 31
32/* Get INT_WIDTH. */
33#include <limits.h>
34
35/* Get abort(). */
36#include <stdlib.h>
37
32#ifdef STATIC 38#ifdef STATIC
33STATIC 39STATIC
34#endif 40#endif
@@ -71,6 +77,102 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
71 case TYPE_ULONGLONGINT: 77 case TYPE_ULONGLONGINT:
72 ap->a.a_ulonglongint = va_arg (args, unsigned long long int); 78 ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
73 break; 79 break;
80 case TYPE_INT8_T:
81 #if INT8_WIDTH < INT_WIDTH
82 ap->a.a_int8_t = va_arg (args, /* int8_t */ int);
83 #else
84 ap->a.a_int8_t = va_arg (args, int8_t);
85 #endif
86 break;
87 case TYPE_UINT8_T:
88 #if UINT8_WIDTH < INT_WIDTH
89 ap->a.a_uint8_t = va_arg (args, /* uint8_t */ int);
90 #else
91 ap->a.a_uint8_t = va_arg (args, uint8_t);
92 #endif
93 break;
94 case TYPE_INT16_T:
95 #if INT16_WIDTH < INT_WIDTH
96 ap->a.a_int16_t = va_arg (args, /* int16_t */ int);
97 #else
98 ap->a.a_int16_t = va_arg (args, int16_t);
99 #endif
100 break;
101 case TYPE_UINT16_T:
102 #if UINT16_WIDTH < INT_WIDTH
103 ap->a.a_uint16_t = va_arg (args, /* uint16_t */ int);
104 #else
105 ap->a.a_uint16_t = va_arg (args, uint16_t);
106 #endif
107 break;
108 case TYPE_INT32_T:
109 #if INT32_WIDTH < INT_WIDTH
110 ap->a.a_int32_t = va_arg (args, /* int32_t */ int);
111 #else
112 ap->a.a_int32_t = va_arg (args, int32_t);
113 #endif
114 break;
115 case TYPE_UINT32_T:
116 #if UINT32_WIDTH < INT_WIDTH
117 ap->a.a_uint32_t = va_arg (args, /* uint32_t */ int);
118 #else
119 ap->a.a_uint32_t = va_arg (args, uint32_t);
120 #endif
121 break;
122 case TYPE_INT64_T:
123 ap->a.a_int64_t = va_arg (args, int64_t);
124 break;
125 case TYPE_UINT64_T:
126 ap->a.a_uint64_t = va_arg (args, uint64_t);
127 break;
128 case TYPE_INT_FAST8_T:
129 #if INT_FAST8_WIDTH < INT_WIDTH
130 ap->a.a_int_fast8_t = va_arg (args, /* int_fast8_t */ int);
131 #else
132 ap->a.a_int_fast8_t = va_arg (args, int_fast8_t);
133 #endif
134 break;
135 case TYPE_UINT_FAST8_T:
136 #if UINT_FAST8_WIDTH < INT_WIDTH
137 ap->a.a_uint_fast8_t = va_arg (args, /* uint_fast8_t */ int);
138 #else
139 ap->a.a_uint_fast8_t = va_arg (args, uint_fast8_t);
140 #endif
141 break;
142 case TYPE_INT_FAST16_T:
143 #if INT_FAST16_WIDTH < INT_WIDTH
144 ap->a.a_int_fast16_t = va_arg (args, /* int_fast16_t */ int);
145 #else
146 ap->a.a_int_fast16_t = va_arg (args, int_fast16_t);
147 #endif
148 break;
149 case TYPE_UINT_FAST16_T:
150 #if UINT_FAST16_WIDTH < INT_WIDTH
151 ap->a.a_uint_fast16_t = va_arg (args, /* uint_fast16_t */ int);
152 #else
153 ap->a.a_uint_fast16_t = va_arg (args, uint_fast16_t);
154 #endif
155 break;
156 case TYPE_INT_FAST32_T:
157 #if INT_FAST32_WIDTH < INT_WIDTH
158 ap->a.a_int_fast32_t = va_arg (args, /* int_fast32_t */ int);
159 #else
160 ap->a.a_int_fast32_t = va_arg (args, int_fast32_t);
161 #endif
162 break;
163 case TYPE_UINT_FAST32_T:
164 #if UINT_FAST32_WIDTH < INT_WIDTH
165 ap->a.a_uint_fast32_t = va_arg (args, /* uint_fast32_t */ int);
166 #else
167 ap->a.a_uint_fast32_t = va_arg (args, uint_fast32_t);
168 #endif
169 break;
170 case TYPE_INT_FAST64_T:
171 ap->a.a_int_fast64_t = va_arg (args, int_fast64_t);
172 break;
173 case TYPE_UINT_FAST64_T:
174 ap->a.a_uint_fast64_t = va_arg (args, uint_fast64_t);
175 break;
74 case TYPE_DOUBLE: 176 case TYPE_DOUBLE:
75 ap->a.a_double = va_arg (args, double); 177 ap->a.a_double = va_arg (args, double);
76 break; 178 break;
@@ -99,7 +201,6 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
99 if (ap->a.a_string == NULL) 201 if (ap->a.a_string == NULL)
100 ap->a.a_string = "(NULL)"; 202 ap->a.a_string = "(NULL)";
101 break; 203 break;
102#if HAVE_WCHAR_T
103 case TYPE_WIDE_STRING: 204 case TYPE_WIDE_STRING:
104 ap->a.a_wide_string = va_arg (args, const wchar_t *); 205 ap->a.a_wide_string = va_arg (args, const wchar_t *);
105 /* A null pointer is an invalid argument for "%ls", but in practice 206 /* A null pointer is an invalid argument for "%ls", but in practice
@@ -117,7 +218,6 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
117 ap->a.a_wide_string = wide_null_string; 218 ap->a.a_wide_string = wide_null_string;
118 } 219 }
119 break; 220 break;
120#endif
121 case TYPE_POINTER: 221 case TYPE_POINTER:
122 ap->a.a_pointer = va_arg (args, void *); 222 ap->a.a_pointer = va_arg (args, void *);
123 break; 223 break;
@@ -136,6 +236,30 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
136 case TYPE_COUNT_LONGLONGINT_POINTER: 236 case TYPE_COUNT_LONGLONGINT_POINTER:
137 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); 237 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
138 break; 238 break;
239 case TYPE_COUNT_INT8_T_POINTER:
240 ap->a.a_count_int8_t_pointer = va_arg (args, int8_t *);
241 break;
242 case TYPE_COUNT_INT16_T_POINTER:
243 ap->a.a_count_int16_t_pointer = va_arg (args, int16_t *);
244 break;
245 case TYPE_COUNT_INT32_T_POINTER:
246 ap->a.a_count_int32_t_pointer = va_arg (args, int32_t *);
247 break;
248 case TYPE_COUNT_INT64_T_POINTER:
249 ap->a.a_count_int64_t_pointer = va_arg (args, int64_t *);
250 break;
251 case TYPE_COUNT_INT_FAST8_T_POINTER:
252 ap->a.a_count_int_fast8_t_pointer = va_arg (args, int_fast8_t *);
253 break;
254 case TYPE_COUNT_INT_FAST16_T_POINTER:
255 ap->a.a_count_int_fast16_t_pointer = va_arg (args, int_fast16_t *);
256 break;
257 case TYPE_COUNT_INT_FAST32_T_POINTER:
258 ap->a.a_count_int_fast32_t_pointer = va_arg (args, int_fast32_t *);
259 break;
260 case TYPE_COUNT_INT_FAST64_T_POINTER:
261 ap->a.a_count_int_fast64_t_pointer = va_arg (args, int_fast64_t *);
262 break;
139#if ENABLE_UNISTDIO 263#if ENABLE_UNISTDIO
140 /* The unistdio extensions. */ 264 /* The unistdio extensions. */
141 case TYPE_U8_STRING: 265 case TYPE_U8_STRING:
@@ -175,9 +299,19 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
175 } 299 }
176 break; 300 break;
177#endif 301#endif
178 default: 302 case TYPE_NONE:
179 /* Unknown type. */ 303 /* Argument i is not used by any directive, but some argument with
304 number > i is used by a format directive. POSIX says that this
305 is invalid:
306 "When numbered argument specifications are used, specifying the
307 Nth argument requires that all the leading arguments, from the
308 first to the (N-1)th, are specified in the format string."
309 The reason is that we cannot know how many bytes to skip in the
310 va_arg sequence. */
180 return -1; 311 return -1;
312 default:
313 /* Unknown type. Should not happen. */
314 abort ();
181 } 315 }
182 return 0; 316 return 0;
183} 317}
diff --git a/gl/printf-args.h b/gl/printf-args.h
index f303cb19..e72863ef 100644
--- a/gl/printf-args.h
+++ b/gl/printf-args.h
@@ -1,5 +1,5 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2023 Free Software 2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2026 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -28,19 +28,17 @@
28# define PRINTF_FETCHARGS printf_fetchargs 28# define PRINTF_FETCHARGS printf_fetchargs
29#endif 29#endif
30 30
31/* Get size_t. */ 31/* Get size_t, wchar_t. */
32#include <stddef.h> 32#include <stddef.h>
33 33
34/* Get wchar_t. */
35#if HAVE_WCHAR_T
36# include <stddef.h>
37#endif
38
39/* Get wint_t. */ 34/* Get wint_t. */
40#if HAVE_WINT_T 35#if HAVE_WINT_T
41# include <wchar.h> 36# include <wchar.h>
42#endif 37#endif
43 38
39/* Get intN_t, uintN_t, intN_fast_t, uintN_fast_t. */
40#include <stdint.h>
41
44/* Get va_list. */ 42/* Get va_list. */
45#include <stdarg.h> 43#include <stdarg.h>
46 44
@@ -59,6 +57,26 @@ typedef enum
59 TYPE_ULONGINT, 57 TYPE_ULONGINT,
60 TYPE_LONGLONGINT, 58 TYPE_LONGLONGINT,
61 TYPE_ULONGLONGINT, 59 TYPE_ULONGLONGINT,
60 /* According to ISO C 23 § 7.23.6.1, "all exact-width integer types",
61 "all minimum-width integer types", and "all fastest minimum-width integer
62 types" defined in <stdint.h> should be supported. But for portability
63 between platforms, we support only those with N = 8, 16, 32, 64. */
64 TYPE_INT8_T,
65 TYPE_UINT8_T,
66 TYPE_INT16_T,
67 TYPE_UINT16_T,
68 TYPE_INT32_T,
69 TYPE_UINT32_T,
70 TYPE_INT64_T,
71 TYPE_UINT64_T,
72 TYPE_INT_FAST8_T,
73 TYPE_UINT_FAST8_T,
74 TYPE_INT_FAST16_T,
75 TYPE_UINT_FAST16_T,
76 TYPE_INT_FAST32_T,
77 TYPE_UINT_FAST32_T,
78 TYPE_INT_FAST64_T,
79 TYPE_UINT_FAST64_T,
62 TYPE_DOUBLE, 80 TYPE_DOUBLE,
63 TYPE_LONGDOUBLE, 81 TYPE_LONGDOUBLE,
64 TYPE_CHAR, 82 TYPE_CHAR,
@@ -66,15 +84,21 @@ typedef enum
66 TYPE_WIDE_CHAR, 84 TYPE_WIDE_CHAR,
67#endif 85#endif
68 TYPE_STRING, 86 TYPE_STRING,
69#if HAVE_WCHAR_T
70 TYPE_WIDE_STRING, 87 TYPE_WIDE_STRING,
71#endif
72 TYPE_POINTER, 88 TYPE_POINTER,
73 TYPE_COUNT_SCHAR_POINTER, 89 TYPE_COUNT_SCHAR_POINTER,
74 TYPE_COUNT_SHORT_POINTER, 90 TYPE_COUNT_SHORT_POINTER,
75 TYPE_COUNT_INT_POINTER, 91 TYPE_COUNT_INT_POINTER,
76 TYPE_COUNT_LONGINT_POINTER, 92 TYPE_COUNT_LONGINT_POINTER,
77 TYPE_COUNT_LONGLONGINT_POINTER 93 TYPE_COUNT_LONGLONGINT_POINTER,
94 TYPE_COUNT_INT8_T_POINTER,
95 TYPE_COUNT_INT16_T_POINTER,
96 TYPE_COUNT_INT32_T_POINTER,
97 TYPE_COUNT_INT64_T_POINTER,
98 TYPE_COUNT_INT_FAST8_T_POINTER,
99 TYPE_COUNT_INT_FAST16_T_POINTER,
100 TYPE_COUNT_INT_FAST32_T_POINTER,
101 TYPE_COUNT_INT_FAST64_T_POINTER
78#if ENABLE_UNISTDIO 102#if ENABLE_UNISTDIO
79 /* The unistdio extensions. */ 103 /* The unistdio extensions. */
80, TYPE_U8_STRING 104, TYPE_U8_STRING
@@ -99,7 +123,23 @@ typedef struct
99 unsigned long int a_ulongint; 123 unsigned long int a_ulongint;
100 long long int a_longlongint; 124 long long int a_longlongint;
101 unsigned long long int a_ulonglongint; 125 unsigned long long int a_ulonglongint;
102 float a_float; 126 int8_t a_int8_t;
127 uint8_t a_uint8_t;
128 int16_t a_int16_t;
129 uint16_t a_uint16_t;
130 int32_t a_int32_t;
131 uint32_t a_uint32_t;
132 int64_t a_int64_t;
133 uint64_t a_uint64_t;
134 int_fast8_t a_int_fast8_t;
135 uint_fast8_t a_uint_fast8_t;
136 int_fast16_t a_int_fast16_t;
137 uint_fast16_t a_uint_fast16_t;
138 int_fast32_t a_int_fast32_t;
139 uint_fast32_t a_uint_fast32_t;
140 int_fast64_t a_int_fast64_t;
141 uint_fast64_t a_uint_fast64_t;
142 float a_float; /* unused */
103 double a_double; 143 double a_double;
104 long double a_longdouble; 144 long double a_longdouble;
105 int a_char; 145 int a_char;
@@ -107,15 +147,21 @@ typedef struct
107 wint_t a_wide_char; 147 wint_t a_wide_char;
108#endif 148#endif
109 const char* a_string; 149 const char* a_string;
110#if HAVE_WCHAR_T
111 const wchar_t* a_wide_string; 150 const wchar_t* a_wide_string;
112#endif
113 void* a_pointer; 151 void* a_pointer;
114 signed char * a_count_schar_pointer; 152 signed char * a_count_schar_pointer;
115 short * a_count_short_pointer; 153 short * a_count_short_pointer;
116 int * a_count_int_pointer; 154 int * a_count_int_pointer;
117 long int * a_count_longint_pointer; 155 long int * a_count_longint_pointer;
118 long long int * a_count_longlongint_pointer; 156 long long int * a_count_longlongint_pointer;
157 int8_t * a_count_int8_t_pointer;
158 int16_t * a_count_int16_t_pointer;
159 int32_t * a_count_int32_t_pointer;
160 int64_t * a_count_int64_t_pointer;
161 int_fast8_t * a_count_int_fast8_t_pointer;
162 int_fast16_t * a_count_int_fast16_t_pointer;
163 int_fast32_t * a_count_int_fast32_t_pointer;
164 int_fast64_t * a_count_int_fast64_t_pointer;
119#if ENABLE_UNISTDIO 165#if ENABLE_UNISTDIO
120 /* The unistdio extensions. */ 166 /* The unistdio extensions. */
121 const uint8_t * a_u8_string; 167 const uint8_t * a_u8_string;
diff --git a/gl/printf-parse.c b/gl/printf-parse.c
index 3040749a..34d241a6 100644
--- a/gl/printf-parse.c
+++ b/gl/printf-parse.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999-2000, 2002-2003, 2006-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999-2000, 2002-2003, 2006-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -323,229 +323,316 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
323 } 323 }
324 324
325 { 325 {
326 arg_type type;
327
328 /* Parse argument type/size specifiers. */ 326 /* Parse argument type/size specifiers. */
329 { 327 /* Relevant for the conversion characters d, i. */
330 int flags = 0; 328 arg_type signed_type = TYPE_INT;
331 329 /* Relevant for the conversion characters b, o, u, x, X. */
332 for (;;) 330 arg_type unsigned_type = TYPE_UINT;
333 { 331 /* Relevant for the conversion characters n. */
334 if (*cp == 'h') 332 arg_type pointer_type = TYPE_COUNT_INT_POINTER;
335 { 333 /* Relevant for the conversion characters a, A, e, E, f, F, g, G. */
336 flags |= (1 << (flags & 1)); 334 arg_type floatingpoint_type = TYPE_DOUBLE;
337 cp++; 335
338 } 336 if (*cp == 'h')
339 else if (*cp == 'L') 337 {
340 { 338 if (cp[1] == 'h')
341 flags |= 4; 339 {
342 cp++; 340 signed_type = TYPE_SCHAR;
343 } 341 unsigned_type = TYPE_UCHAR;
344 else if (*cp == 'l') 342 pointer_type = TYPE_COUNT_SCHAR_POINTER;
345 { 343 cp += 2;
346 flags += 8; 344 }
347 cp++; 345 else
348 } 346 {
349 else if (*cp == 'j') 347 signed_type = TYPE_SHORT;
350 { 348 unsigned_type = TYPE_USHORT;
351 if (sizeof (intmax_t) > sizeof (long)) 349 pointer_type = TYPE_COUNT_SHORT_POINTER;
352 { 350 cp++;
353 /* intmax_t = long long */ 351 }
354 flags += 16; 352 }
355 } 353 else if (*cp == 'l')
356 else if (sizeof (intmax_t) > sizeof (int)) 354 {
357 { 355 if (cp[1] == 'l')
358 /* intmax_t = long */ 356 {
359 flags += 8; 357 signed_type = TYPE_LONGLONGINT;
360 } 358 unsigned_type = TYPE_ULONGLONGINT;
361 cp++; 359 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
362 } 360 /* For backward compatibility only. */
363 else if (*cp == 'z' || *cp == 'Z') 361 floatingpoint_type = TYPE_LONGDOUBLE;
364 { 362 cp += 2;
365 /* 'z' is standardized in ISO C 99, but glibc uses 'Z' 363 }
366 because the warning facility in gcc-2.95.2 understands 364 else
367 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ 365 {
368 if (sizeof (size_t) > sizeof (long)) 366 signed_type = TYPE_LONGINT;
369 { 367 unsigned_type = TYPE_ULONGINT;
370 /* size_t = long long */ 368 pointer_type = TYPE_COUNT_LONGINT_POINTER;
371 flags += 16; 369 cp++;
372 } 370 }
373 else if (sizeof (size_t) > sizeof (int)) 371 }
374 { 372 else if (*cp == 'j')
375 /* size_t = long */ 373 {
376 flags += 8; 374 if (sizeof (intmax_t) > sizeof (long))
377 } 375 {
378 cp++; 376 /* intmax_t = long long */
379 } 377 signed_type = TYPE_LONGLONGINT;
380 else if (*cp == 't') 378 unsigned_type = TYPE_ULONGLONGINT;
381 { 379 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
382 if (sizeof (ptrdiff_t) > sizeof (long)) 380 /* For backward compatibility only. */
383 { 381 floatingpoint_type = TYPE_LONGDOUBLE;
384 /* ptrdiff_t = long long */ 382 }
385 flags += 16; 383 else if (sizeof (intmax_t) > sizeof (int))
386 } 384 {
387 else if (sizeof (ptrdiff_t) > sizeof (int)) 385 /* intmax_t = long */
388 { 386 signed_type = TYPE_LONGINT;
389 /* ptrdiff_t = long */ 387 unsigned_type = TYPE_ULONGINT;
390 flags += 8; 388 pointer_type = TYPE_COUNT_LONGINT_POINTER;
391 } 389 }
392 cp++; 390 cp++;
393 } 391 }
392 else if (*cp == 'z' || *cp == 'Z')
393 {
394 /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
395 because the warning facility in gcc-2.95.2 understands
396 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
397 if (sizeof (size_t) > sizeof (long))
398 {
399 /* size_t = unsigned long long */
400 signed_type = TYPE_LONGLONGINT;
401 unsigned_type = TYPE_ULONGLONGINT;
402 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
403 /* For backward compatibility only. */
404 floatingpoint_type = TYPE_LONGDOUBLE;
405 }
406 else if (sizeof (size_t) > sizeof (int))
407 {
408 /* size_t = unsigned long */
409 signed_type = TYPE_LONGINT;
410 unsigned_type = TYPE_ULONGINT;
411 pointer_type = TYPE_COUNT_LONGINT_POINTER;
412 }
413 cp++;
414 }
415 else if (*cp == 't')
416 {
417 if (sizeof (ptrdiff_t) > sizeof (long))
418 {
419 /* ptrdiff_t = long long */
420 signed_type = TYPE_LONGLONGINT;
421 unsigned_type = TYPE_ULONGLONGINT;
422 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
423 /* For backward compatibility only. */
424 floatingpoint_type = TYPE_LONGDOUBLE;
425 }
426 else if (sizeof (ptrdiff_t) > sizeof (int))
427 {
428 /* ptrdiff_t = long */
429 signed_type = TYPE_LONGINT;
430 unsigned_type = TYPE_ULONGINT;
431 pointer_type = TYPE_COUNT_LONGINT_POINTER;
432 }
433 cp++;
434 }
435 else if (*cp == 'w')
436 {
437 /* wN and wfN are standardized in ISO C 23. */
438 if (cp[1] == 'f')
439 {
440 if (cp[2] == '8')
441 {
442 signed_type = TYPE_INT_FAST8_T;
443 unsigned_type = TYPE_UINT_FAST8_T;
444 pointer_type = TYPE_COUNT_INT_FAST8_T_POINTER;
445 cp += 3;
446 }
447 else if (cp[2] == '1' && cp[3] == '6')
448 {
449 signed_type = TYPE_INT_FAST16_T;
450 unsigned_type = TYPE_UINT_FAST16_T;
451 pointer_type = TYPE_COUNT_INT_FAST16_T_POINTER;
452 cp += 4;
453 }
454 else if (cp[2] == '3' && cp[3] == '2')
455 {
456 signed_type = TYPE_INT_FAST32_T;
457 unsigned_type = TYPE_UINT_FAST32_T;
458 pointer_type = TYPE_COUNT_INT_FAST32_T_POINTER;
459 cp += 4;
460 }
461 else if (cp[2] == '6' && cp[3] == '4')
462 {
463 signed_type = TYPE_INT_FAST64_T;
464 unsigned_type = TYPE_UINT_FAST64_T;
465 pointer_type = TYPE_COUNT_INT_FAST64_T_POINTER;
466 cp += 4;
467 }
468 }
469 else
470 {
471 if (cp[1] == '8')
472 {
473 signed_type = TYPE_INT8_T;
474 unsigned_type = TYPE_UINT8_T;
475 pointer_type = TYPE_COUNT_INT8_T_POINTER;
476 cp += 2;
477 }
478 else if (cp[1] == '1' && cp[2] == '6')
479 {
480 signed_type = TYPE_INT16_T;
481 unsigned_type = TYPE_UINT16_T;
482 pointer_type = TYPE_COUNT_INT16_T_POINTER;
483 cp += 3;
484 }
485 else if (cp[1] == '3' && cp[2] == '2')
486 {
487 signed_type = TYPE_INT32_T;
488 unsigned_type = TYPE_UINT32_T;
489 pointer_type = TYPE_COUNT_INT32_T_POINTER;
490 cp += 3;
491 }
492 else if (cp[1] == '6' && cp[2] == '4')
493 {
494 signed_type = TYPE_INT64_T;
495 unsigned_type = TYPE_UINT64_T;
496 pointer_type = TYPE_COUNT_INT64_T_POINTER;
497 cp += 3;
498 }
499 }
500 }
501 else if (*cp == 'L')
502 {
503 signed_type = TYPE_LONGLONGINT;
504 unsigned_type = TYPE_ULONGLONGINT;
505 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
506 floatingpoint_type = TYPE_LONGDOUBLE;
507 cp++;
508 }
394#if defined __APPLE__ && defined __MACH__ 509#if defined __APPLE__ && defined __MACH__
395 /* On Mac OS X 10.3, PRIdMAX is defined as "qd". 510 /* On Mac OS X 10.3, PRIdMAX is defined as "qd".
396 We cannot change it to "lld" because PRIdMAX must also 511 We cannot change it to "lld" because PRIdMAX must also
397 be understood by the system's printf routines. */ 512 be understood by the system's printf routines. */
398 else if (*cp == 'q') 513 else if (*cp == 'q')
399 { 514 {
400 if (64 / 8 > sizeof (long)) 515 if (64 / 8 > sizeof (long))
401 { 516 {
402 /* int64_t = long long */ 517 /* int64_t = long long */
403 flags += 16; 518 signed_type = TYPE_LONGLONGINT;
404 } 519 unsigned_type = TYPE_ULONGLONGINT;
405 else 520 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
406 { 521 /* For backward compatibility only. */
407 /* int64_t = long */ 522 floatingpoint_type = TYPE_LONGDOUBLE;
408 flags += 8; 523 }
409 } 524 else
410 cp++; 525 {
411 } 526 /* int64_t = long */
527 signed_type = TYPE_LONGINT;
528 unsigned_type = TYPE_ULONGINT;
529 pointer_type = TYPE_COUNT_LONGINT_POINTER;
530 }
531 cp++;
532 }
412#endif 533#endif
413#if defined _WIN32 && ! defined __CYGWIN__ 534#if defined _WIN32 && ! defined __CYGWIN__
414 /* On native Windows, PRIdMAX is defined as "I64d". 535 /* On native Windows, PRIdMAX is defined as "I64d".
415 We cannot change it to "lld" because PRIdMAX must also 536 We cannot change it to "lld" because PRIdMAX must also
416 be understood by the system's printf routines. */ 537 be understood by the system's printf routines. */
417 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') 538 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
418 { 539 {
419 if (64 / 8 > sizeof (long)) 540 if (64 / 8 > sizeof (long))
420 { 541 {
421 /* __int64 = long long */ 542 /* __int64_t = long long */
422 flags += 16; 543 signed_type = TYPE_LONGLONGINT;
423 } 544 unsigned_type = TYPE_ULONGLONGINT;
424 else 545 pointer_type = TYPE_COUNT_LONGLONGINT_POINTER;
425 { 546 /* For backward compatibility only. */
426 /* __int64 = long */ 547 floatingpoint_type = TYPE_LONGDOUBLE;
427 flags += 8; 548 }
428 } 549 else
429 cp += 3; 550 {
430 } 551 /* __int64_t = long */
552 signed_type = TYPE_LONGINT;
553 unsigned_type = TYPE_ULONGINT;
554 pointer_type = TYPE_COUNT_LONGINT_POINTER;
555 }
556 cp += 3;
557 }
431#endif 558#endif
432 else 559 (void) pointer_type;
433 break;
434 }
435 560
436 /* Read the conversion character. */ 561 /* Read the conversion character. */
437 c = *cp++; 562 arg_type type;
438 switch (c) 563 c = *cp++;
439 { 564 switch (c)
440 case 'd': case 'i': 565 {
441 /* If 'long long' is larger than 'long': */ 566 case 'd': case 'i':
442 if (flags >= 16 || (flags & 4)) 567 type = signed_type;
443 type = TYPE_LONGLONGINT; 568 break;
444 else 569 case 'b': case 'o': case 'u': case 'x': case 'X':
445 /* If 'long long' is the same as 'long', we parse "lld" into 570 #if SUPPORT_GNU_PRINTF_DIRECTIVES \
446 TYPE_LONGINT. */ 571 || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2)
447 if (flags >= 8) 572 case 'B':
448 type = TYPE_LONGINT; 573 #endif
449 else if (flags & 2) 574 type = unsigned_type;
450 type = TYPE_SCHAR; 575 break;
451 else if (flags & 1) 576 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
452 type = TYPE_SHORT; 577 case 'a': case 'A':
453 else 578 type = floatingpoint_type;
454 type = TYPE_INT; 579 break;
455 break; 580 case 'c':
456 case 'o': case 'u': case 'x': case 'X': 581 if (signed_type == TYPE_LONGINT
457 /* If 'unsigned long long' is larger than 'unsigned long': */ 582 /* For backward compatibility only. */
458 if (flags >= 16 || (flags & 4)) 583 || signed_type == TYPE_LONGLONGINT)
459 type = TYPE_ULONGLONGINT;
460 else
461 /* If 'unsigned long long' is the same as 'unsigned long', we
462 parse "llu" into TYPE_ULONGINT. */
463 if (flags >= 8)
464 type = TYPE_ULONGINT;
465 else if (flags & 2)
466 type = TYPE_UCHAR;
467 else if (flags & 1)
468 type = TYPE_USHORT;
469 else
470 type = TYPE_UINT;
471 break;
472 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
473 case 'a': case 'A':
474 if (flags >= 16 || (flags & 4))
475 type = TYPE_LONGDOUBLE;
476 else
477 type = TYPE_DOUBLE;
478 break;
479 case 'c':
480 if (flags >= 8)
481#if HAVE_WINT_T 584#if HAVE_WINT_T
482 type = TYPE_WIDE_CHAR; 585 type = TYPE_WIDE_CHAR;
483#else 586#else
484 goto error; 587 goto error;
485#endif 588#endif
486 else 589 else
487 type = TYPE_CHAR; 590 type = TYPE_CHAR;
488 break; 591 break;
489#if HAVE_WINT_T 592#if HAVE_WINT_T
490 case 'C': 593 case 'C':
491 type = TYPE_WIDE_CHAR; 594 type = TYPE_WIDE_CHAR;
492 c = 'c'; 595 c = 'c';
493 break; 596 break;
494#endif
495 case 's':
496 if (flags >= 8)
497#if HAVE_WCHAR_T
498 type = TYPE_WIDE_STRING;
499#else
500 goto error;
501#endif 597#endif
502 else 598 case 's':
503 type = TYPE_STRING; 599 if (signed_type == TYPE_LONGINT
504 break; 600 /* For backward compatibility only. */
505#if HAVE_WCHAR_T 601 || signed_type == TYPE_LONGLONGINT)
506 case 'S':
507 type = TYPE_WIDE_STRING; 602 type = TYPE_WIDE_STRING;
508 c = 's'; 603 else
509 break; 604 type = TYPE_STRING;
605 break;
606 case 'S':
607 type = TYPE_WIDE_STRING;
608 c = 's';
609 break;
610 case 'p':
611 type = TYPE_POINTER;
612 break;
613#if NEED_PRINTF_WITH_N_DIRECTIVE
614 case 'n':
615 type = pointer_type;
616 break;
510#endif 617#endif
511 case 'p':
512 type = TYPE_POINTER;
513 break;
514 case 'n':
515 /* If 'long long' is larger than 'long': */
516 if (flags >= 16 || (flags & 4))
517 type = TYPE_COUNT_LONGLONGINT_POINTER;
518 else
519 /* If 'long long' is the same as 'long', we parse "lln" into
520 TYPE_COUNT_LONGINT_POINTER. */
521 if (flags >= 8)
522 type = TYPE_COUNT_LONGINT_POINTER;
523 else if (flags & 2)
524 type = TYPE_COUNT_SCHAR_POINTER;
525 else if (flags & 1)
526 type = TYPE_COUNT_SHORT_POINTER;
527 else
528 type = TYPE_COUNT_INT_POINTER;
529 break;
530#if ENABLE_UNISTDIO 618#if ENABLE_UNISTDIO
531 /* The unistdio extensions. */ 619 /* The unistdio extensions. */
532 case 'U': 620 case 'U':
533 if (flags >= 16) 621 if (signed_type == TYPE_LONGLONGINT)
534 type = TYPE_U32_STRING; 622 type = TYPE_U32_STRING;
535 else if (flags >= 8) 623 else if (signed_type == TYPE_LONGINT)
536 type = TYPE_U16_STRING; 624 type = TYPE_U16_STRING;
537 else 625 else
538 type = TYPE_U8_STRING; 626 type = TYPE_U8_STRING;
539 break; 627 break;
540#endif 628#endif
541 case '%': 629 case '%':
542 type = TYPE_NONE; 630 type = TYPE_NONE;
543 break; 631 break;
544 default: 632 default:
545 /* Unknown conversion character. */ 633 /* Unknown conversion character. */
546 goto error; 634 goto error;
547 } 635 }
548 }
549 636
550 if (type != TYPE_NONE) 637 if (type != TYPE_NONE)
551 { 638 {
@@ -566,17 +653,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
566 d->count++; 653 d->count++;
567 if (d->count >= d_allocated) 654 if (d->count >= d_allocated)
568 { 655 {
569 size_t memory_size;
570 DIRECTIVE *memory;
571
572 d_allocated = xtimes (d_allocated, 2); 656 d_allocated = xtimes (d_allocated, 2);
573 memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); 657 size_t memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
574 if (size_overflow_p (memory_size)) 658 if (size_overflow_p (memory_size))
575 /* Overflow, would lead to out of memory. */ 659 /* Overflow, would lead to out of memory. */
576 goto out_of_memory; 660 goto out_of_memory;
577 memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir 661 DIRECTIVE *memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
578 ? realloc (d->dir, memory_size) 662 ? realloc (d->dir, memory_size)
579 : malloc (memory_size)); 663 : malloc (memory_size));
580 if (memory == NULL) 664 if (memory == NULL)
581 /* Out of memory. */ 665 /* Out of memory. */
582 goto out_of_memory; 666 goto out_of_memory;
diff --git a/gl/printf-parse.h b/gl/printf-parse.h
index 1f86e32c..17164f0e 100644
--- a/gl/printf-parse.h
+++ b/gl/printf-parse.h
@@ -1,5 +1,5 @@
1/* Parse printf format string. 1/* Parse printf format string.
2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2023 Free Software 2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2026 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -61,7 +61,7 @@ typedef struct
61 const char* precision_start; 61 const char* precision_start;
62 const char* precision_end; 62 const char* precision_end;
63 size_t precision_arg_index; 63 size_t precision_arg_index;
64 char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ 64 char conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */
65 size_t arg_index; 65 size_t arg_index;
66} 66}
67char_directive; 67char_directive;
@@ -91,7 +91,7 @@ typedef struct
91 const uint8_t* precision_start; 91 const uint8_t* precision_start;
92 const uint8_t* precision_end; 92 const uint8_t* precision_end;
93 size_t precision_arg_index; 93 size_t precision_arg_index;
94 uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ 94 uint8_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */
95 size_t arg_index; 95 size_t arg_index;
96} 96}
97u8_directive; 97u8_directive;
@@ -119,7 +119,7 @@ typedef struct
119 const uint16_t* precision_start; 119 const uint16_t* precision_start;
120 const uint16_t* precision_end; 120 const uint16_t* precision_end;
121 size_t precision_arg_index; 121 size_t precision_arg_index;
122 uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ 122 uint16_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */
123 size_t arg_index; 123 size_t arg_index;
124} 124}
125u16_directive; 125u16_directive;
@@ -147,7 +147,7 @@ typedef struct
147 const uint32_t* precision_start; 147 const uint32_t* precision_start;
148 const uint32_t* precision_end; 148 const uint32_t* precision_end;
149 size_t precision_arg_index; 149 size_t precision_arg_index;
150 uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ 150 uint32_t conversion; /* d i b B o u x X f F e E g G a A c s p n U % but not C S */
151 size_t arg_index; 151 size_t arg_index;
152} 152}
153u32_directive; 153u32_directive;
diff --git a/gl/pthread-once.c b/gl/pthread-once.c
new file mode 100644
index 00000000..823f0639
--- /dev/null
+++ b/gl/pthread-once.c
@@ -0,0 +1,148 @@
1/* POSIX once-only control.
2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#include <config.h>
20
21/* Specification. */
22#include <pthread.h>
23
24#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
25# include "windows-once.h"
26#endif
27
28#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
29/* Use Windows threads. */
30
31int
32pthread_once (pthread_once_t *once_control, void (*initfunction) (void))
33{
34 glwthread_once (once_control, initfunction);
35 return 0;
36}
37
38#elif HAVE_PTHREAD_H
39/* Provide workarounds for POSIX threads. */
40
41# if defined __CYGWIN__
42
43# include <stdlib.h>
44
45int
46pthread_once (pthread_once_t *once_control, void (*initfunction) (void))
47{
48 /* In this implementation, we reuse the type
49 typedef struct { pthread_mutex_t mutex; int state; } pthread_once_t;
50 #define PTHREAD_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, 0 }
51 while assigning the following meaning to the state:
52 state = (<number of waiting threads> << 16) + <1 if done>
53 In other words:
54 state = { unsigned int num_threads : 16; unsigned int done : 16; }
55 */
56 struct actual_state
57 {
58 _Atomic unsigned short num_threads;
59 /* done == 0: initial state
60 done == 1: initfunction executed, lock still active
61 done == 2: initfunction executed, lock no longer usable */
62 _Atomic unsigned short done;
63 };
64 struct actual_state *state_p = (struct actual_state *) &once_control->state;
65 /* This test is not necessary. It's only an optimization, to establish
66 a fast path for the common case that the 'done' word is already > 0. */
67 if (state_p->done == 0)
68 {
69 /* Increment num_threads (atomically), to indicate that this thread will
70 possibly take the lock. */
71 state_p->num_threads += 1;
72 /* Test the 'done' word. */
73 if (state_p->done == 0)
74 {
75 /* The 'done' word is still zero. Now take the lock. */
76 pthread_mutex_lock (&once_control->mutex);
77 /* Test the 'done' word again. */
78 if (state_p->done == 0)
79 {
80 /* Execute the initfunction. */
81 (*initfunction) ();
82 /* Set the 'done' word to 1 (atomically). */
83 state_p->done = 1;
84 }
85 /* Now the 'done' word is 1. Release the lock. */
86 pthread_mutex_unlock (&once_control->mutex);
87 }
88 /* Here, done is > 0. */
89 /* Decrement num_threads (atomically). */
90 if ((state_p->num_threads -= 1) == 0)
91 {
92 /* num_threads is now zero, and done is > 0.
93 No other thread will need to use the lock.
94 We can therefore destroy the lock, to free resources. */
95 if (__sync_bool_compare_and_swap (&state_p->done, 1, 2))
96 pthread_mutex_destroy (&once_control->mutex);
97 }
98 }
99 /* Proof of correctness:
100 * num_threads is incremented and then decremented by some threads.
101 Therefore, num_threads always stays >= 0, and is == 0 at the end.
102 * The 'done' word, once > 0, stays > 0 (since it is never assigned 0).
103 * The 'done' word is changed from == 0 to > 0 only while the lock
104 is taken. Therefore, only the first thread that succeeds in taking
105 the lock executes the initfunction and sets the 'done' word to a
106 value > 0; the other threads that take the lock do no side effects
107 between taking and releasing the lock.
108 * The 'done' word does not change any more once it is 2.
109 Therefore, it can be changed from 1 to 2 only once.
110 * pthread_mutex_destroy gets invoked right after 'done' has been changed
111 from 1 to 2. Therefore, pthread_mutex_destroy gets invoked only once.
112 * After a moment where num_threads was 0 and done was > 0, no thread can
113 reach the pthread_mutex_lock invocation. Proof:
114 - At such a moment, no thread is in the code range between
115 state_p->num_threads += 1
116 and
117 state_p->num_threads -= 1
118 - After such a moment, some thread can increment num_threads, but from
119 there they cannot reach the pthread_mutex_lock invocation, because the
120 if (state_p->done == 0)
121 test prevents that.
122 * From this it follows that:
123 - pthread_mutex_destroy cannot be executed while the lock is taken
124 (because pthread_mutex_destroy is only executed after a moment where
125 num_threads was 0 and done was > 0).
126 - Once pthread_mutex_destroy has been executed, the lock is not used any
127 more.
128 */
129 return 0;
130}
131
132# endif
133
134#else
135/* Provide a dummy implementation for single-threaded applications. */
136
137int
138pthread_once (pthread_once_t *once_control, void (*initfunction) (void))
139{
140 if (*once_control == 0)
141 {
142 *once_control = ~ 0;
143 initfunction ();
144 }
145 return 0;
146}
147
148#endif
diff --git a/gl/pthread.in.h b/gl/pthread.in.h
new file mode 100644
index 00000000..37deab82
--- /dev/null
+++ b/gl/pthread.in.h
@@ -0,0 +1,1981 @@
1/* Implement the most essential subset of POSIX pthread.h.
2
3 Copyright (C) 2009-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert, Glen Lenker, and Bruno Haible. */
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_PTHREAD_H
26/* Special invocation convention:
27 On Android, we have a sequence of nested includes
28 <pthread.h> -> <time.h> -> <sys/time.h> -> <sys/select.h> ->
29 <signal.h> -> <pthread.h>.
30 In this situation, PTHREAD_COND_INITIALIZER is not yet defined,
31 therefore we should not attempt to define PTHREAD_MUTEX_NORMAL etc. */
32
33#@INCLUDE_NEXT@ @NEXT_PTHREAD_H@
34
35#else
36/* Normal invocation convention. */
37
38#ifndef _@GUARD_PREFIX@_PTHREAD_H_
39
40#if @HAVE_PTHREAD_H@
41
42# define _@GUARD_PREFIX@_ALREADY_INCLUDING_PTHREAD_H
43
44/* The include_next requires a split double-inclusion guard. */
45# @INCLUDE_NEXT@ @NEXT_PTHREAD_H@
46
47# undef _@GUARD_PREFIX@_ALREADY_INCLUDING_PTHREAD_H
48
49#endif
50
51#ifndef _@GUARD_PREFIX@_PTHREAD_H_
52#define _@GUARD_PREFIX@_PTHREAD_H_
53
54/* This file uses _Noreturn, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
55 HAVE_RAW_DECL_*. */
56#if !_GL_CONFIG_H_INCLUDED
57 #error "Please include config.h first."
58#endif
59
60#define __need_system_stdlib_h
61#include <stdlib.h>
62#undef __need_system_stdlib_h
63
64
65/* The pthreads-win32 <pthread.h> defines a couple of broken macros. */
66#undef asctime_r
67#undef ctime_r
68#undef gmtime_r
69#undef localtime_r
70#undef rand_r
71#undef strtok_r
72
73#include <errno.h>
74#include <sched.h>
75#include <sys/types.h>
76#include <time.h>
77
78/* The __attribute__ feature is available in gcc versions 2.5 and later.
79 The attribute __pure__ was added in gcc 2.96. */
80#ifndef _GL_ATTRIBUTE_PURE
81# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
82# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
83# else
84# define _GL_ATTRIBUTE_PURE /* empty */
85# endif
86#endif
87
88/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
89
90/* The definition of _Noreturn is copied here. */
91
92/* The definition of _GL_ARG_NONNULL is copied here. */
93
94/* The definition of _GL_WARN_ON_USE is copied here. */
95
96/* =========== Thread types and macros =========== */
97
98#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
99# if @GNULIB_PTHREAD_THREAD@
100# include "windows-thread.h"
101# if @HAVE_PTHREAD_T@
102# define pthread_t rpl_pthread_t
103# define pthread_attr_t rpl_pthread_attr_t
104# endif
105# if !GNULIB_defined_pthread_thread_types
106typedef glwthread_thread_t pthread_t;
107typedef unsigned int pthread_attr_t;
108# define GNULIB_defined_pthread_thread_types 1
109# endif
110# else
111# if @HAVE_PTHREAD_T@
112# define pthread_t rpl_pthread_t
113# define pthread_attr_t rpl_pthread_attr_t
114# endif
115# if !GNULIB_defined_pthread_thread_types
116typedef int pthread_t;
117typedef unsigned int pthread_attr_t;
118# define GNULIB_defined_pthread_thread_types 1
119# endif
120# endif
121# undef PTHREAD_CREATE_JOINABLE
122# undef PTHREAD_CREATE_DETACHED
123# define PTHREAD_CREATE_JOINABLE 0
124# define PTHREAD_CREATE_DETACHED 1
125#else
126# if !@HAVE_PTHREAD_T@
127# if !GNULIB_defined_pthread_thread_types
128typedef int pthread_t;
129typedef unsigned int pthread_attr_t;
130# define GNULIB_defined_pthread_thread_types 1
131# endif
132# endif
133# if !@HAVE_PTHREAD_CREATE_DETACHED@
134# define PTHREAD_CREATE_JOINABLE 0
135# define PTHREAD_CREATE_DETACHED 1
136# endif
137#endif
138
139/* =========== Once-only control (initialization) types and macros ========== */
140
141#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
142# if @GNULIB_PTHREAD_ONCE@
143# include "windows-once.h"
144# if @HAVE_PTHREAD_T@
145# define pthread_once_t rpl_pthread_once_t
146# endif
147# if !GNULIB_defined_pthread_once_types
148typedef glwthread_once_t pthread_once_t;
149# define GNULIB_defined_pthread_once_types 1
150# endif
151# undef PTHREAD_ONCE_INIT
152# define PTHREAD_ONCE_INIT GLWTHREAD_ONCE_INIT
153# else
154# if @HAVE_PTHREAD_T@
155# define pthread_once_t rpl_pthread_once_t
156# endif
157# if !GNULIB_defined_pthread_once_types
158typedef int pthread_once_t;
159# define GNULIB_defined_pthread_once_types 1
160# endif
161# undef PTHREAD_ONCE_INIT
162# define PTHREAD_ONCE_INIT { 0 }
163# endif
164#else
165# if !@HAVE_PTHREAD_T@
166# if !GNULIB_defined_pthread_once_types
167typedef int pthread_once_t;
168# define GNULIB_defined_pthread_once_types 1
169# endif
170# undef PTHREAD_ONCE_INIT
171# define PTHREAD_ONCE_INIT { 0 }
172# endif
173#endif
174
175/* =========== Mutex types and macros =========== */
176
177#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
178# if @GNULIB_PTHREAD_MUTEX@
179# include "windows-timedmutex.h"
180# include "windows-timedrecmutex.h"
181# if @HAVE_PTHREAD_T@
182# define pthread_mutex_t rpl_pthread_mutex_t
183# define pthread_mutexattr_t rpl_pthread_mutexattr_t
184# endif
185# if !GNULIB_defined_pthread_mutex_types
186typedef struct
187 {
188 int type;
189 union
190 {
191 glwthread_timedmutex_t u_timedmutex;
192 glwthread_timedrecmutex_t u_timedrecmutex;
193 }
194 u;
195 }
196 pthread_mutex_t;
197typedef unsigned int pthread_mutexattr_t;
198# define GNULIB_defined_pthread_mutex_types 1
199# endif
200# undef PTHREAD_MUTEX_INITIALIZER
201# define PTHREAD_MUTEX_INITIALIZER { 1, { GLWTHREAD_TIMEDMUTEX_INIT } }
202# else
203# if @HAVE_PTHREAD_T@
204# define pthread_mutex_t rpl_pthread_mutex_t
205# define pthread_mutexattr_t rpl_pthread_mutexattr_t
206# endif
207# if !GNULIB_defined_pthread_mutex_types
208typedef int pthread_mutex_t;
209typedef unsigned int pthread_mutexattr_t;
210# define GNULIB_defined_pthread_mutex_types 1
211# endif
212# undef PTHREAD_MUTEX_INITIALIZER
213# define PTHREAD_MUTEX_INITIALIZER { 0 }
214# endif
215# undef PTHREAD_MUTEX_DEFAULT
216# undef PTHREAD_MUTEX_NORMAL
217# undef PTHREAD_MUTEX_ERRORCHECK
218# undef PTHREAD_MUTEX_RECURSIVE
219# define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
220# define PTHREAD_MUTEX_NORMAL 0
221# define PTHREAD_MUTEX_ERRORCHECK 1
222# define PTHREAD_MUTEX_RECURSIVE 2
223# undef PTHREAD_MUTEX_STALLED
224# undef PTHREAD_MUTEX_ROBUST
225# define PTHREAD_MUTEX_STALLED 0
226# define PTHREAD_MUTEX_ROBUST 1
227#else
228# if !@HAVE_PTHREAD_T@
229# if !GNULIB_defined_pthread_mutex_types
230typedef int pthread_mutex_t;
231typedef unsigned int pthread_mutexattr_t;
232# define GNULIB_defined_pthread_mutex_types 1
233# endif
234# undef PTHREAD_MUTEX_INITIALIZER
235# define PTHREAD_MUTEX_INITIALIZER { 0 }
236# endif
237# if !@HAVE_PTHREAD_MUTEX_RECURSIVE@
238# define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
239# define PTHREAD_MUTEX_NORMAL 0
240# define PTHREAD_MUTEX_ERRORCHECK 1
241# define PTHREAD_MUTEX_RECURSIVE 2
242# endif
243# if !@HAVE_PTHREAD_MUTEX_ROBUST@
244# define PTHREAD_MUTEX_STALLED 0
245# define PTHREAD_MUTEX_ROBUST 1
246# endif
247#endif
248
249/* =========== Read-write lock types and macros =========== */
250
251#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
252# if @GNULIB_PTHREAD_RWLOCK@
253# include "windows-timedrwlock.h"
254# if @HAVE_PTHREAD_T@
255# define pthread_rwlock_t rpl_pthread_rwlock_t
256# define pthread_rwlockattr_t rpl_pthread_rwlockattr_t
257# endif
258# if !GNULIB_defined_pthread_rwlock_types
259typedef glwthread_timedrwlock_t pthread_rwlock_t;
260typedef unsigned int pthread_rwlockattr_t;
261# define GNULIB_defined_pthread_rwlock_types 1
262# endif
263# undef PTHREAD_RWLOCK_INITIALIZER
264# define PTHREAD_RWLOCK_INITIALIZER GLWTHREAD_TIMEDRWLOCK_INIT
265# else
266# if @HAVE_PTHREAD_T@
267# define pthread_rwlock_t rpl_pthread_rwlock_t
268# define pthread_rwlockattr_t rpl_pthread_rwlockattr_t
269# endif
270# if !GNULIB_defined_pthread_rwlock_types
271typedef int pthread_rwlock_t;
272typedef unsigned int pthread_rwlockattr_t;
273# define GNULIB_defined_pthread_rwlock_types 1
274# endif
275# undef PTHREAD_RWLOCK_INITIALIZER
276# define PTHREAD_RWLOCK_INITIALIZER { 0 }
277# endif
278#elif @GNULIB_PTHREAD_RWLOCK@ && @REPLACE_PTHREAD_RWLOCK_DESTROY@ /* i.e. PTHREAD_RWLOCK_UNIMPLEMENTED */
279# if @HAVE_PTHREAD_T@
280# define pthread_rwlock_t rpl_pthread_rwlock_t
281# define pthread_rwlockattr_t rpl_pthread_rwlockattr_t
282# endif
283# if !GNULIB_defined_pthread_rwlock_types
284typedef struct
285 {
286 pthread_mutex_t lock; /* protects the remaining fields */
287 pthread_cond_t waiting_readers; /* waiting readers */
288 pthread_cond_t waiting_writers; /* waiting writers */
289 unsigned int waiting_writers_count; /* number of waiting writers */
290 int runcount; /* number of readers running, or -1 when a writer runs */
291 }
292 pthread_rwlock_t;
293typedef unsigned int pthread_rwlockattr_t;
294# define GNULIB_defined_pthread_rwlock_types 1
295# endif
296# undef PTHREAD_RWLOCK_INITIALIZER
297# define PTHREAD_RWLOCK_INITIALIZER \
298 { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
299#elif @GNULIB_PTHREAD_RWLOCK@ && @REPLACE_PTHREAD_RWLOCK_INIT@ /* i.e. PTHREAD_RWLOCK_BAD_WAITQUEUE */
300/* Use rwlocks of kind PREFER_WRITER or PREFER_WRITER_NONRECURSIVE instead of
301 the DEFAULT. */
302# undef PTHREAD_RWLOCK_INITIALIZER
303# define PTHREAD_RWLOCK_INITIALIZER PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
304#else
305# if @HAVE_PTHREAD_T@
306# if !defined PTHREAD_RWLOCK_INITIALIZER && defined PTHREAD_RWLOCK_INITIALIZER_NP /* z/OS */
307# define PTHREAD_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER_NP
308# endif
309# else
310# if !GNULIB_defined_pthread_rwlock_types
311typedef int pthread_rwlock_t;
312typedef unsigned int pthread_rwlockattr_t;
313# define GNULIB_defined_pthread_rwlock_types 1
314# endif
315# undef PTHREAD_RWLOCK_INITIALIZER
316# define PTHREAD_RWLOCK_INITIALIZER { 0 }
317# endif
318#endif
319
320/* =========== Condition variable types and macros =========== */
321
322#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
323# if @GNULIB_PTHREAD_COND@
324# include "windows-cond.h"
325# if @HAVE_PTHREAD_T@
326# define pthread_cond_t rpl_pthread_cond_t
327# define pthread_condattr_t rpl_pthread_condattr_t
328# endif
329# if !GNULIB_defined_pthread_cond_types
330typedef glwthread_cond_t pthread_cond_t;
331typedef unsigned int pthread_condattr_t;
332# define GNULIB_defined_pthread_cond_types 1
333# endif
334# undef PTHREAD_COND_INITIALIZER
335# define PTHREAD_COND_INITIALIZER GLWTHREAD_COND_INIT
336# else
337# if @HAVE_PTHREAD_T@
338# define pthread_cond_t rpl_pthread_cond_t
339# define pthread_condattr_t rpl_pthread_condattr_t
340# endif
341# if !GNULIB_defined_pthread_cond_types
342typedef int pthread_cond_t;
343typedef unsigned int pthread_condattr_t;
344# define GNULIB_defined_pthread_cond_types 1
345# endif
346# undef PTHREAD_COND_INITIALIZER
347# define PTHREAD_COND_INITIALIZER { 0 }
348# endif
349#else
350# if !@HAVE_PTHREAD_T@
351# if !GNULIB_defined_pthread_cond_types
352typedef int pthread_cond_t;
353typedef unsigned int pthread_condattr_t;
354# define GNULIB_defined_pthread_cond_types 1
355# endif
356# undef PTHREAD_COND_INITIALIZER
357# define PTHREAD_COND_INITIALIZER { 0 }
358# endif
359#endif
360
361/* =========== Thread-specific storage types and macros =========== */
362
363#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
364# if @GNULIB_PTHREAD_TSS@
365# include "windows-tls.h"
366# if @HAVE_PTHREAD_T@
367# define pthread_key_t rpl_pthread_key_t
368# endif
369# if !GNULIB_defined_pthread_tss_types
370typedef glwthread_tls_key_t pthread_key_t;
371# define GNULIB_defined_pthread_tss_types 1
372# endif
373# undef PTHREAD_DESTRUCTOR_ITERATIONS
374# define PTHREAD_DESTRUCTOR_ITERATIONS GLWTHREAD_DESTRUCTOR_ITERATIONS
375# else
376# if @HAVE_PTHREAD_T@
377# define pthread_key_t rpl_pthread_key_t
378# endif
379# if !GNULIB_defined_pthread_tss_types
380typedef void ** pthread_key_t;
381# define GNULIB_defined_pthread_tss_types 1
382# endif
383# undef PTHREAD_DESTRUCTOR_ITERATIONS
384# define PTHREAD_DESTRUCTOR_ITERATIONS 0
385# endif
386#else
387# if !@HAVE_PTHREAD_T@
388# if !GNULIB_defined_pthread_tss_types
389typedef void ** pthread_key_t;
390# define GNULIB_defined_pthread_tss_types 1
391# endif
392# undef PTHREAD_DESTRUCTOR_ITERATIONS
393# define PTHREAD_DESTRUCTOR_ITERATIONS 0
394# endif
395#endif
396
397/* =========== Spinlock types and macros =========== */
398
399#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
400# if @GNULIB_PTHREAD_SPIN@
401# include "windows-spin.h"
402# if @HAVE_PTHREAD_T@
403# define pthread_spinlock_t rpl_pthread_spinlock_t
404# endif
405# if !GNULIB_defined_pthread_spin_types
406typedef glwthread_spinlock_t pthread_spinlock_t;
407# define GNULIB_defined_pthread_spin_types 1
408# endif
409# else
410# if @HAVE_PTHREAD_T@
411# define pthread_spinlock_t rpl_pthread_spinlock_t
412# endif
413# if !GNULIB_defined_pthread_spin_types
414typedef pthread_mutex_t pthread_spinlock_t;
415# define GNULIB_defined_pthread_spin_types 1
416# endif
417# endif
418# undef PTHREAD_PROCESS_PRIVATE
419# undef PTHREAD_PROCESS_SHARED
420# define PTHREAD_PROCESS_PRIVATE 0
421# define PTHREAD_PROCESS_SHARED 1
422#else
423# if @HAVE_PTHREAD_SPINLOCK_T@
424/* <pthread.h> exists and defines pthread_spinlock_t. */
425# if !@HAVE_PTHREAD_SPIN_INIT@ || @REPLACE_PTHREAD_SPIN_INIT@
426/* If the 'pthread-spin' module is in use, it defines all the pthread_spin*
427 functions. Prepare for it by overriding pthread_spinlock_t if that might
428 be needed. */
429# if !(((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \
430 || __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) \
431 || (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
432 && !defined __ANDROID__) \
433 || __clang_major__ >= 3)) \
434 && !defined __ibmxl__)
435/* We can't use GCC built-ins. Approximate spinlocks with mutexes. */
436# if !GNULIB_defined_pthread_spin_types
437# define pthread_spinlock_t pthread_mutex_t
438# define GNULIB_defined_pthread_spin_types 1
439# endif
440# endif
441# endif
442# else
443/* Approximate spinlocks with mutexes. */
444# if !GNULIB_defined_pthread_spin_types
445typedef pthread_mutex_t pthread_spinlock_t;
446# define GNULIB_defined_pthread_spin_types 1
447# endif
448# endif
449# if !@HAVE_PTHREAD_PROCESS_SHARED@
450# define PTHREAD_PROCESS_PRIVATE 0
451# define PTHREAD_PROCESS_SHARED 1
452# endif
453#endif
454
455/* =========== Other types and macros =========== */
456
457#if !@HAVE_PTHREAD_T@
458# if !GNULIB_defined_other_pthread_types
459typedef int pthread_barrier_t;
460typedef unsigned int pthread_barrierattr_t;
461# define GNULIB_defined_other_pthread_types 1
462# endif
463#endif
464
465#if !defined PTHREAD_CANCELED
466
467# define PTHREAD_BARRIER_SERIAL_THREAD (-1)
468
469# define PTHREAD_CANCEL_DEFERRED 0
470# define PTHREAD_CANCEL_ASYNCHRONOUS 1
471
472# define PTHREAD_CANCEL_ENABLE 0
473# define PTHREAD_CANCEL_DISABLE 1
474
475# define PTHREAD_CANCELED ((void *) -1)
476
477# define PTHREAD_INHERIT_SCHED 0
478# define PTHREAD_EXPLICIT_SCHED 1
479
480# define PTHREAD_PRIO_NONE 0
481# define PTHREAD_PRIO_INHERIT 1
482# define PTHREAD_PRIO_PROTECT 2
483
484# define PTHREAD_SCOPE_SYSTEM 0
485# define PTHREAD_SCOPE_PROCESS 1
486
487#endif
488
489/* =========== Thread functions =========== */
490
491#if @GNULIB_PTHREAD_THREAD@
492/* The 'restrict' qualifier on ARG is nonsense, but POSIX specifies it this way.
493 Sigh. */
494# if @REPLACE_PTHREAD_CREATE@
495# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
496# undef pthread_create
497# define pthread_create rpl_pthread_create
498# endif
499_GL_FUNCDECL_RPL (pthread_create, int,
500 (pthread_t *restrict threadp,
501 const pthread_attr_t *restrict attr,
502 void * (*mainfunc) (void *), void *restrict arg),
503 _GL_ARG_NONNULL ((1, 3)));
504_GL_CXXALIAS_RPL (pthread_create, int,
505 (pthread_t *restrict threadp,
506 const pthread_attr_t *restrict attr,
507 void * (*mainfunc) (void *), void *restrict arg));
508# else
509# if !@HAVE_PTHREAD_CREATE@
510_GL_FUNCDECL_SYS (pthread_create, int,
511 (pthread_t *restrict threadp,
512 const pthread_attr_t *restrict attr,
513 void * (*mainfunc) (void *), void *restrict arg),
514 _GL_ARG_NONNULL ((1, 3)));
515# endif
516_GL_CXXALIAS_SYS_CAST (pthread_create, int,
517 (pthread_t *restrict threadp,
518 const pthread_attr_t *restrict attr,
519 void * (*mainfunc) (void *), void *restrict arg));
520# endif
521# if __GLIBC__ >= 2
522_GL_CXXALIASWARN (pthread_create);
523# endif
524#elif defined GNULIB_POSIXCHECK
525# if HAVE_RAW_DECL_PTHREAD_CREATE
526_GL_WARN_ON_USE (pthread_create, "pthread_create is not portable - "
527 "use gnulib module pthread-thread for portability");
528# endif
529#endif
530
531#if @GNULIB_PTHREAD_THREAD@
532# if @REPLACE_PTHREAD_ATTR_INIT@
533# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
534# undef pthread_attr_init
535# define pthread_attr_init rpl_pthread_attr_init
536# endif
537_GL_FUNCDECL_RPL (pthread_attr_init, int, (pthread_attr_t *attr),
538 _GL_ARG_NONNULL ((1)));
539_GL_CXXALIAS_RPL (pthread_attr_init, int, (pthread_attr_t *attr));
540# else
541# if !@HAVE_PTHREAD_ATTR_INIT@
542_GL_FUNCDECL_SYS (pthread_attr_init, int, (pthread_attr_t *attr),
543 _GL_ARG_NONNULL ((1)));
544# endif
545_GL_CXXALIAS_SYS (pthread_attr_init, int, (pthread_attr_t *attr));
546# endif
547# if __GLIBC__ >= 2
548_GL_CXXALIASWARN (pthread_attr_init);
549# endif
550#elif defined GNULIB_POSIXCHECK
551# if HAVE_RAW_DECL_PTHREAD_ATTR_INIT
552_GL_WARN_ON_USE (pthread_attr_init, "pthread_attr_init is not portable - "
553 "use gnulib module pthread-thread for portability");
554# endif
555#endif
556
557#if @GNULIB_PTHREAD_THREAD@
558# if @REPLACE_PTHREAD_ATTR_GETDETACHSTATE@
559# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
560# undef pthread_attr_getdetachstate
561# define pthread_attr_getdetachstate rpl_pthread_attr_getdetachstate
562# endif
563_GL_FUNCDECL_RPL (pthread_attr_getdetachstate, int,
564 (const pthread_attr_t *attr, int *detachstatep),
565 _GL_ARG_NONNULL ((1, 2)));
566_GL_CXXALIAS_RPL (pthread_attr_getdetachstate, int,
567 (const pthread_attr_t *attr, int *detachstatep));
568# else
569# if !@HAVE_PTHREAD_ATTR_GETDETACHSTATE@
570_GL_FUNCDECL_SYS (pthread_attr_getdetachstate, int,
571 (const pthread_attr_t *attr, int *detachstatep),
572 _GL_ARG_NONNULL ((1, 2)));
573# endif
574_GL_CXXALIAS_SYS (pthread_attr_getdetachstate, int,
575 (const pthread_attr_t *attr, int *detachstatep));
576# endif
577# if __GLIBC__ >= 2
578_GL_CXXALIASWARN (pthread_attr_getdetachstate);
579# endif
580#elif defined GNULIB_POSIXCHECK
581# if HAVE_RAW_DECL_PTHREAD_ATTR_GETDETACHSTATE
582_GL_WARN_ON_USE (pthread_attr_getdetachstate, "pthread_attr_getdetachstate is not portable - "
583 "use gnulib module pthread-thread for portability");
584# endif
585#endif
586
587#if @GNULIB_PTHREAD_THREAD@
588# if @REPLACE_PTHREAD_ATTR_SETDETACHSTATE@
589# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
590# undef pthread_attr_setdetachstate
591# define pthread_attr_setdetachstate rpl_pthread_attr_setdetachstate
592# endif
593_GL_FUNCDECL_RPL (pthread_attr_setdetachstate, int,
594 (pthread_attr_t *attr, int detachstate),
595 _GL_ARG_NONNULL ((1)));
596_GL_CXXALIAS_RPL (pthread_attr_setdetachstate, int,
597 (pthread_attr_t *attr, int detachstate));
598# else
599# if !@HAVE_PTHREAD_ATTR_SETDETACHSTATE@
600_GL_FUNCDECL_SYS (pthread_attr_setdetachstate, int,
601 (pthread_attr_t *attr, int detachstate),
602 _GL_ARG_NONNULL ((1)));
603# endif
604_GL_CXXALIAS_SYS (pthread_attr_setdetachstate, int,
605 (pthread_attr_t *attr, int detachstate));
606# endif
607# if __GLIBC__ >= 2
608_GL_CXXALIASWARN (pthread_attr_setdetachstate);
609# endif
610#elif defined GNULIB_POSIXCHECK
611# if HAVE_RAW_DECL_PTHREAD_ATTR_SETDETACHSTATE
612_GL_WARN_ON_USE (pthread_attr_setdetachstate, "pthread_attr_setdetachstate is not portable - "
613 "use gnulib module pthread-thread for portability");
614# endif
615#endif
616
617#if @GNULIB_PTHREAD_THREAD@
618# if @REPLACE_PTHREAD_ATTR_DESTROY@
619# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
620# undef pthread_attr_destroy
621# define pthread_attr_destroy rpl_pthread_attr_destroy
622# endif
623_GL_FUNCDECL_RPL (pthread_attr_destroy, int, (pthread_attr_t *attr),
624 _GL_ARG_NONNULL ((1)));
625_GL_CXXALIAS_RPL (pthread_attr_destroy, int, (pthread_attr_t *attr));
626# else
627# if !@HAVE_PTHREAD_ATTR_DESTROY@
628_GL_FUNCDECL_SYS (pthread_attr_destroy, int, (pthread_attr_t *attr),
629 _GL_ARG_NONNULL ((1)));
630# endif
631_GL_CXXALIAS_SYS (pthread_attr_destroy, int, (pthread_attr_t *attr));
632# endif
633# if __GLIBC__ >= 2
634_GL_CXXALIASWARN (pthread_attr_destroy);
635# endif
636#elif defined GNULIB_POSIXCHECK
637# if HAVE_RAW_DECL_PTHREAD_ATTR_DESTROY
638_GL_WARN_ON_USE (pthread_attr_destroy, "pthread_attr_destroy is not portable - "
639 "use gnulib module pthread-thread for portability");
640# endif
641#endif
642
643#if @GNULIB_PTHREAD_THREAD@
644# if @REPLACE_PTHREAD_SELF@
645# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
646# undef pthread_self
647# define pthread_self rpl_pthread_self
648# endif
649_GL_FUNCDECL_RPL (pthread_self, pthread_t, (void), _GL_ATTRIBUTE_PURE);
650_GL_CXXALIAS_RPL (pthread_self, pthread_t, (void));
651# else
652# if !@HAVE_PTHREAD_SELF@
653_GL_FUNCDECL_SYS (pthread_self, pthread_t, (void), _GL_ATTRIBUTE_PURE);
654# endif
655_GL_CXXALIAS_SYS (pthread_self, pthread_t, (void));
656# endif
657# if __GLIBC__ >= 2
658_GL_CXXALIASWARN (pthread_self);
659# endif
660#elif defined GNULIB_POSIXCHECK
661# if HAVE_RAW_DECL_PTHREAD_SELF
662_GL_WARN_ON_USE (pthread_self, "pthread_self is not portable - "
663 "use gnulib module pthread-thread for portability");
664# endif
665#endif
666
667#if @GNULIB_PTHREAD_THREAD@
668# if @REPLACE_PTHREAD_EQUAL@
669# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
670# undef pthread_equal
671# define pthread_equal rpl_pthread_equal
672# endif
673_GL_FUNCDECL_RPL (pthread_equal, int, (pthread_t thread1, pthread_t thread2), );
674_GL_CXXALIAS_RPL (pthread_equal, int, (pthread_t thread1, pthread_t thread2));
675# else
676# if !@HAVE_PTHREAD_EQUAL@
677_GL_FUNCDECL_SYS (pthread_equal, int, (pthread_t thread1, pthread_t thread2), );
678# endif
679_GL_CXXALIAS_SYS (pthread_equal, int, (pthread_t thread1, pthread_t thread2));
680# endif
681# if __GLIBC__ >= 2
682_GL_CXXALIASWARN (pthread_equal);
683# endif
684#elif defined GNULIB_POSIXCHECK
685# if HAVE_RAW_DECL_PTHREAD_EQUAL
686_GL_WARN_ON_USE (pthread_equal, "pthread_equal is not portable - "
687 "use gnulib module pthread-thread for portability");
688# endif
689#endif
690
691#if @GNULIB_PTHREAD_THREAD@
692# if @REPLACE_PTHREAD_DETACH@
693# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694# undef pthread_detach
695# define pthread_detach rpl_pthread_detach
696# endif
697_GL_FUNCDECL_RPL (pthread_detach, int, (pthread_t thread), );
698_GL_CXXALIAS_RPL (pthread_detach, int, (pthread_t thread));
699# else
700# if !@HAVE_PTHREAD_DETACH@
701_GL_FUNCDECL_SYS (pthread_detach, int, (pthread_t thread), );
702# endif
703_GL_CXXALIAS_SYS (pthread_detach, int, (pthread_t thread));
704# endif
705# if __GLIBC__ >= 2
706_GL_CXXALIASWARN (pthread_detach);
707# endif
708#elif defined GNULIB_POSIXCHECK
709# if HAVE_RAW_DECL_PTHREAD_DETACH
710_GL_WARN_ON_USE (pthread_detach, "pthread_detach is not portable - "
711 "use gnulib module pthread-thread for portability");
712# endif
713#endif
714
715#if @GNULIB_PTHREAD_THREAD@
716# if @REPLACE_PTHREAD_JOIN@
717# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
718# undef pthread_join
719# define pthread_join rpl_pthread_join
720# endif
721_GL_FUNCDECL_RPL (pthread_join, int, (pthread_t thread, void **valuep), );
722_GL_CXXALIAS_RPL (pthread_join, int, (pthread_t thread, void **valuep));
723# else
724# if !@HAVE_PTHREAD_JOIN@
725_GL_FUNCDECL_SYS (pthread_join, int, (pthread_t thread, void **valuep), );
726# endif
727_GL_CXXALIAS_SYS (pthread_join, int, (pthread_t thread, void **valuep));
728# endif
729# if __GLIBC__ >= 2
730_GL_CXXALIASWARN (pthread_join);
731# endif
732#elif defined GNULIB_POSIXCHECK
733# if HAVE_RAW_DECL_PTHREAD_JOIN
734_GL_WARN_ON_USE (pthread_join, "pthread_join is not portable - "
735 "use gnulib module pthread-thread for portability");
736# endif
737#endif
738
739#if @GNULIB_PTHREAD_THREAD@
740# if @REPLACE_PTHREAD_EXIT@
741# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
742# undef pthread_exit
743# define pthread_exit rpl_pthread_exit
744# endif
745_GL_FUNCDECL_RPL (pthread_exit, _Noreturn void, (void *value), );
746_GL_CXXALIAS_RPL (pthread_exit, void, (void *value));
747# else
748# if !@HAVE_PTHREAD_EXIT@
749_GL_FUNCDECL_SYS (pthread_exit, _Noreturn void, (void *value), );
750# endif
751/* Need to cast because of AIX with xlclang++. */
752_GL_CXXALIAS_SYS_CAST (pthread_exit, void, (void *value));
753# endif
754# if __GLIBC__ >= 2
755_GL_CXXALIASWARN (pthread_exit);
756# endif
757#elif defined GNULIB_POSIXCHECK
758# if HAVE_RAW_DECL_PTHREAD_EXIT
759_GL_WARN_ON_USE (pthread_exit, "pthread_exit is not portable - "
760 "use gnulib module pthread-thread for portability");
761# endif
762#endif
763
764/* =========== Once-only control (initialization) functions =========== */
765
766#if @GNULIB_PTHREAD_ONCE@
767# if @REPLACE_PTHREAD_ONCE@
768# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
769# undef pthread_once
770# define pthread_once rpl_pthread_once
771# endif
772_GL_FUNCDECL_RPL (pthread_once, int,
773 (pthread_once_t *once_control, void (*initfunction) (void)),
774 _GL_ARG_NONNULL ((1, 2)));
775_GL_CXXALIAS_RPL (pthread_once, int,
776 (pthread_once_t *once_control, void (*initfunction) (void)));
777# else
778# if !@HAVE_PTHREAD_ONCE@
779_GL_FUNCDECL_SYS (pthread_once, int,
780 (pthread_once_t *once_control, void (*initfunction) (void)),
781 _GL_ARG_NONNULL ((1, 2)));
782# endif
783_GL_CXXALIAS_SYS_CAST (pthread_once, int,
784 (pthread_once_t *once_control,
785 void (*initfunction) (void)));
786# endif
787# if __GLIBC__ >= 2
788_GL_CXXALIASWARN (pthread_once);
789# endif
790#elif defined GNULIB_POSIXCHECK
791# if HAVE_RAW_DECL_PTHREAD_ONCE
792_GL_WARN_ON_USE (pthread_once, "pthread_once is not portable - "
793 "use gnulib module pthread-once for portability");
794# endif
795#endif
796
797/* =========== Mutex functions =========== */
798
799#if @GNULIB_PTHREAD_MUTEX@
800# if @REPLACE_PTHREAD_MUTEX_INIT@
801# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802# undef pthread_mutex_init
803# define pthread_mutex_init rpl_pthread_mutex_init
804# endif
805_GL_FUNCDECL_RPL (pthread_mutex_init, int,
806 (pthread_mutex_t *restrict mutex,
807 const pthread_mutexattr_t *restrict attr),
808 _GL_ARG_NONNULL ((1)));
809_GL_CXXALIAS_RPL (pthread_mutex_init, int,
810 (pthread_mutex_t *restrict mutex,
811 const pthread_mutexattr_t *restrict attr));
812# else
813# if !@HAVE_PTHREAD_MUTEX_INIT@
814_GL_FUNCDECL_SYS (pthread_mutex_init, int,
815 (pthread_mutex_t *restrict mutex,
816 const pthread_mutexattr_t *restrict attr),
817 _GL_ARG_NONNULL ((1)));
818# endif
819_GL_CXXALIAS_SYS (pthread_mutex_init, int,
820 (pthread_mutex_t *restrict mutex,
821 const pthread_mutexattr_t *restrict attr));
822# endif
823# if __GLIBC__ >= 2
824_GL_CXXALIASWARN (pthread_mutex_init);
825# endif
826#elif defined GNULIB_POSIXCHECK
827# if HAVE_RAW_DECL_PTHREAD_MUTEX_INIT
828_GL_WARN_ON_USE (pthread_mutex_init, "pthread_mutex_init is not portable - "
829 "use gnulib module pthread-mutex for portability");
830# endif
831#endif
832
833#if @GNULIB_PTHREAD_MUTEX@
834# if @REPLACE_PTHREAD_MUTEXATTR_INIT@
835# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
836# undef pthread_mutexattr_init
837# define pthread_mutexattr_init rpl_pthread_mutexattr_init
838# endif
839_GL_FUNCDECL_RPL (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr),
840 _GL_ARG_NONNULL ((1)));
841_GL_CXXALIAS_RPL (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr));
842# else
843# if !@HAVE_PTHREAD_MUTEXATTR_INIT@
844_GL_FUNCDECL_SYS (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr),
845 _GL_ARG_NONNULL ((1)));
846# endif
847_GL_CXXALIAS_SYS (pthread_mutexattr_init, int, (pthread_mutexattr_t *attr));
848# endif
849# if __GLIBC__ >= 2
850_GL_CXXALIASWARN (pthread_mutexattr_init);
851# endif
852#elif defined GNULIB_POSIXCHECK
853# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_INIT
854_GL_WARN_ON_USE (pthread_mutexattr_init, "pthread_mutexattr_init is not portable - "
855 "use gnulib module pthread-mutex for portability");
856# endif
857#endif
858
859#if @GNULIB_PTHREAD_MUTEX@
860# if @REPLACE_PTHREAD_MUTEXATTR_GETTYPE@
861# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
862# undef pthread_mutexattr_gettype
863# define pthread_mutexattr_gettype rpl_pthread_mutexattr_gettype
864# endif
865_GL_FUNCDECL_RPL (pthread_mutexattr_gettype, int,
866 (const pthread_mutexattr_t *restrict attr,
867 int *restrict typep),
868 _GL_ARG_NONNULL ((1, 2)));
869_GL_CXXALIAS_RPL (pthread_mutexattr_gettype, int,
870 (const pthread_mutexattr_t *restrict attr,
871 int *restrict typep));
872# else
873# if !@HAVE_PTHREAD_MUTEXATTR_GETTYPE@
874_GL_FUNCDECL_SYS (pthread_mutexattr_gettype, int,
875 (const pthread_mutexattr_t *restrict attr,
876 int *restrict typep),
877 _GL_ARG_NONNULL ((1, 2)));
878# endif
879/* Need to cast, because on FreeBSD the first parameter is
880 pthread_mutexattr_t *attr. */
881_GL_CXXALIAS_SYS_CAST (pthread_mutexattr_gettype, int,
882 (const pthread_mutexattr_t *restrict attr,
883 int *restrict typep));
884# endif
885# if __GLIBC__ >= 2
886_GL_CXXALIASWARN (pthread_mutexattr_gettype);
887# endif
888#elif defined GNULIB_POSIXCHECK
889# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_GETTYPE
890_GL_WARN_ON_USE (pthread_mutexattr_gettype, "pthread_mutexattr_gettype is not portable - "
891 "use gnulib module pthread-mutex for portability");
892# endif
893#endif
894
895#if @GNULIB_PTHREAD_MUTEX@
896# if @REPLACE_PTHREAD_MUTEXATTR_SETTYPE@
897# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
898# undef pthread_mutexattr_settype
899# define pthread_mutexattr_settype rpl_pthread_mutexattr_settype
900# endif
901_GL_FUNCDECL_RPL (pthread_mutexattr_settype, int,
902 (pthread_mutexattr_t *attr, int type), _GL_ARG_NONNULL ((1)));
903_GL_CXXALIAS_RPL (pthread_mutexattr_settype, int,
904 (pthread_mutexattr_t *attr, int type));
905# else
906# if !@HAVE_PTHREAD_MUTEXATTR_SETTYPE@
907_GL_FUNCDECL_SYS (pthread_mutexattr_settype, int,
908 (pthread_mutexattr_t *attr, int type), _GL_ARG_NONNULL ((1)));
909# endif
910_GL_CXXALIAS_SYS (pthread_mutexattr_settype, int,
911 (pthread_mutexattr_t *attr, int type));
912# endif
913# if __GLIBC__ >= 2
914_GL_CXXALIASWARN (pthread_mutexattr_settype);
915# endif
916#elif defined GNULIB_POSIXCHECK
917# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_SETTYPE
918_GL_WARN_ON_USE (pthread_mutexattr_settype, "pthread_mutexattr_settype is not portable - "
919 "use gnulib module pthread-mutex for portability");
920# endif
921#endif
922
923#if @GNULIB_PTHREAD_MUTEX@
924# if @REPLACE_PTHREAD_MUTEXATTR_GETROBUST@
925# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
926# undef pthread_mutexattr_getrobust
927# define pthread_mutexattr_getrobust rpl_pthread_mutexattr_getrobust
928# endif
929_GL_FUNCDECL_RPL (pthread_mutexattr_getrobust, int,
930 (const pthread_mutexattr_t *restrict attr,
931 int *restrict robustp),
932 _GL_ARG_NONNULL ((1, 2)));
933_GL_CXXALIAS_RPL (pthread_mutexattr_getrobust, int,
934 (const pthread_mutexattr_t *restrict attr,
935 int *restrict robustp));
936# else
937# if !@HAVE_PTHREAD_MUTEXATTR_GETROBUST@
938_GL_FUNCDECL_SYS (pthread_mutexattr_getrobust, int,
939 (const pthread_mutexattr_t *restrict attr,
940 int *restrict robustp),
941 _GL_ARG_NONNULL ((1, 2)));
942# endif
943/* Need to cast, because on FreeBSD the first parameter is
944 pthread_mutexattr_t *attr. */
945_GL_CXXALIAS_SYS_CAST (pthread_mutexattr_getrobust, int,
946 (const pthread_mutexattr_t *restrict attr,
947 int *restrict robustp));
948# endif
949# if __GLIBC__ >= 2
950_GL_CXXALIASWARN (pthread_mutexattr_getrobust);
951# endif
952#elif defined GNULIB_POSIXCHECK
953# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_GETROBUST
954_GL_WARN_ON_USE (pthread_mutexattr_getrobust, "pthread_mutexattr_getrobust is not portable - "
955 "use gnulib module pthread-mutex for portability");
956# endif
957#endif
958
959#if @GNULIB_PTHREAD_MUTEX@
960# if @REPLACE_PTHREAD_MUTEXATTR_SETROBUST@
961# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
962# undef pthread_mutexattr_setrobust
963# define pthread_mutexattr_setrobust rpl_pthread_mutexattr_setrobust
964# endif
965_GL_FUNCDECL_RPL (pthread_mutexattr_setrobust, int,
966 (pthread_mutexattr_t *attr, int robust),
967 _GL_ARG_NONNULL ((1)));
968_GL_CXXALIAS_RPL (pthread_mutexattr_setrobust, int,
969 (pthread_mutexattr_t *attr, int robust));
970# else
971# if !@HAVE_PTHREAD_MUTEXATTR_SETROBUST@
972_GL_FUNCDECL_SYS (pthread_mutexattr_setrobust, int,
973 (pthread_mutexattr_t *attr, int robust),
974 _GL_ARG_NONNULL ((1)));
975# endif
976_GL_CXXALIAS_SYS (pthread_mutexattr_setrobust, int,
977 (pthread_mutexattr_t *attr, int robust));
978# endif
979# if __GLIBC__ >= 2
980_GL_CXXALIASWARN (pthread_mutexattr_setrobust);
981# endif
982#elif defined GNULIB_POSIXCHECK
983# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_SETROBUST
984_GL_WARN_ON_USE (pthread_mutexattr_setrobust, "pthread_mutexattr_setrobust is not portable - "
985 "use gnulib module pthread-mutex for portability");
986# endif
987#endif
988
989#if @GNULIB_PTHREAD_MUTEX@
990# if @REPLACE_PTHREAD_MUTEXATTR_DESTROY@
991# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
992# undef pthread_mutexattr_destroy
993# define pthread_mutexattr_destroy rpl_pthread_mutexattr_destroy
994# endif
995_GL_FUNCDECL_RPL (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr),
996 _GL_ARG_NONNULL ((1)));
997_GL_CXXALIAS_RPL (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr));
998# else
999# if !@HAVE_PTHREAD_MUTEXATTR_DESTROY@
1000_GL_FUNCDECL_SYS (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr),
1001 _GL_ARG_NONNULL ((1)));
1002# endif
1003_GL_CXXALIAS_SYS (pthread_mutexattr_destroy, int, (pthread_mutexattr_t *attr));
1004# endif
1005# if __GLIBC__ >= 2
1006_GL_CXXALIASWARN (pthread_mutexattr_destroy);
1007# endif
1008#elif defined GNULIB_POSIXCHECK
1009# if HAVE_RAW_DECL_PTHREAD_MUTEXATTR_DESTROY
1010_GL_WARN_ON_USE (pthread_mutexattr_destroy, "pthread_mutexattr_destroy is not portable - "
1011 "use gnulib module pthread-mutex for portability");
1012# endif
1013#endif
1014
1015#if @GNULIB_PTHREAD_MUTEX@
1016# if @REPLACE_PTHREAD_MUTEX_LOCK@
1017# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1018# undef pthread_mutex_lock
1019# define pthread_mutex_lock rpl_pthread_mutex_lock
1020# endif
1021_GL_FUNCDECL_RPL (pthread_mutex_lock, int, (pthread_mutex_t *mutex),
1022 _GL_ARG_NONNULL ((1)));
1023_GL_CXXALIAS_RPL (pthread_mutex_lock, int, (pthread_mutex_t *mutex));
1024# else
1025# if !@HAVE_PTHREAD_MUTEX_LOCK@
1026_GL_FUNCDECL_SYS (pthread_mutex_lock, int, (pthread_mutex_t *mutex),
1027 _GL_ARG_NONNULL ((1)));
1028# endif
1029_GL_CXXALIAS_SYS (pthread_mutex_lock, int, (pthread_mutex_t *mutex));
1030# endif
1031# if __GLIBC__ >= 2
1032_GL_CXXALIASWARN (pthread_mutex_lock);
1033# endif
1034#elif defined GNULIB_POSIXCHECK
1035# if HAVE_RAW_DECL_PTHREAD_MUTEX_LOCK
1036_GL_WARN_ON_USE (pthread_mutex_lock, "pthread_mutex_lock is not portable - "
1037 "use gnulib module pthread-mutex for portability");
1038# endif
1039#endif
1040
1041#if @GNULIB_PTHREAD_MUTEX@
1042# if @REPLACE_PTHREAD_MUTEX_TRYLOCK@
1043# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1044# undef pthread_mutex_trylock
1045# define pthread_mutex_trylock rpl_pthread_mutex_trylock
1046# endif
1047_GL_FUNCDECL_RPL (pthread_mutex_trylock, int, (pthread_mutex_t *mutex),
1048 _GL_ARG_NONNULL ((1)));
1049_GL_CXXALIAS_RPL (pthread_mutex_trylock, int, (pthread_mutex_t *mutex));
1050# else
1051# if !@HAVE_PTHREAD_MUTEX_TRYLOCK@
1052_GL_FUNCDECL_SYS (pthread_mutex_trylock, int, (pthread_mutex_t *mutex),
1053 _GL_ARG_NONNULL ((1)));
1054# endif
1055_GL_CXXALIAS_SYS (pthread_mutex_trylock, int, (pthread_mutex_t *mutex));
1056# endif
1057# if __GLIBC__ >= 2
1058_GL_CXXALIASWARN (pthread_mutex_trylock);
1059# endif
1060#elif defined GNULIB_POSIXCHECK
1061# if HAVE_RAW_DECL_PTHREAD_MUTEX_TRYLOCK
1062_GL_WARN_ON_USE (pthread_mutex_trylock, "pthread_mutex_trylock is not portable - "
1063 "use gnulib module pthread-mutex for portability");
1064# endif
1065#endif
1066
1067#if @GNULIB_PTHREAD_MUTEX_TIMEDLOCK@
1068# if @REPLACE_PTHREAD_MUTEX_TIMEDLOCK@
1069# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1070# undef pthread_mutex_timedlock
1071# define pthread_mutex_timedlock rpl_pthread_mutex_timedlock
1072# endif
1073_GL_FUNCDECL_RPL (pthread_mutex_timedlock, int,
1074 (pthread_mutex_t *restrict mutex,
1075 const struct timespec *restrict abstime),
1076 _GL_ARG_NONNULL ((1, 2)));
1077_GL_CXXALIAS_RPL (pthread_mutex_timedlock, int,
1078 (pthread_mutex_t *restrict mutex,
1079 const struct timespec *restrict abstime));
1080# else
1081# if !@HAVE_PTHREAD_MUTEX_TIMEDLOCK@
1082_GL_FUNCDECL_SYS (pthread_mutex_timedlock, int,
1083 (pthread_mutex_t *restrict mutex,
1084 const struct timespec *restrict abstime),
1085 _GL_ARG_NONNULL ((1, 2)));
1086# endif
1087_GL_CXXALIAS_SYS (pthread_mutex_timedlock, int,
1088 (pthread_mutex_t *restrict mutex,
1089 const struct timespec *restrict abstime));
1090# endif
1091# if __GLIBC__ >= 2
1092_GL_CXXALIASWARN (pthread_mutex_timedlock);
1093# endif
1094#elif defined GNULIB_POSIXCHECK
1095# if HAVE_RAW_DECL_PTHREAD_MUTEX_TIMEDLOCK
1096_GL_WARN_ON_USE (pthread_mutex_timedlock, "pthread_mutex_timedlock is not portable - "
1097 "use gnulib module pthread_mutex_timedlock for portability");
1098# endif
1099#endif
1100
1101#if @GNULIB_PTHREAD_MUTEX@
1102# if @REPLACE_PTHREAD_MUTEX_UNLOCK@
1103# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1104# undef pthread_mutex_unlock
1105# define pthread_mutex_unlock rpl_pthread_mutex_unlock
1106# endif
1107_GL_FUNCDECL_RPL (pthread_mutex_unlock, int, (pthread_mutex_t *mutex),
1108 _GL_ARG_NONNULL ((1)));
1109_GL_CXXALIAS_RPL (pthread_mutex_unlock, int, (pthread_mutex_t *mutex));
1110# else
1111# if !@HAVE_PTHREAD_MUTEX_UNLOCK@
1112_GL_FUNCDECL_SYS (pthread_mutex_unlock, int, (pthread_mutex_t *mutex),
1113 _GL_ARG_NONNULL ((1)));
1114# endif
1115_GL_CXXALIAS_SYS (pthread_mutex_unlock, int, (pthread_mutex_t *mutex));
1116# endif
1117# if __GLIBC__ >= 2
1118_GL_CXXALIASWARN (pthread_mutex_unlock);
1119# endif
1120#elif defined GNULIB_POSIXCHECK
1121# if HAVE_RAW_DECL_PTHREAD_MUTEX_UNLOCK
1122_GL_WARN_ON_USE (pthread_mutex_unlock, "pthread_mutex_unlock is not portable - "
1123 "use gnulib module pthread-mutex for portability");
1124# endif
1125#endif
1126
1127#if @GNULIB_PTHREAD_MUTEX@
1128# if @REPLACE_PTHREAD_MUTEX_DESTROY@
1129# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1130# undef pthread_mutex_destroy
1131# define pthread_mutex_destroy rpl_pthread_mutex_destroy
1132# endif
1133_GL_FUNCDECL_RPL (pthread_mutex_destroy, int, (pthread_mutex_t *mutex),
1134 _GL_ARG_NONNULL ((1)));
1135_GL_CXXALIAS_RPL (pthread_mutex_destroy, int, (pthread_mutex_t *mutex));
1136# else
1137# if !@HAVE_PTHREAD_MUTEX_DESTROY@
1138_GL_FUNCDECL_SYS (pthread_mutex_destroy, int, (pthread_mutex_t *mutex),
1139 _GL_ARG_NONNULL ((1)));
1140# endif
1141_GL_CXXALIAS_SYS (pthread_mutex_destroy, int, (pthread_mutex_t *mutex));
1142# endif
1143# if __GLIBC__ >= 2
1144_GL_CXXALIASWARN (pthread_mutex_destroy);
1145# endif
1146#elif defined GNULIB_POSIXCHECK
1147# if HAVE_RAW_DECL_PTHREAD_MUTEX_DESTROY
1148_GL_WARN_ON_USE (pthread_mutex_destroy, "pthread_mutex_destroy is not portable - "
1149 "use gnulib module pthread-mutex for portability");
1150# endif
1151#endif
1152
1153/* =========== Read-write lock functions =========== */
1154
1155#if @GNULIB_PTHREAD_RWLOCK@
1156# if @REPLACE_PTHREAD_RWLOCK_INIT@
1157# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1158# undef pthread_rwlock_init
1159# define pthread_rwlock_init rpl_pthread_rwlock_init
1160# endif
1161_GL_FUNCDECL_RPL (pthread_rwlock_init, int,
1162 (pthread_rwlock_t *restrict lock,
1163 const pthread_rwlockattr_t *restrict attr),
1164 _GL_ARG_NONNULL ((1)));
1165_GL_CXXALIAS_RPL (pthread_rwlock_init, int,
1166 (pthread_rwlock_t *restrict lock,
1167 const pthread_rwlockattr_t *restrict attr));
1168# else
1169# if !@HAVE_PTHREAD_RWLOCK_INIT@
1170_GL_FUNCDECL_SYS (pthread_rwlock_init, int,
1171 (pthread_rwlock_t *restrict lock,
1172 const pthread_rwlockattr_t *restrict attr),
1173 _GL_ARG_NONNULL ((1)));
1174# endif
1175_GL_CXXALIAS_SYS (pthread_rwlock_init, int,
1176 (pthread_rwlock_t *restrict lock,
1177 const pthread_rwlockattr_t *restrict attr));
1178# endif
1179# if __GLIBC__ >= 2
1180_GL_CXXALIASWARN (pthread_rwlock_init);
1181# endif
1182#elif defined GNULIB_POSIXCHECK
1183# if HAVE_RAW_DECL_PTHREAD_RWLOCK_INIT
1184_GL_WARN_ON_USE (pthread_rwlock_init, "pthread_rwlock_init is not portable - "
1185 "use gnulib module pthread-rwlock for portability");
1186# endif
1187#endif
1188
1189#if @GNULIB_PTHREAD_RWLOCK@
1190# if @REPLACE_PTHREAD_RWLOCKATTR_INIT@
1191# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1192# undef pthread_rwlockattr_init
1193# define pthread_rwlockattr_init rpl_pthread_rwlockattr_init
1194# endif
1195_GL_FUNCDECL_RPL (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr),
1196 _GL_ARG_NONNULL ((1)));
1197_GL_CXXALIAS_RPL (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr));
1198# else
1199# if !@HAVE_PTHREAD_RWLOCKATTR_INIT@
1200_GL_FUNCDECL_SYS (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr),
1201 _GL_ARG_NONNULL ((1)));
1202# endif
1203_GL_CXXALIAS_SYS (pthread_rwlockattr_init, int, (pthread_rwlockattr_t *attr));
1204# endif
1205# if __GLIBC__ >= 2
1206_GL_CXXALIASWARN (pthread_rwlockattr_init);
1207# endif
1208#elif defined GNULIB_POSIXCHECK
1209# if HAVE_RAW_DECL_PTHREAD_RWLOCKATTR_INIT
1210_GL_WARN_ON_USE (pthread_rwlockattr_init, "pthread_rwlockattr_init is not portable - "
1211 "use gnulib module pthread-rwlock for portability");
1212# endif
1213#endif
1214
1215#if @GNULIB_PTHREAD_RWLOCK@
1216# if @REPLACE_PTHREAD_RWLOCKATTR_DESTROY@
1217# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1218# undef pthread_rwlockattr_destroy
1219# define pthread_rwlockattr_destroy rpl_pthread_rwlockattr_destroy
1220# endif
1221_GL_FUNCDECL_RPL (pthread_rwlockattr_destroy, int,
1222 (pthread_rwlockattr_t *attr), _GL_ARG_NONNULL ((1)));
1223_GL_CXXALIAS_RPL (pthread_rwlockattr_destroy, int,
1224 (pthread_rwlockattr_t *attr));
1225# else
1226# if !@HAVE_PTHREAD_RWLOCKATTR_DESTROY@
1227_GL_FUNCDECL_SYS (pthread_rwlockattr_destroy, int,
1228 (pthread_rwlockattr_t *attr), _GL_ARG_NONNULL ((1)));
1229# endif
1230_GL_CXXALIAS_SYS (pthread_rwlockattr_destroy, int,
1231 (pthread_rwlockattr_t *attr));
1232# endif
1233# if __GLIBC__ >= 2
1234_GL_CXXALIASWARN (pthread_rwlockattr_destroy);
1235# endif
1236#elif defined GNULIB_POSIXCHECK
1237# if HAVE_RAW_DECL_PTHREAD_RWLOCKATTR_DESTROY
1238_GL_WARN_ON_USE (pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy is not portable - "
1239 "use gnulib module pthread-rwlock for portability");
1240# endif
1241#endif
1242
1243#if @GNULIB_PTHREAD_RWLOCK@
1244# if @REPLACE_PTHREAD_RWLOCK_RDLOCK@
1245# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1246# undef pthread_rwlock_rdlock
1247# define pthread_rwlock_rdlock rpl_pthread_rwlock_rdlock
1248# endif
1249_GL_FUNCDECL_RPL (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock),
1250 _GL_ARG_NONNULL ((1)));
1251_GL_CXXALIAS_RPL (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock));
1252# else
1253# if !@HAVE_PTHREAD_RWLOCK_RDLOCK@
1254_GL_FUNCDECL_SYS (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock),
1255 _GL_ARG_NONNULL ((1)));
1256# endif
1257_GL_CXXALIAS_SYS (pthread_rwlock_rdlock, int, (pthread_rwlock_t *lock));
1258# endif
1259# if __GLIBC__ >= 2
1260_GL_CXXALIASWARN (pthread_rwlock_rdlock);
1261# endif
1262#elif defined GNULIB_POSIXCHECK
1263# if HAVE_RAW_DECL_PTHREAD_RWLOCK_RDLOCK
1264_GL_WARN_ON_USE (pthread_rwlock_rdlock, "pthread_rwlock_rdlock is not portable - "
1265 "use gnulib module pthread-rwlock for portability");
1266# endif
1267#endif
1268
1269#if @GNULIB_PTHREAD_RWLOCK@
1270# if @REPLACE_PTHREAD_RWLOCK_WRLOCK@
1271# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1272# undef pthread_rwlock_wrlock
1273# define pthread_rwlock_wrlock rpl_pthread_rwlock_wrlock
1274# endif
1275_GL_FUNCDECL_RPL (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock),
1276 _GL_ARG_NONNULL ((1)));
1277_GL_CXXALIAS_RPL (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock));
1278# else
1279# if !@HAVE_PTHREAD_RWLOCK_WRLOCK@
1280_GL_FUNCDECL_SYS (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock),
1281 _GL_ARG_NONNULL ((1)));
1282# endif
1283_GL_CXXALIAS_SYS (pthread_rwlock_wrlock, int, (pthread_rwlock_t *lock));
1284# endif
1285# if __GLIBC__ >= 2
1286_GL_CXXALIASWARN (pthread_rwlock_wrlock);
1287# endif
1288#elif defined GNULIB_POSIXCHECK
1289# if HAVE_RAW_DECL_PTHREAD_RWLOCK_WRLOCK
1290_GL_WARN_ON_USE (pthread_rwlock_wrlock, "pthread_rwlock_wrlock is not portable - "
1291 "use gnulib module pthread-rwlock for portability");
1292# endif
1293#endif
1294
1295#if @GNULIB_PTHREAD_RWLOCK@
1296# if @REPLACE_PTHREAD_RWLOCK_TRYRDLOCK@
1297# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1298# undef pthread_rwlock_tryrdlock
1299# define pthread_rwlock_tryrdlock rpl_pthread_rwlock_tryrdlock
1300# endif
1301_GL_FUNCDECL_RPL (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock),
1302 _GL_ARG_NONNULL ((1)));
1303_GL_CXXALIAS_RPL (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock));
1304# else
1305# if !@HAVE_PTHREAD_RWLOCK_TRYRDLOCK@
1306_GL_FUNCDECL_SYS (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock),
1307 _GL_ARG_NONNULL ((1)));
1308# endif
1309_GL_CXXALIAS_SYS (pthread_rwlock_tryrdlock, int, (pthread_rwlock_t *lock));
1310# endif
1311# if __GLIBC__ >= 2
1312_GL_CXXALIASWARN (pthread_rwlock_tryrdlock);
1313# endif
1314#elif defined GNULIB_POSIXCHECK
1315# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TRYRDLOCK
1316_GL_WARN_ON_USE (pthread_rwlock_tryrdlock, "pthread_rwlock_tryrdlock is not portable - "
1317 "use gnulib module pthread-rwlock for portability");
1318# endif
1319#endif
1320
1321#if @GNULIB_PTHREAD_RWLOCK@
1322# if @REPLACE_PTHREAD_RWLOCK_TRYWRLOCK@
1323# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1324# undef pthread_rwlock_trywrlock
1325# define pthread_rwlock_trywrlock rpl_pthread_rwlock_trywrlock
1326# endif
1327_GL_FUNCDECL_RPL (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock),
1328 _GL_ARG_NONNULL ((1)));
1329_GL_CXXALIAS_RPL (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock));
1330# else
1331# if !@HAVE_PTHREAD_RWLOCK_TRYWRLOCK@
1332_GL_FUNCDECL_SYS (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock),
1333 _GL_ARG_NONNULL ((1)));
1334# endif
1335_GL_CXXALIAS_SYS (pthread_rwlock_trywrlock, int, (pthread_rwlock_t *lock));
1336# endif
1337# if __GLIBC__ >= 2
1338_GL_CXXALIASWARN (pthread_rwlock_trywrlock);
1339# endif
1340#elif defined GNULIB_POSIXCHECK
1341# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TRYWRLOCK
1342_GL_WARN_ON_USE (pthread_rwlock_trywrlock, "pthread_rwlock_trywrlock is not portable - "
1343 "use gnulib module pthread-rwlock for portability");
1344# endif
1345#endif
1346
1347#if @GNULIB_PTHREAD_RWLOCK@
1348# if @REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK@
1349# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1350# undef pthread_rwlock_timedrdlock
1351# define pthread_rwlock_timedrdlock rpl_pthread_rwlock_timedrdlock
1352# endif
1353_GL_FUNCDECL_RPL (pthread_rwlock_timedrdlock, int,
1354 (pthread_rwlock_t *restrict lock,
1355 const struct timespec *restrict abstime),
1356 _GL_ARG_NONNULL ((1, 2)));
1357_GL_CXXALIAS_RPL (pthread_rwlock_timedrdlock, int,
1358 (pthread_rwlock_t *restrict lock,
1359 const struct timespec *restrict abstime));
1360# else
1361# if !@HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK@
1362_GL_FUNCDECL_SYS (pthread_rwlock_timedrdlock, int,
1363 (pthread_rwlock_t *restrict lock,
1364 const struct timespec *restrict abstime),
1365 _GL_ARG_NONNULL ((1, 2)));
1366# endif
1367_GL_CXXALIAS_SYS (pthread_rwlock_timedrdlock, int,
1368 (pthread_rwlock_t *restrict lock,
1369 const struct timespec *restrict abstime));
1370# endif
1371# if __GLIBC__ >= 2
1372_GL_CXXALIASWARN (pthread_rwlock_timedrdlock);
1373# endif
1374#elif defined GNULIB_POSIXCHECK
1375# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TIMEDRDLOCK
1376_GL_WARN_ON_USE (pthread_rwlock_timedrdlock, "pthread_rwlock_timedrdlock is not portable - "
1377 "use gnulib module pthread-rwlock for portability");
1378# endif
1379#endif
1380
1381#if @GNULIB_PTHREAD_RWLOCK@
1382# if @REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK@
1383# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1384# undef pthread_rwlock_timedwrlock
1385# define pthread_rwlock_timedwrlock rpl_pthread_rwlock_timedwrlock
1386# endif
1387_GL_FUNCDECL_RPL (pthread_rwlock_timedwrlock, int,
1388 (pthread_rwlock_t *restrict lock,
1389 const struct timespec *restrict abstime),
1390 _GL_ARG_NONNULL ((1, 2)));
1391_GL_CXXALIAS_RPL (pthread_rwlock_timedwrlock, int,
1392 (pthread_rwlock_t *restrict lock,
1393 const struct timespec *restrict abstime));
1394# else
1395# if !@HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK@
1396_GL_FUNCDECL_SYS (pthread_rwlock_timedwrlock, int,
1397 (pthread_rwlock_t *restrict lock,
1398 const struct timespec *restrict abstime),
1399 _GL_ARG_NONNULL ((1, 2)));
1400# endif
1401_GL_CXXALIAS_SYS (pthread_rwlock_timedwrlock, int,
1402 (pthread_rwlock_t *restrict lock,
1403 const struct timespec *restrict abstime));
1404# endif
1405# if __GLIBC__ >= 2
1406_GL_CXXALIASWARN (pthread_rwlock_timedwrlock);
1407# endif
1408#elif defined GNULIB_POSIXCHECK
1409# if HAVE_RAW_DECL_PTHREAD_RWLOCK_TIMEDWRLOCK
1410_GL_WARN_ON_USE (pthread_rwlock_timedwrlock, "pthread_rwlock_timedwrlock is not portable - "
1411 "use gnulib module pthread-rwlock for portability");
1412# endif
1413#endif
1414
1415#if @GNULIB_PTHREAD_RWLOCK@
1416# if @REPLACE_PTHREAD_RWLOCK_UNLOCK@
1417# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1418# undef pthread_rwlock_unlock
1419# define pthread_rwlock_unlock rpl_pthread_rwlock_unlock
1420# endif
1421_GL_FUNCDECL_RPL (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock),
1422 _GL_ARG_NONNULL ((1)));
1423_GL_CXXALIAS_RPL (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock));
1424# else
1425# if !@HAVE_PTHREAD_RWLOCK_UNLOCK@
1426_GL_FUNCDECL_SYS (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock),
1427 _GL_ARG_NONNULL ((1)));
1428# endif
1429_GL_CXXALIAS_SYS (pthread_rwlock_unlock, int, (pthread_rwlock_t *lock));
1430# endif
1431# if __GLIBC__ >= 2
1432_GL_CXXALIASWARN (pthread_rwlock_unlock);
1433# endif
1434#elif defined GNULIB_POSIXCHECK
1435# if HAVE_RAW_DECL_PTHREAD_RWLOCK_UNLOCK
1436_GL_WARN_ON_USE (pthread_rwlock_unlock, "pthread_rwlock_unlock is not portable - "
1437 "use gnulib module pthread-rwlock for portability");
1438# endif
1439#endif
1440
1441#if @GNULIB_PTHREAD_RWLOCK@
1442# if @REPLACE_PTHREAD_RWLOCK_DESTROY@
1443# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1444# undef pthread_rwlock_destroy
1445# define pthread_rwlock_destroy rpl_pthread_rwlock_destroy
1446# endif
1447_GL_FUNCDECL_RPL (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock),
1448 _GL_ARG_NONNULL ((1)));
1449_GL_CXXALIAS_RPL (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock));
1450# else
1451# if !@HAVE_PTHREAD_RWLOCK_DESTROY@
1452_GL_FUNCDECL_SYS (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock),
1453 _GL_ARG_NONNULL ((1)));
1454# endif
1455_GL_CXXALIAS_SYS (pthread_rwlock_destroy, int, (pthread_rwlock_t *lock));
1456# endif
1457# if __GLIBC__ >= 2
1458_GL_CXXALIASWARN (pthread_rwlock_destroy);
1459# endif
1460#elif defined GNULIB_POSIXCHECK
1461# if HAVE_RAW_DECL_PTHREAD_RWLOCK_DESTROY
1462_GL_WARN_ON_USE (pthread_rwlock_destroy, "pthread_rwlock_destroy is not portable - "
1463 "use gnulib module pthread-rwlock for portability");
1464# endif
1465#endif
1466
1467/* =========== Condition variable functions =========== */
1468
1469#if @GNULIB_PTHREAD_COND@
1470# if @REPLACE_PTHREAD_COND_INIT@
1471# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1472# undef pthread_cond_init
1473# define pthread_cond_init rpl_pthread_cond_init
1474# endif
1475_GL_FUNCDECL_RPL (pthread_cond_init, int,
1476 (pthread_cond_t *restrict cond,
1477 const pthread_condattr_t *restrict attr),
1478 _GL_ARG_NONNULL ((1)));
1479_GL_CXXALIAS_RPL (pthread_cond_init, int,
1480 (pthread_cond_t *restrict cond,
1481 const pthread_condattr_t *restrict attr));
1482# else
1483# if !@HAVE_PTHREAD_COND_INIT@
1484_GL_FUNCDECL_SYS (pthread_cond_init, int,
1485 (pthread_cond_t *restrict cond,
1486 const pthread_condattr_t *restrict attr),
1487 _GL_ARG_NONNULL ((1)));
1488# endif
1489_GL_CXXALIAS_SYS (pthread_cond_init, int,
1490 (pthread_cond_t *restrict cond,
1491 const pthread_condattr_t *restrict attr));
1492# endif
1493# if __GLIBC__ >= 2
1494_GL_CXXALIASWARN (pthread_cond_init);
1495# endif
1496#elif defined GNULIB_POSIXCHECK
1497# if HAVE_RAW_DECL_PTHREAD_COND_INIT
1498_GL_WARN_ON_USE (pthread_cond_init, "pthread_cond_init is not portable - "
1499 "use gnulib module pthread-cond for portability");
1500# endif
1501#endif
1502
1503#if @GNULIB_PTHREAD_COND@
1504# if @REPLACE_PTHREAD_CONDATTR_INIT@
1505# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1506# undef pthread_condattr_init
1507# define pthread_condattr_init rpl_pthread_condattr_init
1508# endif
1509_GL_FUNCDECL_RPL (pthread_condattr_init, int, (pthread_condattr_t *attr),
1510 _GL_ARG_NONNULL ((1)));
1511_GL_CXXALIAS_RPL (pthread_condattr_init, int, (pthread_condattr_t *attr));
1512# else
1513# if !@HAVE_PTHREAD_CONDATTR_INIT@
1514_GL_FUNCDECL_SYS (pthread_condattr_init, int, (pthread_condattr_t *attr),
1515 _GL_ARG_NONNULL ((1)));
1516# endif
1517_GL_CXXALIAS_SYS (pthread_condattr_init, int, (pthread_condattr_t *attr));
1518# endif
1519# if __GLIBC__ >= 2
1520_GL_CXXALIASWARN (pthread_condattr_init);
1521# endif
1522#elif defined GNULIB_POSIXCHECK
1523# if HAVE_RAW_DECL_PTHREAD_CONDATTR_INIT
1524_GL_WARN_ON_USE (pthread_condattr_init, "pthread_condattr_init is not portable - "
1525 "use gnulib module pthread-cond for portability");
1526# endif
1527#endif
1528
1529#if @GNULIB_PTHREAD_COND@
1530# if @REPLACE_PTHREAD_CONDATTR_DESTROY@
1531# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1532# undef pthread_condattr_destroy
1533# define pthread_condattr_destroy rpl_pthread_condattr_destroy
1534# endif
1535_GL_FUNCDECL_RPL (pthread_condattr_destroy, int, (pthread_condattr_t *attr),
1536 _GL_ARG_NONNULL ((1)));
1537_GL_CXXALIAS_RPL (pthread_condattr_destroy, int, (pthread_condattr_t *attr));
1538# else
1539# if !@HAVE_PTHREAD_CONDATTR_DESTROY@
1540_GL_FUNCDECL_SYS (pthread_condattr_destroy, int, (pthread_condattr_t *attr),
1541 _GL_ARG_NONNULL ((1)));
1542# endif
1543_GL_CXXALIAS_SYS (pthread_condattr_destroy, int, (pthread_condattr_t *attr));
1544# endif
1545# if __GLIBC__ >= 2
1546_GL_CXXALIASWARN (pthread_condattr_destroy);
1547# endif
1548#elif defined GNULIB_POSIXCHECK
1549# if HAVE_RAW_DECL_PTHREAD_CONDATTR_DESTROY
1550_GL_WARN_ON_USE (pthread_condattr_destroy, "pthread_condattr_destroy is not portable - "
1551 "use gnulib module pthread-cond for portability");
1552# endif
1553#endif
1554
1555#if @GNULIB_PTHREAD_COND@
1556# if @REPLACE_PTHREAD_COND_WAIT@
1557# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1558# undef pthread_cond_wait
1559# define pthread_cond_wait rpl_pthread_cond_wait
1560# endif
1561_GL_FUNCDECL_RPL (pthread_cond_wait, int,
1562 (pthread_cond_t *restrict cond,
1563 pthread_mutex_t *restrict mutex),
1564 _GL_ARG_NONNULL ((1, 2)));
1565_GL_CXXALIAS_RPL (pthread_cond_wait, int,
1566 (pthread_cond_t *restrict cond,
1567 pthread_mutex_t *restrict mutex));
1568# else
1569# if !@HAVE_PTHREAD_COND_WAIT@
1570_GL_FUNCDECL_SYS (pthread_cond_wait, int,
1571 (pthread_cond_t *restrict cond,
1572 pthread_mutex_t *restrict mutex),
1573 _GL_ARG_NONNULL ((1, 2)));
1574# endif
1575_GL_CXXALIAS_SYS (pthread_cond_wait, int,
1576 (pthread_cond_t *restrict cond,
1577 pthread_mutex_t *restrict mutex));
1578# endif
1579# if __GLIBC__ >= 2
1580_GL_CXXALIASWARN (pthread_cond_wait);
1581# endif
1582#elif defined GNULIB_POSIXCHECK
1583# if HAVE_RAW_DECL_PTHREAD_COND_WAIT
1584_GL_WARN_ON_USE (pthread_cond_wait, "pthread_cond_wait is not portable - "
1585 "use gnulib module pthread-cond for portability");
1586# endif
1587#endif
1588
1589#if @GNULIB_PTHREAD_COND@
1590# if @REPLACE_PTHREAD_COND_TIMEDWAIT@
1591# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1592# undef pthread_cond_timedwait
1593# define pthread_cond_timedwait rpl_pthread_cond_timedwait
1594# endif
1595_GL_FUNCDECL_RPL (pthread_cond_timedwait, int,
1596 (pthread_cond_t *restrict cond,
1597 pthread_mutex_t *restrict mutex,
1598 const struct timespec *restrict abstime),
1599 _GL_ARG_NONNULL ((1, 2, 3)));
1600_GL_CXXALIAS_RPL (pthread_cond_timedwait, int,
1601 (pthread_cond_t *restrict cond,
1602 pthread_mutex_t *restrict mutex,
1603 const struct timespec *restrict abstime));
1604# else
1605# if !@HAVE_PTHREAD_COND_TIMEDWAIT@
1606_GL_FUNCDECL_SYS (pthread_cond_timedwait, int,
1607 (pthread_cond_t *restrict cond,
1608 pthread_mutex_t *restrict mutex,
1609 const struct timespec *restrict abstime),
1610 _GL_ARG_NONNULL ((1, 2, 3)));
1611# endif
1612_GL_CXXALIAS_SYS (pthread_cond_timedwait, int,
1613 (pthread_cond_t *restrict cond,
1614 pthread_mutex_t *restrict mutex,
1615 const struct timespec *restrict abstime));
1616# endif
1617# if __GLIBC__ >= 2
1618_GL_CXXALIASWARN (pthread_cond_timedwait);
1619# endif
1620#elif defined GNULIB_POSIXCHECK
1621# if HAVE_RAW_DECL_PTHREAD_COND_TIMEDWAIT
1622_GL_WARN_ON_USE (pthread_cond_timedwait, "pthread_cond_timedwait is not portable - "
1623 "use gnulib module pthread-cond for portability");
1624# endif
1625#endif
1626
1627#if @GNULIB_PTHREAD_COND@
1628# if @REPLACE_PTHREAD_COND_SIGNAL@
1629# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1630# undef pthread_cond_signal
1631# define pthread_cond_signal rpl_pthread_cond_signal
1632# endif
1633_GL_FUNCDECL_RPL (pthread_cond_signal, int, (pthread_cond_t *cond),
1634 _GL_ARG_NONNULL ((1)));
1635_GL_CXXALIAS_RPL (pthread_cond_signal, int, (pthread_cond_t *cond));
1636# else
1637# if !@HAVE_PTHREAD_COND_SIGNAL@
1638_GL_FUNCDECL_SYS (pthread_cond_signal, int, (pthread_cond_t *cond),
1639 _GL_ARG_NONNULL ((1)));
1640# endif
1641_GL_CXXALIAS_SYS (pthread_cond_signal, int, (pthread_cond_t *cond));
1642# endif
1643# if __GLIBC__ >= 2
1644_GL_CXXALIASWARN (pthread_cond_signal);
1645# endif
1646#elif defined GNULIB_POSIXCHECK
1647# if HAVE_RAW_DECL_PTHREAD_COND_SIGNAL
1648_GL_WARN_ON_USE (pthread_cond_signal, "pthread_cond_signal is not portable - "
1649 "use gnulib module pthread-cond for portability");
1650# endif
1651#endif
1652
1653#if @GNULIB_PTHREAD_COND@
1654# if @REPLACE_PTHREAD_COND_BROADCAST@
1655# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1656# undef pthread_cond_broadcast
1657# define pthread_cond_broadcast rpl_pthread_cond_broadcast
1658# endif
1659_GL_FUNCDECL_RPL (pthread_cond_broadcast, int, (pthread_cond_t *cond),
1660 _GL_ARG_NONNULL ((1)));
1661_GL_CXXALIAS_RPL (pthread_cond_broadcast, int, (pthread_cond_t *cond));
1662# else
1663# if !@HAVE_PTHREAD_COND_BROADCAST@
1664_GL_FUNCDECL_SYS (pthread_cond_broadcast, int, (pthread_cond_t *cond),
1665 _GL_ARG_NONNULL ((1)));
1666# endif
1667_GL_CXXALIAS_SYS (pthread_cond_broadcast, int, (pthread_cond_t *cond));
1668# endif
1669# if __GLIBC__ >= 2
1670_GL_CXXALIASWARN (pthread_cond_broadcast);
1671# endif
1672#elif defined GNULIB_POSIXCHECK
1673# if HAVE_RAW_DECL_PTHREAD_COND_BROADCAST
1674_GL_WARN_ON_USE (pthread_cond_broadcast, "pthread_cond_broadcast is not portable - "
1675 "use gnulib module pthread-cond for portability");
1676# endif
1677#endif
1678
1679#if @GNULIB_PTHREAD_COND@
1680# if @REPLACE_PTHREAD_COND_DESTROY@
1681# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1682# undef pthread_cond_destroy
1683# define pthread_cond_destroy rpl_pthread_cond_destroy
1684# endif
1685_GL_FUNCDECL_RPL (pthread_cond_destroy, int, (pthread_cond_t *cond),
1686 _GL_ARG_NONNULL ((1)));
1687_GL_CXXALIAS_RPL (pthread_cond_destroy, int, (pthread_cond_t *cond));
1688# else
1689# if !@HAVE_PTHREAD_COND_DESTROY@
1690_GL_FUNCDECL_SYS (pthread_cond_destroy, int, (pthread_cond_t *cond),
1691 _GL_ARG_NONNULL ((1)));
1692# endif
1693_GL_CXXALIAS_SYS (pthread_cond_destroy, int, (pthread_cond_t *cond));
1694# endif
1695# if __GLIBC__ >= 2
1696_GL_CXXALIASWARN (pthread_cond_destroy);
1697# endif
1698#elif defined GNULIB_POSIXCHECK
1699# if HAVE_RAW_DECL_PTHREAD_COND_DESTROY
1700_GL_WARN_ON_USE (pthread_cond_destroy, "pthread_cond_destroy is not portable - "
1701 "use gnulib module pthread-cond for portability");
1702# endif
1703#endif
1704
1705/* =========== Thread-specific storage functions =========== */
1706
1707#if @GNULIB_PTHREAD_TSS@
1708# if @REPLACE_PTHREAD_KEY_CREATE@
1709# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1710# undef pthread_key_create
1711# define pthread_key_create rpl_pthread_key_create
1712# endif
1713_GL_FUNCDECL_RPL (pthread_key_create, int,
1714 (pthread_key_t *keyp, void (*destructor) (void *)),
1715 _GL_ARG_NONNULL ((1)));
1716_GL_CXXALIAS_RPL (pthread_key_create, int,
1717 (pthread_key_t *keyp, void (*destructor) (void *)));
1718# else
1719# if !@HAVE_PTHREAD_KEY_CREATE@
1720_GL_FUNCDECL_SYS (pthread_key_create, int,
1721 (pthread_key_t *keyp, void (*destructor) (void *)),
1722 _GL_ARG_NONNULL ((1)));
1723# endif
1724_GL_CXXALIAS_SYS_CAST (pthread_key_create, int,
1725 (pthread_key_t *keyp, void (*destructor) (void *)));
1726# endif
1727# if __GLIBC__ >= 2
1728_GL_CXXALIASWARN (pthread_key_create);
1729# endif
1730#elif defined GNULIB_POSIXCHECK
1731# if HAVE_RAW_DECL_PTHREAD_KEY_CREATE
1732_GL_WARN_ON_USE (pthread_key_create, "pthread_key_create is not portable - "
1733 "use gnulib module pthread-tss for portability");
1734# endif
1735#endif
1736
1737#if @GNULIB_PTHREAD_TSS@
1738# if @REPLACE_PTHREAD_SETSPECIFIC@
1739# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1740# undef pthread_setspecific
1741# define pthread_setspecific rpl_pthread_setspecific
1742# endif
1743_GL_FUNCDECL_RPL (pthread_setspecific, int,
1744 (pthread_key_t key, const void *value), );
1745_GL_CXXALIAS_RPL (pthread_setspecific, int,
1746 (pthread_key_t key, const void *value));
1747# else
1748# if !@HAVE_PTHREAD_SETSPECIFIC@
1749_GL_FUNCDECL_SYS (pthread_setspecific, int,
1750 (pthread_key_t key, const void *value), );
1751# endif
1752_GL_CXXALIAS_SYS (pthread_setspecific, int,
1753 (pthread_key_t key, const void *value));
1754# endif
1755# if __GLIBC__ >= 2
1756_GL_CXXALIASWARN (pthread_setspecific);
1757# endif
1758#elif defined GNULIB_POSIXCHECK
1759# if HAVE_RAW_DECL_PTHREAD_SETSPECIFIC
1760_GL_WARN_ON_USE (pthread_setspecific, "pthread_setspecific is not portable - "
1761 "use gnulib module pthread-tss for portability");
1762# endif
1763#endif
1764
1765#if @GNULIB_PTHREAD_TSS@
1766# if @REPLACE_PTHREAD_GETSPECIFIC@
1767# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1768# undef pthread_getspecific
1769# define pthread_getspecific rpl_pthread_getspecific
1770# endif
1771_GL_FUNCDECL_RPL (pthread_getspecific, void *, (pthread_key_t key), );
1772_GL_CXXALIAS_RPL (pthread_getspecific, void *, (pthread_key_t key));
1773# else
1774# if !@HAVE_PTHREAD_GETSPECIFIC@
1775_GL_FUNCDECL_SYS (pthread_getspecific, void *, (pthread_key_t key), );
1776# endif
1777_GL_CXXALIAS_SYS (pthread_getspecific, void *, (pthread_key_t key));
1778# endif
1779# if __GLIBC__ >= 2
1780_GL_CXXALIASWARN (pthread_getspecific);
1781# endif
1782#elif defined GNULIB_POSIXCHECK
1783# if HAVE_RAW_DECL_PTHREAD_GETSPECIFIC
1784_GL_WARN_ON_USE (pthread_getspecific, "pthread_getspecific is not portable - "
1785 "use gnulib module pthread-tss for portability");
1786# endif
1787#endif
1788
1789#if @GNULIB_PTHREAD_TSS@
1790# if @REPLACE_PTHREAD_KEY_DELETE@
1791# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1792# undef pthread_key_delete
1793# define pthread_key_delete rpl_pthread_key_delete
1794# endif
1795_GL_FUNCDECL_RPL (pthread_key_delete, int, (pthread_key_t key), );
1796_GL_CXXALIAS_RPL (pthread_key_delete, int, (pthread_key_t key));
1797# else
1798# if !@HAVE_PTHREAD_KEY_DELETE@
1799_GL_FUNCDECL_SYS (pthread_key_delete, int, (pthread_key_t key), );
1800# endif
1801_GL_CXXALIAS_SYS (pthread_key_delete, int, (pthread_key_t key));
1802# endif
1803# if __GLIBC__ >= 2
1804_GL_CXXALIASWARN (pthread_key_delete);
1805# endif
1806#elif defined GNULIB_POSIXCHECK
1807# if HAVE_RAW_DECL_PTHREAD_KEY_DELETE
1808_GL_WARN_ON_USE (pthread_key_delete, "pthread_key_delete is not portable - "
1809 "use gnulib module pthread-tss for portability");
1810# endif
1811#endif
1812
1813/* =========== Spinlock functions =========== */
1814
1815#if @GNULIB_PTHREAD_SPIN@
1816# if @REPLACE_PTHREAD_SPIN_INIT@
1817# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1818# undef pthread_spin_init
1819# define pthread_spin_init rpl_pthread_spin_init
1820# endif
1821_GL_FUNCDECL_RPL (pthread_spin_init, int,
1822 (pthread_spinlock_t *lock, int shared_across_processes),
1823 _GL_ARG_NONNULL ((1)));
1824_GL_CXXALIAS_RPL (pthread_spin_init, int,
1825 (pthread_spinlock_t *lock, int shared_across_processes));
1826# else
1827# if !@HAVE_PTHREAD_SPIN_INIT@
1828_GL_FUNCDECL_SYS (pthread_spin_init, int,
1829 (pthread_spinlock_t *lock, int shared_across_processes),
1830 _GL_ARG_NONNULL ((1)));
1831# endif
1832_GL_CXXALIAS_SYS (pthread_spin_init, int,
1833 (pthread_spinlock_t *lock, int shared_across_processes));
1834# endif
1835# if __GLIBC__ >= 2
1836_GL_CXXALIASWARN (pthread_spin_init);
1837# endif
1838#elif defined GNULIB_POSIXCHECK
1839# if HAVE_RAW_DECL_PTHREAD_SPIN_INIT
1840_GL_WARN_ON_USE (pthread_spin_init, "pthread_spin_init is not portable - "
1841 "use gnulib module pthread-spin for portability");
1842# endif
1843#endif
1844
1845#if @GNULIB_PTHREAD_SPIN@
1846# if @REPLACE_PTHREAD_SPIN_LOCK@
1847# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1848# undef pthread_spin_lock
1849# define pthread_spin_lock rpl_pthread_spin_lock
1850# endif
1851_GL_FUNCDECL_RPL (pthread_spin_lock, int, (pthread_spinlock_t *lock),
1852 _GL_ARG_NONNULL ((1)));
1853_GL_CXXALIAS_RPL (pthread_spin_lock, int, (pthread_spinlock_t *lock));
1854# else
1855# if !@HAVE_PTHREAD_SPIN_LOCK@
1856_GL_FUNCDECL_SYS (pthread_spin_lock, int, (pthread_spinlock_t *lock),
1857 _GL_ARG_NONNULL ((1)));
1858# endif
1859_GL_CXXALIAS_SYS (pthread_spin_lock, int, (pthread_spinlock_t *lock));
1860# endif
1861# if __GLIBC__ >= 2
1862_GL_CXXALIASWARN (pthread_spin_lock);
1863# endif
1864#elif defined GNULIB_POSIXCHECK
1865# if HAVE_RAW_DECL_PTHREAD_SPIN_LOCK
1866_GL_WARN_ON_USE (pthread_spin_lock, "pthread_spin_lock is not portable - "
1867 "use gnulib module pthread-spin for portability");
1868# endif
1869#endif
1870
1871#if @GNULIB_PTHREAD_SPIN@
1872# if @REPLACE_PTHREAD_SPIN_TRYLOCK@
1873# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1874# undef pthread_spin_trylock
1875# define pthread_spin_trylock rpl_pthread_spin_trylock
1876# endif
1877_GL_FUNCDECL_RPL (pthread_spin_trylock, int, (pthread_spinlock_t *lock),
1878 _GL_ARG_NONNULL ((1)));
1879_GL_CXXALIAS_RPL (pthread_spin_trylock, int, (pthread_spinlock_t *lock));
1880# else
1881# if !@HAVE_PTHREAD_SPIN_TRYLOCK@
1882_GL_FUNCDECL_SYS (pthread_spin_trylock, int, (pthread_spinlock_t *lock),
1883 _GL_ARG_NONNULL ((1)));
1884# endif
1885_GL_CXXALIAS_SYS (pthread_spin_trylock, int, (pthread_spinlock_t *lock));
1886# endif
1887# if __GLIBC__ >= 2
1888_GL_CXXALIASWARN (pthread_spin_trylock);
1889# endif
1890#elif defined GNULIB_POSIXCHECK
1891# if HAVE_RAW_DECL_PTHREAD_SPIN_TRYLOCK
1892_GL_WARN_ON_USE (pthread_spin_trylock, "pthread_spin_trylock is not portable - "
1893 "use gnulib module pthread-spin for portability");
1894# endif
1895#endif
1896
1897#if @GNULIB_PTHREAD_SPIN@
1898# if @REPLACE_PTHREAD_SPIN_UNLOCK@
1899# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1900# undef pthread_spin_unlock
1901# define pthread_spin_unlock rpl_pthread_spin_unlock
1902# endif
1903_GL_FUNCDECL_RPL (pthread_spin_unlock, int, (pthread_spinlock_t *lock),
1904 _GL_ARG_NONNULL ((1)));
1905_GL_CXXALIAS_RPL (pthread_spin_unlock, int, (pthread_spinlock_t *lock));
1906# else
1907# if !@HAVE_PTHREAD_SPIN_UNLOCK@
1908_GL_FUNCDECL_SYS (pthread_spin_unlock, int, (pthread_spinlock_t *lock),
1909 _GL_ARG_NONNULL ((1)));
1910# endif
1911_GL_CXXALIAS_SYS (pthread_spin_unlock, int, (pthread_spinlock_t *lock));
1912# endif
1913# if __GLIBC__ >= 2
1914_GL_CXXALIASWARN (pthread_spin_unlock);
1915# endif
1916#elif defined GNULIB_POSIXCHECK
1917# if HAVE_RAW_DECL_PTHREAD_SPIN_UNLOCK
1918_GL_WARN_ON_USE (pthread_spin_unlock, "pthread_spin_unlock is not portable - "
1919 "use gnulib module pthread-spin for portability");
1920# endif
1921#endif
1922
1923#if @GNULIB_PTHREAD_SPIN@
1924# if @REPLACE_PTHREAD_SPIN_DESTROY@
1925# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1926# undef pthread_spin_destroy
1927# define pthread_spin_destroy rpl_pthread_spin_destroy
1928# endif
1929_GL_FUNCDECL_RPL (pthread_spin_destroy, int, (pthread_spinlock_t *lock),
1930 _GL_ARG_NONNULL ((1)));
1931_GL_CXXALIAS_RPL (pthread_spin_destroy, int, (pthread_spinlock_t *lock));
1932# else
1933# if !@HAVE_PTHREAD_SPIN_DESTROY@
1934_GL_FUNCDECL_SYS (pthread_spin_destroy, int, (pthread_spinlock_t *lock),
1935 _GL_ARG_NONNULL ((1)));
1936# endif
1937_GL_CXXALIAS_SYS (pthread_spin_destroy, int, (pthread_spinlock_t *lock));
1938# endif
1939# if __GLIBC__ >= 2
1940_GL_CXXALIASWARN (pthread_spin_destroy);
1941# endif
1942#elif defined GNULIB_POSIXCHECK
1943# if HAVE_RAW_DECL_PTHREAD_SPIN_DESTROY
1944_GL_WARN_ON_USE (pthread_spin_destroy, "pthread_spin_destroy is not portable - "
1945 "use gnulib module pthread-spin for portability");
1946# endif
1947#endif
1948
1949
1950#if defined __cplusplus && defined GNULIB_NAMESPACE && !@HAVE_PTHREAD_H@ && defined __MINGW32__
1951/* Provide the symbols required by mingw's <bits/gthr-default.h>. */
1952using GNULIB_NAMESPACE::pthread_create;
1953using GNULIB_NAMESPACE::pthread_self;
1954using GNULIB_NAMESPACE::pthread_equal;
1955using GNULIB_NAMESPACE::pthread_detach;
1956using GNULIB_NAMESPACE::pthread_join;
1957using GNULIB_NAMESPACE::pthread_once;
1958using GNULIB_NAMESPACE::pthread_mutex_init;
1959using GNULIB_NAMESPACE::pthread_mutexattr_init;
1960using GNULIB_NAMESPACE::pthread_mutexattr_settype;
1961using GNULIB_NAMESPACE::pthread_mutexattr_destroy;
1962using GNULIB_NAMESPACE::pthread_mutex_lock;
1963using GNULIB_NAMESPACE::pthread_mutex_trylock;
1964using GNULIB_NAMESPACE::pthread_mutex_timedlock;
1965using GNULIB_NAMESPACE::pthread_mutex_unlock;
1966using GNULIB_NAMESPACE::pthread_mutex_destroy;
1967using GNULIB_NAMESPACE::pthread_cond_wait;
1968using GNULIB_NAMESPACE::pthread_cond_timedwait;
1969using GNULIB_NAMESPACE::pthread_cond_signal;
1970using GNULIB_NAMESPACE::pthread_cond_broadcast;
1971using GNULIB_NAMESPACE::pthread_cond_destroy;
1972using GNULIB_NAMESPACE::pthread_key_create;
1973using GNULIB_NAMESPACE::pthread_setspecific;
1974using GNULIB_NAMESPACE::pthread_getspecific;
1975using GNULIB_NAMESPACE::pthread_key_delete;
1976#endif
1977
1978
1979#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */
1980#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */
1981#endif
diff --git a/gl/realloc.c b/gl/realloc.c
index 1063eb09..9b35c235 100644
--- a/gl/realloc.c
+++ b/gl/realloc.c
@@ -1,6 +1,6 @@
1/* realloc() function that is glibc compatible. 1/* realloc() function that is glibc compatible.
2 2
3 Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2023 Free Software 3 Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -18,17 +18,21 @@
18 18
19/* written by Jim Meyering and Bruno Haible */ 19/* written by Jim Meyering and Bruno Haible */
20 20
21#include <config.h> 21/* Ensure that we call the system's realloc() below. */
22#define _GL_USE_STDLIB_ALLOC 1
22 23
24#define _GL_REALLOC_INLINE _GL_EXTERN_INLINE
25#include <config.h>
23#include <stdlib.h> 26#include <stdlib.h>
24 27
25#include <errno.h> 28#include <errno.h>
29#include <stdckdint.h>
26 30
27#include "xalloc-oversized.h" 31#ifdef __CHERI_PURE_CAPABILITY__
32# include <cheri.h>
33#endif
28 34
29/* Call the system's realloc below. This file does not define 35#ifndef _GL_INLINE_RPL_REALLOC
30 _GL_USE_STDLIB_ALLOC because it needs Gnulib's malloc if present. */
31#undef realloc
32 36
33/* Change the size of an allocated block of memory P to N bytes, 37/* Change the size of an allocated block of memory P to N bytes,
34 with error checking. If P is NULL, use malloc. Otherwise if N is zero, 38 with error checking. If P is NULL, use malloc. Otherwise if N is zero,
@@ -37,27 +41,70 @@
37void * 41void *
38rpl_realloc (void *p, size_t n) 42rpl_realloc (void *p, size_t n)
39{ 43{
40 if (p == NULL) 44 size_t n1 = n;
41 return malloc (n);
42 45
43 if (n == 0) 46 if (n == 0)
44 { 47 {
45 free (p); 48# if NEED_SANITIZED_REALLOC
46 return NULL; 49 /* When P is non-null, ISO C23 §7.24.3.7.(3) says realloc (P, 0) has
50 undefined behavior even though C17 and earlier partially defined
51 the behavior. Let the programmer know.
52 When the undefined-behaviour sanitizers report this case, i.e. when
53 <https://gcc.gnu.org/PR117233> and
54 <https://github.com/llvm/llvm-project/issues/113065>
55 have been closed and new releases of GCC and clang have been made,
56 we can revisit this code. */
57 if (p != NULL)
58 abort ();
59# endif
60
61 /* realloc (NULL, 0) acts like glibc malloc (0), i.e., like malloc (1)
62 except the caller cannot dereference any non-null return.
63
64 realloc (P, 0) with non-null P is a messier situation.
65 As mentioned above, C23 says behavior is undefined.
66 POSIX.1-2024 extends C17 to say realloc (P, 0)
67 either fails by setting errno and returning a null pointer,
68 or succeeds by freeing P and then either:
69 (a) setting errno=EINVAL and returning a null pointer; or
70 (b) acting like a successful malloc (0).
71 glibc 1 through 2.1 realloc acted like (b),
72 which conforms to C17, to C23 and to POSIX.1-2024.
73 glibc 2.1.1+ realloc acts like (a) except it does not set errno;
74 this conforms to C17 and to C23 but not to POSIX.1-2024.
75 Quite possibly future versions of POSIX will change,
76 due either to C23 or to (a)'s semantics being messy.
77 Act like (b), as that's easy, matches GNU, BSD and V7 malloc,
78 matches BSD and V7 realloc, and requires no extra code at
79 caller sites. */
80
81# if !HAVE_REALLOC_0_NONNULL
82 n1 = 1;
83# endif
47 } 84 }
48 85
49 if (xalloc_oversized (n, 1)) 86# if !HAVE_MALLOC_PTRDIFF
87 ptrdiff_t signed_n;
88 if (ckd_add (&signed_n, n, 0))
50 { 89 {
51 errno = ENOMEM; 90 errno = ENOMEM;
52 return NULL; 91 return NULL;
53 } 92 }
93# endif
54 94
55 void *result = realloc (p, n); 95 void *result = realloc (p, n1);
56 96
57#if !HAVE_MALLOC_POSIX 97# if !HAVE_REALLOC_POSIX
58 if (result == NULL) 98 if (result == NULL)
59 errno = ENOMEM; 99 errno = ENOMEM;
60#endif 100# endif
101
102# ifdef __CHERI_PURE_CAPABILITY__
103 if (result != NULL)
104 result = cheri_bounds_set (result, n);
105# endif
61 106
62 return result; 107 return result;
63} 108}
109
110#endif
diff --git a/gl/reallocarray.c b/gl/reallocarray.c
index 8c99250f..60573fef 100644
--- a/gl/reallocarray.c
+++ b/gl/reallocarray.c
@@ -1,6 +1,6 @@
1/* reallocarray function that is glibc compatible. 1/* reallocarray function that is glibc compatible.
2 2
3 Copyright (C) 2017-2023 Free Software Foundation, Inc. 3 Copyright (C) 2017-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -33,6 +33,6 @@ reallocarray (void *ptr, size_t nmemb, size_t size)
33 return NULL; 33 return NULL;
34 } 34 }
35 35
36 /* Rely on the semantics of GNU realloc. */ 36 /* Call realloc, setting errno to ENOMEM on failure. */
37 return realloc (ptr, nbytes); 37 return realloc (ptr, nbytes);
38} 38}
diff --git a/gl/regcomp.c b/gl/regcomp.c
index 89478396..aa2f6800 100644
--- a/gl/regcomp.c
+++ b/gl/regcomp.c
@@ -1,5 +1,5 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2023 Free Software Foundation, Inc. 2 Copyright (C) 2002-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
@@ -831,7 +831,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
831 if (table_size > pat_len) 831 if (table_size > pat_len)
832 break; 832 break;
833 833
834 dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); 834 dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
835 dfa->state_hash_mask = table_size - 1; 835 dfa->state_hash_mask = table_size - 1;
836 836
837 dfa->mb_cur_max = MB_CUR_MAX; 837 dfa->mb_cur_max = MB_CUR_MAX;
@@ -862,7 +862,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
862 { 862 {
863 int i, j, ch; 863 int i, j, ch;
864 864
865 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 865 dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
866 if (__glibc_unlikely (dfa->sb_char == NULL)) 866 if (__glibc_unlikely (dfa->sb_char == NULL))
867 return REG_ESPACE; 867 return REG_ESPACE;
868 868
@@ -905,7 +905,7 @@ init_word_char (re_dfa_t *dfa)
905 bitset_word_t bits3 = 0x07fffffe; 905 bitset_word_t bits3 = 0x07fffffe;
906 if (BITSET_WORD_BITS == 64) 906 if (BITSET_WORD_BITS == 64)
907 { 907 {
908 /* Pacify gcc -Woverflow on 32-bit platformns. */ 908 /* Pacify gcc -Woverflow on 32-bit platforms. */
909 dfa->word_char[0] = bits1 << 31 << 1 | bits0; 909 dfa->word_char[0] = bits1 << 31 << 1 | bits0;
910 dfa->word_char[1] = bits3 << 31 << 1 | bits2; 910 dfa->word_char[1] = bits3 << 31 << 1 | bits2;
911 i = 2; 911 i = 2;
@@ -1001,21 +1001,25 @@ create_initial_state (re_dfa_t *dfa)
1001 Idx dest_idx = dfa->edests[node_idx].elems[0]; 1001 Idx dest_idx = dfa->edests[node_idx].elems[0];
1002 if (!re_node_set_contains (&init_nodes, dest_idx)) 1002 if (!re_node_set_contains (&init_nodes, dest_idx))
1003 { 1003 {
1004 reg_errcode_t merge_err 1004 err
1005 = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx); 1005 = re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
1006 if (merge_err != REG_NOERROR) 1006 if (err != REG_NOERROR)
1007 return merge_err; 1007 break;
1008 i = 0; 1008 i = 0;
1009 } 1009 }
1010 } 1010 }
1011 } 1011 }
1012 1012
1013 /* It must be the first time to invoke acquire_state. */ 1013 /* It must be the first time to invoke acquire_state. */
1014 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); 1014 dfa->init_state
1015 /* We don't check ERR here, since the initial state must not be NULL. */ 1015 = (err == REG_NOERROR
1016 ? re_acquire_state_context (&err, dfa, &init_nodes, 0)
1017 : NULL);
1016 if (__glibc_unlikely (dfa->init_state == NULL)) 1018 if (__glibc_unlikely (dfa->init_state == NULL))
1017 return err; 1019 {
1018 if (dfa->init_state->has_constraint) 1020 /* Don't check ERR here, as the initial state must not be null. */
1021 }
1022 else if (dfa->init_state->has_constraint)
1019 { 1023 {
1020 dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes, 1024 dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes,
1021 CONTEXT_WORD); 1025 CONTEXT_WORD);
@@ -1025,17 +1029,13 @@ create_initial_state (re_dfa_t *dfa)
1025 &init_nodes, 1029 &init_nodes,
1026 CONTEXT_NEWLINE 1030 CONTEXT_NEWLINE
1027 | CONTEXT_BEGBUF); 1031 | CONTEXT_BEGBUF);
1028 if (__glibc_unlikely (dfa->init_state_word == NULL
1029 || dfa->init_state_nl == NULL
1030 || dfa->init_state_begbuf == NULL))
1031 return err;
1032 } 1032 }
1033 else 1033 else
1034 dfa->init_state_word = dfa->init_state_nl 1034 dfa->init_state_word = dfa->init_state_nl
1035 = dfa->init_state_begbuf = dfa->init_state; 1035 = dfa->init_state_begbuf = dfa->init_state;
1036 1036
1037 re_node_set_free (&init_nodes); 1037 re_node_set_free (&init_nodes);
1038 return REG_NOERROR; 1038 return err;
1039} 1039}
1040 1040
1041/* If it is possible to do searching in single byte encoding instead of UTF-8 1041/* If it is possible to do searching in single byte encoding instead of UTF-8
@@ -1677,12 +1677,11 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1677 { 1677 {
1678 err = duplicate_node_closure (dfa, node, node, node, 1678 err = duplicate_node_closure (dfa, node, node, node,
1679 dfa->nodes[node].constraint); 1679 dfa->nodes[node].constraint);
1680 if (__glibc_unlikely (err != REG_NOERROR))
1681 return err;
1682 } 1680 }
1683 1681
1684 /* Expand each epsilon destination nodes. */ 1682 /* Expand each epsilon destination nodes. */
1685 if (IS_EPSILON_NODE(dfa->nodes[node].type)) 1683 if (__glibc_likely (err == REG_NOERROR)
1684 && IS_EPSILON_NODE (dfa->nodes[node].type))
1686 for (i = 0; i < dfa->edests[node].nelem; ++i) 1685 for (i = 0; i < dfa->edests[node].nelem; ++i)
1687 { 1686 {
1688 re_node_set eclosure_elem; 1687 re_node_set eclosure_elem;
@@ -1700,14 +1699,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1700 { 1699 {
1701 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); 1700 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
1702 if (__glibc_unlikely (err != REG_NOERROR)) 1701 if (__glibc_unlikely (err != REG_NOERROR))
1703 return err; 1702 break;
1704 } 1703 }
1705 else 1704 else
1706 eclosure_elem = dfa->eclosures[edest]; 1705 eclosure_elem = dfa->eclosures[edest];
1707 /* Merge the epsilon closure of 'edest'. */ 1706 /* Merge the epsilon closure of 'edest'. */
1708 err = re_node_set_merge (&eclosure, &eclosure_elem); 1707 err = re_node_set_merge (&eclosure, &eclosure_elem);
1709 if (__glibc_unlikely (err != REG_NOERROR)) 1708 if (__glibc_unlikely (err != REG_NOERROR))
1710 return err; 1709 break;
1711 /* If the epsilon closure of 'edest' is incomplete, 1710 /* If the epsilon closure of 'edest' is incomplete,
1712 the epsilon closure of this node is also incomplete. */ 1711 the epsilon closure of this node is also incomplete. */
1713 if (dfa->eclosures[edest].nelem == 0) 1712 if (dfa->eclosures[edest].nelem == 0)
@@ -1717,12 +1716,18 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1717 } 1716 }
1718 } 1717 }
1719 1718
1720 if (incomplete && !root) 1719 if (err != REG_NOERROR)
1721 dfa->eclosures[node].nelem = 0; 1720 re_node_set_free (&eclosure);
1722 else 1721 else
1723 dfa->eclosures[node] = eclosure; 1722 {
1724 *new_set = eclosure; 1723 if (incomplete && !root)
1725 return REG_NOERROR; 1724 dfa->eclosures[node].nelem = 0;
1725 else
1726 dfa->eclosures[node] = eclosure;
1727 *new_set = eclosure;
1728 }
1729
1730 return err;
1726} 1731}
1727 1732
1728/* Functions for token which are used in the parser. */ 1733/* Functions for token which are used in the parser. */
@@ -3055,8 +3060,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3055 _NL_COLLATE_SYMB_EXTRAMB); 3060 _NL_COLLATE_SYMB_EXTRAMB);
3056 } 3061 }
3057#endif 3062#endif
3058 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3063 sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
3059 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3064 mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
3060 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL)) 3065 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
3061 { 3066 {
3062 re_free (sbcset); 3067 re_free (sbcset);
@@ -3275,6 +3280,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3275 else 3280 else
3276 { 3281 {
3277 free_charset (mbcset); 3282 free_charset (mbcset);
3283 mbcset = NULL;
3278 /* Build a tree for simple bracket. */ 3284 /* Build a tree for simple bracket. */
3279 br_token.type = SIMPLE_BRACKET; 3285 br_token.type = SIMPLE_BRACKET;
3280 br_token.opr.sbcset = sbcset; 3286 br_token.opr.sbcset = sbcset;
@@ -3288,7 +3294,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3288 *err = REG_ESPACE; 3294 *err = REG_ESPACE;
3289 parse_bracket_exp_free_return: 3295 parse_bracket_exp_free_return:
3290 re_free (sbcset); 3296 re_free (sbcset);
3291 free_charset (mbcset); 3297 if (__glibc_likely (mbcset != NULL))
3298 free_charset (mbcset);
3292 return NULL; 3299 return NULL;
3293} 3300}
3294 3301
@@ -3548,13 +3555,13 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3548 reg_errcode_t ret; 3555 reg_errcode_t ret;
3549 bin_tree_t *tree; 3556 bin_tree_t *tree;
3550 3557
3551 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3558 sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
3552 if (__glibc_unlikely (sbcset == NULL)) 3559 if (__glibc_unlikely (sbcset == NULL))
3553 { 3560 {
3554 *err = REG_ESPACE; 3561 *err = REG_ESPACE;
3555 return NULL; 3562 return NULL;
3556 } 3563 }
3557 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3564 mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
3558 if (__glibc_unlikely (mbcset == NULL)) 3565 if (__glibc_unlikely (mbcset == NULL))
3559 { 3566 {
3560 re_free (sbcset); 3567 re_free (sbcset);
diff --git a/gl/regex.c b/gl/regex.c
index 3beb0deb..f9f333d2 100644
--- a/gl/regex.c
+++ b/gl/regex.c
@@ -1,5 +1,5 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2023 Free Software Foundation, Inc. 2 Copyright (C) 2002-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
@@ -24,12 +24,9 @@
24 24
25# if __GNUC_PREREQ (4, 6) 25# if __GNUC_PREREQ (4, 6)
26# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" 26# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
27# pragma GCC diagnostic ignored "-Wswitch-enum"
27# pragma GCC diagnostic ignored "-Wvla" 28# pragma GCC diagnostic ignored "-Wvla"
28# endif 29# endif
29# if __GNUC_PREREQ (4, 3)
30# pragma GCC diagnostic ignored "-Wold-style-definition"
31# pragma GCC diagnostic ignored "-Wtype-limits"
32# endif
33#endif 30#endif
34 31
35/* Make sure no one compiles this code with a C++ compiler. */ 32/* Make sure no one compiles this code with a C++ compiler. */
diff --git a/gl/regex.h b/gl/regex.h
index 9ef0252f..df35c93e 100644
--- a/gl/regex.h
+++ b/gl/regex.h
@@ -1,6 +1,6 @@
1/* Definitions for data structures and routines for the regular 1/* Definitions for data structures and routines for the regular
2 expression library. 2 expression library.
3 Copyright (C) 1985, 1989-2023 Free Software Foundation, Inc. 3 Copyright (C) 1985, 1989-2026 Free Software Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
@@ -66,15 +66,14 @@ typedef unsigned long int active_reg_t;
66 66
67/* The following bits are used to determine the regexp syntax we 67/* The following bits are used to determine the regexp syntax we
68 recognize. The set/not-set meanings are chosen so that Emacs syntax 68 recognize. The set/not-set meanings are chosen so that Emacs syntax
69 remains the value 0. The bits are given in alphabetical order, and 69 is the value 0 for Emacs 20 (2000) and earlier, and the value
70 the definitions shifted by one from the previous bit; thus, when we 70 RE_SYNTAX_EMACS for Emacs 21 (2001) and later. */
71 add or remove a bit, only one other definition need change. */
72typedef unsigned long int reg_syntax_t; 71typedef unsigned long int reg_syntax_t;
73 72
74#ifdef __USE_GNU 73#ifdef __USE_GNU
75/* If this bit is not set, then \ inside a bracket expression is literal. 74/* If this bit is not set, then \ inside a bracket expression is literal.
76 If set, then such a \ quotes the following character. */ 75 If set, then such a \ quotes the following character. */
77# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) 76# define RE_BACKSLASH_ESCAPE_IN_LISTS 1ul
78 77
79/* If this bit is not set, then + and ? are operators, and \+ and \? are 78/* If this bit is not set, then + and ? are operators, and \+ and \? are
80 literals. 79 literals.
@@ -215,7 +214,8 @@ extern reg_syntax_t re_syntax_options;
215 (The [[[ comments delimit what gets put into the Texinfo file, so 214 (The [[[ comments delimit what gets put into the Texinfo file, so
216 don't delete them!) */ 215 don't delete them!) */
217/* [[[begin syntaxes]]] */ 216/* [[[begin syntaxes]]] */
218# define RE_SYNTAX_EMACS 0 217# define RE_SYNTAX_EMACS \
218 (RE_CHAR_CLASSES | RE_INTERVALS)
219 219
220# define RE_SYNTAX_AWK \ 220# define RE_SYNTAX_AWK \
221 (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ 221 (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
@@ -522,20 +522,6 @@ typedef struct
522 522
523/* Declarations for routines. */ 523/* Declarations for routines. */
524 524
525#ifndef _REGEX_NELTS
526# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
527 && !defined __STDC_NO_VLA__)
528# define _REGEX_NELTS(n) n
529# else
530# define _REGEX_NELTS(n)
531# endif
532#endif
533
534#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
535# pragma GCC diagnostic push
536# pragma GCC diagnostic ignored "-Wvla"
537#endif
538
539#ifndef _Attr_access_ 525#ifndef _Attr_access_
540# ifdef __attr_access 526# ifdef __attr_access
541# define _Attr_access_(arg) __attr_access (arg) 527# define _Attr_access_(arg) __attr_access (arg)
@@ -647,10 +633,12 @@ extern int re_exec (const char *);
647 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ 633 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
648 || __clang_major__ >= 3 634 || __clang_major__ >= 3
649# define _Restrict_ __restrict 635# define _Restrict_ __restrict
650# elif 199901L <= __STDC_VERSION__ || defined restrict
651# define _Restrict_ restrict
652# else 636# else
653# define _Restrict_ 637# if 199901L <= __STDC_VERSION__ || defined restrict
638# define _Restrict_ restrict
639# else
640# define _Restrict_
641# endif
654# endif 642# endif
655#endif 643#endif
656/* For the ISO C99 syntax 644/* For the ISO C99 syntax
@@ -661,13 +649,15 @@ extern int re_exec (const char *);
661#ifndef _Restrict_arr_ 649#ifndef _Restrict_arr_
662# ifdef __restrict_arr 650# ifdef __restrict_arr
663# define _Restrict_arr_ __restrict_arr 651# define _Restrict_arr_ __restrict_arr
664# elif ((199901L <= __STDC_VERSION__ \ 652# else
653# if ((199901L <= __STDC_VERSION__ \
665 || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ 654 || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
666 || __clang_major__ >= 3) \ 655 || __clang_major__ >= 3) \
667 && !defined __cplusplus) 656 && !defined __cplusplus)
668# define _Restrict_arr_ _Restrict_ 657# define _Restrict_arr_ _Restrict_
669# else 658# else
670# define _Restrict_arr_ 659# define _Restrict_arr_
660# endif
671# endif 661# endif
672#endif 662#endif
673 663
@@ -678,8 +668,7 @@ extern int regcomp (regex_t *_Restrict_ __preg,
678 668
679extern int regexec (const regex_t *_Restrict_ __preg, 669extern int regexec (const regex_t *_Restrict_ __preg,
680 const char *_Restrict_ __String, size_t __nmatch, 670 const char *_Restrict_ __String, size_t __nmatch,
681 regmatch_t __pmatch[_Restrict_arr_ 671 regmatch_t __pmatch[_Restrict_arr_],
682 _REGEX_NELTS (__nmatch)],
683 int __eflags); 672 int __eflags);
684 673
685extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, 674extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
@@ -688,10 +677,6 @@ extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
688 677
689extern void regfree (regex_t *__preg); 678extern void regfree (regex_t *__preg);
690 679
691#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
692# pragma GCC diagnostic pop
693#endif
694
695#ifdef __cplusplus 680#ifdef __cplusplus
696} 681}
697#endif /* C++ */ 682#endif /* C++ */
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index 998a19b7..4b9b80f6 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -1,5 +1,5 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2023 Free Software Foundation, Inc. 2 Copyright (C) 2002-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
@@ -937,8 +937,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
937 set->alloc = size; 937 set->alloc = size;
938 set->nelem = 0; 938 set->nelem = 0;
939 set->elems = re_malloc (Idx, size); 939 set->elems = re_malloc (Idx, size);
940 if (__glibc_unlikely (set->elems == NULL) 940 if (__glibc_unlikely (set->elems == NULL))
941 && (MALLOC_0_IS_NONNULL || size != 0))
942 return REG_ESPACE; 941 return REG_ESPACE;
943 return REG_NOERROR; 942 return REG_NOERROR;
944} 943}
@@ -1596,7 +1595,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1596 reg_errcode_t err; 1595 reg_errcode_t err;
1597 re_dfastate_t *newstate; 1596 re_dfastate_t *newstate;
1598 1597
1599 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1598 newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
1600 if (__glibc_unlikely (newstate == NULL)) 1599 if (__glibc_unlikely (newstate == NULL))
1601 return NULL; 1600 return NULL;
1602 err = re_node_set_init_copy (&newstate->nodes, nodes); 1601 err = re_node_set_init_copy (&newstate->nodes, nodes);
@@ -1644,7 +1643,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1644 reg_errcode_t err; 1643 reg_errcode_t err;
1645 re_dfastate_t *newstate; 1644 re_dfastate_t *newstate;
1646 1645
1647 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1646 newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
1648 if (__glibc_unlikely (newstate == NULL)) 1647 if (__glibc_unlikely (newstate == NULL))
1649 return NULL; 1648 return NULL;
1650 err = re_node_set_init_copy (&newstate->nodes, nodes); 1649 err = re_node_set_init_copy (&newstate->nodes, nodes);
diff --git a/gl/regex_internal.h b/gl/regex_internal.h
index 149ec2e8..11b745ef 100644
--- a/gl/regex_internal.h
+++ b/gl/regex_internal.h
@@ -1,5 +1,5 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2023 Free Software Foundation, Inc. 2 Copyright (C) 2002-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
@@ -29,6 +29,7 @@
29#include <locale.h> 29#include <locale.h>
30#include <wchar.h> 30#include <wchar.h>
31#include <wctype.h> 31#include <wctype.h>
32#include <stdckdint.h>
32#include <stdint.h> 33#include <stdint.h>
33 34
34#ifndef _LIBC 35#ifndef _LIBC
@@ -97,22 +98,14 @@
97#endif 98#endif
98 99
99/* This is for other GNU distributions with internationalized messages. */ 100/* This is for other GNU distributions with internationalized messages. */
100#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC 101#ifdef _LIBC
101# include <libintl.h> 102# include <libintl.h>
102# ifdef _LIBC
103# undef gettext
104# define gettext(msgid) \
105 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
106# endif
107#else
108# undef gettext 103# undef gettext
109# define gettext(msgid) (msgid) 104# define gettext(msgid) \
110#endif 105 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
111
112#ifndef gettext_noop
113/* This define is so xgettext can find the internationalizable
114 strings. */
115# define gettext_noop(String) String 106# define gettext_noop(String) String
107#else
108# include "gettext.h"
116#endif 109#endif
117 110
118/* Number of ASCII characters. */ 111/* Number of ASCII characters. */
@@ -150,9 +143,6 @@
150 as some non-GCC platforms lack them, an issue when this code is 143 as some non-GCC platforms lack them, an issue when this code is
151 used in Gnulib. */ 144 used in Gnulib. */
152 145
153#ifndef SSIZE_MAX
154# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
155#endif
156#ifndef ULONG_WIDTH 146#ifndef ULONG_WIDTH
157# define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX) 147# define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX)
158/* The number of usable bits in an unsigned integer type with maximum 148/* The number of usable bits in an unsigned integer type with maximum
@@ -438,12 +428,6 @@ typedef struct re_dfa_t re_dfa_t;
438#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) 428#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
439#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) 429#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
440 430
441#ifdef _LIBC
442# define MALLOC_0_IS_NONNULL 1
443#elif !defined MALLOC_0_IS_NONNULL
444# define MALLOC_0_IS_NONNULL 0
445#endif
446
447#ifndef MAX 431#ifndef MAX
448# define MAX(a,b) ((a) < (b) ? (b) : (a)) 432# define MAX(a,b) ((a) < (b) ? (b) : (a))
449#endif 433#endif
@@ -822,7 +806,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
822} 806}
823 807
824#ifdef _LIBC 808#ifdef _LIBC
825# if __GNUC__ >= 7 809# if __glibc_has_attribute (__fallthrough__)
826# define FALLTHROUGH __attribute__ ((__fallthrough__)) 810# define FALLTHROUGH __attribute__ ((__fallthrough__))
827# else 811# else
828# define FALLTHROUGH ((void) 0) 812# define FALLTHROUGH ((void) 0)
diff --git a/gl/regexec.c b/gl/regexec.c
index 13e0349e..c84ce1ef 100644
--- a/gl/regexec.c
+++ b/gl/regexec.c
@@ -1,5 +1,5 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2023 Free Software Foundation, Inc. 2 Copyright (C) 2002-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
@@ -185,7 +185,7 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
185 185
186int 186int
187regexec (const regex_t *__restrict preg, const char *__restrict string, 187regexec (const regex_t *__restrict preg, const char *__restrict string,
188 size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) 188 size_t nmatch, regmatch_t pmatch[], int eflags)
189{ 189{
190 reg_errcode_t err; 190 reg_errcode_t err;
191 Idx start, length; 191 Idx start, length;
@@ -229,7 +229,7 @@ int
229attribute_compat_text_section 229attribute_compat_text_section
230__compat_regexec (const regex_t *__restrict preg, 230__compat_regexec (const regex_t *__restrict preg,
231 const char *__restrict string, size_t nmatch, 231 const char *__restrict string, size_t nmatch,
232 regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags) 232 regmatch_t pmatch[], int eflags)
233{ 233{
234 return regexec (preg, string, nmatch, pmatch, 234 return regexec (preg, string, nmatch, pmatch,
235 eflags & (REG_NOTBOL | REG_NOTEOL)); 235 eflags & (REG_NOTBOL | REG_NOTEOL));
@@ -324,7 +324,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
324 char *s = NULL; 324 char *s = NULL;
325 325
326 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0 326 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
327 || INT_ADD_WRAPV (length1, length2, &len)))) 327 || ckd_add (&len, length1, length2))))
328 return -2; 328 return -2;
329 329
330 /* Concatenate the strings. */ 330 /* Concatenate the strings. */
@@ -2271,7 +2271,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2271 these destinations and the results of the transition table. */ 2271 these destinations and the results of the transition table. */
2272 pstate = mctx->state_log[cur_idx]; 2272 pstate = mctx->state_log[cur_idx];
2273 log_nodes = pstate->entrance_nodes; 2273 log_nodes = pstate->entrance_nodes;
2274 if (next_state != NULL) 2274 if (next_state != NULL && next_state->entrance_nodes != NULL)
2275 { 2275 {
2276 table_nodes = next_state->entrance_nodes; 2276 table_nodes = next_state->entrance_nodes;
2277 *err = re_node_set_init_union (&next_nodes, table_nodes, 2277 *err = re_node_set_init_union (&next_nodes, table_nodes,
@@ -2721,8 +2721,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2721 continue; /* No. */ 2721 continue; /* No. */
2722 if (sub_top->path == NULL) 2722 if (sub_top->path == NULL)
2723 { 2723 {
2724 sub_top->path = calloc (sizeof (state_array_t), 2724 sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
2725 sl_str - sub_top->str_idx + 1); 2725 sizeof (state_array_t));
2726 if (sub_top->path == NULL) 2726 if (sub_top->path == NULL)
2727 return REG_ESPACE; 2727 return REG_ESPACE;
2728 } 2728 }
@@ -3266,7 +3266,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3266 if (ndests == 0) 3266 if (ndests == 0)
3267 { 3267 {
3268 state->trtable = (re_dfastate_t **) 3268 state->trtable = (re_dfastate_t **)
3269 calloc (sizeof (re_dfastate_t *), SBC_MAX); 3269 calloc (SBC_MAX, sizeof (re_dfastate_t *));
3270 if (__glibc_unlikely (state->trtable == NULL)) 3270 if (__glibc_unlikely (state->trtable == NULL))
3271 return false; 3271 return false;
3272 return true; 3272 return true;
@@ -3338,7 +3338,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3338 discern by looking at the character code: allocate a 3338 discern by looking at the character code: allocate a
3339 256-entry transition table. */ 3339 256-entry transition table. */
3340 trtable = state->trtable = 3340 trtable = state->trtable =
3341 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); 3341 (re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
3342 if (__glibc_unlikely (trtable == NULL)) 3342 if (__glibc_unlikely (trtable == NULL))
3343 goto out_free; 3343 goto out_free;
3344 3344
@@ -3369,7 +3369,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3369 transition tables, one starting at trtable[0] and one 3369 transition tables, one starting at trtable[0] and one
3370 starting at trtable[SBC_MAX]. */ 3370 starting at trtable[SBC_MAX]. */
3371 trtable = state->word_trtable = 3371 trtable = state->word_trtable =
3372 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); 3372 (re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
3373 if (__glibc_unlikely (trtable == NULL)) 3373 if (__glibc_unlikely (trtable == NULL))
3374 goto out_free; 3374 goto out_free;
3375 3375
diff --git a/gl/sched.in.h b/gl/sched.in.h
new file mode 100644
index 00000000..cb8ceca0
--- /dev/null
+++ b/gl/sched.in.h
@@ -0,0 +1,110 @@
1/* A GNU-like <sched.h>.
2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _@GUARD_PREFIX@_SCHED_H
18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
24/* This file uses #include_next of a system file that defines time_t.
25 For the 'year2038' module to work right, <config.h> needs to have been
26 included before. */
27#if !_GL_CONFIG_H_INCLUDED
28 #error "Please include config.h first."
29#endif
30
31/* The include_next requires a split double-inclusion guard. */
32#if @HAVE_SCHED_H@
33# if @HAVE_SYS_CDEFS_H@
34# include <sys/cdefs.h>
35# endif
36# @INCLUDE_NEXT@ @NEXT_SCHED_H@
37#endif
38
39#ifndef _@GUARD_PREFIX@_SCHED_H
40#define _@GUARD_PREFIX@_SCHED_H
41
42/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
43#if !_GL_CONFIG_H_INCLUDED
44 #error "Please include config.h first."
45#endif
46
47/* Get pid_t.
48 This is needed on glibc 2.11 (see
49 glibc bug <https://sourceware.org/PR13198>)
50 and Mac OS X 10.5. */
51#include <sys/types.h>
52
53#ifdef __KLIBC__
54/* On OS/2 kLIBC, struct sched_param is in spawn.h. */
55# include <spawn.h>
56#endif
57
58#ifdef __VMS
59/* On OpenVMS, struct sched_param is in <pthread.h>. */
60# include <pthread.h>
61#endif
62
63/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
64
65/* The definition of _GL_WARN_ON_USE is copied here. */
66
67#if !@HAVE_STRUCT_SCHED_PARAM@
68
69# if !GNULIB_defined_struct_sched_param
70struct sched_param
71{
72 int sched_priority;
73};
74# define GNULIB_defined_struct_sched_param 1
75# endif
76
77#endif
78
79#if !(defined SCHED_FIFO && defined SCHED_RR && defined SCHED_OTHER)
80# define SCHED_FIFO 1
81# define SCHED_RR 2
82# define SCHED_OTHER 0
83#endif
84
85#if @GNULIB_SCHED_YIELD@
86# if @REPLACE_SCHED_YIELD@
87# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
88# undef sched_yield
89# define sched_yield rpl_sched_yield
90# endif
91_GL_FUNCDECL_RPL (sched_yield, int, (void), );
92_GL_CXXALIAS_RPL (sched_yield, int, (void));
93# else
94# if !@HAVE_SCHED_YIELD@
95_GL_FUNCDECL_SYS (sched_yield, int, (void), );
96# endif
97_GL_CXXALIAS_SYS (sched_yield, int, (void));
98# endif
99# if __GLIBC__ >= 2
100_GL_CXXALIASWARN (sched_yield);
101# endif
102#elif defined GNULIB_POSIXCHECK
103# if HAVE_RAW_DECL_SCHED_YIELD
104_GL_WARN_ON_USE (sched_yield, "sched_yield is not portable - "
105 "use gnulib module sched_yield for portability");
106# endif
107#endif
108
109#endif /* _@GUARD_PREFIX@_SCHED_H */
110#endif /* _@GUARD_PREFIX@_SCHED_H */
diff --git a/gl/setenv.c b/gl/setenv.c
index f0b88996..ae53146f 100644
--- a/gl/setenv.c
+++ b/gl/setenv.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992, 1995-2003, 2005-2023 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2003, 2005-2026 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
@@ -38,11 +38,23 @@
38# include <unistd.h> 38# include <unistd.h>
39#endif 39#endif
40 40
41#if defined _WIN32 && ! defined __CYGWIN__
42# define WIN32_LEAN_AND_MEAN
43# include <windows.h>
44#endif
45
41#if !_LIBC 46#if !_LIBC
42# include "malloca.h" 47# include "malloca.h"
43#endif 48#endif
44 49
50#if defined _WIN32 && ! defined __CYGWIN__
51/* Don't assume that UNICODE is not defined. */
52# undef SetEnvironmentVariable
53# define SetEnvironmentVariable SetEnvironmentVariableA
54#endif
55
45#if _LIBC || !HAVE_SETENV 56#if _LIBC || !HAVE_SETENV
57#if !HAVE_DECL__PUTENV
46 58
47#if !_LIBC 59#if !_LIBC
48# define __environ environ 60# define __environ environ
@@ -82,6 +94,7 @@ typedef int (*compar_fn_t) (const void *, const void *);
82static void *known_values; 94static void *known_values;
83 95
84# define KNOWN_VALUE(Str) \ 96# define KNOWN_VALUE(Str) \
97 __extension__ \
85 ({ \ 98 ({ \
86 void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \ 99 void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \
87 value != NULL ? *(char **) value : NULL; \ 100 value != NULL ? *(char **) value : NULL; \
@@ -113,8 +126,6 @@ int
113__add_to_environ (const char *name, const char *value, const char *combined, 126__add_to_environ (const char *name, const char *value, const char *combined,
114 int replace) 127 int replace)
115{ 128{
116 char **ep;
117 size_t size;
118 const size_t namelen = strlen (name); 129 const size_t namelen = strlen (name);
119 const size_t vallen = value != NULL ? strlen (value) + 1 : 0; 130 const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
120 131
@@ -122,9 +133,9 @@ __add_to_environ (const char *name, const char *value, const char *combined,
122 133
123 /* We have to get the pointer now that we have the lock and not earlier 134 /* We have to get the pointer now that we have the lock and not earlier
124 since another thread might have created a new environment. */ 135 since another thread might have created a new environment. */
125 ep = __environ; 136 char **ep = __environ;
126 137
127 size = 0; 138 size_t size = 0;
128 if (ep != NULL) 139 if (ep != NULL)
129 { 140 {
130 for (; *ep != NULL; ++ep) 141 for (; *ep != NULL; ++ep)
@@ -136,13 +147,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
136 147
137 if (ep == NULL || *ep == NULL) 148 if (ep == NULL || *ep == NULL)
138 { 149 {
139 char **new_environ;
140#ifdef USE_TSEARCH
141 char *new_value;
142#endif
143
144 /* We allocated this space; we can extend it. */ 150 /* We allocated this space; we can extend it. */
145 new_environ = 151 char **new_environ =
146 (char **) (last_environ == NULL 152 (char **) (last_environ == NULL
147 ? malloc ((size + 2) * sizeof (char *)) 153 ? malloc ((size + 2) * sizeof (char *))
148 : realloc (last_environ, (size + 2) * sizeof (char *))); 154 : realloc (last_environ, (size + 2) * sizeof (char *)));
@@ -164,6 +170,7 @@ __add_to_environ (const char *name, const char *value, const char *combined,
164 { 170 {
165 /* See whether the value is already known. */ 171 /* See whether the value is already known. */
166#ifdef USE_TSEARCH 172#ifdef USE_TSEARCH
173 char *new_value;
167# ifdef _LIBC 174# ifdef _LIBC
168 new_value = (char *) alloca (namelen + 1 + vallen); 175 new_value = (char *) alloca (namelen + 1 + vallen);
169 __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), 176 __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
@@ -214,8 +221,7 @@ __add_to_environ (const char *name, const char *value, const char *combined,
214 } 221 }
215 222
216 if (__environ != last_environ) 223 if (__environ != last_environ)
217 memcpy ((char *) new_environ, (char *) __environ, 224 memcpy (new_environ, __environ, size * sizeof (char *));
218 size * sizeof (char *));
219 225
220 new_environ[size + 1] = NULL; 226 new_environ[size + 1] = NULL;
221 227
@@ -342,6 +348,84 @@ weak_alias (__setenv, setenv)
342weak_alias (__clearenv, clearenv) 348weak_alias (__clearenv, clearenv)
343#endif 349#endif
344 350
351#else /* HAVE_DECL__PUTENV */
352/* Native Windows */
353
354int
355setenv (const char *name, const char *value, int replace)
356{
357 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
358 {
359 errno = EINVAL;
360 return -1;
361 }
362
363 /* The Microsoft documentation
364 <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-wputenv>
365 says:
366 "Don't change an environment entry directly: instead,
367 use _putenv or _wputenv to change it."
368 Note: Microsoft's _putenv updates not only the contents of _environ but
369 also the contents of _wenviron, so that both are in kept in sync. */
370 const char *existing_value = getenv (name);
371 if (existing_value != NULL)
372 {
373 if (replace)
374 {
375 if (strcmp (existing_value, value) == 0)
376 /* No need to allocate memory. */
377 return 0;
378 }
379 else
380 /* Keep the existing value. */
381 return 0;
382 }
383 /* Allocate a new environment entry in the heap. */
384 /* _putenv ("NAME=") unsets NAME, so if VALUE is the empty string, invoke
385 _putenv ("NAME= ") and fix up the result afterwards. */
386 const char *value_ = (value[0] == '\0' ? " " : value);
387 size_t name_len = strlen (name);
388 size_t value_len = strlen (value_);
389 char *string = (char *) malloc (name_len + 1 + value_len + 1);
390 if (string == NULL)
391 return -1;
392 memcpy (string, name, name_len);
393 string[name_len] = '=';
394 memcpy (&string[name_len + 1], value_, value_len + 1);
395 /* Use _putenv. */
396 if (_putenv (string) < 0)
397 return -1;
398 if (value[0] == '\0')
399 {
400 /* Fix up the result. */
401 char *new_value = getenv (name);
402 if (new_value != NULL && new_value[0] == ' ' && new_value[1] == '\0')
403 new_value[0] = '\0';
404# if defined _WIN32 && ! defined __CYGWIN__
405 /* _putenv propagated "NAME= " into the subprocess environment;
406 fix that by calling SetEnvironmentVariable directly. */
407 /* Documentation:
408 <https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setenvironmentvariable> */
409 if (!SetEnvironmentVariable (name, ""))
410 {
411 switch (GetLastError ())
412 {
413 case ERROR_NOT_ENOUGH_MEMORY:
414 case ERROR_OUTOFMEMORY:
415 errno = ENOMEM;
416 break;
417 default:
418 errno = EINVAL;
419 break;
420 }
421 return -1;
422 }
423# endif
424 }
425 return 0;
426}
427
428#endif /* HAVE_DECL__PUTENV */
345#endif /* _LIBC || !HAVE_SETENV */ 429#endif /* _LIBC || !HAVE_SETENV */
346 430
347/* The rest of this file is called into use when replacing an existing 431/* The rest of this file is called into use when replacing an existing
@@ -358,28 +442,31 @@ extern int setenv (const char *, const char *, int);
358int 442int
359rpl_setenv (const char *name, const char *value, int replace) 443rpl_setenv (const char *name, const char *value, int replace)
360{ 444{
361 int result; 445 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
362 if (!name || !*name || strchr (name, '='))
363 { 446 {
364 errno = EINVAL; 447 errno = EINVAL;
365 return -1; 448 return -1;
366 } 449 }
367 /* Call the real setenv even if replace is 0, in case implementation 450 /* Call the real setenv even if replace is 0, in case implementation
368 has underlying data to update, such as when environ changes. */ 451 has underlying data to update, such as when environ changes. */
369 result = setenv (name, value, replace); 452 int result = setenv (name, value, replace);
370 if (result == 0 && replace && *value == '=') 453 if (result == 0 && replace && *value == '=')
371 { 454 {
372 char *tmp = getenv (name); 455 char *tmp = getenv (name);
373 if (!STREQ (tmp, value)) 456 if (!STREQ (tmp, value))
374 { 457 {
375 int saved_errno;
376 size_t len = strlen (value); 458 size_t len = strlen (value);
377 tmp = malloca (len + 2); 459 tmp = malloca (len + 2);
460 if (tmp == NULL)
461 {
462 errno = ENOMEM;
463 return -1;
464 }
378 /* Since leading '=' is eaten, double it up. */ 465 /* Since leading '=' is eaten, double it up. */
379 *tmp = '='; 466 *tmp = '=';
380 memcpy (tmp + 1, value, len + 1); 467 memcpy (tmp + 1, value, len + 1);
381 result = setenv (name, tmp, replace); 468 result = setenv (name, tmp, replace);
382 saved_errno = errno; 469 int saved_errno = errno;
383 freea (tmp); 470 freea (tmp);
384 errno = saved_errno; 471 errno = saved_errno;
385 } 472 }
diff --git a/gl/setlocale-lock.c b/gl/setlocale-lock.c
index b70ba09b..afbcc046 100644
--- a/gl/setlocale-lock.c
+++ b/gl/setlocale-lock.c
@@ -1,5 +1,5 @@
1/* Return the internal lock used by setlocale_null_r. 1/* Return the internal lock used by setlocale_null_r.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc. 2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -18,9 +18,10 @@
18 18
19#include <config.h> 19#include <config.h>
20 20
21/* The option '--disable-threads' explicitly requests no locking. */
21/* When it is known that the gl_get_setlocale_null_lock function is defined 22/* When it is known that the gl_get_setlocale_null_lock function is defined
22 by a dependency library, it should not be defined here. */ 23 by a dependency library, it should not be defined here. */
23#if OMIT_SETLOCALE_LOCK 24#if AVOID_ANY_THREADS || OMIT_SETLOCALE_LOCK
24 25
25/* This declaration is solely to ensure that after preprocessing 26/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */ 27 this file is never empty. */
@@ -37,14 +38,14 @@ typedef int dummy;
37 38
38/* Macro for exporting a symbol (function, not variable) defined in this file, 39/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */ 40 when compiled into a shared library. */
40# ifndef DLL_EXPORTED 41# ifndef SHLIB_EXPORTED
41# if HAVE_VISIBILITY 42# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */ 43 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default"))) 44# define SHLIB_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__ 45# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport) 46# define SHLIB_EXPORTED __declspec(dllexport)
46# else 47# else
47# define DLL_EXPORTED 48# define SHLIB_EXPORTED
48# endif 49# endif
49# endif 50# endif
50 51
@@ -59,7 +60,7 @@ typedef int dummy;
59 because the latter is not guaranteed to be a stable ABI in the future. */ 60 because the latter is not guaranteed to be a stable ABI in the future. */
60 61
61/* Make sure the function gets exported from DLLs. */ 62/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void); 63SHLIB_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
63 64
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT; 65static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock; 66static CRITICAL_SECTION lock;
@@ -96,7 +97,7 @@ gl_get_setlocale_null_lock (void)
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 97static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97 98
98/* Make sure the function gets exported from shared libraries. */ 99/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void); 100SHLIB_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
100 101
101/* Returns the internal lock used by setlocale_null_r. */ 102/* Returns the internal lock used by setlocale_null_r. */
102pthread_mutex_t * 103pthread_mutex_t *
@@ -123,7 +124,7 @@ atomic_init (void)
123} 124}
124 125
125/* Make sure the function gets exported from shared libraries. */ 126/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_setlocale_null_lock (void); 127SHLIB_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
127 128
128/* Returns the internal lock used by setlocale_null_r. */ 129/* Returns the internal lock used by setlocale_null_r. */
129mtx_t * 130mtx_t *
diff --git a/gl/setlocale_null-unlocked.c b/gl/setlocale_null-unlocked.c
new file mode 100644
index 00000000..e7f155c7
--- /dev/null
+++ b/gl/setlocale_null-unlocked.c
@@ -0,0 +1,145 @@
1/* Query the name of the current global locale, without locking.
2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#include <config.h>
20
21/* Specification. */
22#include "setlocale_null.h"
23
24#include <errno.h>
25#include <locale.h>
26#include <string.h>
27#if defined _WIN32 && !defined __CYGWIN__
28# include <wchar.h>
29#endif
30
31/* Use the system's setlocale() function, not the gnulib override, here. */
32#undef setlocale
33
34const char *
35setlocale_null_unlocked (int category)
36{
37 const char *result = setlocale (category, NULL);
38
39#ifdef __ANDROID__
40 if (result == NULL)
41 switch (category)
42 {
43 case LC_CTYPE:
44 case LC_NUMERIC:
45 case LC_TIME:
46 case LC_COLLATE:
47 case LC_MONETARY:
48 case LC_MESSAGES:
49 case LC_ALL:
50 case LC_PAPER:
51 case LC_NAME:
52 case LC_ADDRESS:
53 case LC_TELEPHONE:
54 case LC_MEASUREMENT:
55 result = "C";
56 break;
57 default:
58 break;
59 }
60#endif
61
62 return result;
63}
64
65int
66setlocale_null_r_unlocked (int category, char *buf, size_t bufsize)
67{
68#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER
69 /* On native Windows, nowadays, the setlocale() implementation is based
70 on _wsetlocale() and uses malloc() for the result. We are better off
71 using _wsetlocale() directly. */
72 const wchar_t *result = _wsetlocale (category, NULL);
73
74 if (result == NULL)
75 {
76 /* CATEGORY is invalid. */
77 if (bufsize > 0)
78 /* Return an empty string in BUF.
79 This is a convenience for callers that don't want to write explicit
80 code for handling EINVAL. */
81 buf[0] = '\0';
82 return EINVAL;
83 }
84 else
85 {
86 size_t length = wcslen (result);
87 if (length < bufsize)
88 {
89 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
90 for (size_t i = 0; i <= length; i++)
91 buf[i] = result[i];
92
93 return 0;
94 }
95 else
96 {
97 if (bufsize > 0)
98 {
99 /* Return a truncated result in BUF.
100 This is a convenience for callers that don't want to write
101 explicit code for handling ERANGE. */
102 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
103 for (size_t i = 0; i < bufsize; i++)
104 buf[i] = result[i];
105 buf[bufsize - 1] = '\0';
106 }
107 return ERANGE;
108 }
109 }
110#else
111 const char *result = setlocale_null_unlocked (category);
112
113 if (result == NULL)
114 {
115 /* CATEGORY is invalid. */
116 if (bufsize > 0)
117 /* Return an empty string in BUF.
118 This is a convenience for callers that don't want to write explicit
119 code for handling EINVAL. */
120 buf[0] = '\0';
121 return EINVAL;
122 }
123 else
124 {
125 size_t length = strlen (result);
126 if (length < bufsize)
127 {
128 memcpy (buf, result, length + 1);
129 return 0;
130 }
131 else
132 {
133 if (bufsize > 0)
134 {
135 /* Return a truncated result in BUF.
136 This is a convenience for callers that don't want to write
137 explicit code for handling ERANGE. */
138 memcpy (buf, result, bufsize - 1);
139 buf[bufsize - 1] = '\0';
140 }
141 return ERANGE;
142 }
143 }
144#endif
145}
diff --git a/gl/setlocale_null.c b/gl/setlocale_null.c
index 6ac563db..39b6766c 100644
--- a/gl/setlocale_null.c
+++ b/gl/setlocale_null.c
@@ -1,5 +1,5 @@
1/* Query the name of the current global locale. 1/* Query the name of the current global locale.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc. 2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -25,12 +25,14 @@
25#include <locale.h> 25#include <locale.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28#if defined _WIN32 && !defined __CYGWIN__
29# include <wchar.h>
30#endif
31 28
32#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) 29#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE)
33# if defined _WIN32 && !defined __CYGWIN__ 30
31# if AVOID_ANY_THREADS
32
33/* The option '--disable-threads' explicitly requests no locking. */
34
35# elif defined _WIN32 && !defined __CYGWIN__
34 36
35# define WIN32_LEAN_AND_MEAN /* avoid including junk */ 37# define WIN32_LEAN_AND_MEAN /* avoid including junk */
36# include <windows.h> 38# include <windows.h>
@@ -51,154 +53,39 @@
51# include <threads.h> 53# include <threads.h>
52 54
53# endif 55# endif
54#endif
55
56/* Use the system's setlocale() function, not the gnulib override, here. */
57#undef setlocale
58
59static const char *
60setlocale_null_androidfix (int category)
61{
62 const char *result = setlocale (category, NULL);
63
64#ifdef __ANDROID__
65 if (result == NULL)
66 switch (category)
67 {
68 case LC_CTYPE:
69 case LC_NUMERIC:
70 case LC_TIME:
71 case LC_COLLATE:
72 case LC_MONETARY:
73 case LC_MESSAGES:
74 case LC_ALL:
75 case LC_PAPER:
76 case LC_NAME:
77 case LC_ADDRESS:
78 case LC_TELEPHONE:
79 case LC_MEASUREMENT:
80 result = "C";
81 break;
82 default:
83 break;
84 }
85#endif
86
87 return result;
88}
89
90static int
91setlocale_null_unlocked (int category, char *buf, size_t bufsize)
92{
93#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER
94 /* On native Windows, nowadays, the setlocale() implementation is based
95 on _wsetlocale() and uses malloc() for the result. We are better off
96 using _wsetlocale() directly. */
97 const wchar_t *result = _wsetlocale (category, NULL);
98
99 if (result == NULL)
100 {
101 /* CATEGORY is invalid. */
102 if (bufsize > 0)
103 /* Return an empty string in BUF.
104 This is a convenience for callers that don't want to write explicit
105 code for handling EINVAL. */
106 buf[0] = '\0';
107 return EINVAL;
108 }
109 else
110 {
111 size_t length = wcslen (result);
112 if (length < bufsize)
113 {
114 size_t i;
115 56
116 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
117 for (i = 0; i <= length; i++)
118 buf[i] = result[i];
119
120 return 0;
121 }
122 else
123 {
124 if (bufsize > 0)
125 {
126 /* Return a truncated result in BUF.
127 This is a convenience for callers that don't want to write
128 explicit code for handling ERANGE. */
129 size_t i;
130
131 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
132 for (i = 0; i < bufsize; i++)
133 buf[i] = result[i];
134 buf[bufsize - 1] = '\0';
135 }
136 return ERANGE;
137 }
138 }
139#else
140 const char *result = setlocale_null_androidfix (category);
141
142 if (result == NULL)
143 {
144 /* CATEGORY is invalid. */
145 if (bufsize > 0)
146 /* Return an empty string in BUF.
147 This is a convenience for callers that don't want to write explicit
148 code for handling EINVAL. */
149 buf[0] = '\0';
150 return EINVAL;
151 }
152 else
153 {
154 size_t length = strlen (result);
155 if (length < bufsize)
156 {
157 memcpy (buf, result, length + 1);
158 return 0;
159 }
160 else
161 {
162 if (bufsize > 0)
163 {
164 /* Return a truncated result in BUF.
165 This is a convenience for callers that don't want to write
166 explicit code for handling ERANGE. */
167 memcpy (buf, result, bufsize - 1);
168 buf[bufsize - 1] = '\0';
169 }
170 return ERANGE;
171 }
172 }
173#endif 57#endif
174}
175 58
176#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */ 59#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
177 60
178/* Use a lock, so that no two threads can invoke setlocale_null_unlocked 61/* Use a lock, so that no two threads can invoke setlocale_null_r_unlocked
179 at the same time. */ 62 at the same time. */
180 63
181/* Prohibit renaming this symbol. */ 64/* Prohibit renaming this symbol. */
182# undef gl_get_setlocale_null_lock 65# undef gl_get_setlocale_null_lock
183 66
184# if defined _WIN32 && !defined __CYGWIN__ 67# if AVOID_ANY_THREADS
68
69/* The option '--disable-threads' explicitly requests no locking. */
70# define setlocale_null_r_with_lock setlocale_null_r_unlocked
71
72# elif defined _WIN32 && !defined __CYGWIN__
185 73
186extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void); 74extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
187 75
188static int 76static int
189setlocale_null_with_lock (int category, char *buf, size_t bufsize) 77setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
190{ 78{
191 CRITICAL_SECTION *lock = gl_get_setlocale_null_lock (); 79 CRITICAL_SECTION *lock = gl_get_setlocale_null_lock ();
192 int ret;
193 80
194 EnterCriticalSection (lock); 81 EnterCriticalSection (lock);
195 ret = setlocale_null_unlocked (category, buf, bufsize); 82 int ret = setlocale_null_r_unlocked (category, buf, bufsize);
196 LeaveCriticalSection (lock); 83 LeaveCriticalSection (lock);
197 84
198 return ret; 85 return ret;
199} 86}
200 87
201# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */ 88# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
202 89
203extern 90extern
204# if defined _WIN32 || defined __CYGWIN__ 91# if defined _WIN32 || defined __CYGWIN__
@@ -223,23 +110,22 @@ extern
223# endif 110# endif
224 111
225static int 112static int
226setlocale_null_with_lock (int category, char *buf, size_t bufsize) 113setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
227{ 114{
228 if (pthread_in_use()) 115 if (pthread_in_use())
229 { 116 {
230 pthread_mutex_t *lock = gl_get_setlocale_null_lock (); 117 pthread_mutex_t *lock = gl_get_setlocale_null_lock ();
231 int ret;
232 118
233 if (pthread_mutex_lock (lock)) 119 if (pthread_mutex_lock (lock))
234 abort (); 120 abort ();
235 ret = setlocale_null_unlocked (category, buf, bufsize); 121 int ret = setlocale_null_r_unlocked (category, buf, bufsize);
236 if (pthread_mutex_unlock (lock)) 122 if (pthread_mutex_unlock (lock))
237 abort (); 123 abort ();
238 124
239 return ret; 125 return ret;
240 } 126 }
241 else 127 else
242 return setlocale_null_unlocked (category, buf, bufsize); 128 return setlocale_null_r_unlocked (category, buf, bufsize);
243} 129}
244 130
245# elif HAVE_THREADS_H 131# elif HAVE_THREADS_H
@@ -247,14 +133,13 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize)
247extern mtx_t *gl_get_setlocale_null_lock (void); 133extern mtx_t *gl_get_setlocale_null_lock (void);
248 134
249static int 135static int
250setlocale_null_with_lock (int category, char *buf, size_t bufsize) 136setlocale_null_r_with_lock (int category, char *buf, size_t bufsize)
251{ 137{
252 mtx_t *lock = gl_get_setlocale_null_lock (); 138 mtx_t *lock = gl_get_setlocale_null_lock ();
253 int ret;
254 139
255 if (mtx_lock (lock) != thrd_success) 140 if (mtx_lock (lock) != thrd_success)
256 abort (); 141 abort ();
257 ret = setlocale_null_unlocked (category, buf, bufsize); 142 int ret = setlocale_null_r_unlocked (category, buf, bufsize);
258 if (mtx_unlock (lock) != thrd_success) 143 if (mtx_unlock (lock) != thrd_success)
259 abort (); 144 abort ();
260 145
@@ -271,27 +156,27 @@ setlocale_null_r (int category, char *buf, size_t bufsize)
271#if SETLOCALE_NULL_ALL_MTSAFE 156#if SETLOCALE_NULL_ALL_MTSAFE
272# if SETLOCALE_NULL_ONE_MTSAFE 157# if SETLOCALE_NULL_ONE_MTSAFE
273 158
274 return setlocale_null_unlocked (category, buf, bufsize); 159 return setlocale_null_r_unlocked (category, buf, bufsize);
275 160
276# else 161# else
277 162
278 if (category == LC_ALL) 163 if (category == LC_ALL)
279 return setlocale_null_unlocked (category, buf, bufsize); 164 return setlocale_null_r_unlocked (category, buf, bufsize);
280 else 165 else
281 return setlocale_null_with_lock (category, buf, bufsize); 166 return setlocale_null_r_with_lock (category, buf, bufsize);
282 167
283# endif 168# endif
284#else 169#else
285# if SETLOCALE_NULL_ONE_MTSAFE 170# if SETLOCALE_NULL_ONE_MTSAFE
286 171
287 if (category == LC_ALL) 172 if (category == LC_ALL)
288 return setlocale_null_with_lock (category, buf, bufsize); 173 return setlocale_null_r_with_lock (category, buf, bufsize);
289 else 174 else
290 return setlocale_null_unlocked (category, buf, bufsize); 175 return setlocale_null_r_unlocked (category, buf, bufsize);
291 176
292# else 177# else
293 178
294 return setlocale_null_with_lock (category, buf, bufsize); 179 return setlocale_null_r_with_lock (category, buf, bufsize);
295 180
296# endif 181# endif
297#endif 182#endif
@@ -301,7 +186,7 @@ const char *
301setlocale_null (int category) 186setlocale_null (int category)
302{ 187{
303#if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE 188#if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE
304 return setlocale_null_androidfix (category); 189 return setlocale_null_unlocked (category);
305#else 190#else
306 191
307 /* This call must be multithread-safe. To achieve this without using 192 /* This call must be multithread-safe. To achieve this without using
@@ -317,7 +202,7 @@ setlocale_null (int category)
317 if (category == LC_ALL) 202 if (category == LC_ALL)
318 { 203 {
319# if SETLOCALE_NULL_ALL_MTSAFE 204# if SETLOCALE_NULL_ALL_MTSAFE
320 return setlocale_null_androidfix (LC_ALL); 205 return setlocale_null_unlocked (LC_ALL);
321# else 206# else
322 char buf[SETLOCALE_NULL_ALL_MAX]; 207 char buf[SETLOCALE_NULL_ALL_MAX];
323 static char resultbuf[SETLOCALE_NULL_ALL_MAX]; 208 static char resultbuf[SETLOCALE_NULL_ALL_MAX];
@@ -331,7 +216,7 @@ setlocale_null (int category)
331 else 216 else
332 { 217 {
333# if SETLOCALE_NULL_ONE_MTSAFE 218# if SETLOCALE_NULL_ONE_MTSAFE
334 return setlocale_null_androidfix (category); 219 return setlocale_null_unlocked (category);
335# else 220# else
336 enum 221 enum
337 { 222 {
@@ -364,9 +249,7 @@ setlocale_null (int category)
364 i; 249 i;
365 char buf[SETLOCALE_NULL_MAX]; 250 char buf[SETLOCALE_NULL_MAX];
366 static char resultbuf[LC_INDICES_COUNT][SETLOCALE_NULL_MAX]; 251 static char resultbuf[LC_INDICES_COUNT][SETLOCALE_NULL_MAX];
367 int err; 252 int err = setlocale_null_r (category, buf, sizeof (buf));
368
369 err = setlocale_null_r (category, buf, sizeof (buf));
370 if (err == EINVAL) 253 if (err == EINVAL)
371 return NULL; 254 return NULL;
372 if (err) 255 if (err)
diff --git a/gl/setlocale_null.h b/gl/setlocale_null.h
index c740fa0f..dbd646b3 100644
--- a/gl/setlocale_null.h
+++ b/gl/setlocale_null.h
@@ -1,5 +1,5 @@
1/* Query the name of the current global locale. 1/* Query the name of the current global locale.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc. 2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -44,6 +44,34 @@ extern "C" {
44 55+5*58. */ 44 55+5*58. */
45#define SETLOCALE_NULL_ALL_MAX (148+12*256+1) 45#define SETLOCALE_NULL_ALL_MAX (148+12*256+1)
46 46
47/* setlocale_null_r_unlocked (CATEGORY, BUF, BUFSIZE) is like
48 setlocale (CATEGORY, NULL), except that
49 - it returns the resulting locale category name or locale name in the
50 user-supplied buffer BUF, which must be BUFSIZE bytes long.
51 The recommended minimum buffer size is
52 - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and
53 - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL.
54 The return value is an error code: 0 if the call is successful, EINVAL if
55 CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed
56 size (including the trailing NUL byte). In the latter case, a truncated
57 result is returned in BUF, but still NUL-terminated if BUFSIZE > 0.
58 This call is guaranteed to be multithread-safe only if
59 - CATEGORY != LC_ALL and SETLOCALE_NULL_ONE_MTSAFE is true, or
60 - CATEGORY == LC_ALL and SETLOCALE_NULL_ALL_MTSAFE is true,
61 and the other threads must not make other setlocale invocations (since
62 changing the global locale has side effects on all threads). */
63extern int setlocale_null_r_unlocked (int category, char *buf, size_t bufsize)
64 _GL_ARG_NONNULL ((2));
65
66/* setlocale_null_unlocked (CATEGORY) is like setlocale (CATEGORY, NULL).
67 The return value is NULL if CATEGORY is invalid.
68 This call is guaranteed to be multithread-safe only if
69 - CATEGORY != LC_ALL and SETLOCALE_NULL_ONE_MTSAFE is true, or
70 - CATEGORY == LC_ALL and SETLOCALE_NULL_ALL_MTSAFE is true,
71 and the other threads must not make other setlocale invocations (since
72 changing the global locale has side effects on all threads). */
73extern const char *setlocale_null_unlocked (int category);
74
47/* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL), 75/* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
48 except that 76 except that
49 - it is guaranteed to be multithread-safe, 77 - it is guaranteed to be multithread-safe,
diff --git a/gl/sha256-stream.c b/gl/sha256-stream.c
index 0e83380a..011b36e2 100644
--- a/gl/sha256-stream.c
+++ b/gl/sha256-stream.c
@@ -1,7 +1,7 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or 1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2. 2 memory blocks according to the NIST specification FIPS-180-2.
3 3
4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 4 Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
@@ -23,9 +23,6 @@
23#include <config.h> 23#include <config.h>
24 24
25/* Specification. */ 25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h" 26#include "sha256.h"
30 27
31#include <stdlib.h> 28#include <stdlib.h>
@@ -70,7 +67,6 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
70 /* We read the file in blocks of BLOCKSIZE bytes. One call of the 67 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
71 computation function processes the whole buffer so that with the 68 computation function processes the whole buffer so that with the
72 next round of the loop another block can be read. */ 69 next round of the loop another block can be read. */
73 size_t n;
74 sum = 0; 70 sum = 0;
75 71
76 /* Read block. Take care for partial reads. */ 72 /* Read block. Take care for partial reads. */
@@ -80,11 +76,11 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
80 or the fread() in afalg_stream may have gotten EOF. 76 or the fread() in afalg_stream may have gotten EOF.
81 We need to avoid a subsequent fread() as EOF may 77 We need to avoid a subsequent fread() as EOF may
82 not be sticky. For details of such systems, see: 78 not be sticky. For details of such systems, see:
83 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */ 79 https://sourceware.org/PR1190 */
84 if (feof (stream)) 80 if (feof (stream))
85 goto process_partial_block; 81 goto process_partial_block;
86 82
87 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); 83 size_t n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
88 84
89 sum += n; 85 sum += n;
90 86
@@ -136,10 +132,3 @@ sha224_stream (FILE *stream, void *resblock)
136 return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE, 132 return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE,
137 sha224_init_ctx, sha224_finish_ctx); 133 sha224_init_ctx, sha224_finish_ctx);
138} 134}
139
140/*
141 * Hey Emacs!
142 * Local Variables:
143 * coding: utf-8
144 * End:
145 */
diff --git a/gl/sha256.c b/gl/sha256.c
index e5fea02b..bada2d07 100644
--- a/gl/sha256.c
+++ b/gl/sha256.c
@@ -1,7 +1,7 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or 1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2. 2 memory blocks according to the NIST specification FIPS-180-2.
3 3
4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 4 Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
@@ -96,10 +96,9 @@ set_uint32 (char *cp, uint32_t v)
96void * 96void *
97sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) 97sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
98{ 98{
99 int i;
100 char *r = resbuf; 99 char *r = resbuf;
101 100
102 for (i = 0; i < 8; i++) 101 for (int i = 0; i < 8; i++)
103 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); 102 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
104 103
105 return resbuf; 104 return resbuf;
@@ -108,10 +107,9 @@ sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
108void * 107void *
109sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf) 108sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
110{ 109{
111 int i;
112 char *r = resbuf; 110 char *r = resbuf;
113 111
114 for (i = 0; i < 7; i++) 112 for (int i = 0; i < 7; i++)
115 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i])); 113 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
116 114
117 return resbuf; 115 return resbuf;
@@ -326,8 +324,8 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
326 + S0(x[(I-15)&0x0f]) + x[I&0x0f] \ 324 + S0(x[(I-15)&0x0f]) + x[I&0x0f] \
327 , x[I&0x0f] = tm ) 325 , x[I&0x0f] = tm )
328 326
329#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \ 327#define R(A,B,C,D,E,F,G,H,K,M) do { uint32_t t0 = SS0(A) + F2(A,B,C); \
330 t1 = H + SS1(E) \ 328 uint32_t t1 = H + SS1(E) \
331 + F1(E,F,G) \ 329 + F1(E,F,G) \
332 + K \ 330 + K \
333 + M; \ 331 + M; \
@@ -336,16 +334,15 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
336 334
337 while (words < endp) 335 while (words < endp)
338 { 336 {
339 uint32_t tm;
340 uint32_t t0, t1;
341 int t;
342 /* FIXME: see sha1.c for a better implementation. */ 337 /* FIXME: see sha1.c for a better implementation. */
343 for (t = 0; t < 16; t++) 338 for (int t = 0; t < 16; t++)
344 { 339 {
345 x[t] = SWAP (*words); 340 x[t] = SWAP (*words);
346 words++; 341 words++;
347 } 342 }
348 343
344 uint32_t tm;
345
349 R( a, b, c, d, e, f, g, h, K( 0), x[ 0] ); 346 R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
350 R( h, a, b, c, d, e, f, g, K( 1), x[ 1] ); 347 R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
351 R( g, h, a, b, c, d, e, f, K( 2), x[ 2] ); 348 R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
diff --git a/gl/sha256.h b/gl/sha256.h
index 2879477e..db80ea5e 100644
--- a/gl/sha256.h
+++ b/gl/sha256.h
@@ -1,6 +1,6 @@
1/* Declarations of functions and data types used for SHA256 and SHA224 sum 1/* Declarations of functions and data types used for SHA256 and SHA224 sum
2 library functions. 2 library functions.
3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -18,6 +18,11 @@
18#ifndef SHA256_H 18#ifndef SHA256_H
19# define SHA256_H 1 19# define SHA256_H 1
20 20
21/* This file uses HAVE_OPENSSL_SHA256. */
22# if !_GL_CONFIG_H_INCLUDED
23# error "Please include config.h first."
24# endif
25
21# include <stdio.h> 26# include <stdio.h>
22# include <stdint.h> 27# include <stdint.h>
23 28
@@ -25,7 +30,21 @@
25# ifndef OPENSSL_API_COMPAT 30# ifndef OPENSSL_API_COMPAT
26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ 31# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
27# endif 32# endif
28# include <openssl/sha.h> 33/* If <openssl/macros.h> would give a compile-time error, don't use OpenSSL. */
34# include <openssl/opensslv.h>
35# if OPENSSL_VERSION_MAJOR >= 3
36# include <openssl/configuration.h>
37# if (OPENSSL_CONFIGURED_API \
38 < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
39 ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
40 + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
41 + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
42# undef HAVE_OPENSSL_SHA256
43# endif
44# endif
45# if HAVE_OPENSSL_SHA256
46# include <openssl/sha.h>
47# endif
29# endif 48# endif
30 49
31# ifdef __cplusplus 50# ifdef __cplusplus
diff --git a/gl/size_max.h b/gl/size_max.h
index 48af0250..b627e5ff 100644
--- a/gl/size_max.h
+++ b/gl/size_max.h
@@ -1,5 +1,5 @@
1/* size_max.h -- declare SIZE_MAX through system headers 1/* size_max.h -- declare SIZE_MAX through system headers
2 Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2006, 2009-2026 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -18,6 +18,11 @@
18#ifndef GNULIB_SIZE_MAX_H 18#ifndef GNULIB_SIZE_MAX_H
19#define GNULIB_SIZE_MAX_H 19#define GNULIB_SIZE_MAX_H
20 20
21/* This file uses HAVE_STDINT_H. */
22#if !_GL_CONFIG_H_INCLUDED
23 #error "Please include config.h first."
24#endif
25
21/* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */ 26/* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */
22# include <limits.h> 27# include <limits.h>
23/* Get SIZE_MAX declaration on systems like glibc 2. */ 28/* Get SIZE_MAX declaration on systems like glibc 2. */
diff --git a/gl/snprintf.c b/gl/snprintf.c
index cdff3149..58ad5d7a 100644
--- a/gl/snprintf.c
+++ b/gl/snprintf.c
@@ -1,6 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2026 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Paul Eggert.
4 3
5 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -23,49 +22,23 @@
23#include <errno.h> 22#include <errno.h>
24#include <limits.h> 23#include <limits.h>
25#include <stdarg.h> 24#include <stdarg.h>
26#include <stdlib.h> 25#include <stdint.h>
27#include <string.h>
28 26
29#include "vasnprintf.h"
30
31/* Print formatted output to string STR. Similar to sprintf, but
32 additional length SIZE limit how much is written into STR. Returns
33 string length of formatted string (which may be larger than SIZE).
34 STR may be NULL, in which case nothing will be written. On error,
35 return a negative value. */
36int 27int
37snprintf (char *str, size_t size, const char *format, ...) 28snprintf (char *str, size_t size, const char *format, ...)
38{ 29{
39 char *output;
40 size_t len;
41 size_t lenbuf = size;
42 va_list args; 30 va_list args;
43
44 va_start (args, format); 31 va_start (args, format);
45 output = vasnprintf (str, &lenbuf, format, args); 32 ptrdiff_t ret = vsnzprintf (str, size, format, args);
46 len = lenbuf;
47 va_end (args); 33 va_end (args);
48 34
49 if (!output) 35#if PTRDIFF_MAX > INT_MAX
50 return -1; 36 if (ret > INT_MAX)
51
52 if (output != str)
53 {
54 if (size)
55 {
56 size_t pruned_len = (len < size ? len : size - 1);
57 memcpy (str, output, pruned_len);
58 str[pruned_len] = '\0';
59 }
60
61 free (output);
62 }
63
64 if (INT_MAX < len)
65 { 37 {
66 errno = EOVERFLOW; 38 errno = EOVERFLOW;
67 return -1; 39 return -1;
68 } 40 }
41#endif
69 42
70 return len; 43 return ret;
71} 44}
diff --git a/gl/sockets.c b/gl/sockets.c
index ca99db8b..ce98698d 100644
--- a/gl/sockets.c
+++ b/gl/sockets.c
@@ -1,6 +1,6 @@
1/* sockets.c --- wrappers for Windows socket functions 1/* sockets.c --- wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -46,11 +46,10 @@ close_fd_maybe_socket (const struct fd_hook *remaining_list,
46 our calls to closesocket() and the primary close(), some other thread 46 our calls to closesocket() and the primary close(), some other thread
47 could make system calls that allocate precisely the same HANDLE value 47 could make system calls that allocate precisely the same HANDLE value
48 as sock; then the primary close() would call CloseHandle() on it. */ 48 as sock; then the primary close() would call CloseHandle() on it. */
49 SOCKET sock;
50 WSANETWORKEVENTS ev;
51 49
52 /* Test whether fd refers to a socket. */ 50 /* Test whether fd refers to a socket. */
53 sock = FD_TO_SOCKET (fd); 51 SOCKET sock = FD_TO_SOCKET (fd);
52 WSANETWORKEVENTS ev;
54 ev.lNetworkEvents = 0xDEADBEEF; 53 ev.lNetworkEvents = 0xDEADBEEF;
55 WSAEnumNetworkEvents (sock, NULL, &ev); 54 WSAEnumNetworkEvents (sock, NULL, &ev);
56 if (ev.lNetworkEvents != 0xDEADBEEF) 55 if (ev.lNetworkEvents != 0xDEADBEEF)
@@ -83,11 +82,9 @@ ioctl_fd_maybe_socket (const struct fd_hook *remaining_list,
83 gl_ioctl_fn primary, 82 gl_ioctl_fn primary,
84 int fd, int request, void *arg) 83 int fd, int request, void *arg)
85{ 84{
86 SOCKET sock;
87 WSANETWORKEVENTS ev;
88
89 /* Test whether fd refers to a socket. */ 85 /* Test whether fd refers to a socket. */
90 sock = FD_TO_SOCKET (fd); 86 SOCKET sock = FD_TO_SOCKET (fd);
87 WSANETWORKEVENTS ev;
91 ev.lNetworkEvents = 0xDEADBEEF; 88 ev.lNetworkEvents = 0xDEADBEEF;
92 WSAEnumNetworkEvents (sock, NULL, &ev); 89 WSAEnumNetworkEvents (sock, NULL, &ev);
93 if (ev.lNetworkEvents != 0xDEADBEEF) 90 if (ev.lNetworkEvents != 0xDEADBEEF)
@@ -119,9 +116,7 @@ gl_sockets_startup (_GL_UNUSED int version)
119 if (version > initialized_sockets_version) 116 if (version > initialized_sockets_version)
120 { 117 {
121 WSADATA data; 118 WSADATA data;
122 int err; 119 int err = WSAStartup (version, &data);
123
124 err = WSAStartup (version, &data);
125 if (err != 0) 120 if (err != 0)
126 return 1; 121 return 1;
127 122
@@ -146,13 +141,11 @@ int
146gl_sockets_cleanup (void) 141gl_sockets_cleanup (void)
147{ 142{
148#if WINDOWS_SOCKETS 143#if WINDOWS_SOCKETS
149 int err;
150
151 initialized_sockets_version = 0; 144 initialized_sockets_version = 0;
152 145
153 unregister_fd_hook (&fd_sockets_hook); 146 unregister_fd_hook (&fd_sockets_hook);
154 147
155 err = WSACleanup (); 148 int err = WSACleanup ();
156 if (err != 0) 149 if (err != 0)
157 return 1; 150 return 1;
158#endif 151#endif
diff --git a/gl/sockets.h b/gl/sockets.h
index a0b1601d..ed12cf9a 100644
--- a/gl/sockets.h
+++ b/gl/sockets.h
@@ -1,6 +1,6 @@
1/* sockets.h - wrappers for Windows socket functions 1/* sockets.h - wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,6 +20,15 @@
20#ifndef SOCKETS_H 20#ifndef SOCKETS_H
21#define SOCKETS_H 1 21#define SOCKETS_H 1
22 22
23/* This file uses _GL_ATTRIBUTE_CONST. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
23#define SOCKETS_1_0 0x0001 32#define SOCKETS_1_0 0x0001
24#define SOCKETS_1_1 0x0101 33#define SOCKETS_1_1 0x0101
25#define SOCKETS_2_0 0x0002 34#define SOCKETS_2_0 0x0002
@@ -38,7 +47,12 @@ int gl_sockets_cleanup (void)
38#endif 47#endif
39 ; 48 ;
40 49
41/* This function is useful it you create a socket using gnulib's 50#ifdef __cplusplus
51}
52#endif
53
54
55/* This function is useful if you create a socket using gnulib's
42 Winsock wrappers but needs to pass on the socket handle to some 56 Winsock wrappers but needs to pass on the socket handle to some
43 other library that only accepts sockets. */ 57 other library that only accepts sockets. */
44#ifdef WINDOWS_SOCKETS 58#ifdef WINDOWS_SOCKETS
diff --git a/gl/stat-time.c b/gl/stat-time.c
index bc282232..9dcdc377 100644
--- a/gl/stat-time.c
+++ b/gl/stat-time.c
@@ -1,6 +1,6 @@
1/* stat-related time functions. 1/* stat-related time functions.
2 2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc. 3 Copyright (C) 2012-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,7 +15,6 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h>
19
20#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE 18#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
19#include <config.h>
21#include "stat-time.h" 20#include "stat-time.h"
diff --git a/gl/stat-time.h b/gl/stat-time.h
index 92aa1e64..45364316 100644
--- a/gl/stat-time.h
+++ b/gl/stat-time.h
@@ -1,6 +1,6 @@
1/* stat-related time functions. 1/* stat-related time functions.
2 2
3 Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005, 2007, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,15 +20,18 @@
20#ifndef STAT_TIME_H 20#ifndef STAT_TIME_H
21#define STAT_TIME_H 1 21#define STAT_TIME_H 1
22 22
23/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNUSED,
24 _GL_ATTRIBUTE_PURE, HAVE_STRUCT_STAT_*. */
25#if !_GL_CONFIG_H_INCLUDED
26 #error "Please include config.h first."
27#endif
28
23#include <errno.h> 29#include <errno.h>
24#include <stdckdint.h> 30#include <stdckdint.h>
25#include <stddef.h> 31#include <stddef.h>
26#include <sys/stat.h> 32#include <sys/stat.h>
27#include <time.h> 33#include <time.h>
28 34
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
32_GL_INLINE_HEADER_BEGIN 35_GL_INLINE_HEADER_BEGIN
33#ifndef _GL_STAT_TIME_INLINE 36#ifndef _GL_STAT_TIME_INLINE
34# define _GL_STAT_TIME_INLINE _GL_INLINE 37# define _GL_STAT_TIME_INLINE _GL_INLINE
@@ -49,11 +52,13 @@ extern "C" {
49#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 52#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
50# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 53# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
51# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) 54# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
55# define STAT_TIMESPEC_OFFSETOF(st_xtim) offsetof (struct stat, st_xtim)
52# else 56# else
53# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) 57# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
54# endif 58# endif
55#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 59#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
56# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec) 60# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
61# define STAT_TIMESPEC_OFFSETOF(st_xtim) offsetof (struct stat, st_xtim##espec)
57#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC 62#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
58# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec) 63# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
59#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC 64#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
@@ -112,6 +117,31 @@ get_stat_birthtime_ns (_GL_UNUSED struct stat const *st)
112# endif 117# endif
113} 118}
114 119
120/* Constructs a 'struct timespec' with the given contents.
121 This macro / function is private to stat-time.h. */
122#if !defined __cplusplus
123/* Use a C99 compound literal.
124 This is guaranteed to initialize also the padding bits, for example on
125 platforms where tv_sec is 64 bits and tv_nsec is 32 bits, thus avoiding
126 gcc -Wuse-of-uninitialized-value warnings. */
127# define _gl_make_timespec(sec,nsec) \
128 (struct timespec) { .tv_sec = (sec), .tv_nsec = (nsec) }
129#else
130/* C++ does not have C99 compound literals.
131 A constructor invocation
132 timespec { (sec), (nsec) }
133 would make assumptions about the order of the fields of 'struct timespec',
134 which are not guaranteed by POSIX. So, use an inline function. */
135static inline struct timespec
136_gl_make_timespec (time_t sec, long nsec)
137{
138 struct timespec ts;
139 ts.tv_sec = sec;
140 ts.tv_nsec = nsec;
141 return ts;
142}
143#endif
144
115/* Return *ST's access time. */ 145/* Return *ST's access time. */
116_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE 146_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
117get_stat_atime (struct stat const *st) 147get_stat_atime (struct stat const *st)
@@ -119,10 +149,7 @@ get_stat_atime (struct stat const *st)
119#ifdef STAT_TIMESPEC 149#ifdef STAT_TIMESPEC
120 return STAT_TIMESPEC (st, st_atim); 150 return STAT_TIMESPEC (st, st_atim);
121#else 151#else
122 struct timespec t; 152 return _gl_make_timespec (st->st_atime, get_stat_atime_ns (st));
123 t.tv_sec = st->st_atime;
124 t.tv_nsec = get_stat_atime_ns (st);
125 return t;
126#endif 153#endif
127} 154}
128 155
@@ -133,10 +160,7 @@ get_stat_ctime (struct stat const *st)
133#ifdef STAT_TIMESPEC 160#ifdef STAT_TIMESPEC
134 return STAT_TIMESPEC (st, st_ctim); 161 return STAT_TIMESPEC (st, st_ctim);
135#else 162#else
136 struct timespec t; 163 return _gl_make_timespec (st->st_ctime, get_stat_ctime_ns (st));
137 t.tv_sec = st->st_ctime;
138 t.tv_nsec = get_stat_ctime_ns (st);
139 return t;
140#endif 164#endif
141} 165}
142 166
@@ -147,10 +171,7 @@ get_stat_mtime (struct stat const *st)
147#ifdef STAT_TIMESPEC 171#ifdef STAT_TIMESPEC
148 return STAT_TIMESPEC (st, st_mtim); 172 return STAT_TIMESPEC (st, st_mtim);
149#else 173#else
150 struct timespec t; 174 return _gl_make_timespec (st->st_mtime, get_stat_mtime_ns (st));
151 t.tv_sec = st->st_mtime;
152 t.tv_nsec = get_stat_mtime_ns (st);
153 return t;
154#endif 175#endif
155} 176}
156 177
@@ -165,8 +186,7 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
165 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) 186 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
166 t = STAT_TIMESPEC (st, st_birthtim); 187 t = STAT_TIMESPEC (st, st_birthtim);
167#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 188#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
168 t.tv_sec = st->st_birthtime; 189 t = _gl_make_timespec (st->st_birthtime, st->st_birthtimensec);
169 t.tv_nsec = st->st_birthtimensec;
170#elif defined _WIN32 && ! defined __CYGWIN__ 190#elif defined _WIN32 && ! defined __CYGWIN__
171 /* Native Windows platforms (but not Cygwin) put the "file creation 191 /* Native Windows platforms (but not Cygwin) put the "file creation
172 time" in st_ctime (!). See 192 time" in st_ctime (!). See
@@ -174,13 +194,11 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
174# if _GL_WINDOWS_STAT_TIMESPEC 194# if _GL_WINDOWS_STAT_TIMESPEC
175 t = st->st_ctim; 195 t = st->st_ctim;
176# else 196# else
177 t.tv_sec = st->st_ctime; 197 t = _gl_make_timespec (st->st_ctime, 0);
178 t.tv_nsec = 0;
179# endif 198# endif
180#else 199#else
181 /* Birth time is not supported. */ 200 /* Birth time is not supported. */
182 t.tv_sec = -1; 201 t = _gl_make_timespec (-1, -1);
183 t.tv_nsec = -1;
184#endif 202#endif
185 203
186#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ 204#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
@@ -192,32 +210,29 @@ get_stat_birthtime (_GL_UNUSED struct stat const *st)
192 sometimes returns junk in the birth time fields; work around this 210 sometimes returns junk in the birth time fields; work around this
193 bug if it is detected. */ 211 bug if it is detected. */
194 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) 212 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
195 { 213 t = _gl_make_timespec (-1, -1);
196 t.tv_sec = -1;
197 t.tv_nsec = -1;
198 }
199#endif 214#endif
200 215
201 return t; 216 return t;
202} 217}
203 218
204/* If a stat-like function returned RESULT, normalize the timestamps 219/* If a stat-like function returned RESULT, normalize the timestamps
205 in *ST, in case this platform suffers from the Solaris 11 bug where 220 in *ST, if this platform suffers from a macOS and Solaris bug where
206 tv_nsec might be negative. Return the adjusted RESULT, setting 221 tv_nsec might be negative. Return the adjusted RESULT, setting
207 errno to EOVERFLOW if normalization overflowed. This function 222 errno to EOVERFLOW if normalization overflowed. This function
208 is intended to be private to this .h file. */ 223 is intended to be private to this .h file. */
209_GL_STAT_TIME_INLINE int 224_GL_STAT_TIME_INLINE int
210stat_time_normalize (int result, _GL_UNUSED struct stat *st) 225stat_time_normalize (int result, _GL_UNUSED struct stat *st)
211{ 226{
212#if defined __sun && defined STAT_TIMESPEC 227#if (((defined __APPLE__ && defined __MACH__) || defined __sun) \
228 && defined STAT_TIMESPEC_OFFSETOF)
213 if (result == 0) 229 if (result == 0)
214 { 230 {
215 long int timespec_hz = 1000000000; 231 long int timespec_hz = 1000000000;
216 short int const ts_off[] = { offsetof (struct stat, st_atim), 232 short int const ts_off[] = { STAT_TIMESPEC_OFFSETOF (st_atim),
217 offsetof (struct stat, st_mtim), 233 STAT_TIMESPEC_OFFSETOF (st_mtim),
218 offsetof (struct stat, st_ctim) }; 234 STAT_TIMESPEC_OFFSETOF (st_ctim) };
219 int i; 235 for (int i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
220 for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
221 { 236 {
222 struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); 237 struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
223 long int q = ts->tv_nsec / timespec_hz; 238 long int q = ts->tv_nsec / timespec_hz;
@@ -229,8 +244,7 @@ stat_time_normalize (int result, _GL_UNUSED struct stat *st)
229 } 244 }
230 ts->tv_nsec = r; 245 ts->tv_nsec = r;
231 /* Overflow is possible, as Solaris 11 stat can yield 246 /* Overflow is possible, as Solaris 11 stat can yield
232 tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. 247 tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. */
233 INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
234 if (ckd_add (&ts->tv_sec, q, ts->tv_sec)) 248 if (ckd_add (&ts->tv_sec, q, ts->tv_sec))
235 { 249 {
236 errno = EOVERFLOW; 250 errno = EOVERFLOW;
diff --git a/gl/stat-w32.c b/gl/stat-w32.c
index 2f011975..583ef09b 100644
--- a/gl/stat-w32.c
+++ b/gl/stat-w32.c
@@ -1,5 +1,5 @@
1/* Core of implementation of fstat and stat for native Windows. 1/* Core of implementation of fstat and stat for native Windows.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -112,11 +112,11 @@ initialize (void)
112struct timespec 112struct timespec
113_gl_convert_FILETIME_to_timespec (const FILETIME *ft) 113_gl_convert_FILETIME_to_timespec (const FILETIME *ft)
114{ 114{
115 struct timespec result;
116 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */ 115 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */
117 unsigned long long since_1601 = 116 unsigned long long since_1601 =
118 ((unsigned long long) ft->dwHighDateTime << 32) 117 ((unsigned long long) ft->dwHighDateTime << 32)
119 | (unsigned long long) ft->dwLowDateTime; 118 | (unsigned long long) ft->dwLowDateTime;
119 struct timespec result;
120 if (since_1601 == 0) 120 if (since_1601 == 0)
121 { 121 {
122 result.tv_sec = 0; 122 result.tv_sec = 0;
@@ -289,8 +289,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
289 && (path = fpath, 1))) 289 && (path = fpath, 1)))
290 { 290 {
291 const char *last_dot = NULL; 291 const char *last_dot = NULL;
292 const char *p; 292 for (const char *p = path; *p != '\0'; p++)
293 for (p = path; *p != '\0'; p++)
294 if (*p == '.') 293 if (*p == '.')
295 last_dot = p; 294 last_dot = p;
296 if (last_dot != NULL) 295 if (last_dot != NULL)
diff --git a/gl/stat-w32.h b/gl/stat-w32.h
index c6738749..f5cc82f4 100644
--- a/gl/stat-w32.h
+++ b/gl/stat-w32.h
@@ -1,5 +1,5 @@
1/* Core of implementation of fstat and stat for native Windows. 1/* Core of implementation of fstat and stat for native Windows.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc. 2 Copyright (C) 2017-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/stat.c b/gl/stat.c
index 7987e265..da6a9862 100644
--- a/gl/stat.c
+++ b/gl/stat.c
@@ -1,5 +1,5 @@
1/* Work around platform bugs in stat. 1/* Work around platform bugs in stat.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -42,14 +42,7 @@ orig_stat (const char *filename, struct stat *buf)
42#endif 42#endif
43 43
44/* Specification. */ 44/* Specification. */
45#ifdef __osf__ 45#include <sys/stat.h>
46/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
47 eliminates this include because of the preliminary #include <sys/stat.h>
48 above. */
49# include "sys/stat.h"
50#else
51# include <sys/stat.h>
52#endif
53 46
54#include "stat-time.h" 47#include "stat-time.h"
55 48
@@ -118,6 +111,10 @@ rpl_stat (char const *name, struct stat *buf)
118 around length limitations 111 around length limitations
119 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file> ? */ 112 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file> ? */
120 113
114 /* To ease portability. Like in open.c. */
115 if (streq (name, "/dev/null"))
116 name = "NUL";
117
121 /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13> 118 /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
122 specifies: "More than two leading <slash> characters shall be treated as 119 specifies: "More than two leading <slash> characters shall be treated as
123 a single <slash> character." */ 120 a single <slash> character." */
@@ -290,8 +287,7 @@ rpl_stat (char const *name, struct stat *buf)
290 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0) 287 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
291 { 288 {
292 const char *last_dot = NULL; 289 const char *last_dot = NULL;
293 const char *p; 290 for (const char *p = info.cFileName; *p != '\0'; p++)
294 for (p = info.cFileName; *p != '\0'; p++)
295 if (*p == '.') 291 if (*p == '.')
296 last_dot = p; 292 last_dot = p;
297 if (last_dot != NULL) 293 if (last_dot != NULL)
diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h
deleted file mode 100644
index 7f9dbb46..00000000
--- a/gl/stdalign.in.h
+++ /dev/null
@@ -1,137 +0,0 @@
1/* A substitute for ISO C11 <stdalign.h>.
2
3 Copyright 2011-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert and Bruno Haible. */
19
20#ifndef _GL_STDALIGN_H
21#define _GL_STDALIGN_H
22
23/* ISO C11 <stdalign.h> for platforms that lack it.
24
25 References:
26 ISO C11 (latest free draft
27 <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
28 sections 6.5.3.4, 6.7.5, 7.15.
29 C++11 (latest free draft
30 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
31 section 18.10. */
32
33/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
34 requirement of a structure member (i.e., slot or field) that is of
35 type TYPE, as an integer constant expression.
36
37 This differs from GCC's and clang's __alignof__ operator, which can
38 yield a better-performing alignment for an object of that type. For
39 example, on x86 with GCC and on Linux/x86 with clang,
40 __alignof__ (double) and __alignof__ (long long) are 8, whereas
41 alignof (double) and alignof (long long) are 4 unless the option
42 '-malign-double' is used.
43
44 The result cannot be used as a value for an 'enum' constant, if you
45 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
46
47/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
48 standard headers, defines conflicting implementations of _Alignas
49 and _Alignof that are no better than ours; override them. */
50#undef _Alignas
51#undef _Alignof
52
53/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
54 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
55 clang versions < 8.0.0 have the same bug. */
56#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
57 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
58 && !defined __clang__) \
59 || (defined __clang__ && __clang_major__ < 8))
60# ifdef __cplusplus
61# if (201103 <= __cplusplus || defined _MSC_VER)
62# define _Alignof(type) alignof (type)
63# else
64 template <class __t> struct __alignof_helper { char __a; __t __b; };
65# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
66# define _GL_STDALIGN_NEEDS_STDDEF 1
67# endif
68# else
69# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
70# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
71# else
72# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
73# define _GL_STDALIGN_NEEDS_STDDEF 1
74# endif
75# endif
76#endif
77#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
78# define alignof _Alignof
79#endif
80#define __alignof_is_defined 1
81
82/* alignas (A), also known as _Alignas (A), aligns a variable or type
83 to the alignment A, where A is an integer constant expression. For
84 example:
85
86 int alignas (8) foo;
87 struct s { int a; int alignas (8) bar; };
88
89 aligns the address of FOO and the offset of BAR to be multiples of 8.
90
91 A should be a power of two that is at least the type's alignment
92 and at most the implementation's alignment limit. This limit is
93 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
94 to MSVC through at least version 10.0, A should be an integer
95 constant, as MSVC does not support expressions such as 1 << 3.
96 To be portable to Sun C 5.11, do not align auto variables to
97 anything stricter than their default alignment.
98
99 The following C11 requirements are not supported here:
100
101 - If A is zero, alignas has no effect.
102 - alignas can be used multiple times; the strictest one wins.
103 - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
104
105 */
106
107#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
108# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
109# define _Alignas(a) alignas (a)
110# elif (!defined __attribute__ \
111 && ((defined __APPLE__ && defined __MACH__ \
112 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
113 : __GNUC__ && !defined __ibmxl__) \
114 || (4 <= __clang_major__) \
115 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
116 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
117# define _Alignas(a) __attribute__ ((__aligned__ (a)))
118# elif 1300 <= _MSC_VER
119# define _Alignas(a) __declspec (align (a))
120# endif
121#endif
122#if ((defined _Alignas \
123 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
124 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
125# define alignas _Alignas
126#endif
127#if (defined alignas \
128 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
129# define __alignas_is_defined 1
130#endif
131
132/* Include <stddef.h> if needed for offsetof. */
133#if _GL_STDALIGN_NEEDS_STDDEF
134# include <stddef.h>
135#endif
136
137#endif /* _GL_STDALIGN_H */
diff --git a/gl/stdckdint.in.h b/gl/stdckdint.in.h
index 71bab5f0..ac12fd6c 100644
--- a/gl/stdckdint.in.h
+++ b/gl/stdckdint.in.h
@@ -1,6 +1,6 @@
1/* stdckdint.h -- checked integer arithmetic 1/* stdckdint.h -- checked integer arithmetic
2 2
3 Copyright 2022-2023 Free Software Foundation, Inc. 3 Copyright 2022-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published 6 under the terms of the GNU Lesser General Public License as published
@@ -15,10 +15,30 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _GL_STDCKDINT_H 18#if __GNUC__ >= 3
19#define _GL_STDCKDINT_H 19@PRAGMA_SYSTEM_HEADER@
20#endif
21@PRAGMA_COLUMNS@
20 22
21#include "intprops-internal.h" 23#ifndef _@GUARD_PREFIX@_STDCKDINT_H
24
25/* The include_next requires a split double-inclusion guard. */
26#if defined __cplusplus ? @HAVE_CXX_STDCKDINT_H@ : @HAVE_C_STDCKDINT_H@
27# @INCLUDE_NEXT@ @NEXT_STDCKDINT_H@
28#endif
29
30#ifndef _@GUARD_PREFIX@_STDCKDINT_H
31#define _@GUARD_PREFIX@_STDCKDINT_H
32
33/* Do nothing but include the system header if it works properly. */
34# if defined __cplusplus ? !@HAVE_WORKING_CXX_STDCKDINT_H@ : !@HAVE_WORKING_C_STDCKDINT_H@
35
36/* Avoid redefining macros. */
37# undef ckd_add
38# undef ckd_sub
39# undef ckd_mul
40
41# include "intprops-internal.h"
22 42
23/* Store into *R the low-order bits of A + B, A - B, A * B, respectively. 43/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
24 Return 1 if the result overflows, 0 otherwise. 44 Return 1 if the result overflows, 0 otherwise.
@@ -26,10 +46,13 @@
26 bit-precise integer type, or an enumeration type. 46 bit-precise integer type, or an enumeration type.
27 47
28 These are like the standard macros introduced in C23, except that 48 These are like the standard macros introduced in C23, except that
29 arguments should not have side effects. */ 49 arguments should not have side effects. The C++26 standard is
50 expected to add this header and it's macros. */
30 51
31#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r)) 52# define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
32#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r)) 53# define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
33#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r)) 54# define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
34 55
35#endif /* _GL_STDCKDINT_H */ 56# endif /* defined __cplusplus ? @HAVE_WORKING_CXX_STDCKDINT_H@ : @HAVE_WORKING_C_STDCKDINT_H@ */
57#endif /* _@GUARD_PREFIX@_STDCKDINT_H */
58#endif /* _@GUARD_PREFIX@_STDCKDINT_H */
diff --git a/gl/stddef.in.h b/gl/stddef.in.h
index 6eadcc3d..2fe9e044 100644
--- a/gl/stddef.in.h
+++ b/gl/stddef.in.h
@@ -1,6 +1,6 @@
1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. 1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
2 2
3 Copyright (C) 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -18,7 +18,7 @@
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * POSIX 2008 <stddef.h> for platforms that have issues. 21 * POSIX 2008 and ISO C 23 <stddef.h> for platforms that have issues.
22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
23 */ 23 */
24 24
@@ -27,19 +27,27 @@
27#endif 27#endif
28@PRAGMA_COLUMNS@ 28@PRAGMA_COLUMNS@
29 29
30#if defined __need_wchar_t || defined __need_size_t \ 30#if (defined __need_wchar_t || defined __need_size_t \
31 || defined __need_ptrdiff_t || defined __need_NULL \ 31 || defined __need_ptrdiff_t || defined __need_NULL \
32 || defined __need_wint_t 32 || defined __need_wint_t) \
33 /* Avoid warning triggered by "gcc -std=gnu23 -Wsystem-headers" \
34 in GCC 13.3 and 14.2 \
35 <https://gcc.gnu.org/PR114870>. */ \
36 && !@STDDEF_NOT_IDEMPOTENT@
33/* Special invocation convention inside gcc header files. In 37/* Special invocation convention inside gcc header files. In
34 particular, gcc provides a version of <stddef.h> that blindly 38 particular, <stddef.h> in some ancient versions of GCC blindly
35 redefines NULL even when __need_wint_t was defined, even though 39 redefined NULL when __need_wint_t was defined, even though wint_t
36 wint_t is not normally provided by <stddef.h>. Hence, we must 40 is not normally provided by <stddef.h>.
41 (FIXME: It's not clear what GCC versions those were - perhaps so
42 ancient that we can stop worrying about this?)
43 Although glibc 2.26 (2017) and later do not use __need_wint_t,
44 for portability to macOS, Cygwin, Haiku, and older Glibc + GCC,
37 remember if special invocation has ever been used to obtain wint_t, 45 remember if special invocation has ever been used to obtain wint_t,
38 in which case we need to clean up NULL yet again. */ 46 in which case we need to clean up NULL yet again. */
39 47
40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) 48# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T)
41# ifdef __need_wint_t 49# ifdef __need_wint_t
42# define _GL_STDDEF_WINT_T 50# define _@GUARD_PREFIX@_STDDEF_WINT_T
43# endif 51# endif
44# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 52# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
45 /* On TinyCC, make sure that the macros that indicate the special invocation 53 /* On TinyCC, make sure that the macros that indicate the special invocation
@@ -52,13 +60,20 @@
52# endif 60# endif
53 61
54#else 62#else
63/* For @STDDEF_NOT_IDEMPOTENT@. */
64# undef __need_wchar_t
65# undef __need_size_t
66# undef __need_ptrdiff_t
67# undef __need_NULL
68# undef __need_wint_t
69
55/* Normal invocation convention. */ 70/* Normal invocation convention. */
56 71
57# ifndef _@GUARD_PREFIX@_STDDEF_H 72# ifndef _@GUARD_PREFIX@_STDDEF_H
58 73
59/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a 74/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
60 type with alignment 4, but 'long' has alignment 8. */ 75 type with alignment 4, but 'long' has alignment 8. */
61# if defined _AIX && defined __LP64__ 76# if defined _AIX && defined __LP64__ && !@HAVE_MAX_ALIGN_T@
62# if !GNULIB_defined_max_align_t 77# if !GNULIB_defined_max_align_t
63# ifdef _MAX_ALIGN_T 78# ifdef _MAX_ALIGN_T
64/* /usr/include/stddef.h has already defined max_align_t. Override it. */ 79/* /usr/include/stddef.h has already defined max_align_t. Override it. */
@@ -69,17 +84,24 @@ typedef long rpl_max_align_t;
69typedef long max_align_t; 84typedef long max_align_t;
70# define _MAX_ALIGN_T 85# define _MAX_ALIGN_T
71# endif 86# endif
87# define __CLANG_MAX_ALIGN_T_DEFINED
72# define GNULIB_defined_max_align_t 1 88# define GNULIB_defined_max_align_t 1
73# endif 89# endif
74# endif 90# endif
75 91
92# if !defined _GCC_NULLPTR_T && !@NULLPTR_T_NEEDS_STDDEF@
93 /* Suppress unwanted nullptr_t typedef. See
94 <https://gcc.gnu.org/PR114869>. */
95# define _GCC_NULLPTR_T
96# endif
97
76/* The include_next requires a split double-inclusion guard. */ 98/* The include_next requires a split double-inclusion guard. */
77 99
78# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 100# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
79 101
80/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 102/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
81# if (@REPLACE_NULL@ \ 103# if (@REPLACE_NULL@ \
82 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T)) 104 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T))
83# undef NULL 105# undef NULL
84# ifdef __cplusplus 106# ifdef __cplusplus
85 /* ISO C++ says that the macro NULL must expand to an integer constant 107 /* ISO C++ says that the macro NULL must expand to an integer constant
@@ -100,9 +122,31 @@ typedef long max_align_t;
100# ifndef _@GUARD_PREFIX@_STDDEF_H 122# ifndef _@GUARD_PREFIX@_STDDEF_H
101# define _@GUARD_PREFIX@_STDDEF_H 123# define _@GUARD_PREFIX@_STDDEF_H
102 124
103/* Some platforms lack wchar_t. */ 125/* This file uses _Noreturn, _GL_ATTRIBUTE_NOTHROW. */
104#if !@HAVE_WCHAR_T@ 126#if !_GL_CONFIG_H_INCLUDED
105# define wchar_t int 127 #error "Please include config.h first."
128#endif
129
130/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
131 */
132#ifndef _GL_ATTRIBUTE_NOTHROW
133# if defined __cplusplus
134# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
135# if __cplusplus >= 201103L
136# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
137# else
138# define _GL_ATTRIBUTE_NOTHROW throw ()
139# endif
140# else
141# define _GL_ATTRIBUTE_NOTHROW
142# endif
143# else
144# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
145# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
146# else
147# define _GL_ATTRIBUTE_NOTHROW
148# endif
149# endif
106#endif 150#endif
107 151
108/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is 152/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
@@ -137,11 +181,68 @@ typedef union
137 long int __i _GL_STDDEF_ALIGNAS (long int); 181 long int __i _GL_STDDEF_ALIGNAS (long int);
138} rpl_max_align_t; 182} rpl_max_align_t;
139# define max_align_t rpl_max_align_t 183# define max_align_t rpl_max_align_t
184# define __CLANG_MAX_ALIGN_T_DEFINED
140# define GNULIB_defined_max_align_t 1 185# define GNULIB_defined_max_align_t 1
141# endif 186# endif
142# endif 187# endif
143#endif 188#endif
144 189
190/* ISO C 23 § 7.21.1 The unreachable macro */
191/* This macro is only usable in C, not in C++.
192 There is no way to define it as a macro in C++, because that would break code
193 that does
194 #include <utility>
195 ... std::unreachable() ...
196 Similarly, there is no way to define it as an inline function in C++, because
197 that would break code that does
198 #include <utility>
199 using std::unreachable;
200 As a workaround, we define a macro gl_unreachable, that is like unreachable,
201 but is usable in both C and C++. */
202
203/* Code borrowed from verify.h. */
204#ifndef _GL_HAS_BUILTIN_UNREACHABLE
205# if defined __clang_major__ && __clang_major__ < 5
206# define _GL_HAS_BUILTIN_UNREACHABLE 0
207# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__
208# define _GL_HAS_BUILTIN_UNREACHABLE 1
209# elif defined __has_builtin
210# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
211# else
212# define _GL_HAS_BUILTIN_UNREACHABLE 0
213# endif
214#endif
215
216#if _GL_HAS_BUILTIN_UNREACHABLE
217# define gl_unreachable() __builtin_unreachable ()
218#elif 1200 <= _MSC_VER
219# define gl_unreachable() __assume (0)
220#elif !defined __cplusplus && @HAVE_C_UNREACHABLE@
221# define gl_unreachable() unreachable ()
222#else
223/* Declare abort(), without including <stdlib.h>. */
224extern
225# if defined __cplusplus
226"C"
227# endif
228_Noreturn
229void abort (void)
230# if defined __cplusplus && (__GLIBC__ >= 2)
231_GL_ATTRIBUTE_NOTHROW
232# endif
233;
234# define gl_unreachable() abort ()
235#endif
236
237#if !defined __cplusplus && !@HAVE_C_UNREACHABLE@
238/* In C, define unreachable as a macro. */
239
240# ifndef unreachable
241# define unreachable() gl_unreachable ()
242# endif
243
244#endif
245
145# endif /* _@GUARD_PREFIX@_STDDEF_H */ 246# endif /* _@GUARD_PREFIX@_STDDEF_H */
146# endif /* _@GUARD_PREFIX@_STDDEF_H */ 247# endif /* _@GUARD_PREFIX@_STDDEF_H */
147#endif /* __need_XXX */ 248#endif /* __need_XXX */
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 5ddc644b..f6066094 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2002, 2004-2023 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2002, 2004-2026 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. 2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
@@ -51,13 +51,6 @@
51 in public interfaces due to compiler differences. */ 51 in public interfaces due to compiler differences. */
52 52
53#if @HAVE_STDINT_H@ 53#if @HAVE_STDINT_H@
54# if defined __sgi && ! defined __c99
55 /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
56 with "This header file is to be used only for c99 mode compilations"
57 diagnostics. */
58# define __STDINT_H__
59# endif
60
61 /* Some pre-C++11 <stdint.h> implementations need this. */ 54 /* Some pre-C++11 <stdint.h> implementations need this. */
62# ifdef __cplusplus 55# ifdef __cplusplus
63# ifndef __STDC_CONSTANT_MACROS 56# ifndef __STDC_CONSTANT_MACROS
@@ -80,7 +73,7 @@
80#define _@GUARD_PREFIX@_STDINT_H 73#define _@GUARD_PREFIX@_STDINT_H
81 74
82/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, 75/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
83 LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */ 76 LONG_MIN, LONG_MAX, ULONG_MAX, CHAR_BIT, _GL_INTEGER_WIDTH. */
84#include <limits.h> 77#include <limits.h>
85 78
86/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides 79/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
@@ -94,8 +87,8 @@
94 87
95#if ! @HAVE_C99_STDINT_H@ 88#if ! @HAVE_C99_STDINT_H@
96 89
97/* <sys/types.h> defines some of the stdint.h types as well, on glibc, 90/* <sys/types.h> defines some of the stdint.h types as well, on glibc and
98 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). 91 OpenBSD 3.8 (via <machine/types.h>).
99 AIX 5.2 <sys/types.h> isn't needed and causes troubles. 92 AIX 5.2 <sys/types.h> isn't needed and causes troubles.
100 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but 93 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
101 relies on the system <stdint.h> definitions, so include 94 relies on the system <stdint.h> definitions, so include
@@ -189,6 +182,10 @@ typedef __int64 gl_int64_t;
189# define int64_t gl_int64_t 182# define int64_t gl_int64_t
190# define GL_INT64_T 183# define GL_INT64_T
191# else 184# else
185/* Verify that 'long long' has exactly 64 bits. */
186typedef _gl_verify_int64_bits[
187 _STDINT_MAX (1, sizeof (long long) * CHAR_BIT, 0ll) >> 31 >> 31 == 1
188 ? 1 : -1];
192# undef int64_t 189# undef int64_t
193typedef long long int gl_int64_t; 190typedef long long int gl_int64_t;
194# define int64_t gl_int64_t 191# define int64_t gl_int64_t
@@ -210,6 +207,11 @@ typedef unsigned __int64 gl_uint64_t;
210# define uint64_t gl_uint64_t 207# define uint64_t gl_uint64_t
211# define GL_UINT64_T 208# define GL_UINT64_T
212# else 209# else
210/* Verify that 'unsigned long long' has exactly 64 bits. */
211typedef _gl_verify_uint64_bits[
212 _STDINT_MAX (0, sizeof (unsigned long long) * CHAR_BIT, 0ull)
213 >> 31 >> 31 >> 1 == 1
214 ? 1 : -1];
213# undef uint64_t 215# undef uint64_t
214typedef unsigned long long int gl_uint64_t; 216typedef unsigned long long int gl_uint64_t;
215# define uint64_t gl_uint64_t 217# define uint64_t gl_uint64_t
@@ -306,6 +308,8 @@ typedef gl_uint_fast32_t gl_uint_fast16_t;
306 uintptr_t to avoid conflicting declarations of system functions like 308 uintptr_t to avoid conflicting declarations of system functions like
307 _findclose in <io.h>. */ 309 _findclose in <io.h>. */
308# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ 310# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
311 || (defined __INTPTR_WIDTH__ \
312 && __INTPTR_WIDTH__ != (defined _WIN64 ? LLONG_WIDTH : LONG_WIDTH)) \
309 || defined __MINGW32__) 313 || defined __MINGW32__)
310# undef intptr_t 314# undef intptr_t
311# undef uintptr_t 315# undef uintptr_t
@@ -573,11 +577,7 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
573# endif 577# endif
574 578
575/* wchar_t limits */ 579/* wchar_t limits */
576/* Get WCHAR_MIN, WCHAR_MAX. 580/* Get WCHAR_MIN, WCHAR_MAX. */
577 This include is not on the top, above, because on OSF/1 4.0 we have a
578 sequence of nested includes
579 <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
580 <stdint.h> and assumes its types are already defined. */
581# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) 581# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
582# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 582# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
583# include <wchar.h> 583# include <wchar.h>
diff --git a/gl/stdio-consolesafe.c b/gl/stdio-consolesafe.c
new file mode 100644
index 00000000..f634de13
--- /dev/null
+++ b/gl/stdio-consolesafe.c
@@ -0,0 +1,202 @@
1/* msvcrt workarounds.
2 Copyright (C) 2025-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <stdckdint.h>
23#include <stdlib.h>
24#include <string.h>
25
26/* Outputs N bytes starting at S to FP.
27 These N bytes are known to be followed by a NUL.
28 Finally frees the string at S.
29 Returns the number of written bytes. */
30static size_t
31workaround_fwrite0 (char *s, size_t n, FILE *fp)
32{
33 const char *ptr = s;
34 /* Use fputs instead of fwrite, which is buggy in msvcrt. */
35 size_t written = 0;
36 while (n > 0)
37 {
38 size_t l = strlen (ptr); /* 0 <= l <= n */
39 if (l > 0)
40 {
41 if (fputs (ptr, fp) == EOF)
42 break;
43 written += l;
44 n -= l;
45 }
46 if (n == 0)
47 break;
48 if (fputc ('\0', fp) == EOF)
49 break;
50 written++;
51 n--;
52 ptr += l + 1;
53 }
54 free (s);
55 return written;
56}
57
58size_t
59gl_consolesafe_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *fp)
60{
61 size_t nbytes;
62 if (ckd_mul (&nbytes, size, nmemb) || nbytes == 0)
63 /* Overflow, or nothing to do. */
64 return 0;
65 char *tmp = malloc (nbytes + 1);
66 if (tmp == NULL)
67 return 0;
68 memcpy (tmp, ptr, nbytes);
69 tmp[nbytes] = '\0';
70 size_t written = workaround_fwrite0 (tmp, nbytes, fp);
71 return written / size;
72}
73
74#if defined __MINGW32__ && __USE_MINGW_ANSI_STDIO
75
76# include "fseterr.h"
77# include <stdarg.h>
78
79# if !HAVE_VASPRINTF
80
81# include <errno.h>
82
83/* The old mingw (before mingw-w64) does not have the vasprintf function.
84 Define a suitable replacement here, that supports the same format
85 specifiers as the mingw *printf functions. */
86
87static int
88local_vasprintf (char **resultp, const char *format, va_list args)
89{
90 /* First try: Use a stack-allocated buffer. */
91 char buf[2048];
92 size_t bufsize = sizeof (buf);
93 int ret = __mingw_vsnprintf (buf, bufsize, format, args);
94 if (ret < 0)
95 return -1;
96 size_t nbytes = ret;
97 char *mem = (char *) malloc (nbytes + 1);
98 if (mem == NULL)
99 {
100 errno = ENOMEM;
101 return -1;
102 }
103 if (ret < bufsize)
104 {
105 /* The buffer was sufficiently large. */
106 memcpy (mem, buf, nbytes + 1);
107 }
108 else
109 {
110 /* Second try: Use the heap-allocated memory. */
111 ret = __mingw_vsnprintf (mem, nbytes + 1, format, args);
112 if (ret < 0)
113 {
114 int saved_errno = errno;
115 free (mem);
116 errno = saved_errno;
117 return -1;
118 }
119 if (ret != nbytes)
120 abort ();
121 }
122 *resultp = mem;
123 return nbytes;
124}
125
126# undef vasprintf
127# define vasprintf local_vasprintf
128
129# endif
130
131/* Bypass the functions __mingw_[v][f]printf, that trigger a bug in msvcrt,
132 but without losing the support for modern format specifiers added by
133 __mingw_*printf. */
134
135int
136gl_consolesafe_fprintf (FILE *restrict fp, const char *restrict format, ...)
137{
138 va_list args;
139 va_start (args, format);
140 char *tmpstring;
141 int result = vasprintf (&tmpstring, format, args);
142 va_end (args);
143 if (result >= 0)
144 {
145 if (workaround_fwrite0 (tmpstring, result, fp) < result)
146 result = -1;
147 }
148 else
149 fseterr (fp);
150 return result;
151}
152
153int
154gl_consolesafe_printf (const char *restrict format, ...)
155{
156 va_list args;
157 va_start (args, format);
158 char *tmpstring;
159 int result = vasprintf (&tmpstring, format, args);
160 va_end (args);
161 if (result >= 0)
162 {
163 if (workaround_fwrite0 (tmpstring, result, stdout) < result)
164 result = -1;
165 }
166 else
167 fseterr (stdout);
168 return result;
169}
170
171int
172gl_consolesafe_vfprintf (FILE *restrict fp,
173 const char *restrict format, va_list args)
174{
175 char *tmpstring;
176 int result = vasprintf (&tmpstring, format, args);
177 if (result >= 0)
178 {
179 if (workaround_fwrite0 (tmpstring, result, fp) < result)
180 result = -1;
181 }
182 else
183 fseterr (fp);
184 return result;
185}
186
187int
188gl_consolesafe_vprintf (const char *restrict format, va_list args)
189{
190 char *tmpstring;
191 int result = vasprintf (&tmpstring, format, args);
192 if (result >= 0)
193 {
194 if (workaround_fwrite0 (tmpstring, result, stdout) < result)
195 result = -1;
196 }
197 else
198 fseterr (stdout);
199 return result;
200}
201
202#endif
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
index 46608bed..c90f64df 100644
--- a/gl/stdio-impl.h
+++ b/gl/stdio-impl.h
@@ -1,5 +1,5 @@
1/* Implementation details of FILE streams. 1/* Implementation details of FILE streams.
2 Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc. 2 Copyright (C) 2007-2008, 2010-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -30,6 +30,49 @@
30# endif 30# endif
31#endif 31#endif
32 32
33/* Haiku stdio implementation. */
34#if defined __HAIKU__
35# include <stdint.h>
36/* This FILE structure was made into an incomplete type in 2025.
37 See <https://cgit.haiku-os.org/haiku/tree/src/system/libroot/posix/glibc/libio/libio.h>. */
38# define fp_ ((struct { int _flags; \
39 char *_IO_read_ptr; \
40 char *_IO_read_end; \
41 char *_IO_read_base; \
42 char *_IO_write_base; \
43 char *_IO_write_ptr; \
44 char *_IO_write_end; \
45 char *_IO_buf_base; \
46 char *_IO_buf_end; \
47 char *_IO_save_base; \
48 char *_IO_backup_base; \
49 char *_IO_save_end; \
50 void *_markers; \
51 void *_chain; \
52 int _fileno; \
53 int _flags2; \
54 off_t _old_offset; \
55 unsigned short _cur_column; \
56 signed char _vtable_offset; \
57 char _shortbuf[1]; \
58 void *_lock; \
59 int64_t _offset; \
60 /* More fields, not relevant here. */ \
61 } *) fp)
62# if !defined _IO_UNBUFFERED
63# define _IO_UNBUFFERED 0x2
64# endif
65# if !defined _IO_EOF_SEEN
66# define _IO_EOF_SEEN 0x10
67# endif
68# if !defined _IO_IN_BACKUP
69# define _IO_IN_BACKUP 0x100
70# endif
71# if !defined _IO_LINE_BUF
72# define _IO_LINE_BUF 0x200
73# endif
74#endif
75
33/* BSD stdio derived implementations. */ 76/* BSD stdio derived implementations. */
34 77
35#if defined __NetBSD__ /* NetBSD */ 78#if defined __NetBSD__ /* NetBSD */
@@ -39,7 +82,7 @@
39 82
40#include <errno.h> /* For detecting Plan9. */ 83#include <errno.h> /* For detecting Plan9. */
41 84
42#if defined __sferror || defined __DragonFly__ || defined __ANDROID__ 85#if defined __sferror || defined __OpenBSD__ || defined __DragonFly__ || defined __ANDROID__
43 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ 86 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
44 87
45# if defined __DragonFly__ /* DragonFly */ 88# if defined __DragonFly__ /* DragonFly */
@@ -65,13 +108,59 @@
65# define _flags pub._flags 108# define _flags pub._flags
66# define _r pub._r 109# define _r pub._r
67# define _w pub._w 110# define _w pub._w
68# elif defined __ANDROID__ /* Android */ 111# elif defined __OpenBSD__ /* OpenBSD */
69# ifdef __LP64__ 112# if defined __sferror /* OpenBSD <= 7.7 */
113# define _gl_flags_file_t short
114# else /* OpenBSD >= 7.8 */
115# define _gl_flags_file_t int
116# endif
117 /* Up to this commit from 2025-07-16
118 <https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51d539ef06f5f3553790>
119 the innards of FILE were public. After this commit, the innards of FILE
120 are hidden. In this commit
121 <https://github.com/openbsd/src/commit/9063a2f1ec94013fb0e2c7ec851495108e788a6e>
122 they were reshuffled. */
123# if defined __sferror /* OpenBSD <= 7.7 */
124# define fp_ ((struct { unsigned char *_p; \
125 int _r; \
126 int _w; \
127 _gl_flags_file_t _flags; \
128 _gl_flags_file_t _file; \
129 struct { unsigned char *_base; size_t _size; } _bf; \
130 int _lbfsize; \
131 void *_cookie; \
132 void *_close; \
133 void *_read; \
134 void *_seek; \
135 void *_write; \
136 struct { unsigned char *_base; size_t _size; } _ext; \
137 unsigned char *_up; \
138 int _ur; \
139 unsigned char _ubuf[3]; \
140 unsigned char _nbuf[1]; \
141 struct { unsigned char *_base; size_t _size; } _lb; \
142 int _blksize; \
143 fpos_t _offset; \
144 /* More fields, not relevant here. */ \
145 } *) fp)
146# else /* OpenBSD >= 7.8 */
147# define fp_ ((struct { _gl_flags_file_t _flags; \
148 _gl_flags_file_t _file; \
149 unsigned char *_p; \
150 int _r; \
151 int _w; \
152 struct { unsigned char *_base; size_t _size; } _bf; \
153 int _lbfsize; \
154 /* More fields, not relevant here. */ \
155 } *) fp)
156# endif
157# elif defined __ANDROID__ /* Android */
158# if defined __LP64__
70# define _gl_flags_file_t int 159# define _gl_flags_file_t int
71# else 160# else
72# define _gl_flags_file_t short 161# define _gl_flags_file_t short
73# endif 162# endif
74# ifdef __LP64__ 163# if defined __LP64__
75# define _gl_file_offset_t int64_t 164# define _gl_file_offset_t int64_t
76# else 165# else
77 /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */ 166 /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */
@@ -79,7 +168,7 @@
79# endif 168# endif
80 /* Up to this commit from 2015-10-12 169 /* Up to this commit from 2015-10-12
81 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a> 170 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
82 the innards of FILE were public, and fp_ub could be defined like for OpenBSD, 171 the innards of FILE were public,
83 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h> 172 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
84 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>. 173 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
85 After this commit, the innards of FILE are hidden. */ 174 After this commit, the innards of FILE are hidden. */
@@ -109,9 +198,8 @@
109# define fp_ fp 198# define fp_ fp
110# endif 199# endif
111 200
112# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ 201# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __minix /* NetBSD >= 1.5ZA, Minix 3 */
113 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> 202 /* See <https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
114 and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
115 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */ 203 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
116 struct __sfileext 204 struct __sfileext
117 { 205 {
@@ -119,7 +207,7 @@
119 /* More fields, not relevant here. */ 207 /* More fields, not relevant here. */
120 }; 208 };
121# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub 209# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
122# elif defined __ANDROID__ /* Android */ 210# elif defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
123 struct __sfileext 211 struct __sfileext
124 { 212 {
125 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */ 213 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
@@ -132,9 +220,11 @@
132 220
133# define HASUB(fp) (fp_ub._base != NULL) 221# define HASUB(fp) (fp_ub._base != NULL)
134 222
135# if defined __ANDROID__ /* Android */ 223# if defined __ANDROID__ || defined __OpenBSD__ /* Android, OpenBSD */
136 /* Needed after this commit from 2016-01-25 224 /* Needed after this Android commit from 2016-01-25
137 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */ 225 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7>
226 And after this OpenBSD commit from 2025-07-16
227 <https://github.com/openbsd/src/commit/b7f6c2eb760a2da367dd51d539ef06f5f3553790>. */
138# ifndef __SEOF 228# ifndef __SEOF
139# define __SLBF 1 229# define __SLBF 1
140# define __SNBF 2 230# define __SNBF 2
diff --git a/gl/stdio-read.c b/gl/stdio-read.c
index 6e2984c5..0ca956dc 100644
--- a/gl/stdio-read.c
+++ b/gl/stdio-read.c
@@ -1,5 +1,5 @@
1/* POSIX compatible FILE stream read function. 1/* POSIX compatible FILE stream read function.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -52,9 +52,8 @@
52 return (EXPRESSION); \ 52 return (EXPRESSION); \
53 else \ 53 else \
54 { \ 54 { \
55 RETTYPE ret; \
56 SetLastError (0); \ 55 SetLastError (0); \
57 ret = (EXPRESSION); \ 56 RETTYPE ret = (EXPRESSION); \
58 if (FAILED) \ 57 if (FAILED) \
59 { \ 58 { \
60 if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \ 59 if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
@@ -86,11 +85,9 @@
86int 85int
87scanf (const char *format, ...) 86scanf (const char *format, ...)
88{ 87{
89 int retval;
90 va_list args; 88 va_list args;
91
92 va_start (args, format); 89 va_start (args, format);
93 retval = vfscanf (stdin, format, args); 90 int retval = vfscanf (stdin, format, args);
94 va_end (args); 91 va_end (args);
95 92
96 return retval; 93 return retval;
@@ -103,11 +100,9 @@ scanf (const char *format, ...)
103int 100int
104fscanf (FILE *stream, const char *format, ...) 101fscanf (FILE *stream, const char *format, ...)
105{ 102{
106 int retval;
107 va_list args; 103 va_list args;
108
109 va_start (args, format); 104 va_start (args, format);
110 retval = vfscanf (stream, format, args); 105 int retval = vfscanf (stream, format, args);
111 va_end (args); 106 va_end (args);
112 107
113 return retval; 108 return retval;
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
index 9cf36cca..fc7f74fe 100644
--- a/gl/stdio-write.c
+++ b/gl/stdio-write.c
@@ -1,5 +1,5 @@
1/* POSIX compatible FILE stream write function. 1/* POSIX compatible FILE stream write function.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -107,10 +107,9 @@
107 return (EXPRESSION); \ 107 return (EXPRESSION); \
108 else \ 108 else \
109 { \ 109 { \
110 RETTYPE ret; \
111 CLEAR_ERRNO \ 110 CLEAR_ERRNO \
112 CLEAR_LastError \ 111 CLEAR_LastError \
113 ret = (EXPRESSION); \ 112 RETTYPE ret = (EXPRESSION); \
114 if (FAILED) \ 113 if (FAILED) \
115 { \ 114 { \
116 HANDLE_ENOSPC \ 115 HANDLE_ENOSPC \
@@ -124,11 +123,9 @@
124int 123int
125printf (const char *format, ...) 124printf (const char *format, ...)
126{ 125{
127 int retval;
128 va_list args; 126 va_list args;
129
130 va_start (args, format); 127 va_start (args, format);
131 retval = vfprintf (stdout, format, args); 128 int retval = vfprintf (stdout, format, args);
132 va_end (args); 129 va_end (args);
133 130
134 return retval; 131 return retval;
@@ -139,11 +136,9 @@ printf (const char *format, ...)
139int 136int
140fprintf (FILE *stream, const char *format, ...) 137fprintf (FILE *stream, const char *format, ...)
141{ 138{
142 int retval;
143 va_list args; 139 va_list args;
144
145 va_start (args, format); 140 va_start (args, format);
146 retval = vfprintf (stream, format, args); 141 int retval = vfprintf (stream, format, args);
147 va_end (args); 142 va_end (args);
148 143
149 return retval; 144 return retval;
@@ -162,6 +157,9 @@ vprintf (const char *format, va_list args)
162int 157int
163vfprintf (FILE *stream, const char *format, va_list args) 158vfprintf (FILE *stream, const char *format, va_list args)
164#undef vfprintf 159#undef vfprintf
160#if defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
161# define vfprintf gl_consolesafe_vfprintf
162#endif
165{ 163{
166 CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF) 164 CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF)
167} 165}
@@ -198,6 +196,9 @@ puts (const char *string)
198size_t 196size_t
199fwrite (const void *ptr, size_t s, size_t n, FILE *stream) 197fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
200#undef fwrite 198#undef fwrite
199#if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
200# define fwrite gl_consolesafe_fwrite
201#endif
201{ 202{
202 CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n) 203 CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n)
203} 204}
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 59cbea3d..33b0b8e4 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdio.h>. 1/* A GNU-like <stdio.h>.
2 2
3 Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,14 +20,9 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H 23#if defined __need_FILE || defined __need___FILE || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H || defined _GL_SKIP_GNULIB_STDIO_H
24/* Special invocation convention: 24/* Special invocation convention:
25 - Inside glibc header files. 25 - Inside glibc header files. */
26 - On OSF/1 5.1 we have a sequence of nested includes
27 <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
28 <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
29 In this situation, the functions are not yet declared, therefore we cannot
30 provide the C++ aliases. */
31 26
32#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 27#@INCLUDE_NEXT@ @NEXT_STDIO_H@
33 28
@@ -36,16 +31,40 @@
36 31
37#ifndef _@GUARD_PREFIX@_STDIO_H 32#ifndef _@GUARD_PREFIX@_STDIO_H
38 33
39#define _GL_ALREADY_INCLUDING_STDIO_H 34/* Suppress macOS deprecation warnings for sprintf and vsprintf. */
35#if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
36# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
37# include <AvailabilityMacros.h>
38# endif
39# if (defined MAC_OS_X_VERSION_MIN_REQUIRED \
40 && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED)
41# define _POSIX_C_SOURCE 200809L
42# define _GL_DEFINED__POSIX_C_SOURCE
43# endif
44#endif
45
46#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
40 47
41/* The include_next requires a split double-inclusion guard. */ 48/* The include_next requires a split double-inclusion guard. */
42#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 49#@INCLUDE_NEXT@ @NEXT_STDIO_H@
43 50
44#undef _GL_ALREADY_INCLUDING_STDIO_H 51#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STDIO_H
52
53#ifdef _GL_DEFINED__POSIX_C_SOURCE
54# undef _GL_DEFINED__POSIX_C_SOURCE
55# undef _POSIX_C_SOURCE
56#endif
45 57
46#ifndef _@GUARD_PREFIX@_STDIO_H 58#ifndef _@GUARD_PREFIX@_STDIO_H
47#define _@GUARD_PREFIX@_STDIO_H 59#define _@GUARD_PREFIX@_STDIO_H
48 60
61/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
62 _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW,
63 GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
64#if !_GL_CONFIG_H_INCLUDED
65 #error "Please include config.h first."
66#endif
67
49/* Get va_list. Needed on many systems, including glibc 2.8. */ 68/* Get va_list. Needed on many systems, including glibc 2.8. */
50#include <stdarg.h> 69#include <stdarg.h>
51 70
@@ -53,7 +72,8 @@
53 72
54/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 73/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
55 and eglibc 2.11.2. 74 and eglibc 2.11.2.
56 May also define off_t to a 64-bit type on native Windows. */ 75 May also define off_t to a 64-bit type on native Windows.
76 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
57#include <sys/types.h> 77#include <sys/types.h>
58 78
59/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */ 79/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
@@ -95,7 +115,7 @@
95 that can be freed by passing them as the Ith argument to the 115 that can be freed by passing them as the Ith argument to the
96 function F. */ 116 function F. */
97#ifndef _GL_ATTRIBUTE_DEALLOC 117#ifndef _GL_ATTRIBUTE_DEALLOC
98# if __GNUC__ >= 11 118# if __GNUC__ >= 11 && !defined __clang__
99# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 119# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
100# else 120# else
101# define _GL_ATTRIBUTE_DEALLOC(f, i) 121# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -116,12 +136,44 @@
116# endif 136# endif
117#endif 137#endif
118 138
139/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
140 allocated memory. */
141#ifndef _GL_ATTRIBUTE_MALLOC
142# if __GNUC__ >= 3 || defined __clang__
143# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
144# else
145# define _GL_ATTRIBUTE_MALLOC
146# endif
147#endif
148
149/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
150 */
151#ifndef _GL_ATTRIBUTE_NOTHROW
152# if defined __cplusplus
153# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
154# if __cplusplus >= 201103L
155# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
156# else
157# define _GL_ATTRIBUTE_NOTHROW throw ()
158# endif
159# else
160# define _GL_ATTRIBUTE_NOTHROW
161# endif
162# else
163# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
164# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
165# else
166# define _GL_ATTRIBUTE_NOTHROW
167# endif
168# endif
169#endif
170
119/* An __attribute__ __format__ specifier for a function that takes a format 171/* An __attribute__ __format__ specifier for a function that takes a format
120 string and arguments, where the format string directives are the ones 172 string and arguments, where the format string directives are the ones
121 standardized by ISO C99 and POSIX. 173 standardized by ISO C99 and POSIX.
122 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ 174 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
123/* __gnu_printf__ is supported in GCC >= 4.4. */ 175/* __gnu_printf__ is supported in GCC >= 4.4. */
124#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 176#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4) && !defined __clang__
125# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ 177# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
126#else 178#else
127# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ 179# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
@@ -193,26 +245,100 @@
193# undef putc_unlocked 245# undef putc_unlocked
194#endif 246#endif
195 247
248
249/* Maximum number of characters produced by printing a NaN value. */
250#ifndef _PRINTF_NAN_LEN_MAX
251# if defined __FreeBSD__ || defined __DragonFly__ \
252 || defined __NetBSD__ \
253 || (defined __APPLE__ && defined __MACH__)
254/* On BSD systems, a NaN value prints as just "nan", without a sign. */
255# define _PRINTF_NAN_LEN_MAX 3
256# elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__
257/* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */
258# define _PRINTF_NAN_LEN_MAX 4
259# elif defined _AIX
260/* AIX produces "[-]NaNQ". */
261# define _PRINTF_NAN_LEN_MAX 5
262# elif defined _WIN32 && !defined __CYGWIN__
263/* On native Windows, the output can be:
264 - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
265 - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */
266# define _PRINTF_NAN_LEN_MAX 10
267# else
268/* We don't know, but 32 should be a safe maximum. */
269# define _PRINTF_NAN_LEN_MAX 32
270# endif
271#endif
272
273
274#if (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
275/* Workarounds against msvcrt bugs. */
276_GL_FUNCDECL_SYS (gl_consolesafe_fwrite, size_t,
277 (const void *ptr, size_t size, size_t nmemb, FILE *fp),
278 _GL_ARG_NONNULL ((1, 4)));
279# if defined __MINGW32__
280_GL_FUNCDECL_SYS (gl_consolesafe_fprintf, int,
281 (FILE *restrict fp, const char *restrict format, ...),
282 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
283 _GL_ARG_NONNULL ((1, 2)));
284_GL_FUNCDECL_SYS (gl_consolesafe_printf, int,
285 (const char *restrict format, ...),
286 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
287 _GL_ARG_NONNULL ((1)));
288_GL_FUNCDECL_SYS (gl_consolesafe_vfprintf, int,
289 (FILE *restrict fp,
290 const char *restrict format, va_list args),
291 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
292 _GL_ARG_NONNULL ((1, 2)));
293_GL_FUNCDECL_SYS (gl_consolesafe_vprintf, int,
294 (const char *restrict format, va_list args),
295 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
296 _GL_ARG_NONNULL ((1)));
297# endif
298#endif
299
300
301#if @GNULIB_DZPRINTF@
302/* Prints formatted output to file descriptor FD.
303 Returns the number of bytes written to the file descriptor. Upon
304 failure, returns -1 with errno set.
305 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
306 Therefore, if the format string is valid and does not use %ls/%lc
307 directives nor widths, the only possible failure codes are ENOMEM
308 and the possible failure codes from write(), excluding EINTR. */
309_GL_FUNCDECL_SYS (dzprintf, off64_t,
310 (int fd, const char *restrict format, ...),
311 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
312 _GL_ARG_NONNULL ((2)));
313_GL_CXXALIAS_SYS (dzprintf, off64_t,
314 (int fd, const char *restrict format, ...));
315#endif
316
196#if @GNULIB_DPRINTF@ 317#if @GNULIB_DPRINTF@
318/* Prints formatted output to file descriptor FD.
319 Returns the number of bytes written to the file descriptor. Upon
320 failure, returns a negative value. */
197# if @REPLACE_DPRINTF@ 321# if @REPLACE_DPRINTF@
198# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 322# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
199# define dprintf rpl_dprintf 323# define dprintf rpl_dprintf
200# endif 324# endif
201_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...) 325_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...),
202 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 326 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
203 _GL_ARG_NONNULL ((2))); 327 _GL_ARG_NONNULL ((2)));
204_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...)); 328_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
205# else 329# else
206# if !@HAVE_DPRINTF@ 330# if !@HAVE_DPRINTF@
207_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...) 331_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...),
208 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 332 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
209 _GL_ARG_NONNULL ((2))); 333 _GL_ARG_NONNULL ((2)));
210# endif 334# endif
211_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...)); 335_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
212# endif 336# endif
337# if __GLIBC__ >= 2
213_GL_CXXALIASWARN (dprintf); 338_GL_CXXALIASWARN (dprintf);
339# endif
214#elif defined GNULIB_POSIXCHECK 340#elif defined GNULIB_POSIXCHECK
215# undef dprintf 341# undef dprintf /* https://lists.gnu.org/r/bug-gnulib/2025-11/msg00254.html */
216# if HAVE_RAW_DECL_DPRINTF 342# if HAVE_RAW_DECL_DPRINTF
217_GL_WARN_ON_USE (dprintf, "dprintf is unportable - " 343_GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
218 "use gnulib module dprintf for portability"); 344 "use gnulib module dprintf for portability");
@@ -225,7 +351,7 @@ _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
225# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 351# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
226# define fclose rpl_fclose 352# define fclose rpl_fclose
227# endif 353# endif
228_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 354_GL_FUNCDECL_RPL (fclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
229_GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); 355_GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
230# else 356# else
231_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); 357_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
@@ -234,7 +360,6 @@ _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
234_GL_CXXALIASWARN (fclose); 360_GL_CXXALIASWARN (fclose);
235# endif 361# endif
236#elif defined GNULIB_POSIXCHECK 362#elif defined GNULIB_POSIXCHECK
237# undef fclose
238/* Assume fclose is always declared. */ 363/* Assume fclose is always declared. */
239_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " 364_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
240 "use gnulib module fclose for portable POSIX compliance"); 365 "use gnulib module fclose for portable POSIX compliance");
@@ -272,8 +397,10 @@ _GL_CXXALIASWARN (fcloseall);
272# define fdopen rpl_fdopen 397# define fdopen rpl_fdopen
273# endif 398# endif
274_GL_FUNCDECL_RPL (fdopen, FILE *, 399_GL_FUNCDECL_RPL (fdopen, FILE *,
275 (int fd, const char *mode) 400 (int fd, const char *mode),
276 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 401 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
402 _GL_ATTRIBUTE_MALLOC
403 _GL_ATTRIBUTE_NODISCARD);
277_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 404_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
278# elif defined _WIN32 && !defined __CYGWIN__ 405# elif defined _WIN32 && !defined __CYGWIN__
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 406# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -282,24 +409,43 @@ _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
282# endif 409# endif
283_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); 410_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
284# else 411# else
285# if __GNUC__ >= 11 412# if __GNUC__ >= 11 && !defined __clang__
286/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ 413/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
414# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
287_GL_FUNCDECL_SYS (fdopen, FILE *, 415_GL_FUNCDECL_SYS (fdopen, FILE *,
288 (int fd, const char *mode) 416 (int fd, const char *mode),
289 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 417 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
418 _GL_ATTRIBUTE_MALLOC
419 _GL_ATTRIBUTE_NODISCARD)
420 _GL_ATTRIBUTE_NOTHROW;
421# else
422_GL_FUNCDECL_SYS (fdopen, FILE *,
423 (int fd, const char *mode),
424 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
425 _GL_ATTRIBUTE_MALLOC
426 _GL_ATTRIBUTE_NODISCARD);
427# endif
290# endif 428# endif
291_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 429_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
292# endif 430# endif
293_GL_CXXALIASWARN (fdopen); 431_GL_CXXALIASWARN (fdopen);
294#else 432#else
295# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen 433# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fdopen
296/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */ 434/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
435# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
436_GL_FUNCDECL_SYS (fdopen, FILE *,
437 (int fd, const char *mode),
438 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
439 _GL_ATTRIBUTE_MALLOC)
440 _GL_ATTRIBUTE_NOTHROW;
441# else
297_GL_FUNCDECL_SYS (fdopen, FILE *, 442_GL_FUNCDECL_SYS (fdopen, FILE *,
298 (int fd, const char *mode) 443 (int fd, const char *mode),
299 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 444 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
445 _GL_ATTRIBUTE_MALLOC);
446# endif
300# endif 447# endif
301# if defined GNULIB_POSIXCHECK 448# if defined GNULIB_POSIXCHECK
302# undef fdopen
303/* Assume fdopen is always declared. */ 449/* Assume fdopen is always declared. */
304_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " 450_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
305 "use gnulib module fdopen for portability"); 451 "use gnulib module fdopen for portability");
@@ -331,7 +477,7 @@ _GL_CXXALIASWARN (fdopen);
331# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 477# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
332# define fflush rpl_fflush 478# define fflush rpl_fflush
333# endif 479# endif
334_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); 480_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream), );
335_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); 481_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
336# else 482# else
337_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); 483_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
@@ -340,7 +486,6 @@ _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
340_GL_CXXALIASWARN (fflush); 486_GL_CXXALIASWARN (fflush);
341# endif 487# endif
342#elif defined GNULIB_POSIXCHECK 488#elif defined GNULIB_POSIXCHECK
343# undef fflush
344/* Assume fflush is always declared. */ 489/* Assume fflush is always declared. */
345_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " 490_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
346 "use gnulib module fflush for portable POSIX compliance"); 491 "use gnulib module fflush for portable POSIX compliance");
@@ -352,7 +497,7 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
352# undef fgetc 497# undef fgetc
353# define fgetc rpl_fgetc 498# define fgetc rpl_fgetc
354# endif 499# endif
355_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 500_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
356_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); 501_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
357# else 502# else
358_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); 503_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
@@ -369,8 +514,8 @@ _GL_CXXALIASWARN (fgetc);
369# define fgets rpl_fgets 514# define fgets rpl_fgets
370# endif 515# endif
371_GL_FUNCDECL_RPL (fgets, char *, 516_GL_FUNCDECL_RPL (fgets, char *,
372 (char *restrict s, int n, FILE *restrict stream) 517 (char *restrict s, int n, FILE *restrict stream),
373 _GL_ARG_NONNULL ((1, 3))); 518 _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
374_GL_CXXALIAS_RPL (fgets, char *, 519_GL_CXXALIAS_RPL (fgets, char *,
375 (char *restrict s, int n, FILE *restrict stream)); 520 (char *restrict s, int n, FILE *restrict stream));
376# else 521# else
@@ -406,16 +551,18 @@ _GL_CXXALIASWARN (fileno);
406# define fopen rpl_fopen 551# define fopen rpl_fopen
407# endif 552# endif
408_GL_FUNCDECL_RPL (fopen, FILE *, 553_GL_FUNCDECL_RPL (fopen, FILE *,
409 (const char *restrict filename, const char *restrict mode) 554 (const char *restrict filename, const char *restrict mode),
410 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 555 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
556 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
411_GL_CXXALIAS_RPL (fopen, FILE *, 557_GL_CXXALIAS_RPL (fopen, FILE *,
412 (const char *restrict filename, const char *restrict mode)); 558 (const char *restrict filename, const char *restrict mode));
413# else 559# else
414# if __GNUC__ >= 11 560# if __GNUC__ >= 11 && !defined __clang__
415/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ 561/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
416_GL_FUNCDECL_SYS (fopen, FILE *, 562_GL_FUNCDECL_SYS (fopen, FILE *,
417 (const char *restrict filename, const char *restrict mode) 563 (const char *restrict filename, const char *restrict mode),
418 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 564 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
565 _GL_ATTRIBUTE_NODISCARD);
419# endif 566# endif
420_GL_CXXALIAS_SYS (fopen, FILE *, 567_GL_CXXALIAS_SYS (fopen, FILE *,
421 (const char *restrict filename, const char *restrict mode)); 568 (const char *restrict filename, const char *restrict mode));
@@ -424,21 +571,39 @@ _GL_CXXALIAS_SYS (fopen, FILE *,
424_GL_CXXALIASWARN (fopen); 571_GL_CXXALIASWARN (fopen);
425# endif 572# endif
426#else 573#else
427# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen 574# if @GNULIB_FCLOSE@ && (__GNUC__ >= 11 && !defined __clang__) && !defined fopen
428/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */ 575/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
429_GL_FUNCDECL_SYS (fopen, FILE *, 576_GL_FUNCDECL_SYS (fopen, FILE *,
430 (const char *restrict filename, const char *restrict mode) 577 (const char *restrict filename, const char *restrict mode),
431 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 578 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
432# endif 579# endif
433# if defined GNULIB_POSIXCHECK 580# if defined GNULIB_POSIXCHECK
434# undef fopen
435/* Assume fopen is always declared. */ 581/* Assume fopen is always declared. */
436_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " 582_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
437 "use gnulib module fopen for portability"); 583 "use gnulib module fopen for portability");
438# endif 584# endif
439#endif 585#endif
440 586
587#if @GNULIB_FZPRINTF@
588/* Prints formatted output to stream FP.
589 Returns the number of bytes written to the stream. Upon failure,
590 returns -1 with the stream's error indicator set.
591 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
592 Therefore, if the format string is valid and does not use %ls/%lc
593 directives nor widths, the only possible failure causes are ENOMEM
594 and the possible failure causes from fwrite(). */
595_GL_FUNCDECL_SYS (fzprintf, off64_t,
596 (FILE *restrict fp, const char *restrict format, ...),
597 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
598 _GL_ARG_NONNULL ((1, 2)));
599_GL_CXXALIAS_SYS (fzprintf, off64_t,
600 (FILE *restrict fp, const char *restrict format, ...));
601#endif
602
441#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ 603#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
604/* Prints formatted output to stream FP.
605 Returns the number of bytes written to the stream. Upon failure,
606 returns a negative value with the stream's error indicator set. */
442# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ 607# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
443 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 608 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
444# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 609# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -447,12 +612,12 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian
447# define GNULIB_overrides_fprintf 1 612# define GNULIB_overrides_fprintf 1
448# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 613# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
449_GL_FUNCDECL_RPL (fprintf, int, 614_GL_FUNCDECL_RPL (fprintf, int,
450 (FILE *restrict fp, const char *restrict format, ...) 615 (FILE *restrict fp, const char *restrict format, ...),
451 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 616 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
452 _GL_ARG_NONNULL ((1, 2))); 617 _GL_ARG_NONNULL ((1, 2)));
453# else 618# else
454_GL_FUNCDECL_RPL (fprintf, int, 619_GL_FUNCDECL_RPL (fprintf, int,
455 (FILE *restrict fp, const char *restrict format, ...) 620 (FILE *restrict fp, const char *restrict format, ...),
456 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) 621 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
457 _GL_ARG_NONNULL ((1, 2))); 622 _GL_ARG_NONNULL ((1, 2)));
458# endif 623# endif
@@ -465,11 +630,13 @@ _GL_CXXALIAS_SYS (fprintf, int,
465# if __GLIBC__ >= 2 630# if __GLIBC__ >= 2
466_GL_CXXALIASWARN (fprintf); 631_GL_CXXALIASWARN (fprintf);
467# endif 632# endif
468#endif 633#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
469#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 634# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
470# if !GNULIB_overrides_fprintf
471# undef fprintf 635# undef fprintf
636# define fprintf gl_consolesafe_fprintf
472# endif 637# endif
638#endif
639#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
473/* Assume fprintf is always declared. */ 640/* Assume fprintf is always declared. */
474_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " 641_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
475 "use gnulib module fprintf-posix for portable " 642 "use gnulib module fprintf-posix for portable "
@@ -487,17 +654,18 @@ _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
487# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 654# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
488# define fpurge rpl_fpurge 655# define fpurge rpl_fpurge
489# endif 656# endif
490_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); 657_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
491_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); 658_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
492# else 659# else
493# if !@HAVE_DECL_FPURGE@ 660# if !@HAVE_DECL_FPURGE@
494_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); 661_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), _GL_ARG_NONNULL ((1)));
495# endif 662# endif
496_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); 663_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
497# endif 664# endif
665# if __GLIBC__ >= 2
498_GL_CXXALIASWARN (fpurge); 666_GL_CXXALIASWARN (fpurge);
667# endif
499#elif defined GNULIB_POSIXCHECK 668#elif defined GNULIB_POSIXCHECK
500# undef fpurge
501# if HAVE_RAW_DECL_FPURGE 669# if HAVE_RAW_DECL_FPURGE
502_GL_WARN_ON_USE (fpurge, "fpurge is not always present - " 670_GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
503 "use gnulib module fpurge for portability"); 671 "use gnulib module fpurge for portability");
@@ -510,7 +678,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
510# undef fputc 678# undef fputc
511# define fputc rpl_fputc 679# define fputc rpl_fputc
512# endif 680# endif
513_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); 681_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
514_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); 682_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
515# else 683# else
516_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); 684_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
@@ -527,7 +695,7 @@ _GL_CXXALIASWARN (fputc);
527# define fputs rpl_fputs 695# define fputs rpl_fputs
528# endif 696# endif
529_GL_FUNCDECL_RPL (fputs, int, 697_GL_FUNCDECL_RPL (fputs, int,
530 (const char *restrict string, FILE *restrict stream) 698 (const char *restrict string, FILE *restrict stream),
531 _GL_ARG_NONNULL ((1, 2))); 699 _GL_ARG_NONNULL ((1, 2)));
532_GL_CXXALIAS_RPL (fputs, int, 700_GL_CXXALIAS_RPL (fputs, int,
533 (const char *restrict string, FILE *restrict stream)); 701 (const char *restrict string, FILE *restrict stream));
@@ -548,8 +716,8 @@ _GL_CXXALIASWARN (fputs);
548# endif 716# endif
549_GL_FUNCDECL_RPL (fread, size_t, 717_GL_FUNCDECL_RPL (fread, size_t,
550 (void *restrict ptr, size_t s, size_t n, 718 (void *restrict ptr, size_t s, size_t n,
551 FILE *restrict stream) 719 FILE *restrict stream),
552 _GL_ARG_NONNULL ((4))); 720 _GL_ARG_NONNULL ((4)) _GL_ATTRIBUTE_NODISCARD);
553_GL_CXXALIAS_RPL (fread, size_t, 721_GL_CXXALIAS_RPL (fread, size_t,
554 (void *restrict ptr, size_t s, size_t n, 722 (void *restrict ptr, size_t s, size_t n,
555 FILE *restrict stream)); 723 FILE *restrict stream));
@@ -571,8 +739,8 @@ _GL_CXXALIASWARN (fread);
571# endif 739# endif
572_GL_FUNCDECL_RPL (freopen, FILE *, 740_GL_FUNCDECL_RPL (freopen, FILE *,
573 (const char *restrict filename, const char *restrict mode, 741 (const char *restrict filename, const char *restrict mode,
574 FILE *restrict stream) 742 FILE *restrict stream),
575 _GL_ARG_NONNULL ((2, 3))); 743 _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
576_GL_CXXALIAS_RPL (freopen, FILE *, 744_GL_CXXALIAS_RPL (freopen, FILE *,
577 (const char *restrict filename, const char *restrict mode, 745 (const char *restrict filename, const char *restrict mode,
578 FILE *restrict stream)); 746 FILE *restrict stream));
@@ -585,7 +753,6 @@ _GL_CXXALIAS_SYS (freopen, FILE *,
585_GL_CXXALIASWARN (freopen); 753_GL_CXXALIASWARN (freopen);
586# endif 754# endif
587#elif defined GNULIB_POSIXCHECK 755#elif defined GNULIB_POSIXCHECK
588# undef freopen
589/* Assume freopen is always declared. */ 756/* Assume freopen is always declared. */
590_GL_WARN_ON_USE (freopen, 757_GL_WARN_ON_USE (freopen,
591 "freopen on native Windows platforms is not POSIX compliant - " 758 "freopen on native Windows platforms is not POSIX compliant - "
@@ -599,9 +766,9 @@ _GL_WARN_ON_USE (freopen,
599# define fscanf rpl_fscanf 766# define fscanf rpl_fscanf
600# endif 767# endif
601_GL_FUNCDECL_RPL (fscanf, int, 768_GL_FUNCDECL_RPL (fscanf, int,
602 (FILE *restrict stream, const char *restrict format, ...) 769 (FILE *restrict stream, const char *restrict format, ...),
603 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) 770 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
604 _GL_ARG_NONNULL ((1, 2))); 771 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
605_GL_CXXALIAS_RPL (fscanf, int, 772_GL_CXXALIAS_RPL (fscanf, int,
606 (FILE *restrict stream, const char *restrict format, ...)); 773 (FILE *restrict stream, const char *restrict format, ...));
607# else 774# else
@@ -655,7 +822,7 @@ _GL_CXXALIASWARN (fscanf);
655# undef fseek 822# undef fseek
656# define fseek rpl_fseek 823# define fseek rpl_fseek
657# endif 824# endif
658_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) 825_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence),
659 _GL_ARG_NONNULL ((1))); 826 _GL_ARG_NONNULL ((1)));
660_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); 827_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
661# else 828# else
@@ -678,12 +845,12 @@ _GL_CXXALIASWARN (fseek);
678# undef fseeko 845# undef fseeko
679# define fseeko rpl_fseeko 846# define fseeko rpl_fseeko
680# endif 847# endif
681_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) 848_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence),
682 _GL_ARG_NONNULL ((1))); 849 _GL_ARG_NONNULL ((1)));
683_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); 850_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
684# else 851# else
685# if ! @HAVE_DECL_FSEEKO@ 852# if ! @HAVE_DECL_FSEEKO@
686_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) 853_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence),
687 _GL_ARG_NONNULL ((1))); 854 _GL_ARG_NONNULL ((1)));
688# endif 855# endif
689_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); 856_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
@@ -692,7 +859,6 @@ _GL_CXXALIASWARN (fseeko);
692#elif defined GNULIB_POSIXCHECK 859#elif defined GNULIB_POSIXCHECK
693# define _GL_FSEEK_WARN /* Category 1, above. */ 860# define _GL_FSEEK_WARN /* Category 1, above. */
694# undef fseek 861# undef fseek
695# undef fseeko
696# if HAVE_RAW_DECL_FSEEKO 862# if HAVE_RAW_DECL_FSEEKO
697_GL_WARN_ON_USE (fseeko, "fseeko is unportable - " 863_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
698 "use gnulib module fseeko for portability"); 864 "use gnulib module fseeko for portability");
@@ -721,7 +887,8 @@ _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
721# undef ftell 887# undef ftell
722# define ftell rpl_ftell 888# define ftell rpl_ftell
723# endif 889# endif
724_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); 890_GL_FUNCDECL_RPL (ftell, long, (FILE *fp),
891 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
725_GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); 892_GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
726# else 893# else
727_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); 894_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
@@ -741,11 +908,13 @@ _GL_CXXALIASWARN (ftell);
741# undef ftello 908# undef ftello
742# define ftello rpl_ftello 909# define ftello rpl_ftello
743# endif 910# endif
744_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 911_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp),
912 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
745_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); 913_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
746# else 914# else
747# if ! @HAVE_DECL_FTELLO@ 915# if ! @HAVE_DECL_FTELLO@
748_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 916_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp),
917 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
749# endif 918# endif
750_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); 919_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
751# endif 920# endif
@@ -753,7 +922,6 @@ _GL_CXXALIASWARN (ftello);
753#elif defined GNULIB_POSIXCHECK 922#elif defined GNULIB_POSIXCHECK
754# define _GL_FTELL_WARN /* Category 1, above. */ 923# define _GL_FTELL_WARN /* Category 1, above. */
755# undef ftell 924# undef ftell
756# undef ftello
757# if HAVE_RAW_DECL_FTELLO 925# if HAVE_RAW_DECL_FTELLO
758_GL_WARN_ON_USE (ftello, "ftello is unportable - " 926_GL_WARN_ON_USE (ftello, "ftello is unportable - "
759 "use gnulib module ftello for portability"); 927 "use gnulib module ftello for portability");
@@ -778,7 +946,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
778# endif 946# endif
779_GL_FUNCDECL_RPL (fwrite, size_t, 947_GL_FUNCDECL_RPL (fwrite, size_t,
780 (const void *restrict ptr, size_t s, size_t n, 948 (const void *restrict ptr, size_t s, size_t n,
781 FILE *restrict stream) 949 FILE *restrict stream),
782 _GL_ARG_NONNULL ((1, 4))); 950 _GL_ARG_NONNULL ((1, 4)));
783_GL_CXXALIAS_RPL (fwrite, size_t, 951_GL_CXXALIAS_RPL (fwrite, size_t,
784 (const void *restrict ptr, size_t s, size_t n, 952 (const void *restrict ptr, size_t s, size_t n,
@@ -789,24 +957,24 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
789 FILE *restrict stream)); 957 FILE *restrict stream));
790 958
791/* Work around bug 11959 when fortifying glibc 2.4 through 2.15 959/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
792 <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>, 960 <https://sourceware.org/PR11959>,
793 which sometimes causes an unwanted diagnostic for fwrite calls. 961 which sometimes causes an unwanted diagnostic for fwrite calls.
794 This affects only function declaration attributes under certain 962 This affects only function declaration attributes under certain
795 versions of gcc and clang, and is not needed for C++. */ 963 versions of gcc and clang, and is not needed for C++. */
796# if (0 < __USE_FORTIFY_LEVEL \ 964# if (0 < __USE_FORTIFY_LEVEL \
797 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ 965 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
798 && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ 966 && (3 < __GNUC__ + (4 <= __GNUC_MINOR__) || defined __clang__) \
799 && !defined __cplusplus) 967 && !defined __cplusplus)
800# undef fwrite 968# undef fwrite
801# undef fwrite_unlocked 969# undef fwrite_unlocked
802extern size_t __REDIRECT (rpl_fwrite, 970_GL_EXTERN_C size_t __REDIRECT (rpl_fwrite,
803 (const void *__restrict, size_t, size_t, 971 (const void *__restrict, size_t, size_t,
804 FILE *__restrict), 972 FILE *__restrict),
805 fwrite); 973 fwrite);
806extern size_t __REDIRECT (rpl_fwrite_unlocked, 974_GL_EXTERN_C size_t __REDIRECT (rpl_fwrite_unlocked,
807 (const void *__restrict, size_t, size_t, 975 (const void *__restrict, size_t, size_t,
808 FILE *__restrict), 976 FILE *__restrict),
809 fwrite_unlocked); 977 fwrite_unlocked);
810# define fwrite rpl_fwrite 978# define fwrite rpl_fwrite
811# define fwrite_unlocked rpl_fwrite_unlocked 979# define fwrite_unlocked rpl_fwrite_unlocked
812# endif 980# endif
@@ -814,6 +982,11 @@ extern size_t __REDIRECT (rpl_fwrite_unlocked,
814# if __GLIBC__ >= 2 982# if __GLIBC__ >= 2
815_GL_CXXALIASWARN (fwrite); 983_GL_CXXALIASWARN (fwrite);
816# endif 984# endif
985#elif (defined _WIN32 && !defined __CYGWIN__) && !defined _UCRT
986# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
987# undef fwrite
988# define fwrite gl_consolesafe_fwrite
989# endif
817#endif 990#endif
818 991
819#if @GNULIB_GETC@ 992#if @GNULIB_GETC@
@@ -822,7 +995,7 @@ _GL_CXXALIASWARN (fwrite);
822# undef getc 995# undef getc
823# define getc rpl_fgetc 996# define getc rpl_fgetc
824# endif 997# endif
825_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 998_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
826_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); 999_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
827# else 1000# else
828_GL_CXXALIAS_SYS (getc, int, (FILE *stream)); 1001_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
@@ -838,7 +1011,7 @@ _GL_CXXALIASWARN (getc);
838# undef getchar 1011# undef getchar
839# define getchar rpl_getchar 1012# define getchar rpl_getchar
840# endif 1013# endif
841_GL_FUNCDECL_RPL (getchar, int, (void)); 1014_GL_FUNCDECL_RPL (getchar, int, (void), );
842_GL_CXXALIAS_RPL (getchar, int, (void)); 1015_GL_CXXALIAS_RPL (getchar, int, (void));
843# else 1016# else
844_GL_CXXALIAS_SYS (getchar, int, (void)); 1017_GL_CXXALIAS_SYS (getchar, int, (void));
@@ -860,11 +1033,22 @@ _GL_CXXALIASWARN (getchar);
860# undef getdelim 1033# undef getdelim
861# define getdelim rpl_getdelim 1034# define getdelim rpl_getdelim
862# endif 1035# endif
1036# ifndef __has_feature
1037# define __has_feature(a) 0
1038# endif
1039# if __GLIBC__ >= 2 && !(defined __SANITIZE_ADDRESS__ \
1040 || __has_feature (address_sanitizer))
1041/* Arrange for the inline definition of getline() in <bits/stdio.h>
1042 to call our getdelim() override. Do not use the __getdelim symbol
1043 if address sanitizer is in use, otherwise it may be overridden by
1044 __interceptor_trampoline___getdelim. */
1045# define rpl_getdelim __getdelim
1046# endif
863_GL_FUNCDECL_RPL (getdelim, ssize_t, 1047_GL_FUNCDECL_RPL (getdelim, ssize_t,
864 (char **restrict lineptr, size_t *restrict linesize, 1048 (char **restrict lineptr, size_t *restrict linesize,
865 int delimiter, 1049 int delimiter,
866 FILE *restrict stream) 1050 FILE *restrict stream),
867 _GL_ARG_NONNULL ((1, 2, 4))); 1051 _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
868_GL_CXXALIAS_RPL (getdelim, ssize_t, 1052_GL_CXXALIAS_RPL (getdelim, ssize_t,
869 (char **restrict lineptr, size_t *restrict linesize, 1053 (char **restrict lineptr, size_t *restrict linesize,
870 int delimiter, 1054 int delimiter,
@@ -874,17 +1058,18 @@ _GL_CXXALIAS_RPL (getdelim, ssize_t,
874_GL_FUNCDECL_SYS (getdelim, ssize_t, 1058_GL_FUNCDECL_SYS (getdelim, ssize_t,
875 (char **restrict lineptr, size_t *restrict linesize, 1059 (char **restrict lineptr, size_t *restrict linesize,
876 int delimiter, 1060 int delimiter,
877 FILE *restrict stream) 1061 FILE *restrict stream),
878 _GL_ARG_NONNULL ((1, 2, 4))); 1062 _GL_ARG_NONNULL ((1, 2, 4)) _GL_ATTRIBUTE_NODISCARD);
879# endif 1063# endif
880_GL_CXXALIAS_SYS (getdelim, ssize_t, 1064_GL_CXXALIAS_SYS (getdelim, ssize_t,
881 (char **restrict lineptr, size_t *restrict linesize, 1065 (char **restrict lineptr, size_t *restrict linesize,
882 int delimiter, 1066 int delimiter,
883 FILE *restrict stream)); 1067 FILE *restrict stream));
884# endif 1068# endif
1069# if __GLIBC__ >= 2
885_GL_CXXALIASWARN (getdelim); 1070_GL_CXXALIASWARN (getdelim);
1071# endif
886#elif defined GNULIB_POSIXCHECK 1072#elif defined GNULIB_POSIXCHECK
887# undef getdelim
888# if HAVE_RAW_DECL_GETDELIM 1073# if HAVE_RAW_DECL_GETDELIM
889_GL_WARN_ON_USE (getdelim, "getdelim is unportable - " 1074_GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
890 "use gnulib module getdelim for portability"); 1075 "use gnulib module getdelim for portability");
@@ -899,14 +1084,27 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
899 Return the number of bytes read and stored at *LINEPTR (not including the 1084 Return the number of bytes read and stored at *LINEPTR (not including the
900 NUL terminator), or -1 on error or EOF. */ 1085 NUL terminator), or -1 on error or EOF. */
901# if @REPLACE_GETLINE@ 1086# if @REPLACE_GETLINE@
902# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1087_GL_FUNCDECL_RPL (getline, ssize_t,
1088 (char **restrict lineptr, size_t *restrict linesize,
1089 FILE *restrict stream),
1090 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
1091# if defined __cplusplus
1092/* The C++ standard library defines std::basic_istream::getline in <istream>
1093 or <string>. */
1094# if !(__GLIBC__ >= 2)
1095extern "C" {
1096inline ssize_t
1097getline (char **restrict lineptr, size_t *restrict linesize,
1098 FILE *restrict stream)
1099{
1100 return rpl_getline (lineptr, linesize, stream);
1101}
1102}
1103# endif
1104# else
903# undef getline 1105# undef getline
904# define getline rpl_getline 1106# define getline rpl_getline
905# endif 1107# endif
906_GL_FUNCDECL_RPL (getline, ssize_t,
907 (char **restrict lineptr, size_t *restrict linesize,
908 FILE *restrict stream)
909 _GL_ARG_NONNULL ((1, 2, 3)));
910_GL_CXXALIAS_RPL (getline, ssize_t, 1108_GL_CXXALIAS_RPL (getline, ssize_t,
911 (char **restrict lineptr, size_t *restrict linesize, 1109 (char **restrict lineptr, size_t *restrict linesize,
912 FILE *restrict stream)); 1110 FILE *restrict stream));
@@ -914,18 +1112,17 @@ _GL_CXXALIAS_RPL (getline, ssize_t,
914# if !@HAVE_DECL_GETLINE@ 1112# if !@HAVE_DECL_GETLINE@
915_GL_FUNCDECL_SYS (getline, ssize_t, 1113_GL_FUNCDECL_SYS (getline, ssize_t,
916 (char **restrict lineptr, size_t *restrict linesize, 1114 (char **restrict lineptr, size_t *restrict linesize,
917 FILE *restrict stream) 1115 FILE *restrict stream),
918 _GL_ARG_NONNULL ((1, 2, 3))); 1116 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
919# endif 1117# endif
920_GL_CXXALIAS_SYS (getline, ssize_t, 1118_GL_CXXALIAS_SYS (getline, ssize_t,
921 (char **restrict lineptr, size_t *restrict linesize, 1119 (char **restrict lineptr, size_t *restrict linesize,
922 FILE *restrict stream)); 1120 FILE *restrict stream));
923# endif 1121# endif
924# if @HAVE_DECL_GETLINE@ 1122# if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@
925_GL_CXXALIASWARN (getline); 1123_GL_CXXALIASWARN (getline);
926# endif 1124# endif
927#elif defined GNULIB_POSIXCHECK 1125#elif defined GNULIB_POSIXCHECK
928# undef getline
929# if HAVE_RAW_DECL_GETLINE 1126# if HAVE_RAW_DECL_GETLINE
930_GL_WARN_ON_USE (getline, "getline is unportable - " 1127_GL_WARN_ON_USE (getline, "getline is unportable - "
931 "use gnulib module getline for portability"); 1128 "use gnulib module getline for portability");
@@ -935,7 +1132,6 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
935/* It is very rare that the developer ever has full control of stdin, 1132/* It is very rare that the developer ever has full control of stdin,
936 so any use of gets warrants an unconditional warning; besides, C11 1133 so any use of gets warrants an unconditional warning; besides, C11
937 removed it. */ 1134 removed it. */
938#undef gets
939#if HAVE_RAW_DECL_GETS && !defined __cplusplus 1135#if HAVE_RAW_DECL_GETS && !defined __cplusplus
940_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 1136_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
941#endif 1137#endif
@@ -951,24 +1147,58 @@ _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
951# endif 1147# endif
952_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream)); 1148_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
953# else 1149# else
1150# if @HAVE_DECL_GETW@
1151# if defined __APPLE__ && defined __MACH__
1152/* The presence of the declaration depends on _POSIX_C_SOURCE. */
1153_GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream), );
1154# endif
954_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream)); 1155_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
1156# endif
955# endif 1157# endif
1158# if __GLIBC__ >= 2
956_GL_CXXALIASWARN (getw); 1159_GL_CXXALIASWARN (getw);
1160# endif
1161#endif
1162
1163#if @GNULIB_OBSTACK_ZPRINTF@
1164struct obstack;
1165/* Grows an obstack with formatted output. Returns the number of
1166 bytes added to OBS. No trailing nul byte is added, and the
1167 object should be closed with obstack_finish before use.
1168 Upon memory allocation error, calls obstack_alloc_failed_handler.
1169 Upon other error, returns -1 with errno set.
1170
1171 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1172 Therefore, if the format string is valid and does not use %ls/%lc
1173 directives nor widths, the only possible failure code is through
1174 obstack_alloc_failed_handler. */
1175_GL_FUNCDECL_SYS (obstack_zprintf, ptrdiff_t,
1176 (struct obstack *obs, const char *format, ...),
1177 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1178 _GL_ARG_NONNULL ((1, 2)));
1179_GL_CXXALIAS_SYS (obstack_zprintf, ptrdiff_t,
1180 (struct obstack *obs, const char *format, ...));
1181_GL_FUNCDECL_SYS (obstack_vzprintf, ptrdiff_t,
1182 (struct obstack *obs, const char *format, va_list args),
1183 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1184 _GL_ARG_NONNULL ((1, 2)));
1185_GL_CXXALIAS_SYS (obstack_vzprintf, ptrdiff_t,
1186 (struct obstack *obs, const char *format, va_list args));
957#endif 1187#endif
958 1188
959#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 1189#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
960struct obstack; 1190struct obstack;
961/* Grow an obstack with formatted output. Return the number of 1191/* Grows an obstack with formatted output. Returns the number of
962 bytes added to OBS. No trailing nul byte is added, and the 1192 bytes added to OBS. No trailing nul byte is added, and the
963 object should be closed with obstack_finish before use. Upon 1193 object should be closed with obstack_finish before use.
964 memory allocation error, call obstack_alloc_failed_handler. Upon 1194 Upon memory allocation error, calls obstack_alloc_failed_handler.
965 other error, return -1. */ 1195 Upon other error, returns -1. */
966# if @REPLACE_OBSTACK_PRINTF@ 1196# if @REPLACE_OBSTACK_PRINTF@
967# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1197# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968# define obstack_printf rpl_obstack_printf 1198# define obstack_printf rpl_obstack_printf
969# endif 1199# endif
970_GL_FUNCDECL_RPL (obstack_printf, int, 1200_GL_FUNCDECL_RPL (obstack_printf, int,
971 (struct obstack *obs, const char *format, ...) 1201 (struct obstack *obs, const char *format, ...),
972 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1202 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
973 _GL_ARG_NONNULL ((1, 2))); 1203 _GL_ARG_NONNULL ((1, 2)));
974_GL_CXXALIAS_RPL (obstack_printf, int, 1204_GL_CXXALIAS_RPL (obstack_printf, int,
@@ -976,7 +1206,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
976# else 1206# else
977# if !@HAVE_DECL_OBSTACK_PRINTF@ 1207# if !@HAVE_DECL_OBSTACK_PRINTF@
978_GL_FUNCDECL_SYS (obstack_printf, int, 1208_GL_FUNCDECL_SYS (obstack_printf, int,
979 (struct obstack *obs, const char *format, ...) 1209 (struct obstack *obs, const char *format, ...),
980 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1210 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
981 _GL_ARG_NONNULL ((1, 2))); 1211 _GL_ARG_NONNULL ((1, 2)));
982# endif 1212# endif
@@ -989,7 +1219,7 @@ _GL_CXXALIASWARN (obstack_printf);
989# define obstack_vprintf rpl_obstack_vprintf 1219# define obstack_vprintf rpl_obstack_vprintf
990# endif 1220# endif
991_GL_FUNCDECL_RPL (obstack_vprintf, int, 1221_GL_FUNCDECL_RPL (obstack_vprintf, int,
992 (struct obstack *obs, const char *format, va_list args) 1222 (struct obstack *obs, const char *format, va_list args),
993 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1223 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
994 _GL_ARG_NONNULL ((1, 2))); 1224 _GL_ARG_NONNULL ((1, 2)));
995_GL_CXXALIAS_RPL (obstack_vprintf, int, 1225_GL_CXXALIAS_RPL (obstack_vprintf, int,
@@ -997,7 +1227,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
997# else 1227# else
998# if !@HAVE_DECL_OBSTACK_PRINTF@ 1228# if !@HAVE_DECL_OBSTACK_PRINTF@
999_GL_FUNCDECL_SYS (obstack_vprintf, int, 1229_GL_FUNCDECL_SYS (obstack_vprintf, int,
1000 (struct obstack *obs, const char *format, va_list args) 1230 (struct obstack *obs, const char *format, va_list args),
1001 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1231 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1002 _GL_ARG_NONNULL ((1, 2))); 1232 _GL_ARG_NONNULL ((1, 2)));
1003# endif 1233# endif
@@ -1009,12 +1239,11 @@ _GL_CXXALIASWARN (obstack_vprintf);
1009 1239
1010#if @GNULIB_PCLOSE@ 1240#if @GNULIB_PCLOSE@
1011# if !@HAVE_PCLOSE@ 1241# if !@HAVE_PCLOSE@
1012_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 1242_GL_FUNCDECL_SYS (pclose, int, (FILE *stream), _GL_ARG_NONNULL ((1)));
1013# endif 1243# endif
1014_GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); 1244_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
1015_GL_CXXALIASWARN (pclose); 1245_GL_CXXALIASWARN (pclose);
1016#elif defined GNULIB_POSIXCHECK 1246#elif defined GNULIB_POSIXCHECK
1017# undef pclose
1018# if HAVE_RAW_DECL_PCLOSE 1247# if HAVE_RAW_DECL_PCLOSE
1019_GL_WARN_ON_USE (pclose, "pclose is unportable - " 1248_GL_WARN_ON_USE (pclose, "pclose is unportable - "
1020 "use gnulib module pclose for more portability"); 1249 "use gnulib module pclose for more portability");
@@ -1029,7 +1258,7 @@ _GL_WARN_ON_USE (pclose, "pclose is unportable - "
1029# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1258# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1030# define perror rpl_perror 1259# define perror rpl_perror
1031# endif 1260# endif
1032_GL_FUNCDECL_RPL (perror, void, (const char *string)); 1261_GL_FUNCDECL_RPL (perror, void, (const char *string), );
1033_GL_CXXALIAS_RPL (perror, void, (const char *string)); 1262_GL_CXXALIAS_RPL (perror, void, (const char *string));
1034# else 1263# else
1035_GL_CXXALIAS_SYS (perror, void, (const char *string)); 1264_GL_CXXALIAS_SYS (perror, void, (const char *string));
@@ -1038,7 +1267,6 @@ _GL_CXXALIAS_SYS (perror, void, (const char *string));
1038_GL_CXXALIASWARN (perror); 1267_GL_CXXALIASWARN (perror);
1039# endif 1268# endif
1040#elif defined GNULIB_POSIXCHECK 1269#elif defined GNULIB_POSIXCHECK
1041# undef perror
1042/* Assume perror is always declared. */ 1270/* Assume perror is always declared. */
1043_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " 1271_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1044 "use gnulib module perror for portability"); 1272 "use gnulib module perror for portability");
@@ -1051,27 +1279,30 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
1051# define popen rpl_popen 1279# define popen rpl_popen
1052# endif 1280# endif
1053_GL_FUNCDECL_RPL (popen, FILE *, 1281_GL_FUNCDECL_RPL (popen, FILE *,
1054 (const char *cmd, const char *mode) 1282 (const char *cmd, const char *mode),
1055 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); 1283 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1284 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1056_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 1285_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
1057# else 1286# else
1058# if !@HAVE_POPEN@ || __GNUC__ >= 11 1287# if !@HAVE_POPEN@ || (__GNUC__ >= 11 && !defined __clang__)
1059_GL_FUNCDECL_SYS (popen, FILE *, 1288_GL_FUNCDECL_SYS (popen, FILE *,
1060 (const char *cmd, const char *mode) 1289 (const char *cmd, const char *mode),
1061 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); 1290 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1291 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_NODISCARD);
1062# endif 1292# endif
1063_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 1293_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
1064# endif 1294# endif
1065_GL_CXXALIASWARN (popen); 1295_GL_CXXALIASWARN (popen);
1066#else 1296#else
1067# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen 1297# if @GNULIB_PCLOSE@ \
1298 && (__GNUC__ >= 11 && !defined __clang__) && !defined popen
1068/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */ 1299/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1069_GL_FUNCDECL_SYS (popen, FILE *, 1300_GL_FUNCDECL_SYS (popen, FILE *,
1070 (const char *cmd, const char *mode) 1301 (const char *cmd, const char *mode),
1071 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)); 1302 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
1303 _GL_ATTRIBUTE_MALLOC);
1072# endif 1304# endif
1073# if defined GNULIB_POSIXCHECK 1305# if defined GNULIB_POSIXCHECK
1074# undef popen
1075# if HAVE_RAW_DECL_POPEN 1306# if HAVE_RAW_DECL_POPEN
1076_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " 1307_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1077 "use gnulib module popen or pipe for more portability"); 1308 "use gnulib module popen or pipe for more portability");
@@ -1079,7 +1310,24 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1079# endif 1310# endif
1080#endif 1311#endif
1081 1312
1313#if @GNULIB_ZPRINTF@
1314/* Prints formatted output to standard output.
1315 Returns the number of bytes written to standard output. Upon failure,
1316 returns -1 with stdout's error indicator set.
1317 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1318 Therefore, if the format string is valid and does not use %ls/%lc
1319 directives nor widths, the only possible failure causes are ENOMEM
1320 and the possible failure causes from fwrite(). */
1321_GL_FUNCDECL_SYS (zprintf, off64_t, (const char *restrict format, ...),
1322 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1323 _GL_ARG_NONNULL ((1)));
1324_GL_CXXALIAS_SYS (zprintf, off64_t, (const char *restrict format, ...));
1325#endif
1326
1082#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 1327#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
1328/* Prints formatted output to standard output.
1329 Returns the number of bytes written to standard output. Upon failure,
1330 returns a negative value with stdout's error indicator set. */
1083# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 1331# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
1084 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1332 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1085# if defined __GNUC__ || defined __clang__ 1333# if defined __GNUC__ || defined __clang__
@@ -1091,14 +1339,14 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
1091_GL_FUNCDECL_RPL_1 (__printf__, int, 1339_GL_FUNCDECL_RPL_1 (__printf__, int,
1092 (const char *restrict format, ...) 1340 (const char *restrict format, ...)
1093 __asm__ (@ASM_SYMBOL_PREFIX@ 1341 __asm__ (@ASM_SYMBOL_PREFIX@
1094 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1342 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
1095 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) 1343 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1096 _GL_ARG_NONNULL ((1))); 1344 _GL_ARG_NONNULL ((1)));
1097# else 1345# else
1098_GL_FUNCDECL_RPL_1 (__printf__, int, 1346_GL_FUNCDECL_RPL_1 (__printf__, int,
1099 (const char *restrict format, ...) 1347 (const char *restrict format, ...)
1100 __asm__ (@ASM_SYMBOL_PREFIX@ 1348 __asm__ (@ASM_SYMBOL_PREFIX@
1101 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1349 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)),
1102 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) 1350 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
1103 _GL_ARG_NONNULL ((1))); 1351 _GL_ARG_NONNULL ((1)));
1104# endif 1352# endif
@@ -1108,7 +1356,7 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
1108# define printf rpl_printf 1356# define printf rpl_printf
1109# endif 1357# endif
1110_GL_FUNCDECL_RPL (printf, int, 1358_GL_FUNCDECL_RPL (printf, int,
1111 (const char *restrict format, ...) 1359 (const char *restrict format, ...),
1112 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2) 1360 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1113 _GL_ARG_NONNULL ((1))); 1361 _GL_ARG_NONNULL ((1)));
1114_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...)); 1362_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
@@ -1120,11 +1368,13 @@ _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
1120# if __GLIBC__ >= 2 1368# if __GLIBC__ >= 2
1121_GL_CXXALIASWARN (printf); 1369_GL_CXXALIASWARN (printf);
1122# endif 1370# endif
1123#endif 1371#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1124#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1372# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1125# if !GNULIB_overrides_printf
1126# undef printf 1373# undef printf
1374# define printf gl_consolesafe_printf
1127# endif 1375# endif
1376#endif
1377#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1128/* Assume printf is always declared. */ 1378/* Assume printf is always declared. */
1129_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " 1379_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1130 "use gnulib module printf-posix for portable " 1380 "use gnulib module printf-posix for portable "
@@ -1137,7 +1387,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
1137# undef putc 1387# undef putc
1138# define putc rpl_fputc 1388# define putc rpl_fputc
1139# endif 1389# endif
1140_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); 1390_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream), _GL_ARG_NONNULL ((2)));
1141_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); 1391_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
1142# else 1392# else
1143_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); 1393_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
@@ -1153,7 +1403,7 @@ _GL_CXXALIASWARN (putc);
1153# undef putchar 1403# undef putchar
1154# define putchar rpl_putchar 1404# define putchar rpl_putchar
1155# endif 1405# endif
1156_GL_FUNCDECL_RPL (putchar, int, (int c)); 1406_GL_FUNCDECL_RPL (putchar, int, (int c), );
1157_GL_CXXALIAS_RPL (putchar, int, (int c)); 1407_GL_CXXALIAS_RPL (putchar, int, (int c));
1158# else 1408# else
1159_GL_CXXALIAS_SYS (putchar, int, (int c)); 1409_GL_CXXALIAS_SYS (putchar, int, (int c));
@@ -1169,7 +1419,7 @@ _GL_CXXALIASWARN (putchar);
1169# undef puts 1419# undef puts
1170# define puts rpl_puts 1420# define puts rpl_puts
1171# endif 1421# endif
1172_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); 1422_GL_FUNCDECL_RPL (puts, int, (const char *string), _GL_ARG_NONNULL ((1)));
1173_GL_CXXALIAS_RPL (puts, int, (const char *string)); 1423_GL_CXXALIAS_RPL (puts, int, (const char *string));
1174# else 1424# else
1175_GL_CXXALIAS_SYS (puts, int, (const char *string)); 1425_GL_CXXALIAS_SYS (puts, int, (const char *string));
@@ -1190,9 +1440,17 @@ _GL_CXXALIASWARN (puts);
1190# endif 1440# endif
1191_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream)); 1441_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1192# else 1442# else
1443# if @HAVE_DECL_PUTW@
1444# if defined __APPLE__ && defined __MACH__
1445/* The presence of the declaration depends on _POSIX_C_SOURCE. */
1446_GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream), );
1447# endif
1193_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream)); 1448_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1449# endif
1194# endif 1450# endif
1451# if __GLIBC__ >= 2
1195_GL_CXXALIASWARN (putw); 1452_GL_CXXALIASWARN (putw);
1453# endif
1196#endif 1454#endif
1197 1455
1198#if @GNULIB_REMOVE@ 1456#if @GNULIB_REMOVE@
@@ -1201,7 +1459,7 @@ _GL_CXXALIASWARN (putw);
1201# undef remove 1459# undef remove
1202# define remove rpl_remove 1460# define remove rpl_remove
1203# endif 1461# endif
1204_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); 1462_GL_FUNCDECL_RPL (remove, int, (const char *name), _GL_ARG_NONNULL ((1)));
1205_GL_CXXALIAS_RPL (remove, int, (const char *name)); 1463_GL_CXXALIAS_RPL (remove, int, (const char *name));
1206# else 1464# else
1207_GL_CXXALIAS_SYS (remove, int, (const char *name)); 1465_GL_CXXALIAS_SYS (remove, int, (const char *name));
@@ -1210,7 +1468,6 @@ _GL_CXXALIAS_SYS (remove, int, (const char *name));
1210_GL_CXXALIASWARN (remove); 1468_GL_CXXALIASWARN (remove);
1211# endif 1469# endif
1212#elif defined GNULIB_POSIXCHECK 1470#elif defined GNULIB_POSIXCHECK
1213# undef remove
1214/* Assume remove is always declared. */ 1471/* Assume remove is always declared. */
1215_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " 1472_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
1216 "use gnulib module remove for more portability"); 1473 "use gnulib module remove for more portability");
@@ -1223,7 +1480,7 @@ _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
1223# define rename rpl_rename 1480# define rename rpl_rename
1224# endif 1481# endif
1225_GL_FUNCDECL_RPL (rename, int, 1482_GL_FUNCDECL_RPL (rename, int,
1226 (const char *old_filename, const char *new_filename) 1483 (const char *old_filename, const char *new_filename),
1227 _GL_ARG_NONNULL ((1, 2))); 1484 _GL_ARG_NONNULL ((1, 2)));
1228_GL_CXXALIAS_RPL (rename, int, 1485_GL_CXXALIAS_RPL (rename, int,
1229 (const char *old_filename, const char *new_filename)); 1486 (const char *old_filename, const char *new_filename));
@@ -1235,7 +1492,6 @@ _GL_CXXALIAS_SYS (rename, int,
1235_GL_CXXALIASWARN (rename); 1492_GL_CXXALIASWARN (rename);
1236# endif 1493# endif
1237#elif defined GNULIB_POSIXCHECK 1494#elif defined GNULIB_POSIXCHECK
1238# undef rename
1239/* Assume rename is always declared. */ 1495/* Assume rename is always declared. */
1240_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " 1496_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
1241 "use gnulib module rename for more portability"); 1497 "use gnulib module rename for more portability");
@@ -1248,14 +1504,14 @@ _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
1248# define renameat rpl_renameat 1504# define renameat rpl_renameat
1249# endif 1505# endif
1250_GL_FUNCDECL_RPL (renameat, int, 1506_GL_FUNCDECL_RPL (renameat, int,
1251 (int fd1, char const *file1, int fd2, char const *file2) 1507 (int fd1, char const *file1, int fd2, char const *file2),
1252 _GL_ARG_NONNULL ((2, 4))); 1508 _GL_ARG_NONNULL ((2, 4)));
1253_GL_CXXALIAS_RPL (renameat, int, 1509_GL_CXXALIAS_RPL (renameat, int,
1254 (int fd1, char const *file1, int fd2, char const *file2)); 1510 (int fd1, char const *file1, int fd2, char const *file2));
1255# else 1511# else
1256# if !@HAVE_RENAMEAT@ 1512# if !@HAVE_RENAMEAT@
1257_GL_FUNCDECL_SYS (renameat, int, 1513_GL_FUNCDECL_SYS (renameat, int,
1258 (int fd1, char const *file1, int fd2, char const *file2) 1514 (int fd1, char const *file1, int fd2, char const *file2),
1259 _GL_ARG_NONNULL ((2, 4))); 1515 _GL_ARG_NONNULL ((2, 4)));
1260# endif 1516# endif
1261_GL_CXXALIAS_SYS (renameat, int, 1517_GL_CXXALIAS_SYS (renameat, int,
@@ -1263,7 +1519,6 @@ _GL_CXXALIAS_SYS (renameat, int,
1263# endif 1519# endif
1264_GL_CXXALIASWARN (renameat); 1520_GL_CXXALIASWARN (renameat);
1265#elif defined GNULIB_POSIXCHECK 1521#elif defined GNULIB_POSIXCHECK
1266# undef renameat
1267# if HAVE_RAW_DECL_RENAMEAT 1522# if HAVE_RAW_DECL_RENAMEAT
1268_GL_WARN_ON_USE (renameat, "renameat is not portable - " 1523_GL_WARN_ON_USE (renameat, "renameat is not portable - "
1269 "use gnulib module renameat for portability"); 1524 "use gnulib module renameat for portability");
@@ -1281,18 +1536,18 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
1281_GL_FUNCDECL_RPL_1 (__scanf__, int, 1536_GL_FUNCDECL_RPL_1 (__scanf__, int,
1282 (const char *restrict format, ...) 1537 (const char *restrict format, ...)
1283 __asm__ (@ASM_SYMBOL_PREFIX@ 1538 __asm__ (@ASM_SYMBOL_PREFIX@
1284 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) 1539 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)),
1285 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1540 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1286 _GL_ARG_NONNULL ((1))); 1541 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1287_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...)); 1542_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
1288# else 1543# else
1289# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1544# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1290# undef scanf 1545# undef scanf
1291# define scanf rpl_scanf 1546# define scanf rpl_scanf
1292# endif 1547# endif
1293_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...) 1548_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...),
1294 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1549 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1295 _GL_ARG_NONNULL ((1))); 1550 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1296_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...)); 1551_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
1297# endif 1552# endif
1298# else 1553# else
@@ -1303,7 +1558,31 @@ _GL_CXXALIASWARN (scanf);
1303# endif 1558# endif
1304#endif 1559#endif
1305 1560
1561#if @GNULIB_SNZPRINTF@
1562/* Prints formatted output to string STR. Similar to sprintf, but the
1563 additional parameter SIZE limits how much is written into STR.
1564 STR may be NULL, in which case nothing will be written.
1565 Returns the string length of the formatted string (which may be larger
1566 than SIZE). Upon failure, returns -1 with errno set.
1567 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1568 Therefore, if the format string is valid and does not use %ls/%lc
1569 directives nor widths, the only possible failure code is ENOMEM. */
1570_GL_FUNCDECL_SYS (snzprintf, ptrdiff_t,
1571 (char *restrict str, size_t size,
1572 const char *restrict format, ...),
1573 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1574 _GL_ARG_NONNULL ((3)));
1575_GL_CXXALIAS_SYS (snzprintf, ptrdiff_t,
1576 (char *restrict str, size_t size,
1577 const char *restrict format, ...));
1578#endif
1579
1306#if @GNULIB_SNPRINTF@ 1580#if @GNULIB_SNPRINTF@
1581/* Prints formatted output to string STR. Similar to sprintf, but the
1582 additional parameter SIZE limits how much is written into STR.
1583 STR may be NULL, in which case nothing will be written.
1584 Returns the string length of the formatted string (which may be larger
1585 than SIZE). Upon failure, returns a negative value. */
1307# if @REPLACE_SNPRINTF@ 1586# if @REPLACE_SNPRINTF@
1308# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1587# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1309# define snprintf rpl_snprintf 1588# define snprintf rpl_snprintf
@@ -1311,7 +1590,7 @@ _GL_CXXALIASWARN (scanf);
1311# define GNULIB_overrides_snprintf 1 1590# define GNULIB_overrides_snprintf 1
1312_GL_FUNCDECL_RPL (snprintf, int, 1591_GL_FUNCDECL_RPL (snprintf, int,
1313 (char *restrict str, size_t size, 1592 (char *restrict str, size_t size,
1314 const char *restrict format, ...) 1593 const char *restrict format, ...),
1315 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) 1594 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1316 _GL_ARG_NONNULL ((3))); 1595 _GL_ARG_NONNULL ((3)));
1317_GL_CXXALIAS_RPL (snprintf, int, 1596_GL_CXXALIAS_RPL (snprintf, int,
@@ -1321,7 +1600,7 @@ _GL_CXXALIAS_RPL (snprintf, int,
1321# if !@HAVE_DECL_SNPRINTF@ 1600# if !@HAVE_DECL_SNPRINTF@
1322_GL_FUNCDECL_SYS (snprintf, int, 1601_GL_FUNCDECL_SYS (snprintf, int,
1323 (char *restrict str, size_t size, 1602 (char *restrict str, size_t size,
1324 const char *restrict format, ...) 1603 const char *restrict format, ...),
1325 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4) 1604 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1326 _GL_ARG_NONNULL ((3))); 1605 _GL_ARG_NONNULL ((3)));
1327# endif 1606# endif
@@ -1333,13 +1612,29 @@ _GL_CXXALIAS_SYS (snprintf, int,
1333_GL_CXXALIASWARN (snprintf); 1612_GL_CXXALIASWARN (snprintf);
1334# endif 1613# endif
1335#elif defined GNULIB_POSIXCHECK 1614#elif defined GNULIB_POSIXCHECK
1336# undef snprintf
1337# if HAVE_RAW_DECL_SNPRINTF 1615# if HAVE_RAW_DECL_SNPRINTF
1338_GL_WARN_ON_USE (snprintf, "snprintf is unportable - " 1616_GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1339 "use gnulib module snprintf for portability"); 1617 "use gnulib module snprintf for portability");
1340# endif 1618# endif
1341#endif 1619#endif
1342 1620
1621#if @GNULIB_SZPRINTF@
1622/* Prints formatted output to string STR.
1623 Returns the string length of the formatted string. Upon failure,
1624 returns -1 with errno set.
1625 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1626 Therefore, if the format string is valid and does not use %ls/%lc
1627 directives nor widths, the only possible failure code is ENOMEM. */
1628_GL_FUNCDECL_SYS (szprintf, ptrdiff_t,
1629 (char *restrict str,
1630 const char *restrict format, ...),
1631 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1632 _GL_ARG_NONNULL ((1, 2)));
1633_GL_CXXALIAS_SYS (szprintf, ptrdiff_t,
1634 (char *restrict str,
1635 const char *restrict format, ...));
1636#endif
1637
1343/* Some people would argue that all sprintf uses should be warned about 1638/* Some people would argue that all sprintf uses should be warned about
1344 (for example, OpenBSD issues a link warning for it), 1639 (for example, OpenBSD issues a link warning for it),
1345 since it can cause security holes due to buffer overruns. 1640 since it can cause security holes due to buffer overruns.
@@ -1350,13 +1645,16 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1350 GNULIB_POSIXCHECK is defined. */ 1645 GNULIB_POSIXCHECK is defined. */
1351 1646
1352#if @GNULIB_SPRINTF_POSIX@ 1647#if @GNULIB_SPRINTF_POSIX@
1648/* Prints formatted output to string STR.
1649 Returns the string length of the formatted string. Upon failure,
1650 returns a negative value. */
1353# if @REPLACE_SPRINTF@ 1651# if @REPLACE_SPRINTF@
1354# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1652# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1355# define sprintf rpl_sprintf 1653# define sprintf rpl_sprintf
1356# endif 1654# endif
1357# define GNULIB_overrides_sprintf 1 1655# define GNULIB_overrides_sprintf 1
1358_GL_FUNCDECL_RPL (sprintf, int, 1656_GL_FUNCDECL_RPL (sprintf, int,
1359 (char *restrict str, const char *restrict format, ...) 1657 (char *restrict str, const char *restrict format, ...),
1360 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1658 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1361 _GL_ARG_NONNULL ((1, 2))); 1659 _GL_ARG_NONNULL ((1, 2)));
1362_GL_CXXALIAS_RPL (sprintf, int, 1660_GL_CXXALIAS_RPL (sprintf, int,
@@ -1369,7 +1667,6 @@ _GL_CXXALIAS_SYS (sprintf, int,
1369_GL_CXXALIASWARN (sprintf); 1667_GL_CXXALIASWARN (sprintf);
1370# endif 1668# endif
1371#elif defined GNULIB_POSIXCHECK 1669#elif defined GNULIB_POSIXCHECK
1372# undef sprintf
1373/* Assume sprintf is always declared. */ 1670/* Assume sprintf is always declared. */
1374_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " 1671_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1375 "use gnulib module sprintf-posix for portable " 1672 "use gnulib module sprintf-posix for portable "
@@ -1397,14 +1694,18 @@ _GL_CXXALIASWARN (tempnam);
1397# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1694# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1398# define tmpfile rpl_tmpfile 1695# define tmpfile rpl_tmpfile
1399# endif 1696# endif
1400_GL_FUNCDECL_RPL (tmpfile, FILE *, (void) 1697_GL_FUNCDECL_RPL (tmpfile, FILE *, (void),
1401 _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 1698 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1699 _GL_ATTRIBUTE_MALLOC
1700 _GL_ATTRIBUTE_NODISCARD);
1402_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); 1701_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1403# else 1702# else
1404# if __GNUC__ >= 11 1703# if __GNUC__ >= 11 && !defined __clang__
1405/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ 1704/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1406_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) 1705_GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
1407 _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 1706 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1707 _GL_ATTRIBUTE_MALLOC
1708 _GL_ATTRIBUTE_NODISCARD);
1408# endif 1709# endif
1409_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); 1710_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1410# endif 1711# endif
@@ -1412,13 +1713,14 @@ _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1412_GL_CXXALIASWARN (tmpfile); 1713_GL_CXXALIASWARN (tmpfile);
1413# endif 1714# endif
1414#else 1715#else
1415# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile 1716# if @GNULIB_FCLOSE@ \
1717 && (__GNUC__ >= 11 && !defined __clang__) && !defined tmpfile
1416/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */ 1718/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1417_GL_FUNCDECL_SYS (tmpfile, FILE *, (void) 1719_GL_FUNCDECL_SYS (tmpfile, FILE *, (void),
1418 _GL_ATTRIBUTE_DEALLOC (fclose, 1)); 1720 _GL_ATTRIBUTE_DEALLOC (fclose, 1)
1721 _GL_ATTRIBUTE_MALLOC);
1419# endif 1722# endif
1420# if defined GNULIB_POSIXCHECK 1723# if defined GNULIB_POSIXCHECK
1421# undef tmpfile
1422# if HAVE_RAW_DECL_TMPFILE 1724# if HAVE_RAW_DECL_TMPFILE
1423_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " 1725_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1424 "use gnulib module tmpfile for portability"); 1726 "use gnulib module tmpfile for portability");
@@ -1426,6 +1728,31 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1426# endif 1728# endif
1427#endif 1729#endif
1428 1730
1731#if @GNULIB_VASZPRINTF@
1732/* Prints formatted output to a string dynamically allocated with malloc().
1733 If the memory allocation succeeds, it stores the address of the string in
1734 *RESULT and returns the number of resulting bytes, excluding the trailing
1735 NUL. Upon memory allocation error, or some other error, it returns -1
1736 with errno set.
1737 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1738 Therefore, if the format string is valid and does not use %ls/%lc
1739 directives nor widths, the only possible failure code is ENOMEM. */
1740_GL_FUNCDECL_SYS (aszprintf, ptrdiff_t,
1741 (char **result, const char *format, ...),
1742 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1743 _GL_ARG_NONNULL ((1, 2))
1744 _GL_ATTRIBUTE_NODISCARD);
1745_GL_CXXALIAS_SYS (aszprintf, ptrdiff_t,
1746 (char **result, const char *format, ...));
1747_GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t,
1748 (char **result, const char *format, va_list args),
1749 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1750 _GL_ARG_NONNULL ((1, 2))
1751 _GL_ATTRIBUTE_NODISCARD);
1752_GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t,
1753 (char **result, const char *format, va_list args));
1754#endif
1755
1429#if @GNULIB_VASPRINTF@ 1756#if @GNULIB_VASPRINTF@
1430/* Write formatted output to a string dynamically allocated with malloc(). 1757/* Write formatted output to a string dynamically allocated with malloc().
1431 If the memory allocation succeeds, store the address of the string in 1758 If the memory allocation succeeds, store the address of the string in
@@ -1437,17 +1764,19 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1437# endif 1764# endif
1438# define GNULIB_overrides_asprintf 1765# define GNULIB_overrides_asprintf
1439_GL_FUNCDECL_RPL (asprintf, int, 1766_GL_FUNCDECL_RPL (asprintf, int,
1440 (char **result, const char *format, ...) 1767 (char **result, const char *format, ...),
1441 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1768 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1442 _GL_ARG_NONNULL ((1, 2))); 1769 _GL_ARG_NONNULL ((1, 2))
1770 _GL_ATTRIBUTE_NODISCARD);
1443_GL_CXXALIAS_RPL (asprintf, int, 1771_GL_CXXALIAS_RPL (asprintf, int,
1444 (char **result, const char *format, ...)); 1772 (char **result, const char *format, ...));
1445# else 1773# else
1446# if !@HAVE_VASPRINTF@ 1774# if !@HAVE_VASPRINTF@
1447_GL_FUNCDECL_SYS (asprintf, int, 1775_GL_FUNCDECL_SYS (asprintf, int,
1448 (char **result, const char *format, ...) 1776 (char **result, const char *format, ...),
1449 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3) 1777 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1450 _GL_ARG_NONNULL ((1, 2))); 1778 _GL_ARG_NONNULL ((1, 2))
1779 _GL_ATTRIBUTE_NODISCARD);
1451# endif 1780# endif
1452_GL_CXXALIAS_SYS (asprintf, int, 1781_GL_CXXALIAS_SYS (asprintf, int,
1453 (char **result, const char *format, ...)); 1782 (char **result, const char *format, ...));
@@ -1459,17 +1788,19 @@ _GL_CXXALIASWARN (asprintf);
1459# endif 1788# endif
1460# define GNULIB_overrides_vasprintf 1 1789# define GNULIB_overrides_vasprintf 1
1461_GL_FUNCDECL_RPL (vasprintf, int, 1790_GL_FUNCDECL_RPL (vasprintf, int,
1462 (char **result, const char *format, va_list args) 1791 (char **result, const char *format, va_list args),
1463 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1792 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1464 _GL_ARG_NONNULL ((1, 2))); 1793 _GL_ARG_NONNULL ((1, 2))
1794 _GL_ATTRIBUTE_NODISCARD);
1465_GL_CXXALIAS_RPL (vasprintf, int, 1795_GL_CXXALIAS_RPL (vasprintf, int,
1466 (char **result, const char *format, va_list args)); 1796 (char **result, const char *format, va_list args));
1467# else 1797# else
1468# if !@HAVE_VASPRINTF@ 1798# if !@HAVE_VASPRINTF@
1469_GL_FUNCDECL_SYS (vasprintf, int, 1799_GL_FUNCDECL_SYS (vasprintf, int,
1470 (char **result, const char *format, va_list args) 1800 (char **result, const char *format, va_list args),
1471 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1801 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1472 _GL_ARG_NONNULL ((1, 2))); 1802 _GL_ARG_NONNULL ((1, 2))
1803 _GL_ATTRIBUTE_NODISCARD);
1473# endif 1804# endif
1474_GL_CXXALIAS_SYS (vasprintf, int, 1805_GL_CXXALIAS_SYS (vasprintf, int,
1475 (char **result, const char *format, va_list args)); 1806 (char **result, const char *format, va_list args));
@@ -1477,13 +1808,32 @@ _GL_CXXALIAS_SYS (vasprintf, int,
1477_GL_CXXALIASWARN (vasprintf); 1808_GL_CXXALIASWARN (vasprintf);
1478#endif 1809#endif
1479 1810
1811#if @GNULIB_VDZPRINTF@
1812/* Prints formatted output to file descriptor FD.
1813 Returns the number of bytes written to the file descriptor. Upon
1814 failure, returns -1 with errno set.
1815 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
1816 Therefore, if the format string is valid and does not use %ls/%lc
1817 directives nor widths, the only possible failure codes are ENOMEM
1818 and the possible failure codes from write(), excluding EINTR. */
1819_GL_FUNCDECL_SYS (vdzprintf, off64_t,
1820 (int fd, const char *restrict format, va_list args),
1821 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1822 _GL_ARG_NONNULL ((2)));
1823_GL_CXXALIAS_SYS (vdzprintf, off64_t,
1824 (int fd, const char *restrict format, va_list args));
1825#endif
1826
1480#if @GNULIB_VDPRINTF@ 1827#if @GNULIB_VDPRINTF@
1828/* Prints formatted output to file descriptor FD.
1829 Returns the number of bytes written to the file descriptor. Upon
1830 failure, returns a negative value. */
1481# if @REPLACE_VDPRINTF@ 1831# if @REPLACE_VDPRINTF@
1482# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1832# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1483# define vdprintf rpl_vdprintf 1833# define vdprintf rpl_vdprintf
1484# endif 1834# endif
1485_GL_FUNCDECL_RPL (vdprintf, int, 1835_GL_FUNCDECL_RPL (vdprintf, int,
1486 (int fd, const char *restrict format, va_list args) 1836 (int fd, const char *restrict format, va_list args),
1487 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1837 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1488 _GL_ARG_NONNULL ((2))); 1838 _GL_ARG_NONNULL ((2)));
1489_GL_CXXALIAS_RPL (vdprintf, int, 1839_GL_CXXALIAS_RPL (vdprintf, int,
@@ -1491,7 +1841,7 @@ _GL_CXXALIAS_RPL (vdprintf, int,
1491# else 1841# else
1492# if !@HAVE_VDPRINTF@ 1842# if !@HAVE_VDPRINTF@
1493_GL_FUNCDECL_SYS (vdprintf, int, 1843_GL_FUNCDECL_SYS (vdprintf, int,
1494 (int fd, const char *restrict format, va_list args) 1844 (int fd, const char *restrict format, va_list args),
1495 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1845 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1496 _GL_ARG_NONNULL ((2))); 1846 _GL_ARG_NONNULL ((2)));
1497# endif 1847# endif
@@ -1504,14 +1854,34 @@ _GL_CXXALIAS_SYS_CAST (vdprintf, int,
1504_GL_CXXALIASWARN (vdprintf); 1854_GL_CXXALIASWARN (vdprintf);
1505# endif 1855# endif
1506#elif defined GNULIB_POSIXCHECK 1856#elif defined GNULIB_POSIXCHECK
1507# undef vdprintf
1508# if HAVE_RAW_DECL_VDPRINTF 1857# if HAVE_RAW_DECL_VDPRINTF
1509_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " 1858_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1510 "use gnulib module vdprintf for portability"); 1859 "use gnulib module vdprintf for portability");
1511# endif 1860# endif
1512#endif 1861#endif
1513 1862
1863#if @GNULIB_VFZPRINTF@
1864/* Prints formatted output to stream FP.
1865 Returns the number of bytes written to the stream. Upon failure,
1866 returns -1 with the stream's error indicator set.
1867 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1868 Therefore, if the format string is valid and does not use %ls/%lc
1869 directives nor widths, the only possible failure causes are ENOMEM
1870 and the possible failure causes from fwrite(). */
1871_GL_FUNCDECL_SYS (vfzprintf, off64_t,
1872 (FILE *restrict fp,
1873 const char *restrict format, va_list args),
1874 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1875 _GL_ARG_NONNULL ((1, 2)));
1876_GL_CXXALIAS_SYS (vfzprintf, off64_t,
1877 (FILE *restrict fp,
1878 const char *restrict format, va_list args));
1879#endif
1880
1514#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ 1881#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
1882/* Prints formatted output to stream FP.
1883 Returns the number of bytes written to the stream. Upon failure,
1884 returns a negative value with the stream's error indicator set. */
1515# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ 1885# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
1516 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1886 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1517# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1887# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1521,13 +1891,13 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1521# if @GNULIB_VFPRINTF_POSIX@ 1891# if @GNULIB_VFPRINTF_POSIX@
1522_GL_FUNCDECL_RPL (vfprintf, int, 1892_GL_FUNCDECL_RPL (vfprintf, int,
1523 (FILE *restrict fp, 1893 (FILE *restrict fp,
1524 const char *restrict format, va_list args) 1894 const char *restrict format, va_list args),
1525 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 1895 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1526 _GL_ARG_NONNULL ((1, 2))); 1896 _GL_ARG_NONNULL ((1, 2)));
1527# else 1897# else
1528_GL_FUNCDECL_RPL (vfprintf, int, 1898_GL_FUNCDECL_RPL (vfprintf, int,
1529 (FILE *restrict fp, 1899 (FILE *restrict fp,
1530 const char *restrict format, va_list args) 1900 const char *restrict format, va_list args),
1531 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) 1901 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1532 _GL_ARG_NONNULL ((1, 2))); 1902 _GL_ARG_NONNULL ((1, 2)));
1533# endif 1903# endif
@@ -1545,11 +1915,13 @@ _GL_CXXALIAS_SYS_CAST (vfprintf, int,
1545# if __GLIBC__ >= 2 1915# if __GLIBC__ >= 2
1546_GL_CXXALIASWARN (vfprintf); 1916_GL_CXXALIASWARN (vfprintf);
1547# endif 1917# endif
1548#endif 1918#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1549#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1919# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1550# if !GNULIB_overrides_vfprintf
1551# undef vfprintf 1920# undef vfprintf
1921# define vfprintf gl_consolesafe_vfprintf
1552# endif 1922# endif
1923#endif
1924#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1553/* Assume vfprintf is always declared. */ 1925/* Assume vfprintf is always declared. */
1554_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " 1926_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1555 "use gnulib module vfprintf-posix for portable " 1927 "use gnulib module vfprintf-posix for portable "
@@ -1564,9 +1936,9 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1564# endif 1936# endif
1565_GL_FUNCDECL_RPL (vfscanf, int, 1937_GL_FUNCDECL_RPL (vfscanf, int,
1566 (FILE *restrict stream, 1938 (FILE *restrict stream,
1567 const char *restrict format, va_list args) 1939 const char *restrict format, va_list args),
1568 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) 1940 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1569 _GL_ARG_NONNULL ((1, 2))); 1941 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1570_GL_CXXALIAS_RPL (vfscanf, int, 1942_GL_CXXALIAS_RPL (vfscanf, int,
1571 (FILE *restrict stream, 1943 (FILE *restrict stream,
1572 const char *restrict format, va_list args)); 1944 const char *restrict format, va_list args));
@@ -1580,7 +1952,26 @@ _GL_CXXALIASWARN (vfscanf);
1580# endif 1952# endif
1581#endif 1953#endif
1582 1954
1955#if @GNULIB_VZPRINTF@
1956/* Prints formatted output to standard output.
1957 Returns the number of bytes written to standard output. Upon failure,
1958 returns -1 with stdout's error indicator set.
1959 Failure cause EOVERFLOW can only occur when a width > INT_MAX is used.
1960 Therefore, if the format string is valid and does not use %ls/%lc
1961 directives nor widths, the only possible failure causes are ENOMEM
1962 and the possible failure causes from fwrite(). */
1963_GL_FUNCDECL_SYS (vzprintf, off64_t,
1964 (const char *restrict format, va_list args),
1965 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1966 _GL_ARG_NONNULL ((1)));
1967_GL_CXXALIAS_SYS (vzprintf, off64_t,
1968 (const char *restrict format, va_list args));
1969#endif
1970
1583#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1971#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
1972/* Prints formatted output to standard output.
1973 Returns the number of bytes written to standard output. Upon failure,
1974 returns a negative value with stdout's error indicator set. */
1584# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ 1975# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
1585 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1976 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1586# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1977# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1588,11 +1979,11 @@ _GL_CXXALIASWARN (vfscanf);
1588# endif 1979# endif
1589# define GNULIB_overrides_vprintf 1 1980# define GNULIB_overrides_vprintf 1
1590# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 1981# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1591_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) 1982_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
1592 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0) 1983 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1593 _GL_ARG_NONNULL ((1))); 1984 _GL_ARG_NONNULL ((1)));
1594# else 1985# else
1595_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args) 1986_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args),
1596 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) 1987 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1597 _GL_ARG_NONNULL ((1))); 1988 _GL_ARG_NONNULL ((1)));
1598# endif 1989# endif
@@ -1607,11 +1998,13 @@ _GL_CXXALIAS_SYS_CAST (vprintf, int,
1607# if __GLIBC__ >= 2 1998# if __GLIBC__ >= 2
1608_GL_CXXALIASWARN (vprintf); 1999_GL_CXXALIASWARN (vprintf);
1609# endif 2000# endif
1610#endif 2001#elif defined __MINGW32__ && !defined _UCRT && __USE_MINGW_ANSI_STDIO
1611#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 2002# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1612# if !GNULIB_overrides_vprintf
1613# undef vprintf 2003# undef vprintf
2004# define vprintf gl_consolesafe_vprintf
1614# endif 2005# endif
2006#endif
2007#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1615/* Assume vprintf is always declared. */ 2008/* Assume vprintf is always declared. */
1616_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " 2009_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1617 "use gnulib module vprintf-posix for portable " 2010 "use gnulib module vprintf-posix for portable "
@@ -1624,9 +2017,9 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1624# undef vscanf 2017# undef vscanf
1625# define vscanf rpl_vscanf 2018# define vscanf rpl_vscanf
1626# endif 2019# endif
1627_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args) 2020_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args),
1628 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) 2021 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1629 _GL_ARG_NONNULL ((1))); 2022 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1630_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); 2023_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1631# else 2024# else
1632_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); 2025_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
@@ -1636,7 +2029,31 @@ _GL_CXXALIASWARN (vscanf);
1636# endif 2029# endif
1637#endif 2030#endif
1638 2031
2032#if @GNULIB_VSNZPRINTF@
2033/* Prints formatted output to string STR. Similar to sprintf, but the
2034 additional parameter SIZE limits how much is written into STR.
2035 STR may be NULL, in which case nothing will be written.
2036 Returns the string length of the formatted string (which may be larger
2037 than SIZE). Upon failure, returns -1 with errno set.
2038 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2039 Therefore, if the format string is valid and does not use %ls/%lc
2040 directives nor widths, the only possible failure code is ENOMEM. */
2041_GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t,
2042 (char *restrict str, size_t size,
2043 const char *restrict format, va_list args),
2044 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
2045 _GL_ARG_NONNULL ((3)));
2046_GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t,
2047 (char *restrict str, size_t size,
2048 const char *restrict format, va_list args));
2049#endif
2050
1639#if @GNULIB_VSNPRINTF@ 2051#if @GNULIB_VSNPRINTF@
2052/* Prints formatted output to string STR. Similar to vsprintf, but the
2053 additional parameter SIZE limits how much is written into STR.
2054 STR may be NULL, in which case nothing will be written.
2055 Returns the string length of the formatted string (which may be larger
2056 than SIZE). Upon failure, returns a negative value. */
1640# if @REPLACE_VSNPRINTF@ 2057# if @REPLACE_VSNPRINTF@
1641# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2058# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1642# define vsnprintf rpl_vsnprintf 2059# define vsnprintf rpl_vsnprintf
@@ -1644,7 +2061,7 @@ _GL_CXXALIASWARN (vscanf);
1644# define GNULIB_overrides_vsnprintf 1 2061# define GNULIB_overrides_vsnprintf 1
1645_GL_FUNCDECL_RPL (vsnprintf, int, 2062_GL_FUNCDECL_RPL (vsnprintf, int,
1646 (char *restrict str, size_t size, 2063 (char *restrict str, size_t size,
1647 const char *restrict format, va_list args) 2064 const char *restrict format, va_list args),
1648 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) 2065 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1649 _GL_ARG_NONNULL ((3))); 2066 _GL_ARG_NONNULL ((3)));
1650_GL_CXXALIAS_RPL (vsnprintf, int, 2067_GL_CXXALIAS_RPL (vsnprintf, int,
@@ -1654,7 +2071,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int,
1654# if !@HAVE_DECL_VSNPRINTF@ 2071# if !@HAVE_DECL_VSNPRINTF@
1655_GL_FUNCDECL_SYS (vsnprintf, int, 2072_GL_FUNCDECL_SYS (vsnprintf, int,
1656 (char *restrict str, size_t size, 2073 (char *restrict str, size_t size,
1657 const char *restrict format, va_list args) 2074 const char *restrict format, va_list args),
1658 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) 2075 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1659 _GL_ARG_NONNULL ((3))); 2076 _GL_ARG_NONNULL ((3)));
1660# endif 2077# endif
@@ -1666,14 +2083,33 @@ _GL_CXXALIAS_SYS (vsnprintf, int,
1666_GL_CXXALIASWARN (vsnprintf); 2083_GL_CXXALIASWARN (vsnprintf);
1667# endif 2084# endif
1668#elif defined GNULIB_POSIXCHECK 2085#elif defined GNULIB_POSIXCHECK
1669# undef vsnprintf
1670# if HAVE_RAW_DECL_VSNPRINTF 2086# if HAVE_RAW_DECL_VSNPRINTF
1671_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " 2087_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1672 "use gnulib module vsnprintf for portability"); 2088 "use gnulib module vsnprintf for portability");
1673# endif 2089# endif
1674#endif 2090#endif
1675 2091
2092#if @GNULIB_VSZPRINTF@
2093/* Prints formatted output to string STR.
2094 Returns the string length of the formatted string. Upon failure,
2095 returns -1 with errno set.
2096 Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
2097 Therefore, if the format string is valid and does not use %ls/%lc
2098 directives nor widths, the only possible failure code is ENOMEM. */
2099_GL_FUNCDECL_SYS (vszprintf, ptrdiff_t,
2100 (char *restrict str,
2101 const char *restrict format, va_list args),
2102 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
2103 _GL_ARG_NONNULL ((1, 2)));
2104_GL_CXXALIAS_SYS (vszprintf, ptrdiff_t,
2105 (char *restrict str,
2106 const char *restrict format, va_list args));
2107#endif
2108
1676#if @GNULIB_VSPRINTF_POSIX@ 2109#if @GNULIB_VSPRINTF_POSIX@
2110/* Prints formatted output to string STR.
2111 Returns the string length of the formatted string. Upon failure,
2112 returns a negative value. */
1677# if @REPLACE_VSPRINTF@ 2113# if @REPLACE_VSPRINTF@
1678# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2114# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1679# define vsprintf rpl_vsprintf 2115# define vsprintf rpl_vsprintf
@@ -1681,7 +2117,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1681# define GNULIB_overrides_vsprintf 1 2117# define GNULIB_overrides_vsprintf 1
1682_GL_FUNCDECL_RPL (vsprintf, int, 2118_GL_FUNCDECL_RPL (vsprintf, int,
1683 (char *restrict str, 2119 (char *restrict str,
1684 const char *restrict format, va_list args) 2120 const char *restrict format, va_list args),
1685 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0) 2121 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1686 _GL_ARG_NONNULL ((1, 2))); 2122 _GL_ARG_NONNULL ((1, 2)));
1687_GL_CXXALIAS_RPL (vsprintf, int, 2123_GL_CXXALIAS_RPL (vsprintf, int,
@@ -1699,7 +2135,6 @@ _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1699_GL_CXXALIASWARN (vsprintf); 2135_GL_CXXALIASWARN (vsprintf);
1700# endif 2136# endif
1701#elif defined GNULIB_POSIXCHECK 2137#elif defined GNULIB_POSIXCHECK
1702# undef vsprintf
1703/* Assume vsprintf is always declared. */ 2138/* Assume vsprintf is always declared. */
1704_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " 2139_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1705 "use gnulib module vsprintf-posix for portable " 2140 "use gnulib module vsprintf-posix for portable "
diff --git a/gl/stdlib.c b/gl/stdlib.c
new file mode 100644
index 00000000..f51a25c3
--- /dev/null
+++ b/gl/stdlib.c
@@ -0,0 +1,21 @@
1/* Inline functions for <stdlib.h>.
2
3 Copyright (C) 2024-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#define _GL_STDLIB_INLINE _GL_EXTERN_INLINE
19#include <config.h>
20
21#include <stdlib.h>
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index b79e5f70..95237f2a 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2023 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,12 +20,27 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc 23#if ((defined __need_system_stdlib_h && !defined _GLIBCXX_STDLIB_H) \
24 || defined __need_malloc_and_calloc) \
25 && !defined __SUNPRO_CC
24/* Special invocation conventions inside some gnulib header files, 26/* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */ 27 and inside some glibc header files, respectively.
28 Do not recognize this special invocation convention when GCC's
29 c++/11/stdlib.h is being included or has been included. This is needed
30 to support the use of clang+llvm binaries on Ubuntu 22.04 with
31 CXX="$clangdir/bin/clang++ -I/usr/include/c++/11 \
32 -I/usr/include/x86_64-linux-gnu/c++/11
33 -L/usr/lib/gcc/x86_64-linux-gnu/11
34 -Wl,-rpath,$clangdir/lib"
35 because in this case /usr/include/c++/11/stdlib.h (which does not support
36 the convention) is seen before the gnulib-generated stdlib.h. */
26 37
27#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 38#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
28 39
40/* Make sure that the macros that indicate the special invocation convention
41 get undefined. This is needed at least on CentOS 7. */
42#undef __need_malloc_and_calloc
43
29#else 44#else
30/* Normal invocation convention. */ 45/* Normal invocation convention. */
31 46
@@ -37,14 +52,16 @@
37#ifndef _@GUARD_PREFIX@_STDLIB_H 52#ifndef _@GUARD_PREFIX@_STDLIB_H
38#define _@GUARD_PREFIX@_STDLIB_H 53#define _@GUARD_PREFIX@_STDLIB_H
39 54
55/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
56 _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE,
57 _GL_INLINE_HEADER_BEGIN, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
58#if !_GL_CONFIG_H_INCLUDED
59 #error "Please include config.h first."
60#endif
61
40/* NetBSD 5.0 mis-defines NULL. */ 62/* NetBSD 5.0 mis-defines NULL. */
41#include <stddef.h> 63#include <stddef.h>
42 64
43/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
44#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
45# include <sys/wait.h>
46#endif
47
48/* Solaris declares getloadavg() in <sys/loadavg.h>. */ 65/* Solaris declares getloadavg() in <sys/loadavg.h>. */
49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ 66#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
50/* OpenIndiana has a bug: <sys/time.h> must be included before 67/* OpenIndiana has a bug: <sys/time.h> must be included before
@@ -53,6 +70,11 @@
53# include <sys/loadavg.h> 70# include <sys/loadavg.h>
54#endif 71#endif
55 72
73/* QNX declares getprogname() in <sys/process.h>. */
74#if (@GNULIB_GETPROGNAME@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_PROCESS_H@
75# include <sys/process.h>
76#endif
77
56/* Native Windows platforms declare _mktemp() in <io.h>. */ 78/* Native Windows platforms declare _mktemp() in <io.h>. */
57#if defined _WIN32 && !defined __CYGWIN__ 79#if defined _WIN32 && !defined __CYGWIN__
58# include <io.h> 80# include <io.h>
@@ -60,16 +82,7 @@
60 82
61#if @GNULIB_RANDOM_R@ 83#if @GNULIB_RANDOM_R@
62 84
63/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included 85# include <stdint.h>
64 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
65 'struct random_data'. */
66# if @HAVE_RANDOM_H@
67# include <random.h>
68# endif
69
70# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
71# include <stdint.h>
72# endif
73 86
74# if !@HAVE_STRUCT_RANDOM_DATA@ 87# if !@HAVE_STRUCT_RANDOM_DATA@
75/* Define 'struct random_data'. 88/* Define 'struct random_data'.
@@ -99,11 +112,30 @@ struct random_data
99# include <unistd.h> 112# include <unistd.h>
100#endif 113#endif
101 114
115#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && (defined __sun || defined _AIX)
116/* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro
117 below, this may cause compilation errors later in the libstdc++ header files
118 (that are part of GCC), such as:
119 error: 'rpl_strtol' is not a member of 'std'
120 To avoid this, include the relevant header files here, before these symbols
121 get defined as macros. But do so only on Solaris 11 and AIX (where it is
122 needed), not on mingw (where it would cause other compilation errors). */
123# include <string>
124#endif
125
126_GL_INLINE_HEADER_BEGIN
127#ifndef _GL_STDLIB_INLINE
128# define _GL_STDLIB_INLINE _GL_INLINE
129#endif
130#ifndef _GL_REALLOC_INLINE
131# define _GL_REALLOC_INLINE _GL_INLINE
132#endif
133
102/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 134/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
103 that can be freed by passing them as the Ith argument to the 135 that can be freed by passing them as the Ith argument to the
104 function F. */ 136 function F. */
105#ifndef _GL_ATTRIBUTE_DEALLOC 137#ifndef _GL_ATTRIBUTE_DEALLOC
106# if __GNUC__ >= 11 138# if __GNUC__ >= 11 && !defined __clang__
107# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 139# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
108# else 140# else
109# define _GL_ATTRIBUTE_DEALLOC(f, i) 141# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -128,6 +160,40 @@ struct random_data
128# endif 160# endif
129#endif 161#endif
130 162
163/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
164 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
165/* Applies to: functions. */
166#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
167# if __GNUC__ >= 15 && !defined __clang__
168# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
169 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
170# else
171# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
172# endif
173#endif
174
175/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
176 */
177#ifndef _GL_ATTRIBUTE_NOTHROW
178# if defined __cplusplus
179# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
180# if __cplusplus >= 201103L
181# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
182# else
183# define _GL_ATTRIBUTE_NOTHROW throw ()
184# endif
185# else
186# define _GL_ATTRIBUTE_NOTHROW
187# endif
188# else
189# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
190# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
191# else
192# define _GL_ATTRIBUTE_NOTHROW
193# endif
194# endif
195#endif
196
131/* The __attribute__ feature is available in gcc versions 2.5 and later. 197/* The __attribute__ feature is available in gcc versions 2.5 and later.
132 The attribute __pure__ was added in gcc 2.96. */ 198 The attribute __pure__ was added in gcc 2.96. */
133#ifndef _GL_ATTRIBUTE_PURE 199#ifndef _GL_ATTRIBUTE_PURE
@@ -161,16 +227,38 @@ struct random_data
161#endif 227#endif
162 228
163 229
230/* Declarations for ISO C N3322. */
231#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
232_GL_EXTERN_C void *_GL_FUNCDECL_SYS_NAME (bsearch)
233 (const void *__key, const void *__base, size_t __nmemb, size_t __size,
234 int (*__compare) (const void *, const void *))
235 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3) _GL_ARG_NONNULL ((5));
236_GL_EXTERN_C void qsort (void *__base, size_t __nmemb, size_t __size,
237 int (*__compare) (const void *, const void *))
238 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ARG_NONNULL ((4));
239#endif
240
241
164#if @GNULIB__EXIT@ 242#if @GNULIB__EXIT@
165/* Terminate the current process with the given return code, without running 243/* Terminate the current process with the given return code, without running
166 the 'atexit' handlers. */ 244 the 'atexit' handlers. */
167# if !@HAVE__EXIT@ 245# if @REPLACE__EXIT@
168_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); 246# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
169# endif 247# undef _Exit
248# define _Exit rpl__Exit
249# endif
250_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status), );
251_GL_CXXALIAS_RPL (_Exit, void, (int status));
252# else
253# if !@HAVE__EXIT@
254_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status), );
255# endif
170_GL_CXXALIAS_SYS (_Exit, void, (int status)); 256_GL_CXXALIAS_SYS (_Exit, void, (int status));
257# endif
258# if __GLIBC__ >= 2
171_GL_CXXALIASWARN (_Exit); 259_GL_CXXALIASWARN (_Exit);
260# endif
172#elif defined GNULIB_POSIXCHECK 261#elif defined GNULIB_POSIXCHECK
173# undef _Exit
174# if HAVE_RAW_DECL__EXIT 262# if HAVE_RAW_DECL__EXIT
175_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " 263_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
176 "use gnulib module _Exit for portability"); 264 "use gnulib module _Exit for portability");
@@ -178,6 +266,26 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
178#endif 266#endif
179 267
180 268
269#if @GNULIB_ABORT_DEBUG@
270/* Terminates the current process with signal SIGABRT.
271 Note: While the original abort() function is safe to call in signal handlers,
272 the overridden abort() function is not. */
273# if @REPLACE_ABORT@
274# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
275# undef abort
276# define abort rpl_abort
277# endif
278_GL_FUNCDECL_RPL (abort, _Noreturn void, (void), );
279_GL_CXXALIAS_RPL (abort, void, (void));
280# else
281_GL_CXXALIAS_SYS (abort, void, (void));
282# endif
283# if __GLIBC__ >= 2
284_GL_CXXALIASWARN (abort);
285# endif
286#endif
287
288
181#if @GNULIB_FREE_POSIX@ 289#if @GNULIB_FREE_POSIX@
182# if @REPLACE_FREE@ 290# if @REPLACE_FREE@
183# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 291# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -185,9 +293,9 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
185# define free rpl_free 293# define free rpl_free
186# endif 294# endif
187# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 295# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
188_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ()); 296_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
189# else 297# else
190_GL_FUNCDECL_RPL (free, void, (void *ptr)); 298_GL_FUNCDECL_RPL (free, void, (void *ptr), );
191# endif 299# endif
192_GL_CXXALIAS_RPL (free, void, (void *ptr)); 300_GL_CXXALIAS_RPL (free, void, (void *ptr));
193# else 301# else
@@ -197,10 +305,9 @@ _GL_CXXALIAS_SYS (free, void, (void *ptr));
197_GL_CXXALIASWARN (free); 305_GL_CXXALIASWARN (free);
198# endif 306# endif
199#elif defined GNULIB_POSIXCHECK 307#elif defined GNULIB_POSIXCHECK
200# undef free
201/* Assume free is always declared. */ 308/* Assume free is always declared. */
202_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " 309_GL_WARN_ON_USE (free, "free is not POSIX:2024 compliant everywhere - "
203 "use gnulib module free for portability"); 310 "use gnulib module free-posix for portability");
204#endif 311#endif
205 312
206 313
@@ -212,16 +319,26 @@ _GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
212# define aligned_alloc rpl_aligned_alloc 319# define aligned_alloc rpl_aligned_alloc
213# endif 320# endif
214_GL_FUNCDECL_RPL (aligned_alloc, void *, 321_GL_FUNCDECL_RPL (aligned_alloc, void *,
215 (size_t alignment, size_t size) 322 (size_t alignment, size_t size),
216 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 323 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
324 _GL_ATTRIBUTE_NODISCARD);
217_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); 325_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
218# else 326# else
219# if @HAVE_ALIGNED_ALLOC@ 327# if @HAVE_ALIGNED_ALLOC@
220# if __GNUC__ >= 11 328# if __GNUC__ >= 11 && !defined __clang__
221/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ 329/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
330# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
222_GL_FUNCDECL_SYS (aligned_alloc, void *, 331_GL_FUNCDECL_SYS (aligned_alloc, void *,
223 (size_t alignment, size_t size) 332 (size_t alignment, size_t size),
224 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 333 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
334 _GL_ATTRIBUTE_NODISCARD)
335 _GL_ATTRIBUTE_NOTHROW;
336# else
337_GL_FUNCDECL_SYS (aligned_alloc, void *,
338 (size_t alignment, size_t size),
339 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
340 _GL_ATTRIBUTE_NODISCARD);
341# endif
225# endif 342# endif
226_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); 343_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
227# endif 344# endif
@@ -230,14 +347,21 @@ _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
230_GL_CXXALIASWARN (aligned_alloc); 347_GL_CXXALIASWARN (aligned_alloc);
231# endif 348# endif
232#else 349#else
233# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc 350# if @GNULIB_FREE_POSIX@ \
351 && (__GNUC__ >= 11 && !defined __clang__) && !defined aligned_alloc
234/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ 352/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
353# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
235_GL_FUNCDECL_SYS (aligned_alloc, void *, 354_GL_FUNCDECL_SYS (aligned_alloc, void *,
236 (size_t alignment, size_t size) 355 (size_t alignment, size_t size),
356 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
357 _GL_ATTRIBUTE_NOTHROW;
358# else
359_GL_FUNCDECL_SYS (aligned_alloc, void *,
360 (size_t alignment, size_t size),
237 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 361 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
362# endif
238# endif 363# endif
239# if defined GNULIB_POSIXCHECK 364# if defined GNULIB_POSIXCHECK
240# undef aligned_alloc
241# if HAVE_RAW_DECL_ALIGNED_ALLOC 365# if HAVE_RAW_DECL_ALIGNED_ALLOC
242_GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - " 366_GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
243 "use gnulib module aligned_alloc for portability"); 367 "use gnulib module aligned_alloc for portability");
@@ -249,14 +373,14 @@ _GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
249/* Parse a signed decimal integer. 373/* Parse a signed decimal integer.
250 Returns the value of the integer. Errors are not detected. */ 374 Returns the value of the integer. Errors are not detected. */
251# if !@HAVE_ATOLL@ 375# if !@HAVE_ATOLL@
252_GL_FUNCDECL_SYS (atoll, long long, (const char *string) 376_GL_FUNCDECL_SYS (atoll, long long,
253 _GL_ATTRIBUTE_PURE 377 (const char *string),
254 _GL_ARG_NONNULL ((1))); 378 _GL_ATTRIBUTE_PURE
379 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
255# endif 380# endif
256_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); 381_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
257_GL_CXXALIASWARN (atoll); 382_GL_CXXALIASWARN (atoll);
258#elif defined GNULIB_POSIXCHECK 383#elif defined GNULIB_POSIXCHECK
259# undef atoll
260# if HAVE_RAW_DECL_ATOLL 384# if HAVE_RAW_DECL_ATOLL
261_GL_WARN_ON_USE (atoll, "atoll is unportable - " 385_GL_WARN_ON_USE (atoll, "atoll is unportable - "
262 "use gnulib module atoll for portability"); 386 "use gnulib module atoll for portability");
@@ -264,22 +388,33 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
264#endif 388#endif
265 389
266#if @GNULIB_CALLOC_POSIX@ 390#if @GNULIB_CALLOC_POSIX@
267# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \ 391# if @REPLACE_CALLOC_FOR_CALLOC_POSIX@ \
268 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@) 392 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
269# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 393# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
394 || _GL_USE_STDLIB_ALLOC)
270# undef calloc 395# undef calloc
271# define calloc rpl_calloc 396# define calloc rpl_calloc
272# endif 397# endif
273_GL_FUNCDECL_RPL (calloc, void *, 398_GL_FUNCDECL_RPL (calloc, void *,
274 (size_t nmemb, size_t size) 399 (size_t nmemb, size_t size),
275 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 400 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
401 _GL_ATTRIBUTE_NODISCARD);
276_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); 402_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
277# else 403# else
278# if __GNUC__ >= 11 404# if __GNUC__ >= 11 && !defined __clang__
279/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ 405/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
406# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
280_GL_FUNCDECL_SYS (calloc, void *, 407_GL_FUNCDECL_SYS (calloc, void *,
281 (size_t nmemb, size_t size) 408 (size_t nmemb, size_t size),
282 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 409 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
410 _GL_ATTRIBUTE_NODISCARD)
411 _GL_ATTRIBUTE_NOTHROW;
412# else
413_GL_FUNCDECL_SYS (calloc, void *,
414 (size_t nmemb, size_t size),
415 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
416 _GL_ATTRIBUTE_NODISCARD);
417# endif
283# endif 418# endif
284_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); 419_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
285# endif 420# endif
@@ -287,14 +422,21 @@ _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
287_GL_CXXALIASWARN (calloc); 422_GL_CXXALIASWARN (calloc);
288# endif 423# endif
289#else 424#else
290# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc 425# if @GNULIB_FREE_POSIX@ \
426 && (__GNUC__ >= 11 && !defined __clang__) && !defined calloc
291/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ 427/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
428# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
292_GL_FUNCDECL_SYS (calloc, void *, 429_GL_FUNCDECL_SYS (calloc, void *,
293 (size_t nmemb, size_t size) 430 (size_t nmemb, size_t size),
431 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
432 _GL_ATTRIBUTE_NOTHROW;
433# else
434_GL_FUNCDECL_SYS (calloc, void *,
435 (size_t nmemb, size_t size),
294 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 436 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
437# endif
295# endif 438# endif
296# if defined GNULIB_POSIXCHECK 439# if defined GNULIB_POSIXCHECK
297# undef calloc
298/* Assume calloc is always declared. */ 440/* Assume calloc is always declared. */
299_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " 441_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
300 "use gnulib module calloc-posix for portability"); 442 "use gnulib module calloc-posix for portability");
@@ -307,16 +449,27 @@ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
307# define canonicalize_file_name rpl_canonicalize_file_name 449# define canonicalize_file_name rpl_canonicalize_file_name
308# endif 450# endif
309_GL_FUNCDECL_RPL (canonicalize_file_name, char *, 451_GL_FUNCDECL_RPL (canonicalize_file_name, char *,
310 (const char *name) 452 (const char *name),
311 _GL_ARG_NONNULL ((1)) 453 _GL_ARG_NONNULL ((1))
312 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 454 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
455 _GL_ATTRIBUTE_NODISCARD);
313_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); 456_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
314# else 457# else
315# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 458# if !@HAVE_CANONICALIZE_FILE_NAME@ || (__GNUC__ >= 11 && !defined __clang__)
459# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
316_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 460_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
317 (const char *name) 461 (const char *name),
318 _GL_ARG_NONNULL ((1)) 462 _GL_ARG_NONNULL ((1))
319 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 463 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
464 _GL_ATTRIBUTE_NODISCARD)
465 _GL_ATTRIBUTE_NOTHROW;
466# else
467_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
468 (const char *name),
469 _GL_ARG_NONNULL ((1))
470 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
471 _GL_ATTRIBUTE_NODISCARD);
472# endif
320# endif 473# endif
321_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); 474_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
322# endif 475# endif
@@ -326,16 +479,24 @@ _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
326# endif 479# endif
327_GL_CXXALIASWARN (canonicalize_file_name); 480_GL_CXXALIASWARN (canonicalize_file_name);
328#else 481#else
329# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name 482# if @GNULIB_FREE_POSIX@ \
483 && (__GNUC__ >= 11 && !defined __clang__) && !defined canonicalize_file_name
330/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or 484/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
331 rpl_free. */ 485 rpl_free. */
486# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
487_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
488 (const char *name),
489 _GL_ARG_NONNULL ((1))
490 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
491 _GL_ATTRIBUTE_NOTHROW;
492# else
332_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 493_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
333 (const char *name) 494 (const char *name),
334 _GL_ARG_NONNULL ((1)) 495 _GL_ARG_NONNULL ((1))
335 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 496 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
497# endif
336# endif 498# endif
337# if defined GNULIB_POSIXCHECK 499# if defined GNULIB_POSIXCHECK
338# undef canonicalize_file_name
339# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME 500# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
340_GL_WARN_ON_USE (canonicalize_file_name, 501_GL_WARN_ON_USE (canonicalize_file_name,
341 "canonicalize_file_name is unportable - " 502 "canonicalize_file_name is unportable - "
@@ -416,20 +577,65 @@ _GL_CXXALIASWARN (gcvt);
416 The three numbers are the load average of the last 1 minute, the last 5 577 The three numbers are the load average of the last 1 minute, the last 5
417 minutes, and the last 15 minutes, respectively. 578 minutes, and the last 15 minutes, respectively.
418 LOADAVG is an array of NELEM numbers. */ 579 LOADAVG is an array of NELEM numbers. */
419# if !@HAVE_DECL_GETLOADAVG@ 580# if @REPLACE_GETLOADAVG@
420_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) 581# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
582# undef getloadavg
583# define getloadavg rpl_getloadavg
584# endif
585_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem),
421 _GL_ARG_NONNULL ((1))); 586 _GL_ARG_NONNULL ((1)));
422# endif 587_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem));
588# else
589# if !@HAVE_DECL_GETLOADAVG@
590_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem),
591 _GL_ARG_NONNULL ((1)));
592# endif
423_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); 593_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
594# endif
595# if __GLIBC__ >= 2
424_GL_CXXALIASWARN (getloadavg); 596_GL_CXXALIASWARN (getloadavg);
597# endif
425#elif defined GNULIB_POSIXCHECK 598#elif defined GNULIB_POSIXCHECK
426# undef getloadavg
427# if HAVE_RAW_DECL_GETLOADAVG 599# if HAVE_RAW_DECL_GETLOADAVG
428_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " 600_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
429 "use gnulib module getloadavg for portability"); 601 "use gnulib module getloadavg for portability");
430# endif 602# endif
431#endif 603#endif
432 604
605#if @GNULIB_GETPROGNAME@
606/* Return the base name of the executing program.
607 On native Windows this will usually end in ".exe" or ".EXE". */
608# if @REPLACE_GETPROGNAME@
609# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
610# undef getprogname
611# define getprogname rpl_getprogname
612# endif
613# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
614_GL_FUNCDECL_RPL (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE);
615# else
616_GL_FUNCDECL_RPL (getprogname, const char *, (void), );
617# endif
618_GL_CXXALIAS_RPL (getprogname, const char *, (void));
619# else
620# if !@HAVE_GETPROGNAME@
621# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
622_GL_FUNCDECL_SYS (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE);
623# else
624_GL_FUNCDECL_SYS (getprogname, const char *, (void), );
625# endif
626# endif
627_GL_CXXALIAS_SYS (getprogname, const char *, (void));
628# endif
629# if __GLIBC__ >= 2
630_GL_CXXALIASWARN (getprogname);
631# endif
632#elif defined GNULIB_POSIXCHECK
633# if HAVE_RAW_DECL_GETPROGNAME
634_GL_WARN_ON_USE (getprogname, "getprogname is unportable - "
635 "use gnulib module getprogname for portability");
636# endif
637#endif
638
433#if @GNULIB_GETSUBOPT@ 639#if @GNULIB_GETSUBOPT@
434/* Assuming *OPTIONP is a comma separated list of elements of the form 640/* Assuming *OPTIONP is a comma separated list of elements of the form
435 "token" or "token=value", getsubopt parses the first of these elements. 641 "token" or "token=value", getsubopt parses the first of these elements.
@@ -442,16 +648,29 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
442 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. 648 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
443 For more details see the POSIX specification. 649 For more details see the POSIX specification.
444 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */ 650 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
445# if !@HAVE_GETSUBOPT@ 651# if @REPLACE_GETSUBOPT@
652# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
653# undef getsubopt
654# define getsubopt rpl_getsubopt
655# endif
656_GL_FUNCDECL_RPL (getsubopt, int,
657 (char **optionp, char *const *tokens, char **valuep),
658 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
659_GL_CXXALIAS_RPL (getsubopt, int,
660 (char **optionp, char *const *tokens, char **valuep));
661# else
662# if !@HAVE_GETSUBOPT@
446_GL_FUNCDECL_SYS (getsubopt, int, 663_GL_FUNCDECL_SYS (getsubopt, int,
447 (char **optionp, char *const *tokens, char **valuep) 664 (char **optionp, char *const *tokens, char **valuep),
448 _GL_ARG_NONNULL ((1, 2, 3))); 665 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
449# endif 666# endif
450_GL_CXXALIAS_SYS (getsubopt, int, 667_GL_CXXALIAS_SYS (getsubopt, int,
451 (char **optionp, char *const *tokens, char **valuep)); 668 (char **optionp, char *const *tokens, char **valuep));
669# endif
670# if __GLIBC__ >= 2
452_GL_CXXALIASWARN (getsubopt); 671_GL_CXXALIASWARN (getsubopt);
672# endif
453#elif defined GNULIB_POSIXCHECK 673#elif defined GNULIB_POSIXCHECK
454# undef getsubopt
455# if HAVE_RAW_DECL_GETSUBOPT 674# if HAVE_RAW_DECL_GETSUBOPT
456_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " 675_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
457 "use gnulib module getsubopt for portability"); 676 "use gnulib module getsubopt for portability");
@@ -462,12 +681,11 @@ _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
462/* Change the ownership and access permission of the slave side of the 681/* Change the ownership and access permission of the slave side of the
463 pseudo-terminal whose master side is specified by FD. */ 682 pseudo-terminal whose master side is specified by FD. */
464# if !@HAVE_GRANTPT@ 683# if !@HAVE_GRANTPT@
465_GL_FUNCDECL_SYS (grantpt, int, (int fd)); 684_GL_FUNCDECL_SYS (grantpt, int, (int fd), );
466# endif 685# endif
467_GL_CXXALIAS_SYS (grantpt, int, (int fd)); 686_GL_CXXALIAS_SYS (grantpt, int, (int fd));
468_GL_CXXALIASWARN (grantpt); 687_GL_CXXALIASWARN (grantpt);
469#elif defined GNULIB_POSIXCHECK 688#elif defined GNULIB_POSIXCHECK
470# undef grantpt
471# if HAVE_RAW_DECL_GRANTPT 689# if HAVE_RAW_DECL_GRANTPT
472_GL_WARN_ON_USE (grantpt, "grantpt is not portable - " 690_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
473 "use gnulib module grantpt for portability"); 691 "use gnulib module grantpt for portability");
@@ -479,7 +697,7 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
479 by never specifying a zero size), so it does not need malloc or 697 by never specifying a zero size), so it does not need malloc or
480 realloc to be redefined. */ 698 realloc to be redefined. */
481#if @GNULIB_MALLOC_POSIX@ 699#if @GNULIB_MALLOC_POSIX@
482# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \ 700# if @REPLACE_MALLOC_FOR_MALLOC_POSIX@ \
483 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@) 701 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
484# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 702# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
485 || _GL_USE_STDLIB_ALLOC) 703 || _GL_USE_STDLIB_ALLOC)
@@ -487,15 +705,25 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
487# define malloc rpl_malloc 705# define malloc rpl_malloc
488# endif 706# endif
489_GL_FUNCDECL_RPL (malloc, void *, 707_GL_FUNCDECL_RPL (malloc, void *,
490 (size_t size) 708 (size_t size),
491 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 709 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
710 _GL_ATTRIBUTE_NODISCARD);
492_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); 711_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
493# else 712# else
494# if __GNUC__ >= 11 713# if __GNUC__ >= 11 && !defined __clang__
495/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ 714/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
715# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
496_GL_FUNCDECL_SYS (malloc, void *, 716_GL_FUNCDECL_SYS (malloc, void *,
497 (size_t size) 717 (size_t size),
498 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 718 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
719 _GL_ATTRIBUTE_NODISCARD)
720 _GL_ATTRIBUTE_NOTHROW;
721# else
722_GL_FUNCDECL_SYS (malloc, void *,
723 (size_t size),
724 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
725 _GL_ATTRIBUTE_NODISCARD);
726# endif
499# endif 727# endif
500_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 728_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
501# endif 729# endif
@@ -503,20 +731,77 @@ _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
503_GL_CXXALIASWARN (malloc); 731_GL_CXXALIASWARN (malloc);
504# endif 732# endif
505#else 733#else
506# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc 734# if @GNULIB_FREE_POSIX@ \
735 && (__GNUC__ >= 11 && !defined __clang__) && !defined malloc
507/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ 736/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
737# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
738_GL_FUNCDECL_SYS (malloc, void *,
739 (size_t size),
740 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
741 _GL_ATTRIBUTE_NOTHROW;
742# else
508_GL_FUNCDECL_SYS (malloc, void *, 743_GL_FUNCDECL_SYS (malloc, void *,
509 (size_t size) 744 (size_t size),
510 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 745 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
746# endif
511# endif 747# endif
512# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 748# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
513# undef malloc
514/* Assume malloc is always declared. */ 749/* Assume malloc is always declared. */
515_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " 750_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
516 "use gnulib module malloc-posix for portability"); 751 "use gnulib module malloc-posix for portability");
517# endif 752# endif
518#endif 753#endif
519 754
755/* Return maximum number of bytes in a multibyte character in the
756 current locale. */
757#if @REPLACE_MB_CUR_MAX@
758# if !GNULIB_defined_MB_CUR_MAX
759_GL_STDLIB_INLINE size_t
760gl_MB_CUR_MAX (void)
761{
762# if 0 < @REPLACE_MB_CUR_MAX@
763 return @REPLACE_MB_CUR_MAX@;
764# else
765 /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */
766 int gl_mb_cur_max = MB_CUR_MAX;
767 return gl_mb_cur_max == 3 ? 4 : gl_mb_cur_max;
768# endif
769}
770# undef MB_CUR_MAX
771# define MB_CUR_MAX gl_MB_CUR_MAX ()
772# define GNULIB_defined_MB_CUR_MAX 1
773# endif
774#endif
775
776/* Convert a string to a wide string. */
777#if @GNULIB_MBSTOWCS@
778# if @REPLACE_MBSTOWCS@
779# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
780# undef mbstowcs
781# define mbstowcs rpl_mbstowcs
782# endif
783_GL_FUNCDECL_RPL (mbstowcs, size_t,
784 (wchar_t *restrict dest, const char *restrict src,
785 size_t len),
786 _GL_ARG_NONNULL ((2)));
787_GL_CXXALIAS_RPL (mbstowcs, size_t,
788 (wchar_t *restrict dest, const char *restrict src,
789 size_t len));
790# else
791_GL_CXXALIAS_SYS (mbstowcs, size_t,
792 (wchar_t *restrict dest, const char *restrict src,
793 size_t len));
794# endif
795# if __GLIBC__ >= 2
796_GL_CXXALIASWARN (mbstowcs);
797# endif
798#elif defined GNULIB_POSIXCHECK
799# if HAVE_RAW_DECL_MBSTOWCS
800_GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - "
801 "use gnulib module mbstowcs for portability");
802# endif
803#endif
804
520/* Convert a multibyte character to a wide character. */ 805/* Convert a multibyte character to a wide character. */
521#if @GNULIB_MBTOWC@ 806#if @GNULIB_MBTOWC@
522# if @REPLACE_MBTOWC@ 807# if @REPLACE_MBTOWC@
@@ -525,13 +810,13 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
525# define mbtowc rpl_mbtowc 810# define mbtowc rpl_mbtowc
526# endif 811# endif
527_GL_FUNCDECL_RPL (mbtowc, int, 812_GL_FUNCDECL_RPL (mbtowc, int,
528 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 813 (wchar_t *restrict pwc, const char *restrict s, size_t n), );
529_GL_CXXALIAS_RPL (mbtowc, int, 814_GL_CXXALIAS_RPL (mbtowc, int,
530 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 815 (wchar_t *restrict pwc, const char *restrict s, size_t n));
531# else 816# else
532# if !@HAVE_MBTOWC@ 817# if !@HAVE_MBTOWC@
533_GL_FUNCDECL_SYS (mbtowc, int, 818_GL_FUNCDECL_SYS (mbtowc, int,
534 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 819 (wchar_t *restrict pwc, const char *restrict s, size_t n), );
535# endif 820# endif
536_GL_CXXALIAS_SYS (mbtowc, int, 821_GL_CXXALIAS_SYS (mbtowc, int,
537 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 822 (wchar_t *restrict pwc, const char *restrict s, size_t n));
@@ -540,7 +825,6 @@ _GL_CXXALIAS_SYS (mbtowc, int,
540_GL_CXXALIASWARN (mbtowc); 825_GL_CXXALIASWARN (mbtowc);
541# endif 826# endif
542#elif defined GNULIB_POSIXCHECK 827#elif defined GNULIB_POSIXCHECK
543# undef mbtowc
544# if HAVE_RAW_DECL_MBTOWC 828# if HAVE_RAW_DECL_MBTOWC
545_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - " 829_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
546 "use gnulib module mbtowc for portability"); 830 "use gnulib module mbtowc for portability");
@@ -554,12 +838,13 @@ _GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
554 Returns TEMPLATE, or a null pointer if it cannot get a unique name. 838 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
555 The directory is created mode 700. */ 839 The directory is created mode 700. */
556# if !@HAVE_MKDTEMP@ 840# if !@HAVE_MKDTEMP@
557_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); 841_GL_FUNCDECL_SYS (mkdtemp, char *,
842 (char * /*template*/),
843 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
558# endif 844# endif
559_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); 845_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
560_GL_CXXALIASWARN (mkdtemp); 846_GL_CXXALIASWARN (mkdtemp);
561#elif defined GNULIB_POSIXCHECK 847#elif defined GNULIB_POSIXCHECK
562# undef mkdtemp
563# if HAVE_RAW_DECL_MKDTEMP 848# if HAVE_RAW_DECL_MKDTEMP
564_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " 849_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
565 "use gnulib module mkdtemp for portability"); 850 "use gnulib module mkdtemp for portability");
@@ -579,14 +864,25 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
579 implementation. 864 implementation.
580 Returns the open file descriptor if successful, otherwise -1 and errno 865 Returns the open file descriptor if successful, otherwise -1 and errno
581 set. */ 866 set. */
582# if !@HAVE_MKOSTEMP@ 867# if @REPLACE_MKOSTEMP@
583_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) 868# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
584 _GL_ARG_NONNULL ((1))); 869# undef mkostemp
585# endif 870# define mkostemp rpl_mkostemp
871# endif
872_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/),
873 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
874_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/));
875# else
876# if !@HAVE_MKOSTEMP@
877_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/),
878 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
879# endif
586_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); 880_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
881# endif
882# if __GLIBC__ >= 2
587_GL_CXXALIASWARN (mkostemp); 883_GL_CXXALIASWARN (mkostemp);
884# endif
588#elif defined GNULIB_POSIXCHECK 885#elif defined GNULIB_POSIXCHECK
589# undef mkostemp
590# if HAVE_RAW_DECL_MKOSTEMP 886# if HAVE_RAW_DECL_MKOSTEMP
591_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " 887_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
592 "use gnulib module mkostemp for portability"); 888 "use gnulib module mkostemp for portability");
@@ -607,16 +903,29 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
607 implementation. 903 implementation.
608 Returns the open file descriptor if successful, otherwise -1 and errno 904 Returns the open file descriptor if successful, otherwise -1 and errno
609 set. */ 905 set. */
610# if !@HAVE_MKOSTEMPS@ 906# if @REPLACE_MKOSTEMPS@
907# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
908# undef mkostemps
909# define mkostemps rpl_mkostemps
910# endif
911_GL_FUNCDECL_RPL (mkostemps, int,
912 (char * /*template*/, int /*suffixlen*/, int /*flags*/),
913 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
914_GL_CXXALIAS_RPL (mkostemps, int,
915 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
916# else
917# if !@HAVE_MKOSTEMPS@
611_GL_FUNCDECL_SYS (mkostemps, int, 918_GL_FUNCDECL_SYS (mkostemps, int,
612 (char * /*template*/, int /*suffixlen*/, int /*flags*/) 919 (char * /*template*/, int /*suffixlen*/, int /*flags*/),
613 _GL_ARG_NONNULL ((1))); 920 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
614# endif 921# endif
615_GL_CXXALIAS_SYS (mkostemps, int, 922_GL_CXXALIAS_SYS (mkostemps, int,
616 (char * /*template*/, int /*suffixlen*/, int /*flags*/)); 923 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
924# endif
925# if __GLIBC__ >= 2
617_GL_CXXALIASWARN (mkostemps); 926_GL_CXXALIASWARN (mkostemps);
927# endif
618#elif defined GNULIB_POSIXCHECK 928#elif defined GNULIB_POSIXCHECK
619# undef mkostemps
620# if HAVE_RAW_DECL_MKOSTEMPS 929# if HAVE_RAW_DECL_MKOSTEMPS
621_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " 930_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
622 "use gnulib module mkostemps for portability"); 931 "use gnulib module mkostemps for portability");
@@ -637,17 +946,18 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
637# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 946# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
638# define mkstemp rpl_mkstemp 947# define mkstemp rpl_mkstemp
639# endif 948# endif
640_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); 949_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/),
950 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
641_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); 951_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
642# else 952# else
643# if ! @HAVE_MKSTEMP@ 953# if ! @HAVE_MKSTEMP@
644_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); 954_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/),
955 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
645# endif 956# endif
646_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); 957_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
647# endif 958# endif
648_GL_CXXALIASWARN (mkstemp); 959_GL_CXXALIASWARN (mkstemp);
649#elif defined GNULIB_POSIXCHECK 960#elif defined GNULIB_POSIXCHECK
650# undef mkstemp
651# if HAVE_RAW_DECL_MKSTEMP 961# if HAVE_RAW_DECL_MKSTEMP
652_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " 962_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
653 "use gnulib module mkstemp for portability"); 963 "use gnulib module mkstemp for portability");
@@ -666,13 +976,12 @@ _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
666 Returns the open file descriptor if successful, otherwise -1 and errno 976 Returns the open file descriptor if successful, otherwise -1 and errno
667 set. */ 977 set. */
668# if !@HAVE_MKSTEMPS@ 978# if !@HAVE_MKSTEMPS@
669_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) 979_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/),
670 _GL_ARG_NONNULL ((1))); 980 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
671# endif 981# endif
672_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); 982_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
673_GL_CXXALIASWARN (mkstemps); 983_GL_CXXALIASWARN (mkstemps);
674#elif defined GNULIB_POSIXCHECK 984#elif defined GNULIB_POSIXCHECK
675# undef mkstemps
676# if HAVE_RAW_DECL_MKSTEMPS 985# if HAVE_RAW_DECL_MKSTEMPS
677_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " 986_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
678 "use gnulib module mkstemps for portability"); 987 "use gnulib module mkstemps for portability");
@@ -703,8 +1012,8 @@ _GL_CXXALIASWARN (mktemp);
703# define posix_memalign rpl_posix_memalign 1012# define posix_memalign rpl_posix_memalign
704# endif 1013# endif
705_GL_FUNCDECL_RPL (posix_memalign, int, 1014_GL_FUNCDECL_RPL (posix_memalign, int,
706 (void **memptr, size_t alignment, size_t size) 1015 (void **memptr, size_t alignment, size_t size),
707 _GL_ARG_NONNULL ((1))); 1016 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
708_GL_CXXALIAS_RPL (posix_memalign, int, 1017_GL_CXXALIAS_RPL (posix_memalign, int,
709 (void **memptr, size_t alignment, size_t size)); 1018 (void **memptr, size_t alignment, size_t size));
710# else 1019# else
@@ -713,11 +1022,10 @@ _GL_CXXALIAS_SYS (posix_memalign, int,
713 (void **memptr, size_t alignment, size_t size)); 1022 (void **memptr, size_t alignment, size_t size));
714# endif 1023# endif
715# endif 1024# endif
716# if @HAVE_POSIX_MEMALIGN@ 1025# if __GLIBC__ >= 2 && @HAVE_POSIX_MEMALIGN@
717_GL_CXXALIASWARN (posix_memalign); 1026_GL_CXXALIASWARN (posix_memalign);
718# endif 1027# endif
719#elif defined GNULIB_POSIXCHECK 1028#elif defined GNULIB_POSIXCHECK
720# undef posix_memalign
721# if HAVE_RAW_DECL_POSIX_MEMALIGN 1029# if HAVE_RAW_DECL_POSIX_MEMALIGN
722_GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - " 1030_GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
723 "use gnulib module posix_memalign for portability"); 1031 "use gnulib module posix_memalign for portability");
@@ -727,13 +1035,23 @@ _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
727#if @GNULIB_POSIX_OPENPT@ 1035#if @GNULIB_POSIX_OPENPT@
728/* Return an FD open to the master side of a pseudo-terminal. Flags should 1036/* Return an FD open to the master side of a pseudo-terminal. Flags should
729 include O_RDWR, and may also include O_NOCTTY. */ 1037 include O_RDWR, and may also include O_NOCTTY. */
730# if !@HAVE_POSIX_OPENPT@ 1038# if @REPLACE_POSIX_OPENPT@
731_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); 1039# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
732# endif 1040# undef posix_openpt
1041# define posix_openpt rpl_posix_openpt
1042# endif
1043_GL_FUNCDECL_RPL (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
1044_GL_CXXALIAS_RPL (posix_openpt, int, (int flags));
1045# else
1046# if !@HAVE_POSIX_OPENPT@
1047_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
1048# endif
733_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); 1049_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
1050# endif
1051# if __GLIBC__ >= 2
734_GL_CXXALIASWARN (posix_openpt); 1052_GL_CXXALIASWARN (posix_openpt);
1053# endif
735#elif defined GNULIB_POSIXCHECK 1054#elif defined GNULIB_POSIXCHECK
736# undef posix_openpt
737# if HAVE_RAW_DECL_POSIX_OPENPT 1055# if HAVE_RAW_DECL_POSIX_OPENPT
738_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " 1056_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
739 "use gnulib module posix_openpt for portability"); 1057 "use gnulib module posix_openpt for portability");
@@ -748,17 +1066,16 @@ _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
748# undef ptsname 1066# undef ptsname
749# define ptsname rpl_ptsname 1067# define ptsname rpl_ptsname
750# endif 1068# endif
751_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); 1069_GL_FUNCDECL_RPL (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD);
752_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); 1070_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
753# else 1071# else
754# if !@HAVE_PTSNAME@ 1072# if !@HAVE_PTSNAME@
755_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); 1073_GL_FUNCDECL_SYS (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD);
756# endif 1074# endif
757_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); 1075_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
758# endif 1076# endif
759_GL_CXXALIASWARN (ptsname); 1077_GL_CXXALIASWARN (ptsname);
760#elif defined GNULIB_POSIXCHECK 1078#elif defined GNULIB_POSIXCHECK
761# undef ptsname
762# if HAVE_RAW_DECL_PTSNAME 1079# if HAVE_RAW_DECL_PTSNAME
763_GL_WARN_ON_USE (ptsname, "ptsname is not portable - " 1080_GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
764 "use gnulib module ptsname for portability"); 1081 "use gnulib module ptsname for portability");
@@ -774,11 +1091,11 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
774# undef ptsname_r 1091# undef ptsname_r
775# define ptsname_r rpl_ptsname_r 1092# define ptsname_r rpl_ptsname_r
776# endif 1093# endif
777_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); 1094_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len), );
778_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); 1095_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
779# else 1096# else
780# if !@HAVE_PTSNAME_R@ 1097# if !@HAVE_PTSNAME_R@
781_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); 1098_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len), );
782# endif 1099# endif
783_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); 1100_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
784# endif 1101# endif
@@ -787,7 +1104,6 @@ _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
787# endif 1104# endif
788_GL_CXXALIASWARN (ptsname_r); 1105_GL_CXXALIASWARN (ptsname_r);
789#elif defined GNULIB_POSIXCHECK 1106#elif defined GNULIB_POSIXCHECK
790# undef ptsname_r
791# if HAVE_RAW_DECL_PTSNAME_R 1107# if HAVE_RAW_DECL_PTSNAME_R
792_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " 1108_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
793 "use gnulib module ptsname_r for portability"); 1109 "use gnulib module ptsname_r for portability");
@@ -800,7 +1116,7 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
800# undef putenv 1116# undef putenv
801# define putenv rpl_putenv 1117# define putenv rpl_putenv
802# endif 1118# endif
803_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); 1119_GL_FUNCDECL_RPL (putenv, int, (char *string), _GL_ARG_NONNULL ((1)));
804_GL_CXXALIAS_RPL (putenv, int, (char *string)); 1120_GL_CXXALIAS_RPL (putenv, int, (char *string));
805# elif defined _WIN32 && !defined __CYGWIN__ 1121# elif defined _WIN32 && !defined __CYGWIN__
806# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1122# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -808,6 +1124,10 @@ _GL_CXXALIAS_RPL (putenv, int, (char *string));
808# define putenv _putenv 1124# define putenv _putenv
809# endif 1125# endif
810_GL_CXXALIAS_MDA (putenv, int, (char *string)); 1126_GL_CXXALIAS_MDA (putenv, int, (char *string));
1127# elif defined __KLIBC__
1128/* Need to cast, because on OS/2 kLIBC, the first parameter is
1129 const char *string. */
1130_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string));
811# else 1131# else
812_GL_CXXALIAS_SYS (putenv, int, (char *string)); 1132_GL_CXXALIAS_SYS (putenv, int, (char *string));
813# endif 1133# endif
@@ -824,6 +1144,10 @@ _GL_CXXALIASWARN (putenv);
824/* Need to cast, because on mingw, the parameter is either 1144/* Need to cast, because on mingw, the parameter is either
825 'const char *string' or 'char *string'. */ 1145 'const char *string' or 'char *string'. */
826_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string)); 1146_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
1147# elif defined __KLIBC__
1148/* Need to cast, because on OS/2 kLIBC, the first parameter is
1149 const char *string. */
1150_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string));
827# else 1151# else
828_GL_CXXALIAS_SYS (putenv, int, (char *string)); 1152_GL_CXXALIAS_SYS (putenv, int, (char *string));
829# endif 1153# endif
@@ -851,7 +1175,9 @@ typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
851# endif 1175# endif
852_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, 1176_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
853 _gl_qsort_r_compar_fn compare, 1177 _gl_qsort_r_compar_fn compare,
854 void *arg) _GL_ARG_NONNULL ((1, 4))); 1178 void *arg),
1179 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
1180 _GL_ARG_NONNULL ((4)));
855_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, 1181_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
856 _gl_qsort_r_compar_fn compare, 1182 _gl_qsort_r_compar_fn compare,
857 void *arg)); 1183 void *arg));
@@ -859,15 +1185,18 @@ _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
859# if !@HAVE_QSORT_R@ 1185# if !@HAVE_QSORT_R@
860_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, 1186_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
861 _gl_qsort_r_compar_fn compare, 1187 _gl_qsort_r_compar_fn compare,
862 void *arg) _GL_ARG_NONNULL ((1, 4))); 1188 void *arg),
1189 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
1190 _GL_ARG_NONNULL ((4)));
863# endif 1191# endif
864_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, 1192_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
865 _gl_qsort_r_compar_fn compare, 1193 _gl_qsort_r_compar_fn compare,
866 void *arg)); 1194 void *arg));
867# endif 1195# endif
1196# if __GLIBC__ >= 2
868_GL_CXXALIASWARN (qsort_r); 1197_GL_CXXALIASWARN (qsort_r);
1198# endif
869#elif defined GNULIB_POSIXCHECK 1199#elif defined GNULIB_POSIXCHECK
870# undef qsort_r
871# if HAVE_RAW_DECL_QSORT_R 1200# if HAVE_RAW_DECL_QSORT_R
872_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - " 1201_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
873 "use gnulib module qsort_r for portability"); 1202 "use gnulib module qsort_r for portability");
@@ -875,11 +1204,26 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
875#endif 1204#endif
876 1205
877 1206
878#if @GNULIB_RANDOM_R@ 1207#if @GNULIB_RAND@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@)
879# if !@HAVE_RANDOM_R@ 1208# ifndef RAND_MAX
880# ifndef RAND_MAX 1209# define RAND_MAX 2147483647
881# define RAND_MAX 2147483647 1210# endif
1211#endif
1212
1213
1214#if @GNULIB_RAND@
1215# if @REPLACE_RAND@
1216# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1217# undef rand
1218# define rand rpl_rand
882# endif 1219# endif
1220_GL_FUNCDECL_RPL (rand, int, (void), );
1221_GL_CXXALIAS_RPL (rand, int, (void));
1222# else
1223_GL_CXXALIAS_SYS (rand, int, (void));
1224# endif
1225# if __GLIBC__ >= 2
1226_GL_CXXALIASWARN (rand);
883# endif 1227# endif
884#endif 1228#endif
885 1229
@@ -890,19 +1234,20 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
890# undef random 1234# undef random
891# define random rpl_random 1235# define random rpl_random
892# endif 1236# endif
893_GL_FUNCDECL_RPL (random, long, (void)); 1237_GL_FUNCDECL_RPL (random, long, (void), );
894_GL_CXXALIAS_RPL (random, long, (void)); 1238_GL_CXXALIAS_RPL (random, long, (void));
895# else 1239# else
896# if !@HAVE_RANDOM@ 1240# if !@HAVE_RANDOM@
897_GL_FUNCDECL_SYS (random, long, (void)); 1241_GL_FUNCDECL_SYS (random, long, (void), );
898# endif 1242# endif
899/* Need to cast, because on Haiku, the return type is 1243/* Need to cast, because on Haiku, the return type is
900 int. */ 1244 int. */
901_GL_CXXALIAS_SYS_CAST (random, long, (void)); 1245_GL_CXXALIAS_SYS_CAST (random, long, (void));
902# endif 1246# endif
1247# if __GLIBC__ >= 2
903_GL_CXXALIASWARN (random); 1248_GL_CXXALIASWARN (random);
1249# endif
904#elif defined GNULIB_POSIXCHECK 1250#elif defined GNULIB_POSIXCHECK
905# undef random
906# if HAVE_RAW_DECL_RANDOM 1251# if HAVE_RAW_DECL_RANDOM
907_GL_WARN_ON_USE (random, "random is unportable - " 1252_GL_WARN_ON_USE (random, "random is unportable - "
908 "use gnulib module random for portability"); 1253 "use gnulib module random for portability");
@@ -915,19 +1260,20 @@ _GL_WARN_ON_USE (random, "random is unportable - "
915# undef srandom 1260# undef srandom
916# define srandom rpl_srandom 1261# define srandom rpl_srandom
917# endif 1262# endif
918_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed)); 1263_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed), );
919_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed)); 1264_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
920# else 1265# else
921# if !@HAVE_RANDOM@ 1266# if !@HAVE_RANDOM@
922_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); 1267_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed), );
923# endif 1268# endif
924/* Need to cast, because on FreeBSD, the first parameter is 1269/* Need to cast, because on FreeBSD, the first parameter is
925 unsigned long seed. */ 1270 unsigned long seed. */
926_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); 1271_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
927# endif 1272# endif
1273# if __GLIBC__ >= 2
928_GL_CXXALIASWARN (srandom); 1274_GL_CXXALIASWARN (srandom);
1275# endif
929#elif defined GNULIB_POSIXCHECK 1276#elif defined GNULIB_POSIXCHECK
930# undef srandom
931# if HAVE_RAW_DECL_SRANDOM 1277# if HAVE_RAW_DECL_SRANDOM
932_GL_WARN_ON_USE (srandom, "srandom is unportable - " 1278_GL_WARN_ON_USE (srandom, "srandom is unportable - "
933 "use gnulib module random for portability"); 1279 "use gnulib module random for portability");
@@ -941,14 +1287,14 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
941# define initstate rpl_initstate 1287# define initstate rpl_initstate
942# endif 1288# endif
943_GL_FUNCDECL_RPL (initstate, char *, 1289_GL_FUNCDECL_RPL (initstate, char *,
944 (unsigned int seed, char *buf, size_t buf_size) 1290 (unsigned int seed, char *buf, size_t buf_size),
945 _GL_ARG_NONNULL ((2))); 1291 _GL_ARG_NONNULL ((2)));
946_GL_CXXALIAS_RPL (initstate, char *, 1292_GL_CXXALIAS_RPL (initstate, char *,
947 (unsigned int seed, char *buf, size_t buf_size)); 1293 (unsigned int seed, char *buf, size_t buf_size));
948# else 1294# else
949# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@ 1295# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
950_GL_FUNCDECL_SYS (initstate, char *, 1296_GL_FUNCDECL_SYS (initstate, char *,
951 (unsigned int seed, char *buf, size_t buf_size) 1297 (unsigned int seed, char *buf, size_t buf_size),
952 _GL_ARG_NONNULL ((2))); 1298 _GL_ARG_NONNULL ((2)));
953# endif 1299# endif
954/* Need to cast, because on FreeBSD, the first parameter is 1300/* Need to cast, because on FreeBSD, the first parameter is
@@ -956,9 +1302,10 @@ _GL_FUNCDECL_SYS (initstate, char *,
956_GL_CXXALIAS_SYS_CAST (initstate, char *, 1302_GL_CXXALIAS_SYS_CAST (initstate, char *,
957 (unsigned int seed, char *buf, size_t buf_size)); 1303 (unsigned int seed, char *buf, size_t buf_size));
958# endif 1304# endif
1305# if __GLIBC__ >= 2
959_GL_CXXALIASWARN (initstate); 1306_GL_CXXALIASWARN (initstate);
1307# endif
960#elif defined GNULIB_POSIXCHECK 1308#elif defined GNULIB_POSIXCHECK
961# undef initstate
962# if HAVE_RAW_DECL_INITSTATE 1309# if HAVE_RAW_DECL_INITSTATE
963_GL_WARN_ON_USE (initstate, "initstate is unportable - " 1310_GL_WARN_ON_USE (initstate, "initstate is unportable - "
964 "use gnulib module random for portability"); 1311 "use gnulib module random for portability");
@@ -971,19 +1318,20 @@ _GL_WARN_ON_USE (initstate, "initstate is unportable - "
971# undef setstate 1318# undef setstate
972# define setstate rpl_setstate 1319# define setstate rpl_setstate
973# endif 1320# endif
974_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); 1321_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1)));
975_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); 1322_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
976# else 1323# else
977# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ 1324# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
978_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); 1325_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1)));
979# endif 1326# endif
980/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter 1327/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
981 is const char *arg_state. */ 1328 is const char *arg_state. */
982_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); 1329_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
983# endif 1330# endif
1331# if __GLIBC__ >= 2
984_GL_CXXALIASWARN (setstate); 1332_GL_CXXALIASWARN (setstate);
1333# endif
985#elif defined GNULIB_POSIXCHECK 1334#elif defined GNULIB_POSIXCHECK
986# undef setstate
987# if HAVE_RAW_DECL_SETSTATE 1335# if HAVE_RAW_DECL_SETSTATE
988_GL_WARN_ON_USE (setstate, "setstate is unportable - " 1336_GL_WARN_ON_USE (setstate, "setstate is unportable - "
989 "use gnulib module random for portability"); 1337 "use gnulib module random for portability");
@@ -997,19 +1345,18 @@ _GL_WARN_ON_USE (setstate, "setstate is unportable - "
997# undef random_r 1345# undef random_r
998# define random_r rpl_random_r 1346# define random_r rpl_random_r
999# endif 1347# endif
1000_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) 1348_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result),
1001 _GL_ARG_NONNULL ((1, 2))); 1349 _GL_ARG_NONNULL ((1, 2)));
1002_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); 1350_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
1003# else 1351# else
1004# if !@HAVE_RANDOM_R@ 1352# if !@HAVE_RANDOM_R@
1005_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) 1353_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result),
1006 _GL_ARG_NONNULL ((1, 2))); 1354 _GL_ARG_NONNULL ((1, 2)));
1007# endif 1355# endif
1008_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); 1356_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
1009# endif 1357# endif
1010_GL_CXXALIASWARN (random_r); 1358_GL_CXXALIASWARN (random_r);
1011#elif defined GNULIB_POSIXCHECK 1359#elif defined GNULIB_POSIXCHECK
1012# undef random_r
1013# if HAVE_RAW_DECL_RANDOM_R 1360# if HAVE_RAW_DECL_RANDOM_R
1014_GL_WARN_ON_USE (random_r, "random_r is unportable - " 1361_GL_WARN_ON_USE (random_r, "random_r is unportable - "
1015 "use gnulib module random_r for portability"); 1362 "use gnulib module random_r for portability");
@@ -1023,14 +1370,14 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
1023# define srandom_r rpl_srandom_r 1370# define srandom_r rpl_srandom_r
1024# endif 1371# endif
1025_GL_FUNCDECL_RPL (srandom_r, int, 1372_GL_FUNCDECL_RPL (srandom_r, int,
1026 (unsigned int seed, struct random_data *rand_state) 1373 (unsigned int seed, struct random_data *rand_state),
1027 _GL_ARG_NONNULL ((2))); 1374 _GL_ARG_NONNULL ((2)));
1028_GL_CXXALIAS_RPL (srandom_r, int, 1375_GL_CXXALIAS_RPL (srandom_r, int,
1029 (unsigned int seed, struct random_data *rand_state)); 1376 (unsigned int seed, struct random_data *rand_state));
1030# else 1377# else
1031# if !@HAVE_RANDOM_R@ 1378# if !@HAVE_RANDOM_R@
1032_GL_FUNCDECL_SYS (srandom_r, int, 1379_GL_FUNCDECL_SYS (srandom_r, int,
1033 (unsigned int seed, struct random_data *rand_state) 1380 (unsigned int seed, struct random_data *rand_state),
1034 _GL_ARG_NONNULL ((2))); 1381 _GL_ARG_NONNULL ((2)));
1035# endif 1382# endif
1036_GL_CXXALIAS_SYS (srandom_r, int, 1383_GL_CXXALIAS_SYS (srandom_r, int,
@@ -1038,7 +1385,6 @@ _GL_CXXALIAS_SYS (srandom_r, int,
1038# endif 1385# endif
1039_GL_CXXALIASWARN (srandom_r); 1386_GL_CXXALIASWARN (srandom_r);
1040#elif defined GNULIB_POSIXCHECK 1387#elif defined GNULIB_POSIXCHECK
1041# undef srandom_r
1042# if HAVE_RAW_DECL_SRANDOM_R 1388# if HAVE_RAW_DECL_SRANDOM_R
1043_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " 1389_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
1044 "use gnulib module random_r for portability"); 1390 "use gnulib module random_r for portability");
@@ -1053,7 +1399,7 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
1053# endif 1399# endif
1054_GL_FUNCDECL_RPL (initstate_r, int, 1400_GL_FUNCDECL_RPL (initstate_r, int,
1055 (unsigned int seed, char *buf, size_t buf_size, 1401 (unsigned int seed, char *buf, size_t buf_size,
1056 struct random_data *rand_state) 1402 struct random_data *rand_state),
1057 _GL_ARG_NONNULL ((2, 4))); 1403 _GL_ARG_NONNULL ((2, 4)));
1058_GL_CXXALIAS_RPL (initstate_r, int, 1404_GL_CXXALIAS_RPL (initstate_r, int,
1059 (unsigned int seed, char *buf, size_t buf_size, 1405 (unsigned int seed, char *buf, size_t buf_size,
@@ -1062,7 +1408,7 @@ _GL_CXXALIAS_RPL (initstate_r, int,
1062# if !@HAVE_RANDOM_R@ 1408# if !@HAVE_RANDOM_R@
1063_GL_FUNCDECL_SYS (initstate_r, int, 1409_GL_FUNCDECL_SYS (initstate_r, int,
1064 (unsigned int seed, char *buf, size_t buf_size, 1410 (unsigned int seed, char *buf, size_t buf_size,
1065 struct random_data *rand_state) 1411 struct random_data *rand_state),
1066 _GL_ARG_NONNULL ((2, 4))); 1412 _GL_ARG_NONNULL ((2, 4)));
1067# endif 1413# endif
1068/* Need to cast, because on Haiku, the third parameter is 1414/* Need to cast, because on Haiku, the third parameter is
@@ -1073,7 +1419,6 @@ _GL_CXXALIAS_SYS_CAST (initstate_r, int,
1073# endif 1419# endif
1074_GL_CXXALIASWARN (initstate_r); 1420_GL_CXXALIASWARN (initstate_r);
1075#elif defined GNULIB_POSIXCHECK 1421#elif defined GNULIB_POSIXCHECK
1076# undef initstate_r
1077# if HAVE_RAW_DECL_INITSTATE_R 1422# if HAVE_RAW_DECL_INITSTATE_R
1078_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " 1423_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
1079 "use gnulib module random_r for portability"); 1424 "use gnulib module random_r for portability");
@@ -1087,14 +1432,14 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
1087# define setstate_r rpl_setstate_r 1432# define setstate_r rpl_setstate_r
1088# endif 1433# endif
1089_GL_FUNCDECL_RPL (setstate_r, int, 1434_GL_FUNCDECL_RPL (setstate_r, int,
1090 (char *arg_state, struct random_data *rand_state) 1435 (char *arg_state, struct random_data *rand_state),
1091 _GL_ARG_NONNULL ((1, 2))); 1436 _GL_ARG_NONNULL ((1, 2)));
1092_GL_CXXALIAS_RPL (setstate_r, int, 1437_GL_CXXALIAS_RPL (setstate_r, int,
1093 (char *arg_state, struct random_data *rand_state)); 1438 (char *arg_state, struct random_data *rand_state));
1094# else 1439# else
1095# if !@HAVE_RANDOM_R@ 1440# if !@HAVE_RANDOM_R@
1096_GL_FUNCDECL_SYS (setstate_r, int, 1441_GL_FUNCDECL_SYS (setstate_r, int,
1097 (char *arg_state, struct random_data *rand_state) 1442 (char *arg_state, struct random_data *rand_state),
1098 _GL_ARG_NONNULL ((1, 2))); 1443 _GL_ARG_NONNULL ((1, 2)));
1099# endif 1444# endif
1100/* Need to cast, because on Haiku, the first parameter is 1445/* Need to cast, because on Haiku, the first parameter is
@@ -1104,7 +1449,6 @@ _GL_CXXALIAS_SYS_CAST (setstate_r, int,
1104# endif 1449# endif
1105_GL_CXXALIASWARN (setstate_r); 1450_GL_CXXALIASWARN (setstate_r);
1106#elif defined GNULIB_POSIXCHECK 1451#elif defined GNULIB_POSIXCHECK
1107# undef setstate_r
1108# if HAVE_RAW_DECL_SETSTATE_R 1452# if HAVE_RAW_DECL_SETSTATE_R
1109_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " 1453_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1110 "use gnulib module random_r for portability"); 1454 "use gnulib module random_r for portability");
@@ -1113,21 +1457,45 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1113 1457
1114 1458
1115#if @GNULIB_REALLOC_POSIX@ 1459#if @GNULIB_REALLOC_POSIX@
1116# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \ 1460# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@
1117 || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@) 1461# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2
1462# define _GL_INLINE_RPL_REALLOC 1
1463# ifdef __cplusplus
1464extern "C" {
1465# endif
1466_GL_REALLOC_INLINE void *
1467rpl_realloc (void *ptr, size_t size)
1468{
1469 return realloc (ptr, size ? size : 1);
1470}
1471# ifdef __cplusplus
1472}
1473# endif
1474# endif
1118# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 1475# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1119 || _GL_USE_STDLIB_ALLOC) 1476 || _GL_USE_STDLIB_ALLOC)
1120# undef realloc 1477# undef realloc
1121# define realloc rpl_realloc 1478# define realloc rpl_realloc
1122# endif 1479# endif
1123_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size) 1480# if !defined _GL_INLINE_RPL_REALLOC
1124 _GL_ATTRIBUTE_DEALLOC_FREE); 1481_GL_FUNCDECL_RPL (realloc, void *,
1482 (void *ptr, size_t size),
1483 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
1484# endif
1125_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); 1485_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
1126# else 1486# else
1127# if __GNUC__ >= 11 1487# if __GNUC__ >= 11 && !defined __clang__
1128/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ 1488/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1129_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size) 1489# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1130 _GL_ATTRIBUTE_DEALLOC_FREE); 1490_GL_FUNCDECL_SYS (realloc, void *,
1491 (void *ptr, size_t size),
1492 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD)
1493 _GL_ATTRIBUTE_NOTHROW;
1494# else
1495_GL_FUNCDECL_SYS (realloc, void *,
1496 (void *ptr, size_t size),
1497 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
1498# endif
1131# endif 1499# endif
1132_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 1500_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1133# endif 1501# endif
@@ -1135,13 +1503,21 @@ _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1135_GL_CXXALIASWARN (realloc); 1503_GL_CXXALIASWARN (realloc);
1136# endif 1504# endif
1137#else 1505#else
1138# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc 1506# if @GNULIB_FREE_POSIX@ \
1507 && (__GNUC__ >= 11 && !defined __clang__) && !defined realloc
1139/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ 1508/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1140_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size) 1509# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1141 _GL_ATTRIBUTE_DEALLOC_FREE); 1510_GL_FUNCDECL_SYS (realloc, void *,
1511 (void *ptr, size_t size),
1512 _GL_ATTRIBUTE_DEALLOC_FREE)
1513 _GL_ATTRIBUTE_NOTHROW;
1514# else
1515_GL_FUNCDECL_SYS (realloc, void *,
1516 (void *ptr, size_t size),
1517 _GL_ATTRIBUTE_DEALLOC_FREE);
1518# endif
1142# endif 1519# endif
1143# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 1520# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1144# undef realloc
1145/* Assume realloc is always declared. */ 1521/* Assume realloc is always declared. */
1146_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " 1522_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
1147 "use gnulib module realloc-posix for portability"); 1523 "use gnulib module realloc-posix for portability");
@@ -1156,20 +1532,23 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
1156# define reallocarray rpl_reallocarray 1532# define reallocarray rpl_reallocarray
1157# endif 1533# endif
1158_GL_FUNCDECL_RPL (reallocarray, void *, 1534_GL_FUNCDECL_RPL (reallocarray, void *,
1159 (void *ptr, size_t nmemb, size_t size)); 1535 (void *ptr, size_t nmemb, size_t size),
1536 _GL_ATTRIBUTE_NODISCARD);
1160_GL_CXXALIAS_RPL (reallocarray, void *, 1537_GL_CXXALIAS_RPL (reallocarray, void *,
1161 (void *ptr, size_t nmemb, size_t size)); 1538 (void *ptr, size_t nmemb, size_t size));
1162# else 1539# else
1163# if ! @HAVE_REALLOCARRAY@ 1540# if ! @HAVE_REALLOCARRAY@
1164_GL_FUNCDECL_SYS (reallocarray, void *, 1541_GL_FUNCDECL_SYS (reallocarray, void *,
1165 (void *ptr, size_t nmemb, size_t size)); 1542 (void *ptr, size_t nmemb, size_t size),
1543 _GL_ATTRIBUTE_NODISCARD);
1166# endif 1544# endif
1167_GL_CXXALIAS_SYS (reallocarray, void *, 1545_GL_CXXALIAS_SYS (reallocarray, void *,
1168 (void *ptr, size_t nmemb, size_t size)); 1546 (void *ptr, size_t nmemb, size_t size));
1169# endif 1547# endif
1548# if __GLIBC__ >= 2
1170_GL_CXXALIASWARN (reallocarray); 1549_GL_CXXALIASWARN (reallocarray);
1550# endif
1171#elif defined GNULIB_POSIXCHECK 1551#elif defined GNULIB_POSIXCHECK
1172# undef reallocarray
1173# if HAVE_RAW_DECL_REALLOCARRAY 1552# if HAVE_RAW_DECL_REALLOCARRAY
1174_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - " 1553_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1175 "use gnulib module reallocarray for portability"); 1554 "use gnulib module reallocarray for portability");
@@ -1182,22 +1561,21 @@ _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1182# define realpath rpl_realpath 1561# define realpath rpl_realpath
1183# endif 1562# endif
1184_GL_FUNCDECL_RPL (realpath, char *, 1563_GL_FUNCDECL_RPL (realpath, char *,
1185 (const char *restrict name, char *restrict resolved) 1564 (const char *restrict name, char *restrict resolved),
1186 _GL_ARG_NONNULL ((1))); 1565 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1187_GL_CXXALIAS_RPL (realpath, char *, 1566_GL_CXXALIAS_RPL (realpath, char *,
1188 (const char *restrict name, char *restrict resolved)); 1567 (const char *restrict name, char *restrict resolved));
1189# else 1568# else
1190# if !@HAVE_REALPATH@ 1569# if !@HAVE_REALPATH@
1191_GL_FUNCDECL_SYS (realpath, char *, 1570_GL_FUNCDECL_SYS (realpath, char *,
1192 (const char *restrict name, char *restrict resolved) 1571 (const char *restrict name, char *restrict resolved),
1193 _GL_ARG_NONNULL ((1))); 1572 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1194# endif 1573# endif
1195_GL_CXXALIAS_SYS (realpath, char *, 1574_GL_CXXALIAS_SYS (realpath, char *,
1196 (const char *restrict name, char *restrict resolved)); 1575 (const char *restrict name, char *restrict resolved));
1197# endif 1576# endif
1198_GL_CXXALIASWARN (realpath); 1577_GL_CXXALIASWARN (realpath);
1199#elif defined GNULIB_POSIXCHECK 1578#elif defined GNULIB_POSIXCHECK
1200# undef realpath
1201# if HAVE_RAW_DECL_REALPATH 1579# if HAVE_RAW_DECL_REALPATH
1202_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " 1580_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
1203 "canonicalize or canonicalize-lgpl for portability"); 1581 "canonicalize or canonicalize-lgpl for portability");
@@ -1208,12 +1586,12 @@ _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
1208/* Test a user response to a question. 1586/* Test a user response to a question.
1209 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ 1587 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
1210# if !@HAVE_RPMATCH@ 1588# if !@HAVE_RPMATCH@
1211_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); 1589_GL_FUNCDECL_SYS (rpmatch, int, (const char *response),
1590 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1212# endif 1591# endif
1213_GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); 1592_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
1214_GL_CXXALIASWARN (rpmatch); 1593_GL_CXXALIASWARN (rpmatch);
1215#elif defined GNULIB_POSIXCHECK 1594#elif defined GNULIB_POSIXCHECK
1216# undef rpmatch
1217# if HAVE_RAW_DECL_RPMATCH 1595# if HAVE_RAW_DECL_RPMATCH
1218_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " 1596_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
1219 "use gnulib module rpmatch for portability"); 1597 "use gnulib module rpmatch for portability");
@@ -1224,12 +1602,12 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
1224/* Look up NAME in the environment, returning 0 in insecure situations. */ 1602/* Look up NAME in the environment, returning 0 in insecure situations. */
1225# if !@HAVE_SECURE_GETENV@ 1603# if !@HAVE_SECURE_GETENV@
1226_GL_FUNCDECL_SYS (secure_getenv, char *, 1604_GL_FUNCDECL_SYS (secure_getenv, char *,
1227 (char const *name) _GL_ARG_NONNULL ((1))); 1605 (char const *name),
1606 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1228# endif 1607# endif
1229_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); 1608_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
1230_GL_CXXALIASWARN (secure_getenv); 1609_GL_CXXALIASWARN (secure_getenv);
1231#elif defined GNULIB_POSIXCHECK 1610#elif defined GNULIB_POSIXCHECK
1232# undef secure_getenv
1233# if HAVE_RAW_DECL_SECURE_GETENV 1611# if HAVE_RAW_DECL_SECURE_GETENV
1234_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - " 1612_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
1235 "use gnulib module secure_getenv for portability"); 1613 "use gnulib module secure_getenv for portability");
@@ -1245,14 +1623,14 @@ _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
1245# define setenv rpl_setenv 1623# define setenv rpl_setenv
1246# endif 1624# endif
1247_GL_FUNCDECL_RPL (setenv, int, 1625_GL_FUNCDECL_RPL (setenv, int,
1248 (const char *name, const char *value, int replace) 1626 (const char *name, const char *value, int replace),
1249 _GL_ARG_NONNULL ((1))); 1627 _GL_ARG_NONNULL ((1)));
1250_GL_CXXALIAS_RPL (setenv, int, 1628_GL_CXXALIAS_RPL (setenv, int,
1251 (const char *name, const char *value, int replace)); 1629 (const char *name, const char *value, int replace));
1252# else 1630# else
1253# if !@HAVE_DECL_SETENV@ 1631# if !@HAVE_DECL_SETENV@
1254_GL_FUNCDECL_SYS (setenv, int, 1632_GL_FUNCDECL_SYS (setenv, int,
1255 (const char *name, const char *value, int replace) 1633 (const char *name, const char *value, int replace),
1256 _GL_ARG_NONNULL ((1))); 1634 _GL_ARG_NONNULL ((1)));
1257# endif 1635# endif
1258_GL_CXXALIAS_SYS (setenv, int, 1636_GL_CXXALIAS_SYS (setenv, int,
@@ -1262,13 +1640,25 @@ _GL_CXXALIAS_SYS (setenv, int,
1262_GL_CXXALIASWARN (setenv); 1640_GL_CXXALIASWARN (setenv);
1263# endif 1641# endif
1264#elif defined GNULIB_POSIXCHECK 1642#elif defined GNULIB_POSIXCHECK
1265# undef setenv
1266# if HAVE_RAW_DECL_SETENV 1643# if HAVE_RAW_DECL_SETENV
1267_GL_WARN_ON_USE (setenv, "setenv is unportable - " 1644_GL_WARN_ON_USE (setenv, "setenv is unportable - "
1268 "use gnulib module setenv for portability"); 1645 "use gnulib module setenv for portability");
1269# endif 1646# endif
1270#endif 1647#endif
1271 1648
1649#if @GNULIB_STACK_TRACE@
1650/* Prints a stack trace of the current thread to standard error,
1651 if possible. */
1652# if @CAN_PRINT_STACK_TRACE@
1653_GL_EXTERN_C void print_stack_trace (void);
1654# else
1655# if !GNULIB_defined_print_stack_trace
1656# define print_stack_trace() /* nothing */
1657# define GNULIB_defined_print_stack_trace 1
1658# endif
1659# endif
1660#endif
1661
1272#if @GNULIB_STRTOD@ 1662#if @GNULIB_STRTOD@
1273 /* Parse a double from STRING, updating ENDP if appropriate. */ 1663 /* Parse a double from STRING, updating ENDP if appropriate. */
1274# if @REPLACE_STRTOD@ 1664# if @REPLACE_STRTOD@
@@ -1277,14 +1667,14 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
1277# endif 1667# endif
1278# define GNULIB_defined_strtod_function 1 1668# define GNULIB_defined_strtod_function 1
1279_GL_FUNCDECL_RPL (strtod, double, 1669_GL_FUNCDECL_RPL (strtod, double,
1280 (const char *restrict str, char **restrict endp) 1670 (const char *restrict str, char **restrict endp),
1281 _GL_ARG_NONNULL ((1))); 1671 _GL_ARG_NONNULL ((1)));
1282_GL_CXXALIAS_RPL (strtod, double, 1672_GL_CXXALIAS_RPL (strtod, double,
1283 (const char *restrict str, char **restrict endp)); 1673 (const char *restrict str, char **restrict endp));
1284# else 1674# else
1285# if !@HAVE_STRTOD@ 1675# if !@HAVE_STRTOD@
1286_GL_FUNCDECL_SYS (strtod, double, 1676_GL_FUNCDECL_SYS (strtod, double,
1287 (const char *restrict str, char **restrict endp) 1677 (const char *restrict str, char **restrict endp),
1288 _GL_ARG_NONNULL ((1))); 1678 _GL_ARG_NONNULL ((1)));
1289# endif 1679# endif
1290_GL_CXXALIAS_SYS (strtod, double, 1680_GL_CXXALIAS_SYS (strtod, double,
@@ -1294,13 +1684,43 @@ _GL_CXXALIAS_SYS (strtod, double,
1294_GL_CXXALIASWARN (strtod); 1684_GL_CXXALIASWARN (strtod);
1295# endif 1685# endif
1296#elif defined GNULIB_POSIXCHECK 1686#elif defined GNULIB_POSIXCHECK
1297# undef strtod
1298# if HAVE_RAW_DECL_STRTOD 1687# if HAVE_RAW_DECL_STRTOD
1299_GL_WARN_ON_USE (strtod, "strtod is unportable - " 1688_GL_WARN_ON_USE (strtod, "strtod is unportable - "
1300 "use gnulib module strtod for portability"); 1689 "use gnulib module strtod for portability");
1301# endif 1690# endif
1302#endif 1691#endif
1303 1692
1693#if @GNULIB_STRTOF@
1694 /* Parse a float from STRING, updating ENDP if appropriate. */
1695# if @REPLACE_STRTOF@
1696# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1697# define strtof rpl_strtof
1698# endif
1699# define GNULIB_defined_strtof_function 1
1700_GL_FUNCDECL_RPL (strtof, float,
1701 (const char *restrict str, char **restrict endp),
1702 _GL_ARG_NONNULL ((1)));
1703_GL_CXXALIAS_RPL (strtof, float,
1704 (const char *restrict str, char **restrict endp));
1705# else
1706# if !@HAVE_STRTOF@
1707_GL_FUNCDECL_SYS (strtof, float,
1708 (const char *restrict str, char **restrict endp),
1709 _GL_ARG_NONNULL ((1)));
1710# endif
1711_GL_CXXALIAS_SYS (strtof, float,
1712 (const char *restrict str, char **restrict endp));
1713# endif
1714# if __GLIBC__ >= 2
1715_GL_CXXALIASWARN (strtof);
1716# endif
1717#elif defined GNULIB_POSIXCHECK
1718# if HAVE_RAW_DECL_STRTOF
1719_GL_WARN_ON_USE (strtof, "strtof is unportable - "
1720 "use gnulib module strtof for portability");
1721# endif
1722#endif
1723
1304#if @GNULIB_STRTOLD@ 1724#if @GNULIB_STRTOLD@
1305 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */ 1725 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1306# if @REPLACE_STRTOLD@ 1726# if @REPLACE_STRTOLD@
@@ -1309,14 +1729,14 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
1309# endif 1729# endif
1310# define GNULIB_defined_strtold_function 1 1730# define GNULIB_defined_strtold_function 1
1311_GL_FUNCDECL_RPL (strtold, long double, 1731_GL_FUNCDECL_RPL (strtold, long double,
1312 (const char *restrict str, char **restrict endp) 1732 (const char *restrict str, char **restrict endp),
1313 _GL_ARG_NONNULL ((1))); 1733 _GL_ARG_NONNULL ((1)));
1314_GL_CXXALIAS_RPL (strtold, long double, 1734_GL_CXXALIAS_RPL (strtold, long double,
1315 (const char *restrict str, char **restrict endp)); 1735 (const char *restrict str, char **restrict endp));
1316# else 1736# else
1317# if !@HAVE_STRTOLD@ 1737# if !@HAVE_STRTOLD@
1318_GL_FUNCDECL_SYS (strtold, long double, 1738_GL_FUNCDECL_SYS (strtold, long double,
1319 (const char *restrict str, char **restrict endp) 1739 (const char *restrict str, char **restrict endp),
1320 _GL_ARG_NONNULL ((1))); 1740 _GL_ARG_NONNULL ((1)));
1321# endif 1741# endif
1322_GL_CXXALIAS_SYS (strtold, long double, 1742_GL_CXXALIAS_SYS (strtold, long double,
@@ -1324,7 +1744,6 @@ _GL_CXXALIAS_SYS (strtold, long double,
1324# endif 1744# endif
1325_GL_CXXALIASWARN (strtold); 1745_GL_CXXALIASWARN (strtold);
1326#elif defined GNULIB_POSIXCHECK 1746#elif defined GNULIB_POSIXCHECK
1327# undef strtold
1328# if HAVE_RAW_DECL_STRTOLD 1747# if HAVE_RAW_DECL_STRTOLD
1329_GL_WARN_ON_USE (strtold, "strtold is unportable - " 1748_GL_WARN_ON_USE (strtold, "strtold is unportable - "
1330 "use gnulib module strtold for portability"); 1749 "use gnulib module strtold for portability");
@@ -1347,7 +1766,7 @@ _GL_WARN_ON_USE (strtold, "strtold is unportable - "
1347# define GNULIB_defined_strtol_function 1 1766# define GNULIB_defined_strtol_function 1
1348_GL_FUNCDECL_RPL (strtol, long, 1767_GL_FUNCDECL_RPL (strtol, long,
1349 (const char *restrict string, char **restrict endptr, 1768 (const char *restrict string, char **restrict endptr,
1350 int base) 1769 int base),
1351 _GL_ARG_NONNULL ((1))); 1770 _GL_ARG_NONNULL ((1)));
1352_GL_CXXALIAS_RPL (strtol, long, 1771_GL_CXXALIAS_RPL (strtol, long,
1353 (const char *restrict string, char **restrict endptr, 1772 (const char *restrict string, char **restrict endptr,
@@ -1356,7 +1775,7 @@ _GL_CXXALIAS_RPL (strtol, long,
1356# if !@HAVE_STRTOL@ 1775# if !@HAVE_STRTOL@
1357_GL_FUNCDECL_SYS (strtol, long, 1776_GL_FUNCDECL_SYS (strtol, long,
1358 (const char *restrict string, char **restrict endptr, 1777 (const char *restrict string, char **restrict endptr,
1359 int base) 1778 int base),
1360 _GL_ARG_NONNULL ((1))); 1779 _GL_ARG_NONNULL ((1)));
1361# endif 1780# endif
1362_GL_CXXALIAS_SYS (strtol, long, 1781_GL_CXXALIAS_SYS (strtol, long,
@@ -1367,7 +1786,6 @@ _GL_CXXALIAS_SYS (strtol, long,
1367_GL_CXXALIASWARN (strtol); 1786_GL_CXXALIASWARN (strtol);
1368# endif 1787# endif
1369#elif defined GNULIB_POSIXCHECK 1788#elif defined GNULIB_POSIXCHECK
1370# undef strtol
1371# if HAVE_RAW_DECL_STRTOL 1789# if HAVE_RAW_DECL_STRTOL
1372_GL_WARN_ON_USE (strtol, "strtol is unportable - " 1790_GL_WARN_ON_USE (strtol, "strtol is unportable - "
1373 "use gnulib module strtol for portability"); 1791 "use gnulib module strtol for portability");
@@ -1390,7 +1808,7 @@ _GL_WARN_ON_USE (strtol, "strtol is unportable - "
1390# define GNULIB_defined_strtoll_function 1 1808# define GNULIB_defined_strtoll_function 1
1391_GL_FUNCDECL_RPL (strtoll, long long, 1809_GL_FUNCDECL_RPL (strtoll, long long,
1392 (const char *restrict string, char **restrict endptr, 1810 (const char *restrict string, char **restrict endptr,
1393 int base) 1811 int base),
1394 _GL_ARG_NONNULL ((1))); 1812 _GL_ARG_NONNULL ((1)));
1395_GL_CXXALIAS_RPL (strtoll, long long, 1813_GL_CXXALIAS_RPL (strtoll, long long,
1396 (const char *restrict string, char **restrict endptr, 1814 (const char *restrict string, char **restrict endptr,
@@ -1399,7 +1817,7 @@ _GL_CXXALIAS_RPL (strtoll, long long,
1399# if !@HAVE_STRTOLL@ 1817# if !@HAVE_STRTOLL@
1400_GL_FUNCDECL_SYS (strtoll, long long, 1818_GL_FUNCDECL_SYS (strtoll, long long,
1401 (const char *restrict string, char **restrict endptr, 1819 (const char *restrict string, char **restrict endptr,
1402 int base) 1820 int base),
1403 _GL_ARG_NONNULL ((1))); 1821 _GL_ARG_NONNULL ((1)));
1404# endif 1822# endif
1405_GL_CXXALIAS_SYS (strtoll, long long, 1823_GL_CXXALIAS_SYS (strtoll, long long,
@@ -1408,7 +1826,6 @@ _GL_CXXALIAS_SYS (strtoll, long long,
1408# endif 1826# endif
1409_GL_CXXALIASWARN (strtoll); 1827_GL_CXXALIASWARN (strtoll);
1410#elif defined GNULIB_POSIXCHECK 1828#elif defined GNULIB_POSIXCHECK
1411# undef strtoll
1412# if HAVE_RAW_DECL_STRTOLL 1829# if HAVE_RAW_DECL_STRTOLL
1413_GL_WARN_ON_USE (strtoll, "strtoll is unportable - " 1830_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
1414 "use gnulib module strtoll for portability"); 1831 "use gnulib module strtoll for portability");
@@ -1430,7 +1847,7 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
1430# define GNULIB_defined_strtoul_function 1 1847# define GNULIB_defined_strtoul_function 1
1431_GL_FUNCDECL_RPL (strtoul, unsigned long, 1848_GL_FUNCDECL_RPL (strtoul, unsigned long,
1432 (const char *restrict string, char **restrict endptr, 1849 (const char *restrict string, char **restrict endptr,
1433 int base) 1850 int base),
1434 _GL_ARG_NONNULL ((1))); 1851 _GL_ARG_NONNULL ((1)));
1435_GL_CXXALIAS_RPL (strtoul, unsigned long, 1852_GL_CXXALIAS_RPL (strtoul, unsigned long,
1436 (const char *restrict string, char **restrict endptr, 1853 (const char *restrict string, char **restrict endptr,
@@ -1439,7 +1856,7 @@ _GL_CXXALIAS_RPL (strtoul, unsigned long,
1439# if !@HAVE_STRTOUL@ 1856# if !@HAVE_STRTOUL@
1440_GL_FUNCDECL_SYS (strtoul, unsigned long, 1857_GL_FUNCDECL_SYS (strtoul, unsigned long,
1441 (const char *restrict string, char **restrict endptr, 1858 (const char *restrict string, char **restrict endptr,
1442 int base) 1859 int base),
1443 _GL_ARG_NONNULL ((1))); 1860 _GL_ARG_NONNULL ((1)));
1444# endif 1861# endif
1445_GL_CXXALIAS_SYS (strtoul, unsigned long, 1862_GL_CXXALIAS_SYS (strtoul, unsigned long,
@@ -1450,7 +1867,6 @@ _GL_CXXALIAS_SYS (strtoul, unsigned long,
1450_GL_CXXALIASWARN (strtoul); 1867_GL_CXXALIASWARN (strtoul);
1451# endif 1868# endif
1452#elif defined GNULIB_POSIXCHECK 1869#elif defined GNULIB_POSIXCHECK
1453# undef strtoul
1454# if HAVE_RAW_DECL_STRTOUL 1870# if HAVE_RAW_DECL_STRTOUL
1455_GL_WARN_ON_USE (strtoul, "strtoul is unportable - " 1871_GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1456 "use gnulib module strtoul for portability"); 1872 "use gnulib module strtoul for portability");
@@ -1473,7 +1889,7 @@ _GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1473# define GNULIB_defined_strtoull_function 1 1889# define GNULIB_defined_strtoull_function 1
1474_GL_FUNCDECL_RPL (strtoull, unsigned long long, 1890_GL_FUNCDECL_RPL (strtoull, unsigned long long,
1475 (const char *restrict string, char **restrict endptr, 1891 (const char *restrict string, char **restrict endptr,
1476 int base) 1892 int base),
1477 _GL_ARG_NONNULL ((1))); 1893 _GL_ARG_NONNULL ((1)));
1478_GL_CXXALIAS_RPL (strtoull, unsigned long long, 1894_GL_CXXALIAS_RPL (strtoull, unsigned long long,
1479 (const char *restrict string, char **restrict endptr, 1895 (const char *restrict string, char **restrict endptr,
@@ -1482,7 +1898,7 @@ _GL_CXXALIAS_RPL (strtoull, unsigned long long,
1482# if !@HAVE_STRTOULL@ 1898# if !@HAVE_STRTOULL@
1483_GL_FUNCDECL_SYS (strtoull, unsigned long long, 1899_GL_FUNCDECL_SYS (strtoull, unsigned long long,
1484 (const char *restrict string, char **restrict endptr, 1900 (const char *restrict string, char **restrict endptr,
1485 int base) 1901 int base),
1486 _GL_ARG_NONNULL ((1))); 1902 _GL_ARG_NONNULL ((1)));
1487# endif 1903# endif
1488_GL_CXXALIAS_SYS (strtoull, unsigned long long, 1904_GL_CXXALIAS_SYS (strtoull, unsigned long long,
@@ -1491,7 +1907,6 @@ _GL_CXXALIAS_SYS (strtoull, unsigned long long,
1491# endif 1907# endif
1492_GL_CXXALIASWARN (strtoull); 1908_GL_CXXALIASWARN (strtoull);
1493#elif defined GNULIB_POSIXCHECK 1909#elif defined GNULIB_POSIXCHECK
1494# undef strtoull
1495# if HAVE_RAW_DECL_STRTOULL 1910# if HAVE_RAW_DECL_STRTOULL
1496_GL_WARN_ON_USE (strtoull, "strtoull is unportable - " 1911_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
1497 "use gnulib module strtoull for portability"); 1912 "use gnulib module strtoull for portability");
@@ -1502,12 +1917,11 @@ _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
1502/* Unlock the slave side of the pseudo-terminal whose master side is specified 1917/* Unlock the slave side of the pseudo-terminal whose master side is specified
1503 by FD, so that it can be opened. */ 1918 by FD, so that it can be opened. */
1504# if !@HAVE_UNLOCKPT@ 1919# if !@HAVE_UNLOCKPT@
1505_GL_FUNCDECL_SYS (unlockpt, int, (int fd)); 1920_GL_FUNCDECL_SYS (unlockpt, int, (int fd), );
1506# endif 1921# endif
1507_GL_CXXALIAS_SYS (unlockpt, int, (int fd)); 1922_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
1508_GL_CXXALIASWARN (unlockpt); 1923_GL_CXXALIASWARN (unlockpt);
1509#elif defined GNULIB_POSIXCHECK 1924#elif defined GNULIB_POSIXCHECK
1510# undef unlockpt
1511# if HAVE_RAW_DECL_UNLOCKPT 1925# if HAVE_RAW_DECL_UNLOCKPT
1512_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " 1926_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
1513 "use gnulib module unlockpt for portability"); 1927 "use gnulib module unlockpt for portability");
@@ -1521,11 +1935,11 @@ _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
1521# undef unsetenv 1935# undef unsetenv
1522# define unsetenv rpl_unsetenv 1936# define unsetenv rpl_unsetenv
1523# endif 1937# endif
1524_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 1938_GL_FUNCDECL_RPL (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1)));
1525_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); 1939_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
1526# else 1940# else
1527# if !@HAVE_DECL_UNSETENV@ 1941# if !@HAVE_DECL_UNSETENV@
1528_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 1942_GL_FUNCDECL_SYS (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1)));
1529# endif 1943# endif
1530_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); 1944_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
1531# endif 1945# endif
@@ -1533,7 +1947,6 @@ _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
1533_GL_CXXALIASWARN (unsetenv); 1947_GL_CXXALIASWARN (unsetenv);
1534# endif 1948# endif
1535#elif defined GNULIB_POSIXCHECK 1949#elif defined GNULIB_POSIXCHECK
1536# undef unsetenv
1537# if HAVE_RAW_DECL_UNSETENV 1950# if HAVE_RAW_DECL_UNSETENV
1538_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " 1951_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
1539 "use gnulib module unsetenv for portability"); 1952 "use gnulib module unsetenv for portability");
@@ -1547,7 +1960,7 @@ _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
1547# undef wctomb 1960# undef wctomb
1548# define wctomb rpl_wctomb 1961# define wctomb rpl_wctomb
1549# endif 1962# endif
1550_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); 1963_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc), );
1551_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); 1964_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1552# else 1965# else
1553_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); 1966_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
@@ -1558,6 +1971,20 @@ _GL_CXXALIASWARN (wctomb);
1558#endif 1971#endif
1559 1972
1560 1973
1974_GL_INLINE_HEADER_END
1975
1976
1977/* Includes that provide only macros that don't need to be overridden.
1978 (Includes that are needed for type definitions and function declarations
1979 have their place above, before the function overrides.) */
1980
1981/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.
1982 glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */
1983#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP)
1984# include <sys/wait.h>
1985#endif
1986
1987
1561#endif /* _@GUARD_PREFIX@_STDLIB_H */ 1988#endif /* _@GUARD_PREFIX@_STDLIB_H */
1562#endif /* _@GUARD_PREFIX@_STDLIB_H */ 1989#endif /* _@GUARD_PREFIX@_STDLIB_H */
1563#endif 1990#endif
diff --git a/gl/str-two-way.h b/gl/str-two-way.h
index dfe70224..7cf91ffd 100644
--- a/gl/str-two-way.h
+++ b/gl/str-two-way.h
@@ -1,5 +1,5 @@
1/* Byte-wise substring search, using the Two-Way algorithm. 1/* Byte-wise substring search, using the Two-Way algorithm.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Written by Eric Blake <ebb9@byu.net>, 2008. 4 Written by Eric Blake <ebb9@byu.net>, 2008.
5 5
@@ -108,13 +108,6 @@ static size_t
108critical_factorization (const unsigned char *needle, size_t needle_len, 108critical_factorization (const unsigned char *needle, size_t needle_len,
109 size_t *period) 109 size_t *period)
110{ 110{
111 /* Index of last byte of left half, or SIZE_MAX. */
112 size_t max_suffix, max_suffix_rev;
113 size_t j; /* Index into NEEDLE for current candidate suffix. */
114 size_t k; /* Offset into current period. */
115 size_t p; /* Intermediate period. */
116 unsigned char a, b; /* Current comparison bytes. */
117
118 /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered 111 /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered
119 out 0-length needles. */ 112 out 0-length needles. */
120 if (needle_len < 3) 113 if (needle_len < 3)
@@ -133,73 +126,83 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
133 */ 126 */
134 127
135 /* Perform lexicographic search. */ 128 /* Perform lexicographic search. */
136 max_suffix = SIZE_MAX; 129 size_t max_suffix = /* Index of last byte of left half, or SIZE_MAX. */
137 j = 0; 130 SIZE_MAX;
138 k = p = 1; 131 {
139 while (j + k < needle_len) 132 size_t j = 0; /* Index into NEEDLE for current candidate suffix. */
140 { 133 size_t k = 1; /* Offset into current period. */
141 a = CANON_ELEMENT (needle[j + k]); 134 size_t p = 1; /* Intermediate period. */
142 b = CANON_ELEMENT (needle[max_suffix + k]); 135 while (j + k < needle_len)
143 if (a < b) 136 {
144 { 137 unsigned char a = CANON_ELEMENT (needle[j + k]);
145 /* Suffix is smaller, period is entire prefix so far. */ 138 unsigned char b = CANON_ELEMENT (needle[max_suffix + k]);
146 j += k; 139 if (a < b)
147 k = 1; 140 {
148 p = j - max_suffix; 141 /* Suffix is smaller, period is entire prefix so far. */
149 } 142 j += k;
150 else if (a == b) 143 k = 1;
151 { 144 p = j - max_suffix;
152 /* Advance through repetition of the current period. */ 145 }
153 if (k != p) 146 else if (a == b)
154 ++k; 147 {
155 else 148 /* Advance through repetition of the current period. */
156 { 149 if (k != p)
157 j += p; 150 ++k;
158 k = 1; 151 else
159 } 152 {
160 } 153 j += p;
161 else /* b < a */ 154 k = 1;
162 { 155 }
163 /* Suffix is larger, start over from current location. */ 156 }
164 max_suffix = j++; 157 else /* b < a */
165 k = p = 1; 158 {
166 } 159 /* Suffix is larger, start over from current location. */
167 } 160 max_suffix = j++;
168 *period = p; 161 k = p = 1;
162 }
163 }
164 *period = p;
165 }
169 166
170 /* Perform reverse lexicographic search. */ 167 /* Perform reverse lexicographic search. */
171 max_suffix_rev = SIZE_MAX; 168 size_t max_suffix_rev = /* Index of last byte of left half, or SIZE_MAX. */
172 j = 0; 169 SIZE_MAX;
173 k = p = 1; 170 size_t p_rev;
174 while (j + k < needle_len) 171 {
175 { 172 size_t j = 0; /* Index into NEEDLE for current candidate suffix. */
176 a = CANON_ELEMENT (needle[j + k]); 173 size_t k = 1; /* Offset into current period. */
177 b = CANON_ELEMENT (needle[max_suffix_rev + k]); 174 size_t p = 1; /* Intermediate period. */
178 if (b < a) 175 while (j + k < needle_len)
179 { 176 {
180 /* Suffix is smaller, period is entire prefix so far. */ 177 unsigned char a = CANON_ELEMENT (needle[j + k]);
181 j += k; 178 unsigned char b = CANON_ELEMENT (needle[max_suffix_rev + k]);
182 k = 1; 179 if (b < a)
183 p = j - max_suffix_rev; 180 {
184 } 181 /* Suffix is smaller, period is entire prefix so far. */
185 else if (a == b) 182 j += k;
186 { 183 k = 1;
187 /* Advance through repetition of the current period. */ 184 p = j - max_suffix_rev;
188 if (k != p) 185 }
189 ++k; 186 else if (a == b)
190 else 187 {
191 { 188 /* Advance through repetition of the current period. */
192 j += p; 189 if (k != p)
193 k = 1; 190 ++k;
194 } 191 else
195 } 192 {
196 else /* a < b */ 193 j += p;
197 { 194 k = 1;
198 /* Suffix is larger, start over from current location. */ 195 }
199 max_suffix_rev = j++; 196 }
200 k = p = 1; 197 else /* a < b */
201 } 198 {
202 } 199 /* Suffix is larger, start over from current location. */
200 max_suffix_rev = j++;
201 k = p = 1;
202 }
203 }
204 p_rev = p;
205 }
203 206
204 /* Choose the shorter suffix. Return the index of the first byte of 207 /* Choose the shorter suffix. Return the index of the first byte of
205 the right half, rather than the last byte of the left half. 208 the right half, rather than the last byte of the left half.
@@ -217,7 +220,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
217 factorization. */ 220 factorization. */
218 if (max_suffix_rev + 1 < max_suffix + 1) 221 if (max_suffix_rev + 1 < max_suffix + 1)
219 return max_suffix + 1; 222 return max_suffix + 1;
220 *period = p; 223 *period = p_rev;
221 return max_suffix_rev + 1; 224 return max_suffix_rev + 1;
222} 225}
223 226
@@ -235,15 +238,12 @@ static RETURN_TYPE _GL_ATTRIBUTE_PURE
235two_way_short_needle (const unsigned char *haystack, size_t haystack_len, 238two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
236 const unsigned char *needle, size_t needle_len) 239 const unsigned char *needle, size_t needle_len)
237{ 240{
238 size_t i; /* Index into current byte of NEEDLE. */
239 size_t j; /* Index into current window of HAYSTACK. */
240 size_t period; /* The period of the right half of needle. */
241 size_t suffix; /* The index of the right half of needle. */
242
243 /* Factor the needle into two halves, such that the left half is 241 /* Factor the needle into two halves, such that the left half is
244 smaller than the global period, and the right half is 242 smaller than the global period, and the right half is
245 periodic (with a period as large as NEEDLE_LEN - suffix). */ 243 periodic (with a period as large as NEEDLE_LEN - suffix). */
246 suffix = critical_factorization (needle, needle_len, &period); 244 size_t period; /* The period of the right half of needle. */
245 size_t suffix = /* The index of the right half of needle. */
246 critical_factorization (needle, needle_len, &period);
247 247
248 /* Perform the search. Each iteration compares the right half 248 /* Perform the search. Each iteration compares the right half
249 first. */ 249 first. */
@@ -253,11 +253,12 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
253 only advance by the period, so use memory to avoid rescanning 253 only advance by the period, so use memory to avoid rescanning
254 known occurrences of the period in the right half. */ 254 known occurrences of the period in the right half. */
255 size_t memory = 0; 255 size_t memory = 0;
256 j = 0; 256 size_t j = 0; /* Index into current window of HAYSTACK. */
257 while (AVAILABLE (haystack, haystack_len, j, needle_len)) 257 while (AVAILABLE (haystack, haystack_len, j, needle_len))
258 { 258 {
259 /* Scan for matches in right half. */ 259 /* Scan for matches in right half. */
260 i = MAX (suffix, memory); 260 size_t i = /* Index into current byte of NEEDLE. */
261 MAX (suffix, memory);
261 while (i < needle_len && (CANON_ELEMENT (needle[i]) 262 while (i < needle_len && (CANON_ELEMENT (needle[i])
262 == CANON_ELEMENT (haystack[i + j]))) 263 == CANON_ELEMENT (haystack[i + j])))
263 ++i; 264 ++i;
@@ -287,11 +288,12 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
287 /* The two halves of needle are distinct; no extra memory is 288 /* The two halves of needle are distinct; no extra memory is
288 required, and any mismatch results in a maximal shift. */ 289 required, and any mismatch results in a maximal shift. */
289 period = MAX (suffix, needle_len - suffix) + 1; 290 period = MAX (suffix, needle_len - suffix) + 1;
290 j = 0; 291 size_t j = 0; /* Index into current window of HAYSTACK. */
291 while (AVAILABLE (haystack, haystack_len, j, needle_len)) 292 while (AVAILABLE (haystack, haystack_len, j, needle_len))
292 { 293 {
293 /* Scan for matches in right half. */ 294 /* Scan for matches in right half. */
294 i = suffix; 295 size_t i = /* Index into current byte of NEEDLE. */
296 suffix;
295 while (i < needle_len && (CANON_ELEMENT (needle[i]) 297 while (i < needle_len && (CANON_ELEMENT (needle[i])
296 == CANON_ELEMENT (haystack[i + j]))) 298 == CANON_ELEMENT (haystack[i + j])))
297 ++i; 299 ++i;
@@ -329,24 +331,21 @@ static RETURN_TYPE _GL_ATTRIBUTE_PURE
329two_way_long_needle (const unsigned char *haystack, size_t haystack_len, 331two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
330 const unsigned char *needle, size_t needle_len) 332 const unsigned char *needle, size_t needle_len)
331{ 333{
332 size_t i; /* Index into current byte of NEEDLE. */
333 size_t j; /* Index into current window of HAYSTACK. */
334 size_t period; /* The period of the right half of needle. */
335 size_t suffix; /* The index of the right half of needle. */
336 size_t shift_table[1U << CHAR_BIT]; /* See below. */
337
338 /* Factor the needle into two halves, such that the left half is 334 /* Factor the needle into two halves, such that the left half is
339 smaller than the global period, and the right half is 335 smaller than the global period, and the right half is
340 periodic (with a period as large as NEEDLE_LEN - suffix). */ 336 periodic (with a period as large as NEEDLE_LEN - suffix). */
341 suffix = critical_factorization (needle, needle_len, &period); 337 size_t period; /* The period of the right half of needle. */
338 size_t suffix = /* The index of the right half of needle. */
339 critical_factorization (needle, needle_len, &period);
342 340
343 /* Populate shift_table. For each possible byte value c, 341 /* Populate shift_table. For each possible byte value c,
344 shift_table[c] is the distance from the last occurrence of c to 342 shift_table[c] is the distance from the last occurrence of c to
345 the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. 343 the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE.
346 shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ 344 shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */
347 for (i = 0; i < 1U << CHAR_BIT; i++) 345 size_t shift_table[1U << CHAR_BIT];
346 for (size_t i = 0; i < 1U << CHAR_BIT; i++)
348 shift_table[i] = needle_len; 347 shift_table[i] = needle_len;
349 for (i = 0; i < needle_len; i++) 348 for (size_t i = 0; i < needle_len; i++)
350 shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; 349 shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1;
351 350
352 /* Perform the search. Each iteration compares the right half 351 /* Perform the search. Each iteration compares the right half
@@ -357,13 +356,13 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
357 only advance by the period, so use memory to avoid rescanning 356 only advance by the period, so use memory to avoid rescanning
358 known occurrences of the period in the right half. */ 357 known occurrences of the period in the right half. */
359 size_t memory = 0; 358 size_t memory = 0;
360 size_t shift; 359 size_t j = 0; /* Index into current window of HAYSTACK. */
361 j = 0;
362 while (AVAILABLE (haystack, haystack_len, j, needle_len)) 360 while (AVAILABLE (haystack, haystack_len, j, needle_len))
363 { 361 {
364 /* Check the last byte first; if it does not match, then 362 /* Check the last byte first; if it does not match, then
365 shift to the next possible match location. */ 363 shift to the next possible match location. */
366 shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; 364 size_t shift =
365 shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
367 if (0 < shift) 366 if (0 < shift)
368 { 367 {
369 if (memory && shift < period) 368 if (memory && shift < period)
@@ -375,32 +374,34 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
375 } 374 }
376 memory = 0; 375 memory = 0;
377 j += shift; 376 j += shift;
378 continue;
379 }
380 /* Scan for matches in right half. The last byte has
381 already been matched, by virtue of the shift table. */
382 i = MAX (suffix, memory);
383 while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
384 == CANON_ELEMENT (haystack[i + j])))
385 ++i;
386 if (needle_len - 1 <= i)
387 {
388 /* Scan for matches in left half. */
389 i = suffix - 1;
390 while (memory < i + 1 && (CANON_ELEMENT (needle[i])
391 == CANON_ELEMENT (haystack[i + j])))
392 --i;
393 if (i + 1 < memory + 1)
394 return (RETURN_TYPE) (haystack + j);
395 /* No match, so remember how many repetitions of period
396 on the right half were scanned. */
397 j += period;
398 memory = needle_len - period;
399 } 377 }
400 else 378 else
401 { 379 {
402 j += i - suffix + 1; 380 /* Scan for matches in right half. The last byte has
403 memory = 0; 381 already been matched, by virtue of the shift table. */
382 size_t i = MAX (suffix, memory);
383 while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
384 == CANON_ELEMENT (haystack[i + j])))
385 ++i;
386 if (needle_len - 1 <= i)
387 {
388 /* Scan for matches in left half. */
389 i = suffix - 1;
390 while (memory < i + 1 && (CANON_ELEMENT (needle[i])
391 == CANON_ELEMENT (haystack[i + j])))
392 --i;
393 if (i + 1 < memory + 1)
394 return (RETURN_TYPE) (haystack + j);
395 /* No match, so remember how many repetitions of period
396 on the right half were scanned. */
397 j += period;
398 memory = needle_len - period;
399 }
400 else
401 {
402 j += i - suffix + 1;
403 memory = 0;
404 }
404 } 405 }
405 } 406 }
406 } 407 }
@@ -408,38 +409,40 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
408 { 409 {
409 /* The two halves of needle are distinct; no extra memory is 410 /* The two halves of needle are distinct; no extra memory is
410 required, and any mismatch results in a maximal shift. */ 411 required, and any mismatch results in a maximal shift. */
411 size_t shift;
412 period = MAX (suffix, needle_len - suffix) + 1; 412 period = MAX (suffix, needle_len - suffix) + 1;
413 j = 0; 413 size_t j = 0; /* Index into current window of HAYSTACK. */
414 while (AVAILABLE (haystack, haystack_len, j, needle_len)) 414 while (AVAILABLE (haystack, haystack_len, j, needle_len))
415 { 415 {
416 /* Check the last byte first; if it does not match, then 416 /* Check the last byte first; if it does not match, then
417 shift to the next possible match location. */ 417 shift to the next possible match location. */
418 shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; 418 size_t shift =
419 shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
419 if (0 < shift) 420 if (0 < shift)
420 { 421 {
421 j += shift; 422 j += shift;
422 continue;
423 } 423 }
424 /* Scan for matches in right half. The last byte has 424 else
425 already been matched, by virtue of the shift table. */
426 i = suffix;
427 while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
428 == CANON_ELEMENT (haystack[i + j])))
429 ++i;
430 if (needle_len - 1 <= i)
431 { 425 {
432 /* Scan for matches in left half. */ 426 /* Scan for matches in right half. The last byte has
433 i = suffix - 1; 427 already been matched, by virtue of the shift table. */
434 while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) 428 size_t i = suffix;
435 == CANON_ELEMENT (haystack[i + j]))) 429 while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
436 --i; 430 == CANON_ELEMENT (haystack[i + j])))
437 if (i == SIZE_MAX) 431 ++i;
438 return (RETURN_TYPE) (haystack + j); 432 if (needle_len - 1 <= i)
439 j += period; 433 {
434 /* Scan for matches in left half. */
435 i = suffix - 1;
436 while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
437 == CANON_ELEMENT (haystack[i + j])))
438 --i;
439 if (i == SIZE_MAX)
440 return (RETURN_TYPE) (haystack + j);
441 j += period;
442 }
443 else
444 j += i - suffix + 1;
440 } 445 }
441 else
442 j += i - suffix + 1;
443 } 446 }
444 } 447 }
445 return NULL; 448 return NULL;
diff --git a/gl/strcasecmp.c b/gl/strcasecmp.c
index 3a5ce3e1..67192a31 100644
--- a/gl/strcasecmp.c
+++ b/gl/strcasecmp.c
@@ -1,5 +1,5 @@
1/* Case-insensitive string comparison function. 1/* Case-insensitive string comparison function for unibyte locales.
2 Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -17,13 +17,11 @@
17#include <config.h> 17#include <config.h>
18 18
19/* Specification. */ 19/* Specification. */
20#include <string.h> 20#include <strings.h>
21 21
22#include <ctype.h> 22#include <ctype.h>
23#include <limits.h> 23#include <limits.h>
24 24
25#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
26
27/* Compare strings S1 and S2, ignoring case, returning less than, equal to or 25/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
28 greater than zero if S1 is lexicographically less than, equal to or greater 26 greater than zero if S1 is lexicographically less than, equal to or greater
29 than S2. 27 than S2.
@@ -34,29 +32,24 @@ strcasecmp (const char *s1, const char *s2)
34{ 32{
35 const unsigned char *p1 = (const unsigned char *) s1; 33 const unsigned char *p1 = (const unsigned char *) s1;
36 const unsigned char *p2 = (const unsigned char *) s2; 34 const unsigned char *p2 = (const unsigned char *) s2;
37 unsigned char c1, c2;
38 35
39 if (p1 == p2) 36 if (p1 == p2)
40 return 0; 37 return 0;
41 38
42 do 39 for (;; p1++, p2++)
43 { 40 {
44 c1 = TOLOWER (*p1); 41 unsigned char c1 = tolower (*p1);
45 c2 = TOLOWER (*p2); 42 unsigned char c2 = tolower (*p2);
46 43
47 if (c1 == '\0') 44 if (c1 == '\0' || c1 != c2)
48 break; 45 {
49 46 if (UCHAR_MAX <= INT_MAX)
50 ++p1; 47 return c1 - c2;
51 ++p2; 48 else
49 /* On machines where 'char' and 'int' are types of the same size,
50 the difference of two 'unsigned char' values - including the
51 sign bit - doesn't fit in an 'int'. */
52 return _GL_CMP (c1, c2);
53 }
52 } 54 }
53 while (c1 == c2);
54
55 if (UCHAR_MAX <= INT_MAX)
56 return c1 - c2;
57 else
58 /* On machines where 'char' and 'int' are types of the same size, the
59 difference of two 'unsigned char' values - including the sign bit -
60 doesn't fit in an 'int'. */
61 return _GL_CMP (c1, c2);
62} 55}
diff --git a/gl/strcasestr.c b/gl/strcasestr.c
index 8eea435c..fcfbcf3b 100644
--- a/gl/strcasestr.c
+++ b/gl/strcasestr.c
@@ -1,5 +1,5 @@
1/* Case-insensitive searching in a string. 1/* Case-insensitive searching in a string.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2005. 3 Written by Bruno Haible <bruno@clisp.org>, 2005.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -23,14 +23,12 @@
23#include <ctype.h> 23#include <ctype.h>
24#include <strings.h> 24#include <strings.h>
25 25
26#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
27
28/* Two-Way algorithm. */ 26/* Two-Way algorithm. */
29#define RETURN_TYPE char * 27#define RETURN_TYPE char *
30#define AVAILABLE(h, h_l, j, n_l) \ 28#define AVAILABLE(h, h_l, j, n_l) \
31 (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ 29 (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \
32 && ((h_l) = (j) + (n_l))) 30 && ((h_l) = (j) + (n_l)))
33#define CANON_ELEMENT(c) TOLOWER (c) 31#define CANON_ELEMENT(c) tolower (c)
34#define CMP_FUNC(p1, p2, l) \ 32#define CMP_FUNC(p1, p2, l) \
35 strncasecmp ((const char *) (p1), (const char *) (p2), l) 33 strncasecmp ((const char *) (p1), (const char *) (p2), l)
36#include "str-two-way.h" 34#include "str-two-way.h"
@@ -41,29 +39,32 @@
41char * 39char *
42strcasestr (const char *haystack_start, const char *needle_start) 40strcasestr (const char *haystack_start, const char *needle_start)
43{ 41{
44 const char *haystack = haystack_start;
45 const char *needle = needle_start; 42 const char *needle = needle_start;
46 size_t needle_len; /* Length of NEEDLE. */
47 size_t haystack_len; /* Known minimum length of HAYSTACK. */
48 bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
49 43
50 /* Determine length of NEEDLE, and in the process, make sure 44 /* Determine length of NEEDLE, and in the process, make sure
51 HAYSTACK is at least as long (no point processing all of a long 45 HAYSTACK is at least as long (no point processing all of a long
52 NEEDLE if HAYSTACK is too short). */ 46 NEEDLE if HAYSTACK is too short). */
53 while (*haystack && *needle) 47 {
54 { 48 const char *haystack = haystack_start;
55 ok &= (TOLOWER ((unsigned char) *haystack) 49 bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
56 == TOLOWER ((unsigned char) *needle)); 50 while (*haystack && *needle)
57 haystack++; 51 {
58 needle++; 52 ok &= (tolower ((unsigned char) *haystack)
59 } 53 == tolower ((unsigned char) *needle));
60 if (*needle) 54 haystack++;
61 return NULL; 55 needle++;
62 if (ok) 56 }
63 return (char *) haystack_start; 57 if (*needle)
64 needle_len = needle - needle_start; 58 return NULL;
65 haystack = haystack_start + 1; 59 if (ok)
66 haystack_len = needle_len - 1; 60 return (char *) haystack_start;
61 }
62
63 size_t needle_len = /* Length of NEEDLE. */
64 needle - needle_start;
65 const char *haystack = haystack_start + 1;
66 size_t haystack_len = /* Known minimum length of HAYSTACK. */
67 needle_len - 1;
67 68
68 /* Perform the search. Abstract memory is considered to be an array 69 /* Perform the search. Abstract memory is considered to be an array
69 of 'unsigned char' values, not an array of 'char' values. See 70 of 'unsigned char' values, not an array of 'char' values. See
diff --git a/gl/streq.h b/gl/streq.h
index 712948eb..505fc4ae 100644
--- a/gl/streq.h
+++ b/gl/streq.h
@@ -1,5 +1,5 @@
1/* Optimized string comparison. 1/* Optimized string comparison.
2 Copyright (C) 2001-2002, 2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 2001-2002, 2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -21,7 +21,12 @@
21 21
22#include <string.h> 22#include <string.h>
23 23
24/* STREQ_OPT allows to optimize string comparison with a small literal string. 24#ifdef __cplusplus
25extern "C" {
26#endif
27
28
29/* STREQ_OPT optimizes string comparison with a small literal string.
25 STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) 30 STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
26 is semantically equivalent to 31 is semantically equivalent to
27 strcmp (s, "EUC-KR") == 0 32 strcmp (s, "EUC-KR") == 0
@@ -34,7 +39,7 @@
34static inline int 39static inline int
35streq9 (const char *s1, const char *s2) 40streq9 (const char *s1, const char *s2)
36{ 41{
37 return strcmp (s1 + 9, s2 + 9) == 0; 42 return streq (s1 + 9, s2 + 9);
38} 43}
39 44
40static inline int 45static inline int
@@ -173,4 +178,9 @@ streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23,
173 178
174#endif 179#endif
175 180
181
182#ifdef __cplusplus
183}
184#endif
185
176#endif /* _GL_STREQ_H */ 186#endif /* _GL_STREQ_H */
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
index cddaa4a9..a07ed62f 100644
--- a/gl/strerror-override.c
+++ b/gl/strerror-override.c
@@ -1,6 +1,6 @@
1/* strerror-override.c --- POSIX compatible system error routine 1/* strerror-override.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2010-2023 Free Software Foundation, Inc. 3 Copyright (C) 2010-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -298,6 +298,11 @@ strerror_override (int errnum)
298 return "Invalid or incomplete multibyte or wide character"; 298 return "Invalid or incomplete multibyte or wide character";
299# endif 299# endif
300 300
301# if GNULIB_defined_ESOCKTNOSUPPORT
302 case ESOCKTNOSUPPORT:
303 return "Socket type not supported";
304# endif
305
301 default: 306 default:
302 return NULL; 307 return NULL;
303 } 308 }
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
index 388cc282..1e84bdbc 100644
--- a/gl/strerror-override.h
+++ b/gl/strerror-override.h
@@ -1,6 +1,6 @@
1/* strerror-override.h --- POSIX compatible system error routine 1/* strerror-override.h --- POSIX compatible system error routine
2 2
3 Copyright (C) 2010-2023 Free Software Foundation, Inc. 3 Copyright (C) 2010-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -16,42 +16,58 @@
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _GL_STRERROR_OVERRIDE_H 18#ifndef _GL_STRERROR_OVERRIDE_H
19# define _GL_STRERROR_OVERRIDE_H 19#define _GL_STRERROR_OVERRIDE_H
20
21/* This file uses _GL_ATTRIBUTE_CONST. */
22#if !_GL_CONFIG_H_INCLUDED
23# error "Please include config.h first."
24#endif
25
26#include <errno.h>
27#include <stddef.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
20 32
21# include <errno.h>
22# include <stddef.h>
23 33
24/* Reasonable buffer size that should never trigger ERANGE; if this 34/* Reasonable buffer size that should never trigger ERANGE; if this
25 proves too small, we intentionally abort(), to remind us to fix 35 proves too small, we intentionally abort(), to remind us to fix
26 this value. */ 36 this value. */
27# define STACKBUF_LEN 256 37#define STACKBUF_LEN 256
28 38
29/* If ERRNUM maps to an errno value defined by gnulib, return a string 39/* If ERRNUM maps to an errno value defined by gnulib, return a string
30 describing the error. Otherwise return NULL. */ 40 describing the error. Otherwise return NULL. */
31# if REPLACE_STRERROR_0 \ 41#if REPLACE_STRERROR_0 \
32 || GNULIB_defined_ESOCK \ 42 || GNULIB_defined_ESOCK \
33 || GNULIB_defined_ESTREAMS \ 43 || GNULIB_defined_ESTREAMS \
34 || GNULIB_defined_EWINSOCK \ 44 || GNULIB_defined_EWINSOCK \
35 || GNULIB_defined_ENOMSG \ 45 || GNULIB_defined_ENOMSG \
36 || GNULIB_defined_EIDRM \ 46 || GNULIB_defined_EIDRM \
37 || GNULIB_defined_ENOLINK \ 47 || GNULIB_defined_ENOLINK \
38 || GNULIB_defined_EPROTO \ 48 || GNULIB_defined_EPROTO \
39 || GNULIB_defined_EMULTIHOP \ 49 || GNULIB_defined_EMULTIHOP \
40 || GNULIB_defined_EBADMSG \ 50 || GNULIB_defined_EBADMSG \
41 || GNULIB_defined_EOVERFLOW \ 51 || GNULIB_defined_EOVERFLOW \
42 || GNULIB_defined_ENOTSUP \ 52 || GNULIB_defined_ENOTSUP \
43 || GNULIB_defined_ENETRESET \ 53 || GNULIB_defined_ENETRESET \
44 || GNULIB_defined_ECONNABORTED \ 54 || GNULIB_defined_ECONNABORTED \
45 || GNULIB_defined_ESTALE \ 55 || GNULIB_defined_ESTALE \
46 || GNULIB_defined_EDQUOT \ 56 || GNULIB_defined_EDQUOT \
47 || GNULIB_defined_ECANCELED \ 57 || GNULIB_defined_ECANCELED \
48 || GNULIB_defined_EOWNERDEAD \ 58 || GNULIB_defined_EOWNERDEAD \
49 || GNULIB_defined_ENOTRECOVERABLE \ 59 || GNULIB_defined_ENOTRECOVERABLE \
50 || GNULIB_defined_EILSEQ 60 || GNULIB_defined_EILSEQ \
61 || GNULIB_defined_ESOCKTNOSUPPORT
51extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST; 62extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
52# else 63#else
53# define strerror_override(ignored) NULL 64# define strerror_override(ignored) NULL
54# define GNULIB_defined_strerror_override_macro 1 65# define GNULIB_defined_strerror_override_macro 1
55# endif 66#endif
67
68
69#ifdef __cplusplus
70}
71#endif
56 72
57#endif /* _GL_STRERROR_OVERRIDE_H */ 73#endif /* _GL_STRERROR_OVERRIDE_H */
diff --git a/gl/strerror.c b/gl/strerror.c
index d754f601..c451f055 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -1,6 +1,6 @@
1/* strerror.c --- POSIX compatible system error routine 1/* strerror.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -31,12 +31,17 @@
31/* Use the system functions, not the gnulib overrides in this file. */ 31/* Use the system functions, not the gnulib overrides in this file. */
32#undef sprintf 32#undef sprintf
33 33
34/* macOS 12's "warning: 'sprintf' is deprecated" is pointless,
35 as sprintf is used safely here. */
36#if defined __APPLE__ && defined __MACH__ && _GL_GNUC_PREREQ (4, 2)
37# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
38#endif
39
34char * 40char *
35strerror (int n) 41strerror (int n)
36#undef strerror 42#undef strerror
37{ 43{
38 static char buf[STACKBUF_LEN]; 44 static char buf[STACKBUF_LEN];
39 size_t len;
40 45
41 /* Cast away const, due to the historical signature of strerror; 46 /* Cast away const, due to the historical signature of strerror;
42 callers should not be modifying the string. */ 47 callers should not be modifying the string. */
@@ -61,7 +66,7 @@ strerror (int n)
61 } 66 }
62 67
63 /* Fix STACKBUF_LEN if this ever aborts. */ 68 /* Fix STACKBUF_LEN if this ever aborts. */
64 len = strlen (msg); 69 size_t len = strlen (msg);
65 if (sizeof buf <= len) 70 if (sizeof buf <= len)
66 abort (); 71 abort ();
67 72
diff --git a/gl/string.c b/gl/string.c
new file mode 100644
index 00000000..c2e1b1f4
--- /dev/null
+++ b/gl/string.c
@@ -0,0 +1,19 @@
1/* streq and memeq functions.
2 Copyright (C) 2025-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#define _GL_STRING_INLINE _GL_EXTERN_INLINE
18#include <config.h>
19#include <string.h>
diff --git a/gl/string.in.h b/gl/string.in.h
index e993b2fb..b54ec0ca 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <string.h>. 1/* A GNU-like <string.h>.
2 2
3 Copyright (C) 1995-1996, 2001-2023 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,7 +20,7 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined _GL_ALREADY_INCLUDING_STRING_H 23#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
24/* Special invocation convention: 24/* Special invocation convention:
25 - On OS X/NetBSD we have a sequence of nested includes 25 - On OS X/NetBSD we have a sequence of nested includes
26 <string.h> -> <strings.h> -> "string.h" 26 <string.h> -> <strings.h> -> "string.h"
@@ -34,19 +34,31 @@
34 34
35#ifndef _@GUARD_PREFIX@_STRING_H 35#ifndef _@GUARD_PREFIX@_STRING_H
36 36
37#define _GL_ALREADY_INCLUDING_STRING_H 37#define _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
38 38
39/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
40#@INCLUDE_NEXT@ @NEXT_STRING_H@ 40#@INCLUDE_NEXT@ @NEXT_STRING_H@
41 41
42#undef _GL_ALREADY_INCLUDING_STRING_H 42#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_STRING_H
43 43
44#ifndef _@GUARD_PREFIX@_STRING_H 44#ifndef _@GUARD_PREFIX@_STRING_H
45#define _@GUARD_PREFIX@_STRING_H 45#define _@GUARD_PREFIX@_STRING_H
46 46
47/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
48 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
49 HAVE_RAW_DECL_*. */
50#if !_GL_CONFIG_H_INCLUDED
51 #error "Please include config.h first."
52#endif
53
47/* NetBSD 5.0 mis-defines NULL. */ 54/* NetBSD 5.0 mis-defines NULL. */
48#include <stddef.h> 55#include <stddef.h>
49 56
57#if @GNULIB_STRERROR_L@
58/* Get locale_t. */
59# include <locale.h>
60#endif
61
50/* MirBSD defines mbslen as a macro. */ 62/* MirBSD defines mbslen as a macro. */
51#if @GNULIB_MBSLEN@ && defined __MirBSD__ 63#if @GNULIB_MBSLEN@ && defined __MirBSD__
52# include <wchar.h> 64# include <wchar.h>
@@ -59,19 +71,26 @@
59# include <unistd.h> 71# include <unistd.h>
60#endif 72#endif
61 73
62/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */ 74/* AIX 7.2 and Android 13 declare ffsl and ffsll in <strings.h>, not in
75 <string.h>. */
63/* But in any case avoid namespace pollution on glibc systems. */ 76/* But in any case avoid namespace pollution on glibc systems. */
64#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \ 77#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
65 && defined _AIX) \ 78 && (defined _AIX || defined __ANDROID__)) \
66 && ! defined __GLIBC__ 79 && ! defined __GLIBC__
67# include <strings.h> 80# include <strings.h>
68#endif 81#endif
69 82
83_GL_INLINE_HEADER_BEGIN
84
85#ifndef _GL_STRING_INLINE
86# define _GL_STRING_INLINE _GL_INLINE
87#endif
88
70/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 89/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71 that can be freed by passing them as the Ith argument to the 90 that can be freed by passing them as the Ith argument to the
72 function F. */ 91 function F. */
73#ifndef _GL_ATTRIBUTE_DEALLOC 92#ifndef _GL_ATTRIBUTE_DEALLOC
74# if __GNUC__ >= 11 93# if __GNUC__ >= 11 && !defined __clang__
75# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 94# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76# else 95# else
77# define _GL_ATTRIBUTE_DEALLOC(f, i) 96# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -83,7 +102,7 @@
83/* Applies to: functions. Cannot be used on inline functions. */ 102/* Applies to: functions. Cannot be used on inline functions. */
84#ifndef _GL_ATTRIBUTE_DEALLOC_FREE 103#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85# if defined __cplusplus && defined __GNUC__ && !defined __clang__ 104# if defined __cplusplus && defined __GNUC__ && !defined __clang__
86/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */ 105/* Work around GCC bug <https://gcc.gnu.org/PR108231> */
87# define _GL_ATTRIBUTE_DEALLOC_FREE \ 106# define _GL_ATTRIBUTE_DEALLOC_FREE \
88 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) 107 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
89# else 108# else
@@ -103,6 +122,40 @@
103# endif 122# endif
104#endif 123#endif
105 124
125/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
126 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
127/* Applies to: functions. */
128#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
129# if __GNUC__ >= 15 && !defined __clang__
130# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
131 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
132# else
133# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
134# endif
135#endif
136
137/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
138 */
139#ifndef _GL_ATTRIBUTE_NOTHROW
140# if defined __cplusplus
141# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
142# if __cplusplus >= 201103L
143# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
144# else
145# define _GL_ATTRIBUTE_NOTHROW throw ()
146# endif
147# else
148# define _GL_ATTRIBUTE_NOTHROW
149# endif
150# else
151# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
152# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
153# else
154# define _GL_ATTRIBUTE_NOTHROW
155# endif
156# endif
157#endif
158
106/* The __attribute__ feature is available in gcc versions 2.5 and later. 159/* The __attribute__ feature is available in gcc versions 2.5 and later.
107 The attribute __pure__ was added in gcc 2.96. */ 160 The attribute __pure__ was added in gcc 2.96. */
108#ifndef _GL_ATTRIBUTE_PURE 161#ifndef _GL_ATTRIBUTE_PURE
@@ -119,13 +172,18 @@
119 172
120/* The definition of _GL_WARN_ON_USE is copied here. */ 173/* The definition of _GL_WARN_ON_USE is copied here. */
121 174
175
122/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have 176/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
123 been included yet. */ 177 been included yet. */
124#if @GNULIB_FREE_POSIX@ 178#if @GNULIB_FREE_POSIX@
125# if (@REPLACE_FREE@ && !defined free \ 179# if (@REPLACE_FREE@ && !defined free \
126 && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 180 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
127/* We can't do '#define free rpl_free' here. */ 181/* We can't do '#define free rpl_free' here. */
182# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
183_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
184# else
128_GL_EXTERN_C void rpl_free (void *); 185_GL_EXTERN_C void rpl_free (void *);
186# endif
129# undef _GL_ATTRIBUTE_DEALLOC_FREE 187# undef _GL_ATTRIBUTE_DEALLOC_FREE
130# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 188# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
131# else 189# else
@@ -137,7 +195,7 @@ _GL_EXTERN_C
137 void __cdecl free (void *); 195 void __cdecl free (void *);
138# else 196# else
139# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 197# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
140_GL_EXTERN_C void free (void *) throw (); 198_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
141# else 199# else
142_GL_EXTERN_C void free (void *); 200_GL_EXTERN_C void free (void *);
143# endif 201# endif
@@ -152,39 +210,123 @@ _GL_EXTERN_C
152 void __cdecl free (void *); 210 void __cdecl free (void *);
153# else 211# else
154# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 212# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
155_GL_EXTERN_C void free (void *) throw (); 213_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
156# else 214# else
157_GL_EXTERN_C void free (void *); 215_GL_EXTERN_C void free (void *);
158# endif 216# endif
159# endif 217# endif
160#endif 218#endif
161 219
220
221/* Declarations for ISO C N3322. */
222#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
223# ifndef memcpy
224_GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n)
225# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
226 _GL_ATTRIBUTE_NOTHROW
227# endif
228 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
229 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
230# endif
231# ifndef memccpy
232_GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n)
233# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
234 _GL_ATTRIBUTE_NOTHROW
235# endif
236 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4)
237 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4);
238# endif
239# ifndef memmove
240_GL_EXTERN_C void *memmove (void *__dest, const void *__src, size_t __n)
241# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
242 _GL_ATTRIBUTE_NOTHROW
243# endif
244 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
245 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
246# endif
247# ifndef strncpy
248_GL_EXTERN_C char *strncpy (char *__dest, const char *__src, size_t __n)
249# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
250 _GL_ATTRIBUTE_NOTHROW
251# endif
252 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
253 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
254# endif
255# ifndef strndup
256_GL_EXTERN_C char *strndup (const char *__s, size_t __n)
257# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
258 _GL_ATTRIBUTE_NOTHROW
259# endif
260 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2);
261# endif
262# ifndef strncat
263_GL_EXTERN_C char *strncat (char *__dest, const char *__src, size_t __n)
264# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
265 _GL_ATTRIBUTE_NOTHROW
266# endif
267 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
268# endif
269# ifndef memcmp
270_GL_EXTERN_C int memcmp (const void *__s1, const void *__s2, size_t __n)
271# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
272 _GL_ATTRIBUTE_NOTHROW
273# endif
274 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
275 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
276# endif
277# ifndef strncmp
278_GL_EXTERN_C int strncmp (const char *__s1, const char *__s2, size_t __n)
279# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
280 _GL_ATTRIBUTE_NOTHROW
281# endif
282 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
283 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
284# endif
285# if !defined memchr && !defined __cplusplus
286_GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n)
287 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
288_GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n)
289 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
290# endif
291# ifndef memset
292_GL_EXTERN_C void *memset (void *__s, int __c, size_t __n)
293# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
294 _GL_ATTRIBUTE_NOTHROW
295# endif
296 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
297# endif
298# ifndef memset_explicit
299_GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n)
300 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
301# endif
302#endif
303
304
162/* Clear a block of memory. The compiler will not delete a call to 305/* Clear a block of memory. The compiler will not delete a call to
163 this function, even if the block is dead after the call. */ 306 this function, even if the block is dead after the call. */
164#if @GNULIB_EXPLICIT_BZERO@ 307#if @GNULIB_EXPLICIT_BZERO@
165# if ! @HAVE_EXPLICIT_BZERO@ 308# if ! @HAVE_EXPLICIT_BZERO@
166_GL_FUNCDECL_SYS (explicit_bzero, void, 309_GL_FUNCDECL_SYS (explicit_bzero, void,
167 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); 310 (void *__dest, size_t __n), _GL_ARG_NONNULL ((1)));
168# endif 311# endif
169_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); 312_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
170_GL_CXXALIASWARN (explicit_bzero); 313_GL_CXXALIASWARN (explicit_bzero);
171#elif defined GNULIB_POSIXCHECK 314#elif defined GNULIB_POSIXCHECK
172# undef explicit_bzero
173# if HAVE_RAW_DECL_EXPLICIT_BZERO 315# if HAVE_RAW_DECL_EXPLICIT_BZERO
174_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " 316_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
175 "use gnulib module explicit_bzero for portability"); 317 "use gnulib module explicit_bzero for portability");
176# endif 318# endif
177#endif 319#endif
178 320
321
179/* Find the index of the least-significant set bit. */ 322/* Find the index of the least-significant set bit. */
180#if @GNULIB_FFSL@ 323#if @GNULIB_FFSL@
181# if !@HAVE_FFSL@ 324# if !@HAVE_FFSL@
182_GL_FUNCDECL_SYS (ffsl, int, (long int i)); 325_GL_FUNCDECL_SYS (ffsl, int, (long int i), );
183# endif 326# endif
184_GL_CXXALIAS_SYS (ffsl, int, (long int i)); 327_GL_CXXALIAS_SYS (ffsl, int, (long int i));
185_GL_CXXALIASWARN (ffsl); 328_GL_CXXALIASWARN (ffsl);
186#elif defined GNULIB_POSIXCHECK 329#elif defined GNULIB_POSIXCHECK
187# undef ffsl
188# if HAVE_RAW_DECL_FFSL 330# if HAVE_RAW_DECL_FFSL
189_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); 331_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
190# endif 332# endif
@@ -197,17 +339,16 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
197# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 339# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198# define ffsll rpl_ffsll 340# define ffsll rpl_ffsll
199# endif 341# endif
200_GL_FUNCDECL_RPL (ffsll, int, (long long int i)); 342_GL_FUNCDECL_RPL (ffsll, int, (long long int i), );
201_GL_CXXALIAS_RPL (ffsll, int, (long long int i)); 343_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
202# else 344# else
203# if !@HAVE_FFSLL@ 345# if !@HAVE_FFSLL@
204_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 346_GL_FUNCDECL_SYS (ffsll, int, (long long int i), );
205# endif 347# endif
206_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 348_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
207# endif 349# endif
208_GL_CXXALIASWARN (ffsll); 350_GL_CXXALIASWARN (ffsll);
209#elif defined GNULIB_POSIXCHECK 351#elif defined GNULIB_POSIXCHECK
210# undef ffsll
211# if HAVE_RAW_DECL_FFSLL 352# if HAVE_RAW_DECL_FFSLL
212_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); 353_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
213# endif 354# endif
@@ -240,9 +381,9 @@ _GL_CXXALIASWARN (memccpy);
240# undef memchr 381# undef memchr
241# define memchr rpl_memchr 382# define memchr rpl_memchr
242# endif 383# endif
243_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 384_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n),
244 _GL_ATTRIBUTE_PURE 385 _GL_ATTRIBUTE_PURE
245 _GL_ARG_NONNULL ((1))); 386 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
246_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 387_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
247# else 388# else
248 /* On some systems, this function is defined as an overloaded function: 389 /* On some systems, this function is defined as an overloaded function:
@@ -255,17 +396,36 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
255# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 396# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
256 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 397 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
257 || defined __clang__) 398 || defined __clang__)
258_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ()); 399_GL_CXXALIASWARN1 (memchr, void *,
400 (void *__s, int __c, size_t __n)
401 _GL_ATTRIBUTE_NOTHROW);
259_GL_CXXALIASWARN1 (memchr, void const *, 402_GL_CXXALIASWARN1 (memchr, void const *,
260 (void const *__s, int __c, size_t __n) throw ()); 403 (void const *__s, int __c, size_t __n)
404 _GL_ATTRIBUTE_NOTHROW);
261# elif __GLIBC__ >= 2 405# elif __GLIBC__ >= 2
262_GL_CXXALIASWARN (memchr); 406_GL_CXXALIASWARN (memchr);
263# endif 407# endif
264#elif defined GNULIB_POSIXCHECK 408#elif defined GNULIB_POSIXCHECK
265# undef memchr
266/* Assume memchr is always declared. */ 409/* Assume memchr is always declared. */
267_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " 410_GL_WARN_ON_USE_CXX (memchr,
268 "use gnulib module memchr for portability" ); 411 const void *, void *, (void const *, int, size_t),
412 "memchr has platform-specific bugs - "
413 "use gnulib module memchr for portability" );
414#endif
415
416/* Are S1 and S2, of size N, bytewise equal? */
417#if @GNULIB_STRINGEQ@ && !@HAVE_DECL_MEMEQ@
418# ifdef __cplusplus
419extern "C" {
420# endif
421_GL_STRING_INLINE bool
422memeq (void const *__s1, void const *__s2, size_t __n)
423{
424 return !memcmp (__s1, __s2, __n);
425}
426# ifdef __cplusplus
427}
428# endif
269#endif 429#endif
270 430
271/* Return the first occurrence of NEEDLE in HAYSTACK. */ 431/* Return the first occurrence of NEEDLE in HAYSTACK. */
@@ -276,7 +436,7 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - "
276# endif 436# endif
277_GL_FUNCDECL_RPL (memmem, void *, 437_GL_FUNCDECL_RPL (memmem, void *,
278 (void const *__haystack, size_t __haystack_len, 438 (void const *__haystack, size_t __haystack_len,
279 void const *__needle, size_t __needle_len) 439 void const *__needle, size_t __needle_len),
280 _GL_ATTRIBUTE_PURE 440 _GL_ATTRIBUTE_PURE
281 _GL_ARG_NONNULL ((1, 3))); 441 _GL_ARG_NONNULL ((1, 3)));
282_GL_CXXALIAS_RPL (memmem, void *, 442_GL_CXXALIAS_RPL (memmem, void *,
@@ -286,7 +446,7 @@ _GL_CXXALIAS_RPL (memmem, void *,
286# if ! @HAVE_DECL_MEMMEM@ 446# if ! @HAVE_DECL_MEMMEM@
287_GL_FUNCDECL_SYS (memmem, void *, 447_GL_FUNCDECL_SYS (memmem, void *,
288 (void const *__haystack, size_t __haystack_len, 448 (void const *__haystack, size_t __haystack_len,
289 void const *__needle, size_t __needle_len) 449 void const *__needle, size_t __needle_len),
290 _GL_ATTRIBUTE_PURE 450 _GL_ATTRIBUTE_PURE
291 _GL_ARG_NONNULL ((1, 3))); 451 _GL_ARG_NONNULL ((1, 3)));
292# endif 452# endif
@@ -296,7 +456,6 @@ _GL_CXXALIAS_SYS (memmem, void *,
296# endif 456# endif
297_GL_CXXALIASWARN (memmem); 457_GL_CXXALIASWARN (memmem);
298#elif defined GNULIB_POSIXCHECK 458#elif defined GNULIB_POSIXCHECK
299# undef memmem
300# if HAVE_RAW_DECL_MEMMEM 459# if HAVE_RAW_DECL_MEMMEM
301_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " 460_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
302 "use gnulib module memmem-simple for portability, " 461 "use gnulib module memmem-simple for portability, "
@@ -307,18 +466,33 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
307/* Copy N bytes of SRC to DEST, return pointer to bytes after the 466/* Copy N bytes of SRC to DEST, return pointer to bytes after the
308 last written byte. */ 467 last written byte. */
309#if @GNULIB_MEMPCPY@ 468#if @GNULIB_MEMPCPY@
310# if ! @HAVE_MEMPCPY@ 469# if @REPLACE_MEMPCPY@
470# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
471# undef mempcpy
472# define mempcpy rpl_mempcpy
473# endif
474_GL_FUNCDECL_RPL (mempcpy, void *,
475 (void *restrict __dest, void const *restrict __src,
476 size_t __n),
477 _GL_ARG_NONNULL ((1, 2)));
478_GL_CXXALIAS_RPL (mempcpy, void *,
479 (void *restrict __dest, void const *restrict __src,
480 size_t __n));
481# else
482# if !@HAVE_MEMPCPY@
311_GL_FUNCDECL_SYS (mempcpy, void *, 483_GL_FUNCDECL_SYS (mempcpy, void *,
312 (void *restrict __dest, void const *restrict __src, 484 (void *restrict __dest, void const *restrict __src,
313 size_t __n) 485 size_t __n),
314 _GL_ARG_NONNULL ((1, 2))); 486 _GL_ARG_NONNULL ((1, 2)));
315# endif 487# endif
316_GL_CXXALIAS_SYS (mempcpy, void *, 488_GL_CXXALIAS_SYS (mempcpy, void *,
317 (void *restrict __dest, void const *restrict __src, 489 (void *restrict __dest, void const *restrict __src,
318 size_t __n)); 490 size_t __n));
491# endif
492# if __GLIBC__ >= 2
319_GL_CXXALIASWARN (mempcpy); 493_GL_CXXALIASWARN (mempcpy);
494# endif
320#elif defined GNULIB_POSIXCHECK 495#elif defined GNULIB_POSIXCHECK
321# undef mempcpy
322# if HAVE_RAW_DECL_MEMPCPY 496# if HAVE_RAW_DECL_MEMPCPY
323_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " 497_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
324 "use gnulib module mempcpy for portability"); 498 "use gnulib module mempcpy for portability");
@@ -328,9 +502,9 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - "
328/* Search backwards through a block for a byte (specified as an int). */ 502/* Search backwards through a block for a byte (specified as an int). */
329#if @GNULIB_MEMRCHR@ 503#if @GNULIB_MEMRCHR@
330# if ! @HAVE_DECL_MEMRCHR@ 504# if ! @HAVE_DECL_MEMRCHR@
331_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) 505_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t),
332 _GL_ATTRIBUTE_PURE 506 _GL_ATTRIBUTE_PURE
333 _GL_ARG_NONNULL ((1))); 507 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
334# endif 508# endif
335 /* On some systems, this function is defined as an overloaded function: 509 /* On some systems, this function is defined as an overloaded function:
336 extern "C++" { const void * std::memrchr (const void *, int, size_t); } 510 extern "C++" { const void * std::memrchr (const void *, int, size_t); }
@@ -341,13 +515,16 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
341# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 515# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
342 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 516 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
343 || defined __clang__) 517 || defined __clang__)
344_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ()); 518_GL_CXXALIASWARN1 (memrchr, void *,
345_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ()); 519 (void *, int, size_t)
346# else 520 _GL_ATTRIBUTE_NOTHROW);
521_GL_CXXALIASWARN1 (memrchr, void const *,
522 (void const *, int, size_t)
523 _GL_ATTRIBUTE_NOTHROW);
524# elif __GLIBC__ >= 2
347_GL_CXXALIASWARN (memrchr); 525_GL_CXXALIASWARN (memrchr);
348# endif 526# endif
349#elif defined GNULIB_POSIXCHECK 527#elif defined GNULIB_POSIXCHECK
350# undef memrchr
351# if HAVE_RAW_DECL_MEMRCHR 528# if HAVE_RAW_DECL_MEMRCHR
352_GL_WARN_ON_USE (memrchr, "memrchr is unportable - " 529_GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
353 "use gnulib module memrchr for portability"); 530 "use gnulib module memrchr for portability");
@@ -357,14 +534,27 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
357/* Overwrite a block of memory. The compiler will not optimize 534/* Overwrite a block of memory. The compiler will not optimize
358 effects away, even if the block is dead after the call. */ 535 effects away, even if the block is dead after the call. */
359#if @GNULIB_MEMSET_EXPLICIT@ 536#if @GNULIB_MEMSET_EXPLICIT@
360# if ! @HAVE_MEMSET_EXPLICIT@ 537# if @REPLACE_MEMSET_EXPLICIT@
538# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
539# undef memset_explicit
540# define memset_explicit rpl_memset_explicit
541# endif
542_GL_FUNCDECL_RPL (memset_explicit, void *,
543 (void *__dest, int __c, size_t __n),
544 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
545_GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n));
546# else
547# if !@HAVE_MEMSET_EXPLICIT@
361_GL_FUNCDECL_SYS (memset_explicit, void *, 548_GL_FUNCDECL_SYS (memset_explicit, void *,
362 (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1))); 549 (void *__dest, int __c, size_t __n),
363# endif 550 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
551# endif
364_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); 552_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
553# endif
554# if __GLIBC__ >= 2
365_GL_CXXALIASWARN (memset_explicit); 555_GL_CXXALIASWARN (memset_explicit);
556# endif
366#elif defined GNULIB_POSIXCHECK 557#elif defined GNULIB_POSIXCHECK
367# undef memset_explicit
368# if HAVE_RAW_DECL_MEMSET_EXPLICIT 558# if HAVE_RAW_DECL_MEMSET_EXPLICIT
369_GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - " 559_GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - "
370 "use gnulib module memset_explicit for portability"); 560 "use gnulib module memset_explicit for portability");
@@ -376,7 +566,7 @@ _GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - "
376 occur within N bytes. */ 566 occur within N bytes. */
377#if @GNULIB_RAWMEMCHR@ 567#if @GNULIB_RAWMEMCHR@
378# if ! @HAVE_RAWMEMCHR@ 568# if ! @HAVE_RAWMEMCHR@
379_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) 569_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in),
380 _GL_ATTRIBUTE_PURE 570 _GL_ATTRIBUTE_PURE
381 _GL_ARG_NONNULL ((1))); 571 _GL_ARG_NONNULL ((1)));
382# endif 572# endif
@@ -389,14 +579,16 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
389# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
390 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
391 || defined __clang__) 581 || defined __clang__)
392_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ()); 582_GL_CXXALIASWARN1 (rawmemchr, void *,
583 (void *__s, int __c_in)
584 _GL_ATTRIBUTE_NOTHROW);
393_GL_CXXALIASWARN1 (rawmemchr, void const *, 585_GL_CXXALIASWARN1 (rawmemchr, void const *,
394 (void const *__s, int __c_in) throw ()); 586 (void const *__s, int __c_in)
587 _GL_ATTRIBUTE_NOTHROW);
395# else 588# else
396_GL_CXXALIASWARN (rawmemchr); 589_GL_CXXALIASWARN (rawmemchr);
397# endif 590# endif
398#elif defined GNULIB_POSIXCHECK 591#elif defined GNULIB_POSIXCHECK
399# undef rawmemchr
400# if HAVE_RAW_DECL_RAWMEMCHR 592# if HAVE_RAW_DECL_RAWMEMCHR
401_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " 593_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
402 "use gnulib module rawmemchr for portability"); 594 "use gnulib module rawmemchr for portability");
@@ -405,16 +597,29 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
405 597
406/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ 598/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
407#if @GNULIB_STPCPY@ 599#if @GNULIB_STPCPY@
408# if ! @HAVE_STPCPY@ 600# if @REPLACE_STPCPY@
601# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602# undef stpcpy
603# define stpcpy rpl_stpcpy
604# endif
605_GL_FUNCDECL_RPL (stpcpy, char *,
606 (char *restrict __dst, char const *restrict __src),
607 _GL_ARG_NONNULL ((1, 2)));
608_GL_CXXALIAS_RPL (stpcpy, char *,
609 (char *restrict __dst, char const *restrict __src));
610# else
611# if !@HAVE_STPCPY@
409_GL_FUNCDECL_SYS (stpcpy, char *, 612_GL_FUNCDECL_SYS (stpcpy, char *,
410 (char *restrict __dst, char const *restrict __src) 613 (char *restrict __dst, char const *restrict __src),
411 _GL_ARG_NONNULL ((1, 2))); 614 _GL_ARG_NONNULL ((1, 2)));
412# endif 615# endif
413_GL_CXXALIAS_SYS (stpcpy, char *, 616_GL_CXXALIAS_SYS (stpcpy, char *,
414 (char *restrict __dst, char const *restrict __src)); 617 (char *restrict __dst, char const *restrict __src));
618# endif
619# if __GLIBC__ >= 2
415_GL_CXXALIASWARN (stpcpy); 620_GL_CXXALIASWARN (stpcpy);
621# endif
416#elif defined GNULIB_POSIXCHECK 622#elif defined GNULIB_POSIXCHECK
417# undef stpcpy
418# if HAVE_RAW_DECL_STPCPY 623# if HAVE_RAW_DECL_STPCPY
419_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " 624_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
420 "use gnulib module stpcpy for portability"); 625 "use gnulib module stpcpy for portability");
@@ -431,7 +636,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
431# endif 636# endif
432_GL_FUNCDECL_RPL (stpncpy, char *, 637_GL_FUNCDECL_RPL (stpncpy, char *,
433 (char *restrict __dst, char const *restrict __src, 638 (char *restrict __dst, char const *restrict __src,
434 size_t __n) 639 size_t __n),
435 _GL_ARG_NONNULL ((1, 2))); 640 _GL_ARG_NONNULL ((1, 2)));
436_GL_CXXALIAS_RPL (stpncpy, char *, 641_GL_CXXALIAS_RPL (stpncpy, char *,
437 (char *restrict __dst, char const *restrict __src, 642 (char *restrict __dst, char const *restrict __src,
@@ -440,16 +645,17 @@ _GL_CXXALIAS_RPL (stpncpy, char *,
440# if ! @HAVE_STPNCPY@ 645# if ! @HAVE_STPNCPY@
441_GL_FUNCDECL_SYS (stpncpy, char *, 646_GL_FUNCDECL_SYS (stpncpy, char *,
442 (char *restrict __dst, char const *restrict __src, 647 (char *restrict __dst, char const *restrict __src,
443 size_t __n) 648 size_t __n),
444 _GL_ARG_NONNULL ((1, 2))); 649 _GL_ARG_NONNULL ((1, 2)));
445# endif 650# endif
446_GL_CXXALIAS_SYS (stpncpy, char *, 651_GL_CXXALIAS_SYS (stpncpy, char *,
447 (char *restrict __dst, char const *restrict __src, 652 (char *restrict __dst, char const *restrict __src,
448 size_t __n)); 653 size_t __n));
449# endif 654# endif
655# if __GLIBC__ >= 2
450_GL_CXXALIASWARN (stpncpy); 656_GL_CXXALIASWARN (stpncpy);
657# endif
451#elif defined GNULIB_POSIXCHECK 658#elif defined GNULIB_POSIXCHECK
452# undef stpncpy
453# if HAVE_RAW_DECL_STPNCPY 659# if HAVE_RAW_DECL_STPNCPY
454_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " 660_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
455 "use gnulib module stpncpy for portability"); 661 "use gnulib module stpncpy for portability");
@@ -459,7 +665,6 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
459#if defined GNULIB_POSIXCHECK 665#if defined GNULIB_POSIXCHECK
460/* strchr() does not work with multibyte strings if the locale encoding is 666/* strchr() does not work with multibyte strings if the locale encoding is
461 GB18030 and the character to be searched is a digit. */ 667 GB18030 and the character to be searched is a digit. */
462# undef strchr
463/* Assume strchr is always declared. */ 668/* Assume strchr is always declared. */
464_GL_WARN_ON_USE_CXX (strchr, 669_GL_WARN_ON_USE_CXX (strchr,
465 const char *, char *, (const char *, int), 670 const char *, char *, (const char *, int),
@@ -474,14 +679,14 @@ _GL_WARN_ON_USE_CXX (strchr,
474# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 679# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
475# define strchrnul rpl_strchrnul 680# define strchrnul rpl_strchrnul
476# endif 681# endif
477_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) 682_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in),
478 _GL_ATTRIBUTE_PURE 683 _GL_ATTRIBUTE_PURE
479 _GL_ARG_NONNULL ((1))); 684 _GL_ARG_NONNULL ((1)));
480_GL_CXXALIAS_RPL (strchrnul, char *, 685_GL_CXXALIAS_RPL (strchrnul, char *,
481 (const char *str, int ch)); 686 (const char *str, int ch));
482# else 687# else
483# if ! @HAVE_STRCHRNUL@ 688# if ! @HAVE_STRCHRNUL@
484_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) 689_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in),
485 _GL_ATTRIBUTE_PURE 690 _GL_ATTRIBUTE_PURE
486 _GL_ARG_NONNULL ((1))); 691 _GL_ARG_NONNULL ((1)));
487# endif 692# endif
@@ -495,14 +700,16 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
495# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 700# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
496 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 701 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
497 || defined __clang__) 702 || defined __clang__)
498_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ()); 703_GL_CXXALIASWARN1 (strchrnul, char *,
704 (char *__s, int __c_in)
705 _GL_ATTRIBUTE_NOTHROW);
499_GL_CXXALIASWARN1 (strchrnul, char const *, 706_GL_CXXALIASWARN1 (strchrnul, char const *,
500 (char const *__s, int __c_in) throw ()); 707 (char const *__s, int __c_in)
501# else 708 _GL_ATTRIBUTE_NOTHROW);
709# elif __GLIBC__ >= 2
502_GL_CXXALIASWARN (strchrnul); 710_GL_CXXALIASWARN (strchrnul);
503# endif 711# endif
504#elif defined GNULIB_POSIXCHECK 712#elif defined GNULIB_POSIXCHECK
505# undef strchrnul
506# if HAVE_RAW_DECL_STRCHRNUL 713# if HAVE_RAW_DECL_STRCHRNUL
507_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " 714_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
508 "use gnulib module strchrnul for portability"); 715 "use gnulib module strchrnul for portability");
@@ -517,7 +724,7 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
517# define strdup rpl_strdup 724# define strdup rpl_strdup
518# endif 725# endif
519_GL_FUNCDECL_RPL (strdup, char *, 726_GL_FUNCDECL_RPL (strdup, char *,
520 (char const *__s) 727 (char const *__s),
521 _GL_ARG_NONNULL ((1)) 728 _GL_ARG_NONNULL ((1))
522 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 729 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
523_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 730_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
@@ -532,25 +739,41 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
532 /* strdup exists as a function and as a macro. Get rid of the macro. */ 739 /* strdup exists as a function and as a macro. Get rid of the macro. */
533# undef strdup 740# undef strdup
534# endif 741# endif
535# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup 742# if (!@HAVE_DECL_STRDUP@ || (__GNUC__ >= 11 && !defined __clang__)) \
743 && !defined strdup
744# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
536_GL_FUNCDECL_SYS (strdup, char *, 745_GL_FUNCDECL_SYS (strdup, char *,
537 (char const *__s) 746 (char const *__s),
747 _GL_ARG_NONNULL ((1))
748 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
749 _GL_ATTRIBUTE_NOTHROW;
750# else
751_GL_FUNCDECL_SYS (strdup, char *,
752 (char const *__s),
538 _GL_ARG_NONNULL ((1)) 753 _GL_ARG_NONNULL ((1))
539 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 754 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
755# endif
540# endif 756# endif
541_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 757_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
542# endif 758# endif
543_GL_CXXALIASWARN (strdup); 759_GL_CXXALIASWARN (strdup);
544#else 760#else
545# if __GNUC__ >= 11 && !defined strdup 761# if (__GNUC__ >= 11 && !defined __clang__) && !defined strdup
546/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ 762/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
763# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
764_GL_FUNCDECL_SYS (strdup, char *,
765 (char const *__s),
766 _GL_ARG_NONNULL ((1))
767 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
768 _GL_ATTRIBUTE_NOTHROW;
769# else
547_GL_FUNCDECL_SYS (strdup, char *, 770_GL_FUNCDECL_SYS (strdup, char *,
548 (char const *__s) 771 (char const *__s),
549 _GL_ARG_NONNULL ((1)) 772 _GL_ARG_NONNULL ((1))
550 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 773 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
774# endif
551# endif 775# endif
552# if defined GNULIB_POSIXCHECK 776# if defined GNULIB_POSIXCHECK
553# undef strdup
554# if HAVE_RAW_DECL_STRDUP 777# if HAVE_RAW_DECL_STRDUP
555_GL_WARN_ON_USE (strdup, "strdup is unportable - " 778_GL_WARN_ON_USE (strdup, "strdup is unportable - "
556 "use gnulib module strdup for portability"); 779 "use gnulib module strdup for portability");
@@ -575,6 +798,21 @@ _GL_CXXALIASWARN (strdup);
575# endif 798# endif
576#endif 799#endif
577 800
801/* Are strings S1 and S2 equal? */
802#if @GNULIB_STRINGEQ@ && !@HAVE_DECL_STREQ@
803# ifdef __cplusplus
804extern "C" {
805# endif
806_GL_STRING_INLINE bool
807streq (char const *__s1, char const *__s2)
808{
809 return !strcmp (__s1, __s2);
810}
811# ifdef __cplusplus
812}
813# endif
814#endif
815
578/* Append no more than N characters from SRC onto DEST. */ 816/* Append no more than N characters from SRC onto DEST. */
579#if @GNULIB_STRNCAT@ 817#if @GNULIB_STRNCAT@
580# if @REPLACE_STRNCAT@ 818# if @REPLACE_STRNCAT@
@@ -583,8 +821,9 @@ _GL_CXXALIASWARN (strdup);
583# define strncat rpl_strncat 821# define strncat rpl_strncat
584# endif 822# endif
585_GL_FUNCDECL_RPL (strncat, char *, 823_GL_FUNCDECL_RPL (strncat, char *,
586 (char *restrict dest, const char *restrict src, size_t n) 824 (char *restrict dest, const char *restrict src, size_t n),
587 _GL_ARG_NONNULL ((1, 2))); 825 _GL_ARG_NONNULL ((1))
826 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
588_GL_CXXALIAS_RPL (strncat, char *, 827_GL_CXXALIAS_RPL (strncat, char *,
589 (char *restrict dest, const char *restrict src, size_t n)); 828 (char *restrict dest, const char *restrict src, size_t n));
590# else 829# else
@@ -595,13 +834,41 @@ _GL_CXXALIAS_SYS (strncat, char *,
595_GL_CXXALIASWARN (strncat); 834_GL_CXXALIASWARN (strncat);
596# endif 835# endif
597#elif defined GNULIB_POSIXCHECK 836#elif defined GNULIB_POSIXCHECK
598# undef strncat
599# if HAVE_RAW_DECL_STRNCAT 837# if HAVE_RAW_DECL_STRNCAT
600_GL_WARN_ON_USE (strncat, "strncat is unportable - " 838_GL_WARN_ON_USE (strncat, "strncat is unportable - "
601 "use gnulib module strncat for portability"); 839 "use gnulib module strncat for portability");
602# endif 840# endif
603#endif 841#endif
604 842
843/* Copy no more than N bytes of SRC to DST, returning DST. */
844#if @GNULIB_STRNCPY@
845# if @REPLACE_STRNCPY@
846# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
847# undef strncpy
848# define strncpy rpl_strncpy
849# endif
850_GL_FUNCDECL_RPL (strncpy, char *,
851 (char *restrict __dst, char const *restrict __src,
852 size_t __n),
853 _GL_ARG_NONNULL ((1, 2)));
854_GL_CXXALIAS_RPL (strncpy, char *,
855 (char *restrict __dst, char const *restrict __src,
856 size_t __n));
857# else
858_GL_CXXALIAS_SYS (strncpy, char *,
859 (char *restrict __dst, char const *restrict __src,
860 size_t __n));
861# endif
862# if __GLIBC__ >= 2
863_GL_CXXALIASWARN (strncpy);
864# endif
865#elif defined GNULIB_POSIXCHECK
866# if HAVE_RAW_DECL_STRNCPY
867_GL_WARN_ON_USE (strncpy, "strncpy is unportable - "
868 "use gnulib module strncpy for portability");
869# endif
870#endif
871
605/* Return a newly allocated copy of at most N bytes of STRING. */ 872/* Return a newly allocated copy of at most N bytes of STRING. */
606#if @GNULIB_STRNDUP@ 873#if @GNULIB_STRNDUP@
607# if @REPLACE_STRNDUP@ 874# if @REPLACE_STRNDUP@
@@ -610,30 +877,46 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
610# define strndup rpl_strndup 877# define strndup rpl_strndup
611# endif 878# endif
612_GL_FUNCDECL_RPL (strndup, char *, 879_GL_FUNCDECL_RPL (strndup, char *,
613 (char const *__s, size_t __n) 880 (char const *__s, size_t __n),
614 _GL_ARG_NONNULL ((1)) 881 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
615 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 882 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
616_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); 883_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
617# else 884# else
618# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup) 885# if !@HAVE_DECL_STRNDUP@ \
886 || ((__GNUC__ >= 11 && !defined __clang__) && !defined strndup)
887# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
619_GL_FUNCDECL_SYS (strndup, char *, 888_GL_FUNCDECL_SYS (strndup, char *,
620 (char const *__s, size_t __n) 889 (char const *__s, size_t __n),
621 _GL_ARG_NONNULL ((1)) 890 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
891 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
892 _GL_ATTRIBUTE_NOTHROW;
893# else
894_GL_FUNCDECL_SYS (strndup, char *,
895 (char const *__s, size_t __n),
896 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
622 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 897 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
898# endif
623# endif 899# endif
624_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); 900_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
625# endif 901# endif
626_GL_CXXALIASWARN (strndup); 902_GL_CXXALIASWARN (strndup);
627#else 903#else
628# if __GNUC__ >= 11 && !defined strndup 904# if (__GNUC__ >= 11 && !defined __clang__) && !defined strndup
629/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ 905/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
906# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
630_GL_FUNCDECL_SYS (strndup, char *, 907_GL_FUNCDECL_SYS (strndup, char *,
631 (char const *__s, size_t __n) 908 (char const *__s, size_t __n),
632 _GL_ARG_NONNULL ((1)) 909 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
910 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
911 _GL_ATTRIBUTE_NOTHROW;
912# else
913_GL_FUNCDECL_SYS (strndup, char *,
914 (char const *__s, size_t __n),
915 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
633 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 916 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
917# endif
634# endif 918# endif
635# if defined GNULIB_POSIXCHECK 919# if defined GNULIB_POSIXCHECK
636# undef strndup
637# if HAVE_RAW_DECL_STRNDUP 920# if HAVE_RAW_DECL_STRNDUP
638_GL_WARN_ON_USE (strndup, "strndup is unportable - " 921_GL_WARN_ON_USE (strndup, "strndup is unportable - "
639 "use gnulib module strndup for portability"); 922 "use gnulib module strndup for portability");
@@ -650,13 +933,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
650# undef strnlen 933# undef strnlen
651# define strnlen rpl_strnlen 934# define strnlen rpl_strnlen
652# endif 935# endif
653_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) 936_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen),
654 _GL_ATTRIBUTE_PURE 937 _GL_ATTRIBUTE_PURE
655 _GL_ARG_NONNULL ((1))); 938 _GL_ARG_NONNULL ((1)));
656_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); 939_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
657# else 940# else
658# if ! @HAVE_DECL_STRNLEN@ 941# if ! @HAVE_DECL_STRNLEN@
659_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) 942_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen),
660 _GL_ATTRIBUTE_PURE 943 _GL_ATTRIBUTE_PURE
661 _GL_ARG_NONNULL ((1))); 944 _GL_ARG_NONNULL ((1)));
662# endif 945# endif
@@ -664,7 +947,6 @@ _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
664# endif 947# endif
665_GL_CXXALIASWARN (strnlen); 948_GL_CXXALIASWARN (strnlen);
666#elif defined GNULIB_POSIXCHECK 949#elif defined GNULIB_POSIXCHECK
667# undef strnlen
668# if HAVE_RAW_DECL_STRNLEN 950# if HAVE_RAW_DECL_STRNLEN
669_GL_WARN_ON_USE (strnlen, "strnlen is unportable - " 951_GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
670 "use gnulib module strnlen for portability"); 952 "use gnulib module strnlen for portability");
@@ -676,7 +958,6 @@ _GL_WARN_ON_USE (strnlen, "strnlen is unportable - "
676 Even in this simple case, it does not work with multibyte strings if the 958 Even in this simple case, it does not work with multibyte strings if the
677 locale encoding is GB18030 and one of the characters to be searched is a 959 locale encoding is GB18030 and one of the characters to be searched is a
678 digit. */ 960 digit. */
679# undef strcspn
680/* Assume strcspn is always declared. */ 961/* Assume strcspn is always declared. */
681_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " 962_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
682 "in multibyte locales - " 963 "in multibyte locales - "
@@ -686,7 +967,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings "
686/* Find the first occurrence in S of any character in ACCEPT. */ 967/* Find the first occurrence in S of any character in ACCEPT. */
687#if @GNULIB_STRPBRK@ 968#if @GNULIB_STRPBRK@
688# if ! @HAVE_STRPBRK@ 969# if ! @HAVE_STRPBRK@
689_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) 970_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept),
690 _GL_ATTRIBUTE_PURE 971 _GL_ATTRIBUTE_PURE
691 _GL_ARG_NONNULL ((1, 2))); 972 _GL_ARG_NONNULL ((1, 2)));
692# endif 973# endif
@@ -699,9 +980,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
699# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 980# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
700 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 981 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
701 || defined __clang__) 982 || defined __clang__)
702_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ()); 983_GL_CXXALIASWARN1 (strpbrk, char *,
984 (char *__s, char const *__accept)
985 _GL_ATTRIBUTE_NOTHROW);
703_GL_CXXALIASWARN1 (strpbrk, char const *, 986_GL_CXXALIASWARN1 (strpbrk, char const *,
704 (char const *__s, char const *__accept) throw ()); 987 (char const *__s, char const *__accept)
988 _GL_ATTRIBUTE_NOTHROW);
705# elif __GLIBC__ >= 2 989# elif __GLIBC__ >= 2
706_GL_CXXALIASWARN (strpbrk); 990_GL_CXXALIASWARN (strpbrk);
707# endif 991# endif
@@ -710,7 +994,6 @@ _GL_CXXALIASWARN (strpbrk);
710 Even in this simple case, it does not work with multibyte strings if the 994 Even in this simple case, it does not work with multibyte strings if the
711 locale encoding is GB18030 and one of the characters to be searched is a 995 locale encoding is GB18030 and one of the characters to be searched is a
712 digit. */ 996 digit. */
713# undef strpbrk
714_GL_WARN_ON_USE_CXX (strpbrk, 997_GL_WARN_ON_USE_CXX (strpbrk,
715 const char *, char *, (const char *, const char *), 998 const char *, char *, (const char *, const char *),
716 "strpbrk cannot work correctly on character strings " 999 "strpbrk cannot work correctly on character strings "
@@ -730,7 +1013,6 @@ _GL_WARN_ON_USE_CXX (strpbrk,
730#if defined GNULIB_POSIXCHECK 1013#if defined GNULIB_POSIXCHECK
731/* strspn() assumes the second argument is a list of single-byte characters. 1014/* strspn() assumes the second argument is a list of single-byte characters.
732 Even in this simple case, it cannot work with multibyte strings. */ 1015 Even in this simple case, it cannot work with multibyte strings. */
733# undef strspn
734/* Assume strspn is always declared. */ 1016/* Assume strspn is always declared. */
735_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " 1017_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
736 "in multibyte locales - " 1018 "in multibyte locales - "
@@ -740,7 +1022,6 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
740#if defined GNULIB_POSIXCHECK 1022#if defined GNULIB_POSIXCHECK
741/* strrchr() does not work with multibyte strings if the locale encoding is 1023/* strrchr() does not work with multibyte strings if the locale encoding is
742 GB18030 and the character to be searched is a digit. */ 1024 GB18030 and the character to be searched is a digit. */
743# undef strrchr
744/* Assume strrchr is always declared. */ 1025/* Assume strrchr is always declared. */
745_GL_WARN_ON_USE_CXX (strrchr, 1026_GL_WARN_ON_USE_CXX (strrchr,
746 const char *, char *, (const char *, int), 1027 const char *, char *, (const char *, int),
@@ -768,20 +1049,18 @@ _GL_WARN_ON_USE_CXX (strrchr,
768#if @GNULIB_STRSEP@ 1049#if @GNULIB_STRSEP@
769# if ! @HAVE_STRSEP@ 1050# if ! @HAVE_STRSEP@
770_GL_FUNCDECL_SYS (strsep, char *, 1051_GL_FUNCDECL_SYS (strsep, char *,
771 (char **restrict __stringp, char const *restrict __delim) 1052 (char **restrict __stringp, char const *restrict __delim),
772 _GL_ARG_NONNULL ((1, 2))); 1053 _GL_ARG_NONNULL ((1, 2)));
773# endif 1054# endif
774_GL_CXXALIAS_SYS (strsep, char *, 1055_GL_CXXALIAS_SYS (strsep, char *,
775 (char **restrict __stringp, char const *restrict __delim)); 1056 (char **restrict __stringp, char const *restrict __delim));
776_GL_CXXALIASWARN (strsep); 1057_GL_CXXALIASWARN (strsep);
777# if defined GNULIB_POSIXCHECK 1058# if defined GNULIB_POSIXCHECK
778# undef strsep
779_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " 1059_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings "
780 "in multibyte locales - " 1060 "in multibyte locales - "
781 "use mbssep if you care about internationalization"); 1061 "use mbssep if you care about internationalization");
782# endif 1062# endif
783#elif defined GNULIB_POSIXCHECK 1063#elif defined GNULIB_POSIXCHECK
784# undef strsep
785# if HAVE_RAW_DECL_STRSEP 1064# if HAVE_RAW_DECL_STRSEP
786_GL_WARN_ON_USE (strsep, "strsep is unportable - " 1065_GL_WARN_ON_USE (strsep, "strsep is unportable - "
787 "use gnulib module strsep for portability"); 1066 "use gnulib module strsep for portability");
@@ -793,7 +1072,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - "
793# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
794# define strstr rpl_strstr 1073# define strstr rpl_strstr
795# endif 1074# endif
796_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) 1075_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle),
797 _GL_ATTRIBUTE_PURE 1076 _GL_ATTRIBUTE_PURE
798 _GL_ARG_NONNULL ((1, 2))); 1077 _GL_ARG_NONNULL ((1, 2)));
799_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); 1078_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle));
@@ -809,9 +1088,11 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
809 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1088 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
810 || defined __clang__) 1089 || defined __clang__)
811_GL_CXXALIASWARN1 (strstr, char *, 1090_GL_CXXALIASWARN1 (strstr, char *,
812 (char *haystack, const char *needle) throw ()); 1091 (char *haystack, const char *needle)
1092 _GL_ATTRIBUTE_NOTHROW);
813_GL_CXXALIASWARN1 (strstr, const char *, 1093_GL_CXXALIASWARN1 (strstr, const char *,
814 (const char *haystack, const char *needle) throw ()); 1094 (const char *haystack, const char *needle)
1095 _GL_ATTRIBUTE_NOTHROW);
815# elif __GLIBC__ >= 2 1096# elif __GLIBC__ >= 2
816_GL_CXXALIASWARN (strstr); 1097_GL_CXXALIASWARN (strstr);
817# endif 1098# endif
@@ -822,11 +1103,13 @@ _GL_CXXALIASWARN (strstr);
822 as a sequence of bytes, not of characters. */ 1103 as a sequence of bytes, not of characters. */
823# undef strstr 1104# undef strstr
824/* Assume strstr is always declared. */ 1105/* Assume strstr is always declared. */
825_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " 1106_GL_WARN_ON_USE_CXX (strstr,
826 "work correctly on character strings in most " 1107 const char *, char *, (const char *, const char *),
827 "multibyte locales - " 1108 "strstr is quadratic on many systems, and cannot "
828 "use mbsstr if you care about internationalization, " 1109 "work correctly on character strings in most "
829 "or use strstr if you care about speed"); 1110 "multibyte locales - "
1111 "use mbsstr if you care about internationalization, "
1112 "or use strstr if you care about speed");
830#endif 1113#endif
831 1114
832/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive 1115/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
@@ -837,7 +1120,7 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot "
837# define strcasestr rpl_strcasestr 1120# define strcasestr rpl_strcasestr
838# endif 1121# endif
839_GL_FUNCDECL_RPL (strcasestr, char *, 1122_GL_FUNCDECL_RPL (strcasestr, char *,
840 (const char *haystack, const char *needle) 1123 (const char *haystack, const char *needle),
841 _GL_ATTRIBUTE_PURE 1124 _GL_ATTRIBUTE_PURE
842 _GL_ARG_NONNULL ((1, 2))); 1125 _GL_ARG_NONNULL ((1, 2)));
843_GL_CXXALIAS_RPL (strcasestr, char *, 1126_GL_CXXALIAS_RPL (strcasestr, char *,
@@ -845,7 +1128,7 @@ _GL_CXXALIAS_RPL (strcasestr, char *,
845# else 1128# else
846# if ! @HAVE_STRCASESTR@ 1129# if ! @HAVE_STRCASESTR@
847_GL_FUNCDECL_SYS (strcasestr, char *, 1130_GL_FUNCDECL_SYS (strcasestr, char *,
848 (const char *haystack, const char *needle) 1131 (const char *haystack, const char *needle),
849 _GL_ATTRIBUTE_PURE 1132 _GL_ATTRIBUTE_PURE
850 _GL_ARG_NONNULL ((1, 2))); 1133 _GL_ARG_NONNULL ((1, 2)));
851# endif 1134# endif
@@ -860,17 +1143,18 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
860 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1143 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
861 || defined __clang__) 1144 || defined __clang__)
862_GL_CXXALIASWARN1 (strcasestr, char *, 1145_GL_CXXALIASWARN1 (strcasestr, char *,
863 (char *haystack, const char *needle) throw ()); 1146 (char *haystack, const char *needle)
1147 _GL_ATTRIBUTE_NOTHROW);
864_GL_CXXALIASWARN1 (strcasestr, const char *, 1148_GL_CXXALIASWARN1 (strcasestr, const char *,
865 (const char *haystack, const char *needle) throw ()); 1149 (const char *haystack, const char *needle)
866# else 1150 _GL_ATTRIBUTE_NOTHROW);
1151# elif __GLIBC__ >= 2
867_GL_CXXALIASWARN (strcasestr); 1152_GL_CXXALIASWARN (strcasestr);
868# endif 1153# endif
869#elif defined GNULIB_POSIXCHECK 1154#elif defined GNULIB_POSIXCHECK
870/* strcasestr() does not work with multibyte strings: 1155/* strcasestr() does not work with multibyte strings:
871 It is a glibc extension, and glibc implements it only for unibyte 1156 It is a glibc extension, and glibc implements it only for unibyte
872 locales. */ 1157 locales. */
873# undef strcasestr
874# if HAVE_RAW_DECL_STRCASESTR 1158# if HAVE_RAW_DECL_STRCASESTR
875_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " 1159_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
876 "strings in multibyte locales - " 1160 "strings in multibyte locales - "
@@ -910,19 +1194,19 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
910# endif 1194# endif
911_GL_FUNCDECL_RPL (strtok_r, char *, 1195_GL_FUNCDECL_RPL (strtok_r, char *,
912 (char *restrict s, char const *restrict delim, 1196 (char *restrict s, char const *restrict delim,
913 char **restrict save_ptr) 1197 char **restrict save_ptr),
914 _GL_ARG_NONNULL ((2, 3))); 1198 _GL_ARG_NONNULL ((2, 3)));
915_GL_CXXALIAS_RPL (strtok_r, char *, 1199_GL_CXXALIAS_RPL (strtok_r, char *,
916 (char *restrict s, char const *restrict delim, 1200 (char *restrict s, char const *restrict delim,
917 char **restrict save_ptr)); 1201 char **restrict save_ptr));
918# else 1202# else
919# if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK 1203# if @UNDEFINE_STRTOK_R@
920# undef strtok_r 1204# undef strtok_r
921# endif 1205# endif
922# if ! @HAVE_DECL_STRTOK_R@ 1206# if ! @HAVE_DECL_STRTOK_R@
923_GL_FUNCDECL_SYS (strtok_r, char *, 1207_GL_FUNCDECL_SYS (strtok_r, char *,
924 (char *restrict s, char const *restrict delim, 1208 (char *restrict s, char const *restrict delim,
925 char **restrict save_ptr) 1209 char **restrict save_ptr),
926 _GL_ARG_NONNULL ((2, 3))); 1210 _GL_ARG_NONNULL ((2, 3)));
927# endif 1211# endif
928_GL_CXXALIAS_SYS (strtok_r, char *, 1212_GL_CXXALIAS_SYS (strtok_r, char *,
@@ -936,7 +1220,6 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character "
936 "use mbstok_r if you care about internationalization"); 1220 "use mbstok_r if you care about internationalization");
937# endif 1221# endif
938#elif defined GNULIB_POSIXCHECK 1222#elif defined GNULIB_POSIXCHECK
939# undef strtok_r
940# if HAVE_RAW_DECL_STRTOK_R 1223# if HAVE_RAW_DECL_STRTOK_R
941_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " 1224_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
942 "use gnulib module strtok_r for portability"); 1225 "use gnulib module strtok_r for portability");
@@ -947,22 +1230,38 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
947/* The following functions are not specified by POSIX. They are gnulib 1230/* The following functions are not specified by POSIX. They are gnulib
948 extensions. */ 1231 extensions. */
949 1232
1233#if @GNULIB_STR_STARTSWITH@
1234/* Returns true if STRING starts with PREFIX.
1235 Returns false otherwise. */
1236_GL_EXTERN_C bool str_startswith (const char *string, const char *prefix)
1237 _GL_ATTRIBUTE_PURE
1238 _GL_ARG_NONNULL ((1, 2));
1239#endif
1240
1241#if @GNULIB_STR_ENDSWITH@
1242/* Returns true if STRING ends with SUFFIX.
1243 Returns false otherwise. */
1244_GL_EXTERN_C bool str_endswith (const char *string, const char *prefix)
1245 _GL_ATTRIBUTE_PURE
1246 _GL_ARG_NONNULL ((1, 2));
1247#endif
1248
950#if @GNULIB_MBSLEN@ 1249#if @GNULIB_MBSLEN@
951/* Return the number of multibyte characters in the character string STRING. 1250/* Return the number of multibyte characters in the character string STRING.
952 This considers multibyte characters, unlike strlen, which counts bytes. */ 1251 This considers multibyte characters, unlike strlen, which counts bytes. */
953# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ 1252# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
954# undef mbslen 1253# undef mbslen
955# endif 1254# endif
956# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ 1255# if @HAVE_MBSLEN@ /* AIX, MirBSD define mbslen already in libc. */
957# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1256# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958# define mbslen rpl_mbslen 1257# define mbslen rpl_mbslen
959# endif 1258# endif
960_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) 1259_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string),
961 _GL_ATTRIBUTE_PURE 1260 _GL_ATTRIBUTE_PURE
962 _GL_ARG_NONNULL ((1))); 1261 _GL_ARG_NONNULL ((1)));
963_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); 1262_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
964# else 1263# else
965_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) 1264_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string),
966 _GL_ATTRIBUTE_PURE 1265 _GL_ATTRIBUTE_PURE
967 _GL_ARG_NONNULL ((1))); 1266 _GL_ARG_NONNULL ((1)));
968_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 1267_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
@@ -989,12 +1288,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1288# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
990# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ 1289# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
991# endif 1290# endif
992_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) 1291_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c),
993 _GL_ATTRIBUTE_PURE 1292 _GL_ATTRIBUTE_PURE
994 _GL_ARG_NONNULL ((1))); 1293 _GL_ARG_NONNULL ((1)));
995_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); 1294_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
996# else 1295# else
997_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) 1296_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c),
998 _GL_ATTRIBUTE_PURE 1297 _GL_ATTRIBUTE_PURE
999 _GL_ARG_NONNULL ((1))); 1298 _GL_ARG_NONNULL ((1)));
1000_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); 1299_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
@@ -1011,12 +1310,12 @@ _GL_CXXALIASWARN (mbschr);
1011# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1310# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1012# define mbsrchr rpl_mbsrchr /* avoid collision with system function */ 1311# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
1013# endif 1312# endif
1014_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) 1313_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c),
1015 _GL_ATTRIBUTE_PURE 1314 _GL_ATTRIBUTE_PURE
1016 _GL_ARG_NONNULL ((1))); 1315 _GL_ARG_NONNULL ((1)));
1017_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); 1316_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
1018# else 1317# else
1019_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) 1318_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c),
1020 _GL_ATTRIBUTE_PURE 1319 _GL_ATTRIBUTE_PURE
1021 _GL_ARG_NONNULL ((1))); 1320 _GL_ARG_NONNULL ((1)));
1022_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); 1321_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
@@ -1032,6 +1331,33 @@ _GL_CXXALIASWARN (mbsrchr);
1032_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) 1331_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
1033 _GL_ATTRIBUTE_PURE 1332 _GL_ATTRIBUTE_PURE
1034 _GL_ARG_NONNULL ((1, 2)); 1333 _GL_ARG_NONNULL ((1, 2));
1334# ifndef _GL_NO_CONST_GENERICS
1335/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1336 compiler warnings for 'const' related mistakes. */
1337# ifdef __cplusplus
1338extern "C++" { /* needed for AIX */
1339template <typename T>
1340 T * mbsstr_template (T* haystack, const char *needle);
1341template <>
1342 inline char * mbsstr_template (char *haystack, const char *needle)
1343 { return mbsstr (haystack, needle); }
1344template <>
1345 inline const char * mbsstr_template (const char *haystack, const char *needle)
1346 { return mbsstr (haystack, needle); }
1347}
1348# undef mbsstr
1349# define mbsstr mbsstr_template
1350# elif !defined mbsstr
1351# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1352 || defined __ICC || defined __TINYC__ \
1353 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1354# define mbsstr(h,n) \
1355 _Generic ((h), \
1356 char const *: (char const *) mbsstr ((h), (n)), \
1357 default : mbsstr ((h), (n)))
1358# endif
1359# endif
1360# endif
1035#endif 1361#endif
1036 1362
1037#if @GNULIB_MBSCASECMP@ 1363#if @GNULIB_MBSCASECMP@
@@ -1073,6 +1399,33 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
1073_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) 1399_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1074 _GL_ATTRIBUTE_PURE 1400 _GL_ATTRIBUTE_PURE
1075 _GL_ARG_NONNULL ((1, 2)); 1401 _GL_ARG_NONNULL ((1, 2));
1402# ifndef _GL_NO_CONST_GENERICS
1403/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1404 compiler warnings for 'const' related mistakes. */
1405# ifdef __cplusplus
1406extern "C++" { /* needed for AIX */
1407template <typename T>
1408 T * mbspcasecmp_template (T* string, const char *prefix);
1409template <>
1410 inline char * mbspcasecmp_template (char *string, const char *prefix)
1411 { return mbspcasecmp (string, prefix); }
1412template <>
1413 inline const char * mbspcasecmp_template (const char *string, const char *prefix)
1414 { return mbspcasecmp (string, prefix); }
1415}
1416# undef mbspcasecmp
1417# define mbspcasecmp mbspcasecmp_template
1418# elif !defined mbspcasecmp
1419# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1420 || defined __ICC || defined __TINYC__ \
1421 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1422# define mbspcasecmp(s,p) \
1423 _Generic ((s), \
1424 char const *: (char const *) mbspcasecmp ((s), (p)), \
1425 default : mbspcasecmp ((s), (p)))
1426# endif
1427# endif
1428# endif
1076#endif 1429#endif
1077 1430
1078#if @GNULIB_MBSCASESTR@ 1431#if @GNULIB_MBSCASESTR@
@@ -1084,6 +1437,33 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
1084_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) 1437_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
1085 _GL_ATTRIBUTE_PURE 1438 _GL_ATTRIBUTE_PURE
1086 _GL_ARG_NONNULL ((1, 2)); 1439 _GL_ARG_NONNULL ((1, 2));
1440# ifndef _GL_NO_CONST_GENERICS
1441/* Don't silently convert a 'const char *' to a 'char *'. Programmers want
1442 compiler warnings for 'const' related mistakes. */
1443# ifdef __cplusplus
1444extern "C++" { /* needed for AIX */
1445template <typename T>
1446 T * mbscasestr_template (T* haystack, const char *needle);
1447template <>
1448 inline char * mbscasestr_template (char *haystack, const char *needle)
1449 { return mbscasestr (haystack, needle); }
1450template <>
1451 inline const char * mbscasestr_template (const char *haystack, const char *needle)
1452 { return mbscasestr (haystack, needle); }
1453}
1454# undef mbscasestr
1455# define mbscasestr mbscasestr_template
1456# elif !defined mbscasestr
1457# if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
1458 || defined __ICC || defined __TINYC__ \
1459 || (__STDC_VERSION__ >= 201112L && !(defined __GNUC__ || defined __clang__)))
1460# define mbscasestr(h,n) \
1461 _Generic ((h), \
1462 char const *: (char const *) mbscasestr ((h), (n)), \
1463 default : mbscasestr ((h), (n)))
1464# endif
1465# endif
1466# endif
1087#endif 1467#endif
1088 1468
1089#if @GNULIB_MBSCSPN@ 1469#if @GNULIB_MBSCSPN@
@@ -1106,12 +1486,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
1106# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1486# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1107# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ 1487# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
1108# endif 1488# endif
1109_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) 1489_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept),
1110 _GL_ATTRIBUTE_PURE 1490 _GL_ATTRIBUTE_PURE
1111 _GL_ARG_NONNULL ((1, 2))); 1491 _GL_ARG_NONNULL ((1, 2)));
1112_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); 1492_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
1113# else 1493# else
1114_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) 1494_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept),
1115 _GL_ATTRIBUTE_PURE 1495 _GL_ATTRIBUTE_PURE
1116 _GL_ARG_NONNULL ((1, 2))); 1496 _GL_ARG_NONNULL ((1, 2)));
1117_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); 1497_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
@@ -1171,6 +1551,24 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1171 _GL_ARG_NONNULL ((2, 3)); 1551 _GL_ARG_NONNULL ((2, 3));
1172#endif 1552#endif
1173 1553
1554#if @GNULIB_MBS_STARTSWITH@
1555/* Returns true if STRING starts with PREFIX.
1556 Returns false otherwise. */
1557_GL_EXTERN_C bool mbs_startswith (const char *string, const char *prefix)
1558 _GL_ATTRIBUTE_PURE
1559 _GL_ARG_NONNULL ((1, 2));
1560#endif
1561
1562#if @GNULIB_MBS_ENDSWITH@
1563/* Returns true if STRING ends with SUFFIX.
1564 Returns false otherwise.
1565 Unlike str_endswith(), this function works correctly in multibyte locales.
1566 */
1567_GL_EXTERN_C bool mbs_endswith (const char *string, const char *suffix)
1568 _GL_ATTRIBUTE_PURE
1569 _GL_ARG_NONNULL ((1, 2));
1570#endif
1571
1174/* Map any int, typically from errno, into an error message. */ 1572/* Map any int, typically from errno, into an error message. */
1175#if @GNULIB_STRERROR@ 1573#if @GNULIB_STRERROR@
1176# if @REPLACE_STRERROR@ 1574# if @REPLACE_STRERROR@
@@ -1178,7 +1576,7 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1178# undef strerror 1576# undef strerror
1179# define strerror rpl_strerror 1577# define strerror rpl_strerror
1180# endif 1578# endif
1181_GL_FUNCDECL_RPL (strerror, char *, (int)); 1579_GL_FUNCDECL_RPL (strerror, char *, (int), );
1182_GL_CXXALIAS_RPL (strerror, char *, (int)); 1580_GL_CXXALIAS_RPL (strerror, char *, (int));
1183# else 1581# else
1184_GL_CXXALIAS_SYS (strerror, char *, (int)); 1582_GL_CXXALIAS_SYS (strerror, char *, (int));
@@ -1187,7 +1585,6 @@ _GL_CXXALIAS_SYS (strerror, char *, (int));
1187_GL_CXXALIASWARN (strerror); 1585_GL_CXXALIASWARN (strerror);
1188# endif 1586# endif
1189#elif defined GNULIB_POSIXCHECK 1587#elif defined GNULIB_POSIXCHECK
1190# undef strerror
1191/* Assume strerror is always declared. */ 1588/* Assume strerror is always declared. */
1192_GL_WARN_ON_USE (strerror, "strerror is unportable - " 1589_GL_WARN_ON_USE (strerror, "strerror is unportable - "
1193 "use gnulib module strerror to guarantee non-NULL result"); 1590 "use gnulib module strerror to guarantee non-NULL result");
@@ -1201,27 +1598,63 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
1201# undef strerror_r 1598# undef strerror_r
1202# define strerror_r rpl_strerror_r 1599# define strerror_r rpl_strerror_r
1203# endif 1600# endif
1204_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) 1601_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen),
1205 _GL_ARG_NONNULL ((2))); 1602 _GL_ARG_NONNULL ((2)));
1206_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); 1603_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
1207# else 1604# else
1208# if !@HAVE_DECL_STRERROR_R@ 1605# if !@HAVE_DECL_STRERROR_R@
1209_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) 1606_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen),
1210 _GL_ARG_NONNULL ((2))); 1607 _GL_ARG_NONNULL ((2)));
1211# endif 1608# endif
1212_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); 1609_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
1213# endif 1610# endif
1214# if @HAVE_DECL_STRERROR_R@ 1611# if __GLIBC__ >= 2 && @HAVE_DECL_STRERROR_R@
1215_GL_CXXALIASWARN (strerror_r); 1612_GL_CXXALIASWARN (strerror_r);
1216# endif 1613# endif
1217#elif defined GNULIB_POSIXCHECK 1614#elif defined GNULIB_POSIXCHECK
1218# undef strerror_r
1219# if HAVE_RAW_DECL_STRERROR_R 1615# if HAVE_RAW_DECL_STRERROR_R
1220_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " 1616_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1221 "use gnulib module strerror_r-posix for portability"); 1617 "use gnulib module strerror_r-posix for portability");
1222# endif 1618# endif
1223#endif 1619#endif
1224 1620
1621/* Map any int, typically from errno, into an error message.
1622 With locale_t argument. */
1623#if @GNULIB_STRERROR_L@
1624# if @REPLACE_STRERROR_L@
1625# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1626# undef strerror_l
1627# define strerror_l rpl_strerror_l
1628# endif
1629_GL_FUNCDECL_RPL (strerror_l, char *, (int errnum, locale_t locale),
1630 _GL_ARG_NONNULL ((2)));
1631_GL_CXXALIAS_RPL (strerror_l, char *, (int errnum, locale_t locale));
1632# else
1633# if !@HAVE_STRERROR_L@
1634_GL_FUNCDECL_SYS (strerror_l, char *, (int errnum, locale_t locale),
1635 _GL_ARG_NONNULL ((2)));
1636# endif
1637_GL_CXXALIAS_SYS (strerror_l, char *, (int errnum, locale_t locale));
1638# endif
1639# if __GLIBC__ >= 2
1640_GL_CXXALIASWARN (strerror_l);
1641# endif
1642#elif defined GNULIB_POSIXCHECK
1643# if HAVE_RAW_DECL_STRERROR_L
1644_GL_WARN_ON_USE (strerror_l, "strerror_l is unportable - "
1645 "use gnulib module strerror_l for portability");
1646# endif
1647#endif
1648
1649/* Map any int, typically from errno, into an error message. Multithread-safe,
1650 with locale_t argument.
1651 Not portable! Only provided by gnulib. */
1652#if @GNULIB_STRERROR_L@
1653_GL_FUNCDECL_SYS (strerror_l_r, int,
1654 (int errnum, char *buf, size_t buflen, locale_t locale),
1655 _GL_ARG_NONNULL ((2, 4)));
1656#endif
1657
1225/* Return the name of the system error code ERRNUM. */ 1658/* Return the name of the system error code ERRNUM. */
1226#if @GNULIB_STRERRORNAME_NP@ 1659#if @GNULIB_STRERRORNAME_NP@
1227# if @REPLACE_STRERRORNAME_NP@ 1660# if @REPLACE_STRERRORNAME_NP@
@@ -1229,17 +1662,18 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
1229# undef strerrorname_np 1662# undef strerrorname_np
1230# define strerrorname_np rpl_strerrorname_np 1663# define strerrorname_np rpl_strerrorname_np
1231# endif 1664# endif
1232_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum)); 1665_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum), );
1233_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); 1666_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1234# else 1667# else
1235# if !@HAVE_STRERRORNAME_NP@ 1668# if !@HAVE_STRERRORNAME_NP@
1236_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum)); 1669_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum), );
1237# endif 1670# endif
1238_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); 1671_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1239# endif 1672# endif
1673# if __GLIBC__ >= 2
1240_GL_CXXALIASWARN (strerrorname_np); 1674_GL_CXXALIASWARN (strerrorname_np);
1675# endif
1241#elif defined GNULIB_POSIXCHECK 1676#elif defined GNULIB_POSIXCHECK
1242# undef strerrorname_np
1243# if HAVE_RAW_DECL_STRERRORNAME_NP 1677# if HAVE_RAW_DECL_STRERRORNAME_NP
1244_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - " 1678_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1245 "use gnulib module strerrorname_np for portability"); 1679 "use gnulib module strerrorname_np for portability");
@@ -1249,12 +1683,11 @@ _GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1249/* Return an abbreviation string for the signal number SIG. */ 1683/* Return an abbreviation string for the signal number SIG. */
1250#if @GNULIB_SIGABBREV_NP@ 1684#if @GNULIB_SIGABBREV_NP@
1251# if ! @HAVE_SIGABBREV_NP@ 1685# if ! @HAVE_SIGABBREV_NP@
1252_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig)); 1686_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig), );
1253# endif 1687# endif
1254_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); 1688_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1255_GL_CXXALIASWARN (sigabbrev_np); 1689_GL_CXXALIASWARN (sigabbrev_np);
1256#elif defined GNULIB_POSIXCHECK 1690#elif defined GNULIB_POSIXCHECK
1257# undef sigabbrev_np
1258# if HAVE_RAW_DECL_SIGABBREV_NP 1691# if HAVE_RAW_DECL_SIGABBREV_NP
1259_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - " 1692_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1260 "use gnulib module sigabbrev_np for portability"); 1693 "use gnulib module sigabbrev_np for portability");
@@ -1264,12 +1697,11 @@ _GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1264/* Return an English description string for the signal number SIG. */ 1697/* Return an English description string for the signal number SIG. */
1265#if @GNULIB_SIGDESCR_NP@ 1698#if @GNULIB_SIGDESCR_NP@
1266# if ! @HAVE_SIGDESCR_NP@ 1699# if ! @HAVE_SIGDESCR_NP@
1267_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig)); 1700_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig), );
1268# endif 1701# endif
1269_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); 1702_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1270_GL_CXXALIASWARN (sigdescr_np); 1703_GL_CXXALIASWARN (sigdescr_np);
1271#elif defined GNULIB_POSIXCHECK 1704#elif defined GNULIB_POSIXCHECK
1272# undef sigdescr_np
1273# if HAVE_RAW_DECL_SIGDESCR_NP 1705# if HAVE_RAW_DECL_SIGDESCR_NP
1274_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - " 1706_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1275 "use gnulib module sigdescr_np for portability"); 1707 "use gnulib module sigdescr_np for portability");
@@ -1281,11 +1713,11 @@ _GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1281# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1713# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1282# define strsignal rpl_strsignal 1714# define strsignal rpl_strsignal
1283# endif 1715# endif
1284_GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); 1716_GL_FUNCDECL_RPL (strsignal, char *, (int __sig), );
1285_GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); 1717_GL_CXXALIAS_RPL (strsignal, char *, (int __sig));
1286# else 1718# else
1287# if ! @HAVE_DECL_STRSIGNAL@ 1719# if ! @HAVE_DECL_STRSIGNAL@
1288_GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); 1720_GL_FUNCDECL_SYS (strsignal, char *, (int __sig), );
1289# endif 1721# endif
1290/* Need to cast, because on Cygwin 1.5.x systems, the return type is 1722/* Need to cast, because on Cygwin 1.5.x systems, the return type is
1291 'const char *'. */ 1723 'const char *'. */
@@ -1293,7 +1725,6 @@ _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig));
1293# endif 1725# endif
1294_GL_CXXALIASWARN (strsignal); 1726_GL_CXXALIASWARN (strsignal);
1295#elif defined GNULIB_POSIXCHECK 1727#elif defined GNULIB_POSIXCHECK
1296# undef strsignal
1297# if HAVE_RAW_DECL_STRSIGNAL 1728# if HAVE_RAW_DECL_STRSIGNAL
1298_GL_WARN_ON_USE (strsignal, "strsignal is unportable - " 1729_GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1299 "use gnulib module strsignal for portability"); 1730 "use gnulib module strsignal for portability");
@@ -1301,21 +1732,31 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
1301#endif 1732#endif
1302 1733
1303#if @GNULIB_STRVERSCMP@ 1734#if @GNULIB_STRVERSCMP@
1304# if !@HAVE_STRVERSCMP@ 1735# if @REPLACE_STRVERSCMP@
1305_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) 1736# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1737# define strverscmp rpl_strverscmp
1738# endif
1739_GL_FUNCDECL_RPL (strverscmp, int, (const char *, const char *),
1306 _GL_ATTRIBUTE_PURE 1740 _GL_ATTRIBUTE_PURE
1307 _GL_ARG_NONNULL ((1, 2))); 1741 _GL_ARG_NONNULL ((1, 2)));
1308# endif 1742_GL_CXXALIAS_RPL (strverscmp, int, (const char *, const char *));
1743# else
1744# if !@HAVE_STRVERSCMP@
1745_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *),
1746 _GL_ATTRIBUTE_PURE
1747 _GL_ARG_NONNULL ((1, 2)));
1748# endif
1309_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); 1749_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
1750# endif
1310_GL_CXXALIASWARN (strverscmp); 1751_GL_CXXALIASWARN (strverscmp);
1311#elif defined GNULIB_POSIXCHECK 1752#elif defined GNULIB_POSIXCHECK
1312# undef strverscmp
1313# if HAVE_RAW_DECL_STRVERSCMP 1753# if HAVE_RAW_DECL_STRVERSCMP
1314_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " 1754_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1315 "use gnulib module strverscmp for portability"); 1755 "use gnulib module strverscmp for portability");
1316# endif 1756# endif
1317#endif 1757#endif
1318 1758
1759_GL_INLINE_HEADER_END
1319 1760
1320#endif /* _@GUARD_PREFIX@_STRING_H */ 1761#endif /* _@GUARD_PREFIX@_STRING_H */
1321#endif /* _@GUARD_PREFIX@_STRING_H */ 1762#endif /* _@GUARD_PREFIX@_STRING_H */
diff --git a/gl/strings.in.h b/gl/strings.in.h
index 2cfe8b16..fd7cd2df 100644
--- a/gl/strings.in.h
+++ b/gl/strings.in.h
@@ -1,6 +1,6 @@
1/* A substitute <strings.h>. 1/* A substitute <strings.h>.
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -36,11 +36,26 @@
36#ifndef _@GUARD_PREFIX@_STRINGS_H 36#ifndef _@GUARD_PREFIX@_STRINGS_H
37#define _@GUARD_PREFIX@_STRINGS_H 37#define _@GUARD_PREFIX@_STRINGS_H
38 38
39/* This file uses _GL_ARG_NONNULL, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
40#if !_GL_CONFIG_H_INCLUDED
41 #error "Please include config.h first."
42#endif
43
39#if ! @HAVE_DECL_STRNCASECMP@ 44#if ! @HAVE_DECL_STRNCASECMP@
40/* Get size_t. */ 45/* Get size_t. */
41# include <stddef.h> 46# include <stddef.h>
42#endif 47#endif
43 48
49#if @GNULIB_STRCASECMP_L@ || @GNULIB_STRNCASECMP_L@
50/* Get locale_t. */
51# include <locale.h>
52# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ < 10) \
53 || (defined __APPLE__ && defined __MACH__))
54/* Get the declaration of strcasecmp_l. */
55# include <string.h>
56# endif
57#endif
58
44 59
45/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 60/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
46 61
@@ -53,66 +68,161 @@ extern "C" {
53#endif 68#endif
54 69
55 70
56 /* Find the index of the least-significant set bit. */
57#if @GNULIB_FFS@ 71#if @GNULIB_FFS@
72/* Find the index of the least-significant set bit. */
58# if !@HAVE_FFS@ 73# if !@HAVE_FFS@
59_GL_FUNCDECL_SYS (ffs, int, (int i)); 74_GL_FUNCDECL_SYS (ffs, int, (int i), );
60# endif 75# endif
61_GL_CXXALIAS_SYS (ffs, int, (int i)); 76_GL_CXXALIAS_SYS (ffs, int, (int i));
62_GL_CXXALIASWARN (ffs); 77_GL_CXXALIASWARN (ffs);
63#elif defined GNULIB_POSIXCHECK 78#elif defined GNULIB_POSIXCHECK
64# undef ffs
65# if HAVE_RAW_DECL_FFS 79# if HAVE_RAW_DECL_FFS
66_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module"); 80_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
67# endif 81# endif
68#endif 82#endif
69 83
84#if @GNULIB_STRCASECMP@
70/* Compare strings S1 and S2, ignoring case, returning less than, equal to or 85/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
71 greater than zero if S1 is lexicographically less than, equal to or greater 86 greater than zero if S1 is lexicographically less than, equal to or greater
72 than S2. 87 than S2.
73 Note: This function does not work in multibyte locales. */ 88 Note: This function does not work in multibyte locales. */
74#if ! @HAVE_STRCASECMP@ 89# if @REPLACE_STRCASECMP@
75extern int strcasecmp (char const *s1, char const *s2) 90# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
76 _GL_ARG_NONNULL ((1, 2)); 91# undef strcasecmp
77#endif 92# define strcasecmp rpl_strcasecmp
78#if defined GNULIB_POSIXCHECK 93# endif
94_GL_FUNCDECL_RPL (strcasecmp, int, (const char *, const char *),
95 _GL_ARG_NONNULL ((1, 2)));
96_GL_CXXALIAS_RPL (strcasecmp, int, (const char *, const char *));
97# else
98# if !@HAVE_STRCASECMP@
99_GL_FUNCDECL_SYS (strcasecmp, int, (const char *, const char *),
100 _GL_ARG_NONNULL ((1, 2)));
101# endif
102_GL_CXXALIAS_SYS (strcasecmp, int, (const char *, const char *));
103# endif
104# if __GLIBC__ >= 2
105_GL_CXXALIASWARN (strcasecmp);
106# endif
107#elif defined GNULIB_POSIXCHECK
79/* strcasecmp() does not work with multibyte strings: 108/* strcasecmp() does not work with multibyte strings:
80 POSIX says that it operates on "strings", and "string" in POSIX is defined 109 POSIX says that it operates on "strings", and "string" in POSIX is defined
81 as a sequence of bytes, not of characters. */ 110 as a sequence of bytes, not of characters. */
82# undef strcasecmp
83# if HAVE_RAW_DECL_STRCASECMP 111# if HAVE_RAW_DECL_STRCASECMP
84_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " 112_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
85 "strings in multibyte locales - " 113 "strings in multibyte locales and is unportable - "
86 "use mbscasecmp if you care about " 114 "use mbscasecmp if you care about "
87 "internationalization, or use c_strcasecmp , " 115 "internationalization, or use c_strcasecmp "
88 "gnulib module c-strcase) if you want a locale " 116 "(gnulib module c-strcasecmp) if you want a locale "
89 "independent function"); 117 "independent function");
90# endif 118# endif
91#endif 119#endif
92 120
121#if @GNULIB_STRCASECMP_L@
122# if @REPLACE_STRCASECMP_L@
123# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
124# undef strcasecmp_l
125# define strcasecmp_l rpl_strcasecmp_l
126# endif
127_GL_FUNCDECL_RPL (strcasecmp_l, int,
128 (const char *s1, const char *s2, locale_t locale),
129 _GL_ARG_NONNULL ((1, 2, 3)));
130_GL_CXXALIAS_RPL (strcasecmp_l, int,
131 (const char *s1, const char *s2, locale_t locale));
132# else
133# if !@HAVE_STRCASECMP_L@
134_GL_FUNCDECL_SYS (strcasecmp_l, int,
135 (const char *s1, const char *s2, locale_t locale),
136 _GL_ARG_NONNULL ((1, 2, 3)));
137# endif
138_GL_CXXALIAS_SYS (strcasecmp_l, int,
139 (const char *s1, const char *s2, locale_t locale));
140# endif
141# if __GLIBC__ >= 2
142_GL_CXXALIASWARN (strcasecmp_l);
143# endif
144#elif defined GNULIB_POSIXCHECK
145/* strcasecmp_l() does not work with multibyte strings:
146 POSIX says that it operates on "strings", and "string" in POSIX is defined
147 as a sequence of bytes, not of characters. */
148# if HAVE_RAW_DECL_STRCASECMP_L
149_GL_WARN_ON_USE (strcasecmp_l, "strcasecmp_l cannot work correctly on "
150 "character strings in multibyte locales and is unportable - "
151 "use gnulib module strcasecmp_l for portability");
152# endif
153#endif
154
155#if @GNULIB_STRNCASECMP@
93/* Compare no more than N bytes of strings S1 and S2, ignoring case, 156/* Compare no more than N bytes of strings S1 and S2, ignoring case,
94 returning less than, equal to or greater than zero if S1 is 157 returning less than, equal to or greater than zero if S1 is
95 lexicographically less than, equal to or greater than S2. 158 lexicographically less than, equal to or greater than S2.
96 Note: This function cannot work correctly in multibyte locales. */ 159 Note: This function cannot work correctly in multibyte locales. */
97#if ! @HAVE_DECL_STRNCASECMP@ 160# if @REPLACE_STRNCASECMP@
98extern int strncasecmp (char const *s1, char const *s2, size_t n) 161# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
99 _GL_ARG_NONNULL ((1, 2)); 162# undef strncasecmp
100#endif 163# define strncasecmp rpl_strncasecmp
101#if defined GNULIB_POSIXCHECK 164# endif
165_GL_FUNCDECL_RPL (strncasecmp, int, (const char *, const char *, size_t),
166 _GL_ARG_NONNULL ((1, 2)));
167_GL_CXXALIAS_RPL (strncasecmp, int, (const char *, const char *, size_t));
168# else
169# if !@HAVE_DECL_STRNCASECMP@
170_GL_FUNCDECL_SYS (strncasecmp, int, (const char *, const char *, size_t),
171 _GL_ARG_NONNULL ((1, 2)));
172# endif
173_GL_CXXALIAS_SYS (strncasecmp, int, (const char *, const char *, size_t));
174# endif
175# if __GLIBC__ >= 2
176_GL_CXXALIASWARN (strncasecmp);
177# endif
178#elif defined GNULIB_POSIXCHECK
102/* strncasecmp() does not work with multibyte strings: 179/* strncasecmp() does not work with multibyte strings:
103 POSIX says that it operates on "strings", and "string" in POSIX is defined 180 POSIX says that it operates on "strings", and "string" in POSIX is defined
104 as a sequence of bytes, not of characters. */ 181 as a sequence of bytes, not of characters. */
105# undef strncasecmp
106# if HAVE_RAW_DECL_STRNCASECMP 182# if HAVE_RAW_DECL_STRNCASECMP
107_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " 183_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
108 "strings in multibyte locales - " 184 "strings in multibyte locales and is unportable - "
109 "use mbsncasecmp or mbspcasecmp if you care about " 185 "use mbsncasecmp or mbspcasecmp if you care about "
110 "internationalization, or use c_strncasecmp , " 186 "internationalization, or use c_strncasecmp "
111 "gnulib module c-strcase) if you want a locale " 187 "(gnulib module c-strncasecmp) if you want a locale "
112 "independent function"); 188 "independent function");
113# endif 189# endif
114#endif 190#endif
115 191
192#if @GNULIB_STRNCASECMP_L@
193# if @REPLACE_STRNCASECMP_L@
194# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
195# undef strncasecmp_l
196# define strncasecmp_l rpl_strncasecmp_l
197# endif
198_GL_FUNCDECL_RPL (strncasecmp_l, int,
199 (const char *s1, const char *s2, size_t n, locale_t locale),
200 _GL_ARG_NONNULL ((1, 2, 4)));
201_GL_CXXALIAS_RPL (strncasecmp_l, int,
202 (const char *s1, const char *s2, size_t n, locale_t locale));
203# else
204# if !@HAVE_STRNCASECMP_L@
205_GL_FUNCDECL_SYS (strncasecmp_l, int,
206 (const char *s1, const char *s2, size_t n, locale_t locale),
207 _GL_ARG_NONNULL ((1, 2, 4)));
208# endif
209_GL_CXXALIAS_SYS (strncasecmp_l, int,
210 (const char *s1, const char *s2, size_t n, locale_t locale));
211# endif
212# if __GLIBC__ >= 2
213_GL_CXXALIASWARN (strncasecmp_l);
214# endif
215#elif defined GNULIB_POSIXCHECK
216/* strncasecmp_l() does not work with multibyte strings:
217 POSIX says that it operates on "strings", and "string" in POSIX is defined
218 as a sequence of bytes, not of characters. */
219# if HAVE_RAW_DECL_STRNCASECMP_L
220_GL_WARN_ON_USE (strncasecmp_l, "strncasecmp_l cannot work correctly on "
221 "character strings in multibyte locales and is unportable - "
222 "use gnulib module strncasecmp_l for portability");
223# endif
224#endif
225
116 226
117#ifdef __cplusplus 227#ifdef __cplusplus
118} 228}
diff --git a/gl/stripslash.c b/gl/stripslash.c
index fe46a9c1..8f8c38e3 100644
--- a/gl/stripslash.c
+++ b/gl/stripslash.c
@@ -1,6 +1,6 @@
1/* stripslash.c -- remove redundant trailing slashes from a file name 1/* stripslash.c -- remove redundant trailing slashes from a file name
2 2
3 Copyright (C) 1990, 2001, 2003-2006, 2009-2023 Free Software Foundation, 3 Copyright (C) 1990, 2001, 2003-2006, 2009-2026 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -31,15 +31,13 @@ bool
31strip_trailing_slashes (char *file) 31strip_trailing_slashes (char *file)
32{ 32{
33 char *base = last_component (file); 33 char *base = last_component (file);
34 char *base_lim;
35 bool had_slash;
36 34
37 /* last_component returns "" for file system roots, but we need to turn 35 /* last_component returns "" for file system roots, but we need to turn
38 "///" into "/". */ 36 "///" into "/". */
39 if (! *base) 37 if (! *base)
40 base = file; 38 base = file;
41 base_lim = base + base_len (base); 39 char *base_lim = base + base_len (base);
42 had_slash = (*base_lim != '\0'); 40 bool had_slash = (*base_lim != '\0');
43 *base_lim = '\0'; 41 *base_lim = '\0';
44 return had_slash; 42 return had_slash;
45} 43}
diff --git a/gl/strncasecmp.c b/gl/strncasecmp.c
index c5c2cd35..c6bec00d 100644
--- a/gl/strncasecmp.c
+++ b/gl/strncasecmp.c
@@ -1,5 +1,5 @@
1/* strncasecmp.c -- case insensitive string comparator 1/* Case-insensitive string comparison function for unibyte locales.
2 Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2007, 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -17,13 +17,11 @@
17#include <config.h> 17#include <config.h>
18 18
19/* Specification. */ 19/* Specification. */
20#include <string.h> 20#include <strings.h>
21 21
22#include <ctype.h> 22#include <ctype.h>
23#include <limits.h> 23#include <limits.h>
24 24
25#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
26
27/* Compare no more than N bytes of strings S1 and S2, ignoring case, 25/* Compare no more than N bytes of strings S1 and S2, ignoring case,
28 returning less than, equal to or greater than zero if S1 is 26 returning less than, equal to or greater than zero if S1 is
29 lexicographically less than, equal to or greater than S2. 27 lexicographically less than, equal to or greater than S2.
@@ -34,29 +32,24 @@ strncasecmp (const char *s1, const char *s2, size_t n)
34{ 32{
35 register const unsigned char *p1 = (const unsigned char *) s1; 33 register const unsigned char *p1 = (const unsigned char *) s1;
36 register const unsigned char *p2 = (const unsigned char *) s2; 34 register const unsigned char *p2 = (const unsigned char *) s2;
37 unsigned char c1, c2;
38 35
39 if (p1 == p2 || n == 0) 36 if (p1 == p2 || n == 0)
40 return 0; 37 return 0;
41 38
42 do 39 for (;; p1++, p2++)
43 { 40 {
44 c1 = TOLOWER (*p1); 41 unsigned char c1 = tolower (*p1);
45 c2 = TOLOWER (*p2); 42 unsigned char c2 = tolower (*p2);
46 43
47 if (--n == 0 || c1 == '\0') 44 if (--n == 0 || c1 == '\0' || c1 != c2)
48 break; 45 {
49 46 if (UCHAR_MAX <= INT_MAX)
50 ++p1; 47 return c1 - c2;
51 ++p2; 48 else
49 /* On machines where 'char' and 'int' are types of the same size,
50 the difference of two 'unsigned char' values - including the
51 sign bit - doesn't fit in an 'int'. */
52 return _GL_CMP (c1, c2);
53 }
52 } 54 }
53 while (c1 == c2);
54
55 if (UCHAR_MAX <= INT_MAX)
56 return c1 - c2;
57 else
58 /* On machines where 'char' and 'int' are types of the same size, the
59 difference of two 'unsigned char' values - including the sign bit -
60 doesn't fit in an 'int'. */
61 return _GL_CMP (c1, c2);
62} 55}
diff --git a/gl/strncpy.c b/gl/strncpy.c
new file mode 100644
index 00000000..25908377
--- /dev/null
+++ b/gl/strncpy.c
@@ -0,0 +1,38 @@
1/* Copy a size-bounded string.
2 Copyright (C) 1999, 2011-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 1999. */
18
19#include <config.h>
20
21/* Specification. */
22#include <string.h>
23
24char *
25strncpy (char *dest, const char *src, size_t n)
26{
27 char *destptr = dest;
28
29 for (; n > 0 && (*destptr = *src) != '\0'; src++, destptr++, n--)
30 ;
31
32 /* This behavior is rarely useful, but it is specified by the ISO C
33 standard. */
34 for (; n > 0; n--)
35 *destptr++ = '\0';
36
37 return dest;
38}
diff --git a/gl/strsep.c b/gl/strsep.c
index 8e9708a3..6338c62d 100644
--- a/gl/strsep.c
+++ b/gl/strsep.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 2004, 2007, 2009-2023 Free Software Foundation, Inc. 1/* Copyright (C) 2004, 2007, 2009-2026 Free Software Foundation, Inc.
2 2
3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
@@ -26,7 +26,6 @@ char *
26strsep (char **stringp, const char *delim) 26strsep (char **stringp, const char *delim)
27{ 27{
28 char *start = *stringp; 28 char *start = *stringp;
29 char *ptr;
30 29
31 if (start == NULL) 30 if (start == NULL)
32 return NULL; 31 return NULL;
@@ -38,12 +37,14 @@ strsep (char **stringp, const char *delim)
38 return start; 37 return start;
39 } 38 }
40 39
40 char *ptr;
41 /* Optimize the case of one delimiter. */ 41 /* Optimize the case of one delimiter. */
42 if (delim[1] == '\0') 42 if (delim[1] == '\0')
43 ptr = strchr (start, delim[0]); 43 ptr = strchr (start, delim[0]);
44 else 44 else
45 /* The general case. */ 45 /* The general case. */
46 ptr = strpbrk (start, delim); 46 ptr = strpbrk (start, delim);
47
47 if (ptr == NULL) 48 if (ptr == NULL)
48 { 49 {
49 *stringp = NULL; 50 *stringp = NULL;
diff --git a/gl/strstr.c b/gl/strstr.c
index 574f4d50..a5730a37 100644
--- a/gl/strstr.c
+++ b/gl/strstr.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2023 Free Software 1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2026 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
@@ -36,31 +36,33 @@
36char * 36char *
37strstr (const char *haystack_start, const char *needle_start) 37strstr (const char *haystack_start, const char *needle_start)
38{ 38{
39 const char *haystack = haystack_start;
40 const char *needle = needle_start; 39 const char *needle = needle_start;
41 size_t needle_len; /* Length of NEEDLE. */
42 size_t haystack_len; /* Known minimum length of HAYSTACK. */
43 bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
44 40
45 /* Determine length of NEEDLE, and in the process, make sure 41 /* Determine length of NEEDLE, and in the process, make sure
46 HAYSTACK is at least as long (no point processing all of a long 42 HAYSTACK is at least as long (no point processing all of a long
47 NEEDLE if HAYSTACK is too short). */ 43 NEEDLE if HAYSTACK is too short). */
48 while (*haystack && *needle) 44 {
49 ok &= *haystack++ == *needle++; 45 const char *haystack = haystack_start;
50 if (*needle) 46 bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
51 return NULL; 47 while (*haystack && *needle)
52 if (ok) 48 ok &= *haystack++ == *needle++;
53 return (char *) haystack_start; 49 if (*needle)
50 return NULL;
51 if (ok)
52 return (char *) haystack_start;
53 }
54 54
55 /* Reduce the size of haystack using strchr, since it has a smaller 55 /* Reduce the size of haystack using strchr, since it has a smaller
56 linear coefficient than the Two-Way algorithm. */ 56 linear coefficient than the Two-Way algorithm. */
57 needle_len = needle - needle_start; 57 size_t needle_len = /* Length of NEEDLE. */
58 haystack = strchr (haystack_start + 1, *needle_start); 58 needle - needle_start;
59 const char *haystack = strchr (haystack_start + 1, *needle_start);
59 if (!haystack || __builtin_expect (needle_len == 1, 0)) 60 if (!haystack || __builtin_expect (needle_len == 1, 0))
60 return (char *) haystack; 61 return (char *) haystack;
61 needle -= needle_len; 62 needle -= needle_len;
62 haystack_len = (haystack > haystack_start + needle_len ? 1 63 size_t haystack_len = /* Known minimum length of HAYSTACK. */
63 : needle_len + haystack_start - haystack); 64 (haystack > haystack_start + needle_len ? 1
65 : needle_len + haystack_start - haystack);
64 66
65 /* Perform the search. Abstract memory is considered to be an array 67 /* Perform the search. Abstract memory is considered to be an array
66 of 'unsigned char' values, not an array of 'char' values. See 68 of 'unsigned char' values, not an array of 'char' values. See
diff --git a/gl/sys-limits.h b/gl/sys-limits.h
index 0e9556d6..d61ebdf7 100644
--- a/gl/sys-limits.h
+++ b/gl/sys-limits.h
@@ -1,6 +1,6 @@
1/* System call limits 1/* System call limits
2 2
3 Copyright 2018-2023 Free Software Foundation, Inc. 3 Copyright 2018-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -30,10 +30,6 @@
30 Using this also works around a serious Linux bug before 2.6.16; see 30 Using this also works around a serious Linux bug before 2.6.16; see
31 <https://bugzilla.redhat.com/show_bug.cgi?id=612839>. 31 <https://bugzilla.redhat.com/show_bug.cgi?id=612839>.
32 32
33 Using this also works around a Tru64 5.1 bug, where attempting
34 to read INT_MAX bytes fails with errno == EINVAL. See
35 <https://lists.gnu.org/r/bug-gnu-utils/2002-04/msg00010.html>.
36
37 Using this is likely to work around similar bugs in other operating 33 Using this is likely to work around similar bugs in other operating
38 systems. */ 34 systems. */
39 35
diff --git a/gl/sys_socket.c b/gl/sys_socket.c
index b7388cec..023a7c55 100644
--- a/gl/sys_socket.c
+++ b/gl/sys_socket.c
@@ -1,6 +1,6 @@
1/* Inline functions for <sys/socket.h>. 1/* Inline functions for <sys/socket.h>.
2 2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc. 3 Copyright (C) 2012-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,8 +15,8 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE
18#include <config.h> 19#include <config.h>
19 20
20#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE 21#include <sys/socket.h>
21#include "sys/socket.h"
22typedef int dummy; 22typedef int dummy;
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index 6705593f..c19b7461 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,6 +1,6 @@
1/* Provide a sys/socket header file for systems lacking it (read: MinGW) 1/* Provide a sys/socket header file for systems lacking it (read: MinGW)
2 and for systems where it is incomplete. 2 and for systems where it is incomplete.
3 Copyright (C) 2005-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005-2026 Free Software Foundation, Inc.
4 Written by Simon Josefsson. 4 Written by Simon Josefsson.
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
@@ -27,7 +27,7 @@
27#endif 27#endif
28@PRAGMA_COLUMNS@ 28@PRAGMA_COLUMNS@
29 29
30#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H 30#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_SYS_SOCKET_H
31/* Special invocation convention: 31/* Special invocation convention:
32 - On Cygwin 1.5.x we have a sequence of nested includes 32 - On Cygwin 1.5.x we have a sequence of nested includes
33 <sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>, 33 <sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>,
@@ -43,7 +43,7 @@
43 43
44#if @HAVE_SYS_SOCKET_H@ 44#if @HAVE_SYS_SOCKET_H@
45 45
46# define _GL_ALREADY_INCLUDING_SYS_SOCKET_H 46# define _@GUARD_PREFIX@_ALREADY_INCLUDING_SYS_SOCKET_H
47 47
48/* On many platforms, <sys/socket.h> assumes prior inclusion of 48/* On many platforms, <sys/socket.h> assumes prior inclusion of
49 <sys/types.h>. */ 49 <sys/types.h>. */
@@ -56,16 +56,19 @@
56/* The include_next requires a split double-inclusion guard. */ 56/* The include_next requires a split double-inclusion guard. */
57# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ 57# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
58 58
59# undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H 59# undef _@GUARD_PREFIX@_ALREADY_INCLUDING_SYS_SOCKET_H
60 60
61#endif 61#endif
62 62
63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H 63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
64#define _@GUARD_PREFIX@_SYS_SOCKET_H 64#define _@GUARD_PREFIX@_SYS_SOCKET_H
65 65
66#ifndef _GL_INLINE_HEADER_BEGIN 66/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK,
67 HAVE_RAW_DECL_*, alignof. */
68#if !_GL_CONFIG_H_INCLUDED
67 #error "Please include config.h first." 69 #error "Please include config.h first."
68#endif 70#endif
71
69_GL_INLINE_HEADER_BEGIN 72_GL_INLINE_HEADER_BEGIN
70#ifndef _GL_SYS_SOCKET_INLINE 73#ifndef _GL_SYS_SOCKET_INLINE
71# define _GL_SYS_SOCKET_INLINE _GL_INLINE 74# define _GL_SYS_SOCKET_INLINE _GL_INLINE
@@ -199,6 +202,7 @@ struct sockaddr_storage
199 202
200/* Rudimentary 'struct msghdr'; this works as long as you don't try to 203/* Rudimentary 'struct msghdr'; this works as long as you don't try to
201 access msg_control or msg_controllen. */ 204 access msg_control or msg_controllen. */
205# if !defined GNULIB_defined_struct_msghdr
202struct msghdr { 206struct msghdr {
203 void *msg_name; 207 void *msg_name;
204 socklen_t msg_namelen; 208 socklen_t msg_namelen;
@@ -206,6 +210,8 @@ struct msghdr {
206 int msg_iovlen; 210 int msg_iovlen;
207 int msg_flags; 211 int msg_flags;
208}; 212};
213# define GNULIB_defined_struct_msghdr 1
214# endif
209 215
210#endif 216#endif
211 217
@@ -229,11 +235,10 @@ struct msghdr {
229_GL_SYS_SOCKET_INLINE int 235_GL_SYS_SOCKET_INLINE int
230rpl_fd_isset (SOCKET fd, fd_set * set) 236rpl_fd_isset (SOCKET fd, fd_set * set)
231{ 237{
232 u_int i;
233 if (set == NULL) 238 if (set == NULL)
234 return 0; 239 return 0;
235 240
236 for (i = 0; i < set->fd_count; i++) 241 for (u_int i = 0; i < set->fd_count; i++)
237 if (set->fd_array[i] == fd) 242 if (set->fd_array[i] == fd)
238 return 1; 243 return 1;
239 244
@@ -286,17 +291,18 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
286# undef socket 291# undef socket
287# define socket rpl_socket 292# define socket rpl_socket
288# endif 293# endif
289_GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol)); 294_GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol), );
290_GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol)); 295_GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol));
291# else 296# else
292_GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol)); 297_GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol));
293# endif 298# endif
294_GL_CXXALIASWARN (socket); 299_GL_CXXALIASWARN (socket);
295#elif @HAVE_WINSOCK2_H@ 300#elif @HAVE_WINSOCK2_H@
296# undef socket 301# if !GNULIB_SOCKET
297# define socket socket_used_without_requesting_gnulib_module_socket 302# undef socket
303# define socket socket_used_without_requesting_gnulib_module_socket
304# endif
298#elif defined GNULIB_POSIXCHECK 305#elif defined GNULIB_POSIXCHECK
299# undef socket
300# if HAVE_RAW_DECL_SOCKET 306# if HAVE_RAW_DECL_SOCKET
301_GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - " 307_GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
302 "use gnulib module socket for portability"); 308 "use gnulib module socket for portability");
@@ -310,7 +316,7 @@ _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
310# define connect rpl_connect 316# define connect rpl_connect
311# endif 317# endif
312_GL_FUNCDECL_RPL (connect, int, 318_GL_FUNCDECL_RPL (connect, int,
313 (int fd, const struct sockaddr *addr, socklen_t addrlen) 319 (int fd, const struct sockaddr *addr, socklen_t addrlen),
314 _GL_ARG_NONNULL ((2))); 320 _GL_ARG_NONNULL ((2)));
315_GL_CXXALIAS_RPL (connect, int, 321_GL_CXXALIAS_RPL (connect, int,
316 (int fd, const struct sockaddr *addr, socklen_t addrlen)); 322 (int fd, const struct sockaddr *addr, socklen_t addrlen));
@@ -323,10 +329,11 @@ _GL_CXXALIAS_SYS_CAST (connect, int,
323# endif 329# endif
324_GL_CXXALIASWARN (connect); 330_GL_CXXALIASWARN (connect);
325#elif @HAVE_WINSOCK2_H@ 331#elif @HAVE_WINSOCK2_H@
326# undef connect 332# if !GNULIB_CONNECT
327# define connect socket_used_without_requesting_gnulib_module_connect 333# undef connect
334# define connect connect_used_without_requesting_gnulib_module_connect
335# endif
328#elif defined GNULIB_POSIXCHECK 336#elif defined GNULIB_POSIXCHECK
329# undef connect
330# if HAVE_RAW_DECL_CONNECT 337# if HAVE_RAW_DECL_CONNECT
331_GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - " 338_GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
332 "use gnulib module connect for portability"); 339 "use gnulib module connect for portability");
@@ -342,7 +349,7 @@ _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
342_GL_FUNCDECL_RPL (accept, int, 349_GL_FUNCDECL_RPL (accept, int,
343 (int fd, 350 (int fd,
344 struct sockaddr *restrict addr, 351 struct sockaddr *restrict addr,
345 socklen_t *restrict addrlen)); 352 socklen_t *restrict addrlen), );
346_GL_CXXALIAS_RPL (accept, int, 353_GL_CXXALIAS_RPL (accept, int,
347 (int fd, 354 (int fd,
348 struct sockaddr *restrict addr, 355 struct sockaddr *restrict addr,
@@ -355,12 +362,15 @@ _GL_CXXALIAS_SYS_CAST (accept, int,
355 struct sockaddr *restrict addr, 362 struct sockaddr *restrict addr,
356 socklen_t *restrict addrlen)); 363 socklen_t *restrict addrlen));
357# endif 364# endif
365# if __GLIBC__ >= 2
358_GL_CXXALIASWARN (accept); 366_GL_CXXALIASWARN (accept);
367# endif
359#elif @HAVE_WINSOCK2_H@ 368#elif @HAVE_WINSOCK2_H@
360# undef accept 369# if !GNULIB_ACCEPT
361# define accept accept_used_without_requesting_gnulib_module_accept 370# undef accept
371# define accept accept_used_without_requesting_gnulib_module_accept
372# endif
362#elif defined GNULIB_POSIXCHECK 373#elif defined GNULIB_POSIXCHECK
363# undef accept
364# if HAVE_RAW_DECL_ACCEPT 374# if HAVE_RAW_DECL_ACCEPT
365_GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - " 375_GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
366 "use gnulib module accept for portability"); 376 "use gnulib module accept for portability");
@@ -374,7 +384,7 @@ _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
374# define bind rpl_bind 384# define bind rpl_bind
375# endif 385# endif
376_GL_FUNCDECL_RPL (bind, int, 386_GL_FUNCDECL_RPL (bind, int,
377 (int fd, const struct sockaddr *addr, socklen_t addrlen) 387 (int fd, const struct sockaddr *addr, socklen_t addrlen),
378 _GL_ARG_NONNULL ((2))); 388 _GL_ARG_NONNULL ((2)));
379_GL_CXXALIAS_RPL (bind, int, 389_GL_CXXALIAS_RPL (bind, int,
380 (int fd, const struct sockaddr *addr, socklen_t addrlen)); 390 (int fd, const struct sockaddr *addr, socklen_t addrlen));
@@ -387,10 +397,11 @@ _GL_CXXALIAS_SYS_CAST (bind, int,
387# endif 397# endif
388_GL_CXXALIASWARN (bind); 398_GL_CXXALIASWARN (bind);
389#elif @HAVE_WINSOCK2_H@ 399#elif @HAVE_WINSOCK2_H@
390# undef bind 400# if !GNULIB_BIND
391# define bind bind_used_without_requesting_gnulib_module_bind 401# undef bind
402# define bind bind_used_without_requesting_gnulib_module_bind
403# endif
392#elif defined GNULIB_POSIXCHECK 404#elif defined GNULIB_POSIXCHECK
393# undef bind
394# if HAVE_RAW_DECL_BIND 405# if HAVE_RAW_DECL_BIND
395_GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - " 406_GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
396 "use gnulib module bind for portability"); 407 "use gnulib module bind for portability");
@@ -405,7 +416,7 @@ _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
405# endif 416# endif
406_GL_FUNCDECL_RPL (getpeername, int, 417_GL_FUNCDECL_RPL (getpeername, int,
407 (int fd, struct sockaddr *restrict addr, 418 (int fd, struct sockaddr *restrict addr,
408 socklen_t *restrict addrlen) 419 socklen_t *restrict addrlen),
409 _GL_ARG_NONNULL ((2, 3))); 420 _GL_ARG_NONNULL ((2, 3)));
410_GL_CXXALIAS_RPL (getpeername, int, 421_GL_CXXALIAS_RPL (getpeername, int,
411 (int fd, struct sockaddr *restrict addr, 422 (int fd, struct sockaddr *restrict addr,
@@ -417,12 +428,15 @@ _GL_CXXALIAS_SYS_CAST (getpeername, int,
417 (int fd, struct sockaddr *restrict addr, 428 (int fd, struct sockaddr *restrict addr,
418 socklen_t *restrict addrlen)); 429 socklen_t *restrict addrlen));
419# endif 430# endif
431# if __GLIBC__ >= 2
420_GL_CXXALIASWARN (getpeername); 432_GL_CXXALIASWARN (getpeername);
433# endif
421#elif @HAVE_WINSOCK2_H@ 434#elif @HAVE_WINSOCK2_H@
422# undef getpeername 435# if !GNULIB_GETPEERNAME
423# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername 436# undef getpeername
437# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
438# endif
424#elif defined GNULIB_POSIXCHECK 439#elif defined GNULIB_POSIXCHECK
425# undef getpeername
426# if HAVE_RAW_DECL_GETPEERNAME 440# if HAVE_RAW_DECL_GETPEERNAME
427_GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - " 441_GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
428 "use gnulib module getpeername for portability"); 442 "use gnulib module getpeername for portability");
@@ -437,7 +451,7 @@ _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
437# endif 451# endif
438_GL_FUNCDECL_RPL (getsockname, int, 452_GL_FUNCDECL_RPL (getsockname, int,
439 (int fd, struct sockaddr *restrict addr, 453 (int fd, struct sockaddr *restrict addr,
440 socklen_t *restrict addrlen) 454 socklen_t *restrict addrlen),
441 _GL_ARG_NONNULL ((2, 3))); 455 _GL_ARG_NONNULL ((2, 3)));
442_GL_CXXALIAS_RPL (getsockname, int, 456_GL_CXXALIAS_RPL (getsockname, int,
443 (int fd, struct sockaddr *restrict addr, 457 (int fd, struct sockaddr *restrict addr,
@@ -449,12 +463,15 @@ _GL_CXXALIAS_SYS_CAST (getsockname, int,
449 (int fd, struct sockaddr *restrict addr, 463 (int fd, struct sockaddr *restrict addr,
450 socklen_t *restrict addrlen)); 464 socklen_t *restrict addrlen));
451# endif 465# endif
466# if __GLIBC__ >= 2
452_GL_CXXALIASWARN (getsockname); 467_GL_CXXALIASWARN (getsockname);
468# endif
453#elif @HAVE_WINSOCK2_H@ 469#elif @HAVE_WINSOCK2_H@
454# undef getsockname 470# if !GNULIB_GETSOCKNAME
455# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname 471# undef getsockname
472# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
473# endif
456#elif defined GNULIB_POSIXCHECK 474#elif defined GNULIB_POSIXCHECK
457# undef getsockname
458# if HAVE_RAW_DECL_GETSOCKNAME 475# if HAVE_RAW_DECL_GETSOCKNAME
459_GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - " 476_GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
460 "use gnulib module getsockname for portability"); 477 "use gnulib module getsockname for portability");
@@ -469,7 +486,7 @@ _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
469# endif 486# endif
470_GL_FUNCDECL_RPL (getsockopt, int, 487_GL_FUNCDECL_RPL (getsockopt, int,
471 (int fd, int level, int optname, 488 (int fd, int level, int optname,
472 void *restrict optval, socklen_t *restrict optlen) 489 void *restrict optval, socklen_t *restrict optlen),
473 _GL_ARG_NONNULL ((4, 5))); 490 _GL_ARG_NONNULL ((4, 5)));
474_GL_CXXALIAS_RPL (getsockopt, int, 491_GL_CXXALIAS_RPL (getsockopt, int,
475 (int fd, int level, int optname, 492 (int fd, int level, int optname,
@@ -483,10 +500,11 @@ _GL_CXXALIAS_SYS_CAST (getsockopt, int,
483# endif 500# endif
484_GL_CXXALIASWARN (getsockopt); 501_GL_CXXALIASWARN (getsockopt);
485#elif @HAVE_WINSOCK2_H@ 502#elif @HAVE_WINSOCK2_H@
486# undef getsockopt 503# if !GNULIB_GETSOCKOPT
487# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt 504# undef getsockopt
505# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
506# endif
488#elif defined GNULIB_POSIXCHECK 507#elif defined GNULIB_POSIXCHECK
489# undef getsockopt
490# if HAVE_RAW_DECL_GETSOCKOPT 508# if HAVE_RAW_DECL_GETSOCKOPT
491_GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - " 509_GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
492 "use gnulib module getsockopt for portability"); 510 "use gnulib module getsockopt for portability");
@@ -499,17 +517,18 @@ _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
499# undef listen 517# undef listen
500# define listen rpl_listen 518# define listen rpl_listen
501# endif 519# endif
502_GL_FUNCDECL_RPL (listen, int, (int fd, int backlog)); 520_GL_FUNCDECL_RPL (listen, int, (int fd, int backlog), );
503_GL_CXXALIAS_RPL (listen, int, (int fd, int backlog)); 521_GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
504# else 522# else
505_GL_CXXALIAS_SYS (listen, int, (int fd, int backlog)); 523_GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
506# endif 524# endif
507_GL_CXXALIASWARN (listen); 525_GL_CXXALIASWARN (listen);
508#elif @HAVE_WINSOCK2_H@ 526#elif @HAVE_WINSOCK2_H@
509# undef listen 527# if !GNULIB_LISTEN
510# define listen listen_used_without_requesting_gnulib_module_listen 528# undef listen
529# define listen listen_used_without_requesting_gnulib_module_listen
530# endif
511#elif defined GNULIB_POSIXCHECK 531#elif defined GNULIB_POSIXCHECK
512# undef listen
513# if HAVE_RAW_DECL_LISTEN 532# if HAVE_RAW_DECL_LISTEN
514_GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - " 533_GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
515 "use gnulib module listen for portability"); 534 "use gnulib module listen for portability");
@@ -522,7 +541,7 @@ _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
522# undef recv 541# undef recv
523# define recv rpl_recv 542# define recv rpl_recv
524# endif 543# endif
525_GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags) 544_GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags),
526 _GL_ARG_NONNULL ((2))); 545 _GL_ARG_NONNULL ((2)));
527_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 546_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
528# else 547# else
@@ -533,10 +552,11 @@ _GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
533# endif 552# endif
534_GL_CXXALIASWARN (recv); 553_GL_CXXALIASWARN (recv);
535#elif @HAVE_WINSOCK2_H@ 554#elif @HAVE_WINSOCK2_H@
536# undef recv 555# if !GNULIB_RECV
537# define recv recv_used_without_requesting_gnulib_module_recv 556# undef recv
557# define recv recv_used_without_requesting_gnulib_module_recv
558# endif
538#elif defined GNULIB_POSIXCHECK 559#elif defined GNULIB_POSIXCHECK
539# undef recv
540# if HAVE_RAW_DECL_RECV 560# if HAVE_RAW_DECL_RECV
541_GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - " 561_GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
542 "use gnulib module recv for portability"); 562 "use gnulib module recv for portability");
@@ -550,7 +570,7 @@ _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
550# define send rpl_send 570# define send rpl_send
551# endif 571# endif
552_GL_FUNCDECL_RPL (send, ssize_t, 572_GL_FUNCDECL_RPL (send, ssize_t,
553 (int fd, const void *buf, size_t len, int flags) 573 (int fd, const void *buf, size_t len, int flags),
554 _GL_ARG_NONNULL ((2))); 574 _GL_ARG_NONNULL ((2)));
555_GL_CXXALIAS_RPL (send, ssize_t, 575_GL_CXXALIAS_RPL (send, ssize_t,
556 (int fd, const void *buf, size_t len, int flags)); 576 (int fd, const void *buf, size_t len, int flags));
@@ -563,10 +583,11 @@ _GL_CXXALIAS_SYS_CAST (send, ssize_t,
563# endif 583# endif
564_GL_CXXALIASWARN (send); 584_GL_CXXALIASWARN (send);
565#elif @HAVE_WINSOCK2_H@ 585#elif @HAVE_WINSOCK2_H@
566# undef send 586# if !GNULIB_SEND
567# define send send_used_without_requesting_gnulib_module_send 587# undef send
588# define send send_used_without_requesting_gnulib_module_send
589# endif
568#elif defined GNULIB_POSIXCHECK 590#elif defined GNULIB_POSIXCHECK
569# undef send
570# if HAVE_RAW_DECL_SEND 591# if HAVE_RAW_DECL_SEND
571_GL_WARN_ON_USE (send, "send is not always POSIX compliant - " 592_GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
572 "use gnulib module send for portability"); 593 "use gnulib module send for portability");
@@ -582,7 +603,7 @@ _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
582_GL_FUNCDECL_RPL (recvfrom, ssize_t, 603_GL_FUNCDECL_RPL (recvfrom, ssize_t,
583 (int fd, void *restrict buf, size_t len, int flags, 604 (int fd, void *restrict buf, size_t len, int flags,
584 struct sockaddr *restrict from, 605 struct sockaddr *restrict from,
585 socklen_t *restrict fromlen) 606 socklen_t *restrict fromlen),
586 _GL_ARG_NONNULL ((2))); 607 _GL_ARG_NONNULL ((2)));
587_GL_CXXALIAS_RPL (recvfrom, ssize_t, 608_GL_CXXALIAS_RPL (recvfrom, ssize_t,
588 (int fd, void *restrict buf, size_t len, int flags, 609 (int fd, void *restrict buf, size_t len, int flags,
@@ -596,12 +617,15 @@ _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
596 struct sockaddr *restrict from, 617 struct sockaddr *restrict from,
597 socklen_t *restrict fromlen)); 618 socklen_t *restrict fromlen));
598# endif 619# endif
620# if __GLIBC__ >= 2
599_GL_CXXALIASWARN (recvfrom); 621_GL_CXXALIASWARN (recvfrom);
622# endif
600#elif @HAVE_WINSOCK2_H@ 623#elif @HAVE_WINSOCK2_H@
601# undef recvfrom 624# if !GNULIB_RECVFROM
602# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom 625# undef recvfrom
626# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
627# endif
603#elif defined GNULIB_POSIXCHECK 628#elif defined GNULIB_POSIXCHECK
604# undef recvfrom
605# if HAVE_RAW_DECL_RECVFROM 629# if HAVE_RAW_DECL_RECVFROM
606_GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - " 630_GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
607 "use gnulib module recvfrom for portability"); 631 "use gnulib module recvfrom for portability");
@@ -616,7 +640,7 @@ _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
616# endif 640# endif
617_GL_FUNCDECL_RPL (sendto, ssize_t, 641_GL_FUNCDECL_RPL (sendto, ssize_t,
618 (int fd, const void *buf, size_t len, int flags, 642 (int fd, const void *buf, size_t len, int flags,
619 const struct sockaddr *to, socklen_t tolen) 643 const struct sockaddr *to, socklen_t tolen),
620 _GL_ARG_NONNULL ((2))); 644 _GL_ARG_NONNULL ((2)));
621_GL_CXXALIAS_RPL (sendto, ssize_t, 645_GL_CXXALIAS_RPL (sendto, ssize_t,
622 (int fd, const void *buf, size_t len, int flags, 646 (int fd, const void *buf, size_t len, int flags,
@@ -630,10 +654,11 @@ _GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
630# endif 654# endif
631_GL_CXXALIASWARN (sendto); 655_GL_CXXALIASWARN (sendto);
632#elif @HAVE_WINSOCK2_H@ 656#elif @HAVE_WINSOCK2_H@
633# undef sendto 657# if !GNULIB_SENDTO
634# define sendto sendto_used_without_requesting_gnulib_module_sendto 658# undef sendto
659# define sendto sendto_used_without_requesting_gnulib_module_sendto
660# endif
635#elif defined GNULIB_POSIXCHECK 661#elif defined GNULIB_POSIXCHECK
636# undef sendto
637# if HAVE_RAW_DECL_SENDTO 662# if HAVE_RAW_DECL_SENDTO
638_GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - " 663_GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
639 "use gnulib module sendto for portability"); 664 "use gnulib module sendto for portability");
@@ -647,7 +672,7 @@ _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
647# define setsockopt rpl_setsockopt 672# define setsockopt rpl_setsockopt
648# endif 673# endif
649_GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname, 674_GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
650 const void * optval, socklen_t optlen) 675 const void * optval, socklen_t optlen),
651 _GL_ARG_NONNULL ((4))); 676 _GL_ARG_NONNULL ((4)));
652_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname, 677_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
653 const void * optval, socklen_t optlen)); 678 const void * optval, socklen_t optlen));
@@ -660,10 +685,11 @@ _GL_CXXALIAS_SYS_CAST (setsockopt, int,
660# endif 685# endif
661_GL_CXXALIASWARN (setsockopt); 686_GL_CXXALIASWARN (setsockopt);
662#elif @HAVE_WINSOCK2_H@ 687#elif @HAVE_WINSOCK2_H@
663# undef setsockopt 688# if !GNULIB_SETSOCKOPT
664# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt 689# undef setsockopt
690# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
691# endif
665#elif defined GNULIB_POSIXCHECK 692#elif defined GNULIB_POSIXCHECK
666# undef setsockopt
667# if HAVE_RAW_DECL_SETSOCKOPT 693# if HAVE_RAW_DECL_SETSOCKOPT
668_GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - " 694_GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
669 "use gnulib module setsockopt for portability"); 695 "use gnulib module setsockopt for portability");
@@ -676,17 +702,18 @@ _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
676# undef shutdown 702# undef shutdown
677# define shutdown rpl_shutdown 703# define shutdown rpl_shutdown
678# endif 704# endif
679_GL_FUNCDECL_RPL (shutdown, int, (int fd, int how)); 705_GL_FUNCDECL_RPL (shutdown, int, (int fd, int how), );
680_GL_CXXALIAS_RPL (shutdown, int, (int fd, int how)); 706_GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
681# else 707# else
682_GL_CXXALIAS_SYS (shutdown, int, (int fd, int how)); 708_GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
683# endif 709# endif
684_GL_CXXALIASWARN (shutdown); 710_GL_CXXALIASWARN (shutdown);
685#elif @HAVE_WINSOCK2_H@ 711#elif @HAVE_WINSOCK2_H@
686# undef shutdown 712# if !GNULIB_SHUTDOWN
687# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown 713# undef shutdown
714# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
715# endif
688#elif defined GNULIB_POSIXCHECK 716#elif defined GNULIB_POSIXCHECK
689# undef shutdown
690# if HAVE_RAW_DECL_SHUTDOWN 717# if HAVE_RAW_DECL_SHUTDOWN
691_GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - " 718_GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
692 "use gnulib module shutdown for portability"); 719 "use gnulib module shutdown for portability");
@@ -705,21 +732,20 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
705# endif 732# endif
706_GL_FUNCDECL_RPL (accept4, int, 733_GL_FUNCDECL_RPL (accept4, int,
707 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, 734 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
708 int flags)); 735 int flags), );
709_GL_CXXALIAS_RPL (accept4, int, 736_GL_CXXALIAS_RPL (accept4, int,
710 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, 737 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
711 int flags)); 738 int flags));
712# else 739# else
713_GL_FUNCDECL_SYS (accept4, int, 740_GL_FUNCDECL_SYS (accept4, int,
714 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, 741 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
715 int flags)); 742 int flags), );
716_GL_CXXALIAS_SYS (accept4, int, 743_GL_CXXALIAS_SYS (accept4, int,
717 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, 744 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
718 int flags)); 745 int flags));
719# endif 746# endif
720_GL_CXXALIASWARN (accept4); 747_GL_CXXALIASWARN (accept4);
721#elif defined GNULIB_POSIXCHECK 748#elif defined GNULIB_POSIXCHECK
722# undef accept4
723# if HAVE_RAW_DECL_ACCEPT4 749# if HAVE_RAW_DECL_ACCEPT4
724_GL_WARN_ON_USE (accept4, "accept4 is unportable - " 750_GL_WARN_ON_USE (accept4, "accept4 is unportable - "
725 "use gnulib module accept4 for portability"); 751 "use gnulib module accept4 for portability");
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
index 096887c0..deed21cd 100644
--- a/gl/sys_stat.in.h
+++ b/gl/sys_stat.in.h
@@ -1,5 +1,5 @@
1/* Provide a more complete sys/stat.h header file. 1/* Provide a more complete sys/stat.h header file.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -25,6 +25,13 @@
25#endif 25#endif
26@PRAGMA_COLUMNS@ 26@PRAGMA_COLUMNS@
27 27
28/* This file uses #include_next of a system file that defines time_t.
29 For the 'year2038' module to work right, <config.h> needs to have been
30 included before. */
31#if !_GL_CONFIG_H_INCLUDED
32 #error "Please include config.h first."
33#endif
34
28#if defined __need_system_sys_stat_h 35#if defined __need_system_sys_stat_h
29/* Special invocation convention. */ 36/* Special invocation convention. */
30 37
@@ -48,12 +55,42 @@
48#ifndef _@GUARD_PREFIX@_SYS_STAT_H 55#ifndef _@GUARD_PREFIX@_SYS_STAT_H
49#define _@GUARD_PREFIX@_SYS_STAT_H 56#define _@GUARD_PREFIX@_SYS_STAT_H
50 57
58/* This file uses _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW,
59 GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
60#if !_GL_CONFIG_H_INCLUDED
61 #error "Please include config.h first."
62#endif
63
64
65/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
66 */
67#ifndef _GL_ATTRIBUTE_NOTHROW
68# if defined __cplusplus
69# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
70# if __cplusplus >= 201103L
71# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
72# else
73# define _GL_ATTRIBUTE_NOTHROW throw ()
74# endif
75# else
76# define _GL_ATTRIBUTE_NOTHROW
77# endif
78# else
79# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
80# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
81# else
82# define _GL_ATTRIBUTE_NOTHROW
83# endif
84# endif
85#endif
86
51/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 87/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52 88
53/* The definition of _GL_ARG_NONNULL is copied here. */ 89/* The definition of _GL_ARG_NONNULL is copied here. */
54 90
55/* The definition of _GL_WARN_ON_USE is copied here. */ 91/* The definition of _GL_WARN_ON_USE is copied here. */
56 92
93
57/* Before doing "#define mknod rpl_mknod" below, we need to include all 94/* Before doing "#define mknod rpl_mknod" below, we need to include all
58 headers that may declare mknod(). OS/2 kLIBC declares mknod() in 95 headers that may declare mknod(). OS/2 kLIBC declares mknod() in
59 <unistd.h>, not in <sys/stat.h>. */ 96 <unistd.h>, not in <sys/stat.h>. */
@@ -86,9 +123,11 @@
86# if @GNULIB_STAT@ 123# if @GNULIB_STAT@
87# define stat rpl_stat 124# define stat rpl_stat
88# else 125# else
89 /* Provoke a clear link error if stat() is used as a function and 126# if !GNULIB_STAT
90 module 'stat' is not in use. */ 127 /* Provoke a clear link error if stat() is used as a function and
91# define stat stat_used_without_requesting_gnulib_module_stat 128 module 'stat' is not in use. */
129# define stat stat_used_without_requesting_gnulib_module_stat
130# endif
92# endif 131# endif
93 132
94# if !GNULIB_defined_struct_stat 133# if !GNULIB_defined_struct_stat
@@ -397,7 +436,7 @@ struct stat
397# undef chmod 436# undef chmod
398# define chmod rpl_chmod 437# define chmod rpl_chmod
399# endif 438# endif
400_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode) 439_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode),
401 _GL_ARG_NONNULL ((1))); 440 _GL_ARG_NONNULL ((1)));
402_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode)); 441_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
403# elif defined _WIN32 && !defined __CYGWIN__ 442# elif defined _WIN32 && !defined __CYGWIN__
@@ -412,7 +451,6 @@ _GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
412# endif 451# endif
413_GL_CXXALIASWARN (chmod); 452_GL_CXXALIASWARN (chmod);
414#elif defined GNULIB_POSIXCHECK 453#elif defined GNULIB_POSIXCHECK
415# undef chmod
416# if HAVE_RAW_DECL_CHMOD 454# if HAVE_RAW_DECL_CHMOD
417_GL_WARN_ON_USE (chmod, "chmod has portability problems - " 455_GL_WARN_ON_USE (chmod, "chmod has portability problems - "
418 "use gnulib module chmod for portability"); 456 "use gnulib module chmod for portability");
@@ -442,22 +480,21 @@ _GL_CXXALIASWARN (chmod);
442# define fchmodat rpl_fchmodat 480# define fchmodat rpl_fchmodat
443# endif 481# endif
444_GL_FUNCDECL_RPL (fchmodat, int, 482_GL_FUNCDECL_RPL (fchmodat, int,
445 (int fd, char const *file, mode_t mode, int flag) 483 (int fd, char const *file, mode_t mode, int flag),
446 _GL_ARG_NONNULL ((2))); 484 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
447_GL_CXXALIAS_RPL (fchmodat, int, 485_GL_CXXALIAS_RPL (fchmodat, int,
448 (int fd, char const *file, mode_t mode, int flag)); 486 (int fd, char const *file, mode_t mode, int flag));
449# else 487# else
450# if !@HAVE_FCHMODAT@ 488# if !@HAVE_FCHMODAT@
451_GL_FUNCDECL_SYS (fchmodat, int, 489_GL_FUNCDECL_SYS (fchmodat, int,
452 (int fd, char const *file, mode_t mode, int flag) 490 (int fd, char const *file, mode_t mode, int flag),
453 _GL_ARG_NONNULL ((2))); 491 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
454# endif 492# endif
455_GL_CXXALIAS_SYS (fchmodat, int, 493_GL_CXXALIAS_SYS (fchmodat, int,
456 (int fd, char const *file, mode_t mode, int flag)); 494 (int fd, char const *file, mode_t mode, int flag));
457# endif 495# endif
458_GL_CXXALIASWARN (fchmodat); 496_GL_CXXALIASWARN (fchmodat);
459#elif defined GNULIB_POSIXCHECK 497#elif defined GNULIB_POSIXCHECK
460# undef fchmodat
461# if HAVE_RAW_DECL_FCHMODAT 498# if HAVE_RAW_DECL_FCHMODAT
462_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " 499_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
463 "use gnulib module openat for portability"); 500 "use gnulib module openat for portability");
@@ -471,7 +508,8 @@ _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
471# undef fstat 508# undef fstat
472# define fstat rpl_fstat 509# define fstat rpl_fstat
473# endif 510# endif
474_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); 511_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf),
512 _GL_ARG_NONNULL ((2)));
475_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); 513_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
476# else 514# else
477_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); 515_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
@@ -480,13 +518,14 @@ _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
480_GL_CXXALIASWARN (fstat); 518_GL_CXXALIASWARN (fstat);
481# endif 519# endif
482#elif @GNULIB_OVERRIDES_STRUCT_STAT@ 520#elif @GNULIB_OVERRIDES_STRUCT_STAT@
483# undef fstat 521# if !GNULIB_FSTAT
484# define fstat fstat_used_without_requesting_gnulib_module_fstat 522# undef fstat
523# define fstat fstat_used_without_requesting_gnulib_module_fstat
524# endif
485#elif @WINDOWS_64_BIT_ST_SIZE@ 525#elif @WINDOWS_64_BIT_ST_SIZE@
486/* Above, we define stat to _stati64. */ 526/* Above, we define stat to _stati64. */
487# define fstat _fstati64 527# define fstat _fstati64
488#elif defined GNULIB_POSIXCHECK 528#elif defined GNULIB_POSIXCHECK
489# undef fstat
490# if HAVE_RAW_DECL_FSTAT 529# if HAVE_RAW_DECL_FSTAT
491_GL_WARN_ON_USE (fstat, "fstat has portability problems - " 530_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
492 "use gnulib module fstat for portability"); 531 "use gnulib module fstat for portability");
@@ -502,7 +541,7 @@ _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
502# endif 541# endif
503_GL_FUNCDECL_RPL (fstatat, int, 542_GL_FUNCDECL_RPL (fstatat, int,
504 (int fd, char const *restrict name, struct stat *restrict st, 543 (int fd, char const *restrict name, struct stat *restrict st,
505 int flags) 544 int flags),
506 _GL_ARG_NONNULL ((2, 3))); 545 _GL_ARG_NONNULL ((2, 3)));
507_GL_CXXALIAS_RPL (fstatat, int, 546_GL_CXXALIAS_RPL (fstatat, int,
508 (int fd, char const *restrict name, struct stat *restrict st, 547 (int fd, char const *restrict name, struct stat *restrict st,
@@ -511,7 +550,7 @@ _GL_CXXALIAS_RPL (fstatat, int,
511# if !@HAVE_FSTATAT@ 550# if !@HAVE_FSTATAT@
512_GL_FUNCDECL_SYS (fstatat, int, 551_GL_FUNCDECL_SYS (fstatat, int,
513 (int fd, char const *restrict name, struct stat *restrict st, 552 (int fd, char const *restrict name, struct stat *restrict st,
514 int flags) 553 int flags),
515 _GL_ARG_NONNULL ((2, 3))); 554 _GL_ARG_NONNULL ((2, 3)));
516# endif 555# endif
517_GL_CXXALIAS_SYS (fstatat, int, 556_GL_CXXALIAS_SYS (fstatat, int,
@@ -520,10 +559,11 @@ _GL_CXXALIAS_SYS (fstatat, int,
520# endif 559# endif
521_GL_CXXALIASWARN (fstatat); 560_GL_CXXALIASWARN (fstatat);
522#elif @GNULIB_OVERRIDES_STRUCT_STAT@ 561#elif @GNULIB_OVERRIDES_STRUCT_STAT@
523# undef fstatat 562# if !GNULIB_FSTATAT
524# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat 563# undef fstatat
564# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
565# endif
525#elif defined GNULIB_POSIXCHECK 566#elif defined GNULIB_POSIXCHECK
526# undef fstatat
527# if HAVE_RAW_DECL_FSTATAT 567# if HAVE_RAW_DECL_FSTATAT
528_GL_WARN_ON_USE (fstatat, "fstatat is not portable - " 568_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
529 "use gnulib module openat for portability"); 569 "use gnulib module openat for portability");
@@ -541,19 +581,18 @@ _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
541# undef futimens 581# undef futimens
542# define futimens rpl_futimens 582# define futimens rpl_futimens
543# endif 583# endif
544_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2])); 584_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]), );
545_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2])); 585_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
546# else 586# else
547# if !@HAVE_FUTIMENS@ 587# if !@HAVE_FUTIMENS@
548_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); 588_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]), );
549# endif 589# endif
550_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); 590_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
551# endif 591# endif
552# if @HAVE_FUTIMENS@ 592# if __GLIBC__ >= 2 && @HAVE_FUTIMENS@
553_GL_CXXALIASWARN (futimens); 593_GL_CXXALIASWARN (futimens);
554# endif 594# endif
555#elif defined GNULIB_POSIXCHECK 595#elif defined GNULIB_POSIXCHECK
556# undef futimens
557# if HAVE_RAW_DECL_FUTIMENS 596# if HAVE_RAW_DECL_FUTIMENS
558_GL_WARN_ON_USE (futimens, "futimens is not portable - " 597_GL_WARN_ON_USE (futimens, "futimens is not portable - "
559 "use gnulib module futimens for portability"); 598 "use gnulib module futimens for portability");
@@ -563,14 +602,17 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - "
563 602
564#if @GNULIB_GETUMASK@ 603#if @GNULIB_GETUMASK@
565# if !@HAVE_GETUMASK@ 604# if !@HAVE_GETUMASK@
566_GL_FUNCDECL_SYS (getumask, mode_t, (void)); 605# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
606_GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
607# else
608_GL_FUNCDECL_SYS (getumask, mode_t, (void), );
609# endif
567# endif 610# endif
568_GL_CXXALIAS_SYS (getumask, mode_t, (void)); 611_GL_CXXALIAS_SYS (getumask, mode_t, (void));
569# if @HAVE_GETUMASK@ 612# if @HAVE_GETUMASK@
570_GL_CXXALIASWARN (getumask); 613_GL_CXXALIASWARN (getumask);
571# endif 614# endif
572#elif defined GNULIB_POSIXCHECK 615#elif defined GNULIB_POSIXCHECK
573# undef getumask
574# if HAVE_RAW_DECL_GETUMASK 616# if HAVE_RAW_DECL_GETUMASK
575_GL_WARN_ON_USE (getumask, "getumask is not portable - " 617_GL_WARN_ON_USE (getumask, "getumask is not portable - "
576 "use gnulib module getumask for portability"); 618 "use gnulib module getumask for portability");
@@ -582,13 +624,12 @@ _GL_WARN_ON_USE (getumask, "getumask is not portable - "
582/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME 624/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
583 denotes a symbolic link. */ 625 denotes a symbolic link. */
584# if !@HAVE_LCHMOD@ || defined __hpux 626# if !@HAVE_LCHMOD@ || defined __hpux
585_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) 627_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode),
586 _GL_ARG_NONNULL ((1))); 628 _GL_ARG_NONNULL ((1)));
587# endif 629# endif
588_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); 630_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
589_GL_CXXALIASWARN (lchmod); 631_GL_CXXALIASWARN (lchmod);
590#elif defined GNULIB_POSIXCHECK 632#elif defined GNULIB_POSIXCHECK
591# undef lchmod
592# if HAVE_RAW_DECL_LCHMOD 633# if HAVE_RAW_DECL_LCHMOD
593_GL_WARN_ON_USE (lchmod, "lchmod is unportable - " 634_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
594 "use gnulib module lchmod for portability"); 635 "use gnulib module lchmod for portability");
@@ -602,7 +643,7 @@ _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
602# undef mkdir 643# undef mkdir
603# define mkdir rpl_mkdir 644# define mkdir rpl_mkdir
604# endif 645# endif
605_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) 646_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode),
606 _GL_ARG_NONNULL ((1))); 647 _GL_ARG_NONNULL ((1)));
607_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); 648_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
608# elif defined _WIN32 && !defined __CYGWIN__ 649# elif defined _WIN32 && !defined __CYGWIN__
@@ -627,12 +668,6 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
627_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); 668_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
628# endif 669# endif
629_GL_CXXALIASWARN (mkdir); 670_GL_CXXALIASWARN (mkdir);
630#elif defined GNULIB_POSIXCHECK
631# undef mkdir
632# if HAVE_RAW_DECL_MKDIR
633_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
634 "use gnulib module mkdir for portability");
635# endif
636#elif @GNULIB_MDA_MKDIR@ 671#elif @GNULIB_MDA_MKDIR@
637/* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not 672/* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
638 required. In C++ with GNULIB_NAMESPACE, avoid differences between 673 required. In C++ with GNULIB_NAMESPACE, avoid differences between
@@ -655,18 +690,22 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
655_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); 690_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
656# endif 691# endif
657_GL_CXXALIASWARN (mkdir); 692_GL_CXXALIASWARN (mkdir);
693#elif defined GNULIB_POSIXCHECK
694# if HAVE_RAW_DECL_MKDIR
695_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
696 "use gnulib module mkdir for portability");
697# endif
658#endif 698#endif
659 699
660 700
661#if @GNULIB_MKDIRAT@ 701#if @GNULIB_MKDIRAT@
662# if !@HAVE_MKDIRAT@ 702# if !@HAVE_MKDIRAT@
663_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) 703_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode),
664 _GL_ARG_NONNULL ((2))); 704 _GL_ARG_NONNULL ((2)));
665# endif 705# endif
666_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); 706_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
667_GL_CXXALIASWARN (mkdirat); 707_GL_CXXALIASWARN (mkdirat);
668#elif defined GNULIB_POSIXCHECK 708#elif defined GNULIB_POSIXCHECK
669# undef mkdirat
670# if HAVE_RAW_DECL_MKDIRAT 709# if HAVE_RAW_DECL_MKDIRAT
671_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " 710_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
672 "use gnulib module openat for portability"); 711 "use gnulib module openat for portability");
@@ -680,19 +719,18 @@ _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
680# undef mkfifo 719# undef mkfifo
681# define mkfifo rpl_mkfifo 720# define mkfifo rpl_mkfifo
682# endif 721# endif
683_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) 722_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode),
684 _GL_ARG_NONNULL ((1))); 723 _GL_ARG_NONNULL ((1)));
685_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); 724_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
686# else 725# else
687# if !@HAVE_MKFIFO@ 726# if !@HAVE_MKFIFO@
688_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) 727_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode),
689 _GL_ARG_NONNULL ((1))); 728 _GL_ARG_NONNULL ((1)));
690# endif 729# endif
691_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); 730_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
692# endif 731# endif
693_GL_CXXALIASWARN (mkfifo); 732_GL_CXXALIASWARN (mkfifo);
694#elif defined GNULIB_POSIXCHECK 733#elif defined GNULIB_POSIXCHECK
695# undef mkfifo
696# if HAVE_RAW_DECL_MKFIFO 734# if HAVE_RAW_DECL_MKFIFO
697_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " 735_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
698 "use gnulib module mkfifo for portability"); 736 "use gnulib module mkfifo for portability");
@@ -706,19 +744,20 @@ _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
706# undef mkfifoat 744# undef mkfifoat
707# define mkfifoat rpl_mkfifoat 745# define mkfifoat rpl_mkfifoat
708# endif 746# endif
709_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode) 747_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode),
710 _GL_ARG_NONNULL ((2))); 748 _GL_ARG_NONNULL ((2)));
711_GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)); 749_GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
712# else 750# else
713# if !@HAVE_MKFIFOAT@ 751# if !@HAVE_MKFIFOAT@
714_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) 752_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode),
715 _GL_ARG_NONNULL ((2))); 753 _GL_ARG_NONNULL ((2)));
716# endif 754# endif
717_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); 755_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
718# endif 756# endif
757# if __GLIBC__ >= 2
719_GL_CXXALIASWARN (mkfifoat); 758_GL_CXXALIASWARN (mkfifoat);
759# endif
720#elif defined GNULIB_POSIXCHECK 760#elif defined GNULIB_POSIXCHECK
721# undef mkfifoat
722# if HAVE_RAW_DECL_MKFIFOAT 761# if HAVE_RAW_DECL_MKFIFOAT
723_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " 762_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
724 "use gnulib module mkfifoat for portability"); 763 "use gnulib module mkfifoat for portability");
@@ -732,20 +771,18 @@ _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
732# undef mknod 771# undef mknod
733# define mknod rpl_mknod 772# define mknod rpl_mknod
734# endif 773# endif
735_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) 774_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev),
736 _GL_ARG_NONNULL ((1))); 775 _GL_ARG_NONNULL ((1)));
737_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); 776_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
738# else 777# else
739# if !@HAVE_MKNOD@ 778# if !@HAVE_MKNOD@
740_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) 779_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev),
741 _GL_ARG_NONNULL ((1))); 780 _GL_ARG_NONNULL ((1)));
742# endif 781# endif
743/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ 782_GL_CXXALIAS_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev));
744_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
745# endif 783# endif
746_GL_CXXALIASWARN (mknod); 784_GL_CXXALIASWARN (mknod);
747#elif defined GNULIB_POSIXCHECK 785#elif defined GNULIB_POSIXCHECK
748# undef mknod
749# if HAVE_RAW_DECL_MKNOD 786# if HAVE_RAW_DECL_MKNOD
750_GL_WARN_ON_USE (mknod, "mknod is not portable - " 787_GL_WARN_ON_USE (mknod, "mknod is not portable - "
751 "use gnulib module mknod for portability"); 788 "use gnulib module mknod for portability");
@@ -760,22 +797,23 @@ _GL_WARN_ON_USE (mknod, "mknod is not portable - "
760# define mknodat rpl_mknodat 797# define mknodat rpl_mknodat
761# endif 798# endif
762_GL_FUNCDECL_RPL (mknodat, int, 799_GL_FUNCDECL_RPL (mknodat, int,
763 (int fd, char const *file, mode_t mode, dev_t dev) 800 (int fd, char const *file, mode_t mode, dev_t dev),
764 _GL_ARG_NONNULL ((2))); 801 _GL_ARG_NONNULL ((2)));
765_GL_CXXALIAS_RPL (mknodat, int, 802_GL_CXXALIAS_RPL (mknodat, int,
766 (int fd, char const *file, mode_t mode, dev_t dev)); 803 (int fd, char const *file, mode_t mode, dev_t dev));
767# else 804# else
768# if !@HAVE_MKNODAT@ 805# if !@HAVE_MKNODAT@
769_GL_FUNCDECL_SYS (mknodat, int, 806_GL_FUNCDECL_SYS (mknodat, int,
770 (int fd, char const *file, mode_t mode, dev_t dev) 807 (int fd, char const *file, mode_t mode, dev_t dev),
771 _GL_ARG_NONNULL ((2))); 808 _GL_ARG_NONNULL ((2)));
772# endif 809# endif
773_GL_CXXALIAS_SYS (mknodat, int, 810_GL_CXXALIAS_SYS (mknodat, int,
774 (int fd, char const *file, mode_t mode, dev_t dev)); 811 (int fd, char const *file, mode_t mode, dev_t dev));
775# endif 812# endif
813# if __GLIBC__ >= 2
776_GL_CXXALIASWARN (mknodat); 814_GL_CXXALIASWARN (mknodat);
815# endif
777#elif defined GNULIB_POSIXCHECK 816#elif defined GNULIB_POSIXCHECK
778# undef mknodat
779# if HAVE_RAW_DECL_MKNODAT 817# if HAVE_RAW_DECL_MKNODAT
780_GL_WARN_ON_USE (mknodat, "mknodat is not portable - " 818_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
781 "use gnulib module mkfifoat for portability"); 819 "use gnulib module mkfifoat for portability");
@@ -797,7 +835,11 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
797# elif @WINDOWS_64_BIT_ST_SIZE@ 835# elif @WINDOWS_64_BIT_ST_SIZE@
798 /* Above, we define stat to _stati64. */ 836 /* Above, we define stat to _stati64. */
799# if defined __MINGW32__ && defined _stati64 837# if defined __MINGW32__ && defined _stati64
800# ifndef _USE_32BIT_TIME_T 838# ifdef _USE_32BIT_TIME_T
839 /* The system headers possibly define _stati64 to _stat32i64. */
840# undef _stat32i64
841# define _stat32i64(name, st) rpl_stat (name, st)
842# else
801 /* The system headers define _stati64 to _stat64. */ 843 /* The system headers define _stati64 to _stat64. */
802# undef _stat64 844# undef _stat64
803# define _stat64(name, st) rpl_stat (name, st) 845# define _stat64(name, st) rpl_stat (name, st)
@@ -849,7 +891,6 @@ _GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
849 #define stat stat_used_without_requesting_gnulib_module_stat 891 #define stat stat_used_without_requesting_gnulib_module_stat
850 */ 892 */
851#elif defined GNULIB_POSIXCHECK 893#elif defined GNULIB_POSIXCHECK
852# undef stat
853# if HAVE_RAW_DECL_STAT 894# if HAVE_RAW_DECL_STAT
854_GL_WARN_ON_USE (stat, "stat is unportable - " 895_GL_WARN_ON_USE (stat, "stat is unportable - "
855 "use gnulib module stat for portability"); 896 "use gnulib module stat for portability");
@@ -872,7 +913,7 @@ _GL_CXXALIAS_RPL_1 (lstat, stat, int,
872# define lstat rpl_lstat 913# define lstat rpl_lstat
873# endif 914# endif
874_GL_FUNCDECL_RPL (lstat, int, 915_GL_FUNCDECL_RPL (lstat, int,
875 (const char *restrict name, struct stat *restrict buf) 916 (const char *restrict name, struct stat *restrict buf),
876 _GL_ARG_NONNULL ((1, 2))); 917 _GL_ARG_NONNULL ((1, 2)));
877_GL_CXXALIAS_RPL (lstat, int, 918_GL_CXXALIAS_RPL (lstat, int,
878 (const char *restrict name, struct stat *restrict buf)); 919 (const char *restrict name, struct stat *restrict buf));
@@ -884,10 +925,11 @@ _GL_CXXALIAS_SYS (lstat, int,
884_GL_CXXALIASWARN (lstat); 925_GL_CXXALIASWARN (lstat);
885# endif 926# endif
886#elif @GNULIB_OVERRIDES_STRUCT_STAT@ 927#elif @GNULIB_OVERRIDES_STRUCT_STAT@
887# undef lstat 928# if !GNULIB_LSTAT
888# define lstat lstat_used_without_requesting_gnulib_module_lstat 929# undef lstat
930# define lstat lstat_used_without_requesting_gnulib_module_lstat
931# endif
889#elif defined GNULIB_POSIXCHECK 932#elif defined GNULIB_POSIXCHECK
890# undef lstat
891# if HAVE_RAW_DECL_LSTAT 933# if HAVE_RAW_DECL_LSTAT
892_GL_WARN_ON_USE (lstat, "lstat is unportable - " 934_GL_WARN_ON_USE (lstat, "lstat is unportable - "
893 "use gnulib module lstat for portability"); 935 "use gnulib module lstat for portability");
@@ -924,24 +966,23 @@ _GL_CXXALIASWARN (umask);
924# define utimensat rpl_utimensat 966# define utimensat rpl_utimensat
925# endif 967# endif
926_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, 968_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
927 struct timespec const times[2], int flag) 969 struct timespec const times[2], int flag),
928 _GL_ARG_NONNULL ((2))); 970 _GL_ARG_NONNULL ((2)));
929_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, 971_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
930 struct timespec const times[2], int flag)); 972 struct timespec const times[2], int flag));
931# else 973# else
932# if !@HAVE_UTIMENSAT@ 974# if !@HAVE_UTIMENSAT@
933_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, 975_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
934 struct timespec const times[2], int flag) 976 struct timespec const times[2], int flag),
935 _GL_ARG_NONNULL ((2))); 977 _GL_ARG_NONNULL ((2)));
936# endif 978# endif
937_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, 979_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
938 struct timespec const times[2], int flag)); 980 struct timespec const times[2], int flag));
939# endif 981# endif
940# if @HAVE_UTIMENSAT@ 982# if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@
941_GL_CXXALIASWARN (utimensat); 983_GL_CXXALIASWARN (utimensat);
942# endif 984# endif
943#elif defined GNULIB_POSIXCHECK 985#elif defined GNULIB_POSIXCHECK
944# undef utimensat
945# if HAVE_RAW_DECL_UTIMENSAT 986# if HAVE_RAW_DECL_UTIMENSAT
946_GL_WARN_ON_USE (utimensat, "utimensat is not portable - " 987_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
947 "use gnulib module utimensat for portability"); 988 "use gnulib module utimensat for portability");
diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h
index 082a6c67..733b4ba4 100644
--- a/gl/sys_types.in.h
+++ b/gl/sys_types.in.h
@@ -1,6 +1,6 @@
1/* Provide a more complete sys/types.h. 1/* Provide a more complete sys/types.h.
2 2
3 Copyright (C) 2011-2023 Free Software Foundation, Inc. 3 Copyright (C) 2011-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,6 +20,13 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23/* This file uses #include_next of a system file that defines time_t.
24 For the 'year2038' module to work right, <config.h> needs to have been
25 included before. */
26#if !_GL_CONFIG_H_INCLUDED
27 #error "Please include config.h first."
28#endif
29
23#if defined _WIN32 && !defined __CYGWIN__ \ 30#if defined _WIN32 && !defined __CYGWIN__ \
24 && (defined __need_off_t || defined __need___off64_t \ 31 && (defined __need_off_t || defined __need___off64_t \
25 || defined __need_ssize_t || defined __need_time_t) 32 || defined __need_ssize_t || defined __need_time_t)
@@ -53,6 +60,15 @@
53# define _GL_WINDOWS_64_BIT_OFF_T 1 60# define _GL_WINDOWS_64_BIT_OFF_T 1
54#endif 61#endif
55 62
63/* Define the off64_t type. */
64#if !@HAVE_OFF64_T@
65# if !GNULIB_defined_off64_t
66/* Define off64_t to int64_t always. */
67typedef long long off64_t;
68# define GNULIB_defined_off64_t 1
69# endif
70#endif
71
56/* Override dev_t and ino_t if distinguishable inodes support is requested 72/* Override dev_t and ino_t if distinguishable inodes support is requested
57 on native Windows. */ 73 on native Windows. */
58#if @WINDOWS_STAT_INODES@ 74#if @WINDOWS_STAT_INODES@
@@ -101,6 +117,22 @@ typedef unsigned long long int rpl_ino_t;
101# include <stddef.h> 117# include <stddef.h>
102#endif 118#endif
103 119
120/* Define blksize_t, required by POSIX:2024. */
121#if !@HAVE_BLKSIZE_T@
122# if !defined GNULIB_defined_blksize_t
123typedef int blksize_t;
124# define GNULIB_defined_blksize_t 1
125# endif
126#endif
127
128/* Define blkcnt_t, required by POSIX:2024. */
129#if !@HAVE_BLKCNT_T@
130# if !defined GNULIB_defined_blkcnt_t
131typedef long long blkcnt_t;
132# define GNULIB_defined_blkcnt_t 1
133# endif
134#endif
135
104#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ 136#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
105#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ 137#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
106#endif /* __need_XXX */ 138#endif /* __need_XXX */
diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h
index 64c4fb6d..8f7f506f 100644
--- a/gl/sys_uio.in.h
+++ b/gl/sys_uio.in.h
@@ -1,5 +1,5 @@
1/* Substitute for <sys/uio.h>. 1/* Substitute for <sys/uio.h>.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc. 2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/time.in.h b/gl/time.in.h
index 50c9b30b..5bbccf76 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -1,6 +1,6 @@
1/* A more-standard <time.h>. 1/* A more-standard <time.h>.
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,6 +20,13 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23/* This file uses #include_next of a system file that defines time_t.
24 For the 'year2038' module to work right, <config.h> needs to have been
25 included before. */
26#if !_GL_CONFIG_H_INCLUDED
27 #error "Please include config.h first."
28#endif
29
23/* Don't get in the way of glibc when it includes time.h merely to 30/* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the 31 declare a few standard symbols, rather than to declare all the
25 symbols. (However, skip this for MinGW as it treats __need_time_t 32 symbols. (However, skip this for MinGW as it treats __need_time_t
@@ -45,6 +52,12 @@
45 52
46# @INCLUDE_NEXT@ @NEXT_TIME_H@ 53# @INCLUDE_NEXT@ @NEXT_TIME_H@
47 54
55/* This file uses _GL_ATTRIBUTE_DEPRECATED, GNULIB_POSIXCHECK,
56 HAVE_RAW_DECL_*. */
57# if !_GL_CONFIG_H_INCLUDED
58# error "Please include config.h first."
59# endif
60
48/* NetBSD 5.0 mis-defines NULL. */ 61/* NetBSD 5.0 mis-defines NULL. */
49# include <stddef.h> 62# include <stddef.h>
50 63
@@ -109,27 +122,99 @@ struct __time_t_must_be_integral {
109# endif 122# endif
110# endif 123# endif
111 124
125# if @GNULIB_TZNAME@
126/* tzname[0..1]: Abbreviated time zone names, set by the tzset() function. */
127# if NEED_DECL_TZNAME
128extern
129# ifdef __cplusplus
130 "C"
131# endif
132 char *tzname[];
133# endif
134# if defined _WIN32 && !defined __CYGWIN__
135/* On native Windows, map 'tzname' to '_tzname' etc., so that -loldnames is not
136 required. */
137# undef tzname
138# define tzname _tzname
139# endif
140# endif
141
112/* Set *TS to the current time, and return BASE. 142/* Set *TS to the current time, and return BASE.
113 Upon failure, return 0. */ 143 Upon failure, return 0. */
114# if @GNULIB_TIMESPEC_GET@ 144# if @GNULIB_TIMESPEC_GET@
115# if ! @HAVE_TIMESPEC_GET@ 145# if @REPLACE_TIMESPEC_GET@
116_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base) 146# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
147# undef timespec_get
148# define timespec_get rpl_timespec_get
149# endif
150_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base),
117 _GL_ARG_NONNULL ((1))); 151 _GL_ARG_NONNULL ((1)));
118# endif 152_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base));
153# else
154# if !@HAVE_TIMESPEC_GET@
155_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base),
156 _GL_ARG_NONNULL ((1)));
157# endif
119_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base)); 158_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
159# endif
160# if __GLIBC__ >= 2
120_GL_CXXALIASWARN (timespec_get); 161_GL_CXXALIASWARN (timespec_get);
162# endif
163# elif defined GNULIB_POSIXCHECK
164# if HAVE_RAW_DECL_TIMESPEC_GET
165_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
166 "use gnulib module timespec_get for portability");
167# endif
121# endif 168# endif
122 169
123/* Set *TS to the current time resolution, and return BASE. 170/* Set *TS to the current time resolution, and return BASE.
124 Upon failure, return 0. */ 171 Upon failure, return 0. */
125# if @GNULIB_TIMESPEC_GETRES@ 172# if @GNULIB_TIMESPEC_GETRES@
126# if ! @HAVE_TIMESPEC_GETRES@ 173# if @REPLACE_TIMESPEC_GETRES@
127_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base) 174# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
175# undef timespec_getres
176# define timespec_getres rpl_timespec_getres
177# endif
178_GL_FUNCDECL_RPL (timespec_getres, int, (struct timespec *ts, int base),
128 _GL_ARG_NONNULL ((1))); 179 _GL_ARG_NONNULL ((1)));
129# endif 180_GL_CXXALIAS_RPL (timespec_getres, int, (struct timespec *ts, int base));
181# else
182# if !@HAVE_TIMESPEC_GETRES@
183_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base),
184 _GL_ARG_NONNULL ((1)));
185# endif
130_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base)); 186_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
187# endif
188# if __GLIBC__ >= 2
131_GL_CXXALIASWARN (timespec_getres); 189_GL_CXXALIASWARN (timespec_getres);
132# endif 190# endif
191# elif defined GNULIB_POSIXCHECK
192# if HAVE_RAW_DECL_TIMESPEC_GETRES
193_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
194 "use gnulib module timespec_getres for portability");
195# endif
196# endif
197
198/* Return the number of seconds that have elapsed since the Epoch. */
199# if @GNULIB_TIME@
200# if @REPLACE_TIME@
201# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
202# define time rpl_time
203# endif
204_GL_FUNCDECL_RPL (time, time_t, (time_t *__tp), );
205_GL_CXXALIAS_RPL (time, time_t, (time_t *__tp));
206# else
207_GL_CXXALIAS_SYS (time, time_t, (time_t *__tp));
208# endif
209# if __GLIBC__ >= 2
210_GL_CXXALIASWARN (time);
211# endif
212# elif defined GNULIB_POSIXCHECK
213# if HAVE_RAW_DECL_TIME
214_GL_WARN_ON_USE (time, "time has consistency problems - "
215 "use gnulib module time for portability");
216# endif
217# endif
133 218
134/* Sleep for at least RQTP seconds unless interrupted, If interrupted, 219/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
135 return -1 and store the remaining time into RMTP. See 220 return -1 and store the remaining time into RMTP. See
@@ -140,20 +225,25 @@ _GL_CXXALIASWARN (timespec_getres);
140# define nanosleep rpl_nanosleep 225# define nanosleep rpl_nanosleep
141# endif 226# endif
142_GL_FUNCDECL_RPL (nanosleep, int, 227_GL_FUNCDECL_RPL (nanosleep, int,
143 (struct timespec const *__rqtp, struct timespec *__rmtp) 228 (struct timespec const *__rqtp, struct timespec *__rmtp),
144 _GL_ARG_NONNULL ((1))); 229 _GL_ARG_NONNULL ((1)));
145_GL_CXXALIAS_RPL (nanosleep, int, 230_GL_CXXALIAS_RPL (nanosleep, int,
146 (struct timespec const *__rqtp, struct timespec *__rmtp)); 231 (struct timespec const *__rqtp, struct timespec *__rmtp));
147# else 232# else
148# if ! @HAVE_NANOSLEEP@ 233# if ! @HAVE_NANOSLEEP@
149_GL_FUNCDECL_SYS (nanosleep, int, 234_GL_FUNCDECL_SYS (nanosleep, int,
150 (struct timespec const *__rqtp, struct timespec *__rmtp) 235 (struct timespec const *__rqtp, struct timespec *__rmtp),
151 _GL_ARG_NONNULL ((1))); 236 _GL_ARG_NONNULL ((1)));
152# endif 237# endif
153_GL_CXXALIAS_SYS (nanosleep, int, 238_GL_CXXALIAS_SYS (nanosleep, int,
154 (struct timespec const *__rqtp, struct timespec *__rmtp)); 239 (struct timespec const *__rqtp, struct timespec *__rmtp));
155# endif 240# endif
156_GL_CXXALIASWARN (nanosleep); 241_GL_CXXALIASWARN (nanosleep);
242# elif defined GNULIB_POSIXCHECK
243# if HAVE_RAW_DECL_NANOSLEEP
244_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
245 "use gnulib module nanosleep for portability");
246# endif
157# endif 247# endif
158 248
159/* Initialize time conversion information. */ 249/* Initialize time conversion information. */
@@ -163,7 +253,7 @@ _GL_CXXALIASWARN (nanosleep);
163# undef tzset 253# undef tzset
164# define tzset rpl_tzset 254# define tzset rpl_tzset
165# endif 255# endif
166_GL_FUNCDECL_RPL (tzset, void, (void)); 256_GL_FUNCDECL_RPL (tzset, void, (void), );
167_GL_CXXALIAS_RPL (tzset, void, (void)); 257_GL_CXXALIAS_RPL (tzset, void, (void));
168# elif defined _WIN32 && !defined __CYGWIN__ 258# elif defined _WIN32 && !defined __CYGWIN__
169# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 259# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -189,6 +279,11 @@ _GL_CXXALIAS_MDA (tzset, void, (void));
189_GL_CXXALIAS_SYS (tzset, void, (void)); 279_GL_CXXALIAS_SYS (tzset, void, (void));
190# endif 280# endif
191_GL_CXXALIASWARN (tzset); 281_GL_CXXALIASWARN (tzset);
282# elif defined GNULIB_POSIXCHECK
283# if HAVE_RAW_DECL_TZSET
284_GL_WARN_ON_USE (tzset, "tzset has portability problems - "
285 "use gnulib module tzset for portability");
286# endif
192# endif 287# endif
193 288
194/* Return the 'time_t' representation of TP and normalize TP. */ 289/* Return the 'time_t' representation of TP and normalize TP. */
@@ -197,7 +292,7 @@ _GL_CXXALIASWARN (tzset);
197# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 292# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198# define mktime rpl_mktime 293# define mktime rpl_mktime
199# endif 294# endif
200_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); 295_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp), _GL_ARG_NONNULL ((1)));
201_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); 296_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
202# else 297# else
203_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); 298_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
@@ -205,6 +300,11 @@ _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
205# if __GLIBC__ >= 2 300# if __GLIBC__ >= 2
206_GL_CXXALIASWARN (mktime); 301_GL_CXXALIASWARN (mktime);
207# endif 302# endif
303# elif defined GNULIB_POSIXCHECK
304# if HAVE_RAW_DECL_MKTIME
305_GL_WARN_ON_USE (mktime, "mktime has portability problems - "
306 "use gnulib module mktime for portability");
307# endif
208# endif 308# endif
209 309
210/* Convert TIMER to RESULT, assuming local time and UTC respectively. See 310/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
@@ -217,14 +317,14 @@ _GL_CXXALIASWARN (mktime);
217# define localtime_r rpl_localtime_r 317# define localtime_r rpl_localtime_r
218# endif 318# endif
219_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, 319_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
220 struct tm *restrict __result) 320 struct tm *restrict __result),
221 _GL_ARG_NONNULL ((1, 2))); 321 _GL_ARG_NONNULL ((1, 2)));
222_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, 322_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
223 struct tm *restrict __result)); 323 struct tm *restrict __result));
224# else 324# else
225# if ! @HAVE_DECL_LOCALTIME_R@ 325# if ! @HAVE_DECL_LOCALTIME_R@
226_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, 326_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
227 struct tm *restrict __result) 327 struct tm *restrict __result),
228 _GL_ARG_NONNULL ((1, 2))); 328 _GL_ARG_NONNULL ((1, 2)));
229# endif 329# endif
230_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, 330_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
@@ -239,14 +339,14 @@ _GL_CXXALIASWARN (localtime_r);
239# define gmtime_r rpl_gmtime_r 339# define gmtime_r rpl_gmtime_r
240# endif 340# endif
241_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, 341_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
242 struct tm *restrict __result) 342 struct tm *restrict __result),
243 _GL_ARG_NONNULL ((1, 2))); 343 _GL_ARG_NONNULL ((1, 2)));
244_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, 344_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
245 struct tm *restrict __result)); 345 struct tm *restrict __result));
246# else 346# else
247# if ! @HAVE_DECL_LOCALTIME_R@ 347# if ! @HAVE_DECL_LOCALTIME_R@
248_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, 348_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
249 struct tm *restrict __result) 349 struct tm *restrict __result),
250 _GL_ARG_NONNULL ((1, 2))); 350 _GL_ARG_NONNULL ((1, 2)));
251# endif 351# endif
252_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, 352_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
@@ -255,6 +355,15 @@ _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
255# if @HAVE_DECL_LOCALTIME_R@ 355# if @HAVE_DECL_LOCALTIME_R@
256_GL_CXXALIASWARN (gmtime_r); 356_GL_CXXALIASWARN (gmtime_r);
257# endif 357# endif
358# elif defined GNULIB_POSIXCHECK
359# if HAVE_RAW_DECL_LOCALTIME_R
360_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
361 "use gnulib module time_r for portability");
362# endif
363# if HAVE_RAW_DECL_GMTIME_R
364_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
365 "use gnulib module time_r for portability");
366# endif
258# endif 367# endif
259 368
260/* Convert TIMER to RESULT, assuming local time and UTC respectively. See 369/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
@@ -266,7 +375,7 @@ _GL_CXXALIASWARN (gmtime_r);
266# undef localtime 375# undef localtime
267# define localtime rpl_localtime 376# define localtime rpl_localtime
268# endif 377# endif
269_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) 378_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer),
270 _GL_ARG_NONNULL ((1))); 379 _GL_ARG_NONNULL ((1)));
271_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); 380_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
272# else 381# else
@@ -275,6 +384,11 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
275# if __GLIBC__ >= 2 384# if __GLIBC__ >= 2
276_GL_CXXALIASWARN (localtime); 385_GL_CXXALIASWARN (localtime);
277# endif 386# endif
387# elif defined GNULIB_POSIXCHECK
388# if HAVE_RAW_DECL_LOCALTIME
389_GL_WARN_ON_USE (localtime, "localtime has portability problems - "
390 "use gnulib module localtime for portability");
391# endif
278# endif 392# endif
279 393
280# if 0 || @REPLACE_GMTIME@ 394# if 0 || @REPLACE_GMTIME@
@@ -283,7 +397,7 @@ _GL_CXXALIASWARN (localtime);
283# undef gmtime 397# undef gmtime
284# define gmtime rpl_gmtime 398# define gmtime rpl_gmtime
285# endif 399# endif
286_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) 400_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer),
287 _GL_ARG_NONNULL ((1))); 401 _GL_ARG_NONNULL ((1)));
288_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); 402_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
289# else 403# else
@@ -299,13 +413,18 @@ _GL_CXXALIASWARN (gmtime);
299# if ! @HAVE_STRPTIME@ 413# if ! @HAVE_STRPTIME@
300_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, 414_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
301 char const *restrict __format, 415 char const *restrict __format,
302 struct tm *restrict __tm) 416 struct tm *restrict __tm),
303 _GL_ARG_NONNULL ((1, 2, 3))); 417 _GL_ARG_NONNULL ((1, 2, 3)));
304# endif 418# endif
305_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, 419_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
306 char const *restrict __format, 420 char const *restrict __format,
307 struct tm *restrict __tm)); 421 struct tm *restrict __tm));
308_GL_CXXALIASWARN (strptime); 422_GL_CXXALIASWARN (strptime);
423# elif defined GNULIB_POSIXCHECK
424# if HAVE_RAW_DECL_STRPTIME
425_GL_WARN_ON_USE (strptime, "strptime is unportable - "
426 "use gnulib module strptime for portability");
427# endif
309# endif 428# endif
310 429
311/* Convert *TP to a date and time string. See 430/* Convert *TP to a date and time string. See
@@ -315,8 +434,10 @@ _GL_CXXALIASWARN (strptime);
315# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 434# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316# define ctime rpl_ctime 435# define ctime rpl_ctime
317# endif 436# endif
437# ifndef __cplusplus
318_GL_ATTRIBUTE_DEPRECATED 438_GL_ATTRIBUTE_DEPRECATED
319_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp) 439# endif
440_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp),
320 _GL_ARG_NONNULL ((1))); 441 _GL_ARG_NONNULL ((1)));
321_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp)); 442_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
322# else 443# else
@@ -325,6 +446,8 @@ _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
325# if __GLIBC__ >= 2 446# if __GLIBC__ >= 2
326_GL_CXXALIASWARN (ctime); 447_GL_CXXALIASWARN (ctime);
327# endif 448# endif
449# elif defined GNULIB_POSIXCHECK
450/* No need to warn about portability, as a more serious warning is below. */
328# endif 451# endif
329 452
330/* Convert *TP to a date and time string. See 453/* Convert *TP to a date and time string. See
@@ -336,7 +459,7 @@ _GL_CXXALIASWARN (ctime);
336# endif 459# endif
337_GL_FUNCDECL_RPL (strftime, size_t, 460_GL_FUNCDECL_RPL (strftime, size_t,
338 (char *restrict __buf, size_t __bufsize, 461 (char *restrict __buf, size_t __bufsize,
339 const char *restrict __fmt, const struct tm *restrict __tp) 462 const char *restrict __fmt, const struct tm *restrict __tp),
340 _GL_ARG_NONNULL ((1, 3, 4))); 463 _GL_ARG_NONNULL ((1, 3, 4)));
341_GL_CXXALIAS_RPL (strftime, size_t, 464_GL_CXXALIAS_RPL (strftime, size_t,
342 (char *restrict __buf, size_t __bufsize, 465 (char *restrict __buf, size_t __bufsize,
@@ -349,16 +472,31 @@ _GL_CXXALIAS_SYS (strftime, size_t,
349# if __GLIBC__ >= 2 472# if __GLIBC__ >= 2
350_GL_CXXALIASWARN (strftime); 473_GL_CXXALIASWARN (strftime);
351# endif 474# endif
475# elif defined GNULIB_POSIXCHECK
476# if HAVE_RAW_DECL_STRFTIME
477_GL_WARN_ON_USE (strftime, "strftime has portability problems - "
478 "use gnulib module strftime-fixes for portability");
479# endif
352# endif 480# endif
353 481
354# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ 482# if @GNULIB_TIME_RZ@
355/* Functions that use a first-class time zone data type, instead of 483/* Functions that use a first-class time zone data type, instead of
356 relying on an implicit global time zone. 484 relying on an implicit global time zone.
357 Inspired by NetBSD. */ 485 Inspired by NetBSD. */
358 486
359/* Represents a time zone. 487/* Represents a time zone.
360 (timezone_t) NULL stands for UTC. */ 488 (timezone_t) NULL stands for UTC. */
489# if !@HAVE_TZALLOC@
490# if !GNULIB_defined_timezone_t
491# if !@HAVE_TIMEZONE_T@
361typedef struct tm_zone *timezone_t; 492typedef struct tm_zone *timezone_t;
493# else
494typedef struct tm_zone *rpl_timezone_t;
495# define timezone_t rpl_timezone_t
496# endif
497# define GNULIB_defined_timezone_t 1
498# endif
499# endif
362 500
363/* tzalloc (name) 501/* tzalloc (name)
364 Returns a time zone object for the given time zone NAME. This object 502 Returns a time zone object for the given time zone NAME. This object
@@ -368,37 +506,79 @@ typedef struct tm_zone *timezone_t;
368 would use it the TZ environment variable was unset. 506 would use it the TZ environment variable was unset.
369 May return NULL if NAME is invalid (this is platform dependent) or 507 May return NULL if NAME is invalid (this is platform dependent) or
370 upon memory allocation failure. */ 508 upon memory allocation failure. */
371_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); 509# if !@HAVE_TZALLOC@
510_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name), );
372_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name)); 511_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
512# endif
373 513
374/* tzfree (tz) 514/* tzfree (tz)
375 Frees a time zone object. 515 Free a time zone object, preserving errno.
376 The argument must have been returned by tzalloc(). */ 516 The argument must have been returned by tzalloc(). */
377_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz)); 517# if !@HAVE_TZALLOC@
518_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz), );
378_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz)); 519_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
520# else
521# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
522# undef tzfree
523# define tzfree rpl_tzfree
524# endif
525_GL_FUNCDECL_RPL (tzfree, void, (timezone_t __tz), );
526_GL_CXXALIAS_RPL (tzfree, void, (timezone_t __tz));
527# endif
379 528
380/* localtime_rz (tz, &t, &result) 529/* localtime_rz (tz, &t, &result)
381 Converts an absolute time T to a broken-down time RESULT, assuming the 530 Converts an absolute time T to a broken-down time RESULT, assuming the
382 time zone TZ. 531 time zone TZ.
383 This function is like 'localtime_r', but relies on the argument TZ instead 532 This function is like 'localtime_r', but relies on the argument TZ instead
384 of an implicit global time zone. */ 533 of an implicit global time zone. */
534# if @REPLACE_LOCALTIME_RZ@
535# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
536# undef localtime_rz
537# define localtime_rz rpl_localtime_rz
538# endif
539_GL_FUNCDECL_RPL (localtime_rz, struct tm *,
540 (timezone_t __tz, time_t const *restrict __timer,
541 struct tm *restrict __result),
542 _GL_ARG_NONNULL ((2, 3)));
543_GL_CXXALIAS_RPL (localtime_rz, struct tm *,
544 (timezone_t __tz, time_t const *restrict __timer,
545 struct tm *restrict __result));
546# else
547# if !@HAVE_TZALLOC@
385_GL_FUNCDECL_SYS (localtime_rz, struct tm *, 548_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
386 (timezone_t __tz, time_t const *restrict __timer, 549 (timezone_t __tz, time_t const *restrict __timer,
387 struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3))); 550 struct tm *restrict __result),
551 _GL_ARG_NONNULL ((2, 3)));
552# endif
388_GL_CXXALIAS_SYS (localtime_rz, struct tm *, 553_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
389 (timezone_t __tz, time_t const *restrict __timer, 554 (timezone_t __tz, time_t const *restrict __timer,
390 struct tm *restrict __result)); 555 struct tm *restrict __result));
556# endif
391 557
392/* mktime_z (tz, &tm) 558/* mktime_z (tz, &tm)
393 Normalizes the broken-down time TM and converts it to an absolute time, 559 Normalizes the broken-down time TM and converts it to an absolute time,
394 assuming the time zone TZ. Returns the absolute time. 560 assuming the time zone TZ. Returns the absolute time.
395 This function is like 'mktime', but relies on the argument TZ instead 561 This function is like 'mktime', but relies on the argument TZ instead
396 of an implicit global time zone. */ 562 of an implicit global time zone. */
563# if @REPLACE_MKTIME_Z@
564# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
565# undef mktime_z
566# define mktime_z rpl_mktime_z
567# endif
568_GL_FUNCDECL_RPL (mktime_z, time_t,
569 (timezone_t __tz, struct tm *restrict __tm),
570 _GL_ARG_NONNULL ((2)));
571_GL_CXXALIAS_RPL (mktime_z, time_t,
572 (timezone_t __tz, struct tm *restrict __tm));
573# else
574# if !@HAVE_TZALLOC@
397_GL_FUNCDECL_SYS (mktime_z, time_t, 575_GL_FUNCDECL_SYS (mktime_z, time_t,
398 (timezone_t __tz, struct tm *restrict __tm) 576 (timezone_t __tz, struct tm *restrict __tm),
399 _GL_ARG_NONNULL ((2))); 577 _GL_ARG_NONNULL ((2)));
578# endif
400_GL_CXXALIAS_SYS (mktime_z, time_t, 579_GL_CXXALIAS_SYS (mktime_z, time_t,
401 (timezone_t __tz, struct tm *restrict __tm)); 580 (timezone_t __tz, struct tm *restrict __tm));
581# endif
402 582
403/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z' 583/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
404 in the 'tm_zone' member of 'struct tm') are valid as long as 584 in the 'tm_zone' member of 'struct tm') are valid as long as
@@ -415,39 +595,46 @@ _GL_CXXALIAS_SYS (mktime_z, time_t,
415# undef timegm 595# undef timegm
416# define timegm rpl_timegm 596# define timegm rpl_timegm
417# endif 597# endif
418_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); 598_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
419_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); 599_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
420# else 600# else
421# if ! @HAVE_TIMEGM@ 601# if ! @HAVE_TIMEGM@
422_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); 602_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm), _GL_ARG_NONNULL ((1)));
423# endif 603# endif
424_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); 604_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
425# endif 605# endif
606# if __GLIBC__ >= 2
426_GL_CXXALIASWARN (timegm); 607_GL_CXXALIASWARN (timegm);
608# endif
609# elif defined GNULIB_POSIXCHECK
610# if HAVE_RAW_DECL_TIMEGM
611_GL_WARN_ON_USE (timegm, "timegm is unportable - "
612 "use gnulib module timegm for portability");
613# endif
427# endif 614# endif
428 615
429/* Encourage applications to avoid unsafe functions that can overrun 616/* Encourage applications to avoid unsafe functions that can overrun
430 buffers when given outlandish struct tm values. Portable 617 buffers when given outlandish struct tm values. Portable
431 applications should use strftime (or even sprintf) instead. */ 618 applications should use strftime (or even sprintf) instead. */
432# if defined GNULIB_POSIXCHECK 619# if defined GNULIB_POSIXCHECK
433# undef asctime 620# if HAVE_RAW_DECL_ASCTIME
434_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " 621_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
435 "better use strftime (or even sprintf) instead"); 622 "better use strftime (or even sprintf) instead");
623# endif
436# endif 624# endif
437# if defined GNULIB_POSIXCHECK 625# if defined GNULIB_POSIXCHECK
438# undef asctime_r
439# if HAVE_RAW_DECL_ASCTIME_R 626# if HAVE_RAW_DECL_ASCTIME_R
440_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - " 627_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
441 "better use strftime (or even sprintf) instead"); 628 "better use strftime (or even sprintf) instead");
442# endif 629# endif
443# endif 630# endif
444# if defined GNULIB_POSIXCHECK 631# if defined GNULIB_POSIXCHECK
445# undef ctime 632# if HAVE_RAW_DECL_CTIME
446_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - " 633_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
447 "better use strftime (or even sprintf) instead"); 634 "better use strftime (or even sprintf) instead");
635# endif
448# endif 636# endif
449# if defined GNULIB_POSIXCHECK 637# if defined GNULIB_POSIXCHECK
450# undef ctime_r
451# if HAVE_RAW_DECL_CTIME_R 638# if HAVE_RAW_DECL_CTIME_R
452_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - " 639_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
453 "better use strftime (or even sprintf) instead"); 640 "better use strftime (or even sprintf) instead");
diff --git a/gl/time_r.c b/gl/time_r.c
index 97be4fd0..dfc427f6 100644
--- a/gl/time_r.c
+++ b/gl/time_r.c
@@ -1,6 +1,6 @@
1/* Reentrant time functions like localtime_r. 1/* Reentrant time functions like localtime_r.
2 2
3 Copyright (C) 2003, 2006-2007, 2010-2023 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006-2007, 2010-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -21,6 +21,11 @@
21 21
22#include <time.h> 22#include <time.h>
23 23
24/* The replacement functions in this file are only used on native Windows.
25 They are multithread-safe, because the gmtime() and localtime() functions
26 on native Windows — both in the ucrt and in the older MSVCRT — return a
27 pointer to a 'struct tm' in thread-local memory. */
28
24static struct tm * 29static struct tm *
25copy_tm_result (struct tm *dest, struct tm const *src) 30copy_tm_result (struct tm *dest, struct tm const *src)
26{ 31{
diff --git a/gl/timegm.c b/gl/timegm.c
index b47025a0..0862b6e9 100644
--- a/gl/timegm.c
+++ b/gl/timegm.c
@@ -1,6 +1,6 @@
1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. 1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
2 2
3 Copyright (C) 1994-2023 Free Software Foundation, Inc. 3 Copyright (C) 1994-2026 Free Software Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
@@ -30,8 +30,7 @@ __time64_t
30__timegm64 (struct tm *tmp) 30__timegm64 (struct tm *tmp)
31{ 31{
32 static mktime_offset_t gmtime_offset; 32 static mktime_offset_t gmtime_offset;
33 tmp->tm_isdst = 0; 33 return __mktime_internal (tmp, false, &gmtime_offset);
34 return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset);
35} 34}
36 35
37#if defined _LIBC && __TIMESIZE != 64 36#if defined _LIBC && __TIMESIZE != 64
diff --git a/gl/uchar.in.h b/gl/uchar.in.h
new file mode 100644
index 00000000..300f7b5f
--- /dev/null
+++ b/gl/uchar.in.h
@@ -0,0 +1,909 @@
1/* <uchar.h> substitute - 16-bit and 32-bit wide character types.
2 Copyright (C) 2019-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19/*
20 * ISO C 23 <uchar.h> for platforms that lack it.
21 */
22
23#ifndef _@GUARD_PREFIX@_UCHAR_H
24
25#if __GNUC__ >= 3
26@PRAGMA_SYSTEM_HEADER@
27#endif
28@PRAGMA_COLUMNS@
29
30/* The include_next requires a split double-inclusion guard. */
31#if (defined __cplusplus ? @CXX_HAVE_UCHAR_H@ : @HAVE_UCHAR_H@)
32# if defined __HAIKU__
33/* Work around <https://dev.haiku-os.org/ticket/17040>. */
34# include <stdint.h>
35# endif
36/* On AIX 7.2 with xlclang++, /usr/include/uchar.h produces compilation errors
37 because it contains typedef definitions of char16_t and char32_t, however
38 char16_t and char32_t are keywords in this situation. To work around it,
39 define char16_t and char32_t as macros. */
40# if defined __cplusplus && defined _AIX && defined __ibmxl__ && defined __clang__
41# define char16_t gl_char16_t
42# define char32_t gl_char32_t
43# endif
44# @INCLUDE_NEXT@ @NEXT_UCHAR_H@
45#endif
46
47#ifndef _@GUARD_PREFIX@_UCHAR_H
48#define _@GUARD_PREFIX@_UCHAR_H
49
50/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_BEGIN_C_LINKAGE,
51 _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
52#if !_GL_CONFIG_H_INCLUDED
53 #error "Please include config.h first."
54#endif
55
56/* Get uint_least16_t, uint_least32_t. */
57#include <stdint.h>
58
59/* Get mbstate_t, size_t. */
60#include <wchar.h>
61
62/* For the inline functions. */
63#include <string.h>
64#include <wctype.h>
65
66/* The __attribute__ feature is available in gcc versions 2.5 and later.
67 The attribute __pure__ was added in gcc 2.96. */
68#ifndef _GL_ATTRIBUTE_PURE
69# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
70# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
71# else
72# define _GL_ATTRIBUTE_PURE /* empty */
73# endif
74#endif
75
76/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
77
78/* The definition of _GL_ARG_NONNULL is copied here. */
79
80/* The definition of _GL_WARN_ON_USE is copied here. */
81
82
83_GL_INLINE_HEADER_BEGIN
84
85
86#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_CHAR8_TYPE@ : @HAVE_UCHAR_H@)
87
88/* An 8-bit variant of wchar_t.
89 Note: This type is only mandated by ISO C 23 or newer, and it does
90 denote UTF-8 units. */
91typedef unsigned char char8_t;
92
93#elif @GNULIBHEADERS_OVERRIDE_CHAR8_T@
94
95typedef unsigned char gl_char8_t;
96# define char8_t gl_char8_t
97
98#endif
99
100#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_UCHAR_TYPES@ : @HAVE_UCHAR_H@)
101
102/* A 16-bit variant of wchar_t.
103 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
104 and newer, it denotes UTF-16 units; in older versions of ISO C it did
105 so only on platforms on which __STDC_UTF_16__ was defined. */
106typedef uint_least16_t char16_t;
107
108#elif @GNULIBHEADERS_OVERRIDE_CHAR16_T@
109
110typedef uint_least16_t gl_char16_t;
111# define char16_t gl_char16_t
112
113#endif
114
115#if !(defined __cplusplus ? @CXX_HAVE_UCHAR_H@ || @CXX_HAS_UCHAR_TYPES@ : @HAVE_UCHAR_H@)
116
117/* A 32-bit variant of wchar_t.
118 Note: This type is only mandated by ISO C 11 or newer. In ISO C 23
119 and newer, it denotes UTF-32 code points; in older versions of ISO C
120 it did so only on platforms on which __STDC_UTF_32__ was defined.
121 In gnulib, we guarantee that it denotes UTF-32 code points if and
122 only if the module 'uchar-h-c23' is in use. */
123typedef uint_least32_t char32_t;
124
125#elif @GNULIBHEADERS_OVERRIDE_CHAR32_T@
126
127typedef uint_least32_t gl_char32_t;
128# define char32_t gl_char32_t
129
130#endif
131
132/* Define if a 'char32_t' can hold more characters than a 'wchar_t'. */
133#if @SMALL_WCHAR_T@ /* 32-bit AIX, Cygwin, native Windows */
134# define _GL_SMALL_WCHAR_T 1
135#endif
136
137/* Define if 'wchar_t', like 'char32_t',
138 - is a 32-bit type, and
139 - represents Unicode code points.
140 For this test, we can use __STDC_ISO_10646__ (defined by glibc, musl libc,
141 Cygwin) but need to consider _GL_SMALL_WCHAR_T, so as to exclude Cygwin.
142 We cannot use __STDC_UTF_16__ or __STDC_UTF_32__
143 - because these macros provide info about char16_t and char32_t (not
144 wchar_t!), and
145 - because GCC >= 4.9 defines these macros on all platforms, even on
146 FreeBSD and Solaris.
147 We should better not use __STD_UTF_16__, __STD_UTF_32__ either, because
148 these macros are misspellings, only defined by Android's <uchar.h>. */
149#if defined __STDC_ISO_10646__ && !_GL_SMALL_WCHAR_T
150/* glibc, musl libc */
151# define _GL_WCHAR_T_IS_UCS4 1
152#endif
153#if _GL_WCHAR_T_IS_UCS4
154static_assert (sizeof (char32_t) == sizeof (wchar_t));
155#endif
156
157
158/* Convert a single-byte character to a 32-bit wide character. */
159#if @GNULIB_BTOC32@
160# if _GL_WCHAR_T_IS_UCS4 && !defined IN_BTOC32
161_GL_BEGIN_C_LINKAGE
162_GL_INLINE _GL_ATTRIBUTE_PURE wint_t
163btoc32 (int c)
164{
165 return
166# if @GNULIB_BTOWC@ && defined __cplusplus && defined GNULIB_NAMESPACE
167 GNULIB_NAMESPACE::
168# endif
169 btowc (c);
170}
171_GL_END_C_LINKAGE
172# else
173_GL_FUNCDECL_SYS (btoc32, wint_t, (int c), _GL_ATTRIBUTE_PURE);
174# endif
175_GL_CXXALIAS_SYS (btoc32, wint_t, (int c));
176_GL_CXXALIASWARN (btoc32);
177#endif
178
179
180/* Test a specific property of a 32-bit wide character. */
181#if @GNULIB_C32ISALNUM@
182# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALNUM
183_GL_BEGIN_C_LINKAGE
184_GL_INLINE int
185c32isalnum (wint_t wc)
186{
187 return
188# if defined __cplusplus && defined GNULIB_NAMESPACE
189 GNULIB_NAMESPACE::
190# endif
191 iswalnum (wc);
192}
193_GL_END_C_LINKAGE
194# else
195_GL_FUNCDECL_SYS (c32isalnum, int, (wint_t wc), );
196# endif
197_GL_CXXALIAS_SYS (c32isalnum, int, (wint_t wc));
198_GL_CXXALIASWARN (c32isalnum);
199#endif
200#if @GNULIB_C32ISALPHA@
201# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALPHA
202_GL_BEGIN_C_LINKAGE
203_GL_INLINE int
204c32isalpha (wint_t wc)
205{
206 return
207# if defined __cplusplus && defined GNULIB_NAMESPACE
208 GNULIB_NAMESPACE::
209# endif
210 iswalpha (wc);
211}
212_GL_END_C_LINKAGE
213# else
214_GL_FUNCDECL_SYS (c32isalpha, int, (wint_t wc), );
215# endif
216_GL_CXXALIAS_SYS (c32isalpha, int, (wint_t wc));
217_GL_CXXALIASWARN (c32isalpha);
218#endif
219#if @GNULIB_C32ISBLANK@
220# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISBLANK
221_GL_BEGIN_C_LINKAGE
222_GL_INLINE int
223c32isblank (wint_t wc)
224{
225 return
226# if defined __cplusplus && defined GNULIB_NAMESPACE
227 GNULIB_NAMESPACE::
228# endif
229 iswblank (wc);
230}
231_GL_END_C_LINKAGE
232# else
233_GL_FUNCDECL_SYS (c32isblank, int, (wint_t wc), );
234# endif
235_GL_CXXALIAS_SYS (c32isblank, int, (wint_t wc));
236_GL_CXXALIASWARN (c32isblank);
237#endif
238#if @GNULIB_C32ISCNTRL@
239# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISCNTRL
240_GL_BEGIN_C_LINKAGE
241_GL_INLINE int
242c32iscntrl (wint_t wc)
243{
244 return
245# if defined __cplusplus && defined GNULIB_NAMESPACE
246 GNULIB_NAMESPACE::
247# endif
248 iswcntrl (wc);
249}
250_GL_END_C_LINKAGE
251# else
252_GL_FUNCDECL_SYS (c32iscntrl, int, (wint_t wc), );
253# endif
254_GL_CXXALIAS_SYS (c32iscntrl, int, (wint_t wc));
255_GL_CXXALIASWARN (c32iscntrl);
256#endif
257#if @GNULIB_C32ISDIGIT@
258# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISDIGIT
259_GL_BEGIN_C_LINKAGE
260_GL_INLINE int
261c32isdigit (wint_t wc)
262{
263 return
264# if @GNULIB_ISWDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE
265 GNULIB_NAMESPACE::
266# endif
267 iswdigit (wc);
268}
269_GL_END_C_LINKAGE
270# else
271_GL_FUNCDECL_SYS (c32isdigit, int, (wint_t wc), );
272# endif
273_GL_CXXALIAS_SYS (c32isdigit, int, (wint_t wc));
274_GL_CXXALIASWARN (c32isdigit);
275#endif
276#if @GNULIB_C32ISGRAPH@
277# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISGRAPH
278_GL_BEGIN_C_LINKAGE
279_GL_INLINE int
280c32isgraph (wint_t wc)
281{
282 return
283# if defined __cplusplus && defined GNULIB_NAMESPACE
284 GNULIB_NAMESPACE::
285# endif
286 iswgraph (wc);
287}
288_GL_END_C_LINKAGE
289# else
290_GL_FUNCDECL_SYS (c32isgraph, int, (wint_t wc), );
291# endif
292_GL_CXXALIAS_SYS (c32isgraph, int, (wint_t wc));
293_GL_CXXALIASWARN (c32isgraph);
294#endif
295#if @GNULIB_C32ISLOWER@
296# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISLOWER
297_GL_BEGIN_C_LINKAGE
298_GL_INLINE int
299c32islower (wint_t wc)
300{
301 return
302# if defined __cplusplus && defined GNULIB_NAMESPACE
303 GNULIB_NAMESPACE::
304# endif
305 iswlower (wc);
306}
307_GL_END_C_LINKAGE
308# else
309_GL_FUNCDECL_SYS (c32islower, int, (wint_t wc), );
310# endif
311_GL_CXXALIAS_SYS (c32islower, int, (wint_t wc));
312_GL_CXXALIASWARN (c32islower);
313#endif
314#if @GNULIB_C32ISPRINT@
315# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPRINT
316_GL_BEGIN_C_LINKAGE
317_GL_INLINE int
318c32isprint (wint_t wc)
319{
320 return
321# if defined __cplusplus && defined GNULIB_NAMESPACE
322 GNULIB_NAMESPACE::
323# endif
324 iswprint (wc);
325}
326_GL_END_C_LINKAGE
327# else
328_GL_FUNCDECL_SYS (c32isprint, int, (wint_t wc), );
329# endif
330_GL_CXXALIAS_SYS (c32isprint, int, (wint_t wc));
331_GL_CXXALIASWARN (c32isprint);
332#endif
333#if @GNULIB_C32ISPUNCT@
334# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPUNCT
335_GL_BEGIN_C_LINKAGE
336_GL_INLINE int
337c32ispunct (wint_t wc)
338{
339 return
340# if defined __cplusplus && defined GNULIB_NAMESPACE
341 GNULIB_NAMESPACE::
342# endif
343 iswpunct (wc);
344}
345_GL_END_C_LINKAGE
346# else
347_GL_FUNCDECL_SYS (c32ispunct, int, (wint_t wc), );
348# endif
349_GL_CXXALIAS_SYS (c32ispunct, int, (wint_t wc));
350_GL_CXXALIASWARN (c32ispunct);
351#endif
352#if @GNULIB_C32ISSPACE@
353# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISSPACE
354_GL_BEGIN_C_LINKAGE
355_GL_INLINE int
356c32isspace (wint_t wc)
357{
358 return
359# if defined __cplusplus && defined GNULIB_NAMESPACE
360 GNULIB_NAMESPACE::
361# endif
362 iswspace (wc);
363}
364_GL_END_C_LINKAGE
365# else
366_GL_FUNCDECL_SYS (c32isspace, int, (wint_t wc), );
367# endif
368_GL_CXXALIAS_SYS (c32isspace, int, (wint_t wc));
369_GL_CXXALIASWARN (c32isspace);
370#endif
371#if @GNULIB_C32ISUPPER@
372# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISUPPER
373_GL_BEGIN_C_LINKAGE
374_GL_INLINE int
375c32isupper (wint_t wc)
376{
377 return
378# if defined __cplusplus && defined GNULIB_NAMESPACE
379 GNULIB_NAMESPACE::
380# endif
381 iswupper (wc);
382}
383_GL_END_C_LINKAGE
384# else
385_GL_FUNCDECL_SYS (c32isupper, int, (wint_t wc), );
386# endif
387_GL_CXXALIAS_SYS (c32isupper, int, (wint_t wc));
388_GL_CXXALIASWARN (c32isupper);
389#endif
390#if @GNULIB_C32ISXDIGIT@
391# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISXDIGIT
392_GL_BEGIN_C_LINKAGE
393_GL_INLINE int
394c32isxdigit (wint_t wc)
395{
396 return
397# if @GNULIB_ISWXDIGIT@ && defined __cplusplus && defined GNULIB_NAMESPACE
398 GNULIB_NAMESPACE::
399# endif
400 iswxdigit (wc);
401}
402_GL_END_C_LINKAGE
403# else
404_GL_FUNCDECL_SYS (c32isxdigit, int, (wint_t wc), );
405# endif
406_GL_CXXALIAS_SYS (c32isxdigit, int, (wint_t wc));
407_GL_CXXALIASWARN (c32isxdigit);
408#endif
409
410
411/* Case mapping of a 32-bit wide character. */
412#if @GNULIB_C32TOLOWER@
413# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOLOWER
414_GL_BEGIN_C_LINKAGE
415_GL_INLINE wint_t
416c32tolower (wint_t wc)
417{
418 return
419# if defined __cplusplus && defined GNULIB_NAMESPACE
420 GNULIB_NAMESPACE::
421# endif
422 towlower (wc);
423}
424_GL_END_C_LINKAGE
425# else
426_GL_FUNCDECL_SYS (c32tolower, wint_t, (wint_t wc), );
427# endif
428_GL_CXXALIAS_SYS (c32tolower, wint_t, (wint_t wc));
429_GL_CXXALIASWARN (c32tolower);
430#endif
431#if @GNULIB_C32TOUPPER@
432# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32TOUPPER
433_GL_BEGIN_C_LINKAGE
434_GL_INLINE wint_t
435c32toupper (wint_t wc)
436{
437 return
438# if defined __cplusplus && defined GNULIB_NAMESPACE
439 GNULIB_NAMESPACE::
440# endif
441 towupper (wc);
442}
443_GL_END_C_LINKAGE
444# else
445_GL_FUNCDECL_SYS (c32toupper, wint_t, (wint_t wc), );
446# endif
447_GL_CXXALIAS_SYS (c32toupper, wint_t, (wint_t wc));
448_GL_CXXALIASWARN (c32toupper);
449#endif
450
451
452/* Number of screen columns needed for a 32-bit wide character. */
453#if @GNULIB_C32WIDTH@
454# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32WIDTH
455_GL_BEGIN_C_LINKAGE
456_GL_INLINE int
457c32width (char32_t wc)
458{
459 return
460# if @GNULIB_WCWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE
461 GNULIB_NAMESPACE::
462# endif
463 wcwidth (wc);
464}
465_GL_END_C_LINKAGE
466# else
467_GL_FUNCDECL_SYS (c32width, int, (char32_t wc), );
468# endif
469_GL_CXXALIAS_SYS (c32width, int, (char32_t wc));
470_GL_CXXALIASWARN (c32width);
471#endif
472
473
474/* Converts a 32-bit wide character to a multibyte character. */
475#if @GNULIB_C32RTOMB@
476# if @REPLACE_C32RTOMB@
477# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
478# undef c32rtomb
479# define c32rtomb rpl_c32rtomb
480# endif
481_GL_FUNCDECL_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps), );
482_GL_CXXALIAS_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
483# else
484# if !@HAVE_C32RTOMB@
485_GL_FUNCDECL_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps), );
486# endif
487_GL_CXXALIAS_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
488# endif
489# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
490_GL_CXXALIASWARN (c32rtomb);
491# endif
492#elif defined GNULIB_POSIXCHECK
493# if HAVE_RAW_DECL_C32RTOMB
494_GL_WARN_ON_USE (c32rtomb, "c32rtomb is not portable - "
495 "use gnulib module c32rtomb for portability");
496# endif
497#endif
498
499
500/* Convert a 32-bit wide string to a string. */
501#if @GNULIB_C32SNRTOMBS@
502# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SNRTOMBS
503_GL_BEGIN_C_LINKAGE
504_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
505c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len,
506 mbstate_t *ps)
507{
508 return
509# if @GNULIB_WCSNRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE
510 GNULIB_NAMESPACE::
511# endif
512 wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps);
513}
514_GL_END_C_LINKAGE
515# else
516_GL_FUNCDECL_SYS (c32snrtombs, size_t,
517 (char *dest, const char32_t **srcp, size_t srclen, size_t len,
518 mbstate_t *ps),
519 _GL_ARG_NONNULL ((2)));
520# endif
521_GL_CXXALIAS_SYS (c32snrtombs, size_t,
522 (char *dest, const char32_t **srcp, size_t srclen, size_t len,
523 mbstate_t *ps));
524_GL_CXXALIASWARN (c32snrtombs);
525#endif
526
527
528/* Convert a 32-bit wide string to a string. */
529#if @GNULIB_C32SRTOMBS@
530# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SRTOMBS
531_GL_BEGIN_C_LINKAGE
532_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
533c32srtombs (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
534{
535 return
536# if @GNULIB_WCSRTOMBS@ && defined __cplusplus && defined GNULIB_NAMESPACE
537 GNULIB_NAMESPACE::
538# endif
539 wcsrtombs (dest, (const wchar_t **) srcp, len, ps);
540}
541_GL_END_C_LINKAGE
542# else
543_GL_FUNCDECL_SYS (c32srtombs, size_t,
544 (char *dest, const char32_t **srcp, size_t len,
545 mbstate_t *ps),
546 _GL_ARG_NONNULL ((2)));
547# endif
548_GL_CXXALIAS_SYS (c32srtombs, size_t,
549 (char *dest, const char32_t **srcp, size_t len,
550 mbstate_t *ps));
551_GL_CXXALIASWARN (c32srtombs);
552#endif
553
554
555/* Convert a 32-bit wide string to a string. */
556#if @GNULIB_C32STOMBS@
557# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32STOMBS
558_GL_BEGIN_C_LINKAGE
559_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
560c32stombs (char *dest, const char32_t *src, size_t len)
561{
562 mbstate_t state;
563
564 mbszero (&state);
565 return c32srtombs (dest, &src, len, &state);
566}
567_GL_END_C_LINKAGE
568# else
569_GL_FUNCDECL_SYS (c32stombs, size_t,
570 (char *dest, const char32_t *src, size_t len),
571 _GL_ARG_NONNULL ((2)));
572# endif
573_GL_CXXALIAS_SYS (c32stombs, size_t,
574 (char *dest, const char32_t *src, size_t len));
575_GL_CXXALIASWARN (c32stombs);
576#endif
577
578
579/* Number of screen columns needed for a size-bounded 32-bit wide string. */
580#if @GNULIB_C32SWIDTH@
581# if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32SWIDTH
582_GL_BEGIN_C_LINKAGE
583_GL_INLINE _GL_ARG_NONNULL ((1)) int
584c32swidth (const char32_t *s, size_t n)
585{
586 return
587# if @GNULIB_WCSWIDTH@ && defined __cplusplus && defined GNULIB_NAMESPACE
588 GNULIB_NAMESPACE::
589# endif
590 wcswidth ((const wchar_t *) s, n);
591}
592_GL_END_C_LINKAGE
593# else
594_GL_FUNCDECL_SYS (c32swidth, int, (const char32_t *s, size_t n),
595 _GL_ARG_NONNULL ((1)));
596# endif
597_GL_CXXALIAS_SYS (c32swidth, int, (const char32_t *s, size_t n));
598_GL_CXXALIASWARN (c32swidth);
599#endif
600
601
602/* Converts a 32-bit wide character to unibyte character.
603 Returns the single-byte representation of WC if it exists,
604 or EOF otherwise. */
605#if @GNULIB_C32TOB@
606# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32TOB
607_GL_BEGIN_C_LINKAGE
608_GL_INLINE int
609c32tob (wint_t wc)
610{
611 return
612# if @GNULIB_WCTOB@ && defined __cplusplus && defined GNULIB_NAMESPACE
613 GNULIB_NAMESPACE::
614# endif
615 wctob (wc);
616}
617_GL_END_C_LINKAGE
618# else
619_GL_FUNCDECL_SYS (c32tob, int, (wint_t wc), );
620# endif
621_GL_CXXALIAS_SYS (c32tob, int, (wint_t wc));
622_GL_CXXALIASWARN (c32tob);
623#endif
624
625
626/* Converts a multibyte character to a 32-bit wide character. */
627#if @GNULIB_MBRTOC32@
628# if @REPLACE_MBRTOC32@
629# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
630# undef mbrtoc32
631# define mbrtoc32 rpl_mbrtoc32
632# endif
633_GL_FUNCDECL_RPL (mbrtoc32, size_t,
634 (char32_t *pc, const char *s, size_t n, mbstate_t *ps), );
635_GL_CXXALIAS_RPL (mbrtoc32, size_t,
636 (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
637# else
638# if !@HAVE_MBRTOC32@
639_GL_FUNCDECL_SYS (mbrtoc32, size_t,
640 (char32_t *pc, const char *s, size_t n, mbstate_t *ps), );
641# endif
642_GL_CXXALIAS_SYS (mbrtoc32, size_t,
643 (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
644# endif
645# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
646_GL_CXXALIASWARN (mbrtoc32);
647# endif
648#elif defined GNULIB_POSIXCHECK
649# if HAVE_RAW_DECL_MBRTOC32
650_GL_WARN_ON_USE (mbrtoc32, "mbrtoc32 is not portable - "
651 "use gnulib module mbrtoc32 for portability");
652# endif
653#endif
654
655
656/* Converts a multibyte character and returns the next 16-bit wide
657 character. */
658#if @GNULIB_MBRTOC16@
659# if @REPLACE_MBRTOC16@
660# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
661# undef mbrtoc16
662# define mbrtoc16 rpl_mbrtoc16
663# endif
664_GL_FUNCDECL_RPL (mbrtoc16, size_t,
665 (char16_t *pc, const char *s, size_t n, mbstate_t *ps), );
666_GL_CXXALIAS_RPL (mbrtoc16, size_t,
667 (char16_t *pc, const char *s, size_t n, mbstate_t *ps));
668# else
669# if !@HAVE_MBRTOC16@
670_GL_FUNCDECL_SYS (mbrtoc16, size_t,
671 (char16_t *pc, const char *s, size_t n, mbstate_t *ps), );
672# endif
673_GL_CXXALIAS_SYS (mbrtoc16, size_t,
674 (char16_t *pc, const char *s, size_t n, mbstate_t *ps));
675# endif
676# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
677_GL_CXXALIASWARN (mbrtoc16);
678# endif
679#elif defined GNULIB_POSIXCHECK
680# if HAVE_RAW_DECL_MBRTOC16
681_GL_WARN_ON_USE (mbrtoc16, "mbrtoc16 is not portable - "
682 "use gnulib module mbrtoc16 for portability");
683# endif
684#endif
685
686
687/* Convert a string to a 32-bit wide string. */
688#if @GNULIB_MBSNRTOC32S@
689# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSNRTOC32S
690_GL_BEGIN_C_LINKAGE
691_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
692mbsnrtoc32s (char32_t *dest, const char **srcp, size_t srclen, size_t len,
693 mbstate_t *ps)
694{
695 return
696# if @GNULIB_MBSNRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE
697 GNULIB_NAMESPACE::
698# endif
699 mbsnrtowcs ((wchar_t *) dest, srcp, srclen, len, ps);
700}
701_GL_END_C_LINKAGE
702# else
703_GL_FUNCDECL_SYS (mbsnrtoc32s, size_t,
704 (char32_t *dest, const char **srcp, size_t srclen, size_t len,
705 mbstate_t *ps),
706 _GL_ARG_NONNULL ((2)));
707# endif
708_GL_CXXALIAS_SYS (mbsnrtoc32s, size_t,
709 (char32_t *dest, const char **srcp, size_t srclen, size_t len,
710 mbstate_t *ps));
711_GL_CXXALIASWARN (mbsnrtoc32s);
712#endif
713
714
715/* Convert a string to a 32-bit wide string. */
716#if @GNULIB_MBSRTOC32S@
717# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSRTOC32S
718_GL_BEGIN_C_LINKAGE
719_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
720mbsrtoc32s (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps)
721{
722 return
723# if @GNULIB_MBSRTOWCS@ && defined __cplusplus && defined GNULIB_NAMESPACE
724 GNULIB_NAMESPACE::
725# endif
726 mbsrtowcs ((wchar_t *) dest, srcp, len, ps);
727}
728_GL_END_C_LINKAGE
729# else
730_GL_FUNCDECL_SYS (mbsrtoc32s, size_t,
731 (char32_t *dest, const char **srcp, size_t len,
732 mbstate_t *ps),
733 _GL_ARG_NONNULL ((2)));
734# endif
735_GL_CXXALIAS_SYS (mbsrtoc32s, size_t,
736 (char32_t *dest, const char **srcp, size_t len,
737 mbstate_t *ps));
738_GL_CXXALIASWARN (mbsrtoc32s);
739#endif
740
741
742/* Convert a string to a 32-bit wide string. */
743#if @GNULIB_MBSTOC32S@
744# if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSTOC32S
745_GL_BEGIN_C_LINKAGE
746_GL_INLINE _GL_ARG_NONNULL ((2)) size_t
747mbstoc32s (char32_t *dest, const char *src, size_t len)
748{
749 mbstate_t state;
750
751 mbszero (&state);
752 return mbsrtoc32s (dest, &src, len, &state);
753}
754_GL_END_C_LINKAGE
755# else
756_GL_FUNCDECL_SYS (mbstoc32s, size_t,
757 (char32_t *dest, const char *src, size_t len),
758 _GL_ARG_NONNULL ((2)));
759# endif
760_GL_CXXALIAS_SYS (mbstoc32s, size_t,
761 (char32_t *dest, const char *src, size_t len));
762_GL_CXXALIASWARN (mbstoc32s);
763#endif
764
765
766#if @GNULIB_C32_GET_TYPE_TEST@ || @GNULIB_C32_APPLY_TYPE_TEST@
767/* A scalar type. Instances of this type, other than (c32_type_test_t) 0,
768 represent a character property, sometimes also viewed as a "character class".
769 It can be applied to 32-bit wide characters. It is the counterpart of
770 type 'wctype_t' for wide characters.
771 To test whether a given character has a certain property, use the function
772 'c32_apply_type_test'. */
773# if _GL_WCHAR_T_IS_UCS4
774typedef wctype_t c32_type_test_t;
775# else
776typedef /*bool*/int (*c32_type_test_t) (wint_t wc);
777# endif
778#endif
779
780/* Return a character property with the given name, or (c32_type_test_t) 0
781 if the designated property does not exist.
782 This function is the counterpart of function 'wctype' for wide characters.
783 */
784#if @GNULIB_C32_GET_TYPE_TEST@
785# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_TYPE_TEST
786_GL_BEGIN_C_LINKAGE
787_GL_INLINE _GL_ARG_NONNULL ((1)) c32_type_test_t
788c32_get_type_test (const char *name)
789{
790 return
791# if @GNULIB_WCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE
792 GNULIB_NAMESPACE::
793# endif
794 wctype (name);
795}
796_GL_END_C_LINKAGE
797# else
798_GL_FUNCDECL_SYS (c32_get_type_test, c32_type_test_t, (const char *name),
799 _GL_ARG_NONNULL ((1)));
800# endif
801_GL_CXXALIAS_SYS (c32_get_type_test, c32_type_test_t, (const char *name));
802_GL_CXXALIASWARN (c32_get_type_test);
803#endif
804
805/* Test whether a given 32-bit wide character has the specified character
806 property.
807 Return non-zero if true, zero if false or if the argument is WEOF.
808 This function is the counterpart of function 'iswctype' for wide characters.
809 */
810#if @GNULIB_C32_APPLY_TYPE_TEST@
811# if _GL_WCHAR_T_IS_UCS4
812# if !defined IN_C32_APPLY_TYPE_TEST
813_GL_BEGIN_C_LINKAGE
814_GL_INLINE int
815c32_apply_type_test (wint_t wc, c32_type_test_t property)
816{
817 return
818# if @GNULIB_ISWCTYPE@ && defined __cplusplus && defined GNULIB_NAMESPACE
819 GNULIB_NAMESPACE::
820# endif
821 iswctype (wc, property);
822}
823_GL_END_C_LINKAGE
824# else
825_GL_FUNCDECL_SYS (c32_apply_type_test, int,
826 (wint_t wc, c32_type_test_t property), );
827# endif
828# else
829_GL_FUNCDECL_SYS (c32_apply_type_test, int,
830 (wint_t wc, c32_type_test_t property),
831 _GL_ARG_NONNULL ((2)));
832# endif
833_GL_CXXALIAS_SYS (c32_apply_type_test, int,
834 (wint_t wc, c32_type_test_t property));
835_GL_CXXALIASWARN (c32_apply_type_test);
836#endif
837
838
839#if @GNULIB_C32_GET_MAPPING@ || @GNULIB_C32_APPLY_MAPPING@
840/* A scalar type. Instances of this type, other than (c32_mapping_t) 0,
841 represent a character mapping. It can be applied to 32-bit wide characters.
842 It is the counterpart of type 'wctrans_t' for wide characters.
843 To apply a certain mapping to a given character, use the function
844 'c32_apply_mapping'. */
845# if _GL_WCHAR_T_IS_UCS4
846typedef wctrans_t c32_mapping_t;
847# else
848typedef wint_t (*c32_mapping_t) (wint_t wc);
849# endif
850#endif
851
852/* Return a character mapping with the given name, or (c32_mapping_t) 0
853 if the designated mapping does not exist.
854 This function is the counterpart of function 'wctrans' for wide characters.
855 */
856#if @GNULIB_C32_GET_MAPPING@
857# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_GET_MAPPING
858_GL_BEGIN_C_LINKAGE
859_GL_INLINE _GL_ARG_NONNULL ((1)) c32_mapping_t
860c32_get_mapping (const char *name)
861{
862 return
863# if @GNULIB_WCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE
864 GNULIB_NAMESPACE::
865# endif
866 wctrans (name);
867}
868_GL_END_C_LINKAGE
869# else
870_GL_FUNCDECL_SYS (c32_get_mapping, c32_mapping_t, (const char *name),
871 _GL_ARG_NONNULL ((1)));
872# endif
873_GL_CXXALIAS_SYS (c32_get_mapping, c32_mapping_t, (const char *name));
874_GL_CXXALIASWARN (c32_get_mapping);
875#endif
876
877/* Apply the specified character mapping to a given 32-bit wide character.
878 Return the result of this mapping. Return the WC argument unchanged if it is
879 WEOF.
880 This function is the counterpart of function 'towctrans' for wide characters.
881 */
882#if @GNULIB_C32_APPLY_MAPPING@
883# if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32_APPLY_MAPPING
884_GL_BEGIN_C_LINKAGE
885_GL_INLINE _GL_ARG_NONNULL ((2)) wint_t
886c32_apply_mapping (wint_t wc, c32_mapping_t mapping)
887{
888 return
889# if @GNULIB_TOWCTRANS@ && defined __cplusplus && defined GNULIB_NAMESPACE
890 GNULIB_NAMESPACE::
891# endif
892 towctrans (wc, mapping);
893}
894_GL_END_C_LINKAGE
895# else
896_GL_FUNCDECL_SYS (c32_apply_mapping, wint_t,
897 (wint_t wc, c32_mapping_t mapping),
898 _GL_ARG_NONNULL ((2)));
899# endif
900_GL_CXXALIAS_SYS (c32_apply_mapping, wint_t,
901 (wint_t wc, c32_mapping_t mapping));
902_GL_CXXALIASWARN (c32_apply_mapping);
903#endif
904
905
906_GL_INLINE_HEADER_END
907
908#endif /* _@GUARD_PREFIX@_UCHAR_H */
909#endif /* _@GUARD_PREFIX@_UCHAR_H */
diff --git a/gl/unicase.in.h b/gl/unicase.in.h
new file mode 100644
index 00000000..e1615aff
--- /dev/null
+++ b/gl/unicase.in.h
@@ -0,0 +1,471 @@
1/* Unicode character case mappings.
2 Copyright (C) 2002, 2009-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _UNICASE_H
18#define _UNICASE_H
19
20#include "unitypes.h"
21
22/* Get bool. */
23#include <stdbool.h>
24
25/* Get size_t. */
26#include <stddef.h>
27
28/* Get uninorm_t. */
29#include "uninorm.h"
30
31#if @HAVE_UNISTRING_WOE32DLL_H@
32# include <unistring/woe32dll.h>
33#else
34# define LIBUNISTRING_DLL_VARIABLE
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* ========================================================================= */
42
43/* Character case mappings.
44 These mappings are locale and context independent.
45 WARNING! These functions are not sufficient for languages such as German.
46 Better use the functions below that treat an entire string at once and are
47 language aware. */
48
49/* Return the uppercase mapping of a Unicode character. */
50extern ucs4_t
51 uc_toupper (ucs4_t uc)
52 _UC_ATTRIBUTE_CONST;
53
54/* Return the lowercase mapping of a Unicode character. */
55extern ucs4_t
56 uc_tolower (ucs4_t uc)
57 _UC_ATTRIBUTE_CONST;
58
59/* Return the titlecase mapping of a Unicode character. */
60extern ucs4_t
61 uc_totitle (ucs4_t uc)
62 _UC_ATTRIBUTE_CONST;
63
64/* ========================================================================= */
65
66/* String case mappings. */
67
68/* These functions are locale dependent. The iso639_language argument
69 identifies the language (e.g. "tr" for Turkish). NULL means to use
70 locale independent case mappings. */
71
72/* Return the ISO 639 language code of the current locale.
73 Return "" if it is unknown, or in the "C" locale. */
74extern const char *
75 uc_locale_language (void)
76 _UC_ATTRIBUTE_PURE;
77
78/* Conventions:
79
80 All functions prefixed with u8_ operate on UTF-8 encoded strings.
81 Their unit is an uint8_t (1 byte).
82
83 All functions prefixed with u16_ operate on UTF-16 encoded strings.
84 Their unit is an uint16_t (a 2-byte word).
85
86 All functions prefixed with u32_ operate on UCS-4 encoded strings.
87 Their unit is an uint32_t (a 4-byte word).
88
89 All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly
90 n units.
91
92 Functions returning a string result take a (resultbuf, lengthp) argument
93 pair. If resultbuf is not NULL and the result fits into *lengthp units,
94 it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly
95 allocated string is returned. In both cases, *lengthp is set to the
96 length (number of units) of the returned string. In case of error,
97 NULL is returned and errno is set. */
98
99/* Return the uppercase mapping of a string.
100 The nf argument identifies the normalization form to apply after the
101 case-mapping. It can also be NULL, for no normalization. */
102extern uint8_t *
103 u8_toupper (const uint8_t *s, size_t n, const char *iso639_language,
104 uninorm_t nf,
105 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
106extern uint16_t *
107 u16_toupper (const uint16_t *s, size_t n, const char *iso639_language,
108 uninorm_t nf,
109 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
110extern uint32_t *
111 u32_toupper (const uint32_t *s, size_t n, const char *iso639_language,
112 uninorm_t nf,
113 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
114
115/* Return the lowercase mapping of a string.
116 The nf argument identifies the normalization form to apply after the
117 case-mapping. It can also be NULL, for no normalization. */
118extern uint8_t *
119 u8_tolower (const uint8_t *s, size_t n, const char *iso639_language,
120 uninorm_t nf,
121 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
122extern uint16_t *
123 u16_tolower (const uint16_t *s, size_t n, const char *iso639_language,
124 uninorm_t nf,
125 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
126extern uint32_t *
127 u32_tolower (const uint32_t *s, size_t n, const char *iso639_language,
128 uninorm_t nf,
129 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
130
131/* Return the titlecase mapping of a string.
132 The nf argument identifies the normalization form to apply after the
133 case-mapping. It can also be NULL, for no normalization. */
134extern uint8_t *
135 u8_totitle (const uint8_t *s, size_t n, const char *iso639_language,
136 uninorm_t nf,
137 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
138extern uint16_t *
139 u16_totitle (const uint16_t *s, size_t n, const char *iso639_language,
140 uninorm_t nf,
141 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
142extern uint32_t *
143 u32_totitle (const uint32_t *s, size_t n, const char *iso639_language,
144 uninorm_t nf,
145 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
146
147/* The case-mapping context given by a prefix string. */
148typedef struct casing_prefix_context
149 {
150 /* These fields are private, undocumented. */
151 uint32_t last_char_except_ignorable;
152 uint32_t last_char_normal_or_above;
153 }
154 casing_prefix_context_t;
155/* The case-mapping context of the empty prefix string. */
156extern @GNULIB_UNICASE_EMPTY_PREFIX_CONTEXT_DLL_VARIABLE@ const casing_prefix_context_t unicase_empty_prefix_context;
157/* Return the case-mapping context of a given prefix string. */
158extern casing_prefix_context_t
159 u8_casing_prefix_context (const uint8_t *s, size_t n);
160extern casing_prefix_context_t
161 u16_casing_prefix_context (const uint16_t *s, size_t n);
162extern casing_prefix_context_t
163 u32_casing_prefix_context (const uint32_t *s, size_t n);
164/* Return the case-mapping context of the prefix concat(A, S), given the
165 case-mapping context of the prefix A. */
166extern casing_prefix_context_t
167 u8_casing_prefixes_context (const uint8_t *s, size_t n,
168 casing_prefix_context_t a_context);
169extern casing_prefix_context_t
170 u16_casing_prefixes_context (const uint16_t *s, size_t n,
171 casing_prefix_context_t a_context);
172extern casing_prefix_context_t
173 u32_casing_prefixes_context (const uint32_t *s, size_t n,
174 casing_prefix_context_t a_context);
175
176/* The case-mapping context given by a suffix string. */
177typedef struct casing_suffix_context
178 {
179 /* These fields are private, undocumented. */
180 uint32_t first_char_except_ignorable;
181 uint32_t bits;
182 }
183 casing_suffix_context_t;
184/* The case-mapping context of the empty suffix string. */
185extern @GNULIB_UNICASE_EMPTY_SUFFIX_CONTEXT_DLL_VARIABLE@ const casing_suffix_context_t unicase_empty_suffix_context;
186/* Return the case-mapping context of a given suffix string. */
187extern casing_suffix_context_t
188 u8_casing_suffix_context (const uint8_t *s, size_t n);
189extern casing_suffix_context_t
190 u16_casing_suffix_context (const uint16_t *s, size_t n);
191extern casing_suffix_context_t
192 u32_casing_suffix_context (const uint32_t *s, size_t n);
193/* Return the case-mapping context of the suffix concat(S, A), given the
194 case-mapping context of the suffix A. */
195extern casing_suffix_context_t
196 u8_casing_suffixes_context (const uint8_t *s, size_t n,
197 casing_suffix_context_t a_context);
198extern casing_suffix_context_t
199 u16_casing_suffixes_context (const uint16_t *s, size_t n,
200 casing_suffix_context_t a_context);
201extern casing_suffix_context_t
202 u32_casing_suffixes_context (const uint32_t *s, size_t n,
203 casing_suffix_context_t a_context);
204
205/* Return the uppercase mapping of a string that is surrounded by a prefix
206 and a suffix. */
207extern uint8_t *
208 u8_ct_toupper (const uint8_t *s, size_t n,
209 casing_prefix_context_t prefix_context,
210 casing_suffix_context_t suffix_context,
211 const char *iso639_language,
212 uninorm_t nf,
213 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
214extern uint16_t *
215 u16_ct_toupper (const uint16_t *s, size_t n,
216 casing_prefix_context_t prefix_context,
217 casing_suffix_context_t suffix_context,
218 const char *iso639_language,
219 uninorm_t nf,
220 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
221extern uint32_t *
222 u32_ct_toupper (const uint32_t *s, size_t n,
223 casing_prefix_context_t prefix_context,
224 casing_suffix_context_t suffix_context,
225 const char *iso639_language,
226 uninorm_t nf,
227 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
228
229/* Return the lowercase mapping of a string that is surrounded by a prefix
230 and a suffix. */
231extern uint8_t *
232 u8_ct_tolower (const uint8_t *s, size_t n,
233 casing_prefix_context_t prefix_context,
234 casing_suffix_context_t suffix_context,
235 const char *iso639_language,
236 uninorm_t nf,
237 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
238extern uint16_t *
239 u16_ct_tolower (const uint16_t *s, size_t n,
240 casing_prefix_context_t prefix_context,
241 casing_suffix_context_t suffix_context,
242 const char *iso639_language,
243 uninorm_t nf,
244 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
245extern uint32_t *
246 u32_ct_tolower (const uint32_t *s, size_t n,
247 casing_prefix_context_t prefix_context,
248 casing_suffix_context_t suffix_context,
249 const char *iso639_language,
250 uninorm_t nf,
251 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
252
253/* Return the titlecase mapping of a string that is surrounded by a prefix
254 and a suffix. */
255extern uint8_t *
256 u8_ct_totitle (const uint8_t *s, size_t n,
257 casing_prefix_context_t prefix_context,
258 casing_suffix_context_t suffix_context,
259 const char *iso639_language,
260 uninorm_t nf,
261 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
262extern uint16_t *
263 u16_ct_totitle (const uint16_t *s, size_t n,
264 casing_prefix_context_t prefix_context,
265 casing_suffix_context_t suffix_context,
266 const char *iso639_language,
267 uninorm_t nf,
268 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
269extern uint32_t *
270 u32_ct_totitle (const uint32_t *s, size_t n,
271 casing_prefix_context_t prefix_context,
272 casing_suffix_context_t suffix_context,
273 const char *iso639_language,
274 uninorm_t nf,
275 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
276
277/* Return the case folded string.
278 Comparing uN_casefold (S1) and uN_casefold (S2) with uN_cmp2() is equivalent
279 to comparing S1 and S2 with uN_casecmp().
280 The nf argument identifies the normalization form to apply after the
281 case-mapping. It can also be NULL, for no normalization. */
282extern uint8_t *
283 u8_casefold (const uint8_t *s, size_t n, const char *iso639_language,
284 uninorm_t nf,
285 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
286extern uint16_t *
287 u16_casefold (const uint16_t *s, size_t n, const char *iso639_language,
288 uninorm_t nf,
289 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
290extern uint32_t *
291 u32_casefold (const uint32_t *s, size_t n, const char *iso639_language,
292 uninorm_t nf,
293 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
294/* Likewise, for a string that is surrounded by a prefix and a suffix. */
295extern uint8_t *
296 u8_ct_casefold (const uint8_t *s, size_t n,
297 casing_prefix_context_t prefix_context,
298 casing_suffix_context_t suffix_context,
299 const char *iso639_language,
300 uninorm_t nf,
301 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
302extern uint16_t *
303 u16_ct_casefold (const uint16_t *s, size_t n,
304 casing_prefix_context_t prefix_context,
305 casing_suffix_context_t suffix_context,
306 const char *iso639_language,
307 uninorm_t nf,
308 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
309extern uint32_t *
310 u32_ct_casefold (const uint32_t *s, size_t n,
311 casing_prefix_context_t prefix_context,
312 casing_suffix_context_t suffix_context,
313 const char *iso639_language,
314 uninorm_t nf,
315 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
316
317/* Compare S1 and S2, ignoring differences in case and normalization.
318 The nf argument identifies the normalization form to apply after the
319 case-mapping. It can also be NULL, for no normalization.
320 If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
321 return 0. Upon failure, return -1 with errno set. */
322extern int
323 u8_casecmp (const uint8_t *s1, size_t n1,
324 const uint8_t *s2, size_t n2,
325 const char *iso639_language, uninorm_t nf, int *resultp);
326extern int
327 u16_casecmp (const uint16_t *s1, size_t n1,
328 const uint16_t *s2, size_t n2,
329 const char *iso639_language, uninorm_t nf, int *resultp);
330extern int
331 u32_casecmp (const uint32_t *s1, size_t n1,
332 const uint32_t *s2, size_t n2,
333 const char *iso639_language, uninorm_t nf, int *resultp);
334extern int
335 ulc_casecmp (const char *s1, size_t n1,
336 const char *s2, size_t n2,
337 const char *iso639_language, uninorm_t nf, int *resultp);
338
339/* Convert the string S of length N to a NUL-terminated byte sequence, in such
340 a way that comparing uN_casexfrm (S1) and uN_casexfrm (S2) with the gnulib
341 function memcmp2() is equivalent to comparing S1 and S2 with uN_casecoll().
342 NF must be either UNINORM_NFC, UNINORM_NFKC, or NULL for no normalization. */
343extern char *
344 u8_casexfrm (const uint8_t *s, size_t n, const char *iso639_language,
345 uninorm_t nf,
346 char *_UC_RESTRICT resultbuf, size_t *lengthp);
347extern char *
348 u16_casexfrm (const uint16_t *s, size_t n, const char *iso639_language,
349 uninorm_t nf,
350 char *_UC_RESTRICT resultbuf, size_t *lengthp);
351extern char *
352 u32_casexfrm (const uint32_t *s, size_t n, const char *iso639_language,
353 uninorm_t nf,
354 char *_UC_RESTRICT resultbuf, size_t *lengthp);
355extern char *
356 ulc_casexfrm (const char *s, size_t n, const char *iso639_language,
357 uninorm_t nf,
358 char *_UC_RESTRICT resultbuf, size_t *lengthp);
359
360/* Compare S1 and S2, ignoring differences in case and normalization, using the
361 collation rules of the current locale.
362 The nf argument identifies the normalization form to apply after the
363 case-mapping. It must be either UNINORM_NFC or UNINORM_NFKC. It can also
364 be NULL, for no normalization.
365 If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
366 return 0. Upon failure, return -1 with errno set. */
367extern int
368 u8_casecoll (const uint8_t *s1, size_t n1,
369 const uint8_t *s2, size_t n2,
370 const char *iso639_language, uninorm_t nf, int *resultp);
371extern int
372 u16_casecoll (const uint16_t *s1, size_t n1,
373 const uint16_t *s2, size_t n2,
374 const char *iso639_language, uninorm_t nf, int *resultp);
375extern int
376 u32_casecoll (const uint32_t *s1, size_t n1,
377 const uint32_t *s2, size_t n2,
378 const char *iso639_language, uninorm_t nf, int *resultp);
379extern int
380 ulc_casecoll (const char *s1, size_t n1,
381 const char *s2, size_t n2,
382 const char *iso639_language, uninorm_t nf, int *resultp);
383
384
385/* Set *RESULTP to true if mapping NFD(S) to upper case is a no-op, or to false
386 otherwise, and return 0. Upon failure, return -1 with errno set. */
387extern int
388 u8_is_uppercase (const uint8_t *s, size_t n,
389 const char *iso639_language,
390 bool *resultp);
391extern int
392 u16_is_uppercase (const uint16_t *s, size_t n,
393 const char *iso639_language,
394 bool *resultp);
395extern int
396 u32_is_uppercase (const uint32_t *s, size_t n,
397 const char *iso639_language,
398 bool *resultp);
399
400/* Set *RESULTP to true if mapping NFD(S) to lower case is a no-op, or to false
401 otherwise, and return 0. Upon failure, return -1 with errno set. */
402extern int
403 u8_is_lowercase (const uint8_t *s, size_t n,
404 const char *iso639_language,
405 bool *resultp);
406extern int
407 u16_is_lowercase (const uint16_t *s, size_t n,
408 const char *iso639_language,
409 bool *resultp);
410extern int
411 u32_is_lowercase (const uint32_t *s, size_t n,
412 const char *iso639_language,
413 bool *resultp);
414
415/* Set *RESULTP to true if mapping NFD(S) to title case is a no-op, or to false
416 otherwise, and return 0. Upon failure, return -1 with errno set. */
417extern int
418 u8_is_titlecase (const uint8_t *s, size_t n,
419 const char *iso639_language,
420 bool *resultp);
421extern int
422 u16_is_titlecase (const uint16_t *s, size_t n,
423 const char *iso639_language,
424 bool *resultp);
425extern int
426 u32_is_titlecase (const uint32_t *s, size_t n,
427 const char *iso639_language,
428 bool *resultp);
429
430/* Set *RESULTP to true if applying case folding to NFD(S) is a no-op, or to
431 false otherwise, and return 0. Upon failure, return -1 with errno set. */
432extern int
433 u8_is_casefolded (const uint8_t *s, size_t n,
434 const char *iso639_language,
435 bool *resultp);
436extern int
437 u16_is_casefolded (const uint16_t *s, size_t n,
438 const char *iso639_language,
439 bool *resultp);
440extern int
441 u32_is_casefolded (const uint32_t *s, size_t n,
442 const char *iso639_language,
443 bool *resultp);
444
445/* Set *RESULTP to true if case matters for S, that is, if mapping NFD(S) to
446 either upper case or lower case or title case is not a no-op.
447 Set *RESULTP to false if NFD(S) maps to itself under the upper case mapping,
448 under the lower case mapping, and under the title case mapping; in other
449 words, when NFD(S) consists entirely of caseless characters.
450 Upon failure, return -1 with errno set. */
451extern int
452 u8_is_cased (const uint8_t *s, size_t n,
453 const char *iso639_language,
454 bool *resultp);
455extern int
456 u16_is_cased (const uint16_t *s, size_t n,
457 const char *iso639_language,
458 bool *resultp);
459extern int
460 u32_is_cased (const uint32_t *s, size_t n,
461 const char *iso639_language,
462 bool *resultp);
463
464
465/* ========================================================================= */
466
467#ifdef __cplusplus
468}
469#endif
470
471#endif /* _UNICASE_H */
diff --git a/gl/unicase/.dirstamp b/gl/unicase/.dirstamp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/gl/unicase/.dirstamp
diff --git a/gl/unicase/simple-mapping.h b/gl/unicase/simple-mapping.h
new file mode 100644
index 00000000..2b3d21d6
--- /dev/null
+++ b/gl/unicase/simple-mapping.h
@@ -0,0 +1,39 @@
1/* Simple case mapping for Unicode characters.
2 Copyright (C) 2002, 2006, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18ucs4_t
19FUNC (ucs4_t uc)
20{
21 unsigned int index1 = uc >> mapping_header_0;
22 if (index1 < mapping_header_1)
23 {
24 int lookup1 = u_mapping.level1[index1];
25 if (lookup1 >= 0)
26 {
27 unsigned int index2 = (uc >> mapping_header_2) & mapping_header_3;
28 int lookup2 = u_mapping.level2[lookup1 + index2];
29 if (lookup2 >= 0)
30 {
31 unsigned int index3 = (uc & mapping_header_4);
32 int lookup3 = u_mapping.level3[lookup2 + index3];
33
34 return uc + lookup3;
35 }
36 }
37 }
38 return uc;
39}
diff --git a/gl/unicase/tolower.c b/gl/unicase/tolower.c
new file mode 100644
index 00000000..89676ad6
--- /dev/null
+++ b/gl/unicase/tolower.c
@@ -0,0 +1,27 @@
1/* Lowercase mapping for Unicode characters (locale and context independent).
2 Copyright (C) 2002, 2006, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unicase.h"
22
23/* Define u_mapping table. */
24#include "tolower.h"
25
26#define FUNC uc_tolower
27#include "simple-mapping.h"
diff --git a/gl/unicase/tolower.h b/gl/unicase/tolower.h
new file mode 100644
index 00000000..f06dacf5
--- /dev/null
+++ b/gl/unicase/tolower.h
@@ -0,0 +1,759 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Simple character mapping of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define mapping_header_0 16
21#define mapping_header_1 2
22#define mapping_header_2 7
23#define mapping_header_3 511
24#define mapping_header_4 127
25static const
26struct
27 {
28 int level1[2];
29 short level2[2 << 9];
30 int level3[37 << 7];
31 }
32u_mapping =
33{
34 { 0, 512 },
35 {
36 0, 128, 256, 384, 512, -1, 640, 768,
37 896, 1024, 1152, -1, -1, -1, -1, -1,
38 -1, -1, -1, -1, -1, -1, -1, -1,
39 -1, -1, -1, -1, -1, -1, -1, -1,
40 -1, 1280, -1, -1, -1, -1, -1, 1408,
41 -1, -1, -1, -1, -1, -1, -1, -1,
42 -1, -1, -1, -1, -1, -1, -1, -1,
43 -1, 1536, -1, -1, 1664, 1792, 1920, 2048,
44 -1, -1, 2176, 2304, -1, -1, -1, -1,
45 -1, 2432, -1, -1, -1, -1, -1, -1,
46 -1, -1, -1, -1, -1, -1, -1, -1,
47 2560, 2688, -1, -1, -1, -1, -1, -1,
48 -1, -1, -1, -1, -1, -1, -1, -1,
49 -1, -1, -1, -1, -1, -1, -1, -1,
50 -1, -1, -1, -1, -1, -1, -1, -1,
51 -1, -1, -1, -1, -1, -1, -1, -1,
52 -1, -1, -1, -1, -1, -1, -1, -1,
53 -1, -1, -1, -1, -1, -1, -1, -1,
54 -1, -1, -1, -1, -1, -1, -1, -1,
55 -1, -1, -1, -1, -1, -1, -1, -1,
56 -1, -1, -1, -1, -1, -1, -1, -1,
57 -1, -1, -1, -1, -1, -1, -1, -1,
58 -1, -1, -1, -1, -1, -1, -1, -1,
59 -1, -1, -1, -1, -1, -1, -1, -1,
60 -1, -1, -1, -1, -1, -1, -1, -1,
61 -1, -1, -1, -1, -1, -1, -1, -1,
62 -1, -1, -1, -1, -1, -1, -1, -1,
63 -1, -1, -1, -1, -1, -1, -1, -1,
64 -1, -1, -1, -1, -1, -1, -1, -1,
65 -1, -1, -1, -1, -1, -1, -1, -1,
66 -1, -1, -1, -1, -1, -1, -1, -1,
67 -1, -1, -1, -1, -1, -1, -1, -1,
68 -1, -1, -1, -1, -1, -1, -1, -1,
69 -1, -1, -1, -1, -1, -1, -1, -1,
70 -1, -1, -1, -1, -1, -1, -1, -1,
71 -1, -1, -1, -1, -1, -1, -1, -1,
72 -1, -1, -1, -1, -1, -1, -1, -1,
73 -1, -1, -1, -1, -1, -1, -1, -1,
74 -1, -1, -1, -1, -1, -1, -1, -1,
75 -1, -1, -1, -1, -1, -1, -1, -1,
76 -1, -1, -1, -1, -1, -1, -1, -1,
77 -1, -1, -1, -1, 2816, 2944, 3072, 3200,
78 -1, -1, -1, -1, -1, -1, -1, -1,
79 -1, -1, -1, -1, -1, -1, -1, -1,
80 -1, -1, -1, -1, -1, -1, -1, -1,
81 -1, -1, -1, -1, -1, -1, -1, -1,
82 -1, -1, -1, -1, -1, -1, -1, -1,
83 -1, -1, -1, -1, -1, -1, -1, -1,
84 -1, -1, -1, -1, -1, -1, -1, -1,
85 -1, -1, -1, -1, -1, -1, -1, -1,
86 -1, -1, -1, -1, -1, -1, -1, -1,
87 -1, -1, -1, -1, -1, -1, -1, -1,
88 -1, -1, -1, -1, -1, -1, -1, -1,
89 -1, -1, -1, -1, -1, -1, -1, -1,
90 -1, -1, -1, -1, -1, -1, -1, -1,
91 -1, -1, -1, -1, -1, -1, -1, -1,
92 -1, -1, -1, -1, -1, -1, -1, -1,
93 -1, -1, -1, -1, -1, -1, -1, -1,
94 -1, -1, -1, -1, -1, -1, -1, -1,
95 -1, -1, -1, -1, -1, -1, -1, -1,
96 -1, -1, -1, -1, -1, -1, -1, -1,
97 -1, -1, -1, -1, -1, -1, -1, -1,
98 -1, -1, -1, -1, -1, -1, -1, -1,
99 -1, -1, -1, -1, -1, -1, 3328, -1,
100 -1, -1, -1, -1, -1, -1, -1, -1,
101 3456, 3584, 3712, 3840, -1, -1, -1, -1,
102 -1, -1, -1, -1, -1, -1, -1, -1,
103 -1, 3968, 4096, -1, -1, -1, -1, -1,
104 -1, -1, -1, -1, -1, -1, -1, -1,
105 -1, -1, -1, -1, -1, -1, -1, -1,
106 -1, 4224, -1, -1, -1, -1, -1, -1,
107 -1, -1, -1, -1, -1, -1, -1, -1,
108 -1, -1, -1, -1, -1, -1, -1, -1,
109 -1, -1, -1, -1, -1, -1, -1, -1,
110 -1, -1, -1, -1, -1, -1, -1, -1,
111 -1, -1, -1, -1, -1, -1, -1, -1,
112 -1, -1, -1, -1, -1, -1, -1, -1,
113 -1, -1, -1, -1, -1, -1, -1, -1,
114 -1, -1, -1, -1, -1, -1, -1, -1,
115 -1, -1, -1, -1, -1, -1, -1, -1,
116 -1, -1, -1, -1, -1, -1, -1, -1,
117 -1, -1, -1, -1, -1, -1, -1, -1,
118 -1, -1, -1, -1, -1, -1, -1, -1,
119 -1, -1, -1, -1, -1, -1, -1, -1,
120 -1, -1, -1, -1, -1, -1, -1, -1,
121 -1, -1, -1, -1, -1, -1, -1, -1,
122 -1, -1, -1, -1, -1, -1, -1, -1,
123 -1, -1, -1, -1, -1, -1, -1, -1,
124 -1, -1, -1, -1, -1, -1, -1, -1,
125 -1, -1, -1, -1, -1, -1, -1, -1,
126 -1, -1, -1, -1, -1, -1, -1, -1,
127 -1, -1, -1, -1, 4352, 4480, -1, -1,
128 -1, -1, -1, -1, -1, -1, -1, -1,
129 -1, -1, -1, -1, -1, -1, -1, -1,
130 -1, -1, -1, -1, -1, -1, -1, -1,
131 -1, -1, -1, -1, -1, -1, -1, -1,
132 -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, -1, -1, -1, -1, -1,
134 -1, -1, -1, -1, -1, -1, -1, -1,
135 -1, -1, -1, -1, -1, -1, -1, -1,
136 -1, -1, -1, -1, -1, -1, -1, -1,
137 -1, -1, -1, -1, -1, -1, -1, -1,
138 -1, -1, -1, -1, -1, -1, -1, -1,
139 -1, -1, -1, -1, -1, -1, -1, -1,
140 -1, -1, -1, -1, -1, -1, -1, -1,
141 -1, -1, -1, -1, -1, -1, -1, -1,
142 -1, -1, -1, -1, -1, -1, -1, -1,
143 -1, -1, -1, -1, -1, -1, -1, -1,
144 -1, -1, -1, -1, -1, -1, -1, -1,
145 -1, -1, -1, -1, -1, -1, -1, -1,
146 -1, -1, -1, -1, -1, -1, -1, -1,
147 -1, -1, -1, -1, -1, -1, -1, -1,
148 -1, -1, -1, -1, -1, -1, -1, -1,
149 -1, -1, -1, -1, -1, -1, -1, -1,
150 -1, -1, -1, -1, -1, -1, -1, -1,
151 -1, -1, -1, -1, -1, -1, -1, -1,
152 -1, -1, -1, -1, -1, -1, -1, -1,
153 -1, -1, -1, -1, -1, -1, -1, -1,
154 -1, -1, -1, -1, -1, -1, -1, -1,
155 -1, -1, -1, -1, -1, -1, -1, -1,
156 -1, -1, -1, -1, -1, -1, -1, -1,
157 -1, -1, -1, -1, -1, -1, -1, -1,
158 -1, -1, 4608, -1, -1, -1, -1, -1,
159 -1, -1, -1, -1, -1, -1, -1, -1,
160 -1, -1, -1, -1, -1, -1, -1, -1,
161 -1, -1, -1, -1, -1, -1, -1, -1,
162 -1, -1, -1, -1, -1, -1, -1, -1,
163 -1, -1, -1, -1, -1, -1, -1, -1
164 },
165 {
166 0, 0, 0, 0, 0, 0, 0, 0,
167 0, 0, 0, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 0, 0,
169 0, 0, 0, 0, 0, 0, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0,
171 0, 0, 0, 0, 0, 0, 0, 0,
172 0, 0, 0, 0, 0, 0, 0, 0,
173 0, 0, 0, 0, 0, 0, 0, 0,
174 0, 32, 32, 32, 32, 32, 32, 32,
175 32, 32, 32, 32, 32, 32, 32, 32,
176 32, 32, 32, 32, 32, 32, 32, 32,
177 32, 32, 32, 0, 0, 0, 0, 0,
178 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0,
181 0, 0, 0, 0, 0, 0, 0, 0,
182 0, 0, 0, 0, 0, 0, 0, 0,
183 0, 0, 0, 0, 0, 0, 0, 0,
184 0, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0,
187 0, 0, 0, 0, 0, 0, 0, 0,
188 0, 0, 0, 0, 0, 0, 0, 0,
189 0, 0, 0, 0, 0, 0, 0, 0,
190 32, 32, 32, 32, 32, 32, 32, 32,
191 32, 32, 32, 32, 32, 32, 32, 32,
192 32, 32, 32, 32, 32, 32, 32, 0,
193 32, 32, 32, 32, 32, 32, 32, 0,
194 0, 0, 0, 0, 0, 0, 0, 0,
195 0, 0, 0, 0, 0, 0, 0, 0,
196 0, 0, 0, 0, 0, 0, 0, 0,
197 0, 0, 0, 0, 0, 0, 0, 0,
198 1, 0, 1, 0, 1, 0, 1, 0,
199 1, 0, 1, 0, 1, 0, 1, 0,
200 1, 0, 1, 0, 1, 0, 1, 0,
201 1, 0, 1, 0, 1, 0, 1, 0,
202 1, 0, 1, 0, 1, 0, 1, 0,
203 1, 0, 1, 0, 1, 0, 1, 0,
204 -199, 0, 1, 0, 1, 0, 1, 0,
205 0, 1, 0, 1, 0, 1, 0, 1,
206 0, 1, 0, 1, 0, 1, 0, 1,
207 0, 0, 1, 0, 1, 0, 1, 0,
208 1, 0, 1, 0, 1, 0, 1, 0,
209 1, 0, 1, 0, 1, 0, 1, 0,
210 1, 0, 1, 0, 1, 0, 1, 0,
211 1, 0, 1, 0, 1, 0, 1, 0,
212 1, 0, 1, 0, 1, 0, 1, 0,
213 -121, 1, 0, 1, 0, 1, 0, 0,
214 0, 210, 1, 0, 1, 0, 206, 1,
215 0, 205, 205, 1, 0, 0, 79, 202,
216 203, 1, 0, 205, 207, 0, 211, 209,
217 1, 0, 0, 0, 211, 213, 0, 214,
218 1, 0, 1, 0, 1, 0, 218, 1,
219 0, 218, 0, 0, 1, 0, 218, 1,
220 0, 217, 217, 1, 0, 1, 0, 219,
221 1, 0, 0, 0, 1, 0, 0, 0,
222 0, 0, 0, 0, 2, 1, 0, 2,
223 1, 0, 2, 1, 0, 1, 0, 1,
224 0, 1, 0, 1, 0, 1, 0, 1,
225 0, 1, 0, 1, 0, 0, 1, 0,
226 1, 0, 1, 0, 1, 0, 1, 0,
227 1, 0, 1, 0, 1, 0, 1, 0,
228 0, 2, 1, 0, 1, 0, -97, -56,
229 1, 0, 1, 0, 1, 0, 1, 0,
230 1, 0, 1, 0, 1, 0, 1, 0,
231 1, 0, 1, 0, 1, 0, 1, 0,
232 1, 0, 1, 0, 1, 0, 1, 0,
233 1, 0, 1, 0, 1, 0, 1, 0,
234 -130, 0, 1, 0, 1, 0, 1, 0,
235 1, 0, 1, 0, 1, 0, 1, 0,
236 1, 0, 1, 0, 0, 0, 0, 0,
237 0, 0, 10795, 1, 0, -163, 10792, 0,
238 0, 1, 0, -195, 69, 71, 1, 0,
239 1, 0, 1, 0, 1, 0, 1, 0,
240 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0, 0, 0,
242 0, 0, 0, 0, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 0, 0,
244 0, 0, 0, 0, 0, 0, 0, 0,
245 0, 0, 0, 0, 0, 0, 0, 0,
246 0, 0, 0, 0, 0, 0, 0, 0,
247 0, 0, 0, 0, 0, 0, 0, 0,
248 0, 0, 0, 0, 0, 0, 0, 0,
249 0, 0, 0, 0, 0, 0, 0, 0,
250 0, 0, 0, 0, 0, 0, 0, 0,
251 0, 0, 0, 0, 0, 0, 0, 0,
252 0, 0, 0, 0, 0, 0, 0, 0,
253 0, 0, 0, 0, 0, 0, 0, 0,
254 0, 0, 0, 0, 0, 0, 0, 0,
255 0, 0, 0, 0, 0, 0, 0, 0,
256 0, 0, 0, 0, 0, 0, 0, 0,
257 0, 0, 0, 0, 0, 0, 0, 0,
258 0, 0, 0, 0, 0, 0, 0, 0,
259 0, 0, 0, 0, 0, 0, 0, 0,
260 1, 0, 1, 0, 0, 0, 1, 0,
261 0, 0, 0, 0, 0, 0, 0, 116,
262 0, 0, 0, 0, 0, 0, 38, 0,
263 37, 37, 37, 0, 64, 0, 63, 63,
264 0, 32, 32, 32, 32, 32, 32, 32,
265 32, 32, 32, 32, 32, 32, 32, 32,
266 32, 32, 0, 32, 32, 32, 32, 32,
267 32, 32, 32, 32, 0, 0, 0, 0,
268 0, 0, 0, 0, 0, 0, 0, 0,
269 0, 0, 0, 0, 0, 0, 0, 0,
270 0, 0, 0, 0, 0, 0, 0, 0,
271 0, 0, 0, 0, 0, 0, 0, 8,
272 0, 0, 0, 0, 0, 0, 0, 0,
273 1, 0, 1, 0, 1, 0, 1, 0,
274 1, 0, 1, 0, 1, 0, 1, 0,
275 1, 0, 1, 0, 1, 0, 1, 0,
276 0, 0, 0, 0, -60, 0, 0, 1,
277 0, -7, 1, 0, 0, -130, -130, -130,
278 80, 80, 80, 80, 80, 80, 80, 80,
279 80, 80, 80, 80, 80, 80, 80, 80,
280 32, 32, 32, 32, 32, 32, 32, 32,
281 32, 32, 32, 32, 32, 32, 32, 32,
282 32, 32, 32, 32, 32, 32, 32, 32,
283 32, 32, 32, 32, 32, 32, 32, 32,
284 0, 0, 0, 0, 0, 0, 0, 0,
285 0, 0, 0, 0, 0, 0, 0, 0,
286 0, 0, 0, 0, 0, 0, 0, 0,
287 0, 0, 0, 0, 0, 0, 0, 0,
288 0, 0, 0, 0, 0, 0, 0, 0,
289 0, 0, 0, 0, 0, 0, 0, 0,
290 1, 0, 1, 0, 1, 0, 1, 0,
291 1, 0, 1, 0, 1, 0, 1, 0,
292 1, 0, 1, 0, 1, 0, 1, 0,
293 1, 0, 1, 0, 1, 0, 1, 0,
294 1, 0, 0, 0, 0, 0, 0, 0,
295 0, 0, 1, 0, 1, 0, 1, 0,
296 1, 0, 1, 0, 1, 0, 1, 0,
297 1, 0, 1, 0, 1, 0, 1, 0,
298 1, 0, 1, 0, 1, 0, 1, 0,
299 1, 0, 1, 0, 1, 0, 1, 0,
300 1, 0, 1, 0, 1, 0, 1, 0,
301 1, 0, 1, 0, 1, 0, 1, 0,
302 15, 1, 0, 1, 0, 1, 0, 1,
303 0, 1, 0, 1, 0, 1, 0, 0,
304 1, 0, 1, 0, 1, 0, 1, 0,
305 1, 0, 1, 0, 1, 0, 1, 0,
306 1, 0, 1, 0, 1, 0, 1, 0,
307 1, 0, 1, 0, 1, 0, 1, 0,
308 1, 0, 1, 0, 1, 0, 1, 0,
309 1, 0, 1, 0, 1, 0, 1, 0,
310 1, 0, 1, 0, 1, 0, 1, 0,
311 1, 0, 1, 0, 1, 0, 1, 0,
312 1, 0, 1, 0, 1, 0, 1, 0,
313 1, 0, 1, 0, 1, 0, 1, 0,
314 1, 0, 1, 0, 1, 0, 1, 0,
315 1, 0, 1, 0, 1, 0, 1, 0,
316 0, 48, 48, 48, 48, 48, 48, 48,
317 48, 48, 48, 48, 48, 48, 48, 48,
318 48, 48, 48, 48, 48, 48, 48, 48,
319 48, 48, 48, 48, 48, 48, 48, 48,
320 48, 48, 48, 48, 48, 48, 48, 0,
321 0, 0, 0, 0, 0, 0, 0, 0,
322 0, 0, 0, 0, 0, 0, 0, 0,
323 0, 0, 0, 0, 0, 0, 0, 0,
324 0, 0, 0, 0, 0, 0, 0, 0,
325 0, 0, 0, 0, 0, 0, 0, 0,
326 0, 0, 0, 0, 0, 0, 0, 0,
327 0, 0, 0, 0, 0, 0, 0, 0,
328 0, 0, 0, 0, 0, 0, 0, 0,
329 0, 0, 0, 0, 0, 0, 0, 0,
330 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264,
331 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264,
332 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264,
333 7264, 7264, 7264, 7264, 7264, 7264, 7264, 7264,
334 7264, 7264, 7264, 7264, 7264, 7264, 0, 7264,
335 0, 0, 0, 0, 0, 7264, 0, 0,
336 0, 0, 0, 0, 0, 0, 0, 0,
337 0, 0, 0, 0, 0, 0, 0, 0,
338 0, 0, 0, 0, 0, 0, 0, 0,
339 0, 0, 0, 0, 0, 0, 0, 0,
340 0, 0, 0, 0, 0, 0, 0, 0,
341 0, 0, 0, 0, 0, 0, 0, 0,
342 0, 0, 0, 0, 0, 0, 0, 0,
343 0, 0, 0, 0, 0, 0, 0, 0,
344 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 0, 0,
346 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
347 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
348 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
349 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
350 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
351 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
352 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
353 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
354 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
355 38864, 38864, 38864, 38864, 38864, 38864, 38864, 38864,
356 8, 8, 8, 8, 8, 8, 0, 0,
357 0, 0, 0, 0, 0, 0, 0, 0,
358 0, 0, 0, 0, 0, 0, 0, 0,
359 0, 1, 0, 0, 0, 0, 0, 0,
360 -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008,
361 -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008,
362 -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008,
363 -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008,
364 -3008, -3008, -3008, -3008, -3008, -3008, -3008, -3008,
365 -3008, -3008, -3008, 0, 0, -3008, -3008, -3008,
366 0, 0, 0, 0, 0, 0, 0, 0,
367 0, 0, 0, 0, 0, 0, 0, 0,
368 0, 0, 0, 0, 0, 0, 0, 0,
369 0, 0, 0, 0, 0, 0, 0, 0,
370 0, 0, 0, 0, 0, 0, 0, 0,
371 0, 0, 0, 0, 0, 0, 0, 0,
372 0, 0, 0, 0, 0, 0, 0, 0,
373 0, 0, 0, 0, 0, 0, 0, 0,
374 1, 0, 1, 0, 1, 0, 1, 0,
375 1, 0, 1, 0, 1, 0, 1, 0,
376 1, 0, 1, 0, 1, 0, 1, 0,
377 1, 0, 1, 0, 1, 0, 1, 0,
378 1, 0, 1, 0, 1, 0, 1, 0,
379 1, 0, 1, 0, 1, 0, 1, 0,
380 1, 0, 1, 0, 1, 0, 1, 0,
381 1, 0, 1, 0, 1, 0, 1, 0,
382 1, 0, 1, 0, 1, 0, 1, 0,
383 1, 0, 1, 0, 1, 0, 1, 0,
384 1, 0, 1, 0, 1, 0, 1, 0,
385 1, 0, 1, 0, 1, 0, 1, 0,
386 1, 0, 1, 0, 1, 0, 1, 0,
387 1, 0, 1, 0, 1, 0, 1, 0,
388 1, 0, 1, 0, 1, 0, 1, 0,
389 1, 0, 1, 0, 1, 0, 1, 0,
390 1, 0, 1, 0, 1, 0, 1, 0,
391 1, 0, 1, 0, 1, 0, 1, 0,
392 1, 0, 1, 0, 1, 0, 0, 0,
393 0, 0, 0, 0, 0, 0, -7615, 0,
394 1, 0, 1, 0, 1, 0, 1, 0,
395 1, 0, 1, 0, 1, 0, 1, 0,
396 1, 0, 1, 0, 1, 0, 1, 0,
397 1, 0, 1, 0, 1, 0, 1, 0,
398 1, 0, 1, 0, 1, 0, 1, 0,
399 1, 0, 1, 0, 1, 0, 1, 0,
400 1, 0, 1, 0, 1, 0, 1, 0,
401 1, 0, 1, 0, 1, 0, 1, 0,
402 1, 0, 1, 0, 1, 0, 1, 0,
403 1, 0, 1, 0, 1, 0, 1, 0,
404 1, 0, 1, 0, 1, 0, 1, 0,
405 1, 0, 1, 0, 1, 0, 1, 0,
406 0, 0, 0, 0, 0, 0, 0, 0,
407 -8, -8, -8, -8, -8, -8, -8, -8,
408 0, 0, 0, 0, 0, 0, 0, 0,
409 -8, -8, -8, -8, -8, -8, 0, 0,
410 0, 0, 0, 0, 0, 0, 0, 0,
411 -8, -8, -8, -8, -8, -8, -8, -8,
412 0, 0, 0, 0, 0, 0, 0, 0,
413 -8, -8, -8, -8, -8, -8, -8, -8,
414 0, 0, 0, 0, 0, 0, 0, 0,
415 -8, -8, -8, -8, -8, -8, 0, 0,
416 0, 0, 0, 0, 0, 0, 0, 0,
417 0, -8, 0, -8, 0, -8, 0, -8,
418 0, 0, 0, 0, 0, 0, 0, 0,
419 -8, -8, -8, -8, -8, -8, -8, -8,
420 0, 0, 0, 0, 0, 0, 0, 0,
421 0, 0, 0, 0, 0, 0, 0, 0,
422 0, 0, 0, 0, 0, 0, 0, 0,
423 -8, -8, -8, -8, -8, -8, -8, -8,
424 0, 0, 0, 0, 0, 0, 0, 0,
425 -8, -8, -8, -8, -8, -8, -8, -8,
426 0, 0, 0, 0, 0, 0, 0, 0,
427 -8, -8, -8, -8, -8, -8, -8, -8,
428 0, 0, 0, 0, 0, 0, 0, 0,
429 -8, -8, -74, -74, -9, 0, 0, 0,
430 0, 0, 0, 0, 0, 0, 0, 0,
431 -86, -86, -86, -86, -9, 0, 0, 0,
432 0, 0, 0, 0, 0, 0, 0, 0,
433 -8, -8, -100, -100, 0, 0, 0, 0,
434 0, 0, 0, 0, 0, 0, 0, 0,
435 -8, -8, -112, -112, -7, 0, 0, 0,
436 0, 0, 0, 0, 0, 0, 0, 0,
437 -128, -128, -126, -126, -9, 0, 0, 0,
438 0, 0, 0, 0, 0, 0, 0, 0,
439 0, 0, 0, 0, 0, 0, 0, 0,
440 0, 0, 0, 0, 0, 0, 0, 0,
441 0, 0, 0, 0, 0, 0, 0, 0,
442 0, 0, 0, 0, 0, 0, -7517, 0,
443 0, 0, -8383, -8262, 0, 0, 0, 0,
444 0, 0, 28, 0, 0, 0, 0, 0,
445 0, 0, 0, 0, 0, 0, 0, 0,
446 0, 0, 0, 0, 0, 0, 0, 0,
447 0, 0, 0, 0, 0, 0, 0, 0,
448 0, 0, 0, 0, 0, 0, 0, 0,
449 0, 0, 0, 0, 0, 0, 0, 0,
450 16, 16, 16, 16, 16, 16, 16, 16,
451 16, 16, 16, 16, 16, 16, 16, 16,
452 0, 0, 0, 0, 0, 0, 0, 0,
453 0, 0, 0, 0, 0, 0, 0, 0,
454 0, 0, 0, 1, 0, 0, 0, 0,
455 0, 0, 0, 0, 0, 0, 0, 0,
456 0, 0, 0, 0, 0, 0, 0, 0,
457 0, 0, 0, 0, 0, 0, 0, 0,
458 0, 0, 0, 0, 0, 0, 0, 0,
459 0, 0, 0, 0, 0, 0, 0, 0,
460 0, 0, 0, 0, 0, 0, 0, 0,
461 0, 0, 0, 0, 0, 0, 0, 0,
462 0, 0, 0, 0, 0, 0, 0, 0,
463 0, 0, 0, 0, 0, 0, 0, 0,
464 0, 0, 0, 0, 0, 0, 0, 0,
465 0, 0, 0, 0, 0, 0, 0, 0,
466 0, 0, 0, 0, 0, 0, 0, 0,
467 0, 0, 0, 0, 0, 0, 0, 0,
468 0, 0, 0, 0, 0, 0, 0, 0,
469 0, 0, 0, 0, 0, 0, 0, 0,
470 0, 0, 0, 0, 0, 0, 0, 0,
471 0, 0, 0, 0, 0, 0, 0, 0,
472 0, 0, 0, 0, 0, 0, 0, 0,
473 0, 0, 0, 0, 0, 0, 0, 0,
474 0, 0, 0, 0, 0, 0, 0, 0,
475 0, 0, 0, 0, 0, 0, 0, 0,
476 0, 0, 0, 0, 0, 0, 26, 26,
477 26, 26, 26, 26, 26, 26, 26, 26,
478 26, 26, 26, 26, 26, 26, 26, 26,
479 26, 26, 26, 26, 26, 26, 26, 26,
480 0, 0, 0, 0, 0, 0, 0, 0,
481 0, 0, 0, 0, 0, 0, 0, 0,
482 0, 0, 0, 0, 0, 0, 0, 0,
483 0, 0, 0, 0, 0, 0, 0, 0,
484 0, 0, 0, 0, 0, 0, 0, 0,
485 0, 0, 0, 0, 0, 0, 0, 0,
486 48, 48, 48, 48, 48, 48, 48, 48,
487 48, 48, 48, 48, 48, 48, 48, 48,
488 48, 48, 48, 48, 48, 48, 48, 48,
489 48, 48, 48, 48, 48, 48, 48, 48,
490 48, 48, 48, 48, 48, 48, 48, 48,
491 48, 48, 48, 48, 48, 48, 48, 48,
492 0, 0, 0, 0, 0, 0, 0, 0,
493 0, 0, 0, 0, 0, 0, 0, 0,
494 0, 0, 0, 0, 0, 0, 0, 0,
495 0, 0, 0, 0, 0, 0, 0, 0,
496 0, 0, 0, 0, 0, 0, 0, 0,
497 0, 0, 0, 0, 0, 0, 0, 0,
498 1, 0, -10743, -3814, -10727, 0, 0, 1,
499 0, 1, 0, 1, 0, -10780, -10749, -10783,
500 -10782, 0, 1, 0, 0, 1, 0, 0,
501 0, 0, 0, 0, 0, 0, -10815, -10815,
502 1, 0, 1, 0, 1, 0, 1, 0,
503 1, 0, 1, 0, 1, 0, 1, 0,
504 1, 0, 1, 0, 1, 0, 1, 0,
505 1, 0, 1, 0, 1, 0, 1, 0,
506 1, 0, 1, 0, 1, 0, 1, 0,
507 1, 0, 1, 0, 1, 0, 1, 0,
508 1, 0, 1, 0, 1, 0, 1, 0,
509 1, 0, 1, 0, 1, 0, 1, 0,
510 1, 0, 1, 0, 1, 0, 1, 0,
511 1, 0, 1, 0, 1, 0, 1, 0,
512 1, 0, 1, 0, 1, 0, 1, 0,
513 1, 0, 1, 0, 1, 0, 1, 0,
514 1, 0, 1, 0, 0, 0, 0, 0,
515 0, 0, 0, 1, 0, 1, 0, 0,
516 0, 0, 1, 0, 0, 0, 0, 0,
517 0, 0, 0, 0, 0, 0, 0, 0,
518 0, 0, 0, 0, 0, 0, 0, 0,
519 0, 0, 0, 0, 0, 0, 0, 0,
520 0, 0, 0, 0, 0, 0, 0, 0,
521 0, 0, 0, 0, 0, 0, 0, 0,
522 0, 0, 0, 0, 0, 0, 0, 0,
523 0, 0, 0, 0, 0, 0, 0, 0,
524 0, 0, 0, 0, 0, 0, 0, 0,
525 0, 0, 0, 0, 0, 0, 0, 0,
526 1, 0, 1, 0, 1, 0, 1, 0,
527 1, 0, 1, 0, 1, 0, 1, 0,
528 1, 0, 1, 0, 1, 0, 1, 0,
529 1, 0, 1, 0, 1, 0, 1, 0,
530 1, 0, 1, 0, 1, 0, 1, 0,
531 1, 0, 1, 0, 1, 0, 0, 0,
532 0, 0, 0, 0, 0, 0, 0, 0,
533 0, 0, 0, 0, 0, 0, 0, 0,
534 1, 0, 1, 0, 1, 0, 1, 0,
535 1, 0, 1, 0, 1, 0, 1, 0,
536 1, 0, 1, 0, 1, 0, 1, 0,
537 1, 0, 1, 0, 0, 0, 0, 0,
538 0, 0, 0, 0, 0, 0, 0, 0,
539 0, 0, 0, 0, 0, 0, 0, 0,
540 0, 0, 0, 0, 0, 0, 0, 0,
541 0, 0, 0, 0, 0, 0, 0, 0,
542 0, 0, 0, 0, 0, 0, 0, 0,
543 0, 0, 0, 0, 0, 0, 0, 0,
544 0, 0, 0, 0, 0, 0, 0, 0,
545 0, 0, 0, 0, 0, 0, 0, 0,
546 0, 0, 0, 0, 0, 0, 0, 0,
547 0, 0, 0, 0, 0, 0, 0, 0,
548 0, 0, 0, 0, 0, 0, 0, 0,
549 0, 0, 0, 0, 0, 0, 0, 0,
550 0, 0, 0, 0, 0, 0, 0, 0,
551 0, 0, 0, 0, 0, 0, 0, 0,
552 0, 0, 0, 0, 0, 0, 0, 0,
553 0, 0, 0, 0, 0, 0, 0, 0,
554 0, 0, 1, 0, 1, 0, 1, 0,
555 1, 0, 1, 0, 1, 0, 1, 0,
556 0, 0, 1, 0, 1, 0, 1, 0,
557 1, 0, 1, 0, 1, 0, 1, 0,
558 1, 0, 1, 0, 1, 0, 1, 0,
559 1, 0, 1, 0, 1, 0, 1, 0,
560 1, 0, 1, 0, 1, 0, 1, 0,
561 1, 0, 1, 0, 1, 0, 1, 0,
562 1, 0, 1, 0, 1, 0, 1, 0,
563 1, 0, 1, 0, 1, 0, 1, 0,
564 0, 0, 0, 0, 0, 0, 0, 0,
565 0, 1, 0, 1, 0, -35332, 1, 0,
566 1, 0, 1, 0, 1, 0, 1, 0,
567 0, 0, 0, 1, 0, -42280, 0, 0,
568 1, 0, 1, 0, 0, 0, 1, 0,
569 1, 0, 1, 0, 1, 0, 1, 0,
570 1, 0, 1, 0, 1, 0, 1, 0,
571 1, 0, -42308, -42319, -42315, -42305, -42308, 0,
572 -42258, -42282, -42261, 928, 1, 0, 1, 0,
573 1, 0, 1, 0, 1, 0, 1, 0,
574 1, 0, 1, 0, -48, -42307, -35384, 1,
575 0, 1, 0, -42343, 1, 0, 1, 0,
576 1, 0, 1, 0, 1, 0, 1, 0,
577 1, 0, 1, 0, -42561, 0, 0, 0,
578 0, 0, 0, 0, 0, 0, 0, 0,
579 0, 0, 0, 0, 0, 0, 0, 0,
580 0, 0, 0, 0, 0, 1, 0, 0,
581 0, 0, 0, 0, 0, 0, 0, 0,
582 0, 0, 0, 0, 0, 0, 0, 0,
583 0, 0, 0, 0, 0, 0, 0, 0,
584 0, 0, 0, 0, 0, 0, 0, 0,
585 0, 0, 0, 0, 0, 0, 0, 0,
586 0, 32, 32, 32, 32, 32, 32, 32,
587 32, 32, 32, 32, 32, 32, 32, 32,
588 32, 32, 32, 32, 32, 32, 32, 32,
589 32, 32, 32, 0, 0, 0, 0, 0,
590 0, 0, 0, 0, 0, 0, 0, 0,
591 0, 0, 0, 0, 0, 0, 0, 0,
592 0, 0, 0, 0, 0, 0, 0, 0,
593 0, 0, 0, 0, 0, 0, 0, 0,
594 0, 0, 0, 0, 0, 0, 0, 0,
595 0, 0, 0, 0, 0, 0, 0, 0,
596 0, 0, 0, 0, 0, 0, 0, 0,
597 0, 0, 0, 0, 0, 0, 0, 0,
598 40, 40, 40, 40, 40, 40, 40, 40,
599 40, 40, 40, 40, 40, 40, 40, 40,
600 40, 40, 40, 40, 40, 40, 40, 40,
601 40, 40, 40, 40, 40, 40, 40, 40,
602 40, 40, 40, 40, 40, 40, 40, 40,
603 0, 0, 0, 0, 0, 0, 0, 0,
604 0, 0, 0, 0, 0, 0, 0, 0,
605 0, 0, 0, 0, 0, 0, 0, 0,
606 0, 0, 0, 0, 0, 0, 0, 0,
607 0, 0, 0, 0, 0, 0, 0, 0,
608 0, 0, 0, 0, 0, 0, 0, 0,
609 0, 0, 0, 0, 0, 0, 0, 0,
610 0, 0, 0, 0, 0, 0, 0, 0,
611 0, 0, 0, 0, 0, 0, 0, 0,
612 0, 0, 0, 0, 0, 0, 0, 0,
613 0, 0, 0, 0, 0, 0, 0, 0,
614 0, 0, 0, 0, 0, 0, 0, 0,
615 0, 0, 0, 0, 0, 0, 0, 0,
616 0, 0, 0, 0, 0, 0, 0, 0,
617 0, 0, 0, 0, 0, 0, 0, 0,
618 0, 0, 0, 0, 0, 0, 0, 0,
619 0, 0, 0, 0, 0, 0, 0, 0,
620 40, 40, 40, 40, 40, 40, 40, 40,
621 40, 40, 40, 40, 40, 40, 40, 40,
622 40, 40, 40, 40, 40, 40, 40, 40,
623 40, 40, 40, 40, 40, 40, 40, 40,
624 40, 40, 40, 40, 0, 0, 0, 0,
625 0, 0, 0, 0, 0, 0, 0, 0,
626 0, 0, 0, 0, 0, 0, 0, 0,
627 0, 0, 0, 0, 0, 0, 0, 0,
628 0, 0, 0, 0, 0, 0, 0, 0,
629 0, 0, 0, 0, 0, 0, 0, 0,
630 0, 0, 0, 0, 0, 0, 0, 0,
631 0, 0, 0, 0, 0, 0, 0, 0,
632 0, 0, 0, 0, 0, 0, 0, 0,
633 0, 0, 0, 0, 0, 0, 0, 0,
634 0, 0, 0, 0, 0, 0, 0, 0,
635 0, 0, 0, 0, 0, 0, 0, 0,
636 0, 0, 0, 0, 0, 0, 0, 0,
637 0, 0, 0, 0, 0, 0, 0, 0,
638 0, 0, 0, 0, 0, 0, 0, 0,
639 0, 0, 0, 0, 0, 0, 0, 0,
640 0, 0, 0, 0, 0, 0, 0, 0,
641 0, 0, 0, 0, 0, 0, 0, 0,
642 0, 0, 0, 0, 0, 0, 0, 0,
643 0, 0, 0, 0, 0, 0, 0, 0,
644 39, 39, 39, 39, 39, 39, 39, 39,
645 39, 39, 39, 0, 39, 39, 39, 39,
646 39, 39, 39, 39, 39, 39, 39, 39,
647 39, 39, 39, 0, 39, 39, 39, 39,
648 39, 39, 39, 0, 39, 39, 0, 0,
649 0, 0, 0, 0, 0, 0, 0, 0,
650 0, 0, 0, 0, 0, 0, 0, 0,
651 0, 0, 0, 0, 0, 0, 0, 0,
652 0, 0, 0, 0, 0, 0, 0, 0,
653 0, 0, 0, 0, 0, 0, 0, 0,
654 0, 0, 0, 0, 0, 0, 0, 0,
655 0, 0, 0, 0, 0, 0, 0, 0,
656 0, 0, 0, 0, 0, 0, 0, 0,
657 0, 0, 0, 0, 0, 0, 0, 0,
658 0, 0, 0, 0, 0, 0, 0, 0,
659 0, 0, 0, 0, 0, 0, 0, 0,
660 0, 0, 0, 0, 0, 0, 0, 0,
661 0, 0, 0, 0, 0, 0, 0, 0,
662 64, 64, 64, 64, 64, 64, 64, 64,
663 64, 64, 64, 64, 64, 64, 64, 64,
664 64, 64, 64, 64, 64, 64, 64, 64,
665 64, 64, 64, 64, 64, 64, 64, 64,
666 64, 64, 64, 64, 64, 64, 64, 64,
667 64, 64, 64, 64, 64, 64, 64, 64,
668 64, 64, 64, 0, 0, 0, 0, 0,
669 0, 0, 0, 0, 0, 0, 0, 0,
670 0, 0, 0, 0, 0, 0, 0, 0,
671 0, 0, 0, 0, 0, 0, 0, 0,
672 0, 0, 0, 0, 0, 0, 0, 0,
673 0, 0, 0, 0, 0, 0, 0, 0,
674 0, 0, 0, 0, 0, 0, 0, 0,
675 0, 0, 0, 0, 0, 0, 0, 0,
676 0, 0, 0, 0, 0, 0, 0, 0,
677 0, 0, 0, 0, 0, 0, 0, 0,
678 0, 0, 0, 0, 0, 0, 0, 0,
679 0, 0, 0, 0, 0, 0, 0, 0,
680 0, 0, 0, 0, 0, 0, 0, 0,
681 0, 0, 0, 0, 0, 0, 0, 0,
682 0, 0, 0, 0, 0, 0, 0, 0,
683 0, 0, 0, 0, 0, 0, 0, 0,
684 0, 0, 0, 0, 0, 0, 0, 0,
685 0, 0, 0, 0, 0, 0, 0, 0,
686 0, 0, 0, 0, 0, 0, 0, 0,
687 0, 0, 0, 0, 0, 0, 0, 0,
688 32, 32, 32, 32, 32, 32, 32, 32,
689 32, 32, 32, 32, 32, 32, 32, 32,
690 32, 32, 32, 32, 32, 32, 0, 0,
691 0, 0, 0, 0, 0, 0, 0, 0,
692 0, 0, 0, 0, 0, 0, 0, 0,
693 0, 0, 0, 0, 0, 0, 0, 0,
694 0, 0, 0, 0, 0, 0, 0, 0,
695 0, 0, 0, 0, 0, 0, 0, 0,
696 0, 0, 0, 0, 0, 0, 0, 0,
697 0, 0, 0, 0, 0, 0, 0, 0,
698 32, 32, 32, 32, 32, 32, 32, 32,
699 32, 32, 32, 32, 32, 32, 32, 32,
700 32, 32, 32, 32, 32, 32, 32, 32,
701 32, 32, 32, 32, 32, 32, 32, 32,
702 0, 0, 0, 0, 0, 0, 0, 0,
703 0, 0, 0, 0, 0, 0, 0, 0,
704 0, 0, 0, 0, 0, 0, 0, 0,
705 0, 0, 0, 0, 0, 0, 0, 0,
706 0, 0, 0, 0, 0, 0, 0, 0,
707 0, 0, 0, 0, 0, 0, 0, 0,
708 0, 0, 0, 0, 0, 0, 0, 0,
709 0, 0, 0, 0, 0, 0, 0, 0,
710 0, 0, 0, 0, 0, 0, 0, 0,
711 0, 0, 0, 0, 0, 0, 0, 0,
712 0, 0, 0, 0, 0, 0, 0, 0,
713 0, 0, 0, 0, 0, 0, 0, 0,
714 0, 0, 0, 0, 0, 0, 0, 0,
715 0, 0, 0, 0, 0, 0, 0, 0,
716 0, 0, 0, 0, 0, 0, 0, 0,
717 0, 0, 0, 0, 0, 0, 0, 0,
718 32, 32, 32, 32, 32, 32, 32, 32,
719 32, 32, 32, 32, 32, 32, 32, 32,
720 32, 32, 32, 32, 32, 32, 32, 32,
721 32, 32, 32, 32, 32, 32, 32, 32,
722 0, 0, 0, 0, 0, 0, 0, 0,
723 0, 0, 0, 0, 0, 0, 0, 0,
724 0, 0, 0, 0, 0, 0, 0, 0,
725 0, 0, 0, 0, 0, 0, 0, 0,
726 0, 0, 0, 0, 0, 0, 0, 0,
727 0, 0, 0, 0, 0, 0, 0, 0,
728 0, 0, 0, 0, 0, 0, 0, 0,
729 0, 0, 0, 0, 0, 0, 0, 0,
730 27, 27, 27, 27, 27, 27, 27, 27,
731 27, 27, 27, 27, 27, 27, 27, 27,
732 27, 27, 27, 27, 27, 27, 27, 27,
733 27, 0, 0, 0, 0, 0, 0, 0,
734 0, 0, 0, 0, 0, 0, 0, 0,
735 0, 0, 0, 0, 0, 0, 0, 0,
736 0, 0, 0, 0, 0, 0, 0, 0,
737 0, 0, 0, 0, 0, 0, 0, 0,
738 0, 0, 0, 0, 0, 0, 0, 0,
739 0, 0, 0, 0, 0, 0, 0, 0,
740 0, 0, 0, 0, 0, 0, 0, 0,
741 0, 0, 0, 0, 0, 0, 0, 0,
742 34, 34, 34, 34, 34, 34, 34, 34,
743 34, 34, 34, 34, 34, 34, 34, 34,
744 34, 34, 34, 34, 34, 34, 34, 34,
745 34, 34, 34, 34, 34, 34, 34, 34,
746 34, 34, 0, 0, 0, 0, 0, 0,
747 0, 0, 0, 0, 0, 0, 0, 0,
748 0, 0, 0, 0, 0, 0, 0, 0,
749 0, 0, 0, 0, 0, 0, 0, 0,
750 0, 0, 0, 0, 0, 0, 0, 0,
751 0, 0, 0, 0, 0, 0, 0, 0,
752 0, 0, 0, 0, 0, 0, 0, 0,
753 0, 0, 0, 0, 0, 0, 0, 0,
754 0, 0, 0, 0, 0, 0, 0, 0,
755 0, 0, 0, 0, 0, 0, 0, 0,
756 0, 0, 0, 0, 0, 0, 0, 0,
757 0, 0, 0, 0, 0, 0, 0, 0
758 }
759};
diff --git a/gl/unictype.in.h b/gl/unictype.in.h
new file mode 100644
index 00000000..c3b9ecaf
--- /dev/null
+++ b/gl/unictype.in.h
@@ -0,0 +1,1147 @@
1/* Unicode character classification and properties.
2 Copyright (C) 2002, 2005-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _UNICTYPE_H
18#define _UNICTYPE_H
19
20#include "unitypes.h"
21
22/* Get bool. */
23#include <stdbool.h>
24
25/* Get size_t. */
26#include <stddef.h>
27
28#if @HAVE_UNISTRING_WOE32DLL_H@
29# include <unistring/woe32dll.h>
30#else
31# define LIBUNISTRING_DLL_VARIABLE
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/* ========================================================================= */
39
40/* Field 1 of Unicode Character Database: Character name.
41 See "uniname.h". */
42
43/* ========================================================================= */
44
45/* Field 2 of Unicode Character Database: General category. */
46
47/* Data type denoting a General category value. This is not just a bitmask,
48 but rather a bitmask and a pointer to the lookup table, so that programs
49 that use only the predefined bitmasks (i.e. don't combine bitmasks with &
50 and |) don't have a link-time dependency towards the big general table. */
51typedef struct
52{
53 uint32_t bitmask : 31;
54 /*bool*/ unsigned int generic : 1;
55 union
56 {
57 const void *table; /* when generic is 0 */
58 bool (*lookup_fn) (ucs4_t uc, uint32_t bitmask); /* when generic is 1 */
59 } lookup;
60}
61uc_general_category_t;
62
63/* Bits and bit masks denoting General category values. UnicodeData-3.2.0.html
64 says a 32-bit integer will always suffice to represent them.
65 These bit masks can only be used with the uc_is_general_category_withtable
66 function. */
67enum
68{
69 UC_CATEGORY_MASK_L = 0x0000001f,
70 UC_CATEGORY_MASK_LC = 0x00000007,
71 UC_CATEGORY_MASK_Lu = 0x00000001,
72 UC_CATEGORY_MASK_Ll = 0x00000002,
73 UC_CATEGORY_MASK_Lt = 0x00000004,
74 UC_CATEGORY_MASK_Lm = 0x00000008,
75 UC_CATEGORY_MASK_Lo = 0x00000010,
76 UC_CATEGORY_MASK_M = 0x000000e0,
77 UC_CATEGORY_MASK_Mn = 0x00000020,
78 UC_CATEGORY_MASK_Mc = 0x00000040,
79 UC_CATEGORY_MASK_Me = 0x00000080,
80 UC_CATEGORY_MASK_N = 0x00000700,
81 UC_CATEGORY_MASK_Nd = 0x00000100,
82 UC_CATEGORY_MASK_Nl = 0x00000200,
83 UC_CATEGORY_MASK_No = 0x00000400,
84 UC_CATEGORY_MASK_P = 0x0003f800,
85 UC_CATEGORY_MASK_Pc = 0x00000800,
86 UC_CATEGORY_MASK_Pd = 0x00001000,
87 UC_CATEGORY_MASK_Ps = 0x00002000,
88 UC_CATEGORY_MASK_Pe = 0x00004000,
89 UC_CATEGORY_MASK_Pi = 0x00008000,
90 UC_CATEGORY_MASK_Pf = 0x00010000,
91 UC_CATEGORY_MASK_Po = 0x00020000,
92 UC_CATEGORY_MASK_S = 0x003c0000,
93 UC_CATEGORY_MASK_Sm = 0x00040000,
94 UC_CATEGORY_MASK_Sc = 0x00080000,
95 UC_CATEGORY_MASK_Sk = 0x00100000,
96 UC_CATEGORY_MASK_So = 0x00200000,
97 UC_CATEGORY_MASK_Z = 0x01c00000,
98 UC_CATEGORY_MASK_Zs = 0x00400000,
99 UC_CATEGORY_MASK_Zl = 0x00800000,
100 UC_CATEGORY_MASK_Zp = 0x01000000,
101 UC_CATEGORY_MASK_C = 0x3e000000,
102 UC_CATEGORY_MASK_Cc = 0x02000000,
103 UC_CATEGORY_MASK_Cf = 0x04000000,
104 UC_CATEGORY_MASK_Cs = 0x08000000,
105 UC_CATEGORY_MASK_Co = 0x10000000,
106 UC_CATEGORY_MASK_Cn = 0x20000000
107};
108
109/* Predefined General category values. */
110extern @GNULIB_UNICTYPE_CATEGORY_L_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_L;
111extern @GNULIB_UNICTYPE_CATEGORY_LC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_LC;
112extern @GNULIB_UNICTYPE_CATEGORY_LU_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lu;
113extern @GNULIB_UNICTYPE_CATEGORY_LL_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Ll;
114extern @GNULIB_UNICTYPE_CATEGORY_LT_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lt;
115extern @GNULIB_UNICTYPE_CATEGORY_LM_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lm;
116extern @GNULIB_UNICTYPE_CATEGORY_LO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Lo;
117extern @GNULIB_UNICTYPE_CATEGORY_M_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_M;
118extern @GNULIB_UNICTYPE_CATEGORY_MN_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Mn;
119extern @GNULIB_UNICTYPE_CATEGORY_MC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Mc;
120extern @GNULIB_UNICTYPE_CATEGORY_ME_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Me;
121extern @GNULIB_UNICTYPE_CATEGORY_N_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_N;
122extern @GNULIB_UNICTYPE_CATEGORY_ND_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Nd;
123extern @GNULIB_UNICTYPE_CATEGORY_NL_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Nl;
124extern @GNULIB_UNICTYPE_CATEGORY_NO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_No;
125extern @GNULIB_UNICTYPE_CATEGORY_P_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_P;
126extern @GNULIB_UNICTYPE_CATEGORY_PC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pc;
127extern @GNULIB_UNICTYPE_CATEGORY_PD_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pd;
128extern @GNULIB_UNICTYPE_CATEGORY_PS_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Ps;
129extern @GNULIB_UNICTYPE_CATEGORY_PE_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pe;
130extern @GNULIB_UNICTYPE_CATEGORY_PI_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pi;
131extern @GNULIB_UNICTYPE_CATEGORY_PF_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Pf;
132extern @GNULIB_UNICTYPE_CATEGORY_PO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Po;
133extern @GNULIB_UNICTYPE_CATEGORY_S_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_S;
134extern @GNULIB_UNICTYPE_CATEGORY_SM_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Sm;
135extern @GNULIB_UNICTYPE_CATEGORY_SC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Sc;
136extern @GNULIB_UNICTYPE_CATEGORY_SK_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Sk;
137extern @GNULIB_UNICTYPE_CATEGORY_SO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_So;
138extern @GNULIB_UNICTYPE_CATEGORY_Z_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Z;
139extern @GNULIB_UNICTYPE_CATEGORY_ZS_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Zs;
140extern @GNULIB_UNICTYPE_CATEGORY_ZL_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Zl;
141extern @GNULIB_UNICTYPE_CATEGORY_ZP_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Zp;
142extern @GNULIB_UNICTYPE_CATEGORY_C_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_C;
143extern @GNULIB_UNICTYPE_CATEGORY_CC_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cc;
144extern @GNULIB_UNICTYPE_CATEGORY_CF_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cf;
145extern @GNULIB_UNICTYPE_CATEGORY_CS_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cs;
146extern @GNULIB_UNICTYPE_CATEGORY_CO_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Co;
147extern @GNULIB_UNICTYPE_CATEGORY_CN_DLL_VARIABLE@ const uc_general_category_t UC_CATEGORY_Cn;
148/* Non-public. */
149extern const uc_general_category_t _UC_CATEGORY_NONE;
150
151/* Alias names for predefined General category values. */
152#define UC_LETTER UC_CATEGORY_L
153#define UC_CASED_LETTER UC_CATEGORY_LC
154#define UC_UPPERCASE_LETTER UC_CATEGORY_Lu
155#define UC_LOWERCASE_LETTER UC_CATEGORY_Ll
156#define UC_TITLECASE_LETTER UC_CATEGORY_Lt
157#define UC_MODIFIER_LETTER UC_CATEGORY_Lm
158#define UC_OTHER_LETTER UC_CATEGORY_Lo
159#define UC_MARK UC_CATEGORY_M
160#define UC_NON_SPACING_MARK UC_CATEGORY_Mn
161#define UC_COMBINING_SPACING_MARK UC_CATEGORY_Mc
162#define UC_ENCLOSING_MARK UC_CATEGORY_Me
163#define UC_NUMBER UC_CATEGORY_N
164#define UC_DECIMAL_DIGIT_NUMBER UC_CATEGORY_Nd
165#define UC_LETTER_NUMBER UC_CATEGORY_Nl
166#define UC_OTHER_NUMBER UC_CATEGORY_No
167#define UC_PUNCTUATION UC_CATEGORY_P
168#define UC_CONNECTOR_PUNCTUATION UC_CATEGORY_Pc
169#define UC_DASH_PUNCTUATION UC_CATEGORY_Pd
170#define UC_OPEN_PUNCTUATION UC_CATEGORY_Ps /* a.k.a. UC_START_PUNCTUATION */
171#define UC_CLOSE_PUNCTUATION UC_CATEGORY_Pe /* a.k.a. UC_END_PUNCTUATION */
172#define UC_INITIAL_QUOTE_PUNCTUATION UC_CATEGORY_Pi
173#define UC_FINAL_QUOTE_PUNCTUATION UC_CATEGORY_Pf
174#define UC_OTHER_PUNCTUATION UC_CATEGORY_Po
175#define UC_SYMBOL UC_CATEGORY_S
176#define UC_MATH_SYMBOL UC_CATEGORY_Sm
177#define UC_CURRENCY_SYMBOL UC_CATEGORY_Sc
178#define UC_MODIFIER_SYMBOL UC_CATEGORY_Sk
179#define UC_OTHER_SYMBOL UC_CATEGORY_So
180#define UC_SEPARATOR UC_CATEGORY_Z
181#define UC_SPACE_SEPARATOR UC_CATEGORY_Zs
182#define UC_LINE_SEPARATOR UC_CATEGORY_Zl
183#define UC_PARAGRAPH_SEPARATOR UC_CATEGORY_Zp
184#define UC_OTHER UC_CATEGORY_C
185#define UC_CONTROL UC_CATEGORY_Cc
186#define UC_FORMAT UC_CATEGORY_Cf
187#define UC_SURROGATE UC_CATEGORY_Cs /* all of them are invalid characters */
188#define UC_PRIVATE_USE UC_CATEGORY_Co
189#define UC_UNASSIGNED UC_CATEGORY_Cn /* some of them are invalid characters */
190
191/* Return the union of two general categories.
192 This corresponds to the unions of the two sets of characters. */
193extern uc_general_category_t
194 uc_general_category_or (uc_general_category_t category1,
195 uc_general_category_t category2);
196
197/* Return the intersection of two general categories as bit masks.
198 This *does*not* correspond to the intersection of the two sets of
199 characters. */
200extern uc_general_category_t
201 uc_general_category_and (uc_general_category_t category1,
202 uc_general_category_t category2);
203
204/* Return the intersection of a general category with the complement of a
205 second general category, as bit masks.
206 This *does*not* correspond to the intersection with complement, when
207 viewing the categories as sets of characters. */
208extern uc_general_category_t
209 uc_general_category_and_not (uc_general_category_t category1,
210 uc_general_category_t category2);
211
212/* Return the name of a general category. */
213extern const char *
214 uc_general_category_name (uc_general_category_t category)
215 _UC_ATTRIBUTE_PURE;
216
217/* Return the long name of a general category. */
218extern const char *
219 uc_general_category_long_name (uc_general_category_t category)
220 _UC_ATTRIBUTE_PURE;
221
222/* Return the general category given by name, e.g. "Lu", or by long name,
223 e.g. "Uppercase Letter". */
224extern uc_general_category_t
225 uc_general_category_byname (const char *category_name)
226 _UC_ATTRIBUTE_PURE;
227
228/* Return the general category of a Unicode character. */
229extern uc_general_category_t
230 uc_general_category (ucs4_t uc)
231 _UC_ATTRIBUTE_PURE;
232
233/* Test whether a Unicode character belongs to a given category.
234 The CATEGORY argument can be the combination of several predefined
235 general categories. */
236extern bool
237 uc_is_general_category (ucs4_t uc, uc_general_category_t category)
238 _UC_ATTRIBUTE_PURE;
239/* Likewise. This function uses a big table comprising all categories. */
240extern bool
241 uc_is_general_category_withtable (ucs4_t uc, uint32_t bitmask)
242 _UC_ATTRIBUTE_CONST;
243
244/* ========================================================================= */
245
246/* Field 3 of Unicode Character Database: Canonical combining class. */
247
248/* The possible results of uc_combining_class (0..255) are described in
249 UCD.html. The list here is not definitive; more values can be added
250 in future versions. */
251enum
252{
253 UC_CCC_NR = 0, /* Not Reordered */
254 UC_CCC_OV = 1, /* Overlay */
255 UC_CCC_NK = 7, /* Nukta */
256 UC_CCC_KV = 8, /* Kana Voicing */
257 UC_CCC_VR = 9, /* Virama */
258 UC_CCC_ATBL = 200, /* Attached Below Left */
259 UC_CCC_ATB = 202, /* Attached Below */
260 UC_CCC_ATA = 214, /* Attached Above */
261 UC_CCC_ATAR = 216, /* Attached Above Right */
262 UC_CCC_BL = 218, /* Below Left */
263 UC_CCC_B = 220, /* Below */
264 UC_CCC_BR = 222, /* Below Right */
265 UC_CCC_L = 224, /* Left */
266 UC_CCC_R = 226, /* Right */
267 UC_CCC_AL = 228, /* Above Left */
268 UC_CCC_A = 230, /* Above */
269 UC_CCC_AR = 232, /* Above Right */
270 UC_CCC_DB = 233, /* Double Below */
271 UC_CCC_DA = 234, /* Double Above */
272 UC_CCC_IS = 240 /* Iota Subscript */
273};
274
275/* Return the canonical combining class of a Unicode character. */
276extern int
277 uc_combining_class (ucs4_t uc)
278 _UC_ATTRIBUTE_CONST;
279
280/* Return the name of a canonical combining class. */
281extern const char *
282 uc_combining_class_name (int ccc)
283 _UC_ATTRIBUTE_CONST;
284
285/* Return the long name of a canonical combining class. */
286extern const char *
287 uc_combining_class_long_name (int ccc)
288 _UC_ATTRIBUTE_CONST;
289
290/* Return the canonical combining class given by name, e.g. "BL", or by long
291 name, e.g. "Below Left". */
292extern int
293 uc_combining_class_byname (const char *ccc_name)
294 _UC_ATTRIBUTE_PURE;
295
296/* ========================================================================= */
297
298/* Field 4 of Unicode Character Database: Bidi class.
299 Before Unicode 4.0, this field was called "Bidirectional category". */
300
301enum
302{
303 UC_BIDI_L, /* Left-to-Right */
304 UC_BIDI_LRE, /* Left-to-Right Embedding */
305 UC_BIDI_LRO, /* Left-to-Right Override */
306 UC_BIDI_R, /* Right-to-Left */
307 UC_BIDI_AL, /* Right-to-Left Arabic */
308 UC_BIDI_RLE, /* Right-to-Left Embedding */
309 UC_BIDI_RLO, /* Right-to-Left Override */
310 UC_BIDI_PDF, /* Pop Directional Format */
311 UC_BIDI_EN, /* European Number */
312 UC_BIDI_ES, /* European Number Separator */
313 UC_BIDI_ET, /* European Number Terminator */
314 UC_BIDI_AN, /* Arabic Number */
315 UC_BIDI_CS, /* Common Number Separator */
316 UC_BIDI_NSM, /* Non-Spacing Mark */
317 UC_BIDI_BN, /* Boundary Neutral */
318 UC_BIDI_B, /* Paragraph Separator */
319 UC_BIDI_S, /* Segment Separator */
320 UC_BIDI_WS, /* Whitespace */
321 UC_BIDI_ON, /* Other Neutral */
322 UC_BIDI_LRI, /* Left-to-Right Isolate */
323 UC_BIDI_RLI, /* Right-to-Left Isolate */
324 UC_BIDI_FSI, /* First Strong Isolate */
325 UC_BIDI_PDI /* Pop Directional Isolate */
326};
327
328/* Return the name of a bidi class. */
329extern const char *
330 uc_bidi_class_name (int bidi_class)
331 _UC_ATTRIBUTE_CONST;
332/* Same; obsolete function name. */
333extern const char *
334 uc_bidi_category_name (int category)
335 _UC_ATTRIBUTE_CONST;
336
337/* Return the long name of a bidi class. */
338extern const char *
339 uc_bidi_class_long_name (int bidi_class)
340 _UC_ATTRIBUTE_CONST;
341
342/* Return the bidi class given by name, e.g. "LRE", or by long name, e.g.
343 "Left-to-Right Embedding". */
344extern int
345 uc_bidi_class_byname (const char *bidi_class_name)
346 _UC_ATTRIBUTE_PURE;
347/* Same; obsolete function name. */
348extern int
349 uc_bidi_category_byname (const char *category_name)
350 _UC_ATTRIBUTE_PURE;
351
352/* Return the bidi class of a Unicode character. */
353extern int
354 uc_bidi_class (ucs4_t uc)
355 _UC_ATTRIBUTE_CONST;
356/* Same; obsolete function name. */
357extern int
358 uc_bidi_category (ucs4_t uc)
359 _UC_ATTRIBUTE_CONST;
360
361/* Test whether a Unicode character belongs to a given bidi class. */
362extern bool
363 uc_is_bidi_class (ucs4_t uc, int bidi_class)
364 _UC_ATTRIBUTE_CONST;
365/* Same; obsolete function name. */
366extern bool
367 uc_is_bidi_category (ucs4_t uc, int category)
368 _UC_ATTRIBUTE_CONST;
369
370/* ========================================================================= */
371
372/* Field 5 of Unicode Character Database: Character decomposition mapping.
373 See "uninorm.h". */
374
375/* ========================================================================= */
376
377/* Field 6 of Unicode Character Database: Decimal digit value. */
378
379/* Return the decimal digit value of a Unicode character. */
380extern int
381 uc_decimal_value (ucs4_t uc)
382 _UC_ATTRIBUTE_CONST;
383
384/* ========================================================================= */
385
386/* Field 7 of Unicode Character Database: Digit value. */
387
388/* Return the digit value of a Unicode character. */
389extern int
390 uc_digit_value (ucs4_t uc)
391 _UC_ATTRIBUTE_CONST;
392
393/* ========================================================================= */
394
395/* Field 8 of Unicode Character Database: Numeric value. */
396
397/* Return the numeric value of a Unicode character. */
398typedef struct
399{
400 int numerator;
401 int denominator;
402}
403uc_fraction_t;
404extern uc_fraction_t
405 uc_numeric_value (ucs4_t uc)
406 _UC_ATTRIBUTE_CONST;
407
408/* ========================================================================= */
409
410/* Field 9 of Unicode Character Database: Mirrored. */
411
412/* Return the mirrored character of a Unicode character UC in *PUC. */
413extern bool
414 uc_mirror_char (ucs4_t uc, ucs4_t *puc);
415
416/* ========================================================================= */
417
418/* Field 10 of Unicode Character Database: Unicode 1.0 Name.
419 Not available in this library. */
420
421/* ========================================================================= */
422
423/* Field 11 of Unicode Character Database: ISO 10646 comment.
424 Not available in this library. */
425
426/* ========================================================================= */
427
428/* Field 12, 13, 14 of Unicode Character Database: Uppercase mapping,
429 lowercase mapping, titlecase mapping. See "unicase.h". */
430
431/* ========================================================================= */
432
433/* Field 2 of the file ArabicShaping.txt in the Unicode Character Database. */
434
435/* Possible joining types. */
436enum
437{
438 UC_JOINING_TYPE_U, /* Non_Joining */
439 UC_JOINING_TYPE_T, /* Transparent */
440 UC_JOINING_TYPE_C, /* Join_Causing */
441 UC_JOINING_TYPE_L, /* Left_Joining */
442 UC_JOINING_TYPE_R, /* Right_Joining */
443 UC_JOINING_TYPE_D /* Dual_Joining */
444};
445
446/* Return the name of a joining type. */
447extern const char *
448 uc_joining_type_name (int joining_type)
449 _UC_ATTRIBUTE_CONST;
450
451/* Return the long name of a joining type. */
452extern const char *
453 uc_joining_type_long_name (int joining_type)
454 _UC_ATTRIBUTE_CONST;
455
456/* Return the joining type given by name, e.g. "D", or by long name, e.g.
457 "Dual Joining". */
458extern int
459 uc_joining_type_byname (const char *joining_type_name)
460 _UC_ATTRIBUTE_PURE;
461
462/* Return the joining type of a Unicode character. */
463extern int
464 uc_joining_type (ucs4_t uc)
465 _UC_ATTRIBUTE_CONST;
466
467/* ========================================================================= */
468
469/* Field 3 of the file ArabicShaping.txt in the Unicode Character Database. */
470
471/* Possible joining groups.
472 This enumeration may be extended in the future. */
473enum
474{
475 UC_JOINING_GROUP_NONE, /* No_Joining_Group */
476 UC_JOINING_GROUP_AIN, /* Ain */
477 UC_JOINING_GROUP_ALAPH, /* Alaph */
478 UC_JOINING_GROUP_ALEF, /* Alef */
479 UC_JOINING_GROUP_BEH, /* Beh */
480 UC_JOINING_GROUP_BETH, /* Beth */
481 UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, /* Burushaski_Yeh_Barree */
482 UC_JOINING_GROUP_DAL, /* Dal */
483 UC_JOINING_GROUP_DALATH_RISH, /* Dalath_Rish */
484 UC_JOINING_GROUP_E, /* E */
485 UC_JOINING_GROUP_FARSI_YEH, /* Farsi_Yeh */
486 UC_JOINING_GROUP_FE, /* Fe */
487 UC_JOINING_GROUP_FEH, /* Feh */
488 UC_JOINING_GROUP_FINAL_SEMKATH, /* Final_Semkath */
489 UC_JOINING_GROUP_GAF, /* Gaf */
490 UC_JOINING_GROUP_GAMAL, /* Gamal */
491 UC_JOINING_GROUP_HAH, /* Hah */
492 UC_JOINING_GROUP_HE, /* He */
493 UC_JOINING_GROUP_HEH, /* Heh */
494 UC_JOINING_GROUP_HEH_GOAL, /* Heh_Goal */
495 UC_JOINING_GROUP_HETH, /* Heth */
496 UC_JOINING_GROUP_KAF, /* Kaf */
497 UC_JOINING_GROUP_KAPH, /* Kaph */
498 UC_JOINING_GROUP_KHAPH, /* Khaph */
499 UC_JOINING_GROUP_KNOTTED_HEH, /* Knotted_Heh */
500 UC_JOINING_GROUP_LAM, /* Lam */
501 UC_JOINING_GROUP_LAMADH, /* Lamadh */
502 UC_JOINING_GROUP_MEEM, /* Meem */
503 UC_JOINING_GROUP_MIM, /* Mim */
504 UC_JOINING_GROUP_NOON, /* Noon */
505 UC_JOINING_GROUP_NUN, /* Nun */
506 UC_JOINING_GROUP_NYA, /* Nya */
507 UC_JOINING_GROUP_PE, /* Pe */
508 UC_JOINING_GROUP_QAF, /* Qaf */
509 UC_JOINING_GROUP_QAPH, /* Qaph */
510 UC_JOINING_GROUP_REH, /* Reh */
511 UC_JOINING_GROUP_REVERSED_PE, /* Reversed_Pe */
512 UC_JOINING_GROUP_SAD, /* Sad */
513 UC_JOINING_GROUP_SADHE, /* Sadhe */
514 UC_JOINING_GROUP_SEEN, /* Seen */
515 UC_JOINING_GROUP_SEMKATH, /* Semkath */
516 UC_JOINING_GROUP_SHIN, /* Shin */
517 UC_JOINING_GROUP_SWASH_KAF, /* Swash_Kaf */
518 UC_JOINING_GROUP_SYRIAC_WAW, /* Syriac_Waw */
519 UC_JOINING_GROUP_TAH, /* Tah */
520 UC_JOINING_GROUP_TAW, /* Taw */
521 UC_JOINING_GROUP_TEH_MARBUTA, /* Teh_Marbuta */
522 UC_JOINING_GROUP_TEH_MARBUTA_GOAL, /* Teh_Marbuta_Goal */
523 UC_JOINING_GROUP_TETH, /* Teth */
524 UC_JOINING_GROUP_WAW, /* Waw */
525 UC_JOINING_GROUP_YEH, /* Yeh */
526 UC_JOINING_GROUP_YEH_BARREE, /* Yeh_Barree */
527 UC_JOINING_GROUP_YEH_WITH_TAIL, /* Yeh_With_Tail */
528 UC_JOINING_GROUP_YUDH, /* Yudh */
529 UC_JOINING_GROUP_YUDH_HE, /* Yudh_He */
530 UC_JOINING_GROUP_ZAIN, /* Zain */
531 UC_JOINING_GROUP_ZHAIN, /* Zhain */
532 UC_JOINING_GROUP_ROHINGYA_YEH, /* Rohingya_Yeh */
533 UC_JOINING_GROUP_STRAIGHT_WAW, /* Straight_Waw */
534 UC_JOINING_GROUP_MANICHAEAN_ALEPH, /* Manichaean_Aleph */
535 UC_JOINING_GROUP_MANICHAEAN_BETH, /* Manichaean_Beth */
536 UC_JOINING_GROUP_MANICHAEAN_GIMEL, /* Manichaean_Gimel */
537 UC_JOINING_GROUP_MANICHAEAN_DALETH, /* Manichaean_Daleth */
538 UC_JOINING_GROUP_MANICHAEAN_WAW, /* Manichaean_Waw */
539 UC_JOINING_GROUP_MANICHAEAN_ZAYIN, /* Manichaean_Zayin */
540 UC_JOINING_GROUP_MANICHAEAN_HETH, /* Manichaean_Heth */
541 UC_JOINING_GROUP_MANICHAEAN_TETH, /* Manichaean_Teth */
542 UC_JOINING_GROUP_MANICHAEAN_YODH, /* Manichaean_Yodh */
543 UC_JOINING_GROUP_MANICHAEAN_KAPH, /* Manichaean_Kaph */
544 UC_JOINING_GROUP_MANICHAEAN_LAMEDH, /* Manichaean_Lamedh */
545 UC_JOINING_GROUP_MANICHAEAN_DHAMEDH, /* Manichaean_Dhamedh */
546 UC_JOINING_GROUP_MANICHAEAN_THAMEDH, /* Manichaean_Thamedh */
547 UC_JOINING_GROUP_MANICHAEAN_MEM, /* Manichaean_Mem */
548 UC_JOINING_GROUP_MANICHAEAN_NUN, /* Manichaean_Nun */
549 UC_JOINING_GROUP_MANICHAEAN_SAMEKH, /* Manichaean_Aleph */
550 UC_JOINING_GROUP_MANICHAEAN_AYIN, /* Manichaean_Ayin */
551 UC_JOINING_GROUP_MANICHAEAN_PE, /* Manichaean_Pe */
552 UC_JOINING_GROUP_MANICHAEAN_SADHE, /* Manichaean_Sadhe */
553 UC_JOINING_GROUP_MANICHAEAN_QOPH, /* Manichaean_Qoph */
554 UC_JOINING_GROUP_MANICHAEAN_RESH, /* Manichaean_Resh */
555 UC_JOINING_GROUP_MANICHAEAN_TAW, /* Manichaean_Taw */
556 UC_JOINING_GROUP_MANICHAEAN_ONE, /* Manichaean_One */
557 UC_JOINING_GROUP_MANICHAEAN_FIVE, /* Manichaean_Five */
558 UC_JOINING_GROUP_MANICHAEAN_TEN, /* Manichaean_Ten */
559 UC_JOINING_GROUP_MANICHAEAN_TWENTY, /* Manichaean_Twenty */
560 UC_JOINING_GROUP_MANICHAEAN_HUNDRED, /* Manichaean_Hundred */
561 UC_JOINING_GROUP_AFRICAN_FEH, /* African_Feh */
562 UC_JOINING_GROUP_AFRICAN_QAF, /* African_Qaf */
563 UC_JOINING_GROUP_AFRICAN_NOON, /* African_Noon */
564 UC_JOINING_GROUP_MALAYALAM_NGA, /* Malayalam_Nga */
565 UC_JOINING_GROUP_MALAYALAM_JA, /* Malayalam_Ja */
566 UC_JOINING_GROUP_MALAYALAM_NYA, /* Malayalam_Nya */
567 UC_JOINING_GROUP_MALAYALAM_TTA, /* Malayalam_Tta */
568 UC_JOINING_GROUP_MALAYALAM_NNA, /* Malayalam_Nna */
569 UC_JOINING_GROUP_MALAYALAM_NNNA, /* Malayalam_Nnna */
570 UC_JOINING_GROUP_MALAYALAM_BHA, /* Malayalam_Bha */
571 UC_JOINING_GROUP_MALAYALAM_RA, /* Malayalam_Ra */
572 UC_JOINING_GROUP_MALAYALAM_LLA, /* Malayalam_Lla */
573 UC_JOINING_GROUP_MALAYALAM_LLLA, /* Malayalam_Llla */
574 UC_JOINING_GROUP_MALAYALAM_SSA, /* Malayalam_Ssa */
575 UC_JOINING_GROUP_HANIFI_ROHINGYA_PA, /* Hanifi_Rohingya_Pa */
576 UC_JOINING_GROUP_HANIFI_ROHINGYA_KINNA_YA, /* Hanifi_Rohingya_Kinna_Ya */
577 UC_JOINING_GROUP_THIN_YEH, /* Thin_Yeh */
578 UC_JOINING_GROUP_VERTICAL_TAIL, /* Vertical_Tail */
579 UC_JOINING_GROUP_KASHMIRI_YEH, /* Kashmiri_Yeh */
580 UC_JOINING_GROUP_THIN_NOON /* Thin_Noon */
581};
582
583/* Return the name of a joining group. */
584extern const char *
585 uc_joining_group_name (int joining_group)
586 _UC_ATTRIBUTE_CONST;
587
588/* Return the joining group given by name, e.g. "Teh_Marbuta". */
589extern int
590 uc_joining_group_byname (const char *joining_group_name)
591 _UC_ATTRIBUTE_PURE;
592
593/* Return the joining group of a Unicode character. */
594extern int
595 uc_joining_group (ucs4_t uc)
596 _UC_ATTRIBUTE_CONST;
597
598/* ========================================================================= */
599
600/* Common API for properties. */
601
602/* Data type denoting a property. This is not just a number, but rather a
603 pointer to the test functions, so that programs that use only few of the
604 properties don't have a link-time dependency towards all the tables. */
605typedef struct
606{
607 bool (*test_fn) (ucs4_t uc);
608}
609uc_property_t;
610
611/* Predefined properties. */
612/* General. */
613extern @GNULIB_UNICTYPE_PROPERTY_WHITE_SPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_WHITE_SPACE;
614extern @GNULIB_UNICTYPE_PROPERTY_ALPHABETIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ALPHABETIC;
615extern @GNULIB_UNICTYPE_PROPERTY_OTHER_ALPHABETIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_ALPHABETIC;
616extern @GNULIB_UNICTYPE_PROPERTY_NOT_A_CHARACTER_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_NOT_A_CHARACTER;
617extern @GNULIB_UNICTYPE_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT;
618extern @GNULIB_UNICTYPE_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT;
619extern @GNULIB_UNICTYPE_PROPERTY_DEPRECATED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DEPRECATED;
620extern @GNULIB_UNICTYPE_PROPERTY_LOGICAL_ORDER_EXCEPTION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LOGICAL_ORDER_EXCEPTION;
621extern @GNULIB_UNICTYPE_PROPERTY_VARIATION_SELECTOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_VARIATION_SELECTOR;
622extern @GNULIB_UNICTYPE_PROPERTY_PRIVATE_USE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PRIVATE_USE;
623extern @GNULIB_UNICTYPE_PROPERTY_UNASSIGNED_CODE_VALUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_UNASSIGNED_CODE_VALUE;
624/* Case. */
625extern @GNULIB_UNICTYPE_PROPERTY_UPPERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_UPPERCASE;
626extern @GNULIB_UNICTYPE_PROPERTY_OTHER_UPPERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_UPPERCASE;
627extern @GNULIB_UNICTYPE_PROPERTY_LOWERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LOWERCASE;
628extern @GNULIB_UNICTYPE_PROPERTY_OTHER_LOWERCASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_LOWERCASE;
629extern @GNULIB_UNICTYPE_PROPERTY_TITLECASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_TITLECASE;
630extern @GNULIB_UNICTYPE_PROPERTY_CASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CASED;
631extern @GNULIB_UNICTYPE_PROPERTY_CASE_IGNORABLE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CASE_IGNORABLE;
632extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_LOWERCASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_LOWERCASED;
633extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_UPPERCASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_UPPERCASED;
634extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_TITLECASED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_TITLECASED;
635extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEFOLDED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_CASEFOLDED;
636extern @GNULIB_UNICTYPE_PROPERTY_CHANGES_WHEN_CASEMAPPED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CHANGES_WHEN_CASEMAPPED;
637extern @GNULIB_UNICTYPE_PROPERTY_SOFT_DOTTED_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_SOFT_DOTTED;
638/* Identifiers. */
639extern @GNULIB_UNICTYPE_PROPERTY_ID_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ID_START;
640extern @GNULIB_UNICTYPE_PROPERTY_OTHER_ID_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_ID_START;
641extern @GNULIB_UNICTYPE_PROPERTY_ID_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ID_CONTINUE;
642extern @GNULIB_UNICTYPE_PROPERTY_OTHER_ID_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_ID_CONTINUE;
643extern @GNULIB_UNICTYPE_PROPERTY_XID_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_XID_START;
644extern @GNULIB_UNICTYPE_PROPERTY_XID_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_XID_CONTINUE;
645extern @GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_START_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ID_COMPAT_MATH_START;
646extern @GNULIB_UNICTYPE_PROPERTY_ID_COMPAT_MATH_CONTINUE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ID_COMPAT_MATH_CONTINUE;
647extern @GNULIB_UNICTYPE_PROPERTY_PATTERN_WHITE_SPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PATTERN_WHITE_SPACE;
648extern @GNULIB_UNICTYPE_PROPERTY_PATTERN_SYNTAX_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PATTERN_SYNTAX;
649/* Shaping and rendering. */
650extern @GNULIB_UNICTYPE_PROPERTY_JOIN_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_JOIN_CONTROL;
651extern @GNULIB_UNICTYPE_PROPERTY_GRAPHEME_BASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_GRAPHEME_BASE;
652extern @GNULIB_UNICTYPE_PROPERTY_GRAPHEME_EXTEND_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_GRAPHEME_EXTEND;
653extern @GNULIB_UNICTYPE_PROPERTY_OTHER_GRAPHEME_EXTEND_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_GRAPHEME_EXTEND;
654extern @GNULIB_UNICTYPE_PROPERTY_GRAPHEME_LINK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_GRAPHEME_LINK;
655extern @GNULIB_UNICTYPE_PROPERTY_MODIFIER_COMBINING_MARK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_MODIFIER_COMBINING_MARK;
656/* Bidi. */
657extern @GNULIB_UNICTYPE_PROPERTY_BIDI_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_CONTROL;
658extern @GNULIB_UNICTYPE_PROPERTY_BIDI_LEFT_TO_RIGHT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_LEFT_TO_RIGHT;
659extern @GNULIB_UNICTYPE_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT;
660extern @GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT;
661extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EUROPEAN_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EUROPEAN_DIGIT;
662extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EUR_NUM_SEPARATOR;
663extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EUR_NUM_TERMINATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EUR_NUM_TERMINATOR;
664extern @GNULIB_UNICTYPE_PROPERTY_BIDI_ARABIC_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_ARABIC_DIGIT;
665extern @GNULIB_UNICTYPE_PROPERTY_BIDI_COMMON_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_COMMON_SEPARATOR;
666extern @GNULIB_UNICTYPE_PROPERTY_BIDI_BLOCK_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_BLOCK_SEPARATOR;
667extern @GNULIB_UNICTYPE_PROPERTY_BIDI_SEGMENT_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_SEGMENT_SEPARATOR;
668extern @GNULIB_UNICTYPE_PROPERTY_BIDI_WHITESPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_WHITESPACE;
669extern @GNULIB_UNICTYPE_PROPERTY_BIDI_NON_SPACING_MARK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_NON_SPACING_MARK;
670extern @GNULIB_UNICTYPE_PROPERTY_BIDI_BOUNDARY_NEUTRAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_BOUNDARY_NEUTRAL;
671extern @GNULIB_UNICTYPE_PROPERTY_BIDI_PDF_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_PDF;
672extern @GNULIB_UNICTYPE_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE;
673extern @GNULIB_UNICTYPE_PROPERTY_BIDI_OTHER_NEUTRAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_BIDI_OTHER_NEUTRAL;
674/* Numeric. */
675extern @GNULIB_UNICTYPE_PROPERTY_HEX_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_HEX_DIGIT;
676extern @GNULIB_UNICTYPE_PROPERTY_ASCII_HEX_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ASCII_HEX_DIGIT;
677/* CJK. */
678extern @GNULIB_UNICTYPE_PROPERTY_IDEOGRAPHIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDEOGRAPHIC;
679extern @GNULIB_UNICTYPE_PROPERTY_UNIFIED_IDEOGRAPH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_UNIFIED_IDEOGRAPH;
680extern @GNULIB_UNICTYPE_PROPERTY_RADICAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_RADICAL;
681extern @GNULIB_UNICTYPE_PROPERTY_IDS_UNARY_OPERATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDS_UNARY_OPERATOR;
682extern @GNULIB_UNICTYPE_PROPERTY_IDS_BINARY_OPERATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDS_BINARY_OPERATOR;
683extern @GNULIB_UNICTYPE_PROPERTY_IDS_TRINARY_OPERATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IDS_TRINARY_OPERATOR;
684/* Emoji. */
685extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI;
686extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_PRESENTATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_PRESENTATION;
687extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_MODIFIER;
688extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_MODIFIER_BASE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_MODIFIER_BASE;
689extern @GNULIB_UNICTYPE_PROPERTY_EMOJI_COMPONENT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EMOJI_COMPONENT;
690extern @GNULIB_UNICTYPE_PROPERTY_EXTENDED_PICTOGRAPHIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EXTENDED_PICTOGRAPHIC;
691/* Misc. */
692extern @GNULIB_UNICTYPE_PROPERTY_ZERO_WIDTH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ZERO_WIDTH;
693extern @GNULIB_UNICTYPE_PROPERTY_SPACE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_SPACE;
694extern @GNULIB_UNICTYPE_PROPERTY_NON_BREAK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_NON_BREAK;
695extern @GNULIB_UNICTYPE_PROPERTY_ISO_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_ISO_CONTROL;
696extern @GNULIB_UNICTYPE_PROPERTY_FORMAT_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_FORMAT_CONTROL;
697extern @GNULIB_UNICTYPE_PROPERTY_PREPENDED_CONCATENATION_MARK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PREPENDED_CONCATENATION_MARK;
698extern @GNULIB_UNICTYPE_PROPERTY_DASH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DASH;
699extern @GNULIB_UNICTYPE_PROPERTY_HYPHEN_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_HYPHEN;
700extern @GNULIB_UNICTYPE_PROPERTY_PUNCTUATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PUNCTUATION;
701extern @GNULIB_UNICTYPE_PROPERTY_LINE_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LINE_SEPARATOR;
702extern @GNULIB_UNICTYPE_PROPERTY_PARAGRAPH_SEPARATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PARAGRAPH_SEPARATOR;
703extern @GNULIB_UNICTYPE_PROPERTY_QUOTATION_MARK_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_QUOTATION_MARK;
704extern @GNULIB_UNICTYPE_PROPERTY_SENTENCE_TERMINAL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_SENTENCE_TERMINAL;
705extern @GNULIB_UNICTYPE_PROPERTY_TERMINAL_PUNCTUATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_TERMINAL_PUNCTUATION;
706extern @GNULIB_UNICTYPE_PROPERTY_CURRENCY_SYMBOL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_CURRENCY_SYMBOL;
707extern @GNULIB_UNICTYPE_PROPERTY_MATH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_MATH;
708extern @GNULIB_UNICTYPE_PROPERTY_OTHER_MATH_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_OTHER_MATH;
709extern @GNULIB_UNICTYPE_PROPERTY_PAIRED_PUNCTUATION_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_PAIRED_PUNCTUATION;
710extern @GNULIB_UNICTYPE_PROPERTY_LEFT_OF_PAIR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_LEFT_OF_PAIR;
711extern @GNULIB_UNICTYPE_PROPERTY_COMBINING_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_COMBINING;
712extern @GNULIB_UNICTYPE_PROPERTY_COMPOSITE_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_COMPOSITE;
713extern @GNULIB_UNICTYPE_PROPERTY_DECIMAL_DIGIT_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DECIMAL_DIGIT;
714extern @GNULIB_UNICTYPE_PROPERTY_NUMERIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_NUMERIC;
715extern @GNULIB_UNICTYPE_PROPERTY_DIACRITIC_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_DIACRITIC;
716extern @GNULIB_UNICTYPE_PROPERTY_EXTENDER_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_EXTENDER;
717extern @GNULIB_UNICTYPE_PROPERTY_IGNORABLE_CONTROL_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_IGNORABLE_CONTROL;
718extern @GNULIB_UNICTYPE_PROPERTY_REGIONAL_INDICATOR_DLL_VARIABLE@ const uc_property_t UC_PROPERTY_REGIONAL_INDICATOR;
719
720/* Return the property given by name, e.g. "White space". */
721extern uc_property_t
722 uc_property_byname (const char *property_name);
723
724/* Test whether a property is valid. */
725#define uc_property_is_valid(property) ((property).test_fn != NULL)
726
727/* Test whether a Unicode character has a given property. */
728extern bool
729 uc_is_property (ucs4_t uc, uc_property_t property);
730extern bool uc_is_property_white_space (ucs4_t uc)
731 _UC_ATTRIBUTE_CONST;
732extern bool uc_is_property_alphabetic (ucs4_t uc)
733 _UC_ATTRIBUTE_CONST;
734extern bool uc_is_property_other_alphabetic (ucs4_t uc)
735 _UC_ATTRIBUTE_CONST;
736extern bool uc_is_property_not_a_character (ucs4_t uc)
737 _UC_ATTRIBUTE_CONST;
738extern bool uc_is_property_default_ignorable_code_point (ucs4_t uc)
739 _UC_ATTRIBUTE_CONST;
740extern bool uc_is_property_other_default_ignorable_code_point (ucs4_t uc)
741 _UC_ATTRIBUTE_CONST;
742extern bool uc_is_property_deprecated (ucs4_t uc)
743 _UC_ATTRIBUTE_CONST;
744extern bool uc_is_property_logical_order_exception (ucs4_t uc)
745 _UC_ATTRIBUTE_CONST;
746extern bool uc_is_property_variation_selector (ucs4_t uc)
747 _UC_ATTRIBUTE_CONST;
748extern bool uc_is_property_private_use (ucs4_t uc)
749 _UC_ATTRIBUTE_CONST;
750extern bool uc_is_property_unassigned_code_value (ucs4_t uc)
751 _UC_ATTRIBUTE_CONST;
752extern bool uc_is_property_uppercase (ucs4_t uc)
753 _UC_ATTRIBUTE_CONST;
754extern bool uc_is_property_other_uppercase (ucs4_t uc)
755 _UC_ATTRIBUTE_CONST;
756extern bool uc_is_property_lowercase (ucs4_t uc)
757 _UC_ATTRIBUTE_CONST;
758extern bool uc_is_property_other_lowercase (ucs4_t uc)
759 _UC_ATTRIBUTE_CONST;
760extern bool uc_is_property_titlecase (ucs4_t uc)
761 _UC_ATTRIBUTE_CONST;
762extern bool uc_is_property_cased (ucs4_t uc)
763 _UC_ATTRIBUTE_CONST;
764extern bool uc_is_property_case_ignorable (ucs4_t uc)
765 _UC_ATTRIBUTE_CONST;
766extern bool uc_is_property_changes_when_lowercased (ucs4_t uc)
767 _UC_ATTRIBUTE_CONST;
768extern bool uc_is_property_changes_when_uppercased (ucs4_t uc)
769 _UC_ATTRIBUTE_CONST;
770extern bool uc_is_property_changes_when_titlecased (ucs4_t uc)
771 _UC_ATTRIBUTE_CONST;
772extern bool uc_is_property_changes_when_casefolded (ucs4_t uc)
773 _UC_ATTRIBUTE_CONST;
774extern bool uc_is_property_changes_when_casemapped (ucs4_t uc)
775 _UC_ATTRIBUTE_CONST;
776extern bool uc_is_property_soft_dotted (ucs4_t uc)
777 _UC_ATTRIBUTE_CONST;
778extern bool uc_is_property_id_start (ucs4_t uc)
779 _UC_ATTRIBUTE_CONST;
780extern bool uc_is_property_other_id_start (ucs4_t uc)
781 _UC_ATTRIBUTE_CONST;
782extern bool uc_is_property_id_continue (ucs4_t uc)
783 _UC_ATTRIBUTE_CONST;
784extern bool uc_is_property_other_id_continue (ucs4_t uc)
785 _UC_ATTRIBUTE_CONST;
786extern bool uc_is_property_xid_start (ucs4_t uc)
787 _UC_ATTRIBUTE_CONST;
788extern bool uc_is_property_xid_continue (ucs4_t uc)
789 _UC_ATTRIBUTE_CONST;
790extern bool uc_is_property_id_compat_math_start (ucs4_t uc)
791 _UC_ATTRIBUTE_CONST;
792extern bool uc_is_property_id_compat_math_continue (ucs4_t uc)
793 _UC_ATTRIBUTE_CONST;
794extern bool uc_is_property_pattern_white_space (ucs4_t uc)
795 _UC_ATTRIBUTE_CONST;
796extern bool uc_is_property_pattern_syntax (ucs4_t uc)
797 _UC_ATTRIBUTE_CONST;
798extern bool uc_is_property_join_control (ucs4_t uc)
799 _UC_ATTRIBUTE_CONST;
800extern bool uc_is_property_grapheme_base (ucs4_t uc)
801 _UC_ATTRIBUTE_CONST;
802extern bool uc_is_property_grapheme_extend (ucs4_t uc)
803 _UC_ATTRIBUTE_CONST;
804extern bool uc_is_property_other_grapheme_extend (ucs4_t uc)
805 _UC_ATTRIBUTE_CONST;
806extern bool uc_is_property_grapheme_link (ucs4_t uc)
807 _UC_ATTRIBUTE_CONST;
808extern bool uc_is_property_modifier_combining_mark (ucs4_t uc)
809 _UC_ATTRIBUTE_CONST;
810extern bool uc_is_property_bidi_control (ucs4_t uc)
811 _UC_ATTRIBUTE_CONST;
812extern bool uc_is_property_bidi_left_to_right (ucs4_t uc)
813 _UC_ATTRIBUTE_CONST;
814extern bool uc_is_property_bidi_hebrew_right_to_left (ucs4_t uc)
815 _UC_ATTRIBUTE_CONST;
816extern bool uc_is_property_bidi_arabic_right_to_left (ucs4_t uc)
817 _UC_ATTRIBUTE_CONST;
818extern bool uc_is_property_bidi_european_digit (ucs4_t uc)
819 _UC_ATTRIBUTE_CONST;
820extern bool uc_is_property_bidi_eur_num_separator (ucs4_t uc)
821 _UC_ATTRIBUTE_CONST;
822extern bool uc_is_property_bidi_eur_num_terminator (ucs4_t uc)
823 _UC_ATTRIBUTE_CONST;
824extern bool uc_is_property_bidi_arabic_digit (ucs4_t uc)
825 _UC_ATTRIBUTE_CONST;
826extern bool uc_is_property_bidi_common_separator (ucs4_t uc)
827 _UC_ATTRIBUTE_CONST;
828extern bool uc_is_property_bidi_block_separator (ucs4_t uc)
829 _UC_ATTRIBUTE_CONST;
830extern bool uc_is_property_bidi_segment_separator (ucs4_t uc)
831 _UC_ATTRIBUTE_CONST;
832extern bool uc_is_property_bidi_whitespace (ucs4_t uc)
833 _UC_ATTRIBUTE_CONST;
834extern bool uc_is_property_bidi_non_spacing_mark (ucs4_t uc)
835 _UC_ATTRIBUTE_CONST;
836extern bool uc_is_property_bidi_boundary_neutral (ucs4_t uc)
837 _UC_ATTRIBUTE_CONST;
838extern bool uc_is_property_bidi_pdf (ucs4_t uc)
839 _UC_ATTRIBUTE_CONST;
840extern bool uc_is_property_bidi_embedding_or_override (ucs4_t uc)
841 _UC_ATTRIBUTE_CONST;
842extern bool uc_is_property_bidi_other_neutral (ucs4_t uc)
843 _UC_ATTRIBUTE_CONST;
844extern bool uc_is_property_hex_digit (ucs4_t uc)
845 _UC_ATTRIBUTE_CONST;
846extern bool uc_is_property_ascii_hex_digit (ucs4_t uc)
847 _UC_ATTRIBUTE_CONST;
848extern bool uc_is_property_ideographic (ucs4_t uc)
849 _UC_ATTRIBUTE_CONST;
850extern bool uc_is_property_unified_ideograph (ucs4_t uc)
851 _UC_ATTRIBUTE_CONST;
852extern bool uc_is_property_radical (ucs4_t uc)
853 _UC_ATTRIBUTE_CONST;
854extern bool uc_is_property_ids_unary_operator (ucs4_t uc)
855 _UC_ATTRIBUTE_CONST;
856extern bool uc_is_property_ids_binary_operator (ucs4_t uc)
857 _UC_ATTRIBUTE_CONST;
858extern bool uc_is_property_ids_trinary_operator (ucs4_t uc)
859 _UC_ATTRIBUTE_CONST;
860extern bool uc_is_property_emoji (ucs4_t uc)
861 _UC_ATTRIBUTE_CONST;
862extern bool uc_is_property_emoji_presentation (ucs4_t uc)
863 _UC_ATTRIBUTE_CONST;
864extern bool uc_is_property_emoji_modifier (ucs4_t uc)
865 _UC_ATTRIBUTE_CONST;
866extern bool uc_is_property_emoji_modifier_base (ucs4_t uc)
867 _UC_ATTRIBUTE_CONST;
868extern bool uc_is_property_emoji_component (ucs4_t uc)
869 _UC_ATTRIBUTE_CONST;
870extern bool uc_is_property_extended_pictographic (ucs4_t uc)
871 _UC_ATTRIBUTE_CONST;
872extern bool uc_is_property_zero_width (ucs4_t uc)
873 _UC_ATTRIBUTE_CONST;
874extern bool uc_is_property_space (ucs4_t uc)
875 _UC_ATTRIBUTE_CONST;
876extern bool uc_is_property_non_break (ucs4_t uc)
877 _UC_ATTRIBUTE_CONST;
878extern bool uc_is_property_iso_control (ucs4_t uc)
879 _UC_ATTRIBUTE_CONST;
880extern bool uc_is_property_format_control (ucs4_t uc)
881 _UC_ATTRIBUTE_CONST;
882extern bool uc_is_property_prepended_concatenation_mark (ucs4_t uc)
883 _UC_ATTRIBUTE_CONST;
884extern bool uc_is_property_dash (ucs4_t uc)
885 _UC_ATTRIBUTE_CONST;
886extern bool uc_is_property_hyphen (ucs4_t uc)
887 _UC_ATTRIBUTE_CONST;
888extern bool uc_is_property_punctuation (ucs4_t uc)
889 _UC_ATTRIBUTE_CONST;
890extern bool uc_is_property_line_separator (ucs4_t uc)
891 _UC_ATTRIBUTE_CONST;
892extern bool uc_is_property_paragraph_separator (ucs4_t uc)
893 _UC_ATTRIBUTE_CONST;
894extern bool uc_is_property_quotation_mark (ucs4_t uc)
895 _UC_ATTRIBUTE_CONST;
896extern bool uc_is_property_sentence_terminal (ucs4_t uc)
897 _UC_ATTRIBUTE_CONST;
898extern bool uc_is_property_terminal_punctuation (ucs4_t uc)
899 _UC_ATTRIBUTE_CONST;
900extern bool uc_is_property_currency_symbol (ucs4_t uc)
901 _UC_ATTRIBUTE_CONST;
902extern bool uc_is_property_math (ucs4_t uc)
903 _UC_ATTRIBUTE_CONST;
904extern bool uc_is_property_other_math (ucs4_t uc)
905 _UC_ATTRIBUTE_CONST;
906extern bool uc_is_property_paired_punctuation (ucs4_t uc)
907 _UC_ATTRIBUTE_CONST;
908extern bool uc_is_property_left_of_pair (ucs4_t uc)
909 _UC_ATTRIBUTE_CONST;
910extern bool uc_is_property_combining (ucs4_t uc)
911 _UC_ATTRIBUTE_CONST;
912extern bool uc_is_property_composite (ucs4_t uc)
913 _UC_ATTRIBUTE_CONST;
914extern bool uc_is_property_decimal_digit (ucs4_t uc)
915 _UC_ATTRIBUTE_CONST;
916extern bool uc_is_property_numeric (ucs4_t uc)
917 _UC_ATTRIBUTE_CONST;
918extern bool uc_is_property_diacritic (ucs4_t uc)
919 _UC_ATTRIBUTE_CONST;
920extern bool uc_is_property_extender (ucs4_t uc)
921 _UC_ATTRIBUTE_CONST;
922extern bool uc_is_property_ignorable_control (ucs4_t uc)
923 _UC_ATTRIBUTE_CONST;
924extern bool uc_is_property_regional_indicator (ucs4_t uc)
925 _UC_ATTRIBUTE_CONST;
926
927/* ========================================================================= */
928
929/* Other attributes. */
930
931/* ------------------------------------------------------------------------- */
932
933/* Indic_Conjunct_Break (InCB): from the file DerivedCoreProperties.txt
934 in the Unicode Character Database. */
935
936/* Possible values of the Indic_Conjunct_Break attribute.
937 This enumeration may be extended in the future. */
938enum
939{
940 UC_INDIC_CONJUNCT_BREAK_NONE, /* None */
941 UC_INDIC_CONJUNCT_BREAK_CONSONANT, /* Consonant */
942 UC_INDIC_CONJUNCT_BREAK_LINKER, /* Linker */
943 UC_INDIC_CONJUNCT_BREAK_EXTEND /* Extend */
944};
945
946/* Return the name of an Indic_Conjunct_Break value. */
947extern const char *
948 uc_indic_conjunct_break_name (int indic_conjunct_break)
949 _UC_ATTRIBUTE_CONST;
950
951/* Return the Indic_Conjunct_Break value given by name, e.g. "Consonant". */
952extern int
953 uc_indic_conjunct_break_byname (const char *indic_conjunct_break_name)
954 _UC_ATTRIBUTE_PURE;
955
956/* Return the Indic_Conjunct_Break attribute of a Unicode character. */
957extern int
958 uc_indic_conjunct_break (ucs4_t uc)
959 _UC_ATTRIBUTE_CONST;
960
961/* ========================================================================= */
962
963/* Subdivision of the Unicode characters into scripts. */
964
965typedef struct
966{
967 unsigned int code : 21;
968 unsigned int start : 1;
969 unsigned int end : 1;
970}
971uc_interval_t;
972typedef struct
973{
974 unsigned int nintervals;
975 const uc_interval_t *intervals;
976 const char *name;
977}
978uc_script_t;
979
980/* Return the script of a Unicode character. */
981extern const uc_script_t *
982 uc_script (ucs4_t uc)
983 _UC_ATTRIBUTE_CONST;
984
985/* Return the script given by name, e.g. "HAN". */
986extern const uc_script_t *
987 uc_script_byname (const char *script_name)
988 _UC_ATTRIBUTE_PURE;
989
990/* Test whether a Unicode character belongs to a given script. */
991extern bool
992 uc_is_script (ucs4_t uc, const uc_script_t *script)
993 _UC_ATTRIBUTE_PURE;
994
995/* Get the list of all scripts. */
996extern void
997 uc_all_scripts (const uc_script_t **scripts, size_t *count);
998
999/* ========================================================================= */
1000
1001/* Subdivision of the Unicode character range into blocks. */
1002
1003typedef struct
1004{
1005 ucs4_t start;
1006 ucs4_t end;
1007 const char *name;
1008}
1009uc_block_t;
1010
1011/* Return the block a character belongs to. */
1012extern const uc_block_t *
1013 uc_block (ucs4_t uc)
1014 _UC_ATTRIBUTE_CONST;
1015
1016/* Test whether a Unicode character belongs to a given block. */
1017extern bool
1018 uc_is_block (ucs4_t uc, const uc_block_t *block)
1019 _UC_ATTRIBUTE_PURE;
1020
1021/* Get the list of all blocks. */
1022extern void
1023 uc_all_blocks (const uc_block_t **blocks, size_t *count);
1024
1025/* ========================================================================= */
1026
1027/* Properties taken from language standards. */
1028
1029/* Test whether a Unicode character is considered whitespace in ISO C 99. */
1030extern bool
1031 uc_is_c_whitespace (ucs4_t uc)
1032 _UC_ATTRIBUTE_CONST;
1033
1034/* Test whether a Unicode character is considered whitespace in Java. */
1035extern bool
1036 uc_is_java_whitespace (ucs4_t uc)
1037 _UC_ATTRIBUTE_CONST;
1038
1039enum
1040{
1041 UC_IDENTIFIER_START, /* valid as first or subsequent character */
1042 UC_IDENTIFIER_VALID, /* valid as subsequent character only */
1043 UC_IDENTIFIER_INVALID, /* not valid */
1044 UC_IDENTIFIER_IGNORABLE /* ignorable (Java only) */
1045};
1046
1047/* Return the categorization of a Unicode character w.r.t. the ISO C 99
1048 identifier syntax. */
1049extern int
1050 uc_c_ident_category (ucs4_t uc)
1051 _UC_ATTRIBUTE_CONST;
1052
1053/* Return the categorization of a Unicode character w.r.t. the Java
1054 identifier syntax. */
1055extern int
1056 uc_java_ident_category (ucs4_t uc)
1057 _UC_ATTRIBUTE_CONST;
1058
1059/* ========================================================================= */
1060
1061/* Like ISO C <ctype.h> and <wctype.h>. These functions are deprecated,
1062 because this set of functions was designed with ASCII in mind and cannot
1063 reflect the more diverse reality of the Unicode character set. But they
1064 can be a quick-and-dirty porting aid when migrating from wchar_t APIs
1065 to Unicode strings. */
1066
1067/* Test for any character for which 'uc_is_alpha' or 'uc_is_digit' is true. */
1068extern bool
1069 uc_is_alnum (ucs4_t uc)
1070 _UC_ATTRIBUTE_CONST;
1071
1072/* Test for any character for which 'uc_is_upper' or 'uc_is_lower' is true,
1073 or any character that is one of a locale-specific set of characters for
1074 which none of 'uc_is_cntrl', 'uc_is_digit', 'uc_is_punct', or 'uc_is_space'
1075 is true. */
1076extern bool
1077 uc_is_alpha (ucs4_t uc)
1078 _UC_ATTRIBUTE_CONST;
1079
1080/* Test for any control character. */
1081extern bool
1082 uc_is_cntrl (ucs4_t uc)
1083 _UC_ATTRIBUTE_CONST;
1084
1085/* Test for any character that corresponds to a decimal-digit character. */
1086extern bool
1087 uc_is_digit (ucs4_t uc)
1088 _UC_ATTRIBUTE_CONST;
1089
1090/* Test for any character for which 'uc_is_print' is true and 'uc_is_space'
1091 is false. */
1092extern bool
1093 uc_is_graph (ucs4_t uc)
1094 _UC_ATTRIBUTE_CONST;
1095
1096/* Test for any character that corresponds to a lowercase letter or is one
1097 of a locale-specific set of characters for which none of 'uc_is_cntrl',
1098 'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true. */
1099extern bool
1100 uc_is_lower (ucs4_t uc)
1101 _UC_ATTRIBUTE_CONST;
1102
1103/* Test for any printing character. */
1104extern bool
1105 uc_is_print (ucs4_t uc)
1106 _UC_ATTRIBUTE_CONST;
1107
1108/* Test for any printing character that is one of a locale-specific set of
1109 characters for which neither 'uc_is_space' nor 'uc_is_alnum' is true. */
1110extern bool
1111 uc_is_punct (ucs4_t uc)
1112 _UC_ATTRIBUTE_CONST;
1113
1114/* Test for any character that corresponds to a locale-specific set of
1115 characters for which none of 'uc_is_alnum', 'uc_is_graph', or 'uc_is_punct'
1116 is true. */
1117extern bool
1118 uc_is_space (ucs4_t uc)
1119 _UC_ATTRIBUTE_CONST;
1120
1121/* Test for any character that corresponds to an uppercase letter or is one
1122 of a locale-specific set of character for which none of 'uc_is_cntrl',
1123 'uc_is_digit', 'uc_is_punct', or 'uc_is_space' is true. */
1124extern bool
1125 uc_is_upper (ucs4_t uc)
1126 _UC_ATTRIBUTE_CONST;
1127
1128/* Test for any character that corresponds to a hexadecimal-digit
1129 character. */
1130extern bool
1131 uc_is_xdigit (ucs4_t uc)
1132 _UC_ATTRIBUTE_CONST;
1133
1134/* GNU extension. */
1135/* Test for any character that corresponds to a standard blank character or
1136 a locale-specific set of characters for which 'uc_is_alnum' is false. */
1137extern bool
1138 uc_is_blank (ucs4_t uc)
1139 _UC_ATTRIBUTE_CONST;
1140
1141/* ========================================================================= */
1142
1143#ifdef __cplusplus
1144}
1145#endif
1146
1147#endif /* _UNICTYPE_H */
diff --git a/gl/unictype/.dirstamp b/gl/unictype/.dirstamp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/gl/unictype/.dirstamp
diff --git a/gl/unictype/bitmap.h b/gl/unictype/bitmap.h
new file mode 100644
index 00000000..621861da
--- /dev/null
+++ b/gl/unictype/bitmap.h
@@ -0,0 +1,48 @@
1/* Three-level bitmap lookup.
2 Copyright (C) 2000-2002, 2005-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2000-2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18static inline int bitmap_lookup (const void *table, ucs4_t uc);
19
20/* These values are currently hardcoded into gen-uni-tables.c, function
21 output_predicate(). */
22#define header_0 16
23#define header_2 9
24#define header_3 127
25#define header_4 15
26
27static inline int
28bitmap_lookup (const void *table, ucs4_t uc)
29{
30 unsigned int index1 = uc >> header_0;
31 if (index1 < ((const int *) table)[0])
32 {
33 int lookup1 = ((const int *) table)[1 + index1];
34 if (lookup1 >= 0)
35 {
36 unsigned int index2 = (uc >> header_2) & header_3;
37 int lookup2 = ((const short *) table)[lookup1 + index2];
38 if (lookup2 >= 0)
39 {
40 unsigned int index3 = (uc >> 5) & header_4;
41 unsigned int lookup3 = ((const unsigned int *) table)[lookup2 + index3];
42
43 return (lookup3 >> (uc & 0x1f)) & 1;
44 }
45 }
46 }
47 return 0;
48}
diff --git a/gl/unictype/ctype_alnum.c b/gl/unictype/ctype_alnum.c
new file mode 100644
index 00000000..7cd9157a
--- /dev/null
+++ b/gl/unictype/ctype_alnum.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_alnum table. */
26#include "ctype_alnum.h"
27
28bool
29uc_is_alnum (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_alnum, uc);
32}
diff --git a/gl/unictype/ctype_alnum.h b/gl/unictype/ctype_alnum.h
new file mode 100644
index 00000000..0530175e
--- /dev/null
+++ b/gl/unictype/ctype_alnum.h
@@ -0,0 +1,889 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[4];
29 short level2[4 << 7];
30 unsigned int level3[83 << 4];
31 }
32u_is_alnum =
33{
34 { 4 },
35 {
36 5 * sizeof (int) / sizeof (short) + 0,
37 5 * sizeof (int) / sizeof (short) + 128,
38 5 * sizeof (int) / sizeof (short) + 256,
39 5 * sizeof (int) / sizeof (short) + 384
40 },
41 {
42 5 + 512 * sizeof (short) / sizeof (int) + 0,
43 5 + 512 * sizeof (short) / sizeof (int) + 16,
44 5 + 512 * sizeof (short) / sizeof (int) + 32,
45 5 + 512 * sizeof (short) / sizeof (int) + 48,
46 5 + 512 * sizeof (short) / sizeof (int) + 64,
47 5 + 512 * sizeof (short) / sizeof (int) + 80,
48 5 + 512 * sizeof (short) / sizeof (int) + 96,
49 5 + 512 * sizeof (short) / sizeof (int) + 112,
50 5 + 512 * sizeof (short) / sizeof (int) + 128,
51 5 + 512 * sizeof (short) / sizeof (int) + 144,
52 5 + 512 * sizeof (short) / sizeof (int) + 160,
53 5 + 512 * sizeof (short) / sizeof (int) + 176,
54 5 + 512 * sizeof (short) / sizeof (int) + 192,
55 5 + 512 * sizeof (short) / sizeof (int) + 208,
56 5 + 512 * sizeof (short) / sizeof (int) + 224,
57 5 + 512 * sizeof (short) / sizeof (int) + 240,
58 5 + 512 * sizeof (short) / sizeof (int) + 256,
59 -1,
60 5 + 512 * sizeof (short) / sizeof (int) + 272,
61 -1,
62 -1,
63 -1,
64 5 + 512 * sizeof (short) / sizeof (int) + 288,
65 5 + 512 * sizeof (short) / sizeof (int) + 304,
66 5 + 512 * sizeof (short) / sizeof (int) + 320,
67 -1,
68 5 + 512 * sizeof (short) / sizeof (int) + 336,
69 5 + 512 * sizeof (short) / sizeof (int) + 336,
70 5 + 512 * sizeof (short) / sizeof (int) + 336,
71 5 + 512 * sizeof (short) / sizeof (int) + 336,
72 5 + 512 * sizeof (short) / sizeof (int) + 336,
73 5 + 512 * sizeof (short) / sizeof (int) + 336,
74 5 + 512 * sizeof (short) / sizeof (int) + 336,
75 5 + 512 * sizeof (short) / sizeof (int) + 336,
76 5 + 512 * sizeof (short) / sizeof (int) + 336,
77 5 + 512 * sizeof (short) / sizeof (int) + 336,
78 5 + 512 * sizeof (short) / sizeof (int) + 336,
79 5 + 512 * sizeof (short) / sizeof (int) + 336,
80 5 + 512 * sizeof (short) / sizeof (int) + 352,
81 5 + 512 * sizeof (short) / sizeof (int) + 336,
82 5 + 512 * sizeof (short) / sizeof (int) + 336,
83 5 + 512 * sizeof (short) / sizeof (int) + 336,
84 5 + 512 * sizeof (short) / sizeof (int) + 336,
85 5 + 512 * sizeof (short) / sizeof (int) + 336,
86 5 + 512 * sizeof (short) / sizeof (int) + 336,
87 5 + 512 * sizeof (short) / sizeof (int) + 336,
88 5 + 512 * sizeof (short) / sizeof (int) + 336,
89 5 + 512 * sizeof (short) / sizeof (int) + 336,
90 5 + 512 * sizeof (short) / sizeof (int) + 336,
91 5 + 512 * sizeof (short) / sizeof (int) + 336,
92 5 + 512 * sizeof (short) / sizeof (int) + 336,
93 5 + 512 * sizeof (short) / sizeof (int) + 336,
94 5 + 512 * sizeof (short) / sizeof (int) + 336,
95 5 + 512 * sizeof (short) / sizeof (int) + 336,
96 5 + 512 * sizeof (short) / sizeof (int) + 336,
97 5 + 512 * sizeof (short) / sizeof (int) + 336,
98 5 + 512 * sizeof (short) / sizeof (int) + 336,
99 5 + 512 * sizeof (short) / sizeof (int) + 336,
100 5 + 512 * sizeof (short) / sizeof (int) + 336,
101 5 + 512 * sizeof (short) / sizeof (int) + 336,
102 5 + 512 * sizeof (short) / sizeof (int) + 336,
103 5 + 512 * sizeof (short) / sizeof (int) + 336,
104 5 + 512 * sizeof (short) / sizeof (int) + 336,
105 5 + 512 * sizeof (short) / sizeof (int) + 336,
106 5 + 512 * sizeof (short) / sizeof (int) + 336,
107 5 + 512 * sizeof (short) / sizeof (int) + 336,
108 5 + 512 * sizeof (short) / sizeof (int) + 336,
109 5 + 512 * sizeof (short) / sizeof (int) + 336,
110 5 + 512 * sizeof (short) / sizeof (int) + 336,
111 5 + 512 * sizeof (short) / sizeof (int) + 336,
112 5 + 512 * sizeof (short) / sizeof (int) + 336,
113 5 + 512 * sizeof (short) / sizeof (int) + 336,
114 5 + 512 * sizeof (short) / sizeof (int) + 336,
115 5 + 512 * sizeof (short) / sizeof (int) + 336,
116 5 + 512 * sizeof (short) / sizeof (int) + 336,
117 5 + 512 * sizeof (short) / sizeof (int) + 336,
118 5 + 512 * sizeof (short) / sizeof (int) + 336,
119 5 + 512 * sizeof (short) / sizeof (int) + 336,
120 5 + 512 * sizeof (short) / sizeof (int) + 336,
121 5 + 512 * sizeof (short) / sizeof (int) + 336,
122 5 + 512 * sizeof (short) / sizeof (int) + 336,
123 5 + 512 * sizeof (short) / sizeof (int) + 336,
124 5 + 512 * sizeof (short) / sizeof (int) + 368,
125 5 + 512 * sizeof (short) / sizeof (int) + 384,
126 5 + 512 * sizeof (short) / sizeof (int) + 400,
127 5 + 512 * sizeof (short) / sizeof (int) + 416,
128 5 + 512 * sizeof (short) / sizeof (int) + 336,
129 5 + 512 * sizeof (short) / sizeof (int) + 336,
130 5 + 512 * sizeof (short) / sizeof (int) + 336,
131 5 + 512 * sizeof (short) / sizeof (int) + 336,
132 5 + 512 * sizeof (short) / sizeof (int) + 336,
133 5 + 512 * sizeof (short) / sizeof (int) + 336,
134 5 + 512 * sizeof (short) / sizeof (int) + 336,
135 5 + 512 * sizeof (short) / sizeof (int) + 336,
136 5 + 512 * sizeof (short) / sizeof (int) + 336,
137 5 + 512 * sizeof (short) / sizeof (int) + 336,
138 5 + 512 * sizeof (short) / sizeof (int) + 336,
139 5 + 512 * sizeof (short) / sizeof (int) + 336,
140 5 + 512 * sizeof (short) / sizeof (int) + 336,
141 5 + 512 * sizeof (short) / sizeof (int) + 336,
142 5 + 512 * sizeof (short) / sizeof (int) + 336,
143 5 + 512 * sizeof (short) / sizeof (int) + 336,
144 5 + 512 * sizeof (short) / sizeof (int) + 336,
145 5 + 512 * sizeof (short) / sizeof (int) + 336,
146 5 + 512 * sizeof (short) / sizeof (int) + 336,
147 5 + 512 * sizeof (short) / sizeof (int) + 336,
148 5 + 512 * sizeof (short) / sizeof (int) + 336,
149 5 + 512 * sizeof (short) / sizeof (int) + 432,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 5 + 512 * sizeof (short) / sizeof (int) + 448,
167 5 + 512 * sizeof (short) / sizeof (int) + 464,
168 5 + 512 * sizeof (short) / sizeof (int) + 480,
169 5 + 512 * sizeof (short) / sizeof (int) + 496,
170 5 + 512 * sizeof (short) / sizeof (int) + 512,
171 5 + 512 * sizeof (short) / sizeof (int) + 528,
172 5 + 512 * sizeof (short) / sizeof (int) + 544,
173 5 + 512 * sizeof (short) / sizeof (int) + 560,
174 5 + 512 * sizeof (short) / sizeof (int) + 576,
175 5 + 512 * sizeof (short) / sizeof (int) + 592,
176 5 + 512 * sizeof (short) / sizeof (int) + 608,
177 5 + 512 * sizeof (short) / sizeof (int) + 624,
178 5 + 512 * sizeof (short) / sizeof (int) + 640,
179 5 + 512 * sizeof (short) / sizeof (int) + 656,
180 5 + 512 * sizeof (short) / sizeof (int) + 672,
181 5 + 512 * sizeof (short) / sizeof (int) + 688,
182 5 + 512 * sizeof (short) / sizeof (int) + 704,
183 5 + 512 * sizeof (short) / sizeof (int) + 720,
184 5 + 512 * sizeof (short) / sizeof (int) + 736,
185 5 + 512 * sizeof (short) / sizeof (int) + 752,
186 5 + 512 * sizeof (short) / sizeof (int) + 336,
187 5 + 512 * sizeof (short) / sizeof (int) + 768,
188 5 + 512 * sizeof (short) / sizeof (int) + 784,
189 -1,
190 -1,
191 -1,
192 -1,
193 5 + 512 * sizeof (short) / sizeof (int) + 800,
194 5 + 512 * sizeof (short) / sizeof (int) + 336,
195 5 + 512 * sizeof (short) / sizeof (int) + 336,
196 5 + 512 * sizeof (short) / sizeof (int) + 816,
197 5 + 512 * sizeof (short) / sizeof (int) + 336,
198 5 + 512 * sizeof (short) / sizeof (int) + 336,
199 5 + 512 * sizeof (short) / sizeof (int) + 336,
200 5 + 512 * sizeof (short) / sizeof (int) + 336,
201 5 + 512 * sizeof (short) / sizeof (int) + 336,
202 5 + 512 * sizeof (short) / sizeof (int) + 336,
203 5 + 512 * sizeof (short) / sizeof (int) + 832,
204 5 + 512 * sizeof (short) / sizeof (int) + 336,
205 5 + 512 * sizeof (short) / sizeof (int) + 848,
206 -1,
207 -1,
208 -1,
209 -1,
210 -1,
211 -1,
212 -1,
213 -1,
214 -1,
215 -1,
216 -1,
217 -1,
218 5 + 512 * sizeof (short) / sizeof (int) + 864,
219 -1,
220 -1,
221 -1,
222 5 + 512 * sizeof (short) / sizeof (int) + 336,
223 5 + 512 * sizeof (short) / sizeof (int) + 880,
224 5 + 512 * sizeof (short) / sizeof (int) + 896,
225 5 + 512 * sizeof (short) / sizeof (int) + 912,
226 5 + 512 * sizeof (short) / sizeof (int) + 336,
227 5 + 512 * sizeof (short) / sizeof (int) + 336,
228 5 + 512 * sizeof (short) / sizeof (int) + 336,
229 5 + 512 * sizeof (short) / sizeof (int) + 336,
230 5 + 512 * sizeof (short) / sizeof (int) + 336,
231 5 + 512 * sizeof (short) / sizeof (int) + 336,
232 5 + 512 * sizeof (short) / sizeof (int) + 336,
233 5 + 512 * sizeof (short) / sizeof (int) + 336,
234 5 + 512 * sizeof (short) / sizeof (int) + 336,
235 5 + 512 * sizeof (short) / sizeof (int) + 336,
236 5 + 512 * sizeof (short) / sizeof (int) + 336,
237 5 + 512 * sizeof (short) / sizeof (int) + 336,
238 5 + 512 * sizeof (short) / sizeof (int) + 336,
239 5 + 512 * sizeof (short) / sizeof (int) + 336,
240 5 + 512 * sizeof (short) / sizeof (int) + 928,
241 -1,
242 -1,
243 -1,
244 -1,
245 -1,
246 -1,
247 -1,
248 -1,
249 -1,
250 -1,
251 -1,
252 -1,
253 -1,
254 -1,
255 -1,
256 -1,
257 5 + 512 * sizeof (short) / sizeof (int) + 944,
258 5 + 512 * sizeof (short) / sizeof (int) + 960,
259 5 + 512 * sizeof (short) / sizeof (int) + 976,
260 -1,
261 -1,
262 -1,
263 -1,
264 5 + 512 * sizeof (short) / sizeof (int) + 992,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 -1,
271 -1,
272 5 + 512 * sizeof (short) / sizeof (int) + 1008,
273 -1,
274 -1,
275 -1,
276 5 + 512 * sizeof (short) / sizeof (int) + 1024,
277 5 + 512 * sizeof (short) / sizeof (int) + 1040,
278 -1,
279 -1,
280 -1,
281 5 + 512 * sizeof (short) / sizeof (int) + 1056,
282 5 + 512 * sizeof (short) / sizeof (int) + 1072,
283 5 + 512 * sizeof (short) / sizeof (int) + 1088,
284 5 + 512 * sizeof (short) / sizeof (int) + 1104,
285 5 + 512 * sizeof (short) / sizeof (int) + 1120,
286 5 + 512 * sizeof (short) / sizeof (int) + 1136,
287 -1,
288 -1,
289 5 + 512 * sizeof (short) / sizeof (int) + 1152,
290 5 + 512 * sizeof (short) / sizeof (int) + 1168,
291 -1,
292 -1,
293 -1,
294 -1,
295 5 + 512 * sizeof (short) / sizeof (int) + 1184,
296 -1,
297 -1,
298 5 + 512 * sizeof (short) / sizeof (int) + 336,
299 5 + 512 * sizeof (short) / sizeof (int) + 336,
300 5 + 512 * sizeof (short) / sizeof (int) + 336,
301 5 + 512 * sizeof (short) / sizeof (int) + 336,
302 5 + 512 * sizeof (short) / sizeof (int) + 336,
303 5 + 512 * sizeof (short) / sizeof (int) + 336,
304 5 + 512 * sizeof (short) / sizeof (int) + 336,
305 5 + 512 * sizeof (short) / sizeof (int) + 336,
306 5 + 512 * sizeof (short) / sizeof (int) + 336,
307 5 + 512 * sizeof (short) / sizeof (int) + 336,
308 5 + 512 * sizeof (short) / sizeof (int) + 336,
309 5 + 512 * sizeof (short) / sizeof (int) + 336,
310 5 + 512 * sizeof (short) / sizeof (int) + 336,
311 5 + 512 * sizeof (short) / sizeof (int) + 336,
312 5 + 512 * sizeof (short) / sizeof (int) + 336,
313 5 + 512 * sizeof (short) / sizeof (int) + 336,
314 5 + 512 * sizeof (short) / sizeof (int) + 336,
315 5 + 512 * sizeof (short) / sizeof (int) + 336,
316 5 + 512 * sizeof (short) / sizeof (int) + 336,
317 5 + 512 * sizeof (short) / sizeof (int) + 336,
318 5 + 512 * sizeof (short) / sizeof (int) + 336,
319 5 + 512 * sizeof (short) / sizeof (int) + 336,
320 5 + 512 * sizeof (short) / sizeof (int) + 336,
321 5 + 512 * sizeof (short) / sizeof (int) + 336,
322 5 + 512 * sizeof (short) / sizeof (int) + 336,
323 5 + 512 * sizeof (short) / sizeof (int) + 336,
324 5 + 512 * sizeof (short) / sizeof (int) + 336,
325 5 + 512 * sizeof (short) / sizeof (int) + 336,
326 5 + 512 * sizeof (short) / sizeof (int) + 336,
327 5 + 512 * sizeof (short) / sizeof (int) + 336,
328 5 + 512 * sizeof (short) / sizeof (int) + 336,
329 5 + 512 * sizeof (short) / sizeof (int) + 336,
330 5 + 512 * sizeof (short) / sizeof (int) + 336,
331 5 + 512 * sizeof (short) / sizeof (int) + 336,
332 5 + 512 * sizeof (short) / sizeof (int) + 336,
333 5 + 512 * sizeof (short) / sizeof (int) + 336,
334 5 + 512 * sizeof (short) / sizeof (int) + 336,
335 5 + 512 * sizeof (short) / sizeof (int) + 336,
336 5 + 512 * sizeof (short) / sizeof (int) + 336,
337 5 + 512 * sizeof (short) / sizeof (int) + 336,
338 5 + 512 * sizeof (short) / sizeof (int) + 336,
339 5 + 512 * sizeof (short) / sizeof (int) + 336,
340 5 + 512 * sizeof (short) / sizeof (int) + 336,
341 5 + 512 * sizeof (short) / sizeof (int) + 336,
342 5 + 512 * sizeof (short) / sizeof (int) + 336,
343 5 + 512 * sizeof (short) / sizeof (int) + 336,
344 5 + 512 * sizeof (short) / sizeof (int) + 336,
345 5 + 512 * sizeof (short) / sizeof (int) + 336,
346 5 + 512 * sizeof (short) / sizeof (int) + 336,
347 5 + 512 * sizeof (short) / sizeof (int) + 336,
348 5 + 512 * sizeof (short) / sizeof (int) + 336,
349 5 + 512 * sizeof (short) / sizeof (int) + 336,
350 5 + 512 * sizeof (short) / sizeof (int) + 336,
351 5 + 512 * sizeof (short) / sizeof (int) + 336,
352 5 + 512 * sizeof (short) / sizeof (int) + 336,
353 5 + 512 * sizeof (short) / sizeof (int) + 336,
354 5 + 512 * sizeof (short) / sizeof (int) + 336,
355 5 + 512 * sizeof (short) / sizeof (int) + 336,
356 5 + 512 * sizeof (short) / sizeof (int) + 336,
357 5 + 512 * sizeof (short) / sizeof (int) + 336,
358 5 + 512 * sizeof (short) / sizeof (int) + 336,
359 5 + 512 * sizeof (short) / sizeof (int) + 336,
360 5 + 512 * sizeof (short) / sizeof (int) + 336,
361 5 + 512 * sizeof (short) / sizeof (int) + 336,
362 5 + 512 * sizeof (short) / sizeof (int) + 336,
363 5 + 512 * sizeof (short) / sizeof (int) + 336,
364 5 + 512 * sizeof (short) / sizeof (int) + 336,
365 5 + 512 * sizeof (short) / sizeof (int) + 336,
366 5 + 512 * sizeof (short) / sizeof (int) + 336,
367 5 + 512 * sizeof (short) / sizeof (int) + 336,
368 5 + 512 * sizeof (short) / sizeof (int) + 336,
369 5 + 512 * sizeof (short) / sizeof (int) + 336,
370 5 + 512 * sizeof (short) / sizeof (int) + 336,
371 5 + 512 * sizeof (short) / sizeof (int) + 336,
372 5 + 512 * sizeof (short) / sizeof (int) + 336,
373 5 + 512 * sizeof (short) / sizeof (int) + 336,
374 5 + 512 * sizeof (short) / sizeof (int) + 336,
375 5 + 512 * sizeof (short) / sizeof (int) + 336,
376 5 + 512 * sizeof (short) / sizeof (int) + 336,
377 5 + 512 * sizeof (short) / sizeof (int) + 336,
378 5 + 512 * sizeof (short) / sizeof (int) + 336,
379 5 + 512 * sizeof (short) / sizeof (int) + 336,
380 5 + 512 * sizeof (short) / sizeof (int) + 336,
381 5 + 512 * sizeof (short) / sizeof (int) + 1200,
382 5 + 512 * sizeof (short) / sizeof (int) + 336,
383 5 + 512 * sizeof (short) / sizeof (int) + 336,
384 5 + 512 * sizeof (short) / sizeof (int) + 336,
385 5 + 512 * sizeof (short) / sizeof (int) + 336,
386 5 + 512 * sizeof (short) / sizeof (int) + 336,
387 5 + 512 * sizeof (short) / sizeof (int) + 336,
388 5 + 512 * sizeof (short) / sizeof (int) + 336,
389 5 + 512 * sizeof (short) / sizeof (int) + 336,
390 5 + 512 * sizeof (short) / sizeof (int) + 1216,
391 5 + 512 * sizeof (short) / sizeof (int) + 336,
392 5 + 512 * sizeof (short) / sizeof (int) + 336,
393 5 + 512 * sizeof (short) / sizeof (int) + 336,
394 5 + 512 * sizeof (short) / sizeof (int) + 336,
395 5 + 512 * sizeof (short) / sizeof (int) + 336,
396 5 + 512 * sizeof (short) / sizeof (int) + 336,
397 5 + 512 * sizeof (short) / sizeof (int) + 336,
398 5 + 512 * sizeof (short) / sizeof (int) + 336,
399 5 + 512 * sizeof (short) / sizeof (int) + 336,
400 5 + 512 * sizeof (short) / sizeof (int) + 336,
401 5 + 512 * sizeof (short) / sizeof (int) + 1232,
402 5 + 512 * sizeof (short) / sizeof (int) + 336,
403 5 + 512 * sizeof (short) / sizeof (int) + 336,
404 5 + 512 * sizeof (short) / sizeof (int) + 336,
405 5 + 512 * sizeof (short) / sizeof (int) + 336,
406 5 + 512 * sizeof (short) / sizeof (int) + 336,
407 5 + 512 * sizeof (short) / sizeof (int) + 336,
408 5 + 512 * sizeof (short) / sizeof (int) + 336,
409 5 + 512 * sizeof (short) / sizeof (int) + 336,
410 5 + 512 * sizeof (short) / sizeof (int) + 336,
411 5 + 512 * sizeof (short) / sizeof (int) + 336,
412 5 + 512 * sizeof (short) / sizeof (int) + 336,
413 5 + 512 * sizeof (short) / sizeof (int) + 336,
414 5 + 512 * sizeof (short) / sizeof (int) + 336,
415 5 + 512 * sizeof (short) / sizeof (int) + 1248,
416 5 + 512 * sizeof (short) / sizeof (int) + 336,
417 5 + 512 * sizeof (short) / sizeof (int) + 1264,
418 -1,
419 -1,
420 -1,
421 -1,
422 5 + 512 * sizeof (short) / sizeof (int) + 336,
423 5 + 512 * sizeof (short) / sizeof (int) + 1280,
424 -1,
425 -1,
426 5 + 512 * sizeof (short) / sizeof (int) + 336,
427 5 + 512 * sizeof (short) / sizeof (int) + 336,
428 5 + 512 * sizeof (short) / sizeof (int) + 336,
429 5 + 512 * sizeof (short) / sizeof (int) + 336,
430 5 + 512 * sizeof (short) / sizeof (int) + 336,
431 5 + 512 * sizeof (short) / sizeof (int) + 336,
432 5 + 512 * sizeof (short) / sizeof (int) + 336,
433 5 + 512 * sizeof (short) / sizeof (int) + 336,
434 5 + 512 * sizeof (short) / sizeof (int) + 336,
435 5 + 512 * sizeof (short) / sizeof (int) + 1296,
436 5 + 512 * sizeof (short) / sizeof (int) + 336,
437 5 + 512 * sizeof (short) / sizeof (int) + 336,
438 5 + 512 * sizeof (short) / sizeof (int) + 336,
439 5 + 512 * sizeof (short) / sizeof (int) + 336,
440 5 + 512 * sizeof (short) / sizeof (int) + 336,
441 5 + 512 * sizeof (short) / sizeof (int) + 336,
442 5 + 512 * sizeof (short) / sizeof (int) + 336,
443 5 + 512 * sizeof (short) / sizeof (int) + 336,
444 5 + 512 * sizeof (short) / sizeof (int) + 336,
445 5 + 512 * sizeof (short) / sizeof (int) + 336,
446 5 + 512 * sizeof (short) / sizeof (int) + 336,
447 5 + 512 * sizeof (short) / sizeof (int) + 336,
448 5 + 512 * sizeof (short) / sizeof (int) + 336,
449 5 + 512 * sizeof (short) / sizeof (int) + 336,
450 5 + 512 * sizeof (short) / sizeof (int) + 336,
451 5 + 512 * sizeof (short) / sizeof (int) + 336,
452 5 + 512 * sizeof (short) / sizeof (int) + 1312,
453 -1,
454 -1,
455 -1,
456 -1,
457 -1,
458 -1,
459 -1,
460 -1,
461 -1,
462 -1,
463 -1,
464 -1,
465 -1,
466 -1,
467 -1,
468 -1,
469 -1,
470 -1,
471 -1,
472 -1,
473 -1,
474 -1,
475 -1,
476 -1,
477 -1,
478 -1,
479 -1,
480 -1,
481 -1,
482 -1,
483 -1,
484 -1,
485 -1,
486 -1,
487 -1,
488 -1,
489 -1,
490 -1,
491 -1,
492 -1,
493 -1,
494 -1,
495 -1,
496 -1,
497 -1,
498 -1,
499 -1,
500 -1,
501 -1,
502 -1,
503 -1,
504 -1,
505 -1,
506 -1,
507 -1,
508 -1,
509 -1,
510 -1,
511 -1,
512 -1,
513 -1,
514 -1,
515 -1,
516 -1,
517 -1,
518 -1,
519 -1,
520 -1,
521 -1,
522 -1,
523 -1,
524 -1,
525 -1,
526 -1,
527 -1,
528 -1,
529 -1,
530 -1,
531 -1,
532 -1,
533 -1,
534 -1,
535 -1,
536 -1,
537 -1,
538 -1,
539 -1,
540 -1,
541 -1,
542 -1,
543 -1,
544 -1,
545 -1,
546 -1,
547 -1,
548 -1,
549 -1,
550 -1,
551 -1,
552 -1,
553 -1
554 },
555 {
556 0x00000000U, 0x03FF0000U, 0x07FFFFFEU, 0x07FFFFFEU,
557 0x00000000U, 0x04200400U, 0xFF7FFFFFU, 0xFF7FFFFFU,
558 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
559 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
560 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
561 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0003FFC3U, 0x0000501FU,
562 0x00000000U, 0x00000000U, 0x00000020U, 0xBCDF0000U,
563 0xFFFFD740U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFBFFFFFU,
564 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
565 0xFFFFFC03U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
566 0xFFFFFFFFU, 0xFFFEFFFFU, 0x027FFFFFU, 0xFFFFFFFFU,
567 0x000001FFU, 0x00000000U, 0xFFFF0000U, 0x000787FFU,
568 0x00000000U, 0xFFFFFFFFU, 0x000007FFU, 0xFFFEC3FFU,
569 0xFFFFFFFFU, 0xFFFFFFFFU, 0x002FFFFFU, 0x9FFFC060U,
570 0xFFFD0000U, 0x0000FFFFU, 0xFFFFE000U, 0xFFFFFFFFU,
571 0xFFFFFFFFU, 0x0002003FU, 0xFFFFFFFFU, 0x043007FFU,
572 0x043FFFFFU, 0x00000110U, 0x01FFFFFFU, 0xFFFF07FFU,
573 0x0000FEFFU, 0xFFFFFFFFU, 0x000003FFU, 0x00000000U,
574 0xFFFFFFF0U, 0x23FFFFFFU, 0xFF010000U, 0xFFFEFFC3U,
575 0xFFF99FE1U, 0x23C5FDFFU, 0xB0004000U, 0x1003FFC3U,
576 0xFFF987E0U, 0x036DFDFFU, 0x5E000000U, 0x001CFFC0U,
577 0xFFFBBFE0U, 0x23EDFDFFU, 0x00010000U, 0x0200FFC3U,
578 0xFFF99FE0U, 0x23EDFDFFU, 0xB0000000U, 0x0002FFC3U,
579 0xD63DC7E8U, 0x03FFC718U, 0x00010000U, 0x0000FFC0U,
580 0xFFFDDFE0U, 0x23FFFDFFU, 0x37000000U, 0x0000FFC3U,
581 0xFFFDDFE1U, 0x23EFFDFFU, 0x70000000U, 0x0006FFC3U,
582 0xFFFDDFF0U, 0x27FFFFFFU, 0x80704000U, 0xFC00FFC3U,
583 0xFC7FFFE0U, 0x2FFBFFFFU, 0x0000007FU, 0x0000FFC0U,
584 0xFFFFFFFEU, 0x07FF7FFFU, 0x03FF7FBFU, 0x00000000U,
585 0xFFFFF7D6U, 0x200DFFAFU, 0xF3FF005FU, 0x00000000U,
586 0x00000001U, 0x000003FFU, 0xFFFFFEFFU, 0x00001FFFU,
587 0x00001F00U, 0x00000000U, 0x00000000U, 0x00000000U,
588 0xFFFFFFFFU, 0x800007FFU, 0x3C3F03FFU, 0xFFE1C062U,
589 0x03FF4003U, 0xFFFFFFFFU, 0xFFFF20BFU, 0xF7FFFFFFU,
590 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
591 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
592 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU,
593 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU,
594 0xFF3DFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, 0x00000000U,
595 0x0000FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU,
596 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
597 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
598 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
599 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
600 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF9FFFU,
601 0x07FFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFC7FFU,
602 0x8003FFFFU, 0x0003FFFFU, 0x0003FFFFU, 0x0001DFFFU,
603 0xFFFFFFFFU, 0x000FFFFFU, 0x10800000U, 0x000003FFU,
604 0x03FF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU,
605 0xFFFFFF9FU, 0xFFFF05FFU, 0xFFFFFFFFU, 0x003FFFFFU,
606 0x7FFFFFFFU, 0x00000000U, 0xFFFFFFC0U, 0x001F3FFFU,
607 0xFFFFFFFFU, 0xFFFF0FFFU, 0x03FF03FFU, 0x00000000U,
608 0x007FFFFFU, 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U,
609 0x03FF03FFU, 0x00000080U, 0x00000000U, 0x00000000U,
610 0xFFFFFFE0U, 0x000FFFFFU, 0x03FF1FE0U, 0x00000000U,
611 0xFFFFFFF8U, 0xFFFFC001U, 0xFFFFFFFFU, 0x0000003FU,
612 0xFFFFFFFFU, 0x0000000FU, 0xFFFFE3FFU, 0x3FFFFFFFU,
613 0xFFFF07FFU, 0xE7FFFFFFU, 0x00000000U, 0x046FDE00U,
614 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
615 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
616 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
617 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
618 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU,
619 0xFFFFFFFFU, 0x5FDFFFFFU, 0x0FCF1FDCU, 0x1FDC1FFFU,
620 0x00000000U, 0x00000000U, 0x00000000U, 0x80020000U,
621 0x1FFF0000U, 0x00000000U, 0x00000000U, 0x00000000U,
622 0x3E2FFC84U, 0xF3FFBF50U, 0x000043E0U, 0xFFFFFFFFU,
623 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U,
624 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
625 0xF0000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000003FFU,
626 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
627 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
628 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
629 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000C781FU,
630 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x000080FFU,
631 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0x00000000U,
632 0x00000000U, 0x00008000U, 0x00000000U, 0x00000000U,
633 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
634 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
635 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
636 0x000000E0U, 0x1F3E03FEU, 0xFFFFFFFEU, 0xFFFFFFFFU,
637 0xE07FFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU, 0xF7FFFFFFU,
638 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
639 0x00007FFFU, 0xFFFFFFFFU, 0x00000000U, 0xFFFF0000U,
640 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
641 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
642 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
643 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
644 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
645 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
646 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
647 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
648 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
649 0x00001FFFU, 0x00000000U, 0xFFFF0000U, 0x3FFFFFFFU,
650 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
651 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
652 0xFFFF1FFFU, 0x00000FFFU, 0xFFFFFFFFU, 0x80007FFFU,
653 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU,
654 0xFF800000U, 0xFFFFFFFCU, 0xFFFFFFFFU, 0xFFFFFFFFU,
655 0xFFFFF9FFU, 0xFFFFFFFFU, 0x1FFFFFFFU, 0xFFFE0000U,
656 0xFFFFF7BBU, 0x00000007U, 0xFFFFFFFFU, 0x000FFFFFU,
657 0xFFFFFFFCU, 0x000FFFFFU, 0x03FF0000U, 0x68FC0000U,
658 0xFFFFFFFFU, 0xFFFF003FU, 0x0000007FU, 0x1FFFFFFFU,
659 0xFFFFFFF0U, 0x0007FFFFU, 0x03FF8000U, 0x7FFFFFDFU,
660 0xFFFFFFFFU, 0x000001FFU, 0x03FF0FF7U, 0xC47FFFFFU,
661 0xFFFFFFFFU, 0x3E62FFFFU, 0x38000005U, 0x001C07FFU,
662 0x007E7E7EU, 0xFFFF7F7FU, 0xF7FFFFFFU, 0xFFFF03FFU,
663 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF0007U,
664 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
665 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
666 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
667 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU,
668 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
669 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
670 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
671 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
672 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU,
673 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U,
674 0xA0F8007FU, 0x5F7FFDFFU, 0xFFFFFFDBU, 0xFFFFFFFFU,
675 0xFFFFFFFFU, 0x0003FFFFU, 0xFFF80000U, 0xFFFFFFFFU,
676 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
677 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
678 0xFFFFFFFFU, 0x3FFFFFFFU, 0xFFFF0000U, 0xFFFFFFFFU,
679 0xFFFCFFFFU, 0xFFFFFFFFU, 0x000000FFU, 0x0FFF0000U,
680 0x00000000U, 0x00000000U, 0x00000000U, 0xFFDF0000U,
681 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU,
682 0x03FF0000U, 0x07FFFFFEU, 0x07FFFFFEU, 0xFFFFFFC0U,
683 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x00000000U,
684 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U,
685 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
686 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x001FFFFFU,
687 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
688 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
689 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x00000000U,
690 0xFFFFFFFFU, 0xFFFFE000U, 0xFFFF07FFU, 0x003FFFFFU,
691 0x3FFFFFFFU, 0xFFFFFFFFU, 0x003EFF0FU, 0x00000000U,
692 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
693 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU,
694 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF000FU,
695 0xFFB7F7FFU, 0x1BFBFFFBU, 0xFFFFFFFFU, 0x000FFFFFU,
696 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
697 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
698 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU,
699 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U,
700 0xFFFFFD3FU, 0x91BFFFFFU, 0x003FFFFFU, 0x007FFFFFU,
701 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x0037FFFFU,
702 0x003FFFFFU, 0x03FFFFFFU, 0x03FFFFFFU, 0x00000000U,
703 0xFFFFFFFFU, 0xC0FFFFFFU, 0x00000000U, 0x00000000U,
704 0xFEEF0001U, 0x003FFFFFU, 0x00000000U, 0x1FFFFFFFU,
705 0x1FFFFFFFU, 0x00000000U, 0xFFFFFEFFU, 0x0000001FU,
706 0xFFFFFFFFU, 0x003FFFFFU, 0x003FFFFFU, 0x0007FFFFU,
707 0x0003FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
708 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U,
709 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
710 0xFFFFFFFFU, 0x03FF000FU, 0xFFFFFFFFU, 0xFFFF803FU,
711 0x0000003FU, 0x00000000U, 0x00000000U, 0x00000000U,
712 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
713 0xFFFFFFFFU, 0x000303FFU, 0x000000FCU, 0x00000000U,
714 0x1FFFFFFFU, 0xFFFF0080U, 0x0000003FU, 0xFFFF0000U,
715 0x00000003U, 0xFFFF0000U, 0x0000001FU, 0x007FFFFFU,
716 0xFFFFFFF8U, 0x00FFFFFFU, 0x00000000U, 0x0026FFC0U,
717 0xFFFFFFF8U, 0x0000FFFFU, 0xFFFF0000U, 0x03FF01FFU,
718 0xFFFFFFF8U, 0xFFC0007FU, 0xFFFF0090U, 0x0047FFFFU,
719 0xFFFFFFF8U, 0x0007FFFFU, 0x17FF001EU, 0x00000000U,
720 0xFFFBFFFFU, 0x80000FFFU, 0x00000001U, 0x00000000U,
721 0xBFFFBD7FU, 0xFFFF01FFU, 0x7FFFFFFFU, 0x03FF0000U,
722 0xFFF99FE0U, 0x23EDFDFFU, 0xE0010000U, 0x00000003U,
723 0xFFFF4BFFU, 0x00BFFFFFU, 0x000A0000U, 0x00000000U,
724 0xFFFFFFFFU, 0x001FFFFFU, 0x83FF0780U, 0x00000003U,
725 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF00B0U, 0x00000000U,
726 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
727 0xFFFFFFFFU, 0x00007FFFU, 0x0F000000U, 0x00000000U,
728 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF0010U, 0x00000000U,
729 0xFFFFFFFFU, 0x010007FFU, 0xFFFF03FFU, 0x0000000FU,
730 0x07FFFFFFU, 0x03FF0000U, 0x0000007FU, 0x00000000U,
731 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
732 0xFFFFFFFFU, 0x00000FFFU, 0x00000000U, 0x00000000U,
733 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800003FFU,
734 0xFF6FF27FU, 0x8000FFFFU, 0x03FF0002U, 0x00000000U,
735 0x00000000U, 0xFFFFFCFFU, 0x0001FFFFU, 0x0000000AU,
736 0xFFFFF801U, 0x0407FFFFU, 0xF0010000U, 0xFFFFFFFFU,
737 0x200003FFU, 0xFFFF0000U, 0xFFFFFFFFU, 0x01FFFFFFU,
738 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
739 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FF0001U,
740 0xFFFFFDFFU, 0x00007FFFU, 0x03FF0001U, 0xFFFC0000U,
741 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
742 0xFFFFFB7FU, 0x0001FFFFU, 0x03FF0040U, 0xFFFFFDBFU,
743 0x010003FFU, 0xFFFF03FFU, 0x0FFFFFFFU, 0x000003FFU,
744 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
745 0x00000000U, 0x00000000U, 0x00000000U, 0x0007FFFFU,
746 0xFFFDFFF4U, 0x000FFFFFU, 0x03FF0000U, 0x00000000U,
747 0x00000000U, 0x00010000U, 0x00000000U, 0x00000000U,
748 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
749 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
750 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
751 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
752 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00007FFFU,
753 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
754 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
755 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
756 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
757 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
758 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
759 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU,
760 0xFFFFFFFFU, 0x0000FFFFU, 0x0000007EU, 0xFFFFFFFFU,
761 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
762 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
763 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
764 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
765 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
766 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
767 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
768 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U,
769 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
770 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
771 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
772 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
773 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
774 0x3FFFFFFFU, 0x03FF0000U, 0x00000000U, 0x00000000U,
775 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
776 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU,
777 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x00003FFFU,
778 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF000FU, 0xE0FFFFF8U,
779 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
780 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
781 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
782 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FF1FFFU,
783 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
784 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU,
785 0x00000000U, 0xF9FFFFFFU, 0x000FFFFFU, 0x00000000U,
786 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000107FFU, 0x00000000U,
787 0xFFF80000U, 0x00000000U, 0x00000000U, 0x007C000BU,
788 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
789 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x80000000U,
790 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
791 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
792 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
793 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
794 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
795 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U,
796 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
797 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
798 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U,
799 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
800 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
801 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU,
802 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
803 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
804 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU,
805 0x03FF01FFU, 0x00000000U, 0x00000000U, 0x00000000U,
806 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
807 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
808 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
809 0x00000000U, 0x00000000U, 0xFFC00000U, 0x03FFFFFFU,
810 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
811 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
812 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU,
813 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU,
814 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU,
815 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
816 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
817 0xFFFFFFFFU, 0xFFFFFF3FU, 0xF7FFFFFDU, 0xF7FFFFFFU,
818 0xFFDFFFFFU, 0xFFDFFFFFU, 0xFFFF7FFFU, 0xFFFF7FFFU,
819 0xFFFFFDFFU, 0xFFFFFDFFU, 0xFFFFCFF7U, 0xFFFFFFFFU,
820 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
821 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
822 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U,
823 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
824 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x00003FFFU,
825 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
826 0xFFFFFFFFU, 0x3F801FFFU, 0x000043FFU, 0x00000000U,
827 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
828 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
829 0xFFFF0000U, 0x00003FFFU, 0xFFFFFFFFU, 0x03FF0FFFU,
830 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
831 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
832 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
833 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FF0FFFU,
834 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
835 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x07FF3FFFU,
836 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
837 0x00000000U, 0x00000000U, 0x7FFFFFFFU, 0xC01F3FB7U,
838 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
839 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU,
840 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
841 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000001FU, 0x00000000U,
842 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF080FU, 0x00000000U,
843 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
844 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U,
845 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00000000U,
846 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
847 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
848 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
849 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
850 0xFFFF0000U, 0xFFFF1FFFU, 0xFFFF03FFU, 0xFFFF03FFU,
851 0x000007FFU, 0x00000020U, 0x00000000U, 0xFFFFFFC0U,
852 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
853 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
854 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
855 0x00000000U, 0x00000000U, 0x00000000U, 0x03FF0000U,
856 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
857 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U,
858 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
859 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
860 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
861 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
862 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
863 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
864 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
865 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
866 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
867 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
868 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
869 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
870 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
871 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF0001U,
872 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U,
873 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
874 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
875 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
876 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
877 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
878 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
879 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
880 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
881 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
882 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU,
883 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
884 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU,
885 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
886 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
887 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
888 }
889};
diff --git a/gl/unictype/ctype_alpha.c b/gl/unictype/ctype_alpha.c
new file mode 100644
index 00000000..9beeb03f
--- /dev/null
+++ b/gl/unictype/ctype_alpha.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_alpha table. */
26#include "ctype_alpha.h"
27
28bool
29uc_is_alpha (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_alpha, uc);
32}
diff --git a/gl/unictype/ctype_alpha.h b/gl/unictype/ctype_alpha.h
new file mode 100644
index 00000000..39f2f09a
--- /dev/null
+++ b/gl/unictype/ctype_alpha.h
@@ -0,0 +1,889 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[4];
29 short level2[4 << 7];
30 unsigned int level3[83 << 4];
31 }
32u_is_alpha =
33{
34 { 4 },
35 {
36 5 * sizeof (int) / sizeof (short) + 0,
37 5 * sizeof (int) / sizeof (short) + 128,
38 5 * sizeof (int) / sizeof (short) + 256,
39 5 * sizeof (int) / sizeof (short) + 384
40 },
41 {
42 5 + 512 * sizeof (short) / sizeof (int) + 0,
43 5 + 512 * sizeof (short) / sizeof (int) + 16,
44 5 + 512 * sizeof (short) / sizeof (int) + 32,
45 5 + 512 * sizeof (short) / sizeof (int) + 48,
46 5 + 512 * sizeof (short) / sizeof (int) + 64,
47 5 + 512 * sizeof (short) / sizeof (int) + 80,
48 5 + 512 * sizeof (short) / sizeof (int) + 96,
49 5 + 512 * sizeof (short) / sizeof (int) + 112,
50 5 + 512 * sizeof (short) / sizeof (int) + 128,
51 5 + 512 * sizeof (short) / sizeof (int) + 144,
52 5 + 512 * sizeof (short) / sizeof (int) + 160,
53 5 + 512 * sizeof (short) / sizeof (int) + 176,
54 5 + 512 * sizeof (short) / sizeof (int) + 192,
55 5 + 512 * sizeof (short) / sizeof (int) + 208,
56 5 + 512 * sizeof (short) / sizeof (int) + 224,
57 5 + 512 * sizeof (short) / sizeof (int) + 240,
58 5 + 512 * sizeof (short) / sizeof (int) + 256,
59 -1,
60 5 + 512 * sizeof (short) / sizeof (int) + 272,
61 -1,
62 -1,
63 -1,
64 5 + 512 * sizeof (short) / sizeof (int) + 288,
65 5 + 512 * sizeof (short) / sizeof (int) + 304,
66 5 + 512 * sizeof (short) / sizeof (int) + 320,
67 -1,
68 5 + 512 * sizeof (short) / sizeof (int) + 336,
69 5 + 512 * sizeof (short) / sizeof (int) + 336,
70 5 + 512 * sizeof (short) / sizeof (int) + 336,
71 5 + 512 * sizeof (short) / sizeof (int) + 336,
72 5 + 512 * sizeof (short) / sizeof (int) + 336,
73 5 + 512 * sizeof (short) / sizeof (int) + 336,
74 5 + 512 * sizeof (short) / sizeof (int) + 336,
75 5 + 512 * sizeof (short) / sizeof (int) + 336,
76 5 + 512 * sizeof (short) / sizeof (int) + 336,
77 5 + 512 * sizeof (short) / sizeof (int) + 336,
78 5 + 512 * sizeof (short) / sizeof (int) + 336,
79 5 + 512 * sizeof (short) / sizeof (int) + 336,
80 5 + 512 * sizeof (short) / sizeof (int) + 352,
81 5 + 512 * sizeof (short) / sizeof (int) + 336,
82 5 + 512 * sizeof (short) / sizeof (int) + 336,
83 5 + 512 * sizeof (short) / sizeof (int) + 336,
84 5 + 512 * sizeof (short) / sizeof (int) + 336,
85 5 + 512 * sizeof (short) / sizeof (int) + 336,
86 5 + 512 * sizeof (short) / sizeof (int) + 336,
87 5 + 512 * sizeof (short) / sizeof (int) + 336,
88 5 + 512 * sizeof (short) / sizeof (int) + 336,
89 5 + 512 * sizeof (short) / sizeof (int) + 336,
90 5 + 512 * sizeof (short) / sizeof (int) + 336,
91 5 + 512 * sizeof (short) / sizeof (int) + 336,
92 5 + 512 * sizeof (short) / sizeof (int) + 336,
93 5 + 512 * sizeof (short) / sizeof (int) + 336,
94 5 + 512 * sizeof (short) / sizeof (int) + 336,
95 5 + 512 * sizeof (short) / sizeof (int) + 336,
96 5 + 512 * sizeof (short) / sizeof (int) + 336,
97 5 + 512 * sizeof (short) / sizeof (int) + 336,
98 5 + 512 * sizeof (short) / sizeof (int) + 336,
99 5 + 512 * sizeof (short) / sizeof (int) + 336,
100 5 + 512 * sizeof (short) / sizeof (int) + 336,
101 5 + 512 * sizeof (short) / sizeof (int) + 336,
102 5 + 512 * sizeof (short) / sizeof (int) + 336,
103 5 + 512 * sizeof (short) / sizeof (int) + 336,
104 5 + 512 * sizeof (short) / sizeof (int) + 336,
105 5 + 512 * sizeof (short) / sizeof (int) + 336,
106 5 + 512 * sizeof (short) / sizeof (int) + 336,
107 5 + 512 * sizeof (short) / sizeof (int) + 336,
108 5 + 512 * sizeof (short) / sizeof (int) + 336,
109 5 + 512 * sizeof (short) / sizeof (int) + 336,
110 5 + 512 * sizeof (short) / sizeof (int) + 336,
111 5 + 512 * sizeof (short) / sizeof (int) + 336,
112 5 + 512 * sizeof (short) / sizeof (int) + 336,
113 5 + 512 * sizeof (short) / sizeof (int) + 336,
114 5 + 512 * sizeof (short) / sizeof (int) + 336,
115 5 + 512 * sizeof (short) / sizeof (int) + 336,
116 5 + 512 * sizeof (short) / sizeof (int) + 336,
117 5 + 512 * sizeof (short) / sizeof (int) + 336,
118 5 + 512 * sizeof (short) / sizeof (int) + 336,
119 5 + 512 * sizeof (short) / sizeof (int) + 336,
120 5 + 512 * sizeof (short) / sizeof (int) + 336,
121 5 + 512 * sizeof (short) / sizeof (int) + 336,
122 5 + 512 * sizeof (short) / sizeof (int) + 336,
123 5 + 512 * sizeof (short) / sizeof (int) + 336,
124 5 + 512 * sizeof (short) / sizeof (int) + 368,
125 5 + 512 * sizeof (short) / sizeof (int) + 384,
126 5 + 512 * sizeof (short) / sizeof (int) + 400,
127 5 + 512 * sizeof (short) / sizeof (int) + 416,
128 5 + 512 * sizeof (short) / sizeof (int) + 336,
129 5 + 512 * sizeof (short) / sizeof (int) + 336,
130 5 + 512 * sizeof (short) / sizeof (int) + 336,
131 5 + 512 * sizeof (short) / sizeof (int) + 336,
132 5 + 512 * sizeof (short) / sizeof (int) + 336,
133 5 + 512 * sizeof (short) / sizeof (int) + 336,
134 5 + 512 * sizeof (short) / sizeof (int) + 336,
135 5 + 512 * sizeof (short) / sizeof (int) + 336,
136 5 + 512 * sizeof (short) / sizeof (int) + 336,
137 5 + 512 * sizeof (short) / sizeof (int) + 336,
138 5 + 512 * sizeof (short) / sizeof (int) + 336,
139 5 + 512 * sizeof (short) / sizeof (int) + 336,
140 5 + 512 * sizeof (short) / sizeof (int) + 336,
141 5 + 512 * sizeof (short) / sizeof (int) + 336,
142 5 + 512 * sizeof (short) / sizeof (int) + 336,
143 5 + 512 * sizeof (short) / sizeof (int) + 336,
144 5 + 512 * sizeof (short) / sizeof (int) + 336,
145 5 + 512 * sizeof (short) / sizeof (int) + 336,
146 5 + 512 * sizeof (short) / sizeof (int) + 336,
147 5 + 512 * sizeof (short) / sizeof (int) + 336,
148 5 + 512 * sizeof (short) / sizeof (int) + 336,
149 5 + 512 * sizeof (short) / sizeof (int) + 432,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 5 + 512 * sizeof (short) / sizeof (int) + 448,
167 5 + 512 * sizeof (short) / sizeof (int) + 464,
168 5 + 512 * sizeof (short) / sizeof (int) + 480,
169 5 + 512 * sizeof (short) / sizeof (int) + 496,
170 5 + 512 * sizeof (short) / sizeof (int) + 512,
171 5 + 512 * sizeof (short) / sizeof (int) + 528,
172 5 + 512 * sizeof (short) / sizeof (int) + 544,
173 5 + 512 * sizeof (short) / sizeof (int) + 560,
174 5 + 512 * sizeof (short) / sizeof (int) + 576,
175 5 + 512 * sizeof (short) / sizeof (int) + 592,
176 5 + 512 * sizeof (short) / sizeof (int) + 608,
177 5 + 512 * sizeof (short) / sizeof (int) + 624,
178 5 + 512 * sizeof (short) / sizeof (int) + 640,
179 5 + 512 * sizeof (short) / sizeof (int) + 656,
180 5 + 512 * sizeof (short) / sizeof (int) + 672,
181 5 + 512 * sizeof (short) / sizeof (int) + 688,
182 5 + 512 * sizeof (short) / sizeof (int) + 704,
183 5 + 512 * sizeof (short) / sizeof (int) + 720,
184 5 + 512 * sizeof (short) / sizeof (int) + 736,
185 5 + 512 * sizeof (short) / sizeof (int) + 752,
186 5 + 512 * sizeof (short) / sizeof (int) + 336,
187 5 + 512 * sizeof (short) / sizeof (int) + 768,
188 5 + 512 * sizeof (short) / sizeof (int) + 784,
189 -1,
190 -1,
191 -1,
192 -1,
193 5 + 512 * sizeof (short) / sizeof (int) + 800,
194 5 + 512 * sizeof (short) / sizeof (int) + 336,
195 5 + 512 * sizeof (short) / sizeof (int) + 336,
196 5 + 512 * sizeof (short) / sizeof (int) + 816,
197 5 + 512 * sizeof (short) / sizeof (int) + 336,
198 5 + 512 * sizeof (short) / sizeof (int) + 336,
199 5 + 512 * sizeof (short) / sizeof (int) + 336,
200 5 + 512 * sizeof (short) / sizeof (int) + 336,
201 5 + 512 * sizeof (short) / sizeof (int) + 336,
202 5 + 512 * sizeof (short) / sizeof (int) + 336,
203 5 + 512 * sizeof (short) / sizeof (int) + 832,
204 5 + 512 * sizeof (short) / sizeof (int) + 336,
205 5 + 512 * sizeof (short) / sizeof (int) + 848,
206 -1,
207 -1,
208 -1,
209 -1,
210 -1,
211 -1,
212 -1,
213 -1,
214 -1,
215 -1,
216 -1,
217 -1,
218 5 + 512 * sizeof (short) / sizeof (int) + 864,
219 -1,
220 -1,
221 -1,
222 5 + 512 * sizeof (short) / sizeof (int) + 336,
223 5 + 512 * sizeof (short) / sizeof (int) + 880,
224 5 + 512 * sizeof (short) / sizeof (int) + 896,
225 5 + 512 * sizeof (short) / sizeof (int) + 912,
226 5 + 512 * sizeof (short) / sizeof (int) + 336,
227 5 + 512 * sizeof (short) / sizeof (int) + 336,
228 5 + 512 * sizeof (short) / sizeof (int) + 336,
229 5 + 512 * sizeof (short) / sizeof (int) + 336,
230 5 + 512 * sizeof (short) / sizeof (int) + 336,
231 5 + 512 * sizeof (short) / sizeof (int) + 336,
232 5 + 512 * sizeof (short) / sizeof (int) + 336,
233 5 + 512 * sizeof (short) / sizeof (int) + 336,
234 5 + 512 * sizeof (short) / sizeof (int) + 336,
235 5 + 512 * sizeof (short) / sizeof (int) + 336,
236 5 + 512 * sizeof (short) / sizeof (int) + 336,
237 5 + 512 * sizeof (short) / sizeof (int) + 336,
238 5 + 512 * sizeof (short) / sizeof (int) + 336,
239 5 + 512 * sizeof (short) / sizeof (int) + 336,
240 5 + 512 * sizeof (short) / sizeof (int) + 928,
241 -1,
242 -1,
243 -1,
244 -1,
245 -1,
246 -1,
247 -1,
248 -1,
249 -1,
250 -1,
251 -1,
252 -1,
253 -1,
254 -1,
255 -1,
256 -1,
257 5 + 512 * sizeof (short) / sizeof (int) + 944,
258 5 + 512 * sizeof (short) / sizeof (int) + 960,
259 5 + 512 * sizeof (short) / sizeof (int) + 976,
260 -1,
261 -1,
262 -1,
263 -1,
264 5 + 512 * sizeof (short) / sizeof (int) + 992,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 -1,
271 -1,
272 5 + 512 * sizeof (short) / sizeof (int) + 1008,
273 -1,
274 -1,
275 -1,
276 5 + 512 * sizeof (short) / sizeof (int) + 1024,
277 5 + 512 * sizeof (short) / sizeof (int) + 1040,
278 -1,
279 -1,
280 -1,
281 5 + 512 * sizeof (short) / sizeof (int) + 1056,
282 5 + 512 * sizeof (short) / sizeof (int) + 1072,
283 5 + 512 * sizeof (short) / sizeof (int) + 1088,
284 5 + 512 * sizeof (short) / sizeof (int) + 1104,
285 5 + 512 * sizeof (short) / sizeof (int) + 1120,
286 5 + 512 * sizeof (short) / sizeof (int) + 1136,
287 -1,
288 -1,
289 5 + 512 * sizeof (short) / sizeof (int) + 1152,
290 5 + 512 * sizeof (short) / sizeof (int) + 1168,
291 -1,
292 -1,
293 -1,
294 -1,
295 5 + 512 * sizeof (short) / sizeof (int) + 1184,
296 -1,
297 -1,
298 5 + 512 * sizeof (short) / sizeof (int) + 336,
299 5 + 512 * sizeof (short) / sizeof (int) + 336,
300 5 + 512 * sizeof (short) / sizeof (int) + 336,
301 5 + 512 * sizeof (short) / sizeof (int) + 336,
302 5 + 512 * sizeof (short) / sizeof (int) + 336,
303 5 + 512 * sizeof (short) / sizeof (int) + 336,
304 5 + 512 * sizeof (short) / sizeof (int) + 336,
305 5 + 512 * sizeof (short) / sizeof (int) + 336,
306 5 + 512 * sizeof (short) / sizeof (int) + 336,
307 5 + 512 * sizeof (short) / sizeof (int) + 336,
308 5 + 512 * sizeof (short) / sizeof (int) + 336,
309 5 + 512 * sizeof (short) / sizeof (int) + 336,
310 5 + 512 * sizeof (short) / sizeof (int) + 336,
311 5 + 512 * sizeof (short) / sizeof (int) + 336,
312 5 + 512 * sizeof (short) / sizeof (int) + 336,
313 5 + 512 * sizeof (short) / sizeof (int) + 336,
314 5 + 512 * sizeof (short) / sizeof (int) + 336,
315 5 + 512 * sizeof (short) / sizeof (int) + 336,
316 5 + 512 * sizeof (short) / sizeof (int) + 336,
317 5 + 512 * sizeof (short) / sizeof (int) + 336,
318 5 + 512 * sizeof (short) / sizeof (int) + 336,
319 5 + 512 * sizeof (short) / sizeof (int) + 336,
320 5 + 512 * sizeof (short) / sizeof (int) + 336,
321 5 + 512 * sizeof (short) / sizeof (int) + 336,
322 5 + 512 * sizeof (short) / sizeof (int) + 336,
323 5 + 512 * sizeof (short) / sizeof (int) + 336,
324 5 + 512 * sizeof (short) / sizeof (int) + 336,
325 5 + 512 * sizeof (short) / sizeof (int) + 336,
326 5 + 512 * sizeof (short) / sizeof (int) + 336,
327 5 + 512 * sizeof (short) / sizeof (int) + 336,
328 5 + 512 * sizeof (short) / sizeof (int) + 336,
329 5 + 512 * sizeof (short) / sizeof (int) + 336,
330 5 + 512 * sizeof (short) / sizeof (int) + 336,
331 5 + 512 * sizeof (short) / sizeof (int) + 336,
332 5 + 512 * sizeof (short) / sizeof (int) + 336,
333 5 + 512 * sizeof (short) / sizeof (int) + 336,
334 5 + 512 * sizeof (short) / sizeof (int) + 336,
335 5 + 512 * sizeof (short) / sizeof (int) + 336,
336 5 + 512 * sizeof (short) / sizeof (int) + 336,
337 5 + 512 * sizeof (short) / sizeof (int) + 336,
338 5 + 512 * sizeof (short) / sizeof (int) + 336,
339 5 + 512 * sizeof (short) / sizeof (int) + 336,
340 5 + 512 * sizeof (short) / sizeof (int) + 336,
341 5 + 512 * sizeof (short) / sizeof (int) + 336,
342 5 + 512 * sizeof (short) / sizeof (int) + 336,
343 5 + 512 * sizeof (short) / sizeof (int) + 336,
344 5 + 512 * sizeof (short) / sizeof (int) + 336,
345 5 + 512 * sizeof (short) / sizeof (int) + 336,
346 5 + 512 * sizeof (short) / sizeof (int) + 336,
347 5 + 512 * sizeof (short) / sizeof (int) + 336,
348 5 + 512 * sizeof (short) / sizeof (int) + 336,
349 5 + 512 * sizeof (short) / sizeof (int) + 336,
350 5 + 512 * sizeof (short) / sizeof (int) + 336,
351 5 + 512 * sizeof (short) / sizeof (int) + 336,
352 5 + 512 * sizeof (short) / sizeof (int) + 336,
353 5 + 512 * sizeof (short) / sizeof (int) + 336,
354 5 + 512 * sizeof (short) / sizeof (int) + 336,
355 5 + 512 * sizeof (short) / sizeof (int) + 336,
356 5 + 512 * sizeof (short) / sizeof (int) + 336,
357 5 + 512 * sizeof (short) / sizeof (int) + 336,
358 5 + 512 * sizeof (short) / sizeof (int) + 336,
359 5 + 512 * sizeof (short) / sizeof (int) + 336,
360 5 + 512 * sizeof (short) / sizeof (int) + 336,
361 5 + 512 * sizeof (short) / sizeof (int) + 336,
362 5 + 512 * sizeof (short) / sizeof (int) + 336,
363 5 + 512 * sizeof (short) / sizeof (int) + 336,
364 5 + 512 * sizeof (short) / sizeof (int) + 336,
365 5 + 512 * sizeof (short) / sizeof (int) + 336,
366 5 + 512 * sizeof (short) / sizeof (int) + 336,
367 5 + 512 * sizeof (short) / sizeof (int) + 336,
368 5 + 512 * sizeof (short) / sizeof (int) + 336,
369 5 + 512 * sizeof (short) / sizeof (int) + 336,
370 5 + 512 * sizeof (short) / sizeof (int) + 336,
371 5 + 512 * sizeof (short) / sizeof (int) + 336,
372 5 + 512 * sizeof (short) / sizeof (int) + 336,
373 5 + 512 * sizeof (short) / sizeof (int) + 336,
374 5 + 512 * sizeof (short) / sizeof (int) + 336,
375 5 + 512 * sizeof (short) / sizeof (int) + 336,
376 5 + 512 * sizeof (short) / sizeof (int) + 336,
377 5 + 512 * sizeof (short) / sizeof (int) + 336,
378 5 + 512 * sizeof (short) / sizeof (int) + 336,
379 5 + 512 * sizeof (short) / sizeof (int) + 336,
380 5 + 512 * sizeof (short) / sizeof (int) + 336,
381 5 + 512 * sizeof (short) / sizeof (int) + 1200,
382 5 + 512 * sizeof (short) / sizeof (int) + 336,
383 5 + 512 * sizeof (short) / sizeof (int) + 336,
384 5 + 512 * sizeof (short) / sizeof (int) + 336,
385 5 + 512 * sizeof (short) / sizeof (int) + 336,
386 5 + 512 * sizeof (short) / sizeof (int) + 336,
387 5 + 512 * sizeof (short) / sizeof (int) + 336,
388 5 + 512 * sizeof (short) / sizeof (int) + 336,
389 5 + 512 * sizeof (short) / sizeof (int) + 336,
390 5 + 512 * sizeof (short) / sizeof (int) + 1216,
391 5 + 512 * sizeof (short) / sizeof (int) + 336,
392 5 + 512 * sizeof (short) / sizeof (int) + 336,
393 5 + 512 * sizeof (short) / sizeof (int) + 336,
394 5 + 512 * sizeof (short) / sizeof (int) + 336,
395 5 + 512 * sizeof (short) / sizeof (int) + 336,
396 5 + 512 * sizeof (short) / sizeof (int) + 336,
397 5 + 512 * sizeof (short) / sizeof (int) + 336,
398 5 + 512 * sizeof (short) / sizeof (int) + 336,
399 5 + 512 * sizeof (short) / sizeof (int) + 336,
400 5 + 512 * sizeof (short) / sizeof (int) + 336,
401 5 + 512 * sizeof (short) / sizeof (int) + 1232,
402 5 + 512 * sizeof (short) / sizeof (int) + 336,
403 5 + 512 * sizeof (short) / sizeof (int) + 336,
404 5 + 512 * sizeof (short) / sizeof (int) + 336,
405 5 + 512 * sizeof (short) / sizeof (int) + 336,
406 5 + 512 * sizeof (short) / sizeof (int) + 336,
407 5 + 512 * sizeof (short) / sizeof (int) + 336,
408 5 + 512 * sizeof (short) / sizeof (int) + 336,
409 5 + 512 * sizeof (short) / sizeof (int) + 336,
410 5 + 512 * sizeof (short) / sizeof (int) + 336,
411 5 + 512 * sizeof (short) / sizeof (int) + 336,
412 5 + 512 * sizeof (short) / sizeof (int) + 336,
413 5 + 512 * sizeof (short) / sizeof (int) + 336,
414 5 + 512 * sizeof (short) / sizeof (int) + 336,
415 5 + 512 * sizeof (short) / sizeof (int) + 1248,
416 5 + 512 * sizeof (short) / sizeof (int) + 336,
417 5 + 512 * sizeof (short) / sizeof (int) + 1264,
418 -1,
419 -1,
420 -1,
421 -1,
422 5 + 512 * sizeof (short) / sizeof (int) + 336,
423 5 + 512 * sizeof (short) / sizeof (int) + 1280,
424 -1,
425 -1,
426 5 + 512 * sizeof (short) / sizeof (int) + 336,
427 5 + 512 * sizeof (short) / sizeof (int) + 336,
428 5 + 512 * sizeof (short) / sizeof (int) + 336,
429 5 + 512 * sizeof (short) / sizeof (int) + 336,
430 5 + 512 * sizeof (short) / sizeof (int) + 336,
431 5 + 512 * sizeof (short) / sizeof (int) + 336,
432 5 + 512 * sizeof (short) / sizeof (int) + 336,
433 5 + 512 * sizeof (short) / sizeof (int) + 336,
434 5 + 512 * sizeof (short) / sizeof (int) + 336,
435 5 + 512 * sizeof (short) / sizeof (int) + 1296,
436 5 + 512 * sizeof (short) / sizeof (int) + 336,
437 5 + 512 * sizeof (short) / sizeof (int) + 336,
438 5 + 512 * sizeof (short) / sizeof (int) + 336,
439 5 + 512 * sizeof (short) / sizeof (int) + 336,
440 5 + 512 * sizeof (short) / sizeof (int) + 336,
441 5 + 512 * sizeof (short) / sizeof (int) + 336,
442 5 + 512 * sizeof (short) / sizeof (int) + 336,
443 5 + 512 * sizeof (short) / sizeof (int) + 336,
444 5 + 512 * sizeof (short) / sizeof (int) + 336,
445 5 + 512 * sizeof (short) / sizeof (int) + 336,
446 5 + 512 * sizeof (short) / sizeof (int) + 336,
447 5 + 512 * sizeof (short) / sizeof (int) + 336,
448 5 + 512 * sizeof (short) / sizeof (int) + 336,
449 5 + 512 * sizeof (short) / sizeof (int) + 336,
450 5 + 512 * sizeof (short) / sizeof (int) + 336,
451 5 + 512 * sizeof (short) / sizeof (int) + 336,
452 5 + 512 * sizeof (short) / sizeof (int) + 1312,
453 -1,
454 -1,
455 -1,
456 -1,
457 -1,
458 -1,
459 -1,
460 -1,
461 -1,
462 -1,
463 -1,
464 -1,
465 -1,
466 -1,
467 -1,
468 -1,
469 -1,
470 -1,
471 -1,
472 -1,
473 -1,
474 -1,
475 -1,
476 -1,
477 -1,
478 -1,
479 -1,
480 -1,
481 -1,
482 -1,
483 -1,
484 -1,
485 -1,
486 -1,
487 -1,
488 -1,
489 -1,
490 -1,
491 -1,
492 -1,
493 -1,
494 -1,
495 -1,
496 -1,
497 -1,
498 -1,
499 -1,
500 -1,
501 -1,
502 -1,
503 -1,
504 -1,
505 -1,
506 -1,
507 -1,
508 -1,
509 -1,
510 -1,
511 -1,
512 -1,
513 -1,
514 -1,
515 -1,
516 -1,
517 -1,
518 -1,
519 -1,
520 -1,
521 -1,
522 -1,
523 -1,
524 -1,
525 -1,
526 -1,
527 -1,
528 -1,
529 -1,
530 -1,
531 -1,
532 -1,
533 -1,
534 -1,
535 -1,
536 -1,
537 -1,
538 -1,
539 -1,
540 -1,
541 -1,
542 -1,
543 -1,
544 -1,
545 -1,
546 -1,
547 -1,
548 -1,
549 -1,
550 -1,
551 -1,
552 -1,
553 -1
554 },
555 {
556 0x00000000U, 0x00000000U, 0x07FFFFFEU, 0x07FFFFFEU,
557 0x00000000U, 0x04200400U, 0xFF7FFFFFU, 0xFF7FFFFFU,
558 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
559 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
560 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
561 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0003FFC3U, 0x0000501FU,
562 0x00000000U, 0x00000000U, 0x00000020U, 0xBCDF0000U,
563 0xFFFFD740U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFBFFFFFU,
564 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
565 0xFFFFFC03U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
566 0xFFFFFFFFU, 0xFFFEFFFFU, 0x027FFFFFU, 0xFFFFFFFFU,
567 0x000001FFU, 0x00000000U, 0xFFFF0000U, 0x000787FFU,
568 0x00000000U, 0xFFFFFFFFU, 0x000007FFU, 0xFFFEC3FFU,
569 0xFFFFFFFFU, 0xFFFFFFFFU, 0x002FFFFFU, 0x9FFFC060U,
570 0xFFFD0000U, 0x0000FFFFU, 0xFFFFE000U, 0xFFFFFFFFU,
571 0xFFFFFFFFU, 0x0002003FU, 0xFFFFFFFFU, 0x043007FFU,
572 0x043FFFFFU, 0x00000110U, 0x01FFFFFFU, 0xFFFF07FFU,
573 0x0000FEFFU, 0xFFFFFFFFU, 0x000003FFU, 0x00000000U,
574 0xFFFFFFF0U, 0x23FFFFFFU, 0xFF010000U, 0xFFFEFFC3U,
575 0xFFF99FE1U, 0x23C5FDFFU, 0xB0004000U, 0x1003FFC3U,
576 0xFFF987E0U, 0x036DFDFFU, 0x5E000000U, 0x001CFFC0U,
577 0xFFFBBFE0U, 0x23EDFDFFU, 0x00010000U, 0x0200FFC3U,
578 0xFFF99FE0U, 0x23EDFDFFU, 0xB0000000U, 0x0002FFC3U,
579 0xD63DC7E8U, 0x03FFC718U, 0x00010000U, 0x0000FFC0U,
580 0xFFFDDFE0U, 0x23FFFDFFU, 0x37000000U, 0x0000FFC3U,
581 0xFFFDDFE1U, 0x23EFFDFFU, 0x70000000U, 0x0006FFC3U,
582 0xFFFDDFF0U, 0x27FFFFFFU, 0x80704000U, 0xFC00FFC3U,
583 0xFC7FFFE0U, 0x2FFBFFFFU, 0x0000007FU, 0x0000FFC0U,
584 0xFFFFFFFEU, 0x07FF7FFFU, 0x03FF7FBFU, 0x00000000U,
585 0xFFFFF7D6U, 0x200DFFAFU, 0xF3FF005FU, 0x00000000U,
586 0x00000001U, 0x000003FFU, 0xFFFFFEFFU, 0x00001FFFU,
587 0x00001F00U, 0x00000000U, 0x00000000U, 0x00000000U,
588 0xFFFFFFFFU, 0x800007FFU, 0x3C3F03FFU, 0xFFE1C062U,
589 0x03FF4003U, 0xFFFFFFFFU, 0xFFFF20BFU, 0xF7FFFFFFU,
590 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
591 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
592 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU,
593 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU,
594 0xFF3DFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU, 0x00000000U,
595 0x0000FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU,
596 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
597 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
598 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
599 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
600 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF9FFFU,
601 0x07FFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFC7FFU,
602 0x8003FFFFU, 0x0003FFFFU, 0x0003FFFFU, 0x0001DFFFU,
603 0xFFFFFFFFU, 0x000FFFFFU, 0x10800000U, 0x000003FFU,
604 0x03FF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU,
605 0xFFFFFF9FU, 0xFFFF05FFU, 0xFFFFFFFFU, 0x003FFFFFU,
606 0x7FFFFFFFU, 0x00000000U, 0xFFFFFFC0U, 0x001F3FFFU,
607 0xFFFFFFFFU, 0xFFFF0FFFU, 0x03FF03FFU, 0x00000000U,
608 0x007FFFFFU, 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U,
609 0x03FF03FFU, 0x00000080U, 0x00000000U, 0x00000000U,
610 0xFFFFFFE0U, 0x000FFFFFU, 0x03FF1FE0U, 0x00000000U,
611 0xFFFFFFF8U, 0xFFFFC001U, 0xFFFFFFFFU, 0x0000003FU,
612 0xFFFFFFFFU, 0x0000000FU, 0xFFFFE3FFU, 0x3FFFFFFFU,
613 0xFFFF07FFU, 0xE7FFFFFFU, 0x00000000U, 0x046FDE00U,
614 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
615 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
616 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
617 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
618 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU,
619 0xFFFFFFFFU, 0x5FDFFFFFU, 0x0FCF1FDCU, 0x1FDC1FFFU,
620 0x00000000U, 0x00000000U, 0x00000000U, 0x80020000U,
621 0x1FFF0000U, 0x00000000U, 0x00000000U, 0x00000000U,
622 0x3E2FFC84U, 0xF3FFBF50U, 0x000043E0U, 0xFFFFFFFFU,
623 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U,
624 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
625 0xF0000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000003FFU,
626 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
627 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
628 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
629 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000C781FU,
630 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x000080FFU,
631 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0x00000000U,
632 0x00000000U, 0x00008000U, 0x00000000U, 0x00000000U,
633 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
634 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
635 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
636 0x000000E0U, 0x1F3E03FEU, 0xFFFFFFFEU, 0xFFFFFFFFU,
637 0xE07FFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU, 0xF7FFFFFFU,
638 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
639 0x00007FFFU, 0xFFFFFFFFU, 0x00000000U, 0xFFFF0000U,
640 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
641 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
642 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
643 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
644 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
645 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
646 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
647 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
648 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
649 0x00001FFFU, 0x00000000U, 0xFFFF0000U, 0x3FFFFFFFU,
650 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
651 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
652 0xFFFF1FFFU, 0x00000FFFU, 0xFFFFFFFFU, 0x80007FFFU,
653 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU,
654 0xFF800000U, 0xFFFFFFFCU, 0xFFFFFFFFU, 0xFFFFFFFFU,
655 0xFFFFF9FFU, 0xFFFFFFFFU, 0x1FFFFFFFU, 0xFFFE0000U,
656 0xFFFFF7BBU, 0x00000007U, 0xFFFFFFFFU, 0x000FFFFFU,
657 0xFFFFFFFCU, 0x000FFFFFU, 0x03FF0000U, 0x68FC0000U,
658 0xFFFFFFFFU, 0xFFFF003FU, 0x0000007FU, 0x1FFFFFFFU,
659 0xFFFFFFF0U, 0x0007FFFFU, 0x03FF8000U, 0x7FFFFFDFU,
660 0xFFFFFFFFU, 0x000001FFU, 0x03FF0FF7U, 0xC47FFFFFU,
661 0xFFFFFFFFU, 0x3E62FFFFU, 0x38000005U, 0x001C07FFU,
662 0x007E7E7EU, 0xFFFF7F7FU, 0xF7FFFFFFU, 0xFFFF03FFU,
663 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF0007U,
664 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
665 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
666 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
667 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU,
668 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
669 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
670 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
671 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
672 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU,
673 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U,
674 0xA0F8007FU, 0x5F7FFDFFU, 0xFFFFFFDBU, 0xFFFFFFFFU,
675 0xFFFFFFFFU, 0x0003FFFFU, 0xFFF80000U, 0xFFFFFFFFU,
676 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
677 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
678 0xFFFFFFFFU, 0x3FFFFFFFU, 0xFFFF0000U, 0xFFFFFFFFU,
679 0xFFFCFFFFU, 0xFFFFFFFFU, 0x000000FFU, 0x0FFF0000U,
680 0x00000000U, 0x00000000U, 0x00000000U, 0xFFDF0000U,
681 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU,
682 0x03FF0000U, 0x07FFFFFEU, 0x07FFFFFEU, 0xFFFFFFC0U,
683 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x00000000U,
684 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U,
685 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
686 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x001FFFFFU,
687 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
688 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
689 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x00000000U,
690 0xFFFFFFFFU, 0xFFFFE000U, 0xFFFF07FFU, 0x003FFFFFU,
691 0x3FFFFFFFU, 0xFFFFFFFFU, 0x003EFF0FU, 0x00000000U,
692 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
693 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU,
694 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF000FU,
695 0xFFB7F7FFU, 0x1BFBFFFBU, 0xFFFFFFFFU, 0x000FFFFFU,
696 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
697 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
698 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU,
699 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U,
700 0xFFFFFD3FU, 0x91BFFFFFU, 0x003FFFFFU, 0x007FFFFFU,
701 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x0037FFFFU,
702 0x003FFFFFU, 0x03FFFFFFU, 0x03FFFFFFU, 0x00000000U,
703 0xFFFFFFFFU, 0xC0FFFFFFU, 0x00000000U, 0x00000000U,
704 0xFEEF0001U, 0x003FFFFFU, 0x00000000U, 0x1FFFFFFFU,
705 0x1FFFFFFFU, 0x00000000U, 0xFFFFFEFFU, 0x0000001FU,
706 0xFFFFFFFFU, 0x003FFFFFU, 0x003FFFFFU, 0x0007FFFFU,
707 0x0003FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
708 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U,
709 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
710 0xFFFFFFFFU, 0x03FF000FU, 0xFFFFFFFFU, 0xFFFF803FU,
711 0x0000003FU, 0x00000000U, 0x00000000U, 0x00000000U,
712 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
713 0xFFFFFFFFU, 0x000303FFU, 0x000000FCU, 0x00000000U,
714 0x1FFFFFFFU, 0xFFFF0080U, 0x0000003FU, 0xFFFF0000U,
715 0x00000003U, 0xFFFF0000U, 0x0000001FU, 0x007FFFFFU,
716 0xFFFFFFF8U, 0x00FFFFFFU, 0x00000000U, 0x0026FFC0U,
717 0xFFFFFFF8U, 0x0000FFFFU, 0xFFFF0000U, 0x03FF01FFU,
718 0xFFFFFFF8U, 0xFFC0007FU, 0xFFFF0090U, 0x0047FFFFU,
719 0xFFFFFFF8U, 0x0007FFFFU, 0x17FF001EU, 0x00000000U,
720 0xFFFBFFFFU, 0x80000FFFU, 0x00000001U, 0x00000000U,
721 0xBFFFBD7FU, 0xFFFF01FFU, 0x7FFFFFFFU, 0x03FF0000U,
722 0xFFF99FE0U, 0x23EDFDFFU, 0xE0010000U, 0x00000003U,
723 0xFFFF4BFFU, 0x00BFFFFFU, 0x000A0000U, 0x00000000U,
724 0xFFFFFFFFU, 0x001FFFFFU, 0x83FF0780U, 0x00000003U,
725 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF00B0U, 0x00000000U,
726 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
727 0xFFFFFFFFU, 0x00007FFFU, 0x0F000000U, 0x00000000U,
728 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF0010U, 0x00000000U,
729 0xFFFFFFFFU, 0x010007FFU, 0xFFFF03FFU, 0x0000000FU,
730 0x07FFFFFFU, 0x03FF0000U, 0x0000007FU, 0x00000000U,
731 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
732 0xFFFFFFFFU, 0x00000FFFU, 0x00000000U, 0x00000000U,
733 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800003FFU,
734 0xFF6FF27FU, 0x8000FFFFU, 0x03FF0002U, 0x00000000U,
735 0x00000000U, 0xFFFFFCFFU, 0x0001FFFFU, 0x0000000AU,
736 0xFFFFF801U, 0x0407FFFFU, 0xF0010000U, 0xFFFFFFFFU,
737 0x200003FFU, 0xFFFF0000U, 0xFFFFFFFFU, 0x01FFFFFFU,
738 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
739 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FF0001U,
740 0xFFFFFDFFU, 0x00007FFFU, 0x03FF0001U, 0xFFFC0000U,
741 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
742 0xFFFFFB7FU, 0x0001FFFFU, 0x03FF0040U, 0xFFFFFDBFU,
743 0x010003FFU, 0xFFFF03FFU, 0x0FFFFFFFU, 0x000003FFU,
744 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
745 0x00000000U, 0x00000000U, 0x00000000U, 0x0007FFFFU,
746 0xFFFDFFF4U, 0x000FFFFFU, 0x03FF0000U, 0x00000000U,
747 0x00000000U, 0x00010000U, 0x00000000U, 0x00000000U,
748 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
749 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
750 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
751 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
752 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00007FFFU,
753 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
754 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
755 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
756 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
757 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
758 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
759 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU,
760 0xFFFFFFFFU, 0x0000FFFFU, 0x0000007EU, 0xFFFFFFFFU,
761 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
762 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
763 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
764 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
765 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
766 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
767 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
768 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U,
769 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
770 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
771 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
772 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
773 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
774 0x3FFFFFFFU, 0x03FF0000U, 0x00000000U, 0x00000000U,
775 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
776 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU,
777 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x00003FFFU,
778 0xFFFFFFFFU, 0x0000FFFFU, 0x03FF000FU, 0xE0FFFFF8U,
779 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
780 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
781 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
782 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FF1FFFU,
783 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
784 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU,
785 0x00000000U, 0xF9FFFFFFU, 0x000FFFFFU, 0x00000000U,
786 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000107FFU, 0x00000000U,
787 0xFFF80000U, 0x00000000U, 0x00000000U, 0x007C000BU,
788 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
789 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x80000000U,
790 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
791 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
792 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
793 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
794 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
795 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U,
796 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
797 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
798 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U,
799 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
800 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
801 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU,
802 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
803 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
804 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU,
805 0x03FF01FFU, 0x00000000U, 0x00000000U, 0x00000000U,
806 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
807 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
808 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
809 0x00000000U, 0x00000000U, 0xFFC00000U, 0x03FFFFFFU,
810 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
811 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
812 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU,
813 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU,
814 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU,
815 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
816 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
817 0xFFFFFFFFU, 0xFFFFFF3FU, 0xF7FFFFFDU, 0xF7FFFFFFU,
818 0xFFDFFFFFU, 0xFFDFFFFFU, 0xFFFF7FFFU, 0xFFFF7FFFU,
819 0xFFFFFDFFU, 0xFFFFFDFFU, 0xFFFFCFF7U, 0xFFFFFFFFU,
820 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
821 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
822 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U,
823 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
824 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x00003FFFU,
825 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
826 0xFFFFFFFFU, 0x3F801FFFU, 0x000043FFU, 0x00000000U,
827 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
828 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
829 0xFFFF0000U, 0x00003FFFU, 0xFFFFFFFFU, 0x03FF0FFFU,
830 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
831 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
832 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
833 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FF0FFFU,
834 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
835 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x07FF3FFFU,
836 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
837 0x00000000U, 0x00000000U, 0x7FFFFFFFU, 0xC01F3FB7U,
838 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
839 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU,
840 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
841 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000001FU, 0x00000000U,
842 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF080FU, 0x00000000U,
843 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
844 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U,
845 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00000000U,
846 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
847 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
848 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
849 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
850 0xFFFF0000U, 0xFFFF1FFFU, 0xFFFF03FFU, 0xFFFF03FFU,
851 0x000007FFU, 0x00000020U, 0x00000000U, 0xFFFFFFC0U,
852 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
853 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
854 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
855 0x00000000U, 0x00000000U, 0x00000000U, 0x03FF0000U,
856 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
857 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U,
858 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
859 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
860 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
861 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
862 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
863 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
864 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
865 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
866 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
867 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
868 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
869 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
870 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
871 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF0001U,
872 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U,
873 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
874 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
875 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
876 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
877 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
878 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
879 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
880 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
881 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
882 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU,
883 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
884 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU,
885 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
886 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
887 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
888 }
889};
diff --git a/gl/unictype/ctype_blank.c b/gl/unictype/ctype_blank.c
new file mode 100644
index 00000000..e14cc44e
--- /dev/null
+++ b/gl/unictype/ctype_blank.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_blank table. */
26#include "ctype_blank.h"
27
28bool
29uc_is_blank (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_blank, uc);
32}
diff --git a/gl/unictype/ctype_blank.h b/gl/unictype/ctype_blank.h
new file mode 100644
index 00000000..d0605c69
--- /dev/null
+++ b/gl/unictype/ctype_blank.h
@@ -0,0 +1,184 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[1];
29 short level2[1 << 7];
30 unsigned int level3[4 << 4];
31 }
32u_is_blank =
33{
34 { 1 },
35 { 2 * sizeof (int) / sizeof (short) + 0 },
36 {
37 2 + 128 * sizeof (short) / sizeof (int) + 0,
38 -1,
39 -1,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 2 + 128 * sizeof (short) / sizeof (int) + 16,
49 -1,
50 -1,
51 -1,
52 -1,
53 2 + 128 * sizeof (short) / sizeof (int) + 32,
54 -1,
55 -1,
56 -1,
57 -1,
58 -1,
59 -1,
60 -1,
61 2 + 128 * sizeof (short) / sizeof (int) + 48,
62 -1,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 -1,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1
165 },
166 {
167 0x00000200U, 0x00000001U, 0x00000000U, 0x00000000U,
168 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
169 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
171 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
172 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U,
173 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
174 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
175 0x0000077FU, 0x00000000U, 0x80000000U, 0x00000000U,
176 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
177 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
178 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
179 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U,
180 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
181 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
182 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
183 }
184};
diff --git a/gl/unictype/ctype_cntrl.c b/gl/unictype/ctype_cntrl.c
new file mode 100644
index 00000000..1c5cefa1
--- /dev/null
+++ b/gl/unictype/ctype_cntrl.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_cntrl table. */
26#include "ctype_cntrl.h"
27
28bool
29uc_is_cntrl (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_cntrl, uc);
32}
diff --git a/gl/unictype/ctype_cntrl.h b/gl/unictype/ctype_cntrl.h
new file mode 100644
index 00000000..ba6bf7ca
--- /dev/null
+++ b/gl/unictype/ctype_cntrl.h
@@ -0,0 +1,176 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[1];
29 short level2[1 << 7];
30 unsigned int level3[2 << 4];
31 }
32u_is_cntrl =
33{
34 { 1 },
35 { 2 * sizeof (int) / sizeof (short) + 0 },
36 {
37 2 + 128 * sizeof (short) / sizeof (int) + 0,
38 -1,
39 -1,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 -1,
51 -1,
52 -1,
53 2 + 128 * sizeof (short) / sizeof (int) + 16,
54 -1,
55 -1,
56 -1,
57 -1,
58 -1,
59 -1,
60 -1,
61 -1,
62 -1,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 -1,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1
165 },
166 {
167 0xFFFFFFFFU, 0x00000000U, 0x00000000U, 0x80000000U,
168 0xFFFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
169 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
171 0x00000000U, 0x00000300U, 0x00000000U, 0x00000000U,
172 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
173 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
174 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
175 }
176};
diff --git a/gl/unictype/ctype_digit.c b/gl/unictype/ctype_digit.c
new file mode 100644
index 00000000..71d68807
--- /dev/null
+++ b/gl/unictype/ctype_digit.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_digit table. */
26#include "ctype_digit.h"
27
28bool
29uc_is_digit (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_digit, uc);
32}
diff --git a/gl/unictype/ctype_digit.h b/gl/unictype/ctype_digit.h
new file mode 100644
index 00000000..7322861f
--- /dev/null
+++ b/gl/unictype/ctype_digit.h
@@ -0,0 +1,172 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[1];
29 short level2[1 << 7];
30 unsigned int level3[1 << 4];
31 }
32u_is_digit =
33{
34 { 1 },
35 { 2 * sizeof (int) / sizeof (short) + 0 },
36 {
37 2 + 128 * sizeof (short) / sizeof (int) + 0,
38 -1,
39 -1,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 -1,
51 -1,
52 -1,
53 -1,
54 -1,
55 -1,
56 -1,
57 -1,
58 -1,
59 -1,
60 -1,
61 -1,
62 -1,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 -1,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1
165 },
166 {
167 0x00000000U, 0x03FF0000U, 0x00000000U, 0x00000000U,
168 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
169 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
171 }
172};
diff --git a/gl/unictype/ctype_graph.c b/gl/unictype/ctype_graph.c
new file mode 100644
index 00000000..92701700
--- /dev/null
+++ b/gl/unictype/ctype_graph.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_graph table. */
26#include "ctype_graph.h"
27
28bool
29uc_is_graph (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_graph, uc);
32}
diff --git a/gl/unictype/ctype_graph.h b/gl/unictype/ctype_graph.h
new file mode 100644
index 00000000..948d21d2
--- /dev/null
+++ b/gl/unictype/ctype_graph.h
@@ -0,0 +1,1194 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[17];
29 short level2[6 << 7];
30 unsigned int level3[92 << 4];
31 }
32u_is_graph =
33{
34 { 17 },
35 {
36 18 * sizeof (int) / sizeof (short) + 0,
37 18 * sizeof (int) / sizeof (short) + 128,
38 18 * sizeof (int) / sizeof (short) + 256,
39 18 * sizeof (int) / sizeof (short) + 384,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 18 * sizeof (int) / sizeof (short) + 512,
51 18 * sizeof (int) / sizeof (short) + 640,
52 18 * sizeof (int) / sizeof (short) + 640
53 },
54 {
55 18 + 768 * sizeof (short) / sizeof (int) + 0,
56 18 + 768 * sizeof (short) / sizeof (int) + 16,
57 18 + 768 * sizeof (short) / sizeof (int) + 32,
58 18 + 768 * sizeof (short) / sizeof (int) + 48,
59 18 + 768 * sizeof (short) / sizeof (int) + 64,
60 18 + 768 * sizeof (short) / sizeof (int) + 80,
61 18 + 768 * sizeof (short) / sizeof (int) + 96,
62 18 + 768 * sizeof (short) / sizeof (int) + 112,
63 18 + 768 * sizeof (short) / sizeof (int) + 128,
64 18 + 768 * sizeof (short) / sizeof (int) + 144,
65 18 + 768 * sizeof (short) / sizeof (int) + 160,
66 18 + 768 * sizeof (short) / sizeof (int) + 176,
67 18 + 768 * sizeof (short) / sizeof (int) + 192,
68 18 + 768 * sizeof (short) / sizeof (int) + 208,
69 18 + 768 * sizeof (short) / sizeof (int) + 224,
70 18 + 768 * sizeof (short) / sizeof (int) + 240,
71 18 + 768 * sizeof (short) / sizeof (int) + 256,
72 18 + 768 * sizeof (short) / sizeof (int) + 160,
73 18 + 768 * sizeof (short) / sizeof (int) + 272,
74 18 + 768 * sizeof (short) / sizeof (int) + 160,
75 18 + 768 * sizeof (short) / sizeof (int) + 160,
76 18 + 768 * sizeof (short) / sizeof (int) + 288,
77 18 + 768 * sizeof (short) / sizeof (int) + 304,
78 18 + 768 * sizeof (short) / sizeof (int) + 320,
79 18 + 768 * sizeof (short) / sizeof (int) + 336,
80 18 + 768 * sizeof (short) / sizeof (int) + 352,
81 18 + 768 * sizeof (short) / sizeof (int) + 160,
82 18 + 768 * sizeof (short) / sizeof (int) + 160,
83 18 + 768 * sizeof (short) / sizeof (int) + 160,
84 18 + 768 * sizeof (short) / sizeof (int) + 160,
85 18 + 768 * sizeof (short) / sizeof (int) + 160,
86 18 + 768 * sizeof (short) / sizeof (int) + 160,
87 18 + 768 * sizeof (short) / sizeof (int) + 160,
88 18 + 768 * sizeof (short) / sizeof (int) + 160,
89 18 + 768 * sizeof (short) / sizeof (int) + 160,
90 18 + 768 * sizeof (short) / sizeof (int) + 160,
91 18 + 768 * sizeof (short) / sizeof (int) + 160,
92 18 + 768 * sizeof (short) / sizeof (int) + 160,
93 18 + 768 * sizeof (short) / sizeof (int) + 160,
94 18 + 768 * sizeof (short) / sizeof (int) + 160,
95 18 + 768 * sizeof (short) / sizeof (int) + 160,
96 18 + 768 * sizeof (short) / sizeof (int) + 160,
97 18 + 768 * sizeof (short) / sizeof (int) + 160,
98 18 + 768 * sizeof (short) / sizeof (int) + 160,
99 18 + 768 * sizeof (short) / sizeof (int) + 160,
100 18 + 768 * sizeof (short) / sizeof (int) + 160,
101 18 + 768 * sizeof (short) / sizeof (int) + 160,
102 18 + 768 * sizeof (short) / sizeof (int) + 160,
103 18 + 768 * sizeof (short) / sizeof (int) + 160,
104 18 + 768 * sizeof (short) / sizeof (int) + 160,
105 18 + 768 * sizeof (short) / sizeof (int) + 160,
106 18 + 768 * sizeof (short) / sizeof (int) + 160,
107 18 + 768 * sizeof (short) / sizeof (int) + 160,
108 18 + 768 * sizeof (short) / sizeof (int) + 160,
109 18 + 768 * sizeof (short) / sizeof (int) + 160,
110 18 + 768 * sizeof (short) / sizeof (int) + 160,
111 18 + 768 * sizeof (short) / sizeof (int) + 160,
112 18 + 768 * sizeof (short) / sizeof (int) + 160,
113 18 + 768 * sizeof (short) / sizeof (int) + 160,
114 18 + 768 * sizeof (short) / sizeof (int) + 160,
115 18 + 768 * sizeof (short) / sizeof (int) + 160,
116 18 + 768 * sizeof (short) / sizeof (int) + 160,
117 18 + 768 * sizeof (short) / sizeof (int) + 160,
118 18 + 768 * sizeof (short) / sizeof (int) + 160,
119 18 + 768 * sizeof (short) / sizeof (int) + 160,
120 18 + 768 * sizeof (short) / sizeof (int) + 160,
121 18 + 768 * sizeof (short) / sizeof (int) + 160,
122 18 + 768 * sizeof (short) / sizeof (int) + 160,
123 18 + 768 * sizeof (short) / sizeof (int) + 160,
124 18 + 768 * sizeof (short) / sizeof (int) + 160,
125 18 + 768 * sizeof (short) / sizeof (int) + 160,
126 18 + 768 * sizeof (short) / sizeof (int) + 160,
127 18 + 768 * sizeof (short) / sizeof (int) + 160,
128 18 + 768 * sizeof (short) / sizeof (int) + 160,
129 18 + 768 * sizeof (short) / sizeof (int) + 160,
130 18 + 768 * sizeof (short) / sizeof (int) + 160,
131 18 + 768 * sizeof (short) / sizeof (int) + 160,
132 18 + 768 * sizeof (short) / sizeof (int) + 160,
133 18 + 768 * sizeof (short) / sizeof (int) + 160,
134 18 + 768 * sizeof (short) / sizeof (int) + 160,
135 18 + 768 * sizeof (short) / sizeof (int) + 160,
136 18 + 768 * sizeof (short) / sizeof (int) + 160,
137 18 + 768 * sizeof (short) / sizeof (int) + 368,
138 18 + 768 * sizeof (short) / sizeof (int) + 384,
139 18 + 768 * sizeof (short) / sizeof (int) + 400,
140 18 + 768 * sizeof (short) / sizeof (int) + 416,
141 18 + 768 * sizeof (short) / sizeof (int) + 160,
142 18 + 768 * sizeof (short) / sizeof (int) + 160,
143 18 + 768 * sizeof (short) / sizeof (int) + 160,
144 18 + 768 * sizeof (short) / sizeof (int) + 160,
145 18 + 768 * sizeof (short) / sizeof (int) + 160,
146 18 + 768 * sizeof (short) / sizeof (int) + 160,
147 18 + 768 * sizeof (short) / sizeof (int) + 160,
148 18 + 768 * sizeof (short) / sizeof (int) + 160,
149 18 + 768 * sizeof (short) / sizeof (int) + 160,
150 18 + 768 * sizeof (short) / sizeof (int) + 160,
151 18 + 768 * sizeof (short) / sizeof (int) + 160,
152 18 + 768 * sizeof (short) / sizeof (int) + 160,
153 18 + 768 * sizeof (short) / sizeof (int) + 160,
154 18 + 768 * sizeof (short) / sizeof (int) + 160,
155 18 + 768 * sizeof (short) / sizeof (int) + 160,
156 18 + 768 * sizeof (short) / sizeof (int) + 160,
157 18 + 768 * sizeof (short) / sizeof (int) + 160,
158 18 + 768 * sizeof (short) / sizeof (int) + 160,
159 18 + 768 * sizeof (short) / sizeof (int) + 160,
160 18 + 768 * sizeof (short) / sizeof (int) + 160,
161 18 + 768 * sizeof (short) / sizeof (int) + 160,
162 18 + 768 * sizeof (short) / sizeof (int) + 432,
163 -1,
164 -1,
165 -1,
166 -1,
167 18 + 768 * sizeof (short) / sizeof (int) + 160,
168 18 + 768 * sizeof (short) / sizeof (int) + 160,
169 18 + 768 * sizeof (short) / sizeof (int) + 160,
170 18 + 768 * sizeof (short) / sizeof (int) + 160,
171 18 + 768 * sizeof (short) / sizeof (int) + 160,
172 18 + 768 * sizeof (short) / sizeof (int) + 160,
173 18 + 768 * sizeof (short) / sizeof (int) + 160,
174 18 + 768 * sizeof (short) / sizeof (int) + 160,
175 18 + 768 * sizeof (short) / sizeof (int) + 160,
176 18 + 768 * sizeof (short) / sizeof (int) + 160,
177 18 + 768 * sizeof (short) / sizeof (int) + 160,
178 18 + 768 * sizeof (short) / sizeof (int) + 160,
179 18 + 768 * sizeof (short) / sizeof (int) + 160,
180 18 + 768 * sizeof (short) / sizeof (int) + 448,
181 18 + 768 * sizeof (short) / sizeof (int) + 464,
182 18 + 768 * sizeof (short) / sizeof (int) + 480,
183 18 + 768 * sizeof (short) / sizeof (int) + 496,
184 18 + 768 * sizeof (short) / sizeof (int) + 512,
185 18 + 768 * sizeof (short) / sizeof (int) + 528,
186 18 + 768 * sizeof (short) / sizeof (int) + 544,
187 18 + 768 * sizeof (short) / sizeof (int) + 560,
188 18 + 768 * sizeof (short) / sizeof (int) + 576,
189 18 + 768 * sizeof (short) / sizeof (int) + 592,
190 18 + 768 * sizeof (short) / sizeof (int) + 608,
191 18 + 768 * sizeof (short) / sizeof (int) + 624,
192 18 + 768 * sizeof (short) / sizeof (int) + 640,
193 18 + 768 * sizeof (short) / sizeof (int) + 656,
194 18 + 768 * sizeof (short) / sizeof (int) + 672,
195 18 + 768 * sizeof (short) / sizeof (int) + 688,
196 18 + 768 * sizeof (short) / sizeof (int) + 704,
197 18 + 768 * sizeof (short) / sizeof (int) + 720,
198 18 + 768 * sizeof (short) / sizeof (int) + 736,
199 18 + 768 * sizeof (short) / sizeof (int) + 160,
200 18 + 768 * sizeof (short) / sizeof (int) + 752,
201 18 + 768 * sizeof (short) / sizeof (int) + 768,
202 -1,
203 -1,
204 -1,
205 -1,
206 18 + 768 * sizeof (short) / sizeof (int) + 784,
207 18 + 768 * sizeof (short) / sizeof (int) + 160,
208 18 + 768 * sizeof (short) / sizeof (int) + 160,
209 18 + 768 * sizeof (short) / sizeof (int) + 800,
210 18 + 768 * sizeof (short) / sizeof (int) + 160,
211 18 + 768 * sizeof (short) / sizeof (int) + 160,
212 18 + 768 * sizeof (short) / sizeof (int) + 160,
213 18 + 768 * sizeof (short) / sizeof (int) + 160,
214 18 + 768 * sizeof (short) / sizeof (int) + 160,
215 18 + 768 * sizeof (short) / sizeof (int) + 160,
216 18 + 768 * sizeof (short) / sizeof (int) + 816,
217 18 + 768 * sizeof (short) / sizeof (int) + 160,
218 18 + 768 * sizeof (short) / sizeof (int) + 832,
219 -1,
220 -1,
221 -1,
222 -1,
223 -1,
224 -1,
225 -1,
226 -1,
227 -1,
228 -1,
229 -1,
230 -1,
231 18 + 768 * sizeof (short) / sizeof (int) + 848,
232 -1,
233 -1,
234 -1,
235 18 + 768 * sizeof (short) / sizeof (int) + 160,
236 18 + 768 * sizeof (short) / sizeof (int) + 864,
237 18 + 768 * sizeof (short) / sizeof (int) + 880,
238 18 + 768 * sizeof (short) / sizeof (int) + 896,
239 18 + 768 * sizeof (short) / sizeof (int) + 160,
240 18 + 768 * sizeof (short) / sizeof (int) + 160,
241 18 + 768 * sizeof (short) / sizeof (int) + 160,
242 18 + 768 * sizeof (short) / sizeof (int) + 160,
243 18 + 768 * sizeof (short) / sizeof (int) + 160,
244 18 + 768 * sizeof (short) / sizeof (int) + 160,
245 18 + 768 * sizeof (short) / sizeof (int) + 160,
246 18 + 768 * sizeof (short) / sizeof (int) + 160,
247 18 + 768 * sizeof (short) / sizeof (int) + 160,
248 18 + 768 * sizeof (short) / sizeof (int) + 160,
249 18 + 768 * sizeof (short) / sizeof (int) + 160,
250 18 + 768 * sizeof (short) / sizeof (int) + 160,
251 18 + 768 * sizeof (short) / sizeof (int) + 160,
252 18 + 768 * sizeof (short) / sizeof (int) + 160,
253 18 + 768 * sizeof (short) / sizeof (int) + 912,
254 -1,
255 -1,
256 -1,
257 -1,
258 -1,
259 -1,
260 -1,
261 -1,
262 -1,
263 -1,
264 -1,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 18 + 768 * sizeof (short) / sizeof (int) + 928,
271 18 + 768 * sizeof (short) / sizeof (int) + 944,
272 18 + 768 * sizeof (short) / sizeof (int) + 960,
273 -1,
274 -1,
275 -1,
276 -1,
277 18 + 768 * sizeof (short) / sizeof (int) + 976,
278 -1,
279 -1,
280 -1,
281 -1,
282 -1,
283 -1,
284 -1,
285 18 + 768 * sizeof (short) / sizeof (int) + 992,
286 18 + 768 * sizeof (short) / sizeof (int) + 1008,
287 18 + 768 * sizeof (short) / sizeof (int) + 1024,
288 18 + 768 * sizeof (short) / sizeof (int) + 1040,
289 18 + 768 * sizeof (short) / sizeof (int) + 1056,
290 18 + 768 * sizeof (short) / sizeof (int) + 1072,
291 18 + 768 * sizeof (short) / sizeof (int) + 160,
292 18 + 768 * sizeof (short) / sizeof (int) + 1088,
293 -1,
294 18 + 768 * sizeof (short) / sizeof (int) + 1104,
295 18 + 768 * sizeof (short) / sizeof (int) + 1120,
296 18 + 768 * sizeof (short) / sizeof (int) + 1136,
297 18 + 768 * sizeof (short) / sizeof (int) + 1152,
298 18 + 768 * sizeof (short) / sizeof (int) + 1168,
299 18 + 768 * sizeof (short) / sizeof (int) + 1184,
300 -1,
301 18 + 768 * sizeof (short) / sizeof (int) + 1200,
302 18 + 768 * sizeof (short) / sizeof (int) + 1216,
303 18 + 768 * sizeof (short) / sizeof (int) + 1232,
304 18 + 768 * sizeof (short) / sizeof (int) + 1248,
305 18 + 768 * sizeof (short) / sizeof (int) + 160,
306 18 + 768 * sizeof (short) / sizeof (int) + 1264,
307 18 + 768 * sizeof (short) / sizeof (int) + 1280,
308 18 + 768 * sizeof (short) / sizeof (int) + 1296,
309 -1,
310 -1,
311 18 + 768 * sizeof (short) / sizeof (int) + 160,
312 18 + 768 * sizeof (short) / sizeof (int) + 160,
313 18 + 768 * sizeof (short) / sizeof (int) + 160,
314 18 + 768 * sizeof (short) / sizeof (int) + 160,
315 18 + 768 * sizeof (short) / sizeof (int) + 160,
316 18 + 768 * sizeof (short) / sizeof (int) + 160,
317 18 + 768 * sizeof (short) / sizeof (int) + 160,
318 18 + 768 * sizeof (short) / sizeof (int) + 160,
319 18 + 768 * sizeof (short) / sizeof (int) + 160,
320 18 + 768 * sizeof (short) / sizeof (int) + 160,
321 18 + 768 * sizeof (short) / sizeof (int) + 160,
322 18 + 768 * sizeof (short) / sizeof (int) + 160,
323 18 + 768 * sizeof (short) / sizeof (int) + 160,
324 18 + 768 * sizeof (short) / sizeof (int) + 160,
325 18 + 768 * sizeof (short) / sizeof (int) + 160,
326 18 + 768 * sizeof (short) / sizeof (int) + 160,
327 18 + 768 * sizeof (short) / sizeof (int) + 160,
328 18 + 768 * sizeof (short) / sizeof (int) + 160,
329 18 + 768 * sizeof (short) / sizeof (int) + 160,
330 18 + 768 * sizeof (short) / sizeof (int) + 160,
331 18 + 768 * sizeof (short) / sizeof (int) + 160,
332 18 + 768 * sizeof (short) / sizeof (int) + 160,
333 18 + 768 * sizeof (short) / sizeof (int) + 160,
334 18 + 768 * sizeof (short) / sizeof (int) + 160,
335 18 + 768 * sizeof (short) / sizeof (int) + 160,
336 18 + 768 * sizeof (short) / sizeof (int) + 160,
337 18 + 768 * sizeof (short) / sizeof (int) + 160,
338 18 + 768 * sizeof (short) / sizeof (int) + 160,
339 18 + 768 * sizeof (short) / sizeof (int) + 160,
340 18 + 768 * sizeof (short) / sizeof (int) + 160,
341 18 + 768 * sizeof (short) / sizeof (int) + 160,
342 18 + 768 * sizeof (short) / sizeof (int) + 160,
343 18 + 768 * sizeof (short) / sizeof (int) + 160,
344 18 + 768 * sizeof (short) / sizeof (int) + 160,
345 18 + 768 * sizeof (short) / sizeof (int) + 160,
346 18 + 768 * sizeof (short) / sizeof (int) + 160,
347 18 + 768 * sizeof (short) / sizeof (int) + 160,
348 18 + 768 * sizeof (short) / sizeof (int) + 160,
349 18 + 768 * sizeof (short) / sizeof (int) + 160,
350 18 + 768 * sizeof (short) / sizeof (int) + 160,
351 18 + 768 * sizeof (short) / sizeof (int) + 160,
352 18 + 768 * sizeof (short) / sizeof (int) + 160,
353 18 + 768 * sizeof (short) / sizeof (int) + 160,
354 18 + 768 * sizeof (short) / sizeof (int) + 160,
355 18 + 768 * sizeof (short) / sizeof (int) + 160,
356 18 + 768 * sizeof (short) / sizeof (int) + 160,
357 18 + 768 * sizeof (short) / sizeof (int) + 160,
358 18 + 768 * sizeof (short) / sizeof (int) + 160,
359 18 + 768 * sizeof (short) / sizeof (int) + 160,
360 18 + 768 * sizeof (short) / sizeof (int) + 160,
361 18 + 768 * sizeof (short) / sizeof (int) + 160,
362 18 + 768 * sizeof (short) / sizeof (int) + 160,
363 18 + 768 * sizeof (short) / sizeof (int) + 160,
364 18 + 768 * sizeof (short) / sizeof (int) + 160,
365 18 + 768 * sizeof (short) / sizeof (int) + 160,
366 18 + 768 * sizeof (short) / sizeof (int) + 160,
367 18 + 768 * sizeof (short) / sizeof (int) + 160,
368 18 + 768 * sizeof (short) / sizeof (int) + 160,
369 18 + 768 * sizeof (short) / sizeof (int) + 160,
370 18 + 768 * sizeof (short) / sizeof (int) + 160,
371 18 + 768 * sizeof (short) / sizeof (int) + 160,
372 18 + 768 * sizeof (short) / sizeof (int) + 160,
373 18 + 768 * sizeof (short) / sizeof (int) + 160,
374 18 + 768 * sizeof (short) / sizeof (int) + 160,
375 18 + 768 * sizeof (short) / sizeof (int) + 160,
376 18 + 768 * sizeof (short) / sizeof (int) + 160,
377 18 + 768 * sizeof (short) / sizeof (int) + 160,
378 18 + 768 * sizeof (short) / sizeof (int) + 160,
379 18 + 768 * sizeof (short) / sizeof (int) + 160,
380 18 + 768 * sizeof (short) / sizeof (int) + 160,
381 18 + 768 * sizeof (short) / sizeof (int) + 160,
382 18 + 768 * sizeof (short) / sizeof (int) + 160,
383 18 + 768 * sizeof (short) / sizeof (int) + 160,
384 18 + 768 * sizeof (short) / sizeof (int) + 160,
385 18 + 768 * sizeof (short) / sizeof (int) + 160,
386 18 + 768 * sizeof (short) / sizeof (int) + 160,
387 18 + 768 * sizeof (short) / sizeof (int) + 160,
388 18 + 768 * sizeof (short) / sizeof (int) + 160,
389 18 + 768 * sizeof (short) / sizeof (int) + 160,
390 18 + 768 * sizeof (short) / sizeof (int) + 160,
391 18 + 768 * sizeof (short) / sizeof (int) + 160,
392 18 + 768 * sizeof (short) / sizeof (int) + 160,
393 18 + 768 * sizeof (short) / sizeof (int) + 160,
394 18 + 768 * sizeof (short) / sizeof (int) + 1312,
395 18 + 768 * sizeof (short) / sizeof (int) + 160,
396 18 + 768 * sizeof (short) / sizeof (int) + 160,
397 18 + 768 * sizeof (short) / sizeof (int) + 160,
398 18 + 768 * sizeof (short) / sizeof (int) + 160,
399 18 + 768 * sizeof (short) / sizeof (int) + 160,
400 18 + 768 * sizeof (short) / sizeof (int) + 160,
401 18 + 768 * sizeof (short) / sizeof (int) + 160,
402 18 + 768 * sizeof (short) / sizeof (int) + 160,
403 18 + 768 * sizeof (short) / sizeof (int) + 1328,
404 18 + 768 * sizeof (short) / sizeof (int) + 160,
405 18 + 768 * sizeof (short) / sizeof (int) + 160,
406 18 + 768 * sizeof (short) / sizeof (int) + 160,
407 18 + 768 * sizeof (short) / sizeof (int) + 160,
408 18 + 768 * sizeof (short) / sizeof (int) + 160,
409 18 + 768 * sizeof (short) / sizeof (int) + 160,
410 18 + 768 * sizeof (short) / sizeof (int) + 160,
411 18 + 768 * sizeof (short) / sizeof (int) + 160,
412 18 + 768 * sizeof (short) / sizeof (int) + 160,
413 18 + 768 * sizeof (short) / sizeof (int) + 160,
414 18 + 768 * sizeof (short) / sizeof (int) + 1344,
415 18 + 768 * sizeof (short) / sizeof (int) + 160,
416 18 + 768 * sizeof (short) / sizeof (int) + 160,
417 18 + 768 * sizeof (short) / sizeof (int) + 160,
418 18 + 768 * sizeof (short) / sizeof (int) + 160,
419 18 + 768 * sizeof (short) / sizeof (int) + 160,
420 18 + 768 * sizeof (short) / sizeof (int) + 160,
421 18 + 768 * sizeof (short) / sizeof (int) + 160,
422 18 + 768 * sizeof (short) / sizeof (int) + 160,
423 18 + 768 * sizeof (short) / sizeof (int) + 160,
424 18 + 768 * sizeof (short) / sizeof (int) + 160,
425 18 + 768 * sizeof (short) / sizeof (int) + 160,
426 18 + 768 * sizeof (short) / sizeof (int) + 160,
427 18 + 768 * sizeof (short) / sizeof (int) + 160,
428 18 + 768 * sizeof (short) / sizeof (int) + 1360,
429 18 + 768 * sizeof (short) / sizeof (int) + 160,
430 18 + 768 * sizeof (short) / sizeof (int) + 1376,
431 -1,
432 -1,
433 -1,
434 -1,
435 18 + 768 * sizeof (short) / sizeof (int) + 160,
436 18 + 768 * sizeof (short) / sizeof (int) + 1392,
437 -1,
438 -1,
439 18 + 768 * sizeof (short) / sizeof (int) + 160,
440 18 + 768 * sizeof (short) / sizeof (int) + 160,
441 18 + 768 * sizeof (short) / sizeof (int) + 160,
442 18 + 768 * sizeof (short) / sizeof (int) + 160,
443 18 + 768 * sizeof (short) / sizeof (int) + 160,
444 18 + 768 * sizeof (short) / sizeof (int) + 160,
445 18 + 768 * sizeof (short) / sizeof (int) + 160,
446 18 + 768 * sizeof (short) / sizeof (int) + 160,
447 18 + 768 * sizeof (short) / sizeof (int) + 160,
448 18 + 768 * sizeof (short) / sizeof (int) + 1408,
449 18 + 768 * sizeof (short) / sizeof (int) + 160,
450 18 + 768 * sizeof (short) / sizeof (int) + 160,
451 18 + 768 * sizeof (short) / sizeof (int) + 160,
452 18 + 768 * sizeof (short) / sizeof (int) + 160,
453 18 + 768 * sizeof (short) / sizeof (int) + 160,
454 18 + 768 * sizeof (short) / sizeof (int) + 160,
455 18 + 768 * sizeof (short) / sizeof (int) + 160,
456 18 + 768 * sizeof (short) / sizeof (int) + 160,
457 18 + 768 * sizeof (short) / sizeof (int) + 160,
458 18 + 768 * sizeof (short) / sizeof (int) + 160,
459 18 + 768 * sizeof (short) / sizeof (int) + 160,
460 18 + 768 * sizeof (short) / sizeof (int) + 160,
461 18 + 768 * sizeof (short) / sizeof (int) + 160,
462 18 + 768 * sizeof (short) / sizeof (int) + 160,
463 18 + 768 * sizeof (short) / sizeof (int) + 160,
464 18 + 768 * sizeof (short) / sizeof (int) + 160,
465 18 + 768 * sizeof (short) / sizeof (int) + 1424,
466 -1,
467 -1,
468 -1,
469 -1,
470 -1,
471 -1,
472 -1,
473 -1,
474 -1,
475 -1,
476 -1,
477 -1,
478 -1,
479 -1,
480 -1,
481 -1,
482 -1,
483 -1,
484 -1,
485 -1,
486 -1,
487 -1,
488 -1,
489 -1,
490 -1,
491 -1,
492 -1,
493 -1,
494 -1,
495 -1,
496 -1,
497 -1,
498 -1,
499 -1,
500 -1,
501 -1,
502 -1,
503 -1,
504 -1,
505 -1,
506 -1,
507 -1,
508 -1,
509 -1,
510 -1,
511 -1,
512 -1,
513 -1,
514 -1,
515 -1,
516 -1,
517 -1,
518 -1,
519 -1,
520 -1,
521 -1,
522 -1,
523 -1,
524 -1,
525 -1,
526 -1,
527 -1,
528 -1,
529 -1,
530 -1,
531 -1,
532 -1,
533 -1,
534 -1,
535 -1,
536 -1,
537 -1,
538 -1,
539 -1,
540 -1,
541 -1,
542 -1,
543 -1,
544 -1,
545 -1,
546 -1,
547 -1,
548 -1,
549 -1,
550 -1,
551 -1,
552 -1,
553 -1,
554 -1,
555 -1,
556 -1,
557 -1,
558 -1,
559 -1,
560 -1,
561 -1,
562 -1,
563 -1,
564 -1,
565 -1,
566 -1,
567 18 + 768 * sizeof (short) / sizeof (int) + 1440,
568 -1,
569 -1,
570 -1,
571 -1,
572 -1,
573 -1,
574 -1,
575 -1,
576 -1,
577 -1,
578 -1,
579 -1,
580 -1,
581 -1,
582 -1,
583 -1,
584 -1,
585 -1,
586 -1,
587 -1,
588 -1,
589 -1,
590 -1,
591 -1,
592 -1,
593 -1,
594 -1,
595 -1,
596 -1,
597 -1,
598 -1,
599 -1,
600 -1,
601 -1,
602 -1,
603 -1,
604 -1,
605 -1,
606 -1,
607 -1,
608 -1,
609 -1,
610 -1,
611 -1,
612 -1,
613 -1,
614 -1,
615 -1,
616 -1,
617 -1,
618 -1,
619 -1,
620 -1,
621 -1,
622 -1,
623 -1,
624 -1,
625 -1,
626 -1,
627 -1,
628 -1,
629 -1,
630 -1,
631 -1,
632 -1,
633 -1,
634 -1,
635 -1,
636 -1,
637 -1,
638 -1,
639 -1,
640 -1,
641 -1,
642 -1,
643 -1,
644 -1,
645 -1,
646 -1,
647 -1,
648 -1,
649 -1,
650 -1,
651 -1,
652 -1,
653 -1,
654 -1,
655 -1,
656 -1,
657 -1,
658 -1,
659 -1,
660 -1,
661 -1,
662 -1,
663 -1,
664 -1,
665 -1,
666 -1,
667 -1,
668 -1,
669 -1,
670 -1,
671 -1,
672 -1,
673 -1,
674 -1,
675 -1,
676 -1,
677 -1,
678 -1,
679 -1,
680 -1,
681 -1,
682 -1,
683 -1,
684 -1,
685 -1,
686 -1,
687 -1,
688 -1,
689 -1,
690 -1,
691 -1,
692 -1,
693 -1,
694 -1,
695 18 + 768 * sizeof (short) / sizeof (int) + 160,
696 18 + 768 * sizeof (short) / sizeof (int) + 160,
697 18 + 768 * sizeof (short) / sizeof (int) + 160,
698 18 + 768 * sizeof (short) / sizeof (int) + 160,
699 18 + 768 * sizeof (short) / sizeof (int) + 160,
700 18 + 768 * sizeof (short) / sizeof (int) + 160,
701 18 + 768 * sizeof (short) / sizeof (int) + 160,
702 18 + 768 * sizeof (short) / sizeof (int) + 160,
703 18 + 768 * sizeof (short) / sizeof (int) + 160,
704 18 + 768 * sizeof (short) / sizeof (int) + 160,
705 18 + 768 * sizeof (short) / sizeof (int) + 160,
706 18 + 768 * sizeof (short) / sizeof (int) + 160,
707 18 + 768 * sizeof (short) / sizeof (int) + 160,
708 18 + 768 * sizeof (short) / sizeof (int) + 160,
709 18 + 768 * sizeof (short) / sizeof (int) + 160,
710 18 + 768 * sizeof (short) / sizeof (int) + 160,
711 18 + 768 * sizeof (short) / sizeof (int) + 160,
712 18 + 768 * sizeof (short) / sizeof (int) + 160,
713 18 + 768 * sizeof (short) / sizeof (int) + 160,
714 18 + 768 * sizeof (short) / sizeof (int) + 160,
715 18 + 768 * sizeof (short) / sizeof (int) + 160,
716 18 + 768 * sizeof (short) / sizeof (int) + 160,
717 18 + 768 * sizeof (short) / sizeof (int) + 160,
718 18 + 768 * sizeof (short) / sizeof (int) + 160,
719 18 + 768 * sizeof (short) / sizeof (int) + 160,
720 18 + 768 * sizeof (short) / sizeof (int) + 160,
721 18 + 768 * sizeof (short) / sizeof (int) + 160,
722 18 + 768 * sizeof (short) / sizeof (int) + 160,
723 18 + 768 * sizeof (short) / sizeof (int) + 160,
724 18 + 768 * sizeof (short) / sizeof (int) + 160,
725 18 + 768 * sizeof (short) / sizeof (int) + 160,
726 18 + 768 * sizeof (short) / sizeof (int) + 160,
727 18 + 768 * sizeof (short) / sizeof (int) + 160,
728 18 + 768 * sizeof (short) / sizeof (int) + 160,
729 18 + 768 * sizeof (short) / sizeof (int) + 160,
730 18 + 768 * sizeof (short) / sizeof (int) + 160,
731 18 + 768 * sizeof (short) / sizeof (int) + 160,
732 18 + 768 * sizeof (short) / sizeof (int) + 160,
733 18 + 768 * sizeof (short) / sizeof (int) + 160,
734 18 + 768 * sizeof (short) / sizeof (int) + 160,
735 18 + 768 * sizeof (short) / sizeof (int) + 160,
736 18 + 768 * sizeof (short) / sizeof (int) + 160,
737 18 + 768 * sizeof (short) / sizeof (int) + 160,
738 18 + 768 * sizeof (short) / sizeof (int) + 160,
739 18 + 768 * sizeof (short) / sizeof (int) + 160,
740 18 + 768 * sizeof (short) / sizeof (int) + 160,
741 18 + 768 * sizeof (short) / sizeof (int) + 160,
742 18 + 768 * sizeof (short) / sizeof (int) + 160,
743 18 + 768 * sizeof (short) / sizeof (int) + 160,
744 18 + 768 * sizeof (short) / sizeof (int) + 160,
745 18 + 768 * sizeof (short) / sizeof (int) + 160,
746 18 + 768 * sizeof (short) / sizeof (int) + 160,
747 18 + 768 * sizeof (short) / sizeof (int) + 160,
748 18 + 768 * sizeof (short) / sizeof (int) + 160,
749 18 + 768 * sizeof (short) / sizeof (int) + 160,
750 18 + 768 * sizeof (short) / sizeof (int) + 160,
751 18 + 768 * sizeof (short) / sizeof (int) + 160,
752 18 + 768 * sizeof (short) / sizeof (int) + 160,
753 18 + 768 * sizeof (short) / sizeof (int) + 160,
754 18 + 768 * sizeof (short) / sizeof (int) + 160,
755 18 + 768 * sizeof (short) / sizeof (int) + 160,
756 18 + 768 * sizeof (short) / sizeof (int) + 160,
757 18 + 768 * sizeof (short) / sizeof (int) + 160,
758 18 + 768 * sizeof (short) / sizeof (int) + 160,
759 18 + 768 * sizeof (short) / sizeof (int) + 160,
760 18 + 768 * sizeof (short) / sizeof (int) + 160,
761 18 + 768 * sizeof (short) / sizeof (int) + 160,
762 18 + 768 * sizeof (short) / sizeof (int) + 160,
763 18 + 768 * sizeof (short) / sizeof (int) + 160,
764 18 + 768 * sizeof (short) / sizeof (int) + 160,
765 18 + 768 * sizeof (short) / sizeof (int) + 160,
766 18 + 768 * sizeof (short) / sizeof (int) + 160,
767 18 + 768 * sizeof (short) / sizeof (int) + 160,
768 18 + 768 * sizeof (short) / sizeof (int) + 160,
769 18 + 768 * sizeof (short) / sizeof (int) + 160,
770 18 + 768 * sizeof (short) / sizeof (int) + 160,
771 18 + 768 * sizeof (short) / sizeof (int) + 160,
772 18 + 768 * sizeof (short) / sizeof (int) + 160,
773 18 + 768 * sizeof (short) / sizeof (int) + 160,
774 18 + 768 * sizeof (short) / sizeof (int) + 160,
775 18 + 768 * sizeof (short) / sizeof (int) + 160,
776 18 + 768 * sizeof (short) / sizeof (int) + 160,
777 18 + 768 * sizeof (short) / sizeof (int) + 160,
778 18 + 768 * sizeof (short) / sizeof (int) + 160,
779 18 + 768 * sizeof (short) / sizeof (int) + 160,
780 18 + 768 * sizeof (short) / sizeof (int) + 160,
781 18 + 768 * sizeof (short) / sizeof (int) + 160,
782 18 + 768 * sizeof (short) / sizeof (int) + 160,
783 18 + 768 * sizeof (short) / sizeof (int) + 160,
784 18 + 768 * sizeof (short) / sizeof (int) + 160,
785 18 + 768 * sizeof (short) / sizeof (int) + 160,
786 18 + 768 * sizeof (short) / sizeof (int) + 160,
787 18 + 768 * sizeof (short) / sizeof (int) + 160,
788 18 + 768 * sizeof (short) / sizeof (int) + 160,
789 18 + 768 * sizeof (short) / sizeof (int) + 160,
790 18 + 768 * sizeof (short) / sizeof (int) + 160,
791 18 + 768 * sizeof (short) / sizeof (int) + 160,
792 18 + 768 * sizeof (short) / sizeof (int) + 160,
793 18 + 768 * sizeof (short) / sizeof (int) + 160,
794 18 + 768 * sizeof (short) / sizeof (int) + 160,
795 18 + 768 * sizeof (short) / sizeof (int) + 160,
796 18 + 768 * sizeof (short) / sizeof (int) + 160,
797 18 + 768 * sizeof (short) / sizeof (int) + 160,
798 18 + 768 * sizeof (short) / sizeof (int) + 160,
799 18 + 768 * sizeof (short) / sizeof (int) + 160,
800 18 + 768 * sizeof (short) / sizeof (int) + 160,
801 18 + 768 * sizeof (short) / sizeof (int) + 160,
802 18 + 768 * sizeof (short) / sizeof (int) + 160,
803 18 + 768 * sizeof (short) / sizeof (int) + 160,
804 18 + 768 * sizeof (short) / sizeof (int) + 160,
805 18 + 768 * sizeof (short) / sizeof (int) + 160,
806 18 + 768 * sizeof (short) / sizeof (int) + 160,
807 18 + 768 * sizeof (short) / sizeof (int) + 160,
808 18 + 768 * sizeof (short) / sizeof (int) + 160,
809 18 + 768 * sizeof (short) / sizeof (int) + 160,
810 18 + 768 * sizeof (short) / sizeof (int) + 160,
811 18 + 768 * sizeof (short) / sizeof (int) + 160,
812 18 + 768 * sizeof (short) / sizeof (int) + 160,
813 18 + 768 * sizeof (short) / sizeof (int) + 160,
814 18 + 768 * sizeof (short) / sizeof (int) + 160,
815 18 + 768 * sizeof (short) / sizeof (int) + 160,
816 18 + 768 * sizeof (short) / sizeof (int) + 160,
817 18 + 768 * sizeof (short) / sizeof (int) + 160,
818 18 + 768 * sizeof (short) / sizeof (int) + 160,
819 18 + 768 * sizeof (short) / sizeof (int) + 160,
820 18 + 768 * sizeof (short) / sizeof (int) + 160,
821 18 + 768 * sizeof (short) / sizeof (int) + 160,
822 18 + 768 * sizeof (short) / sizeof (int) + 1456
823 },
824 {
825 0x00000000U, 0xFFFFFFFEU, 0xFFFFFFFFU, 0x7FFFFFFFU,
826 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
827 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
828 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
829 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
830 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
831 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFCFFFFFFU,
832 0xFFFFD7F0U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFFFFFFFU,
833 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
834 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
835 0xFFFFFFFFU, 0xFFFEFFFFU, 0xFE7FFFFFU, 0xFFFFFFFFU,
836 0xFFFEE7FFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0x001F87FFU,
837 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
838 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
839 0xFFFFBFFFU, 0xFFFFFFFFU, 0xFFFFE7FFU, 0xFFFFFFFFU,
840 0xFFFFFFFFU, 0x0003FFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU,
841 0xFFFFFFFFU, 0x7FFF3FFFU, 0x4FFFFFFFU, 0xFFFF07FFU,
842 0xFF83FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
843 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
844 0xFFF99FEFU, 0xF3C5FDFFU, 0xB080799FU, 0x7FFFFFCFU,
845 0xFFF987EEU, 0xD36DFDFFU, 0x5E023987U, 0x007FFFC0U,
846 0xFFFBBFEEU, 0xF3EDFDFFU, 0x00013BBFU, 0xFE03FFCFU,
847 0xFFF99FEEU, 0xF3EDFDFFU, 0xB0E0399FU, 0x00FFFFCFU,
848 0xD63DC7ECU, 0xC3FFC718U, 0x00813DC7U, 0x07FFFFC0U,
849 0xFFFDDFFFU, 0xF3FFFDFFU, 0x37603DDFU, 0xFF80FFCFU,
850 0xFFFDDFFFU, 0xF3EFFDFFU, 0x70603DDFU, 0x000EFFCFU,
851 0xFFFDDFFFU, 0xFFFFFFFFU, 0xFFF0FDDFU, 0xFFFFFFCFU,
852 0xFC7FFFEEU, 0x2FFBFFFFU, 0xFF5F847FU, 0x001CFFC0U,
853 0xFFFFFFFEU, 0x87FFFFFFU, 0x0FFFFFFFU, 0x00000000U,
854 0xFFFFF7D6U, 0x3FFFFFAFU, 0xF3FF7F5FU, 0x00000000U,
855 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFEFFU, 0xFFFE1FFFU,
856 0xFEFFFFFFU, 0xDFFFFFFFU, 0x07FFDFFFU, 0x00000000U,
857 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
858 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU,
859 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
860 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
861 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU,
862 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU,
863 0xFF3DFFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU, 0x1FFFFFFFU,
864 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU,
865 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
866 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
867 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
868 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
869 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
870 0x1FFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU,
871 0x803FFFFFU, 0x007FFFFFU, 0x000FFFFFU, 0x000DDFFFU,
872 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x03FF03FFU,
873 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU,
874 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, 0x003FFFFFU,
875 0x7FFFFFFFU, 0x0FFF0FFFU, 0xFFFFFFF1U, 0x001F3FFFU,
876 0xFFFFFFFFU, 0xFFFF0FFFU, 0xC7FF03FFU, 0xFFFFFFFFU,
877 0xCFFFFFFFU, 0xFFFFFFFFU, 0x7FFFFFFFU, 0x9FFFFFFFU,
878 0x03FF03FFU, 0xFFFF3FFFU, 0x3FFFFFFFU, 0x00000FFFU,
879 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFDFFFU, 0xFFFFFFFFU,
880 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF00FFFFFU,
881 0xFFFFFFFFU, 0xF8FFFFFFU, 0xFFFFE3FFU, 0xFFFFFFFFU,
882 0xFFFF07FFU, 0xE7FFFFFFU, 0xFFFF00FFU, 0x07FFFFFFU,
883 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
884 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
885 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
886 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
887 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU,
888 0xFFFFFFFFU, 0xFFDFFFFFU, 0xEFCFFFDFU, 0x7FDCFFFFU,
889 0xFFFFF880U, 0xFFFFFCFFU, 0x7FFFFFFFU, 0xFFF3FFDFU,
890 0x1FFF7FFFU, 0xFFFFFFFFU, 0xFFFF0003U, 0x0001FFFFU,
891 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
892 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
893 0xFFFFFFFFU, 0x000003FFU, 0x000007FFU, 0xFFFFFFFFU,
894 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
895 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
896 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
897 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
898 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
899 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFCFFFFFU,
900 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
901 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
902 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFE0FFFFFU,
903 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x800180FFU,
904 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0xFFFFFFFFU,
905 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U,
906 0xFBFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU,
907 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
908 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0xFFFF0000U,
909 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU,
910 0xFE7FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
911 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
912 0xFFFF7FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF803FU,
913 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
914 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
915 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
916 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
917 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
918 0xFFFF1FFFU, 0xFFFFFFFFU, 0xFFFF007FU, 0xFFFFFFFFU,
919 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
920 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
921 0xFFFFFFFFU, 0x00000FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
922 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU,
923 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
924 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU, 0xFFFE0000U,
925 0xFFFFFFFFU, 0x03FF1FFFU, 0xFFFFFFFFU, 0x00FFFFFFU,
926 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFC03FU, 0xFFFFFFFFU,
927 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800FFFFFU, 0x1FFFFFFFU,
928 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FFBFFFU, 0x7FFFFFFFU,
929 0xFFFFFFFFU, 0x007FFFFFU, 0xF3FF3FFFU, 0xFFFFFFFFU,
930 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF8000007U, 0x007FFFFFU,
931 0x007E7E7EU, 0xFFFF7F7FU, 0xFFFFFFFFU, 0xFFFF0FFFU,
932 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF3FFFU,
933 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
934 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
935 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
936 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU,
937 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU,
938 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U,
939 0xE0F8007FU, 0x5F7FFFFFU, 0xFFFFFFDBU, 0xFFFFFFFFU,
940 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
941 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
942 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
943 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
944 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, 0xFFFF0000U,
945 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFF7FFFFU, 0xFFDF0F7FU,
946 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x9FFFFFFFU,
947 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
948 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x3E007F7FU,
949 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U,
950 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
951 0xFFFFFF87U, 0xFF8FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
952 0x1FFF7FFFU, 0x00000001U, 0xFFFF0000U, 0x3FFFFFFFU,
953 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
954 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x0FFFFFFFU,
955 0xFFFFFFFFU, 0xFFFFE00FU, 0xFFFF07FFU, 0x07FFFFFFU,
956 0xBFFFFFFFU, 0xFFFFFFFFU, 0x003FFF0FU, 0x00000000U,
957 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
958 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU,
959 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF800FU,
960 0xFFB7F7FFU, 0x1BFBFFFBU, 0xFFFFFFFFU, 0x000FFFFFU,
961 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
962 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
963 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU,
964 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U,
965 0xFFFFFD3FU, 0x91BFFFFFU, 0xFFBFFFFFU, 0xFFFFFFFFU,
966 0x7FFFFFFFU, 0x0000FF80U, 0x00000000U, 0xF837FFFFU,
967 0x8FFFFFFFU, 0x83FFFFFFU, 0x03FFFFFFU, 0x00000000U,
968 0xFFFFFFFFU, 0xF0FFFFFFU, 0xFFFCFFFFU, 0xFFFFFFFFU,
969 0xFEEFF06FU, 0x873FFFFFU, 0x01FF01FFU, 0xFFFFFFFFU,
970 0xFFFFFFFFU, 0x00000000U, 0xFFFFFFFFU, 0x007FF87FU,
971 0xFFFFFFFFU, 0xFE3FFFFFU, 0xFF3FFFFFU, 0xFF07FFFFU,
972 0x1E03FFFFU, 0x0000FE00U, 0x00000000U, 0x00000000U,
973 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U,
974 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0xFC07FFFFU,
975 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU, 0xFFFFFE3FU,
976 0x0000C03FU, 0x00000000U, 0x00000000U, 0x00000000U,
977 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFFFFFFU,
978 0xFFFFFFFFU, 0x00033BFFU, 0x01FF00FCU, 0xFC000000U,
979 0xFFFFFFFFU, 0xFFFF00FFU, 0x03FFFFFFU, 0xFFFF0000U,
980 0x000003FFU, 0xFFFF0000U, 0x00000FFFU, 0x007FFFFFU,
981 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFC3FFFU, 0x803FFFFFU,
982 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF2007U, 0x03FF01FFU,
983 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFF00FFU, 0x007FFFFFU,
984 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001FFFFEU,
985 0xFFFBFFFFU, 0xFFFFFFFFU, 0x00000003U, 0x00000000U,
986 0xBFFFBD7FU, 0xFFFF03FFU, 0xFFFFFFFFU, 0x03FF07FFU,
987 0xFFF99FEFU, 0xFBEDFDFFU, 0xE081399FU, 0x001F1FCFU,
988 0xFFFF4BFFU, 0xFFBFFFFFU, 0x01BFF7A5U, 0x00000006U,
989 0xFFFFFFFFU, 0xFFFFFFFFU, 0xEFFFFFFFU, 0x00000003U,
990 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0x00000000U,
991 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
992 0xFFFFFFFFU, 0xFF3FFFFFU, 0x3FFFFFFFU, 0x00000000U,
993 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF001FU, 0x00001FFFU,
994 0xFFFFFFFFU, 0x03FFFFFFU, 0xFFFF03FFU, 0x0000000FU,
995 0xE7FFFFFFU, 0xFFFF0FFFU, 0x0000007FU, 0x00000000U,
996 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
997 0xFFFFFFFFU, 0x0FFFFFFFU, 0x00000000U, 0x00000000U,
998 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x8007FFFFU,
999 0xFF6FF27FU, 0xF9BFFFFFU, 0x03FF007FU, 0x00000000U,
1000 0x00000000U, 0xFFFFFCFFU, 0xFCFFFFFFU, 0x0000001FU,
1001 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU,
1002 0xFFFFFFFFU, 0xFFFF0007U, 0xFFFFFFFFU, 0x01FFFFFFU,
1003 0x000003FFU, 0x00000000U, 0x00000000U, 0x000000FFU,
1004 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FF0003U,
1005 0xFFFFFDFFU, 0xFF7FFFFFU, 0xFFFF003FU, 0xFFFF1FFFU,
1006 0xFFFCFFFFU, 0x007FFEFFU, 0x00000000U, 0x00000000U,
1007 0xFFFFFB7FU, 0xB47FFFFFU, 0x03FF00FFU, 0xFFFFFDBFU,
1008 0x01FB7FFFU, 0xFFFF03FFU, 0x0FFFFFFFU, 0x000003FFU,
1009 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1010 0x00000000U, 0x00000000U, 0x00000000U, 0x01FFFFFFU,
1011 0xFFFDFFFFU, 0xC7FFFFFFU, 0x07FFFFFFU, 0x00000000U,
1012 0x00000000U, 0x00010000U, 0xFFFFFFFFU, 0x8003FFFFU,
1013 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1014 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1015 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1016 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1017 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001F7FFFU,
1018 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1019 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
1020 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1021 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1022 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1023 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1024 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
1025 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0xFFFFFFFFU,
1026 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1027 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1028 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1029 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1030 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1031 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1032 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
1033 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U,
1034 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1035 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1036 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1037 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1038 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1039 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U, 0x00000000U,
1040 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1041 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFFC3FFU,
1042 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x003F3FFFU,
1043 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFBFF003FU, 0xE0FFFFFBU,
1044 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1045 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1046 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1047 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FFFFFFU,
1048 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1049 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU,
1050 0x07FFFFFFU, 0xF9FFFFFFU, 0x000FFFFFU, 0x00000000U,
1051 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF87FFU, 0xFFFFFFFFU,
1052 0xFFFF80FFU, 0x00000000U, 0x00000000U, 0x007F001FU,
1053 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1054 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x80000000U,
1055 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1056 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
1057 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1058 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1059 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1060 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U,
1061 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1062 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1063 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U,
1064 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1065 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1066 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU,
1067 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1068 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1069 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU,
1070 0xF3FF01FFU, 0x0000000FU, 0x00000000U, 0x00000000U,
1071 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1072 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1073 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1074 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU,
1075 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1076 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1077 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1078 0xFFFFFFFFU, 0xFC0FFFFFU, 0x0001FFFFU, 0x0001FFFFU,
1079 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFF007FU, 0xFFFFFFFFU,
1080 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
1081 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1082 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU,
1083 0xFFFFFFFFU, 0xFFFFFE7FU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1084 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000007FFU,
1085 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000003FU, 0x00000000U,
1086 0x00000000U, 0x00000000U, 0x000FFFFFU, 0x000FFFFFU,
1087 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFFFFU, 0x01FFFFFFU,
1088 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1089 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU,
1090 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU,
1091 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU,
1092 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1093 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1094 0xFFFFFFFFU, 0xFFFFFF3FU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1095 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1096 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFCFFFU, 0xFFFFFFFFU,
1097 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1098 0xF8000FFFU, 0x0000FFFEU, 0x00000000U, 0x00000000U,
1099 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1100 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1101 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1102 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1103 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U,
1104 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1105 0xF9FFFF7FU, 0xFFFF07DBU, 0xFFFFFFFFU, 0x00003FFFU,
1106 0x00008000U, 0x00000000U, 0x00000000U, 0x00000000U,
1107 0xFFFFFFFFU, 0x3FFF1FFFU, 0x0000C3FFU, 0x00000000U,
1108 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1109 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1110 0xFFFF0000U, 0x00007FFFU, 0xFFFFFFFFU, 0x83FFFFFFU,
1111 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1112 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1113 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1114 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FFFFFFU,
1115 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1116 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x87FFFFFFU,
1117 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1118 0x00000000U, 0x00000000U, 0x7FFFFFFFU, 0xC03FFFFFU,
1119 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1120 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU,
1121 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1122 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFF9FU, 0x00000000U,
1123 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FF0FFFU, 0x00000000U,
1124 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1125 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFE0000U,
1126 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, 0x00000000U,
1127 0xFFFFFFFEU, 0x3FFFFFFFU, 0x00000000U, 0x00000000U,
1128 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1129 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U,
1130 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00030000U,
1131 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1132 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1133 0xFFFFFFFFU, 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1134 0x000FFFFFU, 0xFFFE7FFFU, 0xFFFEFFFEU, 0x003FFFFFU,
1135 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1136 0xFFFFFFFFU, 0x00003FFFU, 0x00000000U, 0xFFFFFFC0U,
1137 0xFFFF0007U, 0x0FFFFFFFU, 0x000301FFU, 0x0000003FU,
1138 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1139 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1140 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1141 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1142 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF1FFFFFFU, 0x1FFF1FFFU,
1143 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1144 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00010FFFU,
1145 0xFFFF0FFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU,
1146 0xFFFF00FFU, 0x0FFF3FFFU, 0x01FF0003U, 0x00000000U,
1147 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1148 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1149 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, 0x1FFF3FFFU,
1150 0xFFFFC7FFU, 0xFFFFFFFFU, 0x9FFFE17FU, 0x01FF87FFU,
1151 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1152 0xFFF7FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
1153 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1154 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U,
1155 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1156 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1157 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1158 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1159 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1160 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1161 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1162 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1163 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1164 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1165 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1166 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1167 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1168 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF0001U,
1169 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U,
1170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1171 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1172 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1173 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1174 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1175 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1176 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1177 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1178 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1179 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU,
1180 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1181 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU,
1182 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1183 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1184 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1185 0x00000002U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1186 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1187 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1188 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU,
1189 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1190 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1191 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1192 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU
1193 }
1194};
diff --git a/gl/unictype/ctype_lower.c b/gl/unictype/ctype_lower.c
new file mode 100644
index 00000000..b113106f
--- /dev/null
+++ b/gl/unictype/ctype_lower.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_lower table. */
26#include "ctype_lower.h"
27
28bool
29uc_is_lower (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_lower, uc);
32}
diff --git a/gl/unictype/ctype_lower.h b/gl/unictype/ctype_lower.h
new file mode 100644
index 00000000..aae2e4cc
--- /dev/null
+++ b/gl/unictype/ctype_lower.h
@@ -0,0 +1,371 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[2];
29 short level2[2 << 7];
30 unsigned int level3[18 << 4];
31 }
32u_is_lower =
33{
34 { 2 },
35 {
36 3 * sizeof (int) / sizeof (short) + 0,
37 3 * sizeof (int) / sizeof (short) + 128
38 },
39 {
40 3 + 256 * sizeof (short) / sizeof (int) + 0,
41 3 + 256 * sizeof (short) / sizeof (int) + 16,
42 3 + 256 * sizeof (short) / sizeof (int) + 32,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 3 + 256 * sizeof (short) / sizeof (int) + 48,
49 3 + 256 * sizeof (short) / sizeof (int) + 64,
50 -1,
51 -1,
52 -1,
53 -1,
54 3 + 256 * sizeof (short) / sizeof (int) + 80,
55 3 + 256 * sizeof (short) / sizeof (int) + 96,
56 3 + 256 * sizeof (short) / sizeof (int) + 112,
57 -1,
58 3 + 256 * sizeof (short) / sizeof (int) + 128,
59 -1,
60 -1,
61 -1,
62 3 + 256 * sizeof (short) / sizeof (int) + 144,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 3 + 256 * sizeof (short) / sizeof (int) + 160,
124 -1,
125 3 + 256 * sizeof (short) / sizeof (int) + 176,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 -1,
167 3 + 256 * sizeof (short) / sizeof (int) + 192,
168 -1,
169 -1,
170 3 + 256 * sizeof (short) / sizeof (int) + 208,
171 -1,
172 -1,
173 -1,
174 3 + 256 * sizeof (short) / sizeof (int) + 224,
175 -1,
176 -1,
177 -1,
178 -1,
179 -1,
180 3 + 256 * sizeof (short) / sizeof (int) + 240,
181 -1,
182 -1,
183 -1,
184 -1,
185 -1,
186 -1,
187 -1,
188 -1,
189 -1,
190 -1,
191 -1,
192 -1,
193 -1,
194 -1,
195 -1,
196 -1,
197 -1,
198 -1,
199 -1,
200 -1,
201 -1,
202 -1,
203 -1,
204 -1,
205 -1,
206 -1,
207 -1,
208 -1,
209 -1,
210 -1,
211 -1,
212 -1,
213 -1,
214 -1,
215 -1,
216 -1,
217 -1,
218 -1,
219 -1,
220 -1,
221 -1,
222 -1,
223 3 + 256 * sizeof (short) / sizeof (int) + 256,
224 -1,
225 -1,
226 -1,
227 -1,
228 -1,
229 -1,
230 -1,
231 -1,
232 -1,
233 -1,
234 -1,
235 -1,
236 -1,
237 -1,
238 -1,
239 -1,
240 -1,
241 -1,
242 -1,
243 -1,
244 -1,
245 -1,
246 -1,
247 -1,
248 -1,
249 -1,
250 -1,
251 -1,
252 -1,
253 -1,
254 -1,
255 -1,
256 -1,
257 -1,
258 -1,
259 -1,
260 -1,
261 -1,
262 -1,
263 -1,
264 -1,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 -1,
271 -1,
272 -1,
273 -1,
274 -1,
275 -1,
276 -1,
277 -1,
278 -1,
279 -1,
280 -1,
281 -1,
282 -1,
283 -1,
284 3 + 256 * sizeof (short) / sizeof (int) + 272,
285 -1,
286 -1,
287 -1,
288 -1,
289 -1,
290 -1,
291 -1,
292 -1,
293 -1,
294 -1,
295 -1
296 },
297 {
298 0x00000000U, 0x00000000U, 0x00000000U, 0x07FFFFFEU,
299 0x00000000U, 0x00200000U, 0x80000000U, 0xFF7FFFFFU,
300 0xAAAAAAAAU, 0x54AAAAAAU, 0xAAAAA955U, 0xD4AAAAAAU,
301 0x4E241129U, 0xA251212AU, 0xB5555B60U, 0xAA2CAAAAU,
302 0xAAAAAAAAU, 0x900AAAA8U, 0x1ADFAA85U, 0x20269F7BU,
303 0x60041F8DU, 0x00000000U, 0x00000000U, 0x00000000U,
304 0x00000000U, 0x00000000U, 0x00000020U, 0x388A0000U,
305 0x00000000U, 0xFFFEF000U, 0xAAE37FFFU, 0x092FAAAAU,
306 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0xAAAAAAAAU,
307 0xAAAAA802U, 0xAAAAAAAAU, 0xAAAAD554U, 0xAAAAAAAAU,
308 0xAAAAAAAAU, 0x0000AAAAU, 0x00000000U, 0xFFFFFFFEU,
309 0x0000007FU, 0x00000000U, 0x00000000U, 0x00000000U,
310 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
311 0x00000000U, 0x00000000U, 0xFFFF0000U, 0xE7FFFFFFU,
312 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
313 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
314 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
315 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
316 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
317 0x00000000U, 0x00000000U, 0x00000000U, 0x3F000000U,
318 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
319 0x000005FFU, 0x00000000U, 0x00000000U, 0x00000000U,
320 0x00000000U, 0x00000000U, 0x00000000U, 0x22000000U,
321 0x00004000U, 0x00000000U, 0x00000000U, 0x00000000U,
322 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU,
323 0x082AAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU,
324 0x003F00FFU, 0x00FF00FFU, 0x00AA003FU, 0x3FFF00FFU,
325 0x00FF00FFU, 0x400B00FFU, 0x00030008U, 0x00080023U,
326 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
327 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
328 0x00000000U, 0x00000000U, 0x00004000U, 0xFFFF0000U,
329 0x00000010U, 0x00000000U, 0x00000000U, 0x00000000U,
330 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
331 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x000003FFU,
332 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
333 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
334 0x00000000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x00481562U,
335 0xAAAAAAAAU, 0xAAAAAAAAU, 0xAAAAAAAAU, 0x0008500AU,
336 0xFFFFFFFFU, 0x000020BFU, 0x00000000U, 0x00000000U,
337 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
338 0x00000000U, 0x00000000U, 0xAAAAAAAAU, 0x00002AAAU,
339 0x0AAAAAAAU, 0x00000000U, 0x00000000U, 0x00000000U,
340 0x00000000U, 0xAAA8AAA8U, 0xAAAAAAAAU, 0x9400AAAAU,
341 0xAA9A10AAU, 0xAAA002AAU, 0x0AAAA50AU, 0x00400000U,
342 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
343 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
344 0x00000000U, 0x00000000U, 0x00080000U, 0xFFFF0000U,
345 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
346 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
347 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
348 0x00000000U, 0x00000000U, 0x07FFFFFEU, 0x00000000U,
349 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
350 0x00000000U, 0xFFFFFF00U, 0x0000FFFFU, 0x00000000U,
351 0x00000000U, 0x00000000U, 0xFF000000U, 0x0FFFFFFFU,
352 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
353 0xFF800000U, 0x1BFBFFFBU, 0x00000000U, 0x00000000U,
354 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
355 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x0007FFFFU,
356 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFF0000U,
357 0x0000003FU, 0x00000000U, 0x00000000U, 0x00000000U,
358 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
359 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x00000000U,
360 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
361 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
362 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFFFFFFU,
363 0x00000000U, 0xF8000000U, 0x000FFFFFU, 0x00000000U,
364 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
365 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
366 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
367 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
368 0x00000000U, 0xFFFFFFFCU, 0x0000000FU, 0x00000000U,
369 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
370 }
371};
diff --git a/gl/unictype/ctype_print.c b/gl/unictype/ctype_print.c
new file mode 100644
index 00000000..f689b0ad
--- /dev/null
+++ b/gl/unictype/ctype_print.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_print table. */
26#include "ctype_print.h"
27
28bool
29uc_is_print (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_print, uc);
32}
diff --git a/gl/unictype/ctype_print.h b/gl/unictype/ctype_print.h
new file mode 100644
index 00000000..e2c34597
--- /dev/null
+++ b/gl/unictype/ctype_print.h
@@ -0,0 +1,1194 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[17];
29 short level2[6 << 7];
30 unsigned int level3[92 << 4];
31 }
32u_is_print =
33{
34 { 17 },
35 {
36 18 * sizeof (int) / sizeof (short) + 0,
37 18 * sizeof (int) / sizeof (short) + 128,
38 18 * sizeof (int) / sizeof (short) + 256,
39 18 * sizeof (int) / sizeof (short) + 384,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 18 * sizeof (int) / sizeof (short) + 512,
51 18 * sizeof (int) / sizeof (short) + 640,
52 18 * sizeof (int) / sizeof (short) + 640
53 },
54 {
55 18 + 768 * sizeof (short) / sizeof (int) + 0,
56 18 + 768 * sizeof (short) / sizeof (int) + 16,
57 18 + 768 * sizeof (short) / sizeof (int) + 32,
58 18 + 768 * sizeof (short) / sizeof (int) + 48,
59 18 + 768 * sizeof (short) / sizeof (int) + 64,
60 18 + 768 * sizeof (short) / sizeof (int) + 80,
61 18 + 768 * sizeof (short) / sizeof (int) + 96,
62 18 + 768 * sizeof (short) / sizeof (int) + 112,
63 18 + 768 * sizeof (short) / sizeof (int) + 128,
64 18 + 768 * sizeof (short) / sizeof (int) + 144,
65 18 + 768 * sizeof (short) / sizeof (int) + 160,
66 18 + 768 * sizeof (short) / sizeof (int) + 176,
67 18 + 768 * sizeof (short) / sizeof (int) + 192,
68 18 + 768 * sizeof (short) / sizeof (int) + 208,
69 18 + 768 * sizeof (short) / sizeof (int) + 224,
70 18 + 768 * sizeof (short) / sizeof (int) + 240,
71 18 + 768 * sizeof (short) / sizeof (int) + 256,
72 18 + 768 * sizeof (short) / sizeof (int) + 160,
73 18 + 768 * sizeof (short) / sizeof (int) + 272,
74 18 + 768 * sizeof (short) / sizeof (int) + 160,
75 18 + 768 * sizeof (short) / sizeof (int) + 160,
76 18 + 768 * sizeof (short) / sizeof (int) + 288,
77 18 + 768 * sizeof (short) / sizeof (int) + 304,
78 18 + 768 * sizeof (short) / sizeof (int) + 320,
79 18 + 768 * sizeof (short) / sizeof (int) + 336,
80 18 + 768 * sizeof (short) / sizeof (int) + 352,
81 18 + 768 * sizeof (short) / sizeof (int) + 160,
82 18 + 768 * sizeof (short) / sizeof (int) + 160,
83 18 + 768 * sizeof (short) / sizeof (int) + 160,
84 18 + 768 * sizeof (short) / sizeof (int) + 160,
85 18 + 768 * sizeof (short) / sizeof (int) + 160,
86 18 + 768 * sizeof (short) / sizeof (int) + 160,
87 18 + 768 * sizeof (short) / sizeof (int) + 160,
88 18 + 768 * sizeof (short) / sizeof (int) + 160,
89 18 + 768 * sizeof (short) / sizeof (int) + 160,
90 18 + 768 * sizeof (short) / sizeof (int) + 160,
91 18 + 768 * sizeof (short) / sizeof (int) + 160,
92 18 + 768 * sizeof (short) / sizeof (int) + 160,
93 18 + 768 * sizeof (short) / sizeof (int) + 160,
94 18 + 768 * sizeof (short) / sizeof (int) + 160,
95 18 + 768 * sizeof (short) / sizeof (int) + 160,
96 18 + 768 * sizeof (short) / sizeof (int) + 160,
97 18 + 768 * sizeof (short) / sizeof (int) + 160,
98 18 + 768 * sizeof (short) / sizeof (int) + 160,
99 18 + 768 * sizeof (short) / sizeof (int) + 160,
100 18 + 768 * sizeof (short) / sizeof (int) + 160,
101 18 + 768 * sizeof (short) / sizeof (int) + 160,
102 18 + 768 * sizeof (short) / sizeof (int) + 160,
103 18 + 768 * sizeof (short) / sizeof (int) + 160,
104 18 + 768 * sizeof (short) / sizeof (int) + 160,
105 18 + 768 * sizeof (short) / sizeof (int) + 160,
106 18 + 768 * sizeof (short) / sizeof (int) + 160,
107 18 + 768 * sizeof (short) / sizeof (int) + 160,
108 18 + 768 * sizeof (short) / sizeof (int) + 160,
109 18 + 768 * sizeof (short) / sizeof (int) + 160,
110 18 + 768 * sizeof (short) / sizeof (int) + 160,
111 18 + 768 * sizeof (short) / sizeof (int) + 160,
112 18 + 768 * sizeof (short) / sizeof (int) + 160,
113 18 + 768 * sizeof (short) / sizeof (int) + 160,
114 18 + 768 * sizeof (short) / sizeof (int) + 160,
115 18 + 768 * sizeof (short) / sizeof (int) + 160,
116 18 + 768 * sizeof (short) / sizeof (int) + 160,
117 18 + 768 * sizeof (short) / sizeof (int) + 160,
118 18 + 768 * sizeof (short) / sizeof (int) + 160,
119 18 + 768 * sizeof (short) / sizeof (int) + 160,
120 18 + 768 * sizeof (short) / sizeof (int) + 160,
121 18 + 768 * sizeof (short) / sizeof (int) + 160,
122 18 + 768 * sizeof (short) / sizeof (int) + 160,
123 18 + 768 * sizeof (short) / sizeof (int) + 160,
124 18 + 768 * sizeof (short) / sizeof (int) + 160,
125 18 + 768 * sizeof (short) / sizeof (int) + 160,
126 18 + 768 * sizeof (short) / sizeof (int) + 160,
127 18 + 768 * sizeof (short) / sizeof (int) + 160,
128 18 + 768 * sizeof (short) / sizeof (int) + 160,
129 18 + 768 * sizeof (short) / sizeof (int) + 160,
130 18 + 768 * sizeof (short) / sizeof (int) + 160,
131 18 + 768 * sizeof (short) / sizeof (int) + 160,
132 18 + 768 * sizeof (short) / sizeof (int) + 160,
133 18 + 768 * sizeof (short) / sizeof (int) + 160,
134 18 + 768 * sizeof (short) / sizeof (int) + 160,
135 18 + 768 * sizeof (short) / sizeof (int) + 160,
136 18 + 768 * sizeof (short) / sizeof (int) + 160,
137 18 + 768 * sizeof (short) / sizeof (int) + 368,
138 18 + 768 * sizeof (short) / sizeof (int) + 384,
139 18 + 768 * sizeof (short) / sizeof (int) + 400,
140 18 + 768 * sizeof (short) / sizeof (int) + 416,
141 18 + 768 * sizeof (short) / sizeof (int) + 160,
142 18 + 768 * sizeof (short) / sizeof (int) + 160,
143 18 + 768 * sizeof (short) / sizeof (int) + 160,
144 18 + 768 * sizeof (short) / sizeof (int) + 160,
145 18 + 768 * sizeof (short) / sizeof (int) + 160,
146 18 + 768 * sizeof (short) / sizeof (int) + 160,
147 18 + 768 * sizeof (short) / sizeof (int) + 160,
148 18 + 768 * sizeof (short) / sizeof (int) + 160,
149 18 + 768 * sizeof (short) / sizeof (int) + 160,
150 18 + 768 * sizeof (short) / sizeof (int) + 160,
151 18 + 768 * sizeof (short) / sizeof (int) + 160,
152 18 + 768 * sizeof (short) / sizeof (int) + 160,
153 18 + 768 * sizeof (short) / sizeof (int) + 160,
154 18 + 768 * sizeof (short) / sizeof (int) + 160,
155 18 + 768 * sizeof (short) / sizeof (int) + 160,
156 18 + 768 * sizeof (short) / sizeof (int) + 160,
157 18 + 768 * sizeof (short) / sizeof (int) + 160,
158 18 + 768 * sizeof (short) / sizeof (int) + 160,
159 18 + 768 * sizeof (short) / sizeof (int) + 160,
160 18 + 768 * sizeof (short) / sizeof (int) + 160,
161 18 + 768 * sizeof (short) / sizeof (int) + 160,
162 18 + 768 * sizeof (short) / sizeof (int) + 432,
163 -1,
164 -1,
165 -1,
166 -1,
167 18 + 768 * sizeof (short) / sizeof (int) + 160,
168 18 + 768 * sizeof (short) / sizeof (int) + 160,
169 18 + 768 * sizeof (short) / sizeof (int) + 160,
170 18 + 768 * sizeof (short) / sizeof (int) + 160,
171 18 + 768 * sizeof (short) / sizeof (int) + 160,
172 18 + 768 * sizeof (short) / sizeof (int) + 160,
173 18 + 768 * sizeof (short) / sizeof (int) + 160,
174 18 + 768 * sizeof (short) / sizeof (int) + 160,
175 18 + 768 * sizeof (short) / sizeof (int) + 160,
176 18 + 768 * sizeof (short) / sizeof (int) + 160,
177 18 + 768 * sizeof (short) / sizeof (int) + 160,
178 18 + 768 * sizeof (short) / sizeof (int) + 160,
179 18 + 768 * sizeof (short) / sizeof (int) + 160,
180 18 + 768 * sizeof (short) / sizeof (int) + 448,
181 18 + 768 * sizeof (short) / sizeof (int) + 464,
182 18 + 768 * sizeof (short) / sizeof (int) + 480,
183 18 + 768 * sizeof (short) / sizeof (int) + 496,
184 18 + 768 * sizeof (short) / sizeof (int) + 512,
185 18 + 768 * sizeof (short) / sizeof (int) + 528,
186 18 + 768 * sizeof (short) / sizeof (int) + 544,
187 18 + 768 * sizeof (short) / sizeof (int) + 560,
188 18 + 768 * sizeof (short) / sizeof (int) + 576,
189 18 + 768 * sizeof (short) / sizeof (int) + 592,
190 18 + 768 * sizeof (short) / sizeof (int) + 608,
191 18 + 768 * sizeof (short) / sizeof (int) + 624,
192 18 + 768 * sizeof (short) / sizeof (int) + 640,
193 18 + 768 * sizeof (short) / sizeof (int) + 656,
194 18 + 768 * sizeof (short) / sizeof (int) + 672,
195 18 + 768 * sizeof (short) / sizeof (int) + 688,
196 18 + 768 * sizeof (short) / sizeof (int) + 704,
197 18 + 768 * sizeof (short) / sizeof (int) + 720,
198 18 + 768 * sizeof (short) / sizeof (int) + 736,
199 18 + 768 * sizeof (short) / sizeof (int) + 160,
200 18 + 768 * sizeof (short) / sizeof (int) + 752,
201 18 + 768 * sizeof (short) / sizeof (int) + 768,
202 -1,
203 -1,
204 -1,
205 -1,
206 18 + 768 * sizeof (short) / sizeof (int) + 784,
207 18 + 768 * sizeof (short) / sizeof (int) + 160,
208 18 + 768 * sizeof (short) / sizeof (int) + 160,
209 18 + 768 * sizeof (short) / sizeof (int) + 800,
210 18 + 768 * sizeof (short) / sizeof (int) + 160,
211 18 + 768 * sizeof (short) / sizeof (int) + 160,
212 18 + 768 * sizeof (short) / sizeof (int) + 160,
213 18 + 768 * sizeof (short) / sizeof (int) + 160,
214 18 + 768 * sizeof (short) / sizeof (int) + 160,
215 18 + 768 * sizeof (short) / sizeof (int) + 160,
216 18 + 768 * sizeof (short) / sizeof (int) + 816,
217 18 + 768 * sizeof (short) / sizeof (int) + 160,
218 18 + 768 * sizeof (short) / sizeof (int) + 832,
219 -1,
220 -1,
221 -1,
222 -1,
223 -1,
224 -1,
225 -1,
226 -1,
227 -1,
228 -1,
229 -1,
230 -1,
231 18 + 768 * sizeof (short) / sizeof (int) + 848,
232 -1,
233 -1,
234 -1,
235 18 + 768 * sizeof (short) / sizeof (int) + 160,
236 18 + 768 * sizeof (short) / sizeof (int) + 864,
237 18 + 768 * sizeof (short) / sizeof (int) + 880,
238 18 + 768 * sizeof (short) / sizeof (int) + 896,
239 18 + 768 * sizeof (short) / sizeof (int) + 160,
240 18 + 768 * sizeof (short) / sizeof (int) + 160,
241 18 + 768 * sizeof (short) / sizeof (int) + 160,
242 18 + 768 * sizeof (short) / sizeof (int) + 160,
243 18 + 768 * sizeof (short) / sizeof (int) + 160,
244 18 + 768 * sizeof (short) / sizeof (int) + 160,
245 18 + 768 * sizeof (short) / sizeof (int) + 160,
246 18 + 768 * sizeof (short) / sizeof (int) + 160,
247 18 + 768 * sizeof (short) / sizeof (int) + 160,
248 18 + 768 * sizeof (short) / sizeof (int) + 160,
249 18 + 768 * sizeof (short) / sizeof (int) + 160,
250 18 + 768 * sizeof (short) / sizeof (int) + 160,
251 18 + 768 * sizeof (short) / sizeof (int) + 160,
252 18 + 768 * sizeof (short) / sizeof (int) + 160,
253 18 + 768 * sizeof (short) / sizeof (int) + 912,
254 -1,
255 -1,
256 -1,
257 -1,
258 -1,
259 -1,
260 -1,
261 -1,
262 -1,
263 -1,
264 -1,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 18 + 768 * sizeof (short) / sizeof (int) + 928,
271 18 + 768 * sizeof (short) / sizeof (int) + 944,
272 18 + 768 * sizeof (short) / sizeof (int) + 960,
273 -1,
274 -1,
275 -1,
276 -1,
277 18 + 768 * sizeof (short) / sizeof (int) + 976,
278 -1,
279 -1,
280 -1,
281 -1,
282 -1,
283 -1,
284 -1,
285 18 + 768 * sizeof (short) / sizeof (int) + 992,
286 18 + 768 * sizeof (short) / sizeof (int) + 1008,
287 18 + 768 * sizeof (short) / sizeof (int) + 1024,
288 18 + 768 * sizeof (short) / sizeof (int) + 1040,
289 18 + 768 * sizeof (short) / sizeof (int) + 1056,
290 18 + 768 * sizeof (short) / sizeof (int) + 1072,
291 18 + 768 * sizeof (short) / sizeof (int) + 160,
292 18 + 768 * sizeof (short) / sizeof (int) + 1088,
293 -1,
294 18 + 768 * sizeof (short) / sizeof (int) + 1104,
295 18 + 768 * sizeof (short) / sizeof (int) + 1120,
296 18 + 768 * sizeof (short) / sizeof (int) + 1136,
297 18 + 768 * sizeof (short) / sizeof (int) + 1152,
298 18 + 768 * sizeof (short) / sizeof (int) + 1168,
299 18 + 768 * sizeof (short) / sizeof (int) + 1184,
300 -1,
301 18 + 768 * sizeof (short) / sizeof (int) + 1200,
302 18 + 768 * sizeof (short) / sizeof (int) + 1216,
303 18 + 768 * sizeof (short) / sizeof (int) + 1232,
304 18 + 768 * sizeof (short) / sizeof (int) + 1248,
305 18 + 768 * sizeof (short) / sizeof (int) + 160,
306 18 + 768 * sizeof (short) / sizeof (int) + 1264,
307 18 + 768 * sizeof (short) / sizeof (int) + 1280,
308 18 + 768 * sizeof (short) / sizeof (int) + 1296,
309 -1,
310 -1,
311 18 + 768 * sizeof (short) / sizeof (int) + 160,
312 18 + 768 * sizeof (short) / sizeof (int) + 160,
313 18 + 768 * sizeof (short) / sizeof (int) + 160,
314 18 + 768 * sizeof (short) / sizeof (int) + 160,
315 18 + 768 * sizeof (short) / sizeof (int) + 160,
316 18 + 768 * sizeof (short) / sizeof (int) + 160,
317 18 + 768 * sizeof (short) / sizeof (int) + 160,
318 18 + 768 * sizeof (short) / sizeof (int) + 160,
319 18 + 768 * sizeof (short) / sizeof (int) + 160,
320 18 + 768 * sizeof (short) / sizeof (int) + 160,
321 18 + 768 * sizeof (short) / sizeof (int) + 160,
322 18 + 768 * sizeof (short) / sizeof (int) + 160,
323 18 + 768 * sizeof (short) / sizeof (int) + 160,
324 18 + 768 * sizeof (short) / sizeof (int) + 160,
325 18 + 768 * sizeof (short) / sizeof (int) + 160,
326 18 + 768 * sizeof (short) / sizeof (int) + 160,
327 18 + 768 * sizeof (short) / sizeof (int) + 160,
328 18 + 768 * sizeof (short) / sizeof (int) + 160,
329 18 + 768 * sizeof (short) / sizeof (int) + 160,
330 18 + 768 * sizeof (short) / sizeof (int) + 160,
331 18 + 768 * sizeof (short) / sizeof (int) + 160,
332 18 + 768 * sizeof (short) / sizeof (int) + 160,
333 18 + 768 * sizeof (short) / sizeof (int) + 160,
334 18 + 768 * sizeof (short) / sizeof (int) + 160,
335 18 + 768 * sizeof (short) / sizeof (int) + 160,
336 18 + 768 * sizeof (short) / sizeof (int) + 160,
337 18 + 768 * sizeof (short) / sizeof (int) + 160,
338 18 + 768 * sizeof (short) / sizeof (int) + 160,
339 18 + 768 * sizeof (short) / sizeof (int) + 160,
340 18 + 768 * sizeof (short) / sizeof (int) + 160,
341 18 + 768 * sizeof (short) / sizeof (int) + 160,
342 18 + 768 * sizeof (short) / sizeof (int) + 160,
343 18 + 768 * sizeof (short) / sizeof (int) + 160,
344 18 + 768 * sizeof (short) / sizeof (int) + 160,
345 18 + 768 * sizeof (short) / sizeof (int) + 160,
346 18 + 768 * sizeof (short) / sizeof (int) + 160,
347 18 + 768 * sizeof (short) / sizeof (int) + 160,
348 18 + 768 * sizeof (short) / sizeof (int) + 160,
349 18 + 768 * sizeof (short) / sizeof (int) + 160,
350 18 + 768 * sizeof (short) / sizeof (int) + 160,
351 18 + 768 * sizeof (short) / sizeof (int) + 160,
352 18 + 768 * sizeof (short) / sizeof (int) + 160,
353 18 + 768 * sizeof (short) / sizeof (int) + 160,
354 18 + 768 * sizeof (short) / sizeof (int) + 160,
355 18 + 768 * sizeof (short) / sizeof (int) + 160,
356 18 + 768 * sizeof (short) / sizeof (int) + 160,
357 18 + 768 * sizeof (short) / sizeof (int) + 160,
358 18 + 768 * sizeof (short) / sizeof (int) + 160,
359 18 + 768 * sizeof (short) / sizeof (int) + 160,
360 18 + 768 * sizeof (short) / sizeof (int) + 160,
361 18 + 768 * sizeof (short) / sizeof (int) + 160,
362 18 + 768 * sizeof (short) / sizeof (int) + 160,
363 18 + 768 * sizeof (short) / sizeof (int) + 160,
364 18 + 768 * sizeof (short) / sizeof (int) + 160,
365 18 + 768 * sizeof (short) / sizeof (int) + 160,
366 18 + 768 * sizeof (short) / sizeof (int) + 160,
367 18 + 768 * sizeof (short) / sizeof (int) + 160,
368 18 + 768 * sizeof (short) / sizeof (int) + 160,
369 18 + 768 * sizeof (short) / sizeof (int) + 160,
370 18 + 768 * sizeof (short) / sizeof (int) + 160,
371 18 + 768 * sizeof (short) / sizeof (int) + 160,
372 18 + 768 * sizeof (short) / sizeof (int) + 160,
373 18 + 768 * sizeof (short) / sizeof (int) + 160,
374 18 + 768 * sizeof (short) / sizeof (int) + 160,
375 18 + 768 * sizeof (short) / sizeof (int) + 160,
376 18 + 768 * sizeof (short) / sizeof (int) + 160,
377 18 + 768 * sizeof (short) / sizeof (int) + 160,
378 18 + 768 * sizeof (short) / sizeof (int) + 160,
379 18 + 768 * sizeof (short) / sizeof (int) + 160,
380 18 + 768 * sizeof (short) / sizeof (int) + 160,
381 18 + 768 * sizeof (short) / sizeof (int) + 160,
382 18 + 768 * sizeof (short) / sizeof (int) + 160,
383 18 + 768 * sizeof (short) / sizeof (int) + 160,
384 18 + 768 * sizeof (short) / sizeof (int) + 160,
385 18 + 768 * sizeof (short) / sizeof (int) + 160,
386 18 + 768 * sizeof (short) / sizeof (int) + 160,
387 18 + 768 * sizeof (short) / sizeof (int) + 160,
388 18 + 768 * sizeof (short) / sizeof (int) + 160,
389 18 + 768 * sizeof (short) / sizeof (int) + 160,
390 18 + 768 * sizeof (short) / sizeof (int) + 160,
391 18 + 768 * sizeof (short) / sizeof (int) + 160,
392 18 + 768 * sizeof (short) / sizeof (int) + 160,
393 18 + 768 * sizeof (short) / sizeof (int) + 160,
394 18 + 768 * sizeof (short) / sizeof (int) + 1312,
395 18 + 768 * sizeof (short) / sizeof (int) + 160,
396 18 + 768 * sizeof (short) / sizeof (int) + 160,
397 18 + 768 * sizeof (short) / sizeof (int) + 160,
398 18 + 768 * sizeof (short) / sizeof (int) + 160,
399 18 + 768 * sizeof (short) / sizeof (int) + 160,
400 18 + 768 * sizeof (short) / sizeof (int) + 160,
401 18 + 768 * sizeof (short) / sizeof (int) + 160,
402 18 + 768 * sizeof (short) / sizeof (int) + 160,
403 18 + 768 * sizeof (short) / sizeof (int) + 1328,
404 18 + 768 * sizeof (short) / sizeof (int) + 160,
405 18 + 768 * sizeof (short) / sizeof (int) + 160,
406 18 + 768 * sizeof (short) / sizeof (int) + 160,
407 18 + 768 * sizeof (short) / sizeof (int) + 160,
408 18 + 768 * sizeof (short) / sizeof (int) + 160,
409 18 + 768 * sizeof (short) / sizeof (int) + 160,
410 18 + 768 * sizeof (short) / sizeof (int) + 160,
411 18 + 768 * sizeof (short) / sizeof (int) + 160,
412 18 + 768 * sizeof (short) / sizeof (int) + 160,
413 18 + 768 * sizeof (short) / sizeof (int) + 160,
414 18 + 768 * sizeof (short) / sizeof (int) + 1344,
415 18 + 768 * sizeof (short) / sizeof (int) + 160,
416 18 + 768 * sizeof (short) / sizeof (int) + 160,
417 18 + 768 * sizeof (short) / sizeof (int) + 160,
418 18 + 768 * sizeof (short) / sizeof (int) + 160,
419 18 + 768 * sizeof (short) / sizeof (int) + 160,
420 18 + 768 * sizeof (short) / sizeof (int) + 160,
421 18 + 768 * sizeof (short) / sizeof (int) + 160,
422 18 + 768 * sizeof (short) / sizeof (int) + 160,
423 18 + 768 * sizeof (short) / sizeof (int) + 160,
424 18 + 768 * sizeof (short) / sizeof (int) + 160,
425 18 + 768 * sizeof (short) / sizeof (int) + 160,
426 18 + 768 * sizeof (short) / sizeof (int) + 160,
427 18 + 768 * sizeof (short) / sizeof (int) + 160,
428 18 + 768 * sizeof (short) / sizeof (int) + 1360,
429 18 + 768 * sizeof (short) / sizeof (int) + 160,
430 18 + 768 * sizeof (short) / sizeof (int) + 1376,
431 -1,
432 -1,
433 -1,
434 -1,
435 18 + 768 * sizeof (short) / sizeof (int) + 160,
436 18 + 768 * sizeof (short) / sizeof (int) + 1392,
437 -1,
438 -1,
439 18 + 768 * sizeof (short) / sizeof (int) + 160,
440 18 + 768 * sizeof (short) / sizeof (int) + 160,
441 18 + 768 * sizeof (short) / sizeof (int) + 160,
442 18 + 768 * sizeof (short) / sizeof (int) + 160,
443 18 + 768 * sizeof (short) / sizeof (int) + 160,
444 18 + 768 * sizeof (short) / sizeof (int) + 160,
445 18 + 768 * sizeof (short) / sizeof (int) + 160,
446 18 + 768 * sizeof (short) / sizeof (int) + 160,
447 18 + 768 * sizeof (short) / sizeof (int) + 160,
448 18 + 768 * sizeof (short) / sizeof (int) + 1408,
449 18 + 768 * sizeof (short) / sizeof (int) + 160,
450 18 + 768 * sizeof (short) / sizeof (int) + 160,
451 18 + 768 * sizeof (short) / sizeof (int) + 160,
452 18 + 768 * sizeof (short) / sizeof (int) + 160,
453 18 + 768 * sizeof (short) / sizeof (int) + 160,
454 18 + 768 * sizeof (short) / sizeof (int) + 160,
455 18 + 768 * sizeof (short) / sizeof (int) + 160,
456 18 + 768 * sizeof (short) / sizeof (int) + 160,
457 18 + 768 * sizeof (short) / sizeof (int) + 160,
458 18 + 768 * sizeof (short) / sizeof (int) + 160,
459 18 + 768 * sizeof (short) / sizeof (int) + 160,
460 18 + 768 * sizeof (short) / sizeof (int) + 160,
461 18 + 768 * sizeof (short) / sizeof (int) + 160,
462 18 + 768 * sizeof (short) / sizeof (int) + 160,
463 18 + 768 * sizeof (short) / sizeof (int) + 160,
464 18 + 768 * sizeof (short) / sizeof (int) + 160,
465 18 + 768 * sizeof (short) / sizeof (int) + 1424,
466 -1,
467 -1,
468 -1,
469 -1,
470 -1,
471 -1,
472 -1,
473 -1,
474 -1,
475 -1,
476 -1,
477 -1,
478 -1,
479 -1,
480 -1,
481 -1,
482 -1,
483 -1,
484 -1,
485 -1,
486 -1,
487 -1,
488 -1,
489 -1,
490 -1,
491 -1,
492 -1,
493 -1,
494 -1,
495 -1,
496 -1,
497 -1,
498 -1,
499 -1,
500 -1,
501 -1,
502 -1,
503 -1,
504 -1,
505 -1,
506 -1,
507 -1,
508 -1,
509 -1,
510 -1,
511 -1,
512 -1,
513 -1,
514 -1,
515 -1,
516 -1,
517 -1,
518 -1,
519 -1,
520 -1,
521 -1,
522 -1,
523 -1,
524 -1,
525 -1,
526 -1,
527 -1,
528 -1,
529 -1,
530 -1,
531 -1,
532 -1,
533 -1,
534 -1,
535 -1,
536 -1,
537 -1,
538 -1,
539 -1,
540 -1,
541 -1,
542 -1,
543 -1,
544 -1,
545 -1,
546 -1,
547 -1,
548 -1,
549 -1,
550 -1,
551 -1,
552 -1,
553 -1,
554 -1,
555 -1,
556 -1,
557 -1,
558 -1,
559 -1,
560 -1,
561 -1,
562 -1,
563 -1,
564 -1,
565 -1,
566 -1,
567 18 + 768 * sizeof (short) / sizeof (int) + 1440,
568 -1,
569 -1,
570 -1,
571 -1,
572 -1,
573 -1,
574 -1,
575 -1,
576 -1,
577 -1,
578 -1,
579 -1,
580 -1,
581 -1,
582 -1,
583 -1,
584 -1,
585 -1,
586 -1,
587 -1,
588 -1,
589 -1,
590 -1,
591 -1,
592 -1,
593 -1,
594 -1,
595 -1,
596 -1,
597 -1,
598 -1,
599 -1,
600 -1,
601 -1,
602 -1,
603 -1,
604 -1,
605 -1,
606 -1,
607 -1,
608 -1,
609 -1,
610 -1,
611 -1,
612 -1,
613 -1,
614 -1,
615 -1,
616 -1,
617 -1,
618 -1,
619 -1,
620 -1,
621 -1,
622 -1,
623 -1,
624 -1,
625 -1,
626 -1,
627 -1,
628 -1,
629 -1,
630 -1,
631 -1,
632 -1,
633 -1,
634 -1,
635 -1,
636 -1,
637 -1,
638 -1,
639 -1,
640 -1,
641 -1,
642 -1,
643 -1,
644 -1,
645 -1,
646 -1,
647 -1,
648 -1,
649 -1,
650 -1,
651 -1,
652 -1,
653 -1,
654 -1,
655 -1,
656 -1,
657 -1,
658 -1,
659 -1,
660 -1,
661 -1,
662 -1,
663 -1,
664 -1,
665 -1,
666 -1,
667 -1,
668 -1,
669 -1,
670 -1,
671 -1,
672 -1,
673 -1,
674 -1,
675 -1,
676 -1,
677 -1,
678 -1,
679 -1,
680 -1,
681 -1,
682 -1,
683 -1,
684 -1,
685 -1,
686 -1,
687 -1,
688 -1,
689 -1,
690 -1,
691 -1,
692 -1,
693 -1,
694 -1,
695 18 + 768 * sizeof (short) / sizeof (int) + 160,
696 18 + 768 * sizeof (short) / sizeof (int) + 160,
697 18 + 768 * sizeof (short) / sizeof (int) + 160,
698 18 + 768 * sizeof (short) / sizeof (int) + 160,
699 18 + 768 * sizeof (short) / sizeof (int) + 160,
700 18 + 768 * sizeof (short) / sizeof (int) + 160,
701 18 + 768 * sizeof (short) / sizeof (int) + 160,
702 18 + 768 * sizeof (short) / sizeof (int) + 160,
703 18 + 768 * sizeof (short) / sizeof (int) + 160,
704 18 + 768 * sizeof (short) / sizeof (int) + 160,
705 18 + 768 * sizeof (short) / sizeof (int) + 160,
706 18 + 768 * sizeof (short) / sizeof (int) + 160,
707 18 + 768 * sizeof (short) / sizeof (int) + 160,
708 18 + 768 * sizeof (short) / sizeof (int) + 160,
709 18 + 768 * sizeof (short) / sizeof (int) + 160,
710 18 + 768 * sizeof (short) / sizeof (int) + 160,
711 18 + 768 * sizeof (short) / sizeof (int) + 160,
712 18 + 768 * sizeof (short) / sizeof (int) + 160,
713 18 + 768 * sizeof (short) / sizeof (int) + 160,
714 18 + 768 * sizeof (short) / sizeof (int) + 160,
715 18 + 768 * sizeof (short) / sizeof (int) + 160,
716 18 + 768 * sizeof (short) / sizeof (int) + 160,
717 18 + 768 * sizeof (short) / sizeof (int) + 160,
718 18 + 768 * sizeof (short) / sizeof (int) + 160,
719 18 + 768 * sizeof (short) / sizeof (int) + 160,
720 18 + 768 * sizeof (short) / sizeof (int) + 160,
721 18 + 768 * sizeof (short) / sizeof (int) + 160,
722 18 + 768 * sizeof (short) / sizeof (int) + 160,
723 18 + 768 * sizeof (short) / sizeof (int) + 160,
724 18 + 768 * sizeof (short) / sizeof (int) + 160,
725 18 + 768 * sizeof (short) / sizeof (int) + 160,
726 18 + 768 * sizeof (short) / sizeof (int) + 160,
727 18 + 768 * sizeof (short) / sizeof (int) + 160,
728 18 + 768 * sizeof (short) / sizeof (int) + 160,
729 18 + 768 * sizeof (short) / sizeof (int) + 160,
730 18 + 768 * sizeof (short) / sizeof (int) + 160,
731 18 + 768 * sizeof (short) / sizeof (int) + 160,
732 18 + 768 * sizeof (short) / sizeof (int) + 160,
733 18 + 768 * sizeof (short) / sizeof (int) + 160,
734 18 + 768 * sizeof (short) / sizeof (int) + 160,
735 18 + 768 * sizeof (short) / sizeof (int) + 160,
736 18 + 768 * sizeof (short) / sizeof (int) + 160,
737 18 + 768 * sizeof (short) / sizeof (int) + 160,
738 18 + 768 * sizeof (short) / sizeof (int) + 160,
739 18 + 768 * sizeof (short) / sizeof (int) + 160,
740 18 + 768 * sizeof (short) / sizeof (int) + 160,
741 18 + 768 * sizeof (short) / sizeof (int) + 160,
742 18 + 768 * sizeof (short) / sizeof (int) + 160,
743 18 + 768 * sizeof (short) / sizeof (int) + 160,
744 18 + 768 * sizeof (short) / sizeof (int) + 160,
745 18 + 768 * sizeof (short) / sizeof (int) + 160,
746 18 + 768 * sizeof (short) / sizeof (int) + 160,
747 18 + 768 * sizeof (short) / sizeof (int) + 160,
748 18 + 768 * sizeof (short) / sizeof (int) + 160,
749 18 + 768 * sizeof (short) / sizeof (int) + 160,
750 18 + 768 * sizeof (short) / sizeof (int) + 160,
751 18 + 768 * sizeof (short) / sizeof (int) + 160,
752 18 + 768 * sizeof (short) / sizeof (int) + 160,
753 18 + 768 * sizeof (short) / sizeof (int) + 160,
754 18 + 768 * sizeof (short) / sizeof (int) + 160,
755 18 + 768 * sizeof (short) / sizeof (int) + 160,
756 18 + 768 * sizeof (short) / sizeof (int) + 160,
757 18 + 768 * sizeof (short) / sizeof (int) + 160,
758 18 + 768 * sizeof (short) / sizeof (int) + 160,
759 18 + 768 * sizeof (short) / sizeof (int) + 160,
760 18 + 768 * sizeof (short) / sizeof (int) + 160,
761 18 + 768 * sizeof (short) / sizeof (int) + 160,
762 18 + 768 * sizeof (short) / sizeof (int) + 160,
763 18 + 768 * sizeof (short) / sizeof (int) + 160,
764 18 + 768 * sizeof (short) / sizeof (int) + 160,
765 18 + 768 * sizeof (short) / sizeof (int) + 160,
766 18 + 768 * sizeof (short) / sizeof (int) + 160,
767 18 + 768 * sizeof (short) / sizeof (int) + 160,
768 18 + 768 * sizeof (short) / sizeof (int) + 160,
769 18 + 768 * sizeof (short) / sizeof (int) + 160,
770 18 + 768 * sizeof (short) / sizeof (int) + 160,
771 18 + 768 * sizeof (short) / sizeof (int) + 160,
772 18 + 768 * sizeof (short) / sizeof (int) + 160,
773 18 + 768 * sizeof (short) / sizeof (int) + 160,
774 18 + 768 * sizeof (short) / sizeof (int) + 160,
775 18 + 768 * sizeof (short) / sizeof (int) + 160,
776 18 + 768 * sizeof (short) / sizeof (int) + 160,
777 18 + 768 * sizeof (short) / sizeof (int) + 160,
778 18 + 768 * sizeof (short) / sizeof (int) + 160,
779 18 + 768 * sizeof (short) / sizeof (int) + 160,
780 18 + 768 * sizeof (short) / sizeof (int) + 160,
781 18 + 768 * sizeof (short) / sizeof (int) + 160,
782 18 + 768 * sizeof (short) / sizeof (int) + 160,
783 18 + 768 * sizeof (short) / sizeof (int) + 160,
784 18 + 768 * sizeof (short) / sizeof (int) + 160,
785 18 + 768 * sizeof (short) / sizeof (int) + 160,
786 18 + 768 * sizeof (short) / sizeof (int) + 160,
787 18 + 768 * sizeof (short) / sizeof (int) + 160,
788 18 + 768 * sizeof (short) / sizeof (int) + 160,
789 18 + 768 * sizeof (short) / sizeof (int) + 160,
790 18 + 768 * sizeof (short) / sizeof (int) + 160,
791 18 + 768 * sizeof (short) / sizeof (int) + 160,
792 18 + 768 * sizeof (short) / sizeof (int) + 160,
793 18 + 768 * sizeof (short) / sizeof (int) + 160,
794 18 + 768 * sizeof (short) / sizeof (int) + 160,
795 18 + 768 * sizeof (short) / sizeof (int) + 160,
796 18 + 768 * sizeof (short) / sizeof (int) + 160,
797 18 + 768 * sizeof (short) / sizeof (int) + 160,
798 18 + 768 * sizeof (short) / sizeof (int) + 160,
799 18 + 768 * sizeof (short) / sizeof (int) + 160,
800 18 + 768 * sizeof (short) / sizeof (int) + 160,
801 18 + 768 * sizeof (short) / sizeof (int) + 160,
802 18 + 768 * sizeof (short) / sizeof (int) + 160,
803 18 + 768 * sizeof (short) / sizeof (int) + 160,
804 18 + 768 * sizeof (short) / sizeof (int) + 160,
805 18 + 768 * sizeof (short) / sizeof (int) + 160,
806 18 + 768 * sizeof (short) / sizeof (int) + 160,
807 18 + 768 * sizeof (short) / sizeof (int) + 160,
808 18 + 768 * sizeof (short) / sizeof (int) + 160,
809 18 + 768 * sizeof (short) / sizeof (int) + 160,
810 18 + 768 * sizeof (short) / sizeof (int) + 160,
811 18 + 768 * sizeof (short) / sizeof (int) + 160,
812 18 + 768 * sizeof (short) / sizeof (int) + 160,
813 18 + 768 * sizeof (short) / sizeof (int) + 160,
814 18 + 768 * sizeof (short) / sizeof (int) + 160,
815 18 + 768 * sizeof (short) / sizeof (int) + 160,
816 18 + 768 * sizeof (short) / sizeof (int) + 160,
817 18 + 768 * sizeof (short) / sizeof (int) + 160,
818 18 + 768 * sizeof (short) / sizeof (int) + 160,
819 18 + 768 * sizeof (short) / sizeof (int) + 160,
820 18 + 768 * sizeof (short) / sizeof (int) + 160,
821 18 + 768 * sizeof (short) / sizeof (int) + 160,
822 18 + 768 * sizeof (short) / sizeof (int) + 1456
823 },
824 {
825 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x7FFFFFFFU,
826 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
827 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
828 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
829 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
830 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
831 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFCFFFFFFU,
832 0xFFFFD7F0U, 0xFFFFFFFBU, 0xFFFFFFFFU, 0xFFFFFFFFU,
833 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
834 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
835 0xFFFFFFFFU, 0xFFFEFFFFU, 0xFE7FFFFFU, 0xFFFFFFFFU,
836 0xFFFEE7FFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0x001F87FFU,
837 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
838 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
839 0xFFFFBFFFU, 0xFFFFFFFFU, 0xFFFFE7FFU, 0xFFFFFFFFU,
840 0xFFFFFFFFU, 0x0003FFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU,
841 0xFFFFFFFFU, 0x7FFF3FFFU, 0x4FFFFFFFU, 0xFFFF07FFU,
842 0xFF83FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
843 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
844 0xFFF99FEFU, 0xF3C5FDFFU, 0xB080799FU, 0x7FFFFFCFU,
845 0xFFF987EEU, 0xD36DFDFFU, 0x5E023987U, 0x007FFFC0U,
846 0xFFFBBFEEU, 0xF3EDFDFFU, 0x00013BBFU, 0xFE03FFCFU,
847 0xFFF99FEEU, 0xF3EDFDFFU, 0xB0E0399FU, 0x00FFFFCFU,
848 0xD63DC7ECU, 0xC3FFC718U, 0x00813DC7U, 0x07FFFFC0U,
849 0xFFFDDFFFU, 0xF3FFFDFFU, 0x37603DDFU, 0xFF80FFCFU,
850 0xFFFDDFFFU, 0xF3EFFDFFU, 0x70603DDFU, 0x000EFFCFU,
851 0xFFFDDFFFU, 0xFFFFFFFFU, 0xFFF0FDDFU, 0xFFFFFFCFU,
852 0xFC7FFFEEU, 0x2FFBFFFFU, 0xFF5F847FU, 0x001CFFC0U,
853 0xFFFFFFFEU, 0x87FFFFFFU, 0x0FFFFFFFU, 0x00000000U,
854 0xFFFFF7D6U, 0x3FFFFFAFU, 0xF3FF7F5FU, 0x00000000U,
855 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFEFFU, 0xFFFE1FFFU,
856 0xFEFFFFFFU, 0xDFFFFFFFU, 0x07FFDFFFU, 0x00000000U,
857 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
858 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU,
859 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
860 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
861 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3D7F3DFFU, 0xFFFFFFFFU,
862 0xFFFF3DFFU, 0x7F3DFFFFU, 0xFF7FFF3DU, 0xFFFFFFFFU,
863 0xFF3DFFFFU, 0xFFFFFFFFU, 0xE7FFFFFFU, 0x1FFFFFFFU,
864 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3F3FFFFFU,
865 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
866 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
867 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
868 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
869 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
870 0x1FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU,
871 0x803FFFFFU, 0x007FFFFFU, 0x000FFFFFU, 0x000DDFFFU,
872 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x03FF03FFU,
873 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x01FFFFFFU,
874 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU, 0x003FFFFFU,
875 0x7FFFFFFFU, 0x0FFF0FFFU, 0xFFFFFFF1U, 0x001F3FFFU,
876 0xFFFFFFFFU, 0xFFFF0FFFU, 0xC7FF03FFU, 0xFFFFFFFFU,
877 0xCFFFFFFFU, 0xFFFFFFFFU, 0x7FFFFFFFU, 0x9FFFFFFFU,
878 0x03FF03FFU, 0xFFFF3FFFU, 0x3FFFFFFFU, 0x00000FFFU,
879 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFDFFFU, 0xFFFFFFFFU,
880 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF00FFFFFU,
881 0xFFFFFFFFU, 0xF8FFFFFFU, 0xFFFFE3FFU, 0xFFFFFFFFU,
882 0xFFFF07FFU, 0xE7FFFFFFU, 0xFFFF00FFU, 0x07FFFFFFU,
883 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
884 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
885 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
886 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
887 0x3F3FFFFFU, 0xFFFFFFFFU, 0xAAFF3F3FU, 0x3FFFFFFFU,
888 0xFFFFFFFFU, 0xFFDFFFFFU, 0xEFCFFFDFU, 0x7FDCFFFFU,
889 0xFFFFFFFFU, 0xFFFFFCFFU, 0xFFFFFFFFU, 0xFFF3FFDFU,
890 0x1FFF7FFFU, 0xFFFFFFFFU, 0xFFFF0003U, 0x0001FFFFU,
891 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
892 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
893 0xFFFFFFFFU, 0x000003FFU, 0x000007FFU, 0xFFFFFFFFU,
894 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
895 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
896 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
897 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
898 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
899 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFCFFFFFU,
900 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
901 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
902 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFE0FFFFFU,
903 0xFFFFFFFFU, 0xFFFF20BFU, 0xFFFFFFFFU, 0x800180FFU,
904 0x007FFFFFU, 0x7F7F7F7FU, 0x7F7F7F7FU, 0xFFFFFFFFU,
905 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U,
906 0xFBFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU,
907 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
908 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0xFFFF0000U,
909 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFEU, 0xFFFFFFFFU,
910 0xFE7FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
911 0xFFFFFFE0U, 0xFFFEFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
912 0xFFFF7FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF803FU,
913 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
914 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
915 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
916 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
917 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
918 0xFFFF1FFFU, 0xFFFFFFFFU, 0xFFFF007FU, 0xFFFFFFFFU,
919 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
920 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
921 0xFFFFFFFFU, 0x00000FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
922 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU,
923 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
924 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU, 0xFFFE0000U,
925 0xFFFFFFFFU, 0x03FF1FFFU, 0xFFFFFFFFU, 0x00FFFFFFU,
926 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFC03FU, 0xFFFFFFFFU,
927 0xFFFFFFFFU, 0xFFFFFFFFU, 0x800FFFFFU, 0x1FFFFFFFU,
928 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FFBFFFU, 0x7FFFFFFFU,
929 0xFFFFFFFFU, 0x007FFFFFU, 0xF3FF3FFFU, 0xFFFFFFFFU,
930 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF8000007U, 0x007FFFFFU,
931 0x007E7E7EU, 0xFFFF7F7FU, 0xFFFFFFFFU, 0xFFFF0FFFU,
932 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF3FFFU,
933 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
934 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
935 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
936 0xFFFFFFFFU, 0xFFFF000FU, 0xFFFFF87FU, 0x0FFFFFFFU,
937 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF3FFFU,
938 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U,
939 0xE0F8007FU, 0x5F7FFFFFU, 0xFFFFFFDBU, 0xFFFFFFFFU,
940 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
941 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
942 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
943 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
944 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, 0xFFFF0000U,
945 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFF7FFFFU, 0xFFDF0F7FU,
946 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x9FFFFFFFU,
947 0xFFFFFFFEU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
948 0xFFFFFFFFU, 0x7FFFFFFFU, 0x1CFCFCFCU, 0x3E007F7FU,
949 0xFFFFEFFFU, 0xB7FFFF7FU, 0x3FFF3FFFU, 0x00000000U,
950 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
951 0xFFFFFF87U, 0xFF8FFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
952 0x1FFF7FFFU, 0x00000001U, 0xFFFF0000U, 0x3FFFFFFFU,
953 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
954 0x1FFFFFFFU, 0xFFFFFFFFU, 0x0001FFFFU, 0x0FFFFFFFU,
955 0xFFFFFFFFU, 0xFFFFE00FU, 0xFFFF07FFU, 0x07FFFFFFU,
956 0xBFFFFFFFU, 0xFFFFFFFFU, 0x003FFF0FU, 0x00000000U,
957 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
958 0x3FFFFFFFU, 0xFFFF03FFU, 0xFF0FFFFFU, 0x0FFFFFFFU,
959 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU, 0xF7FF800FU,
960 0xFFB7F7FFU, 0x1BFBFFFBU, 0xFFFFFFFFU, 0x000FFFFFU,
961 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
962 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
963 0xFFFFFFFFU, 0x007FFFFFU, 0x003FFFFFU, 0x000000FFU,
964 0xFFFFFFBFU, 0x07FDFFFFU, 0x00000000U, 0x00000000U,
965 0xFFFFFD3FU, 0x91BFFFFFU, 0xFFBFFFFFU, 0xFFFFFFFFU,
966 0x7FFFFFFFU, 0x0000FF80U, 0x00000000U, 0xF837FFFFU,
967 0x8FFFFFFFU, 0x83FFFFFFU, 0x03FFFFFFU, 0x00000000U,
968 0xFFFFFFFFU, 0xF0FFFFFFU, 0xFFFCFFFFU, 0xFFFFFFFFU,
969 0xFEEFF06FU, 0x873FFFFFU, 0x01FF01FFU, 0xFFFFFFFFU,
970 0xFFFFFFFFU, 0x00000000U, 0xFFFFFFFFU, 0x007FF87FU,
971 0xFFFFFFFFU, 0xFE3FFFFFU, 0xFF3FFFFFU, 0xFF07FFFFU,
972 0x1E03FFFFU, 0x0000FE00U, 0x00000000U, 0x00000000U,
973 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000001FFU, 0x00000000U,
974 0xFFFFFFFFU, 0x0007FFFFU, 0xFFFFFFFFU, 0xFC07FFFFU,
975 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU, 0xFFFFFE3FU,
976 0x0000C03FU, 0x00000000U, 0x00000000U, 0x00000000U,
977 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFFFFFFU,
978 0xFFFFFFFFU, 0x00033BFFU, 0x01FF00FCU, 0xFC000000U,
979 0xFFFFFFFFU, 0xFFFF00FFU, 0x03FFFFFFU, 0xFFFF0000U,
980 0x000003FFU, 0xFFFF0000U, 0x00000FFFU, 0x007FFFFFU,
981 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFC3FFFU, 0x803FFFFFU,
982 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF2007U, 0x03FF01FFU,
983 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFF00FFU, 0x007FFFFFU,
984 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001FFFFEU,
985 0xFFFBFFFFU, 0xFFFFFFFFU, 0x00000003U, 0x00000000U,
986 0xBFFFBD7FU, 0xFFFF03FFU, 0xFFFFFFFFU, 0x03FF07FFU,
987 0xFFF99FEFU, 0xFBEDFDFFU, 0xE081399FU, 0x001F1FCFU,
988 0xFFFF4BFFU, 0xFFBFFFFFU, 0x01BFF7A5U, 0x00000006U,
989 0xFFFFFFFFU, 0xFFFFFFFFU, 0xEFFFFFFFU, 0x00000003U,
990 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0x00000000U,
991 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
992 0xFFFFFFFFU, 0xFF3FFFFFU, 0x3FFFFFFFU, 0x00000000U,
993 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FF001FU, 0x00001FFFU,
994 0xFFFFFFFFU, 0x03FFFFFFU, 0xFFFF03FFU, 0x0000000FU,
995 0xE7FFFFFFU, 0xFFFF0FFFU, 0x0000007FU, 0x00000000U,
996 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
997 0xFFFFFFFFU, 0x0FFFFFFFU, 0x00000000U, 0x00000000U,
998 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x8007FFFFU,
999 0xFF6FF27FU, 0xF9BFFFFFU, 0x03FF007FU, 0x00000000U,
1000 0x00000000U, 0xFFFFFCFFU, 0xFCFFFFFFU, 0x0000001FU,
1001 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU,
1002 0xFFFFFFFFU, 0xFFFF0007U, 0xFFFFFFFFU, 0x01FFFFFFU,
1003 0x000003FFU, 0x00000000U, 0x00000000U, 0x000000FFU,
1004 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FF0003U,
1005 0xFFFFFDFFU, 0xFF7FFFFFU, 0xFFFF003FU, 0xFFFF1FFFU,
1006 0xFFFCFFFFU, 0x007FFEFFU, 0x00000000U, 0x00000000U,
1007 0xFFFFFB7FU, 0xB47FFFFFU, 0x03FF00FFU, 0xFFFFFDBFU,
1008 0x01FB7FFFU, 0xFFFF03FFU, 0x0FFFFFFFU, 0x000003FFU,
1009 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1010 0x00000000U, 0x00000000U, 0x00000000U, 0x01FFFFFFU,
1011 0xFFFDFFFFU, 0xC7FFFFFFU, 0x07FFFFFFU, 0x00000000U,
1012 0x00000000U, 0x00010000U, 0xFFFFFFFFU, 0x8003FFFFU,
1013 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1014 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1015 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1016 0x03FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1017 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x001F7FFFU,
1018 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1019 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
1020 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1021 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1022 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1023 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1024 0xFFFF0000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
1025 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0xFFFFFFFFU,
1026 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1027 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1028 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1029 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1030 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1031 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1032 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
1033 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000007FU, 0x00000000U,
1034 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1035 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1036 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1037 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1038 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1039 0xFFFFFFFFU, 0x03FFFFFFU, 0x00000000U, 0x00000000U,
1040 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1041 0xFFFFFFFFU, 0x01FFFFFFU, 0x7FFFFFFFU, 0xFFFFC3FFU,
1042 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFF03FFU, 0x003F3FFFU,
1043 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFBFF003FU, 0xE0FFFFFBU,
1044 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1045 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1046 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1047 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x03FFFFFFU,
1048 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1049 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU,
1050 0x07FFFFFFU, 0xF9FFFFFFU, 0x000FFFFFU, 0x00000000U,
1051 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF87FFU, 0xFFFFFFFFU,
1052 0xFFFF80FFU, 0x00000000U, 0x00000000U, 0x007F001FU,
1053 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1054 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x80000000U,
1055 0x7FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1056 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0007FFFFU,
1057 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1058 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1059 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1060 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U,
1061 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1062 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1063 0xFFFFFFFFU, 0x00040007U, 0x00270000U, 0xFFFF00F0U,
1064 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1065 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1066 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU,
1067 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1068 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1069 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFF07FFU,
1070 0xF3FF01FFU, 0x0000000FU, 0x00000000U, 0x00000000U,
1071 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1072 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1073 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1074 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x1FFFFFFFU,
1075 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1076 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1077 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1078 0xFFFFFFFFU, 0xFC0FFFFFU, 0x0001FFFFU, 0x0001FFFFU,
1079 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFF007FU, 0xFFFFFFFFU,
1080 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
1081 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1082 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU,
1083 0xFFFFFFFFU, 0xFFFFFE7FU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1084 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000007FFU,
1085 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000003FU, 0x00000000U,
1086 0x00000000U, 0x00000000U, 0x000FFFFFU, 0x000FFFFFU,
1087 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFFFFU, 0x01FFFFFFU,
1088 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1089 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFDFFFFFU, 0xFFFFFFFFU,
1090 0xDFFFFFFFU, 0xEBFFDE64U, 0xFFFFFFEFU, 0xFFFFFFFFU,
1091 0xDFDFE7BFU, 0x7BFFFFFFU, 0xFFFDFC5FU, 0xFFFFFFFFU,
1092 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1093 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1094 0xFFFFFFFFU, 0xFFFFFF3FU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1095 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1096 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFCFFFU, 0xFFFFFFFFU,
1097 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1098 0xF8000FFFU, 0x0000FFFEU, 0x00000000U, 0x00000000U,
1099 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1100 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1101 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1102 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1103 0x7FFFFFFFU, 0x000007E0U, 0x00000000U, 0x00000000U,
1104 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1105 0xF9FFFF7FU, 0xFFFF07DBU, 0xFFFFFFFFU, 0x00003FFFU,
1106 0x00008000U, 0x00000000U, 0x00000000U, 0x00000000U,
1107 0xFFFFFFFFU, 0x3FFF1FFFU, 0x0000C3FFU, 0x00000000U,
1108 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1109 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1110 0xFFFF0000U, 0x00007FFFU, 0xFFFFFFFFU, 0x83FFFFFFU,
1111 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1112 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1113 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1114 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x03FFFFFFU,
1115 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1116 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x87FFFFFFU,
1117 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1118 0x00000000U, 0x00000000U, 0x7FFFFFFFU, 0xC03FFFFFU,
1119 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1120 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFF6F7FU,
1121 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1122 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFF9FU, 0x00000000U,
1123 0xFFFFFFFFU, 0xFFFFFFFFU, 0xC3FF0FFFU, 0x00000000U,
1124 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1125 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFE0000U,
1126 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, 0x00000000U,
1127 0xFFFFFFFEU, 0x3FFFFFFFU, 0x00000000U, 0x00000000U,
1128 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1129 0xFFFFFFEFU, 0x0AF7FE96U, 0xAA96EA84U, 0x5EF7F796U,
1130 0x0FFFFBFFU, 0x0FFFFBEEU, 0x00000000U, 0x00030000U,
1131 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1132 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1133 0xFFFFFFFFU, 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1134 0x000FFFFFU, 0xFFFE7FFFU, 0xFFFEFFFEU, 0x003FFFFFU,
1135 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1136 0xFFFFFFFFU, 0x00003FFFU, 0x00000000U, 0xFFFFFFC0U,
1137 0xFFFF0007U, 0x0FFFFFFFU, 0x000301FFU, 0x0000003FU,
1138 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1139 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1140 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1141 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1142 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF1FFFFFFU, 0x1FFF1FFFU,
1143 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1144 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00010FFFU,
1145 0xFFFF0FFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU,
1146 0xFFFF00FFU, 0x0FFF3FFFU, 0x01FF0003U, 0x00000000U,
1147 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1148 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1149 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, 0x1FFF3FFFU,
1150 0xFFFFC7FFU, 0xFFFFFFFFU, 0x9FFFE17FU, 0x01FF87FFU,
1151 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1152 0xFFF7FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x07FFFFFFU,
1153 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1154 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U,
1155 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1156 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1157 0x3FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1158 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1159 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1160 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1161 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1162 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1163 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1164 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1165 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1166 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1167 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1168 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF0001U,
1169 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU, 0x00000000U,
1170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1171 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1172 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1173 0x3FFFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
1174 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1175 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1176 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1177 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1178 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1179 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF07FFU, 0xFFFFFFFFU,
1180 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1181 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU,
1182 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1183 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1184 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1185 0x00000002U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1186 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
1187 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1188 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU,
1189 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1190 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1191 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
1192 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU
1193 }
1194};
diff --git a/gl/unictype/ctype_punct.c b/gl/unictype/ctype_punct.c
new file mode 100644
index 00000000..3c30ba70
--- /dev/null
+++ b/gl/unictype/ctype_punct.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_punct table. */
26#include "ctype_punct.h"
27
28bool
29uc_is_punct (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_punct, uc);
32}
diff --git a/gl/unictype/ctype_punct.h b/gl/unictype/ctype_punct.h
new file mode 100644
index 00000000..28fc905e
--- /dev/null
+++ b/gl/unictype/ctype_punct.h
@@ -0,0 +1,874 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[17];
29 short level2[4 << 7];
30 unsigned int level3[76 << 4];
31 }
32u_is_punct =
33{
34 { 17 },
35 {
36 18 * sizeof (int) / sizeof (short) + 0,
37 18 * sizeof (int) / sizeof (short) + 128,
38 -1,
39 -1,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 18 * sizeof (int) / sizeof (short) + 256,
51 18 * sizeof (int) / sizeof (short) + 384,
52 18 * sizeof (int) / sizeof (short) + 384
53 },
54 {
55 18 + 512 * sizeof (short) / sizeof (int) + 0,
56 18 + 512 * sizeof (short) / sizeof (int) + 16,
57 18 + 512 * sizeof (short) / sizeof (int) + 32,
58 18 + 512 * sizeof (short) / sizeof (int) + 48,
59 18 + 512 * sizeof (short) / sizeof (int) + 64,
60 18 + 512 * sizeof (short) / sizeof (int) + 80,
61 18 + 512 * sizeof (short) / sizeof (int) + 96,
62 18 + 512 * sizeof (short) / sizeof (int) + 112,
63 18 + 512 * sizeof (short) / sizeof (int) + 128,
64 18 + 512 * sizeof (short) / sizeof (int) + 144,
65 18 + 512 * sizeof (short) / sizeof (int) + 160,
66 18 + 512 * sizeof (short) / sizeof (int) + 176,
67 18 + 512 * sizeof (short) / sizeof (int) + 192,
68 18 + 512 * sizeof (short) / sizeof (int) + 208,
69 18 + 512 * sizeof (short) / sizeof (int) + 224,
70 18 + 512 * sizeof (short) / sizeof (int) + 240,
71 18 + 512 * sizeof (short) / sizeof (int) + 256,
72 18 + 512 * sizeof (short) / sizeof (int) + 272,
73 18 + 512 * sizeof (short) / sizeof (int) + 288,
74 18 + 512 * sizeof (short) / sizeof (int) + 272,
75 18 + 512 * sizeof (short) / sizeof (int) + 272,
76 18 + 512 * sizeof (short) / sizeof (int) + 304,
77 18 + 512 * sizeof (short) / sizeof (int) + 320,
78 18 + 512 * sizeof (short) / sizeof (int) + 336,
79 18 + 512 * sizeof (short) / sizeof (int) + 352,
80 18 + 512 * sizeof (short) / sizeof (int) + 368,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 18 + 512 * sizeof (short) / sizeof (int) + 384,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 -1,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 18 + 512 * sizeof (short) / sizeof (int) + 400,
138 18 + 512 * sizeof (short) / sizeof (int) + 416,
139 18 + 512 * sizeof (short) / sizeof (int) + 432,
140 18 + 512 * sizeof (short) / sizeof (int) + 448,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 -1,
167 18 + 512 * sizeof (short) / sizeof (int) + 272,
168 18 + 512 * sizeof (short) / sizeof (int) + 272,
169 18 + 512 * sizeof (short) / sizeof (int) + 272,
170 18 + 512 * sizeof (short) / sizeof (int) + 272,
171 18 + 512 * sizeof (short) / sizeof (int) + 272,
172 18 + 512 * sizeof (short) / sizeof (int) + 272,
173 18 + 512 * sizeof (short) / sizeof (int) + 272,
174 18 + 512 * sizeof (short) / sizeof (int) + 272,
175 18 + 512 * sizeof (short) / sizeof (int) + 272,
176 18 + 512 * sizeof (short) / sizeof (int) + 272,
177 18 + 512 * sizeof (short) / sizeof (int) + 272,
178 18 + 512 * sizeof (short) / sizeof (int) + 272,
179 18 + 512 * sizeof (short) / sizeof (int) + 464,
180 18 + 512 * sizeof (short) / sizeof (int) + 480,
181 18 + 512 * sizeof (short) / sizeof (int) + 496,
182 18 + 512 * sizeof (short) / sizeof (int) + 512,
183 18 + 512 * sizeof (short) / sizeof (int) + 528,
184 18 + 512 * sizeof (short) / sizeof (int) + 544,
185 18 + 512 * sizeof (short) / sizeof (int) + 560,
186 -1,
187 18 + 512 * sizeof (short) / sizeof (int) + 576,
188 18 + 512 * sizeof (short) / sizeof (int) + 592,
189 18 + 512 * sizeof (short) / sizeof (int) + 608,
190 18 + 512 * sizeof (short) / sizeof (int) + 624,
191 18 + 512 * sizeof (short) / sizeof (int) + 640,
192 18 + 512 * sizeof (short) / sizeof (int) + 656,
193 18 + 512 * sizeof (short) / sizeof (int) + 672,
194 18 + 512 * sizeof (short) / sizeof (int) + 688,
195 18 + 512 * sizeof (short) / sizeof (int) + 704,
196 18 + 512 * sizeof (short) / sizeof (int) + 720,
197 18 + 512 * sizeof (short) / sizeof (int) + 736,
198 18 + 512 * sizeof (short) / sizeof (int) + 752,
199 -1,
200 -1,
201 18 + 512 * sizeof (short) / sizeof (int) + 768,
202 -1,
203 -1,
204 -1,
205 -1,
206 18 + 512 * sizeof (short) / sizeof (int) + 784,
207 -1,
208 -1,
209 18 + 512 * sizeof (short) / sizeof (int) + 800,
210 -1,
211 -1,
212 -1,
213 -1,
214 -1,
215 -1,
216 -1,
217 -1,
218 -1,
219 -1,
220 -1,
221 -1,
222 -1,
223 -1,
224 -1,
225 -1,
226 -1,
227 -1,
228 -1,
229 -1,
230 -1,
231 18 + 512 * sizeof (short) / sizeof (int) + 816,
232 -1,
233 -1,
234 -1,
235 -1,
236 18 + 512 * sizeof (short) / sizeof (int) + 832,
237 18 + 512 * sizeof (short) / sizeof (int) + 848,
238 18 + 512 * sizeof (short) / sizeof (int) + 864,
239 -1,
240 -1,
241 -1,
242 -1,
243 -1,
244 -1,
245 -1,
246 -1,
247 -1,
248 -1,
249 -1,
250 -1,
251 -1,
252 -1,
253 -1,
254 -1,
255 -1,
256 -1,
257 -1,
258 -1,
259 -1,
260 -1,
261 -1,
262 -1,
263 -1,
264 -1,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 -1,
271 -1,
272 -1,
273 -1,
274 -1,
275 -1,
276 -1,
277 18 + 512 * sizeof (short) / sizeof (int) + 880,
278 -1,
279 -1,
280 -1,
281 -1,
282 -1,
283 -1,
284 -1,
285 18 + 512 * sizeof (short) / sizeof (int) + 896,
286 18 + 512 * sizeof (short) / sizeof (int) + 912,
287 18 + 512 * sizeof (short) / sizeof (int) + 928,
288 18 + 512 * sizeof (short) / sizeof (int) + 944,
289 -1,
290 18 + 512 * sizeof (short) / sizeof (int) + 960,
291 18 + 512 * sizeof (short) / sizeof (int) + 272,
292 18 + 512 * sizeof (short) / sizeof (int) + 976,
293 -1,
294 -1,
295 18 + 512 * sizeof (short) / sizeof (int) + 992,
296 18 + 512 * sizeof (short) / sizeof (int) + 1008,
297 18 + 512 * sizeof (short) / sizeof (int) + 1024,
298 18 + 512 * sizeof (short) / sizeof (int) + 1040,
299 18 + 512 * sizeof (short) / sizeof (int) + 1056,
300 -1,
301 18 + 512 * sizeof (short) / sizeof (int) + 1072,
302 18 + 512 * sizeof (short) / sizeof (int) + 1088,
303 18 + 512 * sizeof (short) / sizeof (int) + 1104,
304 18 + 512 * sizeof (short) / sizeof (int) + 1120,
305 18 + 512 * sizeof (short) / sizeof (int) + 272,
306 18 + 512 * sizeof (short) / sizeof (int) + 1136,
307 18 + 512 * sizeof (short) / sizeof (int) + 1152,
308 18 + 512 * sizeof (short) / sizeof (int) + 1168,
309 -1,
310 -1,
311 18 + 512 * sizeof (short) / sizeof (int) + 1184,
312 -1,
313 -1,
314 -1,
315 -1,
316 -1,
317 -1,
318 -1,
319 -1,
320 -1,
321 -1,
322 -1,
323 -1,
324 -1,
325 -1,
326 -1,
327 -1,
328 -1,
329 -1,
330 -1,
331 -1,
332 -1,
333 -1,
334 -1,
335 -1,
336 -1,
337 -1,
338 -1,
339 -1,
340 -1,
341 -1,
342 -1,
343 -1,
344 -1,
345 -1,
346 -1,
347 -1,
348 -1,
349 -1,
350 -1,
351 -1,
352 -1,
353 -1,
354 -1,
355 -1,
356 -1,
357 -1,
358 -1,
359 -1,
360 -1,
361 -1,
362 -1,
363 -1,
364 -1,
365 -1,
366 -1,
367 -1,
368 -1,
369 -1,
370 -1,
371 -1,
372 -1,
373 -1,
374 -1,
375 -1,
376 -1,
377 -1,
378 -1,
379 -1,
380 -1,
381 -1,
382 -1,
383 -1,
384 -1,
385 -1,
386 -1,
387 -1,
388 -1,
389 -1,
390 -1,
391 -1,
392 -1,
393 -1,
394 -1,
395 -1,
396 -1,
397 -1,
398 -1,
399 -1,
400 -1,
401 -1,
402 -1,
403 -1,
404 -1,
405 -1,
406 -1,
407 -1,
408 -1,
409 -1,
410 -1,
411 -1,
412 -1,
413 -1,
414 -1,
415 -1,
416 -1,
417 -1,
418 -1,
419 -1,
420 -1,
421 -1,
422 -1,
423 -1,
424 -1,
425 -1,
426 -1,
427 -1,
428 -1,
429 -1,
430 -1,
431 -1,
432 -1,
433 -1,
434 -1,
435 -1,
436 -1,
437 -1,
438 -1,
439 18 + 512 * sizeof (short) / sizeof (int) + 272,
440 18 + 512 * sizeof (short) / sizeof (int) + 272,
441 18 + 512 * sizeof (short) / sizeof (int) + 272,
442 18 + 512 * sizeof (short) / sizeof (int) + 272,
443 18 + 512 * sizeof (short) / sizeof (int) + 272,
444 18 + 512 * sizeof (short) / sizeof (int) + 272,
445 18 + 512 * sizeof (short) / sizeof (int) + 272,
446 18 + 512 * sizeof (short) / sizeof (int) + 272,
447 18 + 512 * sizeof (short) / sizeof (int) + 272,
448 18 + 512 * sizeof (short) / sizeof (int) + 272,
449 18 + 512 * sizeof (short) / sizeof (int) + 272,
450 18 + 512 * sizeof (short) / sizeof (int) + 272,
451 18 + 512 * sizeof (short) / sizeof (int) + 272,
452 18 + 512 * sizeof (short) / sizeof (int) + 272,
453 18 + 512 * sizeof (short) / sizeof (int) + 272,
454 18 + 512 * sizeof (short) / sizeof (int) + 272,
455 18 + 512 * sizeof (short) / sizeof (int) + 272,
456 18 + 512 * sizeof (short) / sizeof (int) + 272,
457 18 + 512 * sizeof (short) / sizeof (int) + 272,
458 18 + 512 * sizeof (short) / sizeof (int) + 272,
459 18 + 512 * sizeof (short) / sizeof (int) + 272,
460 18 + 512 * sizeof (short) / sizeof (int) + 272,
461 18 + 512 * sizeof (short) / sizeof (int) + 272,
462 18 + 512 * sizeof (short) / sizeof (int) + 272,
463 18 + 512 * sizeof (short) / sizeof (int) + 272,
464 18 + 512 * sizeof (short) / sizeof (int) + 272,
465 18 + 512 * sizeof (short) / sizeof (int) + 272,
466 18 + 512 * sizeof (short) / sizeof (int) + 272,
467 18 + 512 * sizeof (short) / sizeof (int) + 272,
468 18 + 512 * sizeof (short) / sizeof (int) + 272,
469 18 + 512 * sizeof (short) / sizeof (int) + 272,
470 18 + 512 * sizeof (short) / sizeof (int) + 272,
471 18 + 512 * sizeof (short) / sizeof (int) + 272,
472 18 + 512 * sizeof (short) / sizeof (int) + 272,
473 18 + 512 * sizeof (short) / sizeof (int) + 272,
474 18 + 512 * sizeof (short) / sizeof (int) + 272,
475 18 + 512 * sizeof (short) / sizeof (int) + 272,
476 18 + 512 * sizeof (short) / sizeof (int) + 272,
477 18 + 512 * sizeof (short) / sizeof (int) + 272,
478 18 + 512 * sizeof (short) / sizeof (int) + 272,
479 18 + 512 * sizeof (short) / sizeof (int) + 272,
480 18 + 512 * sizeof (short) / sizeof (int) + 272,
481 18 + 512 * sizeof (short) / sizeof (int) + 272,
482 18 + 512 * sizeof (short) / sizeof (int) + 272,
483 18 + 512 * sizeof (short) / sizeof (int) + 272,
484 18 + 512 * sizeof (short) / sizeof (int) + 272,
485 18 + 512 * sizeof (short) / sizeof (int) + 272,
486 18 + 512 * sizeof (short) / sizeof (int) + 272,
487 18 + 512 * sizeof (short) / sizeof (int) + 272,
488 18 + 512 * sizeof (short) / sizeof (int) + 272,
489 18 + 512 * sizeof (short) / sizeof (int) + 272,
490 18 + 512 * sizeof (short) / sizeof (int) + 272,
491 18 + 512 * sizeof (short) / sizeof (int) + 272,
492 18 + 512 * sizeof (short) / sizeof (int) + 272,
493 18 + 512 * sizeof (short) / sizeof (int) + 272,
494 18 + 512 * sizeof (short) / sizeof (int) + 272,
495 18 + 512 * sizeof (short) / sizeof (int) + 272,
496 18 + 512 * sizeof (short) / sizeof (int) + 272,
497 18 + 512 * sizeof (short) / sizeof (int) + 272,
498 18 + 512 * sizeof (short) / sizeof (int) + 272,
499 18 + 512 * sizeof (short) / sizeof (int) + 272,
500 18 + 512 * sizeof (short) / sizeof (int) + 272,
501 18 + 512 * sizeof (short) / sizeof (int) + 272,
502 18 + 512 * sizeof (short) / sizeof (int) + 272,
503 18 + 512 * sizeof (short) / sizeof (int) + 272,
504 18 + 512 * sizeof (short) / sizeof (int) + 272,
505 18 + 512 * sizeof (short) / sizeof (int) + 272,
506 18 + 512 * sizeof (short) / sizeof (int) + 272,
507 18 + 512 * sizeof (short) / sizeof (int) + 272,
508 18 + 512 * sizeof (short) / sizeof (int) + 272,
509 18 + 512 * sizeof (short) / sizeof (int) + 272,
510 18 + 512 * sizeof (short) / sizeof (int) + 272,
511 18 + 512 * sizeof (short) / sizeof (int) + 272,
512 18 + 512 * sizeof (short) / sizeof (int) + 272,
513 18 + 512 * sizeof (short) / sizeof (int) + 272,
514 18 + 512 * sizeof (short) / sizeof (int) + 272,
515 18 + 512 * sizeof (short) / sizeof (int) + 272,
516 18 + 512 * sizeof (short) / sizeof (int) + 272,
517 18 + 512 * sizeof (short) / sizeof (int) + 272,
518 18 + 512 * sizeof (short) / sizeof (int) + 272,
519 18 + 512 * sizeof (short) / sizeof (int) + 272,
520 18 + 512 * sizeof (short) / sizeof (int) + 272,
521 18 + 512 * sizeof (short) / sizeof (int) + 272,
522 18 + 512 * sizeof (short) / sizeof (int) + 272,
523 18 + 512 * sizeof (short) / sizeof (int) + 272,
524 18 + 512 * sizeof (short) / sizeof (int) + 272,
525 18 + 512 * sizeof (short) / sizeof (int) + 272,
526 18 + 512 * sizeof (short) / sizeof (int) + 272,
527 18 + 512 * sizeof (short) / sizeof (int) + 272,
528 18 + 512 * sizeof (short) / sizeof (int) + 272,
529 18 + 512 * sizeof (short) / sizeof (int) + 272,
530 18 + 512 * sizeof (short) / sizeof (int) + 272,
531 18 + 512 * sizeof (short) / sizeof (int) + 272,
532 18 + 512 * sizeof (short) / sizeof (int) + 272,
533 18 + 512 * sizeof (short) / sizeof (int) + 272,
534 18 + 512 * sizeof (short) / sizeof (int) + 272,
535 18 + 512 * sizeof (short) / sizeof (int) + 272,
536 18 + 512 * sizeof (short) / sizeof (int) + 272,
537 18 + 512 * sizeof (short) / sizeof (int) + 272,
538 18 + 512 * sizeof (short) / sizeof (int) + 272,
539 18 + 512 * sizeof (short) / sizeof (int) + 272,
540 18 + 512 * sizeof (short) / sizeof (int) + 272,
541 18 + 512 * sizeof (short) / sizeof (int) + 272,
542 18 + 512 * sizeof (short) / sizeof (int) + 272,
543 18 + 512 * sizeof (short) / sizeof (int) + 272,
544 18 + 512 * sizeof (short) / sizeof (int) + 272,
545 18 + 512 * sizeof (short) / sizeof (int) + 272,
546 18 + 512 * sizeof (short) / sizeof (int) + 272,
547 18 + 512 * sizeof (short) / sizeof (int) + 272,
548 18 + 512 * sizeof (short) / sizeof (int) + 272,
549 18 + 512 * sizeof (short) / sizeof (int) + 272,
550 18 + 512 * sizeof (short) / sizeof (int) + 272,
551 18 + 512 * sizeof (short) / sizeof (int) + 272,
552 18 + 512 * sizeof (short) / sizeof (int) + 272,
553 18 + 512 * sizeof (short) / sizeof (int) + 272,
554 18 + 512 * sizeof (short) / sizeof (int) + 272,
555 18 + 512 * sizeof (short) / sizeof (int) + 272,
556 18 + 512 * sizeof (short) / sizeof (int) + 272,
557 18 + 512 * sizeof (short) / sizeof (int) + 272,
558 18 + 512 * sizeof (short) / sizeof (int) + 272,
559 18 + 512 * sizeof (short) / sizeof (int) + 272,
560 18 + 512 * sizeof (short) / sizeof (int) + 272,
561 18 + 512 * sizeof (short) / sizeof (int) + 272,
562 18 + 512 * sizeof (short) / sizeof (int) + 272,
563 18 + 512 * sizeof (short) / sizeof (int) + 272,
564 18 + 512 * sizeof (short) / sizeof (int) + 272,
565 18 + 512 * sizeof (short) / sizeof (int) + 272,
566 18 + 512 * sizeof (short) / sizeof (int) + 1200
567 },
568 {
569 0x00000000U, 0xFC00FFFEU, 0xF8000001U, 0x78000001U,
570 0x00000000U, 0xFBDFFBFFU, 0x00800000U, 0x00800000U,
571 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
572 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
573 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
574 0x00000000U, 0x00000000U, 0xFFFC003CU, 0xFFFFAFE0U,
575 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFDFU, 0x4020FFFFU,
576 0x000000B0U, 0x00000000U, 0x00000000U, 0x00400000U,
577 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
578 0x000003FCU, 0x00000000U, 0x00000000U, 0x00000000U,
579 0x00000000U, 0x00000000U, 0xFC000000U, 0x00000000U,
580 0xFFFEE600U, 0xFFFFFFFFU, 0x000000FFU, 0x00180000U,
581 0xFFFFFFFFU, 0x00000000U, 0xFFFFF800U, 0x00013C00U,
582 0x00000000U, 0x00000000U, 0xFFD00000U, 0x60003F9FU,
583 0x0002BFFFU, 0xFFFF0000U, 0x000007FFU, 0x00000000U,
584 0x00000000U, 0x0001FFC0U, 0x00000000U, 0xE3CFF800U,
585 0xFBC00000U, 0x7FFF3EEFU, 0x4E000000U, 0x00000000U,
586 0xFF830100U, 0x00000000U, 0xFFFFFC00U, 0xFFFFFFFFU,
587 0x0000000FU, 0xDC000000U, 0x00FEFFFFU, 0x0001003CU,
588 0x0000000EU, 0xD0000000U, 0x0080399FU, 0x6FFC000CU,
589 0x0000000EU, 0xD0000000U, 0x00023987U, 0x00630000U,
590 0x0000000EU, 0xD0000000U, 0x00003BBFU, 0xFC03000CU,
591 0x0000000EU, 0xD0000000U, 0x00E0399FU, 0x00FD000CU,
592 0x00000004U, 0xC0000000U, 0x00803DC7U, 0x07FF0000U,
593 0x0000001FU, 0xD0000000U, 0x00603DDFU, 0xFF80000CU,
594 0x0000001EU, 0xD0000000U, 0x00603DDFU, 0x0008000CU,
595 0x0000000FU, 0xD8000000U, 0x7F80BDDFU, 0x03FF000CU,
596 0x0000000EU, 0x00000000U, 0xFF5F8400U, 0x001C0000U,
597 0x00000000U, 0x80008000U, 0x0C008040U, 0x00000000U,
598 0x00000000U, 0x1FF20000U, 0x00007F00U, 0x00000000U,
599 0xFFFFFFFEU, 0xFFFFFC00U, 0x00000000U, 0xFFFE0000U,
600 0xFEFFE0FFU, 0xDFFFFFFFU, 0x07FFDFFFU, 0x00000000U,
601 0x00000000U, 0x7FFFF800U, 0xC3C0FC00U, 0x001E3F9DU,
602 0xFC00BFFCU, 0x00000000U, 0x00000000U, 0x08000000U,
603 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
604 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
605 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
606 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
607 0x00000000U, 0x00000000U, 0xE0000000U, 0x1FFFFFFFU,
608 0x03FF0000U, 0x00000000U, 0x00000000U, 0x00000000U,
609 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U,
610 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
611 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
612 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
613 0x00000000U, 0x00000000U, 0x00000000U, 0x00006000U,
614 0x18000000U, 0x00000000U, 0x00000000U, 0x00003800U,
615 0x003C0000U, 0x007C0000U, 0x000C0000U, 0x000C0000U,
616 0x00000000U, 0xFFF00000U, 0x2F7FFFFFU, 0x03FF0000U,
617 0x0000FFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
618 0x00000060U, 0x00000200U, 0x00000000U, 0x00000000U,
619 0x00000000U, 0x0FFF0FFFU, 0x00000031U, 0x00000000U,
620 0x00000000U, 0x00000000U, 0xC4000000U, 0xFFFFFFFFU,
621 0xCF800000U, 0x00000000U, 0x7FE00000U, 0x9FFFFFFFU,
622 0x00000000U, 0xFFFF3F7FU, 0x3FFFFFFFU, 0x00000FFFU,
623 0x0000001FU, 0xFFF00000U, 0xFC00C01FU, 0xFFFFFFFFU,
624 0x00000007U, 0x00003FFEU, 0x00000000U, 0xF00FFFC0U,
625 0x00000000U, 0xF8FFFFF0U, 0x00000000U, 0xC0000000U,
626 0x00000000U, 0x00000000U, 0xFFFF00FFU, 0x039021FFU,
627 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
628 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU,
629 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
630 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
631 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
632 0x00000000U, 0xA0000000U, 0xE000E003U, 0x6000E000U,
633 0xFFFFF880U, 0xFFFFFCFFU, 0x7FFFFFFFU, 0x7FF1FFDFU,
634 0x00007FFFU, 0xFFFFFFFFU, 0xFFFF0003U, 0x0001FFFFU,
635 0xC1D0037BU, 0x0C0040AFU, 0xFFFFBC1FU, 0x00000000U,
636 0xFFFF0E00U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
637 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
638 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
639 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
640 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
641 0xFFFFFFFFU, 0x000003FFU, 0x000007FFU, 0xFFFFFFFFU,
642 0x0FFFFFFFU, 0x00000000U, 0x00000000U, 0xFFFFFC00U,
643 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
644 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
645 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
646 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
647 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFCFFFFFU,
648 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
649 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
650 0x00000000U, 0x00000000U, 0x00000000U, 0xFE0387E0U,
651 0x00000000U, 0x00000000U, 0x00000000U, 0x80010000U,
652 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFFFFFFU,
653 0xFFFFFFFFU, 0xFFFF7FFFU, 0x3FFFFFFFU, 0x00000000U,
654 0xFBFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000FFFFFU,
655 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
656 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0xFFFF0000U,
657 0xFFFFFF1EU, 0xE0C1FC01U, 0x00000000U, 0x00000000U,
658 0x1E000000U, 0x00000001U, 0x00000000U, 0x08000000U,
659 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
660 0xFFFF0000U, 0x00000000U, 0xFFFFFFFFU, 0x0000803FU,
661 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
662 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
663 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
664 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
665 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
666 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
667 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
668 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU,
669 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
670 0xFFFF0000U, 0xFFFFFFFFU, 0x0000007FU, 0xC0000000U,
671 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
672 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
673 0x0000E000U, 0x00000000U, 0x00000000U, 0x7FFF8000U,
674 0xC0000000U, 0x00000000U, 0x00000000U, 0x00FF0000U,
675 0x007FFFFFU, 0x00000003U, 0x00000000U, 0x00000000U,
676 0x00000600U, 0x00000000U, 0x00000000U, 0x00000000U,
677 0x00000844U, 0x03FF1FF8U, 0x00000000U, 0x00F00000U,
678 0x00000003U, 0xFFF00000U, 0x0000C03FU, 0x9703FFFFU,
679 0x00000000U, 0x0000FFC0U, 0x800FFF80U, 0x00000000U,
680 0x0000000FU, 0xFFF80000U, 0xC0003FFFU, 0x00000020U,
681 0x00000000U, 0x007FFE00U, 0xF0003008U, 0x3B800000U,
682 0x00000000U, 0xC19D0000U, 0xC0000002U, 0x0063F800U,
683 0x00000000U, 0x00000000U, 0x08000000U, 0x00000C00U,
684 0x00000000U, 0x00000000U, 0x00000000U, 0x00003FF8U,
685 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
686 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
687 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
688 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
689 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
690 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
691 0x40000000U, 0x00000200U, 0x00000000U, 0x00000000U,
692 0x00000000U, 0xFFFC0000U, 0x0007FFFFU, 0x00000000U,
693 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
694 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
695 0x00000000U, 0xC0000000U, 0x0000FFFFU, 0x00000000U,
696 0x00030000U, 0x00000000U, 0x0000FF00U, 0xF0000000U,
697 0x03FFFFFFU, 0xFFFFFFFFU, 0xFFF7FFFFU, 0x00000F7FU,
698 0x00000000U, 0x00000000U, 0x00000000U, 0x80000000U,
699 0xFC00FFFEU, 0xF8000001U, 0xF8000001U, 0x0000003FU,
700 0x00000000U, 0x00000000U, 0x00000000U, 0x3E007F7FU,
701 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
702 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
703 0xFFFFFF87U, 0xFF8FFFFFU, 0x00000000U, 0xFFE00000U,
704 0x1FFF7FFFU, 0x00000001U, 0xFFFF0000U, 0x3FFFFFFFU,
705 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
706 0x00000000U, 0x00000000U, 0x00000000U, 0x0FFFFFFFU,
707 0x00000000U, 0x0000000FU, 0x00000000U, 0x07C00000U,
708 0x80000000U, 0x00000000U, 0x00010000U, 0x00000000U,
709 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
710 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
711 0x00000000U, 0x00000000U, 0x00000000U, 0x00008000U,
712 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
713 0x00000000U, 0x00000000U, 0xFF800000U, 0xFF800000U,
714 0x00000000U, 0x0000FF80U, 0x00000000U, 0xF8000000U,
715 0x8FC00000U, 0x80000000U, 0x00000000U, 0x00000000U,
716 0x00000000U, 0x30000000U, 0xFFFCFFFFU, 0xFFFFFFFFU,
717 0x0000F06EU, 0x87000000U, 0x01FF01FFU, 0xE0000000U,
718 0xE0000000U, 0x00000000U, 0x00000100U, 0x007FF860U,
719 0x00000000U, 0xFE000000U, 0xFF000000U, 0xFF000000U,
720 0x1E000000U, 0x0000FE00U, 0x00000000U, 0x00000000U,
721 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
722 0x00000000U, 0x00000000U, 0x00000000U, 0xFC000000U,
723 0x00000000U, 0x000000F0U, 0x00000000U, 0x00007E00U,
724 0x0000C000U, 0x00000000U, 0x00000000U, 0x00000000U,
725 0x00000000U, 0x00000000U, 0x00000000U, 0x7FFFFFFFU,
726 0x00000000U, 0x00003800U, 0x01FF0000U, 0xFC000000U,
727 0xE0000000U, 0x0000007FU, 0x03FFFFC0U, 0x00000000U,
728 0x000003FCU, 0x00000000U, 0x00000FE0U, 0x00000000U,
729 0x00000007U, 0xFF000000U, 0xFFFC3FFFU, 0x8019003FU,
730 0x00000007U, 0xFFFF0000U, 0x00002007U, 0x00000000U,
731 0x00000007U, 0x001FFF80U, 0x0000006FU, 0x00380000U,
732 0x00000007U, 0xFFF80000U, 0xE800FFE1U, 0x001FFFFEU,
733 0x00000000U, 0x7FFFF000U, 0x00000002U, 0x00000000U,
734 0x00000000U, 0x00000200U, 0x80000000U, 0x000007FFU,
735 0x0000000FU, 0xD8000000U, 0x0080399FU, 0x001F1FCCU,
736 0x00000000U, 0xFF000000U, 0x01B5F7A5U, 0x00000006U,
737 0x00000000U, 0xFFE00000U, 0x6C00F87FU, 0x00000000U,
738 0x00000000U, 0xFFFF0000U, 0x0000004FU, 0x00000000U,
739 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
740 0x00000000U, 0xFF3F8000U, 0x30FFFFFFU, 0x00000000U,
741 0x00000000U, 0xFFFF0000U, 0x0000000FU, 0x00001FFFU,
742 0x00000000U, 0x02FFF800U, 0x00000000U, 0x00000000U,
743 0xE0000000U, 0xFC000FFFU, 0x00000000U, 0x00000000U,
744 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
745 0x00000000U, 0x0FFFF000U, 0x00000000U, 0x00000000U,
746 0x00000000U, 0x00000000U, 0x00000000U, 0x0007FC00U,
747 0x00000000U, 0x79BF0000U, 0x0000007DU, 0x00000000U,
748 0x00000000U, 0x00000000U, 0xFCFE0000U, 0x00000015U,
749 0x000007FEU, 0xFBF80000U, 0x0FFE00FFU, 0x00000000U,
750 0xDFFFFC00U, 0x00000007U, 0x00000000U, 0x00000000U,
751 0x000003FFU, 0x00000000U, 0x00000000U, 0x000000FFU,
752 0x00000000U, 0x00000000U, 0x00000000U, 0x00000002U,
753 0x00000000U, 0xFF7F8000U, 0xFC00003EU, 0x00031FFFU,
754 0xFFFC0000U, 0x007FFEFFU, 0x00000000U, 0x00000000U,
755 0x00000000U, 0xB47E0000U, 0x000000BFU, 0x00000000U,
756 0x00FB7C00U, 0x00000000U, 0x00000000U, 0x00000000U,
757 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
758 0x00000000U, 0x00000000U, 0x00000000U, 0x01F80000U,
759 0x0000000BU, 0xC7F00000U, 0x0400FFFFU, 0x00000000U,
760 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x8003FFFFU,
761 0x00000000U, 0x00000000U, 0x00000000U, 0x001F0000U,
762 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
763 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
764 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
765 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
766 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
767 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
768 0x00000000U, 0x00000000U, 0x00000000U, 0x00060000U,
769 0x00000000U, 0xFFFF0000U, 0x003FFF81U, 0x00000000U,
770 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
771 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
772 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
773 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
774 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
775 0xC0000000U, 0x0000FFFFU, 0x00000000U, 0x00000000U,
776 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
777 0x00000000U, 0x00000000U, 0x00000000U, 0x0000C000U,
778 0x00000000U, 0x00000000U, 0x00000000U, 0x003F0000U,
779 0x00000000U, 0xFFFF0000U, 0xF8000030U, 0x00000003U,
780 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
781 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
782 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
783 0x00000000U, 0x00000000U, 0x00000000U, 0x0000E000U,
784 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
785 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
786 0x07FFFFFFU, 0x00000000U, 0x00000000U, 0x00000000U,
787 0x00000000U, 0x00000000U, 0xFFFE8000U, 0xFFFFFFFFU,
788 0x000780FFU, 0x00000000U, 0x00000000U, 0x00030014U,
789 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
790 0xF0000000U, 0x0000000FU, 0x00000000U, 0x00000000U,
791 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
792 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
793 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
794 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x1C000000U,
795 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
796 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
797 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
798 0xFFFFFFFFU, 0xFC0FFFFFU, 0x0001FFFFU, 0x0001FFFFU,
799 0xFFFFFFFFU, 0xFFFF3FFFU, 0xFFFF007FU, 0xFFFFFFFFU,
800 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000000FU, 0x00000000U,
801 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
802 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU,
803 0xFFFFFFFFU, 0xFFFFFE7FU, 0xFFFFFFFFU, 0xFFFFFFFFU,
804 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x000007FFU,
805 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000003FU, 0x00000000U,
806 0x00000000U, 0x00000000U, 0x000FFFFFU, 0x000FFFFFU,
807 0xFFFFFFFFU, 0xFFFFFFFFU, 0x007FFFFFU, 0x01FFFFFFU,
808 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
809 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
810 0x00000000U, 0x00000000U, 0x08000002U, 0x08000000U,
811 0x00200000U, 0x00200000U, 0x00008000U, 0x00008000U,
812 0x00000200U, 0x00000200U, 0x00000008U, 0x00000000U,
813 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
814 0xF8000FFFU, 0x0000FFFEU, 0x00000000U, 0x00000000U,
815 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
816 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
817 0xF9FFFF7FU, 0x000007DBU, 0x00000000U, 0x00000000U,
818 0x00008000U, 0x00000000U, 0x00000000U, 0x00000000U,
819 0x00000000U, 0x007F0000U, 0x00008000U, 0x00000000U,
820 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
821 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
822 0x00000000U, 0x00004000U, 0x00000000U, 0x8000F000U,
823 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
824 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
825 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
826 0x00000000U, 0x00000000U, 0x00000000U, 0x0000F000U,
827 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
828 0x00000000U, 0x00000000U, 0x00000000U, 0x8000C000U,
829 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
830 0x00000000U, 0x00000000U, 0x00000000U, 0x0020C048U,
831 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
832 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
833 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
834 0x00000000U, 0x00000000U, 0x007FFF80U, 0x00000000U,
835 0x00000000U, 0x00000000U, 0xC00007F0U, 0x00000000U,
836 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
837 0x00000000U, 0x00000000U, 0x00000000U, 0xFFFE0000U,
838 0xFFFFFFFFU, 0x001FFFFFU, 0x00000000U, 0x00000000U,
839 0xFFFFFFFEU, 0x3FFFFFFFU, 0x00000000U, 0x00000000U,
840 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
841 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
842 0x00000000U, 0x00000000U, 0x00000000U, 0x00030000U,
843 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
844 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
845 0xFFFFFFFFU, 0xFFFF0FFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
846 0x000FFFFFU, 0xFFFE7FFFU, 0xFFFEFFFEU, 0x003FFFFFU,
847 0x0000FFFFU, 0x0000E000U, 0x0000FC00U, 0x0000FC00U,
848 0xFFFFF800U, 0x00003FDFU, 0x00000000U, 0x00000000U,
849 0xFFFF0007U, 0x0FFFFFFFU, 0x000301FFU, 0x0000003FU,
850 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
851 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
852 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
853 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
854 0xFFFFFFFFU, 0xFFFFFFFFU, 0xF1FFFFFFU, 0x1FFF1FFFU,
855 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
856 0xFFFFFFFFU, 0xFFFFFFFFU, 0x03FFFFFFU, 0x00010FFFU,
857 0xFFFF0FFFU, 0xFFFFFFFFU, 0x03FF00FFU, 0xFFFFFFFFU,
858 0xFFFF00FFU, 0x0FFF3FFFU, 0x01FF0003U, 0x00000000U,
859 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
860 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
861 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU, 0x1FFF3FFFU,
862 0xFFFFC7FFU, 0xFFFFFFFFU, 0x9FFFE17FU, 0x01FF87FFU,
863 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
864 0xFFF7FFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0400FFFFU,
865 0x00000002U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
866 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
867 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
868 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU,
869 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
870 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
871 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
872 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x3FFFFFFFU
873 }
874};
diff --git a/gl/unictype/ctype_space.c b/gl/unictype/ctype_space.c
new file mode 100644
index 00000000..ee9ce3fd
--- /dev/null
+++ b/gl/unictype/ctype_space.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_space table. */
26#include "ctype_space.h"
27
28bool
29uc_is_space (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_space, uc);
32}
diff --git a/gl/unictype/ctype_space.h b/gl/unictype/ctype_space.h
new file mode 100644
index 00000000..1a72bd6d
--- /dev/null
+++ b/gl/unictype/ctype_space.h
@@ -0,0 +1,184 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[1];
29 short level2[1 << 7];
30 unsigned int level3[4 << 4];
31 }
32u_is_space =
33{
34 { 1 },
35 { 2 * sizeof (int) / sizeof (short) + 0 },
36 {
37 2 + 128 * sizeof (short) / sizeof (int) + 0,
38 -1,
39 -1,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 2 + 128 * sizeof (short) / sizeof (int) + 16,
49 -1,
50 -1,
51 -1,
52 -1,
53 2 + 128 * sizeof (short) / sizeof (int) + 32,
54 -1,
55 -1,
56 -1,
57 -1,
58 -1,
59 -1,
60 -1,
61 2 + 128 * sizeof (short) / sizeof (int) + 48,
62 -1,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 -1,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1
165 },
166 {
167 0x00003E00U, 0x00000001U, 0x00000000U, 0x00000000U,
168 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
169 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
171 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
172 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U,
173 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
174 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
175 0x0000077FU, 0x00000300U, 0x80000000U, 0x00000000U,
176 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
177 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
178 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
179 0x00000001U, 0x00000000U, 0x00000000U, 0x00000000U,
180 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
181 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
182 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
183 }
184};
diff --git a/gl/unictype/ctype_upper.c b/gl/unictype/ctype_upper.c
new file mode 100644
index 00000000..31210804
--- /dev/null
+++ b/gl/unictype/ctype_upper.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_upper table. */
26#include "ctype_upper.h"
27
28bool
29uc_is_upper (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_upper, uc);
32}
diff --git a/gl/unictype/ctype_upper.h b/gl/unictype/ctype_upper.h
new file mode 100644
index 00000000..f0773306
--- /dev/null
+++ b/gl/unictype/ctype_upper.h
@@ -0,0 +1,367 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[2];
29 short level2[2 << 7];
30 unsigned int level3[17 << 4];
31 }
32u_is_upper =
33{
34 { 2 },
35 {
36 3 * sizeof (int) / sizeof (short) + 0,
37 3 * sizeof (int) / sizeof (short) + 128
38 },
39 {
40 3 + 256 * sizeof (short) / sizeof (int) + 0,
41 3 + 256 * sizeof (short) / sizeof (int) + 16,
42 3 + 256 * sizeof (short) / sizeof (int) + 32,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 3 + 256 * sizeof (short) / sizeof (int) + 48,
49 3 + 256 * sizeof (short) / sizeof (int) + 64,
50 -1,
51 -1,
52 -1,
53 -1,
54 3 + 256 * sizeof (short) / sizeof (int) + 80,
55 3 + 256 * sizeof (short) / sizeof (int) + 96,
56 3 + 256 * sizeof (short) / sizeof (int) + 112,
57 -1,
58 3 + 256 * sizeof (short) / sizeof (int) + 128,
59 -1,
60 -1,
61 -1,
62 3 + 256 * sizeof (short) / sizeof (int) + 144,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 3 + 256 * sizeof (short) / sizeof (int) + 160,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 -1,
167 3 + 256 * sizeof (short) / sizeof (int) + 176,
168 -1,
169 -1,
170 3 + 256 * sizeof (short) / sizeof (int) + 192,
171 -1,
172 -1,
173 -1,
174 3 + 256 * sizeof (short) / sizeof (int) + 208,
175 -1,
176 -1,
177 -1,
178 -1,
179 -1,
180 3 + 256 * sizeof (short) / sizeof (int) + 224,
181 -1,
182 -1,
183 -1,
184 -1,
185 -1,
186 -1,
187 -1,
188 -1,
189 -1,
190 -1,
191 -1,
192 -1,
193 -1,
194 -1,
195 -1,
196 -1,
197 -1,
198 -1,
199 -1,
200 -1,
201 -1,
202 -1,
203 -1,
204 -1,
205 -1,
206 -1,
207 -1,
208 -1,
209 -1,
210 -1,
211 -1,
212 -1,
213 -1,
214 -1,
215 -1,
216 -1,
217 -1,
218 -1,
219 -1,
220 -1,
221 -1,
222 -1,
223 3 + 256 * sizeof (short) / sizeof (int) + 240,
224 -1,
225 -1,
226 -1,
227 -1,
228 -1,
229 -1,
230 -1,
231 -1,
232 -1,
233 -1,
234 -1,
235 -1,
236 -1,
237 -1,
238 -1,
239 -1,
240 -1,
241 -1,
242 -1,
243 -1,
244 -1,
245 -1,
246 -1,
247 -1,
248 -1,
249 -1,
250 -1,
251 -1,
252 -1,
253 -1,
254 -1,
255 -1,
256 -1,
257 -1,
258 -1,
259 -1,
260 -1,
261 -1,
262 -1,
263 -1,
264 -1,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 -1,
271 -1,
272 -1,
273 -1,
274 -1,
275 -1,
276 -1,
277 -1,
278 -1,
279 -1,
280 -1,
281 -1,
282 -1,
283 -1,
284 3 + 256 * sizeof (short) / sizeof (int) + 256,
285 -1,
286 -1,
287 -1,
288 -1,
289 -1,
290 -1,
291 -1,
292 -1,
293 -1,
294 -1,
295 -1
296 },
297 {
298 0x00000000U, 0x00000000U, 0x07FFFFFEU, 0x00000000U,
299 0x00000000U, 0x00000000U, 0x7F7FFFFFU, 0x00000000U,
300 0x55555555U, 0xAA555555U, 0x555554AAU, 0x2B555555U,
301 0xB1DBCED6U, 0x11AED2D5U, 0x4AAAADB0U, 0x55D65555U,
302 0x55555555U, 0x6C055555U, 0x0000557AU, 0x00000000U,
303 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
304 0x00000000U, 0x00000000U, 0x00000000U, 0x80450000U,
305 0xFFFED740U, 0x00000FFBU, 0x55008000U, 0xE6905555U,
306 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0x55555555U,
307 0x55555401U, 0x55555555U, 0x55552AABU, 0x55555555U,
308 0x55555555U, 0xFFFE5555U, 0x007FFFFFU, 0x00000000U,
309 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
310 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
311 0x00000000U, 0xFFFFFFFFU, 0x000020BFU, 0x00000000U,
312 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
313 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
314 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
315 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
316 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
317 0x00000000U, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU,
318 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
319 0xFFFF0200U, 0xE7FFFFFFU, 0x00000000U, 0x00000000U,
320 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
321 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
322 0x55555555U, 0x55555555U, 0x55555555U, 0x55555555U,
323 0x40155555U, 0x55555555U, 0x55555555U, 0x55555555U,
324 0x3F00FF00U, 0xFF00FF00U, 0xAA003F00U, 0x0000FF00U,
325 0xFF00FF00U, 0x1F00FF00U, 0x0F001F00U, 0x1F001F00U,
326 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
327 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
328 0x00000000U, 0x00040C40U, 0x00000000U, 0x0000FFFFU,
329 0x00000008U, 0x00000000U, 0x00000000U, 0x00000000U,
330 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
331 0x00000000U, 0xFFC00000U, 0x0000FFFFU, 0x00000000U,
332 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
333 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
334 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U, 0xC025EA9DU,
335 0x55555555U, 0x55555555U, 0x55555555U, 0x00042805U,
336 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
337 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
338 0x00000000U, 0x00000000U, 0x55555555U, 0x00001555U,
339 0x05555555U, 0x00000000U, 0x00000000U, 0x00000000U,
340 0x00000000U, 0x55545554U, 0x55555555U, 0x6A005555U,
341 0x55452855U, 0x555F7D55U, 0x15555AF5U, 0x00200000U,
342 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
343 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
344 0x00000000U, 0x07FFFFFEU, 0x00000000U, 0x00000000U,
345 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
346 0xFFFFFFFFU, 0x000000FFU, 0x00000000U, 0x00000000U,
347 0x00000000U, 0xFFFF0000U, 0x000FFFFFU, 0x00000000U,
348 0x00000000U, 0x00000000U, 0x00000000U, 0xF7FF0000U,
349 0x0037F7FFU, 0x00000000U, 0x00000000U, 0x00000000U,
350 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
351 0xFFFFFFFFU, 0x0007FFFFU, 0x00000000U, 0x00000000U,
352 0x00000000U, 0x00000000U, 0xFFFF0000U, 0x0000003FU,
353 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
354 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
355 0x00000000U, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
356 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
357 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
358 0x00000000U, 0x00000000U, 0xFFFFFFFFU, 0x00000000U,
359 0x00000000U, 0x01FFFFFFU, 0x00000000U, 0x00000000U,
360 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
361 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
362 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
363 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
364 0xFFFFFFFFU, 0x00000003U, 0x00000000U, 0x00000000U,
365 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
366 }
367};
diff --git a/gl/unictype/ctype_xdigit.c b/gl/unictype/ctype_xdigit.c
new file mode 100644
index 00000000..bea31a1b
--- /dev/null
+++ b/gl/unictype/ctype_xdigit.c
@@ -0,0 +1,32 @@
1/* ISO C <ctype.h> like properties of Unicode characters.
2 Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "unictype.h"
22
23#include "bitmap.h"
24
25/* Define u_is_xdigit table. */
26#include "ctype_xdigit.h"
27
28bool
29uc_is_xdigit (ucs4_t uc)
30{
31 return bitmap_lookup (&u_is_xdigit, uc);
32}
diff --git a/gl/unictype/ctype_xdigit.h b/gl/unictype/ctype_xdigit.h
new file mode 100644
index 00000000..508c3ed7
--- /dev/null
+++ b/gl/unictype/ctype_xdigit.h
@@ -0,0 +1,172 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* ISO C <ctype.h> like properties of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[1];
29 short level2[1 << 7];
30 unsigned int level3[1 << 4];
31 }
32u_is_xdigit =
33{
34 { 1 },
35 { 2 * sizeof (int) / sizeof (short) + 0 },
36 {
37 2 + 128 * sizeof (short) / sizeof (int) + 0,
38 -1,
39 -1,
40 -1,
41 -1,
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 -1,
51 -1,
52 -1,
53 -1,
54 -1,
55 -1,
56 -1,
57 -1,
58 -1,
59 -1,
60 -1,
61 -1,
62 -1,
63 -1,
64 -1,
65 -1,
66 -1,
67 -1,
68 -1,
69 -1,
70 -1,
71 -1,
72 -1,
73 -1,
74 -1,
75 -1,
76 -1,
77 -1,
78 -1,
79 -1,
80 -1,
81 -1,
82 -1,
83 -1,
84 -1,
85 -1,
86 -1,
87 -1,
88 -1,
89 -1,
90 -1,
91 -1,
92 -1,
93 -1,
94 -1,
95 -1,
96 -1,
97 -1,
98 -1,
99 -1,
100 -1,
101 -1,
102 -1,
103 -1,
104 -1,
105 -1,
106 -1,
107 -1,
108 -1,
109 -1,
110 -1,
111 -1,
112 -1,
113 -1,
114 -1,
115 -1,
116 -1,
117 -1,
118 -1,
119 -1,
120 -1,
121 -1,
122 -1,
123 -1,
124 -1,
125 -1,
126 -1,
127 -1,
128 -1,
129 -1,
130 -1,
131 -1,
132 -1,
133 -1,
134 -1,
135 -1,
136 -1,
137 -1,
138 -1,
139 -1,
140 -1,
141 -1,
142 -1,
143 -1,
144 -1,
145 -1,
146 -1,
147 -1,
148 -1,
149 -1,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1
165 },
166 {
167 0x00000000U, 0x03FF0000U, 0x0000007EU, 0x0000007EU,
168 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
169 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
170 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
171 }
172};
diff --git a/gl/uninorm.in.h b/gl/uninorm.in.h
new file mode 100644
index 00000000..8d84f78a
--- /dev/null
+++ b/gl/uninorm.in.h
@@ -0,0 +1,255 @@
1/* Normalization forms (composition and decomposition) of Unicode strings.
2 Copyright (C) 2001-2002, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _UNINORM_H
19#define _UNINORM_H
20
21/* Get size_t. */
22#include <stddef.h>
23
24#include "unitypes.h"
25
26#if @HAVE_UNISTRING_WOE32DLL_H@
27# include <unistring/woe32dll.h>
28#else
29# define LIBUNISTRING_DLL_VARIABLE
30#endif
31
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
38/* Conventions:
39
40 All functions prefixed with u8_ operate on UTF-8 encoded strings.
41 Their unit is an uint8_t (1 byte).
42
43 All functions prefixed with u16_ operate on UTF-16 encoded strings.
44 Their unit is an uint16_t (a 2-byte word).
45
46 All functions prefixed with u32_ operate on UCS-4 encoded strings.
47 Their unit is an uint32_t (a 4-byte word).
48
49 All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly
50 n units.
51
52 Functions returning a string result take a (resultbuf, lengthp) argument
53 pair. If resultbuf is not NULL and the result fits into *lengthp units,
54 it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly
55 allocated string is returned. In both cases, *lengthp is set to the
56 length (number of units) of the returned string. In case of error,
57 NULL is returned and errno is set. */
58
59
60enum
61{
62 UC_DECOMP_CANONICAL,/* Canonical decomposition. */
63 UC_DECOMP_FONT, /* <font> A font variant (e.g. a blackletter form). */
64 UC_DECOMP_NOBREAK, /* <noBreak> A no-break version of a space or hyphen. */
65 UC_DECOMP_INITIAL, /* <initial> An initial presentation form (Arabic). */
66 UC_DECOMP_MEDIAL, /* <medial> A medial presentation form (Arabic). */
67 UC_DECOMP_FINAL, /* <final> A final presentation form (Arabic). */
68 UC_DECOMP_ISOLATED,/* <isolated> An isolated presentation form (Arabic). */
69 UC_DECOMP_CIRCLE, /* <circle> An encircled form. */
70 UC_DECOMP_SUPER, /* <super> A superscript form. */
71 UC_DECOMP_SUB, /* <sub> A subscript form. */
72 UC_DECOMP_VERTICAL,/* <vertical> A vertical layout presentation form. */
73 UC_DECOMP_WIDE, /* <wide> A wide (or zenkaku) compatibility character. */
74 UC_DECOMP_NARROW, /* <narrow> A narrow (or hankaku) compatibility character. */
75 UC_DECOMP_SMALL, /* <small> A small variant form (CNS compatibility). */
76 UC_DECOMP_SQUARE, /* <square> A CJK squared font variant. */
77 UC_DECOMP_FRACTION,/* <fraction> A vulgar fraction form. */
78 UC_DECOMP_COMPAT /* <compat> Otherwise unspecified compatibility character. */
79};
80
81/* Maximum size of decomposition of a single Unicode character. */
82#define UC_DECOMPOSITION_MAX_LENGTH 32
83
84/* Return the character decomposition mapping of a Unicode character.
85 DECOMPOSITION must point to an array of at least UC_DECOMPOSITION_MAX_LENGTH
86 ucs_t elements.
87 When a decomposition exists, DECOMPOSITION[0..N-1] and *DECOMP_TAG are
88 filled and N is returned. Otherwise -1 is returned. */
89extern int
90 uc_decomposition (ucs4_t uc, int *decomp_tag, ucs4_t *decomposition);
91
92/* Return the canonical character decomposition mapping of a Unicode character.
93 DECOMPOSITION must point to an array of at least UC_DECOMPOSITION_MAX_LENGTH
94 ucs_t elements.
95 When a decomposition exists, DECOMPOSITION[0..N-1] is filled and N is
96 returned. Otherwise -1 is returned. */
97extern int
98 uc_canonical_decomposition (ucs4_t uc, ucs4_t *decomposition);
99
100
101/* Attempt to combine the Unicode characters uc1, uc2.
102 uc1 is known to have canonical combining class 0.
103 Return the combination of uc1 and uc2, if it exists.
104 Return 0 otherwise.
105 Not all decompositions can be recombined using this function. See the
106 Unicode file CompositionExclusions.txt for details. */
107extern ucs4_t
108 uc_composition (ucs4_t uc1, ucs4_t uc2)
109 _UC_ATTRIBUTE_CONST;
110
111
112/* An object of type uninorm_t denotes a Unicode normalization form. */
113struct unicode_normalization_form;
114typedef const struct unicode_normalization_form *uninorm_t;
115
116/* UNINORM_NFD: Normalization form D: canonical decomposition. */
117extern @GNULIB_UNINORM_NFD_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfd;
118#define UNINORM_NFD (&uninorm_nfd)
119
120/* UNINORM_NFC: Normalization form C: canonical decomposition, then
121 canonical composition. */
122extern @GNULIB_UNINORM_NFC_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfc;
123#define UNINORM_NFC (&uninorm_nfc)
124
125/* UNINORM_NFKD: Normalization form KD: compatibility decomposition. */
126extern @GNULIB_UNINORM_NFKD_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfkd;
127#define UNINORM_NFKD (&uninorm_nfkd)
128
129/* UNINORM_NFKC: Normalization form KC: compatibility decomposition, then
130 canonical composition. */
131extern @GNULIB_UNINORM_NFKC_DLL_VARIABLE@ const struct unicode_normalization_form uninorm_nfkc;
132#define UNINORM_NFKC (&uninorm_nfkc)
133
134/* Test whether a normalization form does compatibility decomposition. */
135#define uninorm_is_compat_decomposing(nf) \
136 ((* (const unsigned int *) (nf) >> 0) & 1)
137
138/* Test whether a normalization form includes canonical composition. */
139#define uninorm_is_composing(nf) \
140 ((* (const unsigned int *) (nf) >> 1) & 1)
141
142/* Return the decomposing variant of a normalization form.
143 This maps NFC,NFD -> NFD and NFKC,NFKD -> NFKD. */
144extern uninorm_t
145 uninorm_decomposing_form (uninorm_t nf)
146 _UC_ATTRIBUTE_PURE;
147
148
149/* Return the specified normalization form of a string. */
150extern uint8_t *
151 u8_normalize (uninorm_t nf, const uint8_t *s, size_t n,
152 uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
153extern uint16_t *
154 u16_normalize (uninorm_t nf, const uint16_t *s, size_t n,
155 uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
156extern uint32_t *
157 u32_normalize (uninorm_t nf, const uint32_t *s, size_t n,
158 uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
159
160
161/* Compare S1 and S2, ignoring differences in normalization.
162 NF must be either UNINORM_NFD or UNINORM_NFKD.
163 If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
164 return 0. Upon failure, return -1 with errno set. */
165extern int
166 u8_normcmp (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2,
167 uninorm_t nf, int *resultp);
168extern int
169 u16_normcmp (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2,
170 uninorm_t nf, int *resultp);
171extern int
172 u32_normcmp (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2,
173 uninorm_t nf, int *resultp);
174
175
176/* Converts the string S of length N to a NUL-terminated byte sequence, in such
177 a way that comparing uN_normxfrm (S1) and uN_normxfrm (S2) with uN_cmp2() is
178 equivalent to comparing S1 and S2 with uN_normcoll().
179 NF must be either UNINORM_NFC or UNINORM_NFKC. */
180extern char *
181 u8_normxfrm (const uint8_t *s, size_t n, uninorm_t nf,
182 char *resultbuf, size_t *lengthp);
183extern char *
184 u16_normxfrm (const uint16_t *s, size_t n, uninorm_t nf,
185 char *resultbuf, size_t *lengthp);
186extern char *
187 u32_normxfrm (const uint32_t *s, size_t n, uninorm_t nf,
188 char *resultbuf, size_t *lengthp);
189
190
191/* Compare S1 and S2, ignoring differences in normalization, using the
192 collation rules of the current locale.
193 NF must be either UNINORM_NFC or UNINORM_NFKC.
194 If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
195 return 0. Upon failure, return -1 with errno set. */
196extern int
197 u8_normcoll (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2,
198 uninorm_t nf, int *resultp);
199extern int
200 u16_normcoll (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2,
201 uninorm_t nf, int *resultp);
202extern int
203 u32_normcoll (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2,
204 uninorm_t nf, int *resultp);
205
206
207/* Normalization of a stream of Unicode characters.
208
209 A "stream of Unicode characters" is essentially a function that accepts an
210 ucs4_t argument repeatedly, optionally combined with a function that
211 "flushes" the stream. */
212
213/* Data type of a stream of Unicode characters that normalizes its input
214 according to a given normalization form and passes the normalized character
215 sequence to the encapsulated stream of Unicode characters. */
216struct uninorm_filter;
217
218/* Bring data buffered in the filter to its destination, the encapsulated
219 stream, then close and free the filter.
220 Return 0 if successful, or -1 with errno set upon failure. */
221extern int
222 uninorm_filter_free (struct uninorm_filter *filter);
223
224/* Create and return a normalization filter for Unicode characters.
225 The pair (stream_func, stream_data) is the encapsulated stream.
226 stream_func (stream_data, uc) receives the Unicode character uc
227 and returns 0 if successful, or -1 with errno set upon failure.
228 Return the new filter, or NULL with errno set upon failure. */
229extern struct uninorm_filter *
230 uninorm_filter_create (uninorm_t nf,
231 int (*stream_func) (void *stream_data, ucs4_t uc),
232 void *stream_data)
233 _GL_ATTRIBUTE_DEALLOC (uninorm_filter_free, 1);
234
235/* Stuff a Unicode character into a normalizing filter.
236 Return 0 if successful, or -1 with errno set upon failure. */
237extern int
238 uninorm_filter_write (struct uninorm_filter *filter, ucs4_t uc);
239
240/* Bring data buffered in the filter to its destination, the encapsulated
241 stream.
242 Return 0 if successful, or -1 with errno set upon failure.
243 Note! If after calling this function, additional characters are written
244 into the filter, the resulting character sequence in the encapsulated stream
245 will not necessarily be normalized. */
246extern int
247 uninorm_filter_flush (struct uninorm_filter *filter);
248
249
250#ifdef __cplusplus
251}
252#endif
253
254
255#endif /* _UNINORM_H */
diff --git a/gl/unistd.c b/gl/unistd.c
index be7a8255..414dce9a 100644
--- a/gl/unistd.c
+++ b/gl/unistd.c
@@ -1,6 +1,6 @@
1/* Inline functions for <unistd.h>. 1/* Inline functions for <unistd.h>.
2 2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc. 3 Copyright (C) 2012-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,8 +15,8 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
18#include <config.h> 19#include <config.h>
19 20
20#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE 21#include <unistd.h>
21#include "unistd.h"
22typedef int dummy; 22typedef int dummy;
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 4812fdb1..f7e4450c 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2023 Free Software Foundation, Inc. 2 Copyright (C) 2003-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -40,6 +40,24 @@
40# undef _GL_INCLUDING_UNISTD_H 40# undef _GL_INCLUDING_UNISTD_H
41#endif 41#endif
42 42
43/* Avoid lseek bugs in FreeBSD, macOS <https://bugs.gnu.org/61386>.
44 This bug is fixed after FreeBSD 13; see <https://bugs.freebsd.org/256205>.
45 Use macOS "9999" to stand for a future fixed macOS version. */
46#if defined __FreeBSD__ && __FreeBSD__ < 14
47# undef SEEK_DATA
48# undef SEEK_HOLE
49#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
50# ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
51# include <AvailabilityMacros.h>
52# endif
53# if (!defined MAC_OS_X_VERSION_MIN_REQUIRED \
54 || MAC_OS_X_VERSION_MIN_REQUIRED < 99990000)
55# include <sys/fcntl.h> /* It also defines the two macros. */
56# undef SEEK_DATA
57# undef SEEK_HOLE
58# endif
59#endif
60
43/* Get all possible declarations of gethostname(). */ 61/* Get all possible declarations of gethostname(). */
44#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ 62#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
45 && !defined _GL_INCLUDING_WINSOCK2_H 63 && !defined _GL_INCLUDING_WINSOCK2_H
@@ -51,6 +69,12 @@
51#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H 69#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
52#define _@GUARD_PREFIX@_UNISTD_H 70#define _@GUARD_PREFIX@_UNISTD_H
53 71
72/* This file uses _GL_ATTRIBUTE_NODISCARD, _GL_INLINE_HEADER_BEGIN, _GL_INLINE,
73 GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
74#if !_GL_CONFIG_H_INCLUDED
75 #error "Please include config.h first."
76#endif
77
54/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ 78/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
55/* But avoid namespace pollution on glibc systems. */ 79/* But avoid namespace pollution on glibc systems. */
56#ifndef __GLIBC__ 80#ifndef __GLIBC__
@@ -71,12 +95,21 @@
71# include <stdio.h> 95# include <stdio.h>
72#endif 96#endif
73 97
98/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
99 <io.h> and/or <direct.h>, not in <unistd.h>.
100 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
101 _lseek(), _read(), _unlink(), _write() in <io.h>. */
102#if defined _WIN32 && !defined __CYGWIN__
103# include <io.h>
104# include <direct.h>
105#endif
106
74/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in 107/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
75 <unistd.h>. */ 108 <unistd.h>. */
76/* But avoid namespace pollution on glibc systems. */ 109/* But avoid namespace pollution on glibc systems. */
77#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \ 110#if ((@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78 && (defined __CYGWIN__ || defined __ANDROID__) \ 111 && (defined __CYGWIN__ || defined __ANDROID__) \
79 && ! defined __GLIBC__ 112 && ! defined __GLIBC__)
80# include <fcntl.h> 113# include <fcntl.h>
81#endif 114#endif
82 115
@@ -84,33 +117,22 @@
84/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in 117/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
85 <unistd.h>. */ 118 <unistd.h>. */
86/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ 119/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
87/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
88 included here. */
89/* But avoid namespace pollution on glibc systems. */ 120/* But avoid namespace pollution on glibc systems. */
90#if !defined __GLIBC__ && !defined __osf__ 121#if !defined __GLIBC__
91# define __need_system_stdlib_h 122# define __need_system_stdlib_h
92# include <stdlib.h> 123# include <stdlib.h>
93# undef __need_system_stdlib_h 124# undef __need_system_stdlib_h
94#endif 125#endif
95 126
96/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
97 <io.h> and/or <direct.h>, not in <unistd.h>.
98 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
99 _lseek(), _read(), _unlink(), _write() in <io.h>. */
100#if defined _WIN32 && !defined __CYGWIN__
101# include <io.h>
102# include <direct.h>
103#endif
104
105/* Native Windows platforms declare _execl*, _execv* in <process.h>. */ 127/* Native Windows platforms declare _execl*, _execv* in <process.h>. */
106#if defined _WIN32 && !defined __CYGWIN__ 128#if defined _WIN32 && !defined __CYGWIN__
107# include <process.h> 129# include <process.h>
108#endif 130#endif
109 131
110/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. 132/* AIX declares getdomainname in <netdb.h>, not in <unistd.h>.
111 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */ 133 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
112/* But avoid namespace pollution on glibc systems. */ 134/* But avoid namespace pollution on glibc systems. */
113#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \ 135#if ((@GNULIB_GETDOMAINNAME@ && defined _AIX) \
114 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \ 136 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
115 && !defined __GLIBC__ 137 && !defined __GLIBC__
116# include <netdb.h> 138# include <netdb.h>
@@ -135,8 +157,9 @@
135#endif 157#endif
136 158
137/* MSVC defines off_t in <sys/types.h>. 159/* MSVC defines off_t in <sys/types.h>.
138 May also define off_t to a 64-bit type on native Windows. */ 160 May also define off_t to a 64-bit type on native Windows.
139/* Get off_t, ssize_t, mode_t. */ 161 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
162/* Get off_t, off64_t, ssize_t, mode_t. */
140#include <sys/types.h> 163#include <sys/types.h>
141 164
142/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 165/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -152,13 +175,13 @@
152# include <getopt-pfx-core.h> 175# include <getopt-pfx-core.h>
153#endif 176#endif
154 177
155#ifndef _GL_INLINE_HEADER_BEGIN
156 #error "Please include config.h first."
157#endif
158_GL_INLINE_HEADER_BEGIN 178_GL_INLINE_HEADER_BEGIN
159#ifndef _GL_UNISTD_INLINE 179#ifndef _GL_UNISTD_INLINE
160# define _GL_UNISTD_INLINE _GL_INLINE 180# define _GL_UNISTD_INLINE _GL_INLINE
161#endif 181#endif
182#ifndef _GL_GETPAGESIZE_INLINE
183# define _GL_GETPAGESIZE_INLINE _GL_INLINE
184#endif
162 185
163/* Hide some function declarations from <winsock2.h>. */ 186/* Hide some function declarations from <winsock2.h>. */
164 187
@@ -265,7 +288,7 @@ _GL_INLINE_HEADER_BEGIN
265# undef access 288# undef access
266# define access rpl_access 289# define access rpl_access
267# endif 290# endif
268_GL_FUNCDECL_RPL (access, int, (const char *file, int mode) 291_GL_FUNCDECL_RPL (access, int, (const char *file, int mode),
269 _GL_ARG_NONNULL ((1))); 292 _GL_ARG_NONNULL ((1)));
270_GL_CXXALIAS_RPL (access, int, (const char *file, int mode)); 293_GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
271# elif defined _WIN32 && !defined __CYGWIN__ 294# elif defined _WIN32 && !defined __CYGWIN__
@@ -279,7 +302,6 @@ _GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
279# endif 302# endif
280_GL_CXXALIASWARN (access); 303_GL_CXXALIASWARN (access);
281#elif defined GNULIB_POSIXCHECK 304#elif defined GNULIB_POSIXCHECK
282# undef access
283# if HAVE_RAW_DECL_ACCESS 305# if HAVE_RAW_DECL_ACCESS
284/* The access() function is a security risk. */ 306/* The access() function is a security risk. */
285_GL_WARN_ON_USE (access, "access does not always support X_OK - " 307_GL_WARN_ON_USE (access, "access does not always support X_OK - "
@@ -316,9 +338,8 @@ _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
316# endif 338# endif
317_GL_CXXALIASWARN (chdir); 339_GL_CXXALIASWARN (chdir);
318#elif defined GNULIB_POSIXCHECK 340#elif defined GNULIB_POSIXCHECK
319# undef chdir
320# if HAVE_RAW_DECL_CHDIR 341# if HAVE_RAW_DECL_CHDIR
321_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " 342_GL_WARN_ON_USE (chdir, "chdir is not always in <unistd.h> - "
322 "use gnulib module chdir for portability"); 343 "use gnulib module chdir for portability");
323# endif 344# endif
324#elif @GNULIB_MDA_CHDIR@ 345#elif @GNULIB_MDA_CHDIR@
@@ -349,19 +370,18 @@ _GL_CXXALIASWARN (chdir);
349# undef chown 370# undef chown
350# define chown rpl_chown 371# define chown rpl_chown
351# endif 372# endif
352_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid) 373_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid),
353 _GL_ARG_NONNULL ((1))); 374 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
354_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)); 375_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
355# else 376# else
356# if !@HAVE_CHOWN@ 377# if !@HAVE_CHOWN@
357_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid) 378_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid),
358 _GL_ARG_NONNULL ((1))); 379 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
359# endif 380# endif
360_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)); 381_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
361# endif 382# endif
362_GL_CXXALIASWARN (chown); 383_GL_CXXALIASWARN (chown);
363#elif defined GNULIB_POSIXCHECK 384#elif defined GNULIB_POSIXCHECK
364# undef chown
365# if HAVE_RAW_DECL_CHOWN 385# if HAVE_RAW_DECL_CHOWN
366_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and " 386_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
367 "doesn't treat a uid or gid of -1 on some systems - " 387 "doesn't treat a uid or gid of -1 on some systems - "
@@ -377,7 +397,7 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
377# undef close 397# undef close
378# define close rpl_close 398# define close rpl_close
379# endif 399# endif
380_GL_FUNCDECL_RPL (close, int, (int fd)); 400_GL_FUNCDECL_RPL (close, int, (int fd), );
381_GL_CXXALIAS_RPL (close, int, (int fd)); 401_GL_CXXALIAS_RPL (close, int, (int fd));
382# elif defined _WIN32 && !defined __CYGWIN__ 402# elif defined _WIN32 && !defined __CYGWIN__
383# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 403# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -390,10 +410,11 @@ _GL_CXXALIAS_SYS (close, int, (int fd));
390# endif 410# endif
391_GL_CXXALIASWARN (close); 411_GL_CXXALIASWARN (close);
392#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ 412#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
393# undef close 413# if !GNULIB_CLOSE
394# define close close_used_without_requesting_gnulib_module_close 414# undef close
415# define close close_used_without_requesting_gnulib_module_close
416# endif
395#elif defined GNULIB_POSIXCHECK 417#elif defined GNULIB_POSIXCHECK
396# undef close
397/* Assume close is always declared. */ 418/* Assume close is always declared. */
398_GL_WARN_ON_USE (close, "close does not portably work on sockets - " 419_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
399 "use gnulib module close for portability"); 420 "use gnulib module close for portability");
@@ -422,7 +443,7 @@ _GL_CXXALIASWARN (close);
422# endif 443# endif
423_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos, 444_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
424 int ofd, off_t *opos, 445 int ofd, off_t *opos,
425 size_t len, unsigned flags)); 446 size_t len, unsigned flags), );
426_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos, 447_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
427 int ofd, off_t *opos, 448 int ofd, off_t *opos,
428 size_t len, unsigned flags)); 449 size_t len, unsigned flags));
@@ -430,15 +451,16 @@ _GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
430# if !@HAVE_COPY_FILE_RANGE@ 451# if !@HAVE_COPY_FILE_RANGE@
431_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, 452_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
432 int ofd, off_t *opos, 453 int ofd, off_t *opos,
433 size_t len, unsigned flags)); 454 size_t len, unsigned flags), );
434# endif 455# endif
435_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, 456_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
436 int ofd, off_t *opos, 457 int ofd, off_t *opos,
437 size_t len, unsigned flags)); 458 size_t len, unsigned flags));
438# endif 459# endif
460# if __GLIBC__ >= 2
439_GL_CXXALIASWARN (copy_file_range); 461_GL_CXXALIASWARN (copy_file_range);
462# endif
440#elif defined GNULIB_POSIXCHECK 463#elif defined GNULIB_POSIXCHECK
441# undef copy_file_range
442# if HAVE_RAW_DECL_COPY_FILE_RANGE 464# if HAVE_RAW_DECL_COPY_FILE_RANGE
443_GL_WARN_ON_USE (copy_file_range, 465_GL_WARN_ON_USE (copy_file_range,
444 "copy_file_range is unportable - " 466 "copy_file_range is unportable - "
@@ -452,7 +474,7 @@ _GL_WARN_ON_USE (copy_file_range,
452# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 474# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
453# define dup rpl_dup 475# define dup rpl_dup
454# endif 476# endif
455_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 477_GL_FUNCDECL_RPL (dup, int, (int oldfd), _GL_ATTRIBUTE_NODISCARD);
456_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 478_GL_CXXALIAS_RPL (dup, int, (int oldfd));
457# elif defined _WIN32 && !defined __CYGWIN__ 479# elif defined _WIN32 && !defined __CYGWIN__
458# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 480# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -465,7 +487,6 @@ _GL_CXXALIAS_SYS (dup, int, (int oldfd));
465# endif 487# endif
466_GL_CXXALIASWARN (dup); 488_GL_CXXALIASWARN (dup);
467#elif defined GNULIB_POSIXCHECK 489#elif defined GNULIB_POSIXCHECK
468# undef dup
469# if HAVE_RAW_DECL_DUP 490# if HAVE_RAW_DECL_DUP
470_GL_WARN_ON_USE (dup, "dup is unportable - " 491_GL_WARN_ON_USE (dup, "dup is unportable - "
471 "use gnulib module dup for portability"); 492 "use gnulib module dup for portability");
@@ -497,7 +518,7 @@ _GL_CXXALIASWARN (dup);
497# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 518# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
498# define dup2 rpl_dup2 519# define dup2 rpl_dup2
499# endif 520# endif
500_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); 521_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd), );
501_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); 522_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
502# elif defined _WIN32 && !defined __CYGWIN__ 523# elif defined _WIN32 && !defined __CYGWIN__
503# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 524# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -510,7 +531,6 @@ _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
510# endif 531# endif
511_GL_CXXALIASWARN (dup2); 532_GL_CXXALIASWARN (dup2);
512#elif defined GNULIB_POSIXCHECK 533#elif defined GNULIB_POSIXCHECK
513# undef dup2
514# if HAVE_RAW_DECL_DUP2 534# if HAVE_RAW_DECL_DUP2
515_GL_WARN_ON_USE (dup2, "dup2 is unportable - " 535_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
516 "use gnulib module dup2 for portability"); 536 "use gnulib module dup2 for portability");
@@ -541,19 +561,23 @@ _GL_CXXALIASWARN (dup2);
541 Return newfd if successful, otherwise -1 and errno set. 561 Return newfd if successful, otherwise -1 and errno set.
542 See the Linux man page at 562 See the Linux man page at
543 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ 563 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
544# if @HAVE_DUP3@ 564# if @REPLACE_DUP3@
545# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 565# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
566# undef dup3
546# define dup3 rpl_dup3 567# define dup3 rpl_dup3
547# endif 568# endif
548_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); 569_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags), );
549_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); 570_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
550# else 571# else
551_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); 572# if !@HAVE_DUP3@
573_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags), );
574# endif
552_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); 575_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
553# endif 576# endif
577# if __GLIBC__ >= 2
554_GL_CXXALIASWARN (dup3); 578_GL_CXXALIASWARN (dup3);
579# endif
555#elif defined GNULIB_POSIXCHECK 580#elif defined GNULIB_POSIXCHECK
556# undef dup3
557# if HAVE_RAW_DECL_DUP3 581# if HAVE_RAW_DECL_DUP3
558_GL_WARN_ON_USE (dup3, "dup3 is unportable - " 582_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
559 "use gnulib module dup3 for portability"); 583 "use gnulib module dup3 for portability");
@@ -610,7 +634,7 @@ rpl_environ (void)
610/* Like access(), except that it uses the effective user id and group id of 634/* Like access(), except that it uses the effective user id and group id of
611 the current process. */ 635 the current process. */
612# if !@HAVE_EUIDACCESS@ 636# if !@HAVE_EUIDACCESS@
613_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) 637_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode),
614 _GL_ARG_NONNULL ((1))); 638 _GL_ARG_NONNULL ((1)));
615# endif 639# endif
616_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); 640_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
@@ -621,7 +645,6 @@ _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
621 "use the gnulib module faccessat instead"); 645 "use the gnulib module faccessat instead");
622# endif 646# endif
623#elif defined GNULIB_POSIXCHECK 647#elif defined GNULIB_POSIXCHECK
624# undef euidaccess
625# if HAVE_RAW_DECL_EUIDACCESS 648# if HAVE_RAW_DECL_EUIDACCESS
626_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " 649_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
627 "use gnulib module euidaccess for portability"); 650 "use gnulib module euidaccess for portability");
@@ -635,7 +658,7 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
635# undef execl 658# undef execl
636# define execl rpl_execl 659# define execl rpl_execl
637# endif 660# endif
638_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...) 661_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...),
639 _GL_ARG_NONNULL ((1))); 662 _GL_ARG_NONNULL ((1)));
640_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...)); 663_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
641# else 664# else
@@ -643,7 +666,6 @@ _GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
643# endif 666# endif
644_GL_CXXALIASWARN (execl); 667_GL_CXXALIASWARN (execl);
645#elif defined GNULIB_POSIXCHECK 668#elif defined GNULIB_POSIXCHECK
646# undef execl
647# if HAVE_RAW_DECL_EXECL 669# if HAVE_RAW_DECL_EXECL
648_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - " 670_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
649 "use gnulib module execl for portability"); 671 "use gnulib module execl for portability");
@@ -670,7 +692,7 @@ _GL_CXXALIASWARN (execl);
670# undef execle 692# undef execle
671# define execle rpl_execle 693# define execle rpl_execle
672# endif 694# endif
673_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...) 695_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...),
674 _GL_ARG_NONNULL ((1))); 696 _GL_ARG_NONNULL ((1)));
675_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...)); 697_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
676# else 698# else
@@ -678,7 +700,6 @@ _GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
678# endif 700# endif
679_GL_CXXALIASWARN (execle); 701_GL_CXXALIASWARN (execle);
680#elif defined GNULIB_POSIXCHECK 702#elif defined GNULIB_POSIXCHECK
681# undef execle
682# if HAVE_RAW_DECL_EXECLE 703# if HAVE_RAW_DECL_EXECLE
683_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - " 704_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
684 "use gnulib module execle for portability"); 705 "use gnulib module execle for portability");
@@ -706,7 +727,7 @@ _GL_CXXALIASWARN (execle);
706# undef execlp 727# undef execlp
707# define execlp rpl_execlp 728# define execlp rpl_execlp
708# endif 729# endif
709_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...) 730_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...),
710 _GL_ARG_NONNULL ((1))); 731 _GL_ARG_NONNULL ((1)));
711_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...)); 732_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
712# else 733# else
@@ -714,7 +735,6 @@ _GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
714# endif 735# endif
715_GL_CXXALIASWARN (execlp); 736_GL_CXXALIASWARN (execlp);
716#elif defined GNULIB_POSIXCHECK 737#elif defined GNULIB_POSIXCHECK
717# undef execlp
718# if HAVE_RAW_DECL_EXECLP 738# if HAVE_RAW_DECL_EXECLP
719_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - " 739_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
720 "use gnulib module execlp for portability"); 740 "use gnulib module execlp for portability");
@@ -743,7 +763,7 @@ _GL_CXXALIASWARN (execlp);
743# undef execv 763# undef execv
744# define execv rpl_execv 764# define execv rpl_execv
745# endif 765# endif
746_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv) 766_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv),
747 _GL_ARG_NONNULL ((1, 2))); 767 _GL_ARG_NONNULL ((1, 2)));
748_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv)); 768_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
749# else 769# else
@@ -751,7 +771,6 @@ _GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
751# endif 771# endif
752_GL_CXXALIASWARN (execv); 772_GL_CXXALIASWARN (execv);
753#elif defined GNULIB_POSIXCHECK 773#elif defined GNULIB_POSIXCHECK
754# undef execv
755# if HAVE_RAW_DECL_EXECV 774# if HAVE_RAW_DECL_EXECV
756_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - " 775_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
757 "use gnulib module execv for portability"); 776 "use gnulib module execv for portability");
@@ -780,7 +799,7 @@ _GL_CXXALIASWARN (execv);
780# define execve rpl_execve 799# define execve rpl_execve
781# endif 800# endif
782_GL_FUNCDECL_RPL (execve, int, 801_GL_FUNCDECL_RPL (execve, int,
783 (const char *program, char * const *argv, char * const *env) 802 (const char *program, char * const *argv, char * const *env),
784 _GL_ARG_NONNULL ((1, 2))); 803 _GL_ARG_NONNULL ((1, 2)));
785_GL_CXXALIAS_RPL (execve, int, 804_GL_CXXALIAS_RPL (execve, int,
786 (const char *program, char * const *argv, char * const *env)); 805 (const char *program, char * const *argv, char * const *env));
@@ -790,7 +809,6 @@ _GL_CXXALIAS_SYS (execve, int,
790# endif 809# endif
791_GL_CXXALIASWARN (execve); 810_GL_CXXALIASWARN (execve);
792#elif defined GNULIB_POSIXCHECK 811#elif defined GNULIB_POSIXCHECK
793# undef execve
794# if HAVE_RAW_DECL_EXECVE 812# if HAVE_RAW_DECL_EXECVE
795_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - " 813_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
796 "use gnulib module execve for portability"); 814 "use gnulib module execve for portability");
@@ -820,7 +838,7 @@ _GL_CXXALIASWARN (execve);
820# undef execvp 838# undef execvp
821# define execvp rpl_execvp 839# define execvp rpl_execvp
822# endif 840# endif
823_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv) 841_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv),
824 _GL_ARG_NONNULL ((1, 2))); 842 _GL_ARG_NONNULL ((1, 2)));
825_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv)); 843_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
826# else 844# else
@@ -828,7 +846,6 @@ _GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
828# endif 846# endif
829_GL_CXXALIASWARN (execvp); 847_GL_CXXALIASWARN (execvp);
830#elif defined GNULIB_POSIXCHECK 848#elif defined GNULIB_POSIXCHECK
831# undef execvp
832# if HAVE_RAW_DECL_EXECVP 849# if HAVE_RAW_DECL_EXECVP
833_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - " 850_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
834 "use gnulib module execvp for portability"); 851 "use gnulib module execvp for portability");
@@ -857,22 +874,23 @@ _GL_CXXALIASWARN (execvp);
857# define execvpe rpl_execvpe 874# define execvpe rpl_execvpe
858# endif 875# endif
859_GL_FUNCDECL_RPL (execvpe, int, 876_GL_FUNCDECL_RPL (execvpe, int,
860 (const char *program, char * const *argv, char * const *env) 877 (const char *program, char * const *argv, char * const *env),
861 _GL_ARG_NONNULL ((1, 2))); 878 _GL_ARG_NONNULL ((1, 2)));
862_GL_CXXALIAS_RPL (execvpe, int, 879_GL_CXXALIAS_RPL (execvpe, int,
863 (const char *program, char * const *argv, char * const *env)); 880 (const char *program, char * const *argv, char * const *env));
864# else 881# else
865# if !@HAVE_DECL_EXECVPE@ 882# if !@HAVE_DECL_EXECVPE@
866_GL_FUNCDECL_SYS (execvpe, int, 883_GL_FUNCDECL_SYS (execvpe, int,
867 (const char *program, char * const *argv, char * const *env) 884 (const char *program, char * const *argv, char * const *env),
868 _GL_ARG_NONNULL ((1, 2))); 885 _GL_ARG_NONNULL ((1, 2)));
869# endif 886# endif
870_GL_CXXALIAS_SYS (execvpe, int, 887_GL_CXXALIAS_SYS (execvpe, int,
871 (const char *program, char * const *argv, char * const *env)); 888 (const char *program, char * const *argv, char * const *env));
872# endif 889# endif
890# if __GLIBC__ >= 2
873_GL_CXXALIASWARN (execvpe); 891_GL_CXXALIASWARN (execvpe);
892# endif
874#elif defined GNULIB_POSIXCHECK 893#elif defined GNULIB_POSIXCHECK
875# undef execvpe
876# if HAVE_RAW_DECL_EXECVPE 894# if HAVE_RAW_DECL_EXECVPE
877_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - " 895_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
878 "use gnulib module execvpe for portability"); 896 "use gnulib module execvpe for portability");
@@ -893,7 +911,7 @@ _GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
893# elif @HAVE_EXECVPE@ 911# elif @HAVE_EXECVPE@
894# if !@HAVE_DECL_EXECVPE@ 912# if !@HAVE_DECL_EXECVPE@
895_GL_FUNCDECL_SYS (execvpe, int, 913_GL_FUNCDECL_SYS (execvpe, int,
896 (const char *program, char * const *argv, char * const *env) 914 (const char *program, char * const *argv, char * const *env),
897 _GL_ARG_NONNULL ((1, 2))); 915 _GL_ARG_NONNULL ((1, 2)));
898# endif 916# endif
899_GL_CXXALIAS_SYS (execvpe, int, 917_GL_CXXALIAS_SYS (execvpe, int,
@@ -912,22 +930,23 @@ _GL_CXXALIASWARN (execvpe);
912# define faccessat rpl_faccessat 930# define faccessat rpl_faccessat
913# endif 931# endif
914_GL_FUNCDECL_RPL (faccessat, int, 932_GL_FUNCDECL_RPL (faccessat, int,
915 (int fd, char const *name, int mode, int flag) 933 (int fd, char const *name, int mode, int flag),
916 _GL_ARG_NONNULL ((2))); 934 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
917_GL_CXXALIAS_RPL (faccessat, int, 935_GL_CXXALIAS_RPL (faccessat, int,
918 (int fd, char const *name, int mode, int flag)); 936 (int fd, char const *name, int mode, int flag));
919# else 937# else
920# if !@HAVE_FACCESSAT@ 938# if !@HAVE_FACCESSAT@
921_GL_FUNCDECL_SYS (faccessat, int, 939_GL_FUNCDECL_SYS (faccessat, int,
922 (int fd, char const *file, int mode, int flag) 940 (int fd, char const *file, int mode, int flag),
923 _GL_ARG_NONNULL ((2))); 941 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
924# endif 942# endif
925_GL_CXXALIAS_SYS (faccessat, int, 943_GL_CXXALIAS_SYS (faccessat, int,
926 (int fd, char const *file, int mode, int flag)); 944 (int fd, char const *file, int mode, int flag));
927# endif 945# endif
946# if __GLIBC__ >= 2
928_GL_CXXALIASWARN (faccessat); 947_GL_CXXALIASWARN (faccessat);
948# endif
929#elif defined GNULIB_POSIXCHECK 949#elif defined GNULIB_POSIXCHECK
930# undef faccessat
931# if HAVE_RAW_DECL_FACCESSAT 950# if HAVE_RAW_DECL_FACCESSAT
932_GL_WARN_ON_USE (faccessat, "faccessat is not portable - " 951_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
933 "use gnulib module faccessat for portability"); 952 "use gnulib module faccessat for portability");
@@ -941,25 +960,29 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
941 Return 0 if successful, otherwise -1 and errno set. 960 Return 0 if successful, otherwise -1 and errno set.
942 See the POSIX:2008 specification 961 See the POSIX:2008 specification
943 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ 962 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
944# if ! @HAVE_FCHDIR@ 963# if @REPLACE_FCHDIR@
945_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); 964# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
946 965# undef fchdir
966# define fchdir rpl_fchdir
967# endif
968_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/), _GL_ATTRIBUTE_NODISCARD);
969_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
970# else
971# if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@
972_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/), _GL_ATTRIBUTE_NODISCARD);
973# endif
974_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
975# endif
976_GL_CXXALIASWARN (fchdir);
977# if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@
947/* Gnulib internal hooks needed to maintain the fchdir metadata. */ 978/* Gnulib internal hooks needed to maintain the fchdir metadata. */
948_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) 979_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
949 _GL_ARG_NONNULL ((2)); 980 _GL_ARG_NONNULL ((2));
950_GL_EXTERN_C void _gl_unregister_fd (int fd); 981_GL_EXTERN_C void _gl_unregister_fd (int fd);
951_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); 982_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
952_GL_EXTERN_C const char *_gl_directory_name (int fd); 983_GL_EXTERN_C const char *_gl_directory_name (int fd);
953
954# else
955# if !@HAVE_DECL_FCHDIR@
956_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
957# endif
958# endif 984# endif
959_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
960_GL_CXXALIASWARN (fchdir);
961#elif defined GNULIB_POSIXCHECK 985#elif defined GNULIB_POSIXCHECK
962# undef fchdir
963# if HAVE_RAW_DECL_FCHDIR 986# if HAVE_RAW_DECL_FCHDIR
964_GL_WARN_ON_USE (fchdir, "fchdir is unportable - " 987_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
965 "use gnulib module fchdir for portability"); 988 "use gnulib module fchdir for portability");
@@ -974,22 +997,21 @@ _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
974# define fchownat rpl_fchownat 997# define fchownat rpl_fchownat
975# endif 998# endif
976_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, 999_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
977 uid_t owner, gid_t group, int flag) 1000 uid_t owner, gid_t group, int flag),
978 _GL_ARG_NONNULL ((2))); 1001 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
979_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, 1002_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
980 uid_t owner, gid_t group, int flag)); 1003 uid_t owner, gid_t group, int flag));
981# else 1004# else
982# if !@HAVE_FCHOWNAT@ 1005# if !@HAVE_FCHOWNAT@
983_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, 1006_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
984 uid_t owner, gid_t group, int flag) 1007 uid_t owner, gid_t group, int flag),
985 _GL_ARG_NONNULL ((2))); 1008 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
986# endif 1009# endif
987_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, 1010_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
988 uid_t owner, gid_t group, int flag)); 1011 uid_t owner, gid_t group, int flag));
989# endif 1012# endif
990_GL_CXXALIASWARN (fchownat); 1013_GL_CXXALIASWARN (fchownat);
991#elif defined GNULIB_POSIXCHECK 1014#elif defined GNULIB_POSIXCHECK
992# undef fchownat
993# if HAVE_RAW_DECL_FCHOWNAT 1015# if HAVE_RAW_DECL_FCHOWNAT
994_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " 1016_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
995 "use gnulib module fchownat for portability"); 1017 "use gnulib module fchownat for portability");
@@ -1002,13 +1024,23 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
1002 Return 0 if successful, otherwise -1 and errno set. 1024 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification 1025 See POSIX:2008 specification
1004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ 1026 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
1005# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ 1027# if @REPLACE_FDATASYNC@
1006_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); 1028# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007# endif 1029# undef fdatasync
1030# define fdatasync rpl_fdatasync
1031# endif
1032_GL_FUNCDECL_RPL (fdatasync, int, (int fd), );
1033_GL_CXXALIAS_RPL (fdatasync, int, (int fd));
1034# else
1035# if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@
1036_GL_FUNCDECL_SYS (fdatasync, int, (int fd), );
1037# endif
1008_GL_CXXALIAS_SYS (fdatasync, int, (int fd)); 1038_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
1039# endif
1040# if __GLIBC__ >= 2
1009_GL_CXXALIASWARN (fdatasync); 1041_GL_CXXALIASWARN (fdatasync);
1042# endif
1010#elif defined GNULIB_POSIXCHECK 1043#elif defined GNULIB_POSIXCHECK
1011# undef fdatasync
1012# if HAVE_RAW_DECL_FDATASYNC 1044# if HAVE_RAW_DECL_FDATASYNC
1013_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - " 1045_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
1014 "use gnulib module fdatasync for portability"); 1046 "use gnulib module fdatasync for portability");
@@ -1022,12 +1054,11 @@ _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
1022 See POSIX:2008 specification 1054 See POSIX:2008 specification
1023 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ 1055 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1024# if !@HAVE_FSYNC@ 1056# if !@HAVE_FSYNC@
1025_GL_FUNCDECL_SYS (fsync, int, (int fd)); 1057_GL_FUNCDECL_SYS (fsync, int, (int fd), );
1026# endif 1058# endif
1027_GL_CXXALIAS_SYS (fsync, int, (int fd)); 1059_GL_CXXALIAS_SYS (fsync, int, (int fd));
1028_GL_CXXALIASWARN (fsync); 1060_GL_CXXALIASWARN (fsync);
1029#elif defined GNULIB_POSIXCHECK 1061#elif defined GNULIB_POSIXCHECK
1030# undef fsync
1031# if HAVE_RAW_DECL_FSYNC 1062# if HAVE_RAW_DECL_FSYNC
1032_GL_WARN_ON_USE (fsync, "fsync is unportable - " 1063_GL_WARN_ON_USE (fsync, "fsync is unportable - "
1033 "use gnulib module fsync for portability"); 1064 "use gnulib module fsync for portability");
@@ -1045,17 +1076,22 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
1045# undef ftruncate 1076# undef ftruncate
1046# define ftruncate rpl_ftruncate 1077# define ftruncate rpl_ftruncate
1047# endif 1078# endif
1048_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length)); 1079_GL_FUNCDECL_RPL (ftruncate, int,
1049_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length)); 1080 (int fd, off_t length), _GL_ATTRIBUTE_NODISCARD);
1081_GL_CXXALIAS_RPL (ftruncate, int,
1082 (int fd, off_t length));
1050# else 1083# else
1051# if !@HAVE_FTRUNCATE@ 1084# if !@HAVE_FTRUNCATE@
1052_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); 1085_GL_FUNCDECL_SYS (ftruncate, int,
1086 (int fd, off_t length), _GL_ATTRIBUTE_NODISCARD);
1053# endif 1087# endif
1054_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); 1088_GL_CXXALIAS_SYS (ftruncate, int,
1089 (int fd, off_t length));
1055# endif 1090# endif
1091# if __GLIBC__ >= 2
1056_GL_CXXALIASWARN (ftruncate); 1092_GL_CXXALIASWARN (ftruncate);
1093# endif
1057#elif defined GNULIB_POSIXCHECK 1094#elif defined GNULIB_POSIXCHECK
1058# undef ftruncate
1059# if HAVE_RAW_DECL_FTRUNCATE 1095# if HAVE_RAW_DECL_FTRUNCATE
1060_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " 1096_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
1061 "use gnulib module ftruncate for portability"); 1097 "use gnulib module ftruncate for portability");
@@ -1070,15 +1106,16 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
1070 or SIZE was too small. 1106 or SIZE was too small.
1071 See the POSIX:2008 specification 1107 See the POSIX:2008 specification
1072 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. 1108 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1073 Additionally, the gnulib module 'getcwd' guarantees the following GNU 1109 Additionally, the gnulib module 'getcwd' or 'getcwd-lgpl' guarantees the
1074 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 1110 following GNU extension: If BUF is NULL, an array is allocated with
1075 is SIZE bytes long, unless SIZE == 0, in which case it is as big as 1111 'malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case
1076 necessary. */ 1112 it is as big as necessary. */
1077# if @REPLACE_GETCWD@ 1113# if @REPLACE_GETCWD@
1078# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1114# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1079# define getcwd rpl_getcwd 1115# define getcwd rpl_getcwd
1080# endif 1116# endif
1081_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); 1117_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size),
1118 _GL_ATTRIBUTE_NODISCARD);
1082_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); 1119_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1083# elif defined _WIN32 && !defined __CYGWIN__ 1120# elif defined _WIN32 && !defined __CYGWIN__
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1121# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1093,7 +1130,6 @@ _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1093# endif 1130# endif
1094_GL_CXXALIASWARN (getcwd); 1131_GL_CXXALIASWARN (getcwd);
1095#elif defined GNULIB_POSIXCHECK 1132#elif defined GNULIB_POSIXCHECK
1096# undef getcwd
1097# if HAVE_RAW_DECL_GETCWD 1133# if HAVE_RAW_DECL_GETCWD
1098_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " 1134_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
1099 "use gnulib module getcwd for portability"); 1135 "use gnulib module getcwd for portability");
@@ -1133,21 +1169,24 @@ _GL_CXXALIASWARN (getcwd);
1133# undef getdomainname 1169# undef getdomainname
1134# define getdomainname rpl_getdomainname 1170# define getdomainname rpl_getdomainname
1135# endif 1171# endif
1136_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) 1172_GL_FUNCDECL_RPL (getdomainname, int,
1137 _GL_ARG_NONNULL ((1))); 1173 (char *name, size_t len),
1138_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); 1174 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1175_GL_CXXALIAS_RPL (getdomainname, int,
1176 (char *name, size_t len));
1139# else 1177# else
1140# if !@HAVE_DECL_GETDOMAINNAME@ 1178# if !@HAVE_DECL_GETDOMAINNAME@
1141_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) 1179_GL_FUNCDECL_SYS (getdomainname, int,
1142 _GL_ARG_NONNULL ((1))); 1180 (char *name, size_t len),
1181 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1143# endif 1182# endif
1144_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); 1183_GL_CXXALIAS_SYS (getdomainname, int,
1184 (char *name, size_t len));
1145# endif 1185# endif
1146# if __GLIBC__ >= 2 1186# if __GLIBC__ >= 2
1147_GL_CXXALIASWARN (getdomainname); 1187_GL_CXXALIASWARN (getdomainname);
1148# endif 1188# endif
1149#elif defined GNULIB_POSIXCHECK 1189#elif defined GNULIB_POSIXCHECK
1150# undef getdomainname
1151# if HAVE_RAW_DECL_GETDOMAINNAME 1190# if HAVE_RAW_DECL_GETDOMAINNAME
1152_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - " 1191_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
1153 "use gnulib module getdomainname for portability"); 1192 "use gnulib module getdomainname for portability");
@@ -1163,11 +1202,11 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
1163# undef getdtablesize 1202# undef getdtablesize
1164# define getdtablesize rpl_getdtablesize 1203# define getdtablesize rpl_getdtablesize
1165# endif 1204# endif
1166_GL_FUNCDECL_RPL (getdtablesize, int, (void)); 1205_GL_FUNCDECL_RPL (getdtablesize, int, (void), );
1167_GL_CXXALIAS_RPL (getdtablesize, int, (void)); 1206_GL_CXXALIAS_RPL (getdtablesize, int, (void));
1168# else 1207# else
1169# if !@HAVE_GETDTABLESIZE@ 1208# if !@HAVE_GETDTABLESIZE@
1170_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 1209_GL_FUNCDECL_SYS (getdtablesize, int, (void), );
1171# endif 1210# endif
1172/* Need to cast, because on AIX, the parameter list is 1211/* Need to cast, because on AIX, the parameter list is
1173 (...). */ 1212 (...). */
@@ -1175,7 +1214,6 @@ _GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
1175# endif 1214# endif
1176_GL_CXXALIASWARN (getdtablesize); 1215_GL_CXXALIASWARN (getdtablesize);
1177#elif defined GNULIB_POSIXCHECK 1216#elif defined GNULIB_POSIXCHECK
1178# undef getdtablesize
1179# if HAVE_RAW_DECL_GETDTABLESIZE 1217# if HAVE_RAW_DECL_GETDTABLESIZE
1180_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " 1218_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
1181 "use gnulib module getdtablesize for portability"); 1219 "use gnulib module getdtablesize for portability");
@@ -1185,13 +1223,27 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
1185 1223
1186#if @GNULIB_GETENTROPY@ 1224#if @GNULIB_GETENTROPY@
1187/* Fill a buffer with random bytes. */ 1225/* Fill a buffer with random bytes. */
1188# if !@HAVE_GETENTROPY@ 1226# if @REPLACE_GETENTROPY@
1189_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length)); 1227# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1228# undef getentropy
1229# define getentropy rpl_getentropy
1230# endif
1231_GL_FUNCDECL_RPL (getentropy, int,
1232 (void *buffer, size_t length), _GL_ATTRIBUTE_NODISCARD);
1233_GL_CXXALIAS_RPL (getentropy, int,
1234 (void *buffer, size_t length));
1235# else
1236# if !@HAVE_GETENTROPY@
1237_GL_FUNCDECL_SYS (getentropy, int,
1238 (void *buffer, size_t length), _GL_ATTRIBUTE_NODISCARD);
1239# endif
1240_GL_CXXALIAS_SYS (getentropy, int,
1241 (void *buffer, size_t length));
1190# endif 1242# endif
1191_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length)); 1243# if __GLIBC__ >= 2
1192_GL_CXXALIASWARN (getentropy); 1244_GL_CXXALIASWARN (getentropy);
1245# endif
1193#elif defined GNULIB_POSIXCHECK 1246#elif defined GNULIB_POSIXCHECK
1194# undef getentropy
1195# if HAVE_RAW_DECL_GETENTROPY 1247# if HAVE_RAW_DECL_GETENTROPY
1196_GL_WARN_ON_USE (getentropy, "getentropy is unportable - " 1248_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1197 "use gnulib module getentropy for portability"); 1249 "use gnulib module getentropy for portability");
@@ -1210,17 +1262,20 @@ _GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1210# undef getgroups 1262# undef getgroups
1211# define getgroups rpl_getgroups 1263# define getgroups rpl_getgroups
1212# endif 1264# endif
1213_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); 1265_GL_FUNCDECL_RPL (getgroups, int,
1214_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); 1266 (int n, gid_t *groups), _GL_ATTRIBUTE_NODISCARD);
1267_GL_CXXALIAS_RPL (getgroups, int,
1268 (int n, gid_t *groups));
1215# else 1269# else
1216# if !@HAVE_GETGROUPS@ 1270# if !@HAVE_GETGROUPS@
1217_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); 1271_GL_FUNCDECL_SYS (getgroups, int,
1272 (int n, gid_t *groups), _GL_ATTRIBUTE_NODISCARD);
1218# endif 1273# endif
1219_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); 1274_GL_CXXALIAS_SYS (getgroups, int,
1275 (int n, gid_t *groups));
1220# endif 1276# endif
1221_GL_CXXALIASWARN (getgroups); 1277_GL_CXXALIASWARN (getgroups);
1222#elif defined GNULIB_POSIXCHECK 1278#elif defined GNULIB_POSIXCHECK
1223# undef getgroups
1224# if HAVE_RAW_DECL_GETGROUPS 1279# if HAVE_RAW_DECL_GETGROUPS
1225_GL_WARN_ON_USE (getgroups, "getgroups is unportable - " 1280_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
1226 "use gnulib module getgroups for portability"); 1281 "use gnulib module getgroups for portability");
@@ -1241,25 +1296,25 @@ _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
1241# undef gethostname 1296# undef gethostname
1242# define gethostname rpl_gethostname 1297# define gethostname rpl_gethostname
1243# endif 1298# endif
1244_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) 1299_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len),
1245 _GL_ARG_NONNULL ((1))); 1300 _GL_ARG_NONNULL ((1)));
1246_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); 1301_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
1247# else 1302# else
1248# if !@HAVE_GETHOSTNAME@ 1303# if !@HAVE_GETHOSTNAME@
1249_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) 1304_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len),
1250 _GL_ARG_NONNULL ((1))); 1305 _GL_ARG_NONNULL ((1)));
1251# endif 1306# endif
1252/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second 1307/* Need to cast, because on Solaris 10 systems, the second parameter is
1253 parameter is
1254 int len. */ 1308 int len. */
1255_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); 1309_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
1256# endif 1310# endif
1257_GL_CXXALIASWARN (gethostname); 1311_GL_CXXALIASWARN (gethostname);
1258#elif @UNISTD_H_HAVE_WINSOCK2_H@ 1312#elif @UNISTD_H_HAVE_WINSOCK2_H@
1259# undef gethostname 1313# if !GNULIB_GETHOSTNAME
1260# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname 1314# undef gethostname
1315# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1316# endif
1261#elif defined GNULIB_POSIXCHECK 1317#elif defined GNULIB_POSIXCHECK
1262# undef gethostname
1263# if HAVE_RAW_DECL_GETHOSTNAME 1318# if HAVE_RAW_DECL_GETHOSTNAME
1264_GL_WARN_ON_USE (gethostname, "gethostname is unportable - " 1319_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1265 "use gnulib module gethostname for portability"); 1320 "use gnulib module gethostname for portability");
@@ -1278,13 +1333,22 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
1278 ${LOGNAME-$USER} on Unix platforms, 1333 ${LOGNAME-$USER} on Unix platforms,
1279 $USERNAME on native Windows platforms. 1334 $USERNAME on native Windows platforms.
1280 */ 1335 */
1281# if !@HAVE_DECL_GETLOGIN@ 1336# if @REPLACE_GETLOGIN@
1282_GL_FUNCDECL_SYS (getlogin, char *, (void)); 1337# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1283# endif 1338# define getlogin rpl_getlogin
1339# endif
1340_GL_FUNCDECL_RPL (getlogin, char *, (void), );
1341_GL_CXXALIAS_RPL (getlogin, char *, (void));
1342# else
1343# if !@HAVE_DECL_GETLOGIN@
1344_GL_FUNCDECL_SYS (getlogin, char *, (void), );
1345# endif
1284_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1346_GL_CXXALIAS_SYS (getlogin, char *, (void));
1347# endif
1348# if __GLIBC__ >= 2
1285_GL_CXXALIASWARN (getlogin); 1349_GL_CXXALIASWARN (getlogin);
1350# endif
1286#elif defined GNULIB_POSIXCHECK 1351#elif defined GNULIB_POSIXCHECK
1287# undef getlogin
1288# if HAVE_RAW_DECL_GETLOGIN 1352# if HAVE_RAW_DECL_GETLOGIN
1289_GL_WARN_ON_USE (getlogin, "getlogin is unportable - " 1353_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
1290 "use gnulib module getlogin for portability"); 1354 "use gnulib module getlogin for portability");
@@ -1311,21 +1375,22 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
1311# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1375# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1312# define getlogin_r rpl_getlogin_r 1376# define getlogin_r rpl_getlogin_r
1313# endif 1377# endif
1314_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) 1378_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size),
1315 _GL_ARG_NONNULL ((1))); 1379 _GL_ARG_NONNULL ((1)));
1316_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); 1380_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
1317# else 1381# else
1318# if !@HAVE_DECL_GETLOGIN_R@ 1382# if !@HAVE_DECL_GETLOGIN_R@
1319_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) 1383_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size),
1320 _GL_ARG_NONNULL ((1))); 1384 _GL_ARG_NONNULL ((1)));
1321# endif 1385# endif
1322/* Need to cast, because on Solaris 10 systems, the second argument is 1386/* Need to cast, because on Solaris 10 systems, the second argument is
1323 int size. */ 1387 int size. */
1324_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); 1388_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
1325# endif 1389# endif
1390# if __GLIBC__ >= 2
1326_GL_CXXALIASWARN (getlogin_r); 1391_GL_CXXALIASWARN (getlogin_r);
1392# endif
1327#elif defined GNULIB_POSIXCHECK 1393#elif defined GNULIB_POSIXCHECK
1328# undef getlogin_r
1329# if HAVE_RAW_DECL_GETLOGIN_R 1394# if HAVE_RAW_DECL_GETLOGIN_R
1330_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " 1395_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
1331 "use gnulib module getlogin_r for portability"); 1396 "use gnulib module getlogin_r for portability");
@@ -1338,13 +1403,13 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
1338# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1403# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1339# define getpagesize rpl_getpagesize 1404# define getpagesize rpl_getpagesize
1340# endif 1405# endif
1341_GL_FUNCDECL_RPL (getpagesize, int, (void)); 1406_GL_FUNCDECL_RPL (getpagesize, int, (void), );
1342_GL_CXXALIAS_RPL (getpagesize, int, (void)); 1407_GL_CXXALIAS_RPL (getpagesize, int, (void));
1343# else 1408# else
1344/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if 1409/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1345 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */ 1410 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1346# if defined __hpux 1411# if defined __hpux
1347_GL_FUNCDECL_SYS (getpagesize, int, (void)); 1412_GL_FUNCDECL_SYS (getpagesize, int, (void), );
1348# endif 1413# endif
1349# if !@HAVE_GETPAGESIZE@ 1414# if !@HAVE_GETPAGESIZE@
1350# if !defined getpagesize 1415# if !defined getpagesize
@@ -1395,7 +1460,7 @@ _GL_FUNCDECL_SYS (getpagesize, int, (void));
1395# define getpagesize() _gl_getpagesize () 1460# define getpagesize() _gl_getpagesize ()
1396# else 1461# else
1397# if !GNULIB_defined_getpagesize_function 1462# if !GNULIB_defined_getpagesize_function
1398_GL_UNISTD_INLINE int 1463_GL_GETPAGESIZE_INLINE int
1399getpagesize () 1464getpagesize ()
1400{ 1465{
1401 return _gl_getpagesize (); 1466 return _gl_getpagesize ();
@@ -1412,7 +1477,6 @@ _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
1412_GL_CXXALIASWARN (getpagesize); 1477_GL_CXXALIASWARN (getpagesize);
1413# endif 1478# endif
1414#elif defined GNULIB_POSIXCHECK 1479#elif defined GNULIB_POSIXCHECK
1415# undef getpagesize
1416# if HAVE_RAW_DECL_GETPAGESIZE 1480# if HAVE_RAW_DECL_GETPAGESIZE
1417_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " 1481_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1418 "use gnulib module getpagesize for portability"); 1482 "use gnulib module getpagesize for portability");
@@ -1431,19 +1495,18 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
1431# undef getpass 1495# undef getpass
1432# define getpass rpl_getpass 1496# define getpass rpl_getpass
1433# endif 1497# endif
1434_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt) 1498_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt),
1435 _GL_ARG_NONNULL ((1))); 1499 _GL_ARG_NONNULL ((1)));
1436_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt)); 1500_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1437# else 1501# else
1438# if !@HAVE_GETPASS@ 1502# if !@HAVE_GETPASS@
1439_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt) 1503_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt),
1440 _GL_ARG_NONNULL ((1))); 1504 _GL_ARG_NONNULL ((1)));
1441# endif 1505# endif
1442_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt)); 1506_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1443# endif 1507# endif
1444_GL_CXXALIASWARN (getpass); 1508_GL_CXXALIASWARN (getpass);
1445#elif defined GNULIB_POSIXCHECK 1509#elif defined GNULIB_POSIXCHECK
1446# undef getpass
1447# if HAVE_RAW_DECL_GETPASS 1510# if HAVE_RAW_DECL_GETPASS
1448_GL_WARN_ON_USE (getpass, "getpass is unportable - " 1511_GL_WARN_ON_USE (getpass, "getpass is unportable - "
1449 "use gnulib module getpass or getpass-gnu for portability"); 1512 "use gnulib module getpass or getpass-gnu for portability");
@@ -1469,15 +1532,23 @@ _GL_CXXALIASWARN (getpid);
1469 1532
1470 1533
1471#if @GNULIB_GETUSERSHELL@ 1534#if @GNULIB_GETUSERSHELL@
1535# if @REPLACE_GETUSERSHELL@
1472/* Return the next valid login shell on the system, or NULL when the end of 1536/* Return the next valid login shell on the system, or NULL when the end of
1473 the list has been reached. */ 1537 the list has been reached. */
1474# if !@HAVE_DECL_GETUSERSHELL@ 1538# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1475_GL_FUNCDECL_SYS (getusershell, char *, (void)); 1539# undef getusershell
1476# endif 1540# define getusershell rpl_getusershell
1541# endif
1542_GL_FUNCDECL_RPL (getusershell, char *, (void), );
1543_GL_CXXALIAS_RPL (getusershell, char *, (void));
1544# else
1545# if !@HAVE_DECL_GETUSERSHELL@
1546_GL_FUNCDECL_SYS (getusershell, char *, (void), );
1547# endif
1477_GL_CXXALIAS_SYS (getusershell, char *, (void)); 1548_GL_CXXALIAS_SYS (getusershell, char *, (void));
1549# endif
1478_GL_CXXALIASWARN (getusershell); 1550_GL_CXXALIASWARN (getusershell);
1479#elif defined GNULIB_POSIXCHECK 1551#elif defined GNULIB_POSIXCHECK
1480# undef getusershell
1481# if HAVE_RAW_DECL_GETUSERSHELL 1552# if HAVE_RAW_DECL_GETUSERSHELL
1482_GL_WARN_ON_USE (getusershell, "getusershell is unportable - " 1553_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1483 "use gnulib module getusershell for portability"); 1554 "use gnulib module getusershell for portability");
@@ -1486,13 +1557,21 @@ _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
1486 1557
1487#if @GNULIB_GETUSERSHELL@ 1558#if @GNULIB_GETUSERSHELL@
1488/* Rewind to pointer that is advanced at each getusershell() call. */ 1559/* Rewind to pointer that is advanced at each getusershell() call. */
1489# if !@HAVE_DECL_GETUSERSHELL@ 1560# if @REPLACE_GETUSERSHELL@
1490_GL_FUNCDECL_SYS (setusershell, void, (void)); 1561# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1491# endif 1562# undef setusershell
1563# define setusershell rpl_setusershell
1564# endif
1565_GL_FUNCDECL_RPL (setusershell, void, (void), );
1566_GL_CXXALIAS_RPL (setusershell, void, (void));
1567# else
1568# if !@HAVE_DECL_GETUSERSHELL@
1569_GL_FUNCDECL_SYS (setusershell, void, (void), );
1570# endif
1492_GL_CXXALIAS_SYS (setusershell, void, (void)); 1571_GL_CXXALIAS_SYS (setusershell, void, (void));
1572# endif
1493_GL_CXXALIASWARN (setusershell); 1573_GL_CXXALIASWARN (setusershell);
1494#elif defined GNULIB_POSIXCHECK 1574#elif defined GNULIB_POSIXCHECK
1495# undef setusershell
1496# if HAVE_RAW_DECL_SETUSERSHELL 1575# if HAVE_RAW_DECL_SETUSERSHELL
1497_GL_WARN_ON_USE (setusershell, "setusershell is unportable - " 1576_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1498 "use gnulib module getusershell for portability"); 1577 "use gnulib module getusershell for portability");
@@ -1502,13 +1581,21 @@ _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
1502#if @GNULIB_GETUSERSHELL@ 1581#if @GNULIB_GETUSERSHELL@
1503/* Free the pointer that is advanced at each getusershell() call and 1582/* Free the pointer that is advanced at each getusershell() call and
1504 associated resources. */ 1583 associated resources. */
1505# if !@HAVE_DECL_GETUSERSHELL@ 1584# if @REPLACE_GETUSERSHELL@
1506_GL_FUNCDECL_SYS (endusershell, void, (void)); 1585# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1507# endif 1586# undef endusershell
1587# define endusershell rpl_endusershell
1588# endif
1589_GL_FUNCDECL_RPL (endusershell, void, (void), );
1590_GL_CXXALIAS_RPL (endusershell, void, (void));
1591# else
1592# if !@HAVE_DECL_GETUSERSHELL@
1593_GL_FUNCDECL_SYS (endusershell, void, (void), );
1594# endif
1508_GL_CXXALIAS_SYS (endusershell, void, (void)); 1595_GL_CXXALIAS_SYS (endusershell, void, (void));
1596# endif
1509_GL_CXXALIASWARN (endusershell); 1597_GL_CXXALIASWARN (endusershell);
1510#elif defined GNULIB_POSIXCHECK 1598#elif defined GNULIB_POSIXCHECK
1511# undef endusershell
1512# if HAVE_RAW_DECL_ENDUSERSHELL 1599# if HAVE_RAW_DECL_ENDUSERSHELL
1513_GL_WARN_ON_USE (endusershell, "endusershell is unportable - " 1600_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1514 "use gnulib module getusershell for portability"); 1601 "use gnulib module getusershell for portability");
@@ -1519,12 +1606,11 @@ _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
1519#if @GNULIB_GROUP_MEMBER@ 1606#if @GNULIB_GROUP_MEMBER@
1520/* Determine whether group id is in calling user's group list. */ 1607/* Determine whether group id is in calling user's group list. */
1521# if !@HAVE_GROUP_MEMBER@ 1608# if !@HAVE_GROUP_MEMBER@
1522_GL_FUNCDECL_SYS (group_member, int, (gid_t gid)); 1609_GL_FUNCDECL_SYS (group_member, int, (gid_t gid), );
1523# endif 1610# endif
1524_GL_CXXALIAS_SYS (group_member, int, (gid_t gid)); 1611_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
1525_GL_CXXALIASWARN (group_member); 1612_GL_CXXALIASWARN (group_member);
1526#elif defined GNULIB_POSIXCHECK 1613#elif defined GNULIB_POSIXCHECK
1527# undef group_member
1528# if HAVE_RAW_DECL_GROUP_MEMBER 1614# if HAVE_RAW_DECL_GROUP_MEMBER
1529_GL_WARN_ON_USE (group_member, "group_member is unportable - " 1615_GL_WARN_ON_USE (group_member, "group_member is unportable - "
1530 "use gnulib module group-member for portability"); 1616 "use gnulib module group-member for portability");
@@ -1539,7 +1625,7 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1539# define isatty rpl_isatty 1625# define isatty rpl_isatty
1540# endif 1626# endif
1541# define GNULIB_defined_isatty 1 1627# define GNULIB_defined_isatty 1
1542_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1628_GL_FUNCDECL_RPL (isatty, int, (int fd), );
1543_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1629_GL_CXXALIAS_RPL (isatty, int, (int fd));
1544# elif defined _WIN32 && !defined __CYGWIN__ 1630# elif defined _WIN32 && !defined __CYGWIN__
1545# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1631# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1552,7 +1638,6 @@ _GL_CXXALIAS_SYS (isatty, int, (int fd));
1552# endif 1638# endif
1553_GL_CXXALIASWARN (isatty); 1639_GL_CXXALIASWARN (isatty);
1554#elif defined GNULIB_POSIXCHECK 1640#elif defined GNULIB_POSIXCHECK
1555# undef isatty
1556# if HAVE_RAW_DECL_ISATTY 1641# if HAVE_RAW_DECL_ISATTY
1557_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1642_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1558 "use gnulib module isatty for portability"); 1643 "use gnulib module isatty for portability");
@@ -1585,19 +1670,18 @@ _GL_CXXALIASWARN (isatty);
1585# undef lchown 1670# undef lchown
1586# define lchown rpl_lchown 1671# define lchown rpl_lchown
1587# endif 1672# endif
1588_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) 1673_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group),
1589 _GL_ARG_NONNULL ((1))); 1674 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1590_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); 1675_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
1591# else 1676# else
1592# if !@HAVE_LCHOWN@ 1677# if !@HAVE_LCHOWN@
1593_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) 1678_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group),
1594 _GL_ARG_NONNULL ((1))); 1679 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1595# endif 1680# endif
1596_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); 1681_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
1597# endif 1682# endif
1598_GL_CXXALIASWARN (lchown); 1683_GL_CXXALIASWARN (lchown);
1599#elif defined GNULIB_POSIXCHECK 1684#elif defined GNULIB_POSIXCHECK
1600# undef lchown
1601# if HAVE_RAW_DECL_LCHOWN 1685# if HAVE_RAW_DECL_LCHOWN
1602_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " 1686_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1603 "use gnulib module lchown for portability"); 1687 "use gnulib module lchown for portability");
@@ -1614,19 +1698,18 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1614# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1698# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1615# define link rpl_link 1699# define link rpl_link
1616# endif 1700# endif
1617_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) 1701_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2),
1618 _GL_ARG_NONNULL ((1, 2))); 1702 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1619_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); 1703_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1620# else 1704# else
1621# if !@HAVE_LINK@ 1705# if !@HAVE_LINK@
1622_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) 1706_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2),
1623 _GL_ARG_NONNULL ((1, 2))); 1707 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1624# endif 1708# endif
1625_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); 1709_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1626# endif 1710# endif
1627_GL_CXXALIASWARN (link); 1711_GL_CXXALIASWARN (link);
1628#elif defined GNULIB_POSIXCHECK 1712#elif defined GNULIB_POSIXCHECK
1629# undef link
1630# if HAVE_RAW_DECL_LINK 1713# if HAVE_RAW_DECL_LINK
1631_GL_WARN_ON_USE (link, "link is unportable - " 1714_GL_WARN_ON_USE (link, "link is unportable - "
1632 "use gnulib module link for portability"); 1715 "use gnulib module link for portability");
@@ -1645,8 +1728,8 @@ _GL_WARN_ON_USE (link, "link is unportable - "
1645# endif 1728# endif
1646_GL_FUNCDECL_RPL (linkat, int, 1729_GL_FUNCDECL_RPL (linkat, int,
1647 (int fd1, const char *path1, int fd2, const char *path2, 1730 (int fd1, const char *path1, int fd2, const char *path2,
1648 int flag) 1731 int flag),
1649 _GL_ARG_NONNULL ((2, 4))); 1732 _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD);
1650_GL_CXXALIAS_RPL (linkat, int, 1733_GL_CXXALIAS_RPL (linkat, int,
1651 (int fd1, const char *path1, int fd2, const char *path2, 1734 (int fd1, const char *path1, int fd2, const char *path2,
1652 int flag)); 1735 int flag));
@@ -1654,16 +1737,17 @@ _GL_CXXALIAS_RPL (linkat, int,
1654# if !@HAVE_LINKAT@ 1737# if !@HAVE_LINKAT@
1655_GL_FUNCDECL_SYS (linkat, int, 1738_GL_FUNCDECL_SYS (linkat, int,
1656 (int fd1, const char *path1, int fd2, const char *path2, 1739 (int fd1, const char *path1, int fd2, const char *path2,
1657 int flag) 1740 int flag),
1658 _GL_ARG_NONNULL ((2, 4))); 1741 _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD);
1659# endif 1742# endif
1660_GL_CXXALIAS_SYS (linkat, int, 1743_GL_CXXALIAS_SYS (linkat, int,
1661 (int fd1, const char *path1, int fd2, const char *path2, 1744 (int fd1, const char *path1, int fd2, const char *path2,
1662 int flag)); 1745 int flag));
1663# endif 1746# endif
1747# if __GLIBC__ >= 2
1664_GL_CXXALIASWARN (linkat); 1748_GL_CXXALIASWARN (linkat);
1749# endif
1665#elif defined GNULIB_POSIXCHECK 1750#elif defined GNULIB_POSIXCHECK
1666# undef linkat
1667# if HAVE_RAW_DECL_LINKAT 1751# if HAVE_RAW_DECL_LINKAT
1668_GL_WARN_ON_USE (linkat, "linkat is unportable - " 1752_GL_WARN_ON_USE (linkat, "linkat is unportable - "
1669 "use gnulib module linkat for portability"); 1753 "use gnulib module linkat for portability");
@@ -1680,7 +1764,7 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1680# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1764# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1681# define lseek rpl_lseek 1765# define lseek rpl_lseek
1682# endif 1766# endif
1683_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1767_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence), );
1684_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1768_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1685# elif defined _WIN32 && !defined __CYGWIN__ 1769# elif defined _WIN32 && !defined __CYGWIN__
1686# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1770# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1693,7 +1777,6 @@ _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1693# endif 1777# endif
1694_GL_CXXALIASWARN (lseek); 1778_GL_CXXALIASWARN (lseek);
1695#elif defined GNULIB_POSIXCHECK 1779#elif defined GNULIB_POSIXCHECK
1696# undef lseek
1697# if HAVE_RAW_DECL_LSEEK 1780# if HAVE_RAW_DECL_LSEEK
1698_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1781_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1699 "systems - use gnulib module lseek for portability"); 1782 "systems - use gnulib module lseek for portability");
@@ -1720,12 +1803,12 @@ _GL_CXXALIASWARN (lseek);
1720 Store the read-end as fd[0] and the write-end as fd[1]. 1803 Store the read-end as fd[0] and the write-end as fd[1].
1721 Return 0 upon success, or -1 with errno set upon failure. */ 1804 Return 0 upon success, or -1 with errno set upon failure. */
1722# if !@HAVE_PIPE@ 1805# if !@HAVE_PIPE@
1723_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); 1806_GL_FUNCDECL_SYS (pipe, int, (int fd[2]),
1807 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1724# endif 1808# endif
1725_GL_CXXALIAS_SYS (pipe, int, (int fd[2])); 1809_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1726_GL_CXXALIASWARN (pipe); 1810_GL_CXXALIASWARN (pipe);
1727#elif defined GNULIB_POSIXCHECK 1811#elif defined GNULIB_POSIXCHECK
1728# undef pipe
1729# if HAVE_RAW_DECL_PIPE 1812# if HAVE_RAW_DECL_PIPE
1730_GL_WARN_ON_USE (pipe, "pipe is unportable - " 1813_GL_WARN_ON_USE (pipe, "pipe is unportable - "
1731 "use gnulib module pipe-posix for portability"); 1814 "use gnulib module pipe-posix for portability");
@@ -1742,19 +1825,23 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1742 Return 0 upon success, or -1 with errno set upon failure. 1825 Return 0 upon success, or -1 with errno set upon failure.
1743 See also the Linux man page at 1826 See also the Linux man page at
1744 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ 1827 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1745# if @HAVE_PIPE2@ 1828# if @REPLACE_PIPE2@
1746# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1829# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1830# undef pipe2
1747# define pipe2 rpl_pipe2 1831# define pipe2 rpl_pipe2
1748# endif 1832# endif
1749_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); 1833_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags),
1834 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1750_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); 1835_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1751# else 1836# else
1752_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); 1837_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags),
1838 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1753_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); 1839_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
1754# endif 1840# endif
1841# if __GLIBC__ >= 2
1755_GL_CXXALIASWARN (pipe2); 1842_GL_CXXALIASWARN (pipe2);
1843# endif
1756#elif defined GNULIB_POSIXCHECK 1844#elif defined GNULIB_POSIXCHECK
1757# undef pipe2
1758# if HAVE_RAW_DECL_PIPE2 1845# if HAVE_RAW_DECL_PIPE2
1759_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " 1846_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1760 "use gnulib module pipe2 for portability"); 1847 "use gnulib module pipe2 for portability");
@@ -1774,22 +1861,23 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1774# define pread rpl_pread 1861# define pread rpl_pread
1775# endif 1862# endif
1776_GL_FUNCDECL_RPL (pread, ssize_t, 1863_GL_FUNCDECL_RPL (pread, ssize_t,
1777 (int fd, void *buf, size_t bufsize, off_t offset) 1864 (int fd, void *buf, size_t bufsize, off_t offset),
1778 _GL_ARG_NONNULL ((2))); 1865 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1779_GL_CXXALIAS_RPL (pread, ssize_t, 1866_GL_CXXALIAS_RPL (pread, ssize_t,
1780 (int fd, void *buf, size_t bufsize, off_t offset)); 1867 (int fd, void *buf, size_t bufsize, off_t offset));
1781# else 1868# else
1782# if !@HAVE_PREAD@ 1869# if !@HAVE_PREAD@
1783_GL_FUNCDECL_SYS (pread, ssize_t, 1870_GL_FUNCDECL_SYS (pread, ssize_t,
1784 (int fd, void *buf, size_t bufsize, off_t offset) 1871 (int fd, void *buf, size_t bufsize, off_t offset),
1785 _GL_ARG_NONNULL ((2))); 1872 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1786# endif 1873# endif
1787_GL_CXXALIAS_SYS (pread, ssize_t, 1874_GL_CXXALIAS_SYS (pread, ssize_t,
1788 (int fd, void *buf, size_t bufsize, off_t offset)); 1875 (int fd, void *buf, size_t bufsize, off_t offset));
1789# endif 1876# endif
1877# if __GLIBC__ >= 2
1790_GL_CXXALIASWARN (pread); 1878_GL_CXXALIASWARN (pread);
1879# endif
1791#elif defined GNULIB_POSIXCHECK 1880#elif defined GNULIB_POSIXCHECK
1792# undef pread
1793# if HAVE_RAW_DECL_PREAD 1881# if HAVE_RAW_DECL_PREAD
1794_GL_WARN_ON_USE (pread, "pread is unportable - " 1882_GL_WARN_ON_USE (pread, "pread is unportable - "
1795 "use gnulib module pread for portability"); 1883 "use gnulib module pread for portability");
@@ -1809,22 +1897,23 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1809# define pwrite rpl_pwrite 1897# define pwrite rpl_pwrite
1810# endif 1898# endif
1811_GL_FUNCDECL_RPL (pwrite, ssize_t, 1899_GL_FUNCDECL_RPL (pwrite, ssize_t,
1812 (int fd, const void *buf, size_t bufsize, off_t offset) 1900 (int fd, const void *buf, size_t bufsize, off_t offset),
1813 _GL_ARG_NONNULL ((2))); 1901 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1814_GL_CXXALIAS_RPL (pwrite, ssize_t, 1902_GL_CXXALIAS_RPL (pwrite, ssize_t,
1815 (int fd, const void *buf, size_t bufsize, off_t offset)); 1903 (int fd, const void *buf, size_t bufsize, off_t offset));
1816# else 1904# else
1817# if !@HAVE_PWRITE@ 1905# if !@HAVE_PWRITE@
1818_GL_FUNCDECL_SYS (pwrite, ssize_t, 1906_GL_FUNCDECL_SYS (pwrite, ssize_t,
1819 (int fd, const void *buf, size_t bufsize, off_t offset) 1907 (int fd, const void *buf, size_t bufsize, off_t offset),
1820 _GL_ARG_NONNULL ((2))); 1908 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1821# endif 1909# endif
1822_GL_CXXALIAS_SYS (pwrite, ssize_t, 1910_GL_CXXALIAS_SYS (pwrite, ssize_t,
1823 (int fd, const void *buf, size_t bufsize, off_t offset)); 1911 (int fd, const void *buf, size_t bufsize, off_t offset));
1824# endif 1912# endif
1913# if __GLIBC__ >= 2
1825_GL_CXXALIASWARN (pwrite); 1914_GL_CXXALIASWARN (pwrite);
1915# endif
1826#elif defined GNULIB_POSIXCHECK 1916#elif defined GNULIB_POSIXCHECK
1827# undef pwrite
1828# if HAVE_RAW_DECL_PWRITE 1917# if HAVE_RAW_DECL_PWRITE
1829_GL_WARN_ON_USE (pwrite, "pwrite is unportable - " 1918_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1830 "use gnulib module pwrite for portability"); 1919 "use gnulib module pwrite for portability");
@@ -1841,8 +1930,9 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1841# undef read 1930# undef read
1842# define read rpl_read 1931# define read rpl_read
1843# endif 1932# endif
1844_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1933
1845 _GL_ARG_NONNULL ((2))); 1934_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count),
1935 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
1846_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1936_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1847# elif defined _WIN32 && !defined __CYGWIN__ 1937# elif defined _WIN32 && !defined __CYGWIN__
1848# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1938# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1863,11 +1953,7 @@ _GL_CXXALIASWARN (read);
1863# undef read 1953# undef read
1864# define read _read 1954# define read _read
1865# endif 1955# endif
1866# ifdef __MINGW32__ 1956_GL_CXXALIAS_MDA_CAST (read, ssize_t, (int fd, void *buf, unsigned int count));
1867_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1868# else
1869_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1870# endif
1871# else 1957# else
1872_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count)); 1958_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1873# endif 1959# endif
@@ -1887,8 +1973,8 @@ _GL_CXXALIASWARN (read);
1887# endif 1973# endif
1888_GL_FUNCDECL_RPL (readlink, ssize_t, 1974_GL_FUNCDECL_RPL (readlink, ssize_t,
1889 (const char *restrict file, 1975 (const char *restrict file,
1890 char *restrict buf, size_t bufsize) 1976 char *restrict buf, size_t bufsize),
1891 _GL_ARG_NONNULL ((1, 2))); 1977 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1892_GL_CXXALIAS_RPL (readlink, ssize_t, 1978_GL_CXXALIAS_RPL (readlink, ssize_t,
1893 (const char *restrict file, 1979 (const char *restrict file,
1894 char *restrict buf, size_t bufsize)); 1980 char *restrict buf, size_t bufsize));
@@ -1896,8 +1982,8 @@ _GL_CXXALIAS_RPL (readlink, ssize_t,
1896# if !@HAVE_READLINK@ 1982# if !@HAVE_READLINK@
1897_GL_FUNCDECL_SYS (readlink, ssize_t, 1983_GL_FUNCDECL_SYS (readlink, ssize_t,
1898 (const char *restrict file, 1984 (const char *restrict file,
1899 char *restrict buf, size_t bufsize) 1985 char *restrict buf, size_t bufsize),
1900 _GL_ARG_NONNULL ((1, 2))); 1986 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
1901# endif 1987# endif
1902_GL_CXXALIAS_SYS (readlink, ssize_t, 1988_GL_CXXALIAS_SYS (readlink, ssize_t,
1903 (const char *restrict file, 1989 (const char *restrict file,
@@ -1905,7 +1991,6 @@ _GL_CXXALIAS_SYS (readlink, ssize_t,
1905# endif 1991# endif
1906_GL_CXXALIASWARN (readlink); 1992_GL_CXXALIASWARN (readlink);
1907#elif defined GNULIB_POSIXCHECK 1993#elif defined GNULIB_POSIXCHECK
1908# undef readlink
1909# if HAVE_RAW_DECL_READLINK 1994# if HAVE_RAW_DECL_READLINK
1910_GL_WARN_ON_USE (readlink, "readlink is unportable - " 1995_GL_WARN_ON_USE (readlink, "readlink is unportable - "
1911 "use gnulib module readlink for portability"); 1996 "use gnulib module readlink for portability");
@@ -1920,8 +2005,8 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1920# endif 2005# endif
1921_GL_FUNCDECL_RPL (readlinkat, ssize_t, 2006_GL_FUNCDECL_RPL (readlinkat, ssize_t,
1922 (int fd, char const *restrict file, 2007 (int fd, char const *restrict file,
1923 char *restrict buf, size_t len) 2008 char *restrict buf, size_t len),
1924 _GL_ARG_NONNULL ((2, 3))); 2009 _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
1925_GL_CXXALIAS_RPL (readlinkat, ssize_t, 2010_GL_CXXALIAS_RPL (readlinkat, ssize_t,
1926 (int fd, char const *restrict file, 2011 (int fd, char const *restrict file,
1927 char *restrict buf, size_t len)); 2012 char *restrict buf, size_t len));
@@ -1929,16 +2014,17 @@ _GL_CXXALIAS_RPL (readlinkat, ssize_t,
1929# if !@HAVE_READLINKAT@ 2014# if !@HAVE_READLINKAT@
1930_GL_FUNCDECL_SYS (readlinkat, ssize_t, 2015_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1931 (int fd, char const *restrict file, 2016 (int fd, char const *restrict file,
1932 char *restrict buf, size_t len) 2017 char *restrict buf, size_t len),
1933 _GL_ARG_NONNULL ((2, 3))); 2018 _GL_ARG_NONNULL ((2, 3)) _GL_ATTRIBUTE_NODISCARD);
1934# endif 2019# endif
1935_GL_CXXALIAS_SYS (readlinkat, ssize_t, 2020_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1936 (int fd, char const *restrict file, 2021 (int fd, char const *restrict file,
1937 char *restrict buf, size_t len)); 2022 char *restrict buf, size_t len));
1938# endif 2023# endif
2024# if __GLIBC__ >= 2
1939_GL_CXXALIASWARN (readlinkat); 2025_GL_CXXALIASWARN (readlinkat);
2026# endif
1940#elif defined GNULIB_POSIXCHECK 2027#elif defined GNULIB_POSIXCHECK
1941# undef readlinkat
1942# if HAVE_RAW_DECL_READLINKAT 2028# if HAVE_RAW_DECL_READLINKAT
1943_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " 2029_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1944 "use gnulib module readlinkat for portability"); 2030 "use gnulib module readlinkat for portability");
@@ -1952,7 +2038,7 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1952# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2038# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1953# define rmdir rpl_rmdir 2039# define rmdir rpl_rmdir
1954# endif 2040# endif
1955_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 2041_GL_FUNCDECL_RPL (rmdir, int, (char const *name), _GL_ARG_NONNULL ((1)));
1956_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 2042_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1957# elif defined _WIN32 && !defined __CYGWIN__ 2043# elif defined _WIN32 && !defined __CYGWIN__
1958# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2044# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1965,7 +2051,6 @@ _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1965# endif 2051# endif
1966_GL_CXXALIASWARN (rmdir); 2052_GL_CXXALIASWARN (rmdir);
1967#elif defined GNULIB_POSIXCHECK 2053#elif defined GNULIB_POSIXCHECK
1968# undef rmdir
1969# if HAVE_RAW_DECL_RMDIR 2054# if HAVE_RAW_DECL_RMDIR
1970_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 2055_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1971 "use gnulib module rmdir for portability"); 2056 "use gnulib module rmdir for portability");
@@ -1996,17 +2081,32 @@ _GL_CXXALIASWARN (rmdir);
1996 2081
1997 Platforms with no ability to set the hostname return -1 and set 2082 Platforms with no ability to set the hostname return -1 and set
1998 errno = ENOSYS. */ 2083 errno = ENOSYS. */
1999# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ 2084# if @REPLACE_SETHOSTNAME@
2000_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) 2085# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2001 _GL_ARG_NONNULL ((1))); 2086# undef sethostname
2087# define sethostname rpl_sethostname
2088# endif
2089_GL_FUNCDECL_RPL (sethostname, int,
2090 (const char *name, size_t len),
2091 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2092_GL_CXXALIAS_RPL (sethostname, int,
2093 (const char *name, size_t len));
2094# else
2095# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
2096_GL_FUNCDECL_SYS (sethostname, int,
2097 (const char *name, size_t len),
2098 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2099# endif
2100/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, and FreeBSD 6.4
2101 the second parameter is int. On Solaris 11 2011-10, the first parameter is
2102 not const. */
2103_GL_CXXALIAS_SYS_CAST (sethostname, int,
2104 (const char *name, size_t len));
2002# endif 2105# endif
2003/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 2106# if __GLIBC__ >= 2
2004 and FreeBSD 6.4 the second parameter is int. On Solaris 11
2005 2011-10, the first parameter is not const. */
2006_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
2007_GL_CXXALIASWARN (sethostname); 2107_GL_CXXALIASWARN (sethostname);
2108# endif
2008#elif defined GNULIB_POSIXCHECK 2109#elif defined GNULIB_POSIXCHECK
2009# undef sethostname
2010# if HAVE_RAW_DECL_SETHOSTNAME 2110# if HAVE_RAW_DECL_SETHOSTNAME
2011_GL_WARN_ON_USE (sethostname, "sethostname is unportable - " 2111_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
2012 "use gnulib module sethostname for portability"); 2112 "use gnulib module sethostname for portability");
@@ -2024,17 +2124,16 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
2024# undef sleep 2124# undef sleep
2025# define sleep rpl_sleep 2125# define sleep rpl_sleep
2026# endif 2126# endif
2027_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n)); 2127_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n), );
2028_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n)); 2128_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
2029# else 2129# else
2030# if !@HAVE_SLEEP@ 2130# if !@HAVE_SLEEP@
2031_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n)); 2131_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n), );
2032# endif 2132# endif
2033_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n)); 2133_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
2034# endif 2134# endif
2035_GL_CXXALIASWARN (sleep); 2135_GL_CXXALIASWARN (sleep);
2036#elif defined GNULIB_POSIXCHECK 2136#elif defined GNULIB_POSIXCHECK
2037# undef sleep
2038# if HAVE_RAW_DECL_SLEEP 2137# if HAVE_RAW_DECL_SLEEP
2039_GL_WARN_ON_USE (sleep, "sleep is unportable - " 2138_GL_WARN_ON_USE (sleep, "sleep is unportable - "
2040 "use gnulib module sleep for portability"); 2139 "use gnulib module sleep for portability");
@@ -2073,19 +2172,22 @@ _GL_CXXALIASWARN (swab);
2073# undef symlink 2172# undef symlink
2074# define symlink rpl_symlink 2173# define symlink rpl_symlink
2075# endif 2174# endif
2076_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) 2175_GL_FUNCDECL_RPL (symlink, int,
2077 _GL_ARG_NONNULL ((1, 2))); 2176 (char const *contents, char const *file),
2078_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); 2177 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2178_GL_CXXALIAS_RPL (symlink, int,
2179 (char const *contents, char const *file));
2079# else 2180# else
2080# if !@HAVE_SYMLINK@ 2181# if !@HAVE_SYMLINK@
2081_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) 2182_GL_FUNCDECL_SYS (symlink, int,
2082 _GL_ARG_NONNULL ((1, 2))); 2183 (char const *contents, char const *file),
2184 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_NODISCARD);
2083# endif 2185# endif
2084_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); 2186_GL_CXXALIAS_SYS (symlink, int,
2187 (char const *contents, char const *file));
2085# endif 2188# endif
2086_GL_CXXALIASWARN (symlink); 2189_GL_CXXALIASWARN (symlink);
2087#elif defined GNULIB_POSIXCHECK 2190#elif defined GNULIB_POSIXCHECK
2088# undef symlink
2089# if HAVE_RAW_DECL_SYMLINK 2191# if HAVE_RAW_DECL_SYMLINK
2090_GL_WARN_ON_USE (symlink, "symlink is not portable - " 2192_GL_WARN_ON_USE (symlink, "symlink is not portable - "
2091 "use gnulib module symlink for portability"); 2193 "use gnulib module symlink for portability");
@@ -2100,22 +2202,23 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
2100# define symlinkat rpl_symlinkat 2202# define symlinkat rpl_symlinkat
2101# endif 2203# endif
2102_GL_FUNCDECL_RPL (symlinkat, int, 2204_GL_FUNCDECL_RPL (symlinkat, int,
2103 (char const *contents, int fd, char const *file) 2205 (char const *contents, int fd, char const *file),
2104 _GL_ARG_NONNULL ((1, 3))); 2206 _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
2105_GL_CXXALIAS_RPL (symlinkat, int, 2207_GL_CXXALIAS_RPL (symlinkat, int,
2106 (char const *contents, int fd, char const *file)); 2208 (char const *contents, int fd, char const *file));
2107# else 2209# else
2108# if !@HAVE_SYMLINKAT@ 2210# if !@HAVE_SYMLINKAT@
2109_GL_FUNCDECL_SYS (symlinkat, int, 2211_GL_FUNCDECL_SYS (symlinkat, int,
2110 (char const *contents, int fd, char const *file) 2212 (char const *contents, int fd, char const *file),
2111 _GL_ARG_NONNULL ((1, 3))); 2213 _GL_ARG_NONNULL ((1, 3)) _GL_ATTRIBUTE_NODISCARD);
2112# endif 2214# endif
2113_GL_CXXALIAS_SYS (symlinkat, int, 2215_GL_CXXALIAS_SYS (symlinkat, int,
2114 (char const *contents, int fd, char const *file)); 2216 (char const *contents, int fd, char const *file));
2115# endif 2217# endif
2218# if __GLIBC__ >= 2
2116_GL_CXXALIASWARN (symlinkat); 2219_GL_CXXALIASWARN (symlinkat);
2220# endif
2117#elif defined GNULIB_POSIXCHECK 2221#elif defined GNULIB_POSIXCHECK
2118# undef symlinkat
2119# if HAVE_RAW_DECL_SYMLINKAT 2222# if HAVE_RAW_DECL_SYMLINKAT
2120_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " 2223_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
2121 "use gnulib module symlinkat for portability"); 2224 "use gnulib module symlinkat for portability");
@@ -2133,19 +2236,20 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
2133# undef truncate 2236# undef truncate
2134# define truncate rpl_truncate 2237# define truncate rpl_truncate
2135# endif 2238# endif
2136_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length) 2239_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length),
2137 _GL_ARG_NONNULL ((1))); 2240 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2138_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length)); 2241_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2139# else 2242# else
2140# if !@HAVE_DECL_TRUNCATE@ 2243# if !@HAVE_DECL_TRUNCATE@
2141_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length) 2244_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length),
2142 _GL_ARG_NONNULL ((1))); 2245 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
2143# endif 2246# endif
2144_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length)); 2247_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2145# endif 2248# endif
2249# if __GLIBC__ >= 2
2146_GL_CXXALIASWARN (truncate); 2250_GL_CXXALIASWARN (truncate);
2251# endif
2147#elif defined GNULIB_POSIXCHECK 2252#elif defined GNULIB_POSIXCHECK
2148# undef truncate
2149# if HAVE_RAW_DECL_TRUNCATE 2253# if HAVE_RAW_DECL_TRUNCATE
2150_GL_WARN_ON_USE (truncate, "truncate is unportable - " 2254_GL_WARN_ON_USE (truncate, "truncate is unportable - "
2151 "use gnulib module truncate for portability"); 2255 "use gnulib module truncate for portability");
@@ -2162,20 +2266,23 @@ _GL_WARN_ON_USE (truncate, "truncate is unportable - "
2162# define ttyname_r rpl_ttyname_r 2266# define ttyname_r rpl_ttyname_r
2163# endif 2267# endif
2164_GL_FUNCDECL_RPL (ttyname_r, int, 2268_GL_FUNCDECL_RPL (ttyname_r, int,
2165 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); 2269 (int fd, char *buf, size_t buflen),
2270 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
2166_GL_CXXALIAS_RPL (ttyname_r, int, 2271_GL_CXXALIAS_RPL (ttyname_r, int,
2167 (int fd, char *buf, size_t buflen)); 2272 (int fd, char *buf, size_t buflen));
2168# else 2273# else
2169# if !@HAVE_DECL_TTYNAME_R@ 2274# if !@HAVE_DECL_TTYNAME_R@
2170_GL_FUNCDECL_SYS (ttyname_r, int, 2275_GL_FUNCDECL_SYS (ttyname_r, int,
2171 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); 2276 (int fd, char *buf, size_t buflen),
2277 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
2172# endif 2278# endif
2173_GL_CXXALIAS_SYS (ttyname_r, int, 2279_GL_CXXALIAS_SYS (ttyname_r, int,
2174 (int fd, char *buf, size_t buflen)); 2280 (int fd, char *buf, size_t buflen));
2175# endif 2281# endif
2282# if __GLIBC__ >= 2
2176_GL_CXXALIASWARN (ttyname_r); 2283_GL_CXXALIASWARN (ttyname_r);
2284# endif
2177#elif defined GNULIB_POSIXCHECK 2285#elif defined GNULIB_POSIXCHECK
2178# undef ttyname_r
2179# if HAVE_RAW_DECL_TTYNAME_R 2286# if HAVE_RAW_DECL_TTYNAME_R
2180_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " 2287_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
2181 "use gnulib module ttyname_r for portability"); 2288 "use gnulib module ttyname_r for portability");
@@ -2189,7 +2296,7 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
2189# undef unlink 2296# undef unlink
2190# define unlink rpl_unlink 2297# define unlink rpl_unlink
2191# endif 2298# endif
2192_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 2299_GL_FUNCDECL_RPL (unlink, int, (char const *file), _GL_ARG_NONNULL ((1)));
2193_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 2300_GL_CXXALIAS_RPL (unlink, int, (char const *file));
2194# elif defined _WIN32 && !defined __CYGWIN__ 2301# elif defined _WIN32 && !defined __CYGWIN__
2195# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2302# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -2202,7 +2309,6 @@ _GL_CXXALIAS_SYS (unlink, int, (char const *file));
2202# endif 2309# endif
2203_GL_CXXALIASWARN (unlink); 2310_GL_CXXALIASWARN (unlink);
2204#elif defined GNULIB_POSIXCHECK 2311#elif defined GNULIB_POSIXCHECK
2205# undef unlink
2206# if HAVE_RAW_DECL_UNLINK 2312# if HAVE_RAW_DECL_UNLINK
2207_GL_WARN_ON_USE (unlink, "unlink is not portable - " 2313_GL_WARN_ON_USE (unlink, "unlink is not portable - "
2208 "use gnulib module unlink for portability"); 2314 "use gnulib module unlink for portability");
@@ -2230,19 +2336,18 @@ _GL_CXXALIASWARN (unlink);
2230# undef unlinkat 2336# undef unlinkat
2231# define unlinkat rpl_unlinkat 2337# define unlinkat rpl_unlinkat
2232# endif 2338# endif
2233_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) 2339_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag),
2234 _GL_ARG_NONNULL ((2))); 2340 _GL_ARG_NONNULL ((2)));
2235_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); 2341_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
2236# else 2342# else
2237# if !@HAVE_UNLINKAT@ 2343# if !@HAVE_UNLINKAT@
2238_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) 2344_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag),
2239 _GL_ARG_NONNULL ((2))); 2345 _GL_ARG_NONNULL ((2)));
2240# endif 2346# endif
2241_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); 2347_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
2242# endif 2348# endif
2243_GL_CXXALIASWARN (unlinkat); 2349_GL_CXXALIASWARN (unlinkat);
2244#elif defined GNULIB_POSIXCHECK 2350#elif defined GNULIB_POSIXCHECK
2245# undef unlinkat
2246# if HAVE_RAW_DECL_UNLINKAT 2351# if HAVE_RAW_DECL_UNLINKAT
2247_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " 2352_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2248 "use gnulib module unlinkat for portability"); 2353 "use gnulib module unlinkat for portability");
@@ -2253,18 +2358,18 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
2253#if @GNULIB_USLEEP@ 2358#if @GNULIB_USLEEP@
2254/* Pause the execution of the current thread for N microseconds. 2359/* Pause the execution of the current thread for N microseconds.
2255 Returns 0 on completion, or -1 on range error. 2360 Returns 0 on completion, or -1 on range error.
2256 See the POSIX:2001 specification 2361 See the POSIX.1-2004 specification
2257 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */ 2362 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
2258# if @REPLACE_USLEEP@ 2363# if @REPLACE_USLEEP@
2259# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2364# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2260# undef usleep 2365# undef usleep
2261# define usleep rpl_usleep 2366# define usleep rpl_usleep
2262# endif 2367# endif
2263_GL_FUNCDECL_RPL (usleep, int, (useconds_t n)); 2368_GL_FUNCDECL_RPL (usleep, int, (useconds_t n), );
2264_GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); 2369_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
2265# else 2370# else
2266# if !@HAVE_USLEEP@ 2371# if !@HAVE_USLEEP@
2267_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); 2372_GL_FUNCDECL_SYS (usleep, int, (useconds_t n), );
2268# endif 2373# endif
2269/* Need to cast, because on Haiku, the first parameter is 2374/* Need to cast, because on Haiku, the first parameter is
2270 unsigned int n. */ 2375 unsigned int n. */
@@ -2272,7 +2377,6 @@ _GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
2272# endif 2377# endif
2273_GL_CXXALIASWARN (usleep); 2378_GL_CXXALIASWARN (usleep);
2274#elif defined GNULIB_POSIXCHECK 2379#elif defined GNULIB_POSIXCHECK
2275# undef usleep
2276# if HAVE_RAW_DECL_USLEEP 2380# if HAVE_RAW_DECL_USLEEP
2277_GL_WARN_ON_USE (usleep, "usleep is unportable - " 2381_GL_WARN_ON_USE (usleep, "usleep is unportable - "
2278 "use gnulib module usleep for portability"); 2382 "use gnulib module usleep for portability");
@@ -2289,17 +2393,21 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
2289# undef write 2393# undef write
2290# define write rpl_write 2394# define write rpl_write
2291# endif 2395# endif
2292_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 2396_GL_FUNCDECL_RPL (write, ssize_t,
2293 _GL_ARG_NONNULL ((2))); 2397 (int fd, const void *buf, size_t count),
2294_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 2398 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
2399_GL_CXXALIAS_RPL (write, ssize_t,
2400 (int fd, const void *buf, size_t count));
2295# elif defined _WIN32 && !defined __CYGWIN__ 2401# elif defined _WIN32 && !defined __CYGWIN__
2296# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2402# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2297# undef write 2403# undef write
2298# define write _write 2404# define write _write
2299# endif 2405# endif
2300_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count)); 2406_GL_CXXALIAS_MDA (write, ssize_t,
2407 (int fd, const void *buf, size_t count));
2301# else 2408# else
2302_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); 2409_GL_CXXALIAS_SYS (write, ssize_t,
2410 (int fd, const void *buf, size_t count));
2303# endif 2411# endif
2304_GL_CXXALIASWARN (write); 2412_GL_CXXALIASWARN (write);
2305#elif @GNULIB_MDA_WRITE@ 2413#elif @GNULIB_MDA_WRITE@
@@ -2311,19 +2419,29 @@ _GL_CXXALIASWARN (write);
2311# undef write 2419# undef write
2312# define write _write 2420# define write _write
2313# endif 2421# endif
2314# ifdef __MINGW32__ 2422_GL_CXXALIAS_MDA_CAST (write, ssize_t,
2315_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count)); 2423 (int fd, const void *buf, unsigned int count));
2316# else
2317_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2318# endif
2319# else 2424# else
2320_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); 2425_GL_CXXALIAS_SYS (write, ssize_t,
2426 (int fd, const void *buf, size_t count));
2321# endif 2427# endif
2322_GL_CXXALIASWARN (write); 2428_GL_CXXALIASWARN (write);
2323#endif 2429#endif
2324 2430
2325_GL_INLINE_HEADER_END 2431_GL_INLINE_HEADER_END
2326 2432
2433
2434/* Includes that provide only macros that don't need to be overridden.
2435 (Includes that are needed for type definitions and function declarations
2436 have their place above, before the function overrides.) */
2437
2438/* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41
2439 do not define O_CLOEXEC in <unistd.h>. */
2440#if ! defined O_CLOEXEC
2441# include <fcntl.h>
2442#endif
2443
2444
2327#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2445#endif /* _@GUARD_PREFIX@_UNISTD_H */
2328#endif /* _GL_INCLUDING_UNISTD_H */ 2446#endif /* _GL_INCLUDING_UNISTD_H */
2329#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2447#endif /* _@GUARD_PREFIX@_UNISTD_H */
diff --git a/gl/unitypes.in.h b/gl/unitypes.in.h
new file mode 100644
index 00000000..6d54baa8
--- /dev/null
+++ b/gl/unitypes.in.h
@@ -0,0 +1,71 @@
1/* Elementary types and macros for the GNU UniString library.
2 Copyright (C) 2002, 2005-2006, 2009-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _UNITYPES_H
18#define _UNITYPES_H
19
20/* Get uint8_t, uint16_t, uint32_t. */
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28/* Type representing a Unicode character. */
29typedef uint32_t ucs4_t;
30
31/* Attribute of a function whose result depends only on the arguments
32 (not pointers!) and which has no side effects. */
33#ifndef _UC_ATTRIBUTE_CONST
34# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__
35# define _UC_ATTRIBUTE_CONST __attribute__ ((__const__))
36# else
37# define _UC_ATTRIBUTE_CONST
38# endif
39#endif
40
41/* Attribute of a function whose result depends only on the arguments
42 (possibly pointers) and global memory, and which has no side effects. */
43#ifndef _UC_ATTRIBUTE_PURE
44# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
45# define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__))
46# else
47# define _UC_ATTRIBUTE_PURE
48# endif
49#endif
50
51/* Qualifier in a function declaration, that asserts that the caller must
52 pass a pointer to a different object in the specified pointer argument
53 than in the other pointer arguments. */
54#ifndef _UC_RESTRICT
55# if defined __restrict \
56 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
57 || __clang_major__ >= 3
58# define _UC_RESTRICT __restrict
59# elif 199901L <= __STDC_VERSION__ || defined restrict
60# define _UC_RESTRICT restrict
61# else
62# define _UC_RESTRICT
63# endif
64#endif
65
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif /* _UNITYPES_H */
diff --git a/gl/uniwidth.in.h b/gl/uniwidth.in.h
new file mode 100644
index 00000000..dad496fd
--- /dev/null
+++ b/gl/uniwidth.in.h
@@ -0,0 +1,72 @@
1/* Display width functions.
2 Copyright (C) 2001-2002, 2005, 2007, 2009-2026 Free Software Foundation,
3 Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _UNIWIDTH_H
19#define _UNIWIDTH_H
20
21#include "unitypes.h"
22
23/* Get size_t. */
24#include <stddef.h>
25
26/* Get locale_charset() declaration. */
27#include "localcharset.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33
34/* Display width. */
35
36/* These functions are locale dependent. The encoding argument identifies
37 the encoding (e.g. "ISO-8859-2" for Polish). */
38
39/* Determine number of column positions required for UC. */
40extern int
41 uc_width (ucs4_t uc, const char *encoding)
42 _UC_ATTRIBUTE_PURE;
43
44/* Determine number of column positions required for first N units
45 (or fewer if S ends before this) in S. */
46extern int
47 u8_width (const uint8_t *s, size_t n, const char *encoding)
48 _UC_ATTRIBUTE_PURE;
49extern int
50 u16_width (const uint16_t *s, size_t n, const char *encoding)
51 _UC_ATTRIBUTE_PURE;
52extern int
53 u32_width (const uint32_t *s, size_t n, const char *encoding)
54 _UC_ATTRIBUTE_PURE;
55
56/* Determine number of column positions required for S. */
57extern int
58 u8_strwidth (const uint8_t *s, const char *encoding)
59 _UC_ATTRIBUTE_PURE;
60extern int
61 u16_strwidth (const uint16_t *s, const char *encoding)
62 _UC_ATTRIBUTE_PURE;
63extern int
64 u32_strwidth (const uint32_t *s, const char *encoding)
65 _UC_ATTRIBUTE_PURE;
66
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* _UNIWIDTH_H */
diff --git a/gl/uniwidth/.dirstamp b/gl/uniwidth/.dirstamp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/gl/uniwidth/.dirstamp
diff --git a/gl/uniwidth/cjk.h b/gl/uniwidth/cjk.h
new file mode 100644
index 00000000..bcd49fbf
--- /dev/null
+++ b/gl/uniwidth/cjk.h
@@ -0,0 +1,37 @@
1/* Test for CJK encoding.
2 Copyright (C) 2001-2002, 2005-2007, 2009-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include "streq.h"
19
20static int
21is_cjk_encoding (const char *encoding)
22{
23 if (0
24 /* Legacy Japanese encodings */
25 || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)
26 /* Legacy Chinese encodings */
27 || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
28 || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0)
29 || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)
30 || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)
31 /* Legacy Korean encodings */
32 || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
33 || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0)
34 || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0))
35 return 1;
36 return 0;
37}
diff --git a/gl/uniwidth/width.c b/gl/uniwidth/width.c
new file mode 100644
index 00000000..683f5513
--- /dev/null
+++ b/gl/uniwidth/width.c
@@ -0,0 +1,95 @@
1/* Determine display width of Unicode character.
2 Copyright (C) 2001-2002, 2006-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2002.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "uniwidth.h"
22
23#include "cjk.h"
24
25/* The non-spacing attribute table consists of:
26 * Non-spacing characters; generated from PropList.txt or
27 "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt"
28 * Format control characters; generated from
29 "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt"
30 * Zero width characters; generated from
31 "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt"
32 * Hangul Jamo characters that have conjoining behaviour:
33 - jungseong = syllable-middle vowels
34 - jongseong = syllable-final consonants
35 Rationale:
36 1) These characters act like combining characters. They have no
37 equivalent in legacy character sets. Therefore the EastAsianWidth.txt
38 file does not really matter for them; UAX #11 East Asian Width
39 <https://www.unicode.org/reports/tr11/> makes it clear that it focus
40 is on compatibility with traditional Japanese layout.
41 By contrast, the same glyphs without conjoining behaviour are available
42 in the U+3130..U+318F block, and these characters are mapped to legacy
43 character sets, and traditional Japanese layout matters for them.
44 2) glibc does the same thing, see
45 <https://sourceware.org/PR21750>
46 <https://sourceware.org/PR26120>
47 */
48#include "uniwidth/width0.h"
49
50#include "uniwidth/width2.h"
51#include "unictype/bitmap.h"
52
53#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
54
55
56/* Determine number of column positions required for UC. */
57int
58uc_width (ucs4_t uc, const char *encoding)
59{
60 /* Test for non-spacing or control character. */
61 if ((uc >> 9) < SIZEOF (nonspacing_table_ind))
62 {
63 int ind = nonspacing_table_ind[uc >> 9];
64 if (ind >= 0)
65 if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1)
66 {
67 if (uc > 0 && uc < 0xa0)
68 return -1;
69 else
70 return 0;
71 }
72 }
73 else if ((uc >> 9) == (0xe0000 >> 9))
74 {
75 if (uc >= 0xe0100)
76 {
77 if (uc <= 0xe01ef)
78 return 0;
79 }
80 else
81 {
82 if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001)
83 return 0;
84 }
85 }
86 /* Test for double-width character. */
87 if (bitmap_lookup (&u_width2, uc))
88 return 2;
89 /* In ancient CJK encodings, Cyrillic and most other characters are
90 double-width as well. */
91 if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9
92 && is_cjk_encoding (encoding))
93 return 2;
94 return 1;
95}
diff --git a/gl/uniwidth/width0.h b/gl/uniwidth/width0.h
new file mode 100644
index 00000000..d05286b7
--- /dev/null
+++ b/gl/uniwidth/width0.h
@@ -0,0 +1,504 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Table of non-spacing or control characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20static const unsigned char nonspacing_table_data[50*64] = {
21 /* 0x0000-0x01ff */
22 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */
24 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0x00, 0x00, /* 0x0080-0x00bf */
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00c0-0x00ff */
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0100-0x013f */
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0140-0x017f */
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0180-0x01bf */
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x01c0-0x01ff */
30 /* 0x0200-0x03ff */
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0200-0x023f */
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0240-0x027f */
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0280-0x02bf */
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x02c0-0x02ff */
35 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x0300-0x033f */
36 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* 0x0340-0x037f */
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0380-0x03bf */
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x03c0-0x03ff */
39 /* 0x0400-0x05ff */
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0400-0x043f */
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0440-0x047f */
42 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0480-0x04bf */
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04c0-0x04ff */
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0500-0x053f */
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0540-0x057f */
46 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */
47 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */
48 /* 0x0600-0x07ff */
49 0x00, 0x00, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */
50 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */
51 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */
52 0x00, 0x00, 0xc0, 0x9f, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */
53 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */
54 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */
55 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */
56 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x20, /* 0x07c0-0x07ff */
57 /* 0x0800-0x09ff */
58 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */
59 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */
60 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */
61 0x00, 0xfc, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, /* 0x08c0-0x08ff */
62 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */
63 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */
64 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */
65 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, /* 0x09c0-0x09ff */
66 /* 0x0a00-0x0bff */
67 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a00-0x0a3f */
68 0x86, 0x39, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, /* 0x0a40-0x0a7f */
69 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a80-0x0abf */
70 0xbe, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x00, 0xfc, /* 0x0ac0-0x0aff */
71 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0x0b00-0x0b3f */
72 0x1e, 0x20, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0b40-0x0b7f */
73 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */
74 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */
75 /* 0x0c00-0x0dff */
76 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, /* 0x0c00-0x0c3f */
77 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */
78 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */
79 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */
80 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, /* 0x0d00-0x0d3f */
81 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */
82 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */
83 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */
84 /* 0x0e00-0x0fff */
85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x07, /* 0x0e00-0x0e3f */
86 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0e40-0x0e7f */
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1f, /* 0x0e80-0x0ebf */
88 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */
89 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */
90 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */
91 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */
92 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */
93 /* 0x1000-0x11ff */
94 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */
95 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */
96 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */
99 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x1140-0x117f */
100 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x1180-0x11bf */
101 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x11c0-0x11ff */
102 /* 0x1200-0x13ff */
103 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */
104 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */
108 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */
111 /* 0x1600-0x17ff */
112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1600-0x163f */
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1640-0x167f */
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1680-0x16bf */
115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16c0-0x16ff */
116 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1700-0x173f */
117 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1740-0x177f */
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */
119 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */
120 /* 0x1800-0x19ff */
121 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */
122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */
123 0x60, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */
125 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */
128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */
129 /* 0x1a00-0x1bff */
130 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */
131 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */
132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x1a80-0x1abf */
133 0xff, 0xff, 0xff, 0x3f, 0xff, 0x0f, 0x00, 0x00, /* 0x1ac0-0x1aff */
134 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */
135 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */
136 0x03, 0x00, 0x00, 0x00, 0x3c, 0x3b, 0x00, 0x00, /* 0x1b80-0x1bbf */
137 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */
138 /* 0x1c00-0x1dff */
139 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */
142 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x10, 0x03, /* 0x1cc0-0x1cff */
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */
146 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x1dc0-0x1dff */
147 /* 0x2000-0x21ff */
148 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */
149 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0x00, 0x00, /* 0x2040-0x207f */
150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */
151 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */
153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2140-0x217f */
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2180-0x21bf */
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x21c0-0x21ff */
156 /* 0x2c00-0x2dff */
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */
158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */
160 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */
161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */
162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */
163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */
164 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */
165 /* 0x3000-0x31ff */
166 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x3000-0x303f */
167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */
168 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */
170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3100-0x313f */
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3140-0x317f */
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3180-0x31bf */
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */
174 /* 0xa600-0xa7ff */
175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf7, 0x3f, /* 0xa640-0xa67f */
177 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */
181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa7c0-0xa7ff */
183 /* 0xa800-0xa9ff */
184 0x44, 0x08, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, /* 0xa800-0xa83f */
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */
187 0x30, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x80, /* 0xa8c0-0xa8ff */
188 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */
189 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */
190 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x33, /* 0xa980-0xa9bf */
191 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */
192 /* 0xaa00-0xabff */
193 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */
194 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0xaa40-0xaa7f */
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */
196 0x02, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x00, /* 0xaac0-0xaaff */
197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */
198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */
200 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */
201 /* 0xd600-0xd7ff */
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd600-0xd63f */
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd640-0xd67f */
204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd680-0xd6bf */
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd6c0-0xd6ff */
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd700-0xd73f */
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd740-0xd77f */
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0xd780-0xd7bf */
209 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, /* 0xd7c0-0xd7ff */
210 /* 0xfa00-0xfbff */
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa80-0xfabf */
214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfac0-0xfaff */
215 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0xfb00-0xfb3f */
216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb40-0xfb7f */
217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */
219 /* 0xfe00-0xffff */
220 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, /* 0xfe00-0xfe3f */
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */
222 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */
223 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */
224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff00-0xff3f */
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff40-0xff7f */
226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff80-0xffbf */
227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, /* 0xffc0-0xffff */
228 /* 0x10000-0x101ff */
229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10000-0x1003f */
230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10040-0x1007f */
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10080-0x100bf */
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x100c0-0x100ff */
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10100-0x1013f */
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */
235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */
237 /* 0x10200-0x103ff */
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10200-0x1023f */
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10240-0x1027f */
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10280-0x102bf */
241 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, /* 0x102c0-0x102ff */
242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10300-0x1033f */
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x10340-0x1037f */
244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10380-0x103bf */
245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x103c0-0x103ff */
246 /* 0x10a00-0x10bff */
247 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */
249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */
250 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */
252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */
253 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */
254 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */
255 /* 0x10c00-0x10dff */
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c00-0x10c3f */
257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c40-0x10c7f */
258 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c80-0x10cbf */
259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10cc0-0x10cff */
260 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, /* 0x10d00-0x10d3f */
261 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, /* 0x10d40-0x10d7f */
262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10d80-0x10dbf */
263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10dc0-0x10dff */
264 /* 0x10e00-0x10fff */
265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10e00-0x10e3f */
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10e40-0x10e7f */
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, /* 0x10e80-0x10ebf */
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, /* 0x10ec0-0x10eff */
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10f00-0x10f3f */
270 0xc0, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10f40-0x10f7f */
271 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10f80-0x10fbf */
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10fc0-0x10fff */
273 /* 0x11000-0x111ff */
274 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */
275 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x80, /* 0x11040-0x1107f */
276 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x06, /* 0x11080-0x110bf */
277 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */
278 0x07, 0x00, 0x00, 0x00, 0x80, 0xef, 0x1f, 0x00, /* 0x11100-0x1113f */
279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, /* 0x11140-0x1117f */
280 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x7f, /* 0x11180-0x111bf */
281 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */
282 /* 0x11200-0x113ff */
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd3, 0x40, /* 0x11200-0x1123f */
284 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11240-0x1127f */
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11280-0x112bf */
286 0x00, 0x00, 0x00, 0x80, 0xf8, 0x07, 0x00, 0x00, /* 0x112c0-0x112ff */
287 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, /* 0x11300-0x1133f */
288 0x01, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x1f, 0x00, /* 0x11340-0x1137f */
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, /* 0x11380-0x113bf */
290 0x01, 0x40, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, /* 0x113c0-0x113ff */
291 /* 0x11400-0x115ff */
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11400-0x1143f */
293 0x5c, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0x11440-0x1147f */
294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x85, /* 0x11480-0x114bf */
295 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x114c0-0x114ff */
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11500-0x1153f */
297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11540-0x1157f */
298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xb0, /* 0x11580-0x115bf */
299 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, /* 0x115c0-0x115ff */
300 /* 0x11600-0x117ff */
301 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xa7, /* 0x11600-0x1163f */
302 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11640-0x1167f */
303 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xbf, 0x00, /* 0x11680-0x116bf */
304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x116c0-0x116ff */
305 0x00, 0x00, 0x00, 0xa0, 0xbc, 0x0f, 0x00, 0x00, /* 0x11700-0x1173f */
306 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11740-0x1177f */
307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11780-0x117bf */
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x117c0-0x117ff */
309 /* 0x11800-0x119ff */
310 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x06, /* 0x11800-0x1183f */
311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11840-0x1187f */
312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11880-0x118bf */
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x118c0-0x118ff */
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, /* 0x11900-0x1193f */
315 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11940-0x1197f */
316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11980-0x119bf */
317 0x00, 0x00, 0xf0, 0x0c, 0x01, 0x00, 0x00, 0x00, /* 0x119c0-0x119ff */
318 /* 0x11a00-0x11bff */
319 0x7e, 0x06, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x79, /* 0x11a00-0x11a3f */
320 0x80, 0x00, 0x7e, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x11a40-0x11a7f */
321 0x00, 0xfc, 0x7f, 0x03, 0x00, 0x00, 0x00, 0x00, /* 0x11a80-0x11abf */
322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11ac0-0x11aff */
323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11b00-0x11b3f */
324 0x00, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, /* 0x11b40-0x11b7f */
325 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11b80-0x11bbf */
326 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11bc0-0x11bff */
327 /* 0x11c00-0x11dff */
328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x3f, /* 0x11c00-0x11c3f */
329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c40-0x11c7f */
330 0x00, 0x00, 0xfc, 0xff, 0xff, 0xfc, 0x6d, 0x00, /* 0x11c80-0x11cbf */
331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11cc0-0x11cff */
332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xb4, /* 0x11d00-0x11d3f */
333 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d40-0x11d7f */
334 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11d80-0x11dbf */
335 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11dc0-0x11dff */
336 /* 0x11e00-0x11fff */
337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11e00-0x11e3f */
338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11e40-0x11e7f */
339 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11e80-0x11ebf */
340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, /* 0x11ec0-0x11eff */
341 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, /* 0x11f00-0x11f3f */
342 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, /* 0x11f40-0x11f7f */
343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11f80-0x11fbf */
344 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11fc0-0x11fff */
345 /* 0x13400-0x135ff */
346 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x13400-0x1343f */
347 0x81, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13440-0x1347f */
348 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13480-0x134bf */
349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x134c0-0x134ff */
350 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13500-0x1353f */
351 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13540-0x1357f */
352 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13580-0x135bf */
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x135c0-0x135ff */
354 /* 0x16000-0x161ff */
355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16000-0x1603f */
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16040-0x1607f */
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16080-0x160bf */
358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x160c0-0x160ff */
359 0x00, 0x00, 0x00, 0xc0, 0xff, 0xe3, 0x00, 0x00, /* 0x16100-0x1613f */
360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16140-0x1617f */
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16180-0x161bf */
362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x161c0-0x161ff */
363 /* 0x16a00-0x16bff */
364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a00-0x16a3f */
365 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a40-0x16a7f */
366 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16a80-0x16abf */
367 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, /* 0x16ac0-0x16aff */
368 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x16b00-0x16b3f */
369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b40-0x16b7f */
370 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16b80-0x16bbf */
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16bc0-0x16bff */
372 /* 0x16e00-0x16fff */
373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e00-0x16e3f */
374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e40-0x16e7f */
375 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16e80-0x16ebf */
376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16ec0-0x16eff */
377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f00-0x16f3f */
378 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f40-0x16f7f */
379 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16f80-0x16fbf */
380 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, /* 0x16fc0-0x16fff */
381 /* 0x1bc00-0x1bdff */
382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc00-0x1bc3f */
383 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bc40-0x1bc7f */
384 0x00, 0x00, 0x00, 0x60, 0x0f, 0x00, 0x00, 0x00, /* 0x1bc80-0x1bcbf */
385 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bcc0-0x1bcff */
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd00-0x1bd3f */
387 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd40-0x1bd7f */
388 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bd80-0x1bdbf */
389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1bdc0-0x1bdff */
390 /* 0x1ce00-0x1cfff */
391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ce00-0x1ce3f */
392 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ce40-0x1ce7f */
393 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ce80-0x1cebf */
394 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cec0-0x1ceff */
395 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, /* 0x1cf00-0x1cf3f */
396 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cf40-0x1cf7f */
397 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cf80-0x1cfbf */
398 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1cfc0-0x1cfff */
399 /* 0x1d000-0x1d1ff */
400 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */
401 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */
402 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */
403 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */
404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */
405 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */
406 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */
408 /* 0x1d200-0x1d3ff */
409 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d200-0x1d23f */
410 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d240-0x1d27f */
411 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d280-0x1d2bf */
412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d2c0-0x1d2ff */
413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */
414 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */
415 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */
416 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d3c0-0x1d3ff */
417 /* 0x1da00-0x1dbff */
418 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf8, /* 0x1da00-0x1da3f */
419 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x20, 0x00, /* 0x1da40-0x1da7f */
420 0x10, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x00, 0x00, /* 0x1da80-0x1dabf */
421 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dac0-0x1daff */
422 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db00-0x1db3f */
423 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db40-0x1db7f */
424 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1db80-0x1dbbf */
425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1dbc0-0x1dbff */
426 /* 0x1e000-0x1e1ff */
427 0x7f, 0xff, 0xff, 0xf9, 0xdb, 0x07, 0x00, 0x00, /* 0x1e000-0x1e03f */
428 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e040-0x1e07f */
429 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e080-0x1e0bf */
430 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e0c0-0x1e0ff */
431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 0x1e100-0x1e13f */
432 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e140-0x1e17f */
433 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e180-0x1e1bf */
434 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e1c0-0x1e1ff */
435 /* 0x1e200-0x1e3ff */
436 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e200-0x1e23f */
437 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e240-0x1e27f */
438 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, /* 0x1e280-0x1e2bf */
439 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, /* 0x1e2c0-0x1e2ff */
440 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e300-0x1e33f */
441 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e340-0x1e37f */
442 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e380-0x1e3bf */
443 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e3c0-0x1e3ff */
444 /* 0x1e400-0x1e5ff */
445 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e400-0x1e43f */
446 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e440-0x1e47f */
447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e480-0x1e4bf */
448 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, /* 0x1e4c0-0x1e4ff */
449 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e500-0x1e53f */
450 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e540-0x1e57f */
451 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e580-0x1e5bf */
452 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x1e5c0-0x1e5ff */
453 /* 0x1e600-0x1e7ff */
454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e600-0x1e63f */
455 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e640-0x1e67f */
456 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e680-0x1e6bf */
457 0x00, 0x00, 0x00, 0x00, 0x48, 0xc0, 0x20, 0x00, /* 0x1e6c0-0x1e6ff */
458 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e700-0x1e73f */
459 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e740-0x1e77f */
460 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e780-0x1e7bf */
461 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e7c0-0x1e7ff */
462 /* 0x1e800-0x1e9ff */
463 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e800-0x1e83f */
464 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e840-0x1e87f */
465 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e880-0x1e8bf */
466 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e8c0-0x1e8ff */
467 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e900-0x1e93f */
468 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e940-0x1e97f */
469 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1e980-0x1e9bf */
470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1e9c0-0x1e9ff */
471};
472static const signed char nonspacing_table_ind[248] = {
473 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */
474 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */
475 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */
476 16, -1, -1, -1, -1, -1, -1, -1, /* 0x3000-0x3fff */
477 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x4000-0x4fff */
478 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x5000-0x5fff */
479 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x6000-0x6fff */
480 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x7000-0x7fff */
481 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x8000-0x8fff */
482 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9000-0x9fff */
483 -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */
484 -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */
485 -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */
486 -1, -1, -1, 20, -1, -1, -1, -1, /* 0xd000-0xdfff */
487 -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */
488 -1, -1, -1, -1, -1, 21, -1, 22, /* 0xf000-0xffff */
489 23, 24, -1, -1, -1, 25, 26, 27, /* 0x10000-0x10fff */
490 28, 29, 30, 31, 32, 33, 34, 35, /* 0x11000-0x11fff */
491 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */
492 -1, -1, 36, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */
493 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */
494 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */
495 37, -1, -1, -1, -1, 38, -1, 39, /* 0x16000-0x16fff */
496 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */
497 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */
498 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */
499 -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */
500 -1, -1, -1, -1, -1, -1, 40, -1, /* 0x1b000-0x1bfff */
501 -1, -1, -1, -1, -1, -1, -1, 41, /* 0x1c000-0x1cfff */
502 42, 43, -1, -1, -1, 44, -1, -1, /* 0x1d000-0x1dfff */
503 45, 46, 47, 48, 49, -1, -1, -1 /* 0x1e000-0x1efff */
504};
diff --git a/gl/uniwidth/width2.h b/gl/uniwidth/width2.h
new file mode 100644
index 00000000..70bb049c
--- /dev/null
+++ b/gl/uniwidth/width2.h
@@ -0,0 +1,541 @@
1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Width 2 property of Unicode characters. */
3/* Generated automatically by gen-uni-tables.c for Unicode 17.0.0. */
4
5/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#define header_0 16
21#define header_2 9
22#define header_3 127
23#define header_4 15
24static const
25struct
26 {
27 int header[1];
28 int level1[4];
29 short level2[3 << 7];
30 unsigned int level3[28 << 4];
31 }
32u_width2 =
33{
34 { 4 },
35 {
36 5 * sizeof (int) / sizeof (short) + 0,
37 5 * sizeof (int) / sizeof (short) + 128,
38 5 * sizeof (int) / sizeof (short) + 256,
39 5 * sizeof (int) / sizeof (short) + 256
40 },
41 {
42 -1,
43 -1,
44 -1,
45 -1,
46 -1,
47 -1,
48 -1,
49 -1,
50 5 + 384 * sizeof (short) / sizeof (int) + 0,
51 -1,
52 -1,
53 -1,
54 -1,
55 -1,
56 -1,
57 -1,
58 -1,
59 5 + 384 * sizeof (short) / sizeof (int) + 16,
60 5 + 384 * sizeof (short) / sizeof (int) + 32,
61 5 + 384 * sizeof (short) / sizeof (int) + 48,
62 -1,
63 5 + 384 * sizeof (short) / sizeof (int) + 64,
64 -1,
65 5 + 384 * sizeof (short) / sizeof (int) + 80,
66 5 + 384 * sizeof (short) / sizeof (int) + 96,
67 5 + 384 * sizeof (short) / sizeof (int) + 112,
68 5 + 384 * sizeof (short) / sizeof (int) + 128,
69 5 + 384 * sizeof (short) / sizeof (int) + 128,
70 5 + 384 * sizeof (short) / sizeof (int) + 128,
71 5 + 384 * sizeof (short) / sizeof (int) + 128,
72 5 + 384 * sizeof (short) / sizeof (int) + 128,
73 5 + 384 * sizeof (short) / sizeof (int) + 128,
74 5 + 384 * sizeof (short) / sizeof (int) + 128,
75 5 + 384 * sizeof (short) / sizeof (int) + 128,
76 5 + 384 * sizeof (short) / sizeof (int) + 128,
77 5 + 384 * sizeof (short) / sizeof (int) + 128,
78 5 + 384 * sizeof (short) / sizeof (int) + 128,
79 5 + 384 * sizeof (short) / sizeof (int) + 128,
80 5 + 384 * sizeof (short) / sizeof (int) + 144,
81 5 + 384 * sizeof (short) / sizeof (int) + 128,
82 5 + 384 * sizeof (short) / sizeof (int) + 128,
83 5 + 384 * sizeof (short) / sizeof (int) + 128,
84 5 + 384 * sizeof (short) / sizeof (int) + 128,
85 5 + 384 * sizeof (short) / sizeof (int) + 128,
86 5 + 384 * sizeof (short) / sizeof (int) + 128,
87 5 + 384 * sizeof (short) / sizeof (int) + 128,
88 5 + 384 * sizeof (short) / sizeof (int) + 128,
89 5 + 384 * sizeof (short) / sizeof (int) + 128,
90 5 + 384 * sizeof (short) / sizeof (int) + 128,
91 5 + 384 * sizeof (short) / sizeof (int) + 128,
92 5 + 384 * sizeof (short) / sizeof (int) + 128,
93 5 + 384 * sizeof (short) / sizeof (int) + 128,
94 5 + 384 * sizeof (short) / sizeof (int) + 128,
95 5 + 384 * sizeof (short) / sizeof (int) + 128,
96 5 + 384 * sizeof (short) / sizeof (int) + 128,
97 5 + 384 * sizeof (short) / sizeof (int) + 128,
98 5 + 384 * sizeof (short) / sizeof (int) + 128,
99 5 + 384 * sizeof (short) / sizeof (int) + 128,
100 5 + 384 * sizeof (short) / sizeof (int) + 128,
101 5 + 384 * sizeof (short) / sizeof (int) + 128,
102 5 + 384 * sizeof (short) / sizeof (int) + 128,
103 5 + 384 * sizeof (short) / sizeof (int) + 128,
104 5 + 384 * sizeof (short) / sizeof (int) + 128,
105 5 + 384 * sizeof (short) / sizeof (int) + 128,
106 5 + 384 * sizeof (short) / sizeof (int) + 128,
107 5 + 384 * sizeof (short) / sizeof (int) + 128,
108 5 + 384 * sizeof (short) / sizeof (int) + 128,
109 5 + 384 * sizeof (short) / sizeof (int) + 128,
110 5 + 384 * sizeof (short) / sizeof (int) + 128,
111 5 + 384 * sizeof (short) / sizeof (int) + 128,
112 5 + 384 * sizeof (short) / sizeof (int) + 128,
113 5 + 384 * sizeof (short) / sizeof (int) + 128,
114 5 + 384 * sizeof (short) / sizeof (int) + 128,
115 5 + 384 * sizeof (short) / sizeof (int) + 128,
116 5 + 384 * sizeof (short) / sizeof (int) + 128,
117 5 + 384 * sizeof (short) / sizeof (int) + 128,
118 5 + 384 * sizeof (short) / sizeof (int) + 128,
119 5 + 384 * sizeof (short) / sizeof (int) + 128,
120 5 + 384 * sizeof (short) / sizeof (int) + 128,
121 5 + 384 * sizeof (short) / sizeof (int) + 128,
122 5 + 384 * sizeof (short) / sizeof (int) + 128,
123 5 + 384 * sizeof (short) / sizeof (int) + 128,
124 5 + 384 * sizeof (short) / sizeof (int) + 160,
125 -1,
126 5 + 384 * sizeof (short) / sizeof (int) + 176,
127 -1,
128 5 + 384 * sizeof (short) / sizeof (int) + 128,
129 5 + 384 * sizeof (short) / sizeof (int) + 128,
130 5 + 384 * sizeof (short) / sizeof (int) + 128,
131 5 + 384 * sizeof (short) / sizeof (int) + 128,
132 5 + 384 * sizeof (short) / sizeof (int) + 128,
133 5 + 384 * sizeof (short) / sizeof (int) + 128,
134 5 + 384 * sizeof (short) / sizeof (int) + 128,
135 5 + 384 * sizeof (short) / sizeof (int) + 128,
136 5 + 384 * sizeof (short) / sizeof (int) + 128,
137 5 + 384 * sizeof (short) / sizeof (int) + 128,
138 5 + 384 * sizeof (short) / sizeof (int) + 128,
139 5 + 384 * sizeof (short) / sizeof (int) + 128,
140 5 + 384 * sizeof (short) / sizeof (int) + 128,
141 5 + 384 * sizeof (short) / sizeof (int) + 128,
142 5 + 384 * sizeof (short) / sizeof (int) + 128,
143 5 + 384 * sizeof (short) / sizeof (int) + 128,
144 5 + 384 * sizeof (short) / sizeof (int) + 128,
145 5 + 384 * sizeof (short) / sizeof (int) + 128,
146 5 + 384 * sizeof (short) / sizeof (int) + 128,
147 5 + 384 * sizeof (short) / sizeof (int) + 128,
148 5 + 384 * sizeof (short) / sizeof (int) + 128,
149 5 + 384 * sizeof (short) / sizeof (int) + 192,
150 -1,
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 -1,
158 -1,
159 -1,
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 5 + 384 * sizeof (short) / sizeof (int) + 208,
167 5 + 384 * sizeof (short) / sizeof (int) + 224,
168 -1,
169 5 + 384 * sizeof (short) / sizeof (int) + 240,
170 -1,
171 -1,
172 -1,
173 -1,
174 -1,
175 -1,
176 -1,
177 -1,
178 -1,
179 -1,
180 -1,
181 -1,
182 -1,
183 -1,
184 -1,
185 -1,
186 -1,
187 -1,
188 -1,
189 -1,
190 -1,
191 -1,
192 -1,
193 -1,
194 -1,
195 -1,
196 -1,
197 -1,
198 -1,
199 -1,
200 -1,
201 -1,
202 -1,
203 -1,
204 -1,
205 -1,
206 -1,
207 -1,
208 -1,
209 -1,
210 -1,
211 -1,
212 -1,
213 -1,
214 -1,
215 -1,
216 -1,
217 -1,
218 -1,
219 -1,
220 -1,
221 -1,
222 -1,
223 -1,
224 -1,
225 5 + 384 * sizeof (short) / sizeof (int) + 256,
226 5 + 384 * sizeof (short) / sizeof (int) + 128,
227 5 + 384 * sizeof (short) / sizeof (int) + 128,
228 5 + 384 * sizeof (short) / sizeof (int) + 128,
229 5 + 384 * sizeof (short) / sizeof (int) + 128,
230 5 + 384 * sizeof (short) / sizeof (int) + 128,
231 5 + 384 * sizeof (short) / sizeof (int) + 128,
232 5 + 384 * sizeof (short) / sizeof (int) + 128,
233 5 + 384 * sizeof (short) / sizeof (int) + 128,
234 5 + 384 * sizeof (short) / sizeof (int) + 128,
235 5 + 384 * sizeof (short) / sizeof (int) + 128,
236 5 + 384 * sizeof (short) / sizeof (int) + 128,
237 5 + 384 * sizeof (short) / sizeof (int) + 272,
238 5 + 384 * sizeof (short) / sizeof (int) + 128,
239 5 + 384 * sizeof (short) / sizeof (int) + 128,
240 5 + 384 * sizeof (short) / sizeof (int) + 288,
241 -1,
242 -1,
243 -1,
244 -1,
245 -1,
246 -1,
247 -1,
248 -1,
249 -1,
250 -1,
251 -1,
252 -1,
253 -1,
254 -1,
255 -1,
256 -1,
257 5 + 384 * sizeof (short) / sizeof (int) + 304,
258 5 + 384 * sizeof (short) / sizeof (int) + 320,
259 5 + 384 * sizeof (short) / sizeof (int) + 336,
260 -1,
261 -1,
262 -1,
263 -1,
264 -1,
265 -1,
266 -1,
267 -1,
268 -1,
269 -1,
270 -1,
271 -1,
272 -1,
273 -1,
274 -1,
275 -1,
276 -1,
277 -1,
278 -1,
279 -1,
280 -1,
281 -1,
282 -1,
283 -1,
284 -1,
285 -1,
286 -1,
287 -1,
288 -1,
289 -1,
290 5 + 384 * sizeof (short) / sizeof (int) + 352,
291 5 + 384 * sizeof (short) / sizeof (int) + 368,
292 5 + 384 * sizeof (short) / sizeof (int) + 384,
293 5 + 384 * sizeof (short) / sizeof (int) + 400,
294 5 + 384 * sizeof (short) / sizeof (int) + 416,
295 5 + 384 * sizeof (short) / sizeof (int) + 432,
296 -1,
297 -1,
298 5 + 384 * sizeof (short) / sizeof (int) + 128,
299 5 + 384 * sizeof (short) / sizeof (int) + 128,
300 5 + 384 * sizeof (short) / sizeof (int) + 128,
301 5 + 384 * sizeof (short) / sizeof (int) + 128,
302 5 + 384 * sizeof (short) / sizeof (int) + 128,
303 5 + 384 * sizeof (short) / sizeof (int) + 128,
304 5 + 384 * sizeof (short) / sizeof (int) + 128,
305 5 + 384 * sizeof (short) / sizeof (int) + 128,
306 5 + 384 * sizeof (short) / sizeof (int) + 128,
307 5 + 384 * sizeof (short) / sizeof (int) + 128,
308 5 + 384 * sizeof (short) / sizeof (int) + 128,
309 5 + 384 * sizeof (short) / sizeof (int) + 128,
310 5 + 384 * sizeof (short) / sizeof (int) + 128,
311 5 + 384 * sizeof (short) / sizeof (int) + 128,
312 5 + 384 * sizeof (short) / sizeof (int) + 128,
313 5 + 384 * sizeof (short) / sizeof (int) + 128,
314 5 + 384 * sizeof (short) / sizeof (int) + 128,
315 5 + 384 * sizeof (short) / sizeof (int) + 128,
316 5 + 384 * sizeof (short) / sizeof (int) + 128,
317 5 + 384 * sizeof (short) / sizeof (int) + 128,
318 5 + 384 * sizeof (short) / sizeof (int) + 128,
319 5 + 384 * sizeof (short) / sizeof (int) + 128,
320 5 + 384 * sizeof (short) / sizeof (int) + 128,
321 5 + 384 * sizeof (short) / sizeof (int) + 128,
322 5 + 384 * sizeof (short) / sizeof (int) + 128,
323 5 + 384 * sizeof (short) / sizeof (int) + 128,
324 5 + 384 * sizeof (short) / sizeof (int) + 128,
325 5 + 384 * sizeof (short) / sizeof (int) + 128,
326 5 + 384 * sizeof (short) / sizeof (int) + 128,
327 5 + 384 * sizeof (short) / sizeof (int) + 128,
328 5 + 384 * sizeof (short) / sizeof (int) + 128,
329 5 + 384 * sizeof (short) / sizeof (int) + 128,
330 5 + 384 * sizeof (short) / sizeof (int) + 128,
331 5 + 384 * sizeof (short) / sizeof (int) + 128,
332 5 + 384 * sizeof (short) / sizeof (int) + 128,
333 5 + 384 * sizeof (short) / sizeof (int) + 128,
334 5 + 384 * sizeof (short) / sizeof (int) + 128,
335 5 + 384 * sizeof (short) / sizeof (int) + 128,
336 5 + 384 * sizeof (short) / sizeof (int) + 128,
337 5 + 384 * sizeof (short) / sizeof (int) + 128,
338 5 + 384 * sizeof (short) / sizeof (int) + 128,
339 5 + 384 * sizeof (short) / sizeof (int) + 128,
340 5 + 384 * sizeof (short) / sizeof (int) + 128,
341 5 + 384 * sizeof (short) / sizeof (int) + 128,
342 5 + 384 * sizeof (short) / sizeof (int) + 128,
343 5 + 384 * sizeof (short) / sizeof (int) + 128,
344 5 + 384 * sizeof (short) / sizeof (int) + 128,
345 5 + 384 * sizeof (short) / sizeof (int) + 128,
346 5 + 384 * sizeof (short) / sizeof (int) + 128,
347 5 + 384 * sizeof (short) / sizeof (int) + 128,
348 5 + 384 * sizeof (short) / sizeof (int) + 128,
349 5 + 384 * sizeof (short) / sizeof (int) + 128,
350 5 + 384 * sizeof (short) / sizeof (int) + 128,
351 5 + 384 * sizeof (short) / sizeof (int) + 128,
352 5 + 384 * sizeof (short) / sizeof (int) + 128,
353 5 + 384 * sizeof (short) / sizeof (int) + 128,
354 5 + 384 * sizeof (short) / sizeof (int) + 128,
355 5 + 384 * sizeof (short) / sizeof (int) + 128,
356 5 + 384 * sizeof (short) / sizeof (int) + 128,
357 5 + 384 * sizeof (short) / sizeof (int) + 128,
358 5 + 384 * sizeof (short) / sizeof (int) + 128,
359 5 + 384 * sizeof (short) / sizeof (int) + 128,
360 5 + 384 * sizeof (short) / sizeof (int) + 128,
361 5 + 384 * sizeof (short) / sizeof (int) + 128,
362 5 + 384 * sizeof (short) / sizeof (int) + 128,
363 5 + 384 * sizeof (short) / sizeof (int) + 128,
364 5 + 384 * sizeof (short) / sizeof (int) + 128,
365 5 + 384 * sizeof (short) / sizeof (int) + 128,
366 5 + 384 * sizeof (short) / sizeof (int) + 128,
367 5 + 384 * sizeof (short) / sizeof (int) + 128,
368 5 + 384 * sizeof (short) / sizeof (int) + 128,
369 5 + 384 * sizeof (short) / sizeof (int) + 128,
370 5 + 384 * sizeof (short) / sizeof (int) + 128,
371 5 + 384 * sizeof (short) / sizeof (int) + 128,
372 5 + 384 * sizeof (short) / sizeof (int) + 128,
373 5 + 384 * sizeof (short) / sizeof (int) + 128,
374 5 + 384 * sizeof (short) / sizeof (int) + 128,
375 5 + 384 * sizeof (short) / sizeof (int) + 128,
376 5 + 384 * sizeof (short) / sizeof (int) + 128,
377 5 + 384 * sizeof (short) / sizeof (int) + 128,
378 5 + 384 * sizeof (short) / sizeof (int) + 128,
379 5 + 384 * sizeof (short) / sizeof (int) + 128,
380 5 + 384 * sizeof (short) / sizeof (int) + 128,
381 5 + 384 * sizeof (short) / sizeof (int) + 128,
382 5 + 384 * sizeof (short) / sizeof (int) + 128,
383 5 + 384 * sizeof (short) / sizeof (int) + 128,
384 5 + 384 * sizeof (short) / sizeof (int) + 128,
385 5 + 384 * sizeof (short) / sizeof (int) + 128,
386 5 + 384 * sizeof (short) / sizeof (int) + 128,
387 5 + 384 * sizeof (short) / sizeof (int) + 128,
388 5 + 384 * sizeof (short) / sizeof (int) + 128,
389 5 + 384 * sizeof (short) / sizeof (int) + 128,
390 5 + 384 * sizeof (short) / sizeof (int) + 128,
391 5 + 384 * sizeof (short) / sizeof (int) + 128,
392 5 + 384 * sizeof (short) / sizeof (int) + 128,
393 5 + 384 * sizeof (short) / sizeof (int) + 128,
394 5 + 384 * sizeof (short) / sizeof (int) + 128,
395 5 + 384 * sizeof (short) / sizeof (int) + 128,
396 5 + 384 * sizeof (short) / sizeof (int) + 128,
397 5 + 384 * sizeof (short) / sizeof (int) + 128,
398 5 + 384 * sizeof (short) / sizeof (int) + 128,
399 5 + 384 * sizeof (short) / sizeof (int) + 128,
400 5 + 384 * sizeof (short) / sizeof (int) + 128,
401 5 + 384 * sizeof (short) / sizeof (int) + 128,
402 5 + 384 * sizeof (short) / sizeof (int) + 128,
403 5 + 384 * sizeof (short) / sizeof (int) + 128,
404 5 + 384 * sizeof (short) / sizeof (int) + 128,
405 5 + 384 * sizeof (short) / sizeof (int) + 128,
406 5 + 384 * sizeof (short) / sizeof (int) + 128,
407 5 + 384 * sizeof (short) / sizeof (int) + 128,
408 5 + 384 * sizeof (short) / sizeof (int) + 128,
409 5 + 384 * sizeof (short) / sizeof (int) + 128,
410 5 + 384 * sizeof (short) / sizeof (int) + 128,
411 5 + 384 * sizeof (short) / sizeof (int) + 128,
412 5 + 384 * sizeof (short) / sizeof (int) + 128,
413 5 + 384 * sizeof (short) / sizeof (int) + 128,
414 5 + 384 * sizeof (short) / sizeof (int) + 128,
415 5 + 384 * sizeof (short) / sizeof (int) + 128,
416 5 + 384 * sizeof (short) / sizeof (int) + 128,
417 5 + 384 * sizeof (short) / sizeof (int) + 128,
418 5 + 384 * sizeof (short) / sizeof (int) + 128,
419 5 + 384 * sizeof (short) / sizeof (int) + 128,
420 5 + 384 * sizeof (short) / sizeof (int) + 128,
421 5 + 384 * sizeof (short) / sizeof (int) + 128,
422 5 + 384 * sizeof (short) / sizeof (int) + 128,
423 5 + 384 * sizeof (short) / sizeof (int) + 128,
424 5 + 384 * sizeof (short) / sizeof (int) + 128,
425 5 + 384 * sizeof (short) / sizeof (int) + 128
426 },
427 {
428 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
429 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
430 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U,
431 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
432 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
433 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
434 0x0C000000U, 0x00000600U, 0x00000000U, 0x00000000U,
435 0x00000000U, 0x00000000U, 0x00000000U, 0x00091E00U,
436 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
437 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
438 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
439 0x00000000U, 0x00000000U, 0x00000000U, 0x60000000U,
440 0x00300000U, 0x00000000U, 0x000FFF00U, 0x80000000U,
441 0x00080000U, 0x60000C02U, 0x00104030U, 0x242C0400U,
442 0x00000C20U, 0x00000100U, 0x00B85000U, 0x00000000U,
443 0x00E00000U, 0x80010000U, 0x00000000U, 0x00000000U,
444 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
445 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
446 0x18000000U, 0x00000000U, 0x00210000U, 0x00000000U,
447 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
448 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
449 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
450 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
451 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
452 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
453 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
454 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
455 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
456 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFF00FFU, 0xFFFFFFFFU,
457 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
458 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
459 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
460 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
461 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
462 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
463 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
464 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
465 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
466 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
467 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000000U, 0x00000000U,
468 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
469 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U,
470 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
471 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
472 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
473 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
474 0x00000000U, 0x00000000U, 0x00000000U, 0x1FFFFFFFU,
475 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
476 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
477 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
478 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
479 0xFFFFFFFFU, 0x0000000FU, 0x00000000U, 0x00000000U,
480 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
481 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
482 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
483 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
484 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
485 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
486 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
487 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
488 0xFFFF0000U, 0xFFFF0000U, 0xFFFFFFFFU, 0x0000FFFFU,
489 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
490 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00000001U,
491 0x00000000U, 0x00000000U, 0x00000000U, 0x0000007FU,
492 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
493 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
494 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
495 0x00000000U, 0x00000000U, 0x00000000U, 0x0003000FU,
496 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
497 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
498 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
499 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x00FFFFFFU,
500 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
501 0xFFFFFFFFU, 0xFFFFFFFFU, 0x003FFFFFU, 0x00000000U,
502 0x000001FFU, 0x00000000U, 0x00000000U, 0x00000000U,
503 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
504 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
505 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
506 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
507 0x00000000U, 0x00000000U, 0x00000000U, 0x6FEF0000U,
508 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
509 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
510 0xFFFFFFFFU, 0x00000007U, 0x00070000U, 0xFFFF00F0U,
511 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
512 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
513 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0FFFFFFFU,
514 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
515 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
516 0x00000010U, 0x00000000U, 0x00000000U, 0x00000000U,
517 0x00000000U, 0x00000000U, 0x00008000U, 0x00000000U,
518 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
519 0x07FE4000U, 0x00000000U, 0x00000000U, 0x00000000U,
520 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
521 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
522 0xFFFFFFFFU, 0xFFBFE001U, 0xFFFFFFFFU, 0xDFFFFFFFU,
523 0x000FFFFFU, 0xFFFFFFFFU, 0x000F87FFU, 0xFF11FFFFU,
524 0xFFFFFFFFU, 0x7FFFFFFFU, 0xFFFFFFFDU, 0xFFFFFFFFU,
525 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0x9FFFFFFFU,
526 0xFFFFFFFFU, 0x3FFFFFFFU, 0xFFFF7800U, 0x040000FFU,
527 0x00600000U, 0x00000010U, 0x00000000U, 0xF8000000U,
528 0xFFFFFFFFU, 0xFFFFFFFFU, 0x0000FFFFU, 0x00000000U,
529 0xFFFFFFFFU, 0xFFFFFFFFU, 0xE0E7103FU, 0x1FF01800U,
530 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
531 0x00000000U, 0x00000000U, 0x00000000U, 0x00010FFFU,
532 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
533 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
534 0xFFFFF000U, 0xF7FFFFFFU, 0xFFFFFFBFU, 0xFFFFFFFFU,
535 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU,
536 0x00000000U, 0x00000000U, 0x00000000U, 0x1F1F0000U,
537 0xFFFF007FU, 0x07FF1FFFU, 0x03FF003FU, 0x007F00FFU,
538 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U,
539 0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U
540 }
541};
diff --git a/gl/unlocked-io.h b/gl/unlocked-io.h
index fdef624a..2b0d13e3 100644
--- a/gl/unlocked-io.h
+++ b/gl/unlocked-io.h
@@ -1,6 +1,6 @@
1/* Prefer faster, non-thread-safe stdio functions if available. 1/* Prefer faster, non-thread-safe stdio functions if available.
2 2
3 Copyright (C) 2001-2004, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2001-2004, 2009-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -31,6 +31,11 @@
31 the *_unlocked functions directly. On hosts that lack those 31 the *_unlocked functions directly. On hosts that lack those
32 functions, invoke the non-thread-safe versions instead. */ 32 functions, invoke the non-thread-safe versions instead. */
33 33
34/* This file uses HAVE_DECL_*_UNLOCKED. */
35# if !_GL_CONFIG_H_INCLUDED
36# error "Please include config.h first."
37# endif
38
34# include <stdio.h> 39# include <stdio.h>
35 40
36# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked 41# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked
@@ -68,6 +73,13 @@
68# define fgets_unlocked(x,y,z) fgets (x,y,z) 73# define fgets_unlocked(x,y,z) fgets (x,y,z)
69# endif 74# endif
70 75
76# if HAVE_DECL_FILENO_UNLOCKED || defined fileno_unlocked
77# undef fileno
78# define fileno(x) fileno_unlocked (x)
79# else
80# define fileno_unlocked(x) fileno (x)
81# endif
82
71# if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked 83# if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked
72# undef fputc 84# undef fputc
73# define fputc(x,y) fputc_unlocked (x,y) 85# define fputc(x,y) fputc_unlocked (x,y)
@@ -96,7 +108,7 @@
96# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) 108# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
97# endif 109# endif
98 110
99# if HAVE_DECL_GETC_UNLOCKED || defined get_unlocked 111# if HAVE_DECL_GETC_UNLOCKED || defined getc_unlocked
100# undef getc 112# undef getc
101# define getc(x) getc_unlocked (x) 113# define getc(x) getc_unlocked (x)
102# else 114# else
diff --git a/gl/unsetenv.c b/gl/unsetenv.c
index e5489490..dab1b90c 100644
--- a/gl/unsetenv.c
+++ b/gl/unsetenv.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992, 1995-2002, 2005-2023 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2002, 2005-2026 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
@@ -56,20 +56,44 @@ __libc_lock_define_initialized (static, envlock)
56int 56int
57unsetenv (const char *name) 57unsetenv (const char *name)
58{ 58{
59 size_t len;
60 char **ep;
61
62 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) 59 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
63 { 60 {
64 __set_errno (EINVAL); 61 __set_errno (EINVAL);
65 return -1; 62 return -1;
66 } 63 }
67 64
68 len = strlen (name); 65 size_t len = strlen (name);
66
67#if HAVE_DECL__PUTENV /* native Windows */
68 /* The Microsoft documentation
69 <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-wputenv>
70 says:
71 "Don't change an environment entry directly: instead,
72 use _putenv or _wputenv to change it."
73 Note: Microsoft's _putenv updates not only the contents of _environ but
74 also the contents of _wenviron, so that both are in kept in sync.
75
76 The way to remove an environment variable is to pass to _putenv a string
77 of the form "NAME=". (NB: This is a different convention than with glibc
78 putenv, which expects a string of the form "NAME"!) */
79 {
80 char *name_ = malloc (len + 2);
81 if (name_ == NULL)
82 return -1;
83 memcpy (name_, name, len);
84 name_[len] = '=';
85 name_[len + 1] = 0;
86 int putenv_result = _putenv (name_);
87 /* In this particular case it is OK to free() the argument passed to
88 _putenv. */
89 free (name_);
90 return putenv_result;
91 }
92#else
69 93
70 LOCK; 94 LOCK;
71 95
72 ep = __environ; 96 char **ep = __environ;
73 while (*ep != NULL) 97 while (*ep != NULL)
74 if (!strncmp (*ep, name, len) && (*ep)[len] == '=') 98 if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
75 { 99 {
@@ -87,6 +111,7 @@ unsetenv (const char *name)
87 UNLOCK; 111 UNLOCK;
88 112
89 return 0; 113 return 0;
114#endif
90} 115}
91 116
92#ifdef _LIBC 117#ifdef _LIBC
@@ -110,12 +135,12 @@ extern int unsetenv (const char *);
110int 135int
111rpl_unsetenv (const char *name) 136rpl_unsetenv (const char *name)
112{ 137{
113 int result = 0;
114 if (!name || !*name || strchr (name, '=')) 138 if (!name || !*name || strchr (name, '='))
115 { 139 {
116 errno = EINVAL; 140 errno = EINVAL;
117 return -1; 141 return -1;
118 } 142 }
143 int result = 0;
119 while (getenv (name)) 144 while (getenv (name))
120# if !VOID_UNSETENV 145# if !VOID_UNSETENV
121 result = 146 result =
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 277c39e3..85e30b90 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -1,5 +1,5 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 1999, 2002-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -29,6 +29,7 @@
29 Depends on FCHAR_T. 29 Depends on FCHAR_T.
30 DCHAR_CPY memcpy like function for DCHAR_T[] arrays. 30 DCHAR_CPY memcpy like function for DCHAR_T[] arrays.
31 DCHAR_SET memset like function for DCHAR_T[] arrays. 31 DCHAR_SET memset like function for DCHAR_T[] arrays.
32 DCHAR_STRLEN strlen like function for DCHAR_T[] arrays.
32 DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays. 33 DCHAR_MBSNLEN mbsnlen like function for DCHAR_T[] arrays.
33 SNPRINTF The system's snprintf (or similar) function. 34 SNPRINTF The system's snprintf (or similar) function.
34 This may be either snprintf or swprintf. 35 This may be either snprintf or swprintf.
@@ -64,7 +65,7 @@
64/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's 65/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's
65 use of CHECK macros expands to code that is too complicated for gcc 66 use of CHECK macros expands to code that is too complicated for gcc
66 -fanalyzer. Suppress the resulting bogus warnings. */ 67 -fanalyzer. Suppress the resulting bogus warnings. */
67#if 10 <= __GNUC__ 68#if _GL_GNUC_PREREQ (10, 0)
68# pragma GCC diagnostic ignored "-Wanalyzer-null-argument" 69# pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
69#endif 70#endif
70 71
@@ -80,14 +81,15 @@
80#endif 81#endif
81 82
82#include <locale.h> /* localeconv() */ 83#include <locale.h> /* localeconv() */
84#include <stdint.h> /* PTRDIFF_MAX */
83#include <stdio.h> /* snprintf(), sprintf() */ 85#include <stdio.h> /* snprintf(), sprintf() */
84#include <stdlib.h> /* abort(), malloc(), realloc(), free() */ 86#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
85#include <string.h> /* memcpy(), strlen() */ 87#include <string.h> /* memcpy(), strlen() */
86#include <wchar.h> /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb() */ 88#include <wchar.h> /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb(), mbszero() */
87#include <errno.h> /* errno */ 89#include <errno.h> /* errno */
88#include <limits.h> /* CHAR_BIT */ 90#include <limits.h> /* CHAR_BIT, INT_MAX, INT_WIDTH, LONG_WIDTH */
89#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ 91#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP, LDBL_MANT_DIG */
90#if HAVE_NL_LANGINFO 92#if HAVE_NL_LANGINFO || __GLIBC__ >= 2 || defined __CYGWIN__
91# include <langinfo.h> 93# include <langinfo.h>
92#endif 94#endif
93#ifndef VASNPRINTF 95#ifndef VASNPRINTF
@@ -103,29 +105,29 @@
103 105
104#include "attribute.h" 106#include "attribute.h"
105 107
106#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 108#if NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION)
107# include <math.h> 109# include <math.h>
108# include "float+.h" 110# include "float+.h"
109#endif 111#endif
110 112
111#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL 113#if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
112# include <math.h> 114# include <math.h>
113# include "isnand-nolibm.h" 115# include "isnand-nolibm.h"
114#endif 116#endif
115 117
116#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL 118#if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION)
117# include <math.h> 119# include <math.h>
118# include "isnanl-nolibm.h" 120# include "isnanl-nolibm.h"
119# include "fpucw.h" 121# include "fpucw.h"
120#endif 122#endif
121 123
122#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 124#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
123# include <math.h> 125# include <math.h>
124# include "isnand-nolibm.h" 126# include "isnand-nolibm.h"
125# include "printf-frexp.h" 127# include "printf-frexp.h"
126#endif 128#endif
127 129
128#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 130#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION)
129# include <math.h> 131# include <math.h>
130# include "isnanl-nolibm.h" 132# include "isnanl-nolibm.h"
131# include "printf-frexpl.h" 133# include "printf-frexpl.h"
@@ -138,8 +140,6 @@
138# define VASNPRINTF vasnwprintf 140# define VASNPRINTF vasnwprintf
139# define FCHAR_T wchar_t 141# define FCHAR_T wchar_t
140# define DCHAR_T wchar_t 142# define DCHAR_T wchar_t
141# define TCHAR_T wchar_t
142# define DCHAR_IS_TCHAR 1
143# define DIRECTIVE wchar_t_directive 143# define DIRECTIVE wchar_t_directive
144# define DIRECTIVES wchar_t_directives 144# define DIRECTIVES wchar_t_directives
145# define PRINTF_PARSE wprintf_parse 145# define PRINTF_PARSE wprintf_parse
@@ -159,24 +159,46 @@
159# endif 159# endif
160#endif 160#endif
161#if WIDE_CHAR_VERSION 161#if WIDE_CHAR_VERSION
162 /* TCHAR_T is wchar_t. */ 162 /* DCHAR_T is wchar_t. */
163# define USE_SNPRINTF 1 163# if HAVE_DECL__SNWPRINTF || (HAVE_SWPRINTF && HAVE_WORKING_SWPRINTF)
164# if HAVE_DECL__SNWPRINTF 164# define TCHAR_T wchar_t
165 /* On Windows, the function swprintf() has a different signature than 165# define DCHAR_IS_TCHAR 1
166 on Unix; we use the function _snwprintf() or - on mingw - snwprintf() 166# define USE_SNPRINTF 1
167 instead. The mingw function snwprintf() has fewer bugs than the 167# if HAVE_DECL__SNWPRINTF
168 MSVCRT function _snwprintf(), so prefer that. */ 168 /* On Windows, the function swprintf() has a different signature than
169# if defined __MINGW32__ 169 on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
170# define SNPRINTF snwprintf 170 instead. The mingw function snwprintf() has fewer bugs than the
171 MSVCRT function _snwprintf(), so prefer that. */
172# if defined __MINGW32__
173# define SNPRINTF snwprintf
174# else
175# define SNPRINTF _snwprintf
176# define USE_MSVC__SNPRINTF 1
177# endif
171# else 178# else
172# define SNPRINTF _snwprintf 179 /* Unix. */
173# define USE_MSVC__SNPRINTF 1 180# define SNPRINTF swprintf
174# endif 181# endif
175# else 182# else
176 /* Unix. */ 183 /* Old platforms such as NetBSD 3.0, OpenBSD 3.8, HP-UX 11.00. */
177# define SNPRINTF swprintf 184# define TCHAR_T char
178# endif 185# endif
179#else 186#endif
187#ifndef DCHAR_STRLEN
188# if WIDE_CHAR_VERSION
189# define DCHAR_STRLEN local_wcslen
190# else
191# define DCHAR_STRLEN strlen
192# endif
193#endif
194#ifndef DCHAR_MBSNLEN
195# if WIDE_CHAR_VERSION
196# define DCHAR_MBSNLEN wcsnlen
197# else
198# define DCHAR_MBSNLEN mbsnlen
199# endif
200#endif
201#if !WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR
180 /* TCHAR_T is char. */ 202 /* TCHAR_T is char. */
181 /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. 203 /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'.
182 But don't use it on BeOS, since BeOS snprintf produces no output if the 204 But don't use it on BeOS, since BeOS snprintf produces no output if the
@@ -210,6 +232,12 @@
210/* Here we need to call the native sprintf, not rpl_sprintf. */ 232/* Here we need to call the native sprintf, not rpl_sprintf. */
211#undef sprintf 233#undef sprintf
212 234
235/* macOS 12's "warning: 'sprintf' is deprecated" is pointless,
236 as sprintf is used safely here. */
237#if defined __APPLE__ && defined __MACH__ && _GL_GNUC_PREREQ (4, 2)
238# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
239#endif
240
213/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" 241/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
214 warnings in this file. Use -Dlint to suppress them. */ 242 warnings in this file. Use -Dlint to suppress them. */
215#if defined GCC_LINT || defined lint 243#if defined GCC_LINT || defined lint
@@ -218,6 +246,11 @@
218# define IF_LINT(Code) /* empty */ 246# define IF_LINT(Code) /* empty */
219#endif 247#endif
220 248
249/* Here we need only the most basic fields of 'struct lconv', and can
250 therefore use the system's localeconv() function, without needing a
251 dependency on module 'localeconv'. */
252#undef localeconv
253
221/* Avoid some warnings from "gcc -Wshadow". 254/* Avoid some warnings from "gcc -Wshadow".
222 This file doesn't use the exp() and remainder() functions. */ 255 This file doesn't use the exp() and remainder() functions. */
223#undef exp 256#undef exp
@@ -225,7 +258,7 @@
225#undef remainder 258#undef remainder
226#define remainder rem 259#define remainder rem
227 260
228#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION 261#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (PTRDIFF_MAX > INT_MAX)) && !WIDE_CHAR_VERSION
229# if (HAVE_STRNLEN && !defined _AIX) 262# if (HAVE_STRNLEN && !defined _AIX)
230# define local_strnlen strnlen 263# define local_strnlen strnlen
231# else 264# else
@@ -241,7 +274,7 @@ local_strnlen (const char *string, size_t maxlen)
241# endif 274# endif
242#endif 275#endif
243 276
244#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T 277#if ((!USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (PTRDIFF_MAX > INT_MAX) || !DCHAR_IS_TCHAR || NEED_WPRINTF_DIRECTIVE_LC) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || (PTRDIFF_MAX > INT_MAX) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)
245# if HAVE_WCSLEN 278# if HAVE_WCSLEN
246# define local_wcslen wcslen 279# define local_wcslen wcslen
247# else 280# else
@@ -264,8 +297,8 @@ local_wcslen (const wchar_t *s)
264# endif 297# endif
265#endif 298#endif
266 299
267#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION 300#if (!USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION
268# if HAVE_WCSNLEN 301# if HAVE_WCSNLEN && HAVE_DECL_WCSNLEN
269# define local_wcsnlen wcsnlen 302# define local_wcsnlen wcsnlen
270# else 303# else
271# ifndef local_wcsnlen_defined 304# ifndef local_wcsnlen_defined
@@ -283,12 +316,12 @@ local_wcsnlen (const wchar_t *s, size_t maxlen)
283# endif 316# endif
284#endif 317#endif
285 318
286#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || (ENABLE_WCHAR_FALLBACK && HAVE_WINT_T)) && !WIDE_CHAR_VERSION 319#if ((!USE_SNPRINTF || (PTRDIFF_MAX > INT_MAX) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) || ((NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T)) && !WIDE_CHAR_VERSION
287# if ENABLE_WCHAR_FALLBACK 320# if ENABLE_WCHAR_FALLBACK
288static size_t 321static size_t
289wctomb_fallback (char *s, wchar_t wc) 322wctomb_fallback (char *s, wchar_t wc)
290{ 323{
291 static char hex[16] = "0123456789ABCDEF"; 324 static char const hex[16] = "0123456789ABCDEF";
292 325
293 s[0] = '\\'; 326 s[0] = '\\';
294 if (sizeof (wchar_t) > 2 && wc > 0xffff) 327 if (sizeof (wchar_t) > 2 && wc > 0xffff)
@@ -351,7 +384,7 @@ local_wctomb (char *s, wchar_t wc)
351# endif 384# endif
352#endif 385#endif
353 386
354#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL 387#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION) || (NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT)
355/* Determine the decimal-point character according to the current locale. */ 388/* Determine the decimal-point character according to the current locale. */
356# ifndef decimal_point_char_defined 389# ifndef decimal_point_char_defined
357# define decimal_point_char_defined 1 390# define decimal_point_char_defined 1
@@ -378,7 +411,218 @@ decimal_point_char (void)
378# endif 411# endif
379#endif 412#endif
380 413
381#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE && !defined IN_LIBINTL 414#if (!WIDE_CHAR_VERSION && (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE)) || ((!WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR) && (NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT))
415/* Determine the thousands-separator character according to the current
416 locale.
417 It is a single multibyte character.
418 In glibc: 35x ".", 90x ",", 23x U+202F, 1x U+2019, 1x U+066C, on other
419 systems also U+00A0. */
420# ifndef thousands_separator_char_defined
421# define thousands_separator_char_defined 1
422static const char *
423thousands_separator_char (char stackbuf[10])
424{
425 /* Determine it in a multithread-safe way.
426 We know nl_langinfo is multithread-safe on glibc systems, on Mac OS X
427 systems, and on NetBSD, but is not required to be multithread-safe by
428 POSIX.
429 localeconv() is not guaranteed to be multithread-safe by POSIX either;
430 however, on native Windows it is (cf. test-localeconv-mt).
431 sprintf(), however, is multithread-safe. */
432# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__) || defined __NetBSD__)
433 return nl_langinfo (THOUSEP);
434# elif defined _WIN32 && !defined __CYGWIN__
435 return localeconv () -> thousands_sep;
436# else
437 sprintf (stackbuf, "%'.0f", 1000.0);
438 /* Now stackbuf = "1<thousep>000". */
439 stackbuf[strlen (stackbuf) - 3] = '\0';
440# if defined __sun
441 /* Solaris specific hack: Replace wrong result (0xC2 means U+00A0). */
442 if (streq (&stackbuf[1], "\302"))
443 strcpy (&stackbuf[1], MB_CUR_MAX > 1 ? "\302\240" : "\240");
444# endif
445 return &stackbuf[1];
446# endif
447}
448# endif
449#endif
450#if !WIDE_CHAR_VERSION && defined DCHAR_CONV_FROM_ENCODING && (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE)
451/* Determine the thousands-separator character, as a DCHAR_T[] array,
452 according to the current locale.
453 It is a single Unicode character. */
454# ifndef thousands_separator_DCHAR_defined
455# define thousands_separator_DCHAR_defined 1
456static const DCHAR_T *
457thousands_separator_DCHAR (DCHAR_T stackbuf[10])
458{
459 /* Determine it in a multithread-safe way. */
460 char tmpbuf[10];
461 const char *tmp = thousands_separator_char (tmpbuf);
462 if (*tmp != '\0')
463 {
464 /* Convert it from char[] to DCHAR_T[]. */
465 size_t converted_len = 10;
466 DCHAR_T *converted =
467 DCHAR_CONV_FROM_ENCODING (locale_charset (),
468 iconveh_question_mark,
469 tmp, strlen (tmp) + 1,
470 NULL,
471 stackbuf, &converted_len);
472 if (converted != NULL)
473 {
474 if (converted != stackbuf)
475 /* It should not be so long. */
476 abort ();
477 return stackbuf;
478 }
479 }
480 stackbuf[0] = 0;
481 return stackbuf;
482}
483# endif
484#endif
485/* Maximum number of 'char' in the char[] or DCHAR_T[] representation of the
486 thousands separator. */
487#define THOUSEP_CHAR_MAXLEN 3
488
489#if WIDE_CHAR_VERSION && ((NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) || ((NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT) && DCHAR_IS_TCHAR))
490/* Determine the thousands-separator character, as a wide character, according
491 to the current locale.
492 It is a single wide character. */
493# ifndef thousands_separator_wchar_defined
494# define thousands_separator_wchar_defined 1
495static const wchar_t *
496thousands_separator_wchar (wchar_t stackbuf[10])
497{
498# if __GLIBC__ >= 2 || defined __CYGWIN__
499 /* On glibc, in the unibyte locale fr_FR, the *wprintf routines use U+202F
500 as separator, which cannot be represented in the locale encoding. */
501 stackbuf[0] =
502 (wchar_t) (unsigned long) nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC);
503 stackbuf[1] = L'\0';
504 return stackbuf;
505# elif defined _WIN32 && !defined __CYGWIN__
506 const char *tmp = localeconv () -> thousands_sep;
507 if (*tmp != '\0')
508 {
509 mbstate_t state;
510 mbszero (&state);
511 if ((int) mbrtowc (&stackbuf[0], tmp, strlen (tmp), &state) > 0)
512 stackbuf[1] = L'\0';
513 else
514 stackbuf[0] = L'\0';
515 }
516 else
517 stackbuf[0] = L'\0';
518 return stackbuf;
519# elif defined __sun
520 /* Use sprintf, because swprintf retrieves a wrong value for the
521 thousands-separator wide character (e.g. (wchar_t) 0xffffffa0). */
522 char tmp[10];
523 sprintf (tmp, "%'.0f", 1000.0);
524 /* Now tmp = L"1<thousep>000". */
525 tmp[strlen (tmp) - 3] = '\0';
526 /* Solaris specific hack: Replace wrong result (0xC2 means U+00A0). */
527 if (streq (&tmp[1], "\302"))
528 strcpy (&tmp[1], MB_CUR_MAX > 1 ? "\302\240" : "\240");
529 if (tmp[1] != '\0')
530 {
531 mbstate_t state;
532 mbszero (&state);
533 if ((int) mbrtowc (&stackbuf[0], &tmp[1], strlen (&tmp[1]), &state) > 0)
534 stackbuf[1] = L'\0';
535 else
536 stackbuf[0] = L'\0';
537 }
538 else
539 stackbuf[0] = L'\0';
540 return stackbuf;
541# else
542 swprintf (stackbuf, 10, L"%'.0f", 1000.0);
543 /* Now stackbuf = L"1<thousep>000". */
544 stackbuf[local_wcslen (stackbuf) - 3] = '\0';
545 return &stackbuf[1];
546# endif
547}
548# endif
549#endif
550/* Maximum number of 'wchar_t' in the wchar_t[] representation of the thousands
551 separator. */
552#define THOUSEP_WCHAR_MAXLEN 1
553
554#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) || (NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT)
555# ifndef grouping_rule_defined
556# define grouping_rule_defined 1
557/* Determine the grouping rule.
558 * As specified in POSIX
559 * <https://pubs.opengroup.org/onlinepubs/9799919799/functions/localeconv.html>
560 * <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap07.html#tag_07_03_04>
561 * it is a string whose elements are 'signed char' values, where
562 * "Each integer specifies the number of digits in each group, with the initial
563 * integer defining the size of the group immediately preceding the decimal
564 * delimiter, and the following integers defining the preceding groups. If
565 * the last integer is not -1, then the size of the previous group (if any)
566 * shall be repeatedly used for the remainder of the digits. If the last
567 * integer is -1, then no further grouping shall be performed."
568 * Platforms that have locales with grouping:
569 * glibc, FreeBSD, NetBSD, AIX, Solaris, Cygwin, Haiku.
570 * Platforms that don't:
571 * musl libc, macOS, OpenBSD, Android, mingw, MSVC.
572 * Typical grouping rules on glibc:
573 * 136x 3 (fr_FR etc.)
574 * 4x 4 (cmn_TW etc.)
575 * 9x 3;2 (ta_IN etc.)
576 * 1x 2;2;2;3 (umn_US)
577 * 21x -1 (C etc.)
578 */
579static const signed char *
580grouping_rule (void)
581{
582 /* We know nl_langinfo is multithread-safe on glibc systems and on Cygwin,
583 but is not required to be multithread-safe by POSIX.
584 localeconv() is not guaranteed to be multithread-safe by POSIX either;
585 however, on all known systems it is (cf. test-localeconv-mt). */
586# if __GLIBC__ >= 2
587 return (const signed char *) nl_langinfo (GROUPING);
588# elif defined __CYGWIN__
589 return (const signed char *) nl_langinfo (_NL_NUMERIC_GROUPING);
590# else
591 return (const signed char *) localeconv () -> grouping;
592# endif
593}
594/* Determines the number of thousands-separators to be inserted in a digit
595 sequence with ndigits digits (before the decimal point). */
596static size_t
597num_thousands_separators (const signed char *grouping, size_t ndigits)
598{
599 const signed char *g = grouping;
600 int h = *g;
601 if (h <= 0 || ndigits == 0)
602 return 0;
603 size_t insert = 0;
604 for (;;)
605 {
606 /* Invariant: here h == *g, h > 0, ndigits > 0. */
607 if (g[1] == 0)
608 /* h repeats endlessly. */
609 return insert + (ndigits - 1) / h;
610 /* h does not repeat. */
611 if (ndigits <= h)
612 return insert;
613 ndigits -= h;
614 insert++;
615 g++;
616 h = *g;
617 if (h < 0)
618 /* No further grouping. */
619 return insert;
620 }
621}
622# endif
623#endif
624
625#if NEED_PRINTF_INFINITE_DOUBLE && !NEED_PRINTF_DOUBLE
382 626
383/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ 627/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */
384static int 628static int
@@ -389,7 +633,7 @@ is_infinite_or_zero (double x)
389 633
390#endif 634#endif
391 635
392#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL 636#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE
393 637
394/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */ 638/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */
395static int 639static int
@@ -400,7 +644,44 @@ is_infinite_or_zerol (long double x)
400 644
401#endif 645#endif
402 646
403#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 647#if NEED_PRINTF_LONG_DOUBLE
648
649/* Like frexpl, except that it supports even "unsupported" numbers. */
650# if (LDBL_MANT_DIG == 64 && (defined __ia64 || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))) && (defined __APPLE__ && defined __MACH__)
651/* Don't assume that frexpl can handle pseudo-denormals; it does not on
652 macOS 12/x86_64. Therefore test for a pseudo-denormal explicitly. */
653
654static
655long double safe_frexpl (long double x, int *exp)
656{
657 union
658 {
659 long double value;
660 struct { unsigned int mant_word[2]; unsigned short sign_exp_word; } r;
661 }
662 u;
663 u.value = x;
664 if (u.r.sign_exp_word == 0 && (u.r.mant_word[1] & 0x80000000u) != 0)
665 {
666 /* Pseudo-Denormal. */
667 *exp = LDBL_MIN_EXP;
668 u.r.sign_exp_word = 1 - LDBL_MIN_EXP;
669 return u.value;
670 }
671 else
672 return frexpl (x, exp);
673}
674
675# else
676# define safe_frexpl frexpl
677# endif
678
679#endif
680
681#if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE
682
683/* An indicator for a failed memory allocation. */
684# define NOMEM_PTR ((void *) (-1))
404 685
405/* Converting 'long double' to decimal without rare rounding bugs requires 686/* Converting 'long double' to decimal without rare rounding bugs requires
406 real bignums. We use the naming conventions of GNU gmp, but vastly simpler 687 real bignums. We use the naming conventions of GNU gmp, but vastly simpler
@@ -422,8 +703,8 @@ typedef struct
422} mpn_t; 703} mpn_t;
423 704
424/* Compute the product of two bignums >= 0. 705/* Compute the product of two bignums >= 0.
425 Return the allocated memory in case of success, NULL in case of memory 706 Return the allocated memory (possibly NULL) in case of success, NOMEM_PTR
426 allocation failure. */ 707 in case of memory allocation failure. */
427static void * 708static void *
428multiply (mpn_t src1, mpn_t src2, mpn_t *dest) 709multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
429{ 710{
@@ -451,26 +732,25 @@ multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
451 { 732 {
452 /* src1 or src2 is zero. */ 733 /* src1 or src2 is zero. */
453 dest->nlimbs = 0; 734 dest->nlimbs = 0;
454 dest->limbs = (mp_limb_t *) malloc (1); 735 dest->limbs = NULL;
455 } 736 }
456 else 737 else
457 { 738 {
458 /* Here 1 <= len1 <= len2. */ 739 /* Here 1 <= len1 <= len2. */
459 size_t dlen; 740 size_t dlen;
460 mp_limb_t *dp; 741 mp_limb_t *dp;
461 size_t k, i, j;
462 742
463 dlen = len1 + len2; 743 dlen = len1 + len2;
464 dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t)); 744 dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t));
465 if (dp == NULL) 745 if (dp == NULL)
466 return NULL; 746 return NOMEM_PTR;
467 for (k = len2; k > 0; ) 747 for (size_t k = len2; k > 0; )
468 dp[--k] = 0; 748 dp[--k] = 0;
469 for (i = 0; i < len1; i++) 749 for (size_t i = 0; i < len1; i++)
470 { 750 {
471 mp_limb_t digit1 = p1[i]; 751 mp_limb_t digit1 = p1[i];
472 mp_twolimb_t carry = 0; 752 mp_twolimb_t carry = 0;
473 for (j = 0; j < len2; j++) 753 for (size_t j = 0; j < len2; j++)
474 { 754 {
475 mp_limb_t digit2 = p2[j]; 755 mp_limb_t digit2 = p2[j];
476 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; 756 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
@@ -494,8 +774,8 @@ multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
494 the remainder. 774 the remainder.
495 Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd, 775 Finally, round-to-even is performed: If r > b/2 or if r = b/2 and q is odd,
496 q is incremented. 776 q is incremented.
497 Return the allocated memory in case of success, NULL in case of memory 777 Return the allocated memory (possibly NULL) in case of success, NOMEM_PTR
498 allocation failure. */ 778 in case of memory allocation failure. */
499static void * 779static void *
500divide (mpn_t a, mpn_t b, mpn_t *q) 780divide (mpn_t a, mpn_t b, mpn_t *q)
501{ 781{
@@ -554,7 +834,6 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
554 size_t a_len = a.nlimbs; 834 size_t a_len = a.nlimbs;
555 const mp_limb_t *b_ptr = b.limbs; 835 const mp_limb_t *b_ptr = b.limbs;
556 size_t b_len = b.nlimbs; 836 size_t b_len = b.nlimbs;
557 mp_limb_t *roomptr;
558 mp_limb_t *tmp_roomptr = NULL; 837 mp_limb_t *tmp_roomptr = NULL;
559 mp_limb_t *q_ptr; 838 mp_limb_t *q_ptr;
560 size_t q_len; 839 size_t q_len;
@@ -564,9 +843,9 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
564 /* Allocate room for a_len+2 digits. 843 /* Allocate room for a_len+2 digits.
565 (Need a_len+1 digits for the real division and 1 more digit for the 844 (Need a_len+1 digits for the real division and 1 more digit for the
566 final rounding of q.) */ 845 final rounding of q.) */
567 roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t)); 846 mp_limb_t *roomptr = (mp_limb_t *) malloc ((a_len + 2) * sizeof (mp_limb_t));
568 if (roomptr == NULL) 847 if (roomptr == NULL)
569 return NULL; 848 return NOMEM_PTR;
570 849
571 /* Normalise a. */ 850 /* Normalise a. */
572 while (a_len > 0 && a_ptr[a_len - 1] == 0) 851 while (a_len > 0 && a_ptr[a_len - 1] == 0)
@@ -606,8 +885,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
606 mp_limb_t remainder = 0; 885 mp_limb_t remainder = 0;
607 const mp_limb_t *sourceptr = a_ptr + a_len; 886 const mp_limb_t *sourceptr = a_ptr + a_len;
608 mp_limb_t *destptr = q_ptr + a_len; 887 mp_limb_t *destptr = q_ptr + a_len;
609 size_t count; 888 for (size_t count = a_len; count > 0; count--)
610 for (count = a_len; count > 0; count--)
611 { 889 {
612 mp_twolimb_t num = 890 mp_twolimb_t num =
613 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; 891 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
@@ -702,14 +980,13 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
702 if (tmp_roomptr == NULL) 980 if (tmp_roomptr == NULL)
703 { 981 {
704 free (roomptr); 982 free (roomptr);
705 return NULL; 983 return NOMEM_PTR;
706 } 984 }
707 { 985 {
708 const mp_limb_t *sourceptr = b_ptr; 986 const mp_limb_t *sourceptr = b_ptr;
709 mp_limb_t *destptr = tmp_roomptr; 987 mp_limb_t *destptr = tmp_roomptr;
710 mp_twolimb_t accu = 0; 988 mp_twolimb_t accu = 0;
711 size_t count; 989 for (size_t count = b_len; count > 0; count--)
712 for (count = b_len; count > 0; count--)
713 { 990 {
714 accu += (mp_twolimb_t) *sourceptr++ << s; 991 accu += (mp_twolimb_t) *sourceptr++ << s;
715 *destptr++ = (mp_limb_t) accu; 992 *destptr++ = (mp_limb_t) accu;
@@ -736,8 +1013,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
736 const mp_limb_t *sourceptr = a_ptr; 1013 const mp_limb_t *sourceptr = a_ptr;
737 mp_limb_t *destptr = r_ptr; 1014 mp_limb_t *destptr = r_ptr;
738 mp_twolimb_t accu = 0; 1015 mp_twolimb_t accu = 0;
739 size_t count; 1016 for (size_t count = a_len; count > 0; count--)
740 for (count = a_len; count > 0; count--)
741 { 1017 {
742 accu += (mp_twolimb_t) *sourceptr++ << s; 1018 accu += (mp_twolimb_t) *sourceptr++ << s;
743 *destptr++ = (mp_limb_t) accu; 1019 *destptr++ = (mp_limb_t) accu;
@@ -813,8 +1089,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
813 const mp_limb_t *sourceptr = b_ptr; 1089 const mp_limb_t *sourceptr = b_ptr;
814 mp_limb_t *destptr = r_ptr + j; 1090 mp_limb_t *destptr = r_ptr + j;
815 mp_twolimb_t carry = 0; 1091 mp_twolimb_t carry = 0;
816 size_t count; 1092 for (size_t count = b_len; count > 0; count--)
817 for (count = b_len; count > 0; count--)
818 { 1093 {
819 /* Here 0 <= carry <= q*. */ 1094 /* Here 0 <= carry <= q*. */
820 carry = 1095 carry =
@@ -838,8 +1113,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
838 const mp_limb_t *sourceptr = b_ptr; 1113 const mp_limb_t *sourceptr = b_ptr;
839 mp_limb_t *destptr = r_ptr + j; 1114 mp_limb_t *destptr = r_ptr + j;
840 mp_limb_t carry = 0; 1115 mp_limb_t carry = 0;
841 size_t count; 1116 for (size_t count = b_len; count > 0; count--)
842 for (count = b_len; count > 0; count--)
843 { 1117 {
844 mp_limb_t source1 = *sourceptr++; 1118 mp_limb_t source1 = *sourceptr++;
845 mp_limb_t source2 = *destptr; 1119 mp_limb_t source2 = *destptr;
@@ -871,8 +1145,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
871 { 1145 {
872 mp_limb_t ptr = r_ptr + r_len; 1146 mp_limb_t ptr = r_ptr + r_len;
873 mp_twolimb_t accu = 0; 1147 mp_twolimb_t accu = 0;
874 size_t count; 1148 for (size_t count = r_len; count > 0; count--)
875 for (count = r_len; count > 0; count--)
876 { 1149 {
877 accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; 1150 accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
878 accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); 1151 accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
@@ -887,29 +1160,25 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
887 /* Compare r << 1 with b. */ 1160 /* Compare r << 1 with b. */
888 if (r_len > b_len) 1161 if (r_len > b_len)
889 goto increment_q; 1162 goto increment_q;
890 { 1163 for (size_t i = b_len;;)
891 size_t i; 1164 {
892 for (i = b_len;;) 1165 mp_limb_t r_i =
893 { 1166 (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
894 mp_limb_t r_i = 1167 | (i < r_len ? r_ptr[i] << 1 : 0);
895 (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) 1168 mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
896 | (i < r_len ? r_ptr[i] << 1 : 0); 1169 if (r_i > b_i)
897 mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); 1170 goto increment_q;
898 if (r_i > b_i) 1171 if (r_i < b_i)
899 goto increment_q; 1172 goto keep_q;
900 if (r_i < b_i) 1173 if (i == 0)
901 goto keep_q; 1174 break;
902 if (i == 0) 1175 i--;
903 break; 1176 }
904 i--;
905 }
906 }
907 if (q_len > 0 && ((q_ptr[0] & 1) != 0)) 1177 if (q_len > 0 && ((q_ptr[0] & 1) != 0))
908 /* q is odd. */ 1178 /* q is odd. */
909 increment_q: 1179 increment_q:
910 { 1180 {
911 size_t i; 1181 for (size_t i = 0; i < q_len; i++)
912 for (i = 0; i < q_len; i++)
913 if (++(q_ptr[i]) != 0) 1182 if (++(q_ptr[i]) != 0)
914 goto keep_q; 1183 goto keep_q;
915 q_ptr[q_len++] = 1; 1184 q_ptr[q_len++] = 1;
@@ -921,6 +1190,14 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
921 return roomptr; 1190 return roomptr;
922} 1191}
923 1192
1193/* Avoid pointless GCC warning "argument 1 value '18446744073709551615' exceeds
1194 maximum object size 9223372036854775807", triggered by the use of xsum as
1195 argument of malloc. */
1196# if _GL_GNUC_PREREQ (7, 0)
1197# pragma GCC diagnostic push
1198# pragma GCC diagnostic ignored "-Walloc-size-larger-than="
1199# endif
1200
924/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal 1201/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal
925 representation. 1202 representation.
926 Destroys the contents of a. 1203 Destroys the contents of a.
@@ -947,8 +1224,7 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
947 /* Divide a by 10^9, in-place. */ 1224 /* Divide a by 10^9, in-place. */
948 mp_limb_t remainder = 0; 1225 mp_limb_t remainder = 0;
949 mp_limb_t *ptr = a_ptr + a_len; 1226 mp_limb_t *ptr = a_ptr + a_len;
950 size_t count; 1227 for (size_t count = a_len; count > 0; count--)
951 for (count = a_len; count > 0; count--)
952 { 1228 {
953 mp_twolimb_t num = 1229 mp_twolimb_t num =
954 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; 1230 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
@@ -956,7 +1232,7 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
956 remainder = num % 1000000000; 1232 remainder = num % 1000000000;
957 } 1233 }
958 /* Store the remainder as 9 decimal digits. */ 1234 /* Store the remainder as 9 decimal digits. */
959 for (count = 9; count > 0; count--) 1235 for (size_t count = 9; count > 0; count--)
960 { 1236 {
961 *d_ptr++ = '0' + (remainder % 10); 1237 *d_ptr++ = '0' + (remainder % 10);
962 remainder = remainder / 10; 1238 remainder = remainder / 10;
@@ -977,6 +1253,10 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
977 return c_ptr; 1253 return c_ptr;
978} 1254}
979 1255
1256# if _GL_GNUC_PREREQ (7, 0)
1257# pragma GCC diagnostic pop
1258# endif
1259
980# if NEED_PRINTF_LONG_DOUBLE 1260# if NEED_PRINTF_LONG_DOUBLE
981 1261
982/* Assuming x is finite and >= 0: 1262/* Assuming x is finite and >= 0:
@@ -986,18 +1266,15 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
986static void * 1266static void *
987decode_long_double (long double x, int *ep, mpn_t *mp) 1267decode_long_double (long double x, int *ep, mpn_t *mp)
988{ 1268{
989 mpn_t m;
990 int exp;
991 long double y;
992 size_t i;
993
994 /* Allocate memory for result. */ 1269 /* Allocate memory for result. */
1270 mpn_t m;
995 m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; 1271 m.nlimbs = (LDBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
996 m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); 1272 m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t));
997 if (m.limbs == NULL) 1273 if (m.limbs == NULL)
998 return NULL; 1274 return NULL;
999 /* Split into exponential part and mantissa. */ 1275 /* Split into exponential part and mantissa. */
1000 y = frexpl (x, &exp); 1276 int exp;
1277 long double y = safe_frexpl (x, &exp);
1001 if (!(y >= 0.0L && y < 1.0L)) 1278 if (!(y >= 0.0L && y < 1.0L))
1002 abort (); 1279 abort ();
1003 /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the 1280 /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the
@@ -1035,7 +1312,7 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
1035 } 1312 }
1036# endif 1313# endif
1037# endif 1314# endif
1038 for (i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) 1315 for (size_t i = LDBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
1039 { 1316 {
1040 mp_limb_t hi, lo; 1317 mp_limb_t hi, lo;
1041 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); 1318 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
@@ -1074,18 +1351,15 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
1074static void * 1351static void *
1075decode_double (double x, int *ep, mpn_t *mp) 1352decode_double (double x, int *ep, mpn_t *mp)
1076{ 1353{
1077 mpn_t m;
1078 int exp;
1079 double y;
1080 size_t i;
1081
1082 /* Allocate memory for result. */ 1354 /* Allocate memory for result. */
1355 mpn_t m;
1083 m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; 1356 m.nlimbs = (DBL_MANT_BIT + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
1084 m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t)); 1357 m.limbs = (mp_limb_t *) malloc (m.nlimbs * sizeof (mp_limb_t));
1085 if (m.limbs == NULL) 1358 if (m.limbs == NULL)
1086 return NULL; 1359 return NULL;
1087 /* Split into exponential part and mantissa. */ 1360 /* Split into exponential part and mantissa. */
1088 y = frexp (x, &exp); 1361 int exp;
1362 double y = frexp (x, &exp);
1089 if (!(y >= 0.0 && y < 1.0)) 1363 if (!(y >= 0.0 && y < 1.0))
1090 abort (); 1364 abort ();
1091 /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the 1365 /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the
@@ -1123,7 +1397,7 @@ decode_double (double x, int *ep, mpn_t *mp)
1123 } 1397 }
1124# endif 1398# endif
1125# endif 1399# endif
1126 for (i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; ) 1400 for (size_t i = DBL_MANT_BIT / GMP_LIMB_BITS; i > 0; )
1127 { 1401 {
1128 mp_limb_t hi, lo; 1402 mp_limb_t hi, lo;
1129 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); 1403 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
@@ -1158,26 +1432,11 @@ decode_double (double x, int *ep, mpn_t *mp)
1158static char * 1432static char *
1159scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) 1433scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1160{ 1434{
1161 int s;
1162 size_t extra_zeroes;
1163 unsigned int abs_n;
1164 unsigned int abs_s;
1165 mp_limb_t *pow5_ptr;
1166 size_t pow5_len;
1167 unsigned int s_limbs;
1168 unsigned int s_bits;
1169 mpn_t pow5;
1170 mpn_t z;
1171 void *z_memory;
1172 char *digits;
1173
1174 if (memory == NULL)
1175 return NULL;
1176 /* x = 2^e * m, hence 1435 /* x = 2^e * m, hence
1177 y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m) 1436 y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m)
1178 = round (2^s * 5^n * m). */ 1437 = round (2^s * 5^n * m). */
1179 s = e + n; 1438 int s = e + n;
1180 extra_zeroes = 0; 1439 size_t extra_zeroes = 0;
1181 /* Factor out a common power of 10 if possible. */ 1440 /* Factor out a common power of 10 if possible. */
1182 if (s > 0 && n > 0) 1441 if (s > 0 && n > 0)
1183 { 1442 {
@@ -1190,11 +1449,12 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1190 z = round (2^s * 5^n * m). */ 1449 z = round (2^s * 5^n * m). */
1191 /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same 1450 /* Compute 5^|n|, possibly shifted by |s| bits if n and s have the same
1192 sign. 2.322 is slightly larger than log(5)/log(2). */ 1451 sign. 2.322 is slightly larger than log(5)/log(2). */
1193 abs_n = (n >= 0 ? n : -n); 1452 unsigned int abs_n = (n >= 0 ? n : -n);
1194 abs_s = (s >= 0 ? s : -s); 1453 unsigned int abs_s = (s >= 0 ? s : -s);
1195 pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1 1454 mp_limb_t *pow5_ptr =
1196 + abs_s / GMP_LIMB_BITS + 1) 1455 (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
1197 * sizeof (mp_limb_t)); 1456 + abs_s / GMP_LIMB_BITS + 1)
1457 * sizeof (mp_limb_t));
1198 if (pow5_ptr == NULL) 1458 if (pow5_ptr == NULL)
1199 { 1459 {
1200 free (memory); 1460 free (memory);
@@ -1202,7 +1462,7 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1202 } 1462 }
1203 /* Initialize with 1. */ 1463 /* Initialize with 1. */
1204 pow5_ptr[0] = 1; 1464 pow5_ptr[0] = 1;
1205 pow5_len = 1; 1465 size_t pow5_len = 1;
1206 /* Multiply with 5^|n|. */ 1466 /* Multiply with 5^|n|. */
1207 if (abs_n > 0) 1467 if (abs_n > 0)
1208 { 1468 {
@@ -1211,13 +1471,11 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1211 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 1471 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
1212 48828125, 244140625, 1220703125 1472 48828125, 244140625, 1220703125
1213 }; 1473 };
1214 unsigned int n13; 1474 for (unsigned int n13 = 0; n13 <= abs_n; n13 += 13)
1215 for (n13 = 0; n13 <= abs_n; n13 += 13)
1216 { 1475 {
1217 mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; 1476 mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
1218 size_t j;
1219 mp_twolimb_t carry = 0; 1477 mp_twolimb_t carry = 0;
1220 for (j = 0; j < pow5_len; j++) 1478 for (size_t j = 0; j < pow5_len; j++)
1221 { 1479 {
1222 mp_limb_t digit2 = pow5_ptr[j]; 1480 mp_limb_t digit2 = pow5_ptr[j];
1223 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; 1481 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
@@ -1228,8 +1486,11 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1228 pow5_ptr[pow5_len++] = (mp_limb_t) carry; 1486 pow5_ptr[pow5_len++] = (mp_limb_t) carry;
1229 } 1487 }
1230 } 1488 }
1231 s_limbs = abs_s / GMP_LIMB_BITS; 1489 unsigned int s_limbs = abs_s / GMP_LIMB_BITS;
1232 s_bits = abs_s % GMP_LIMB_BITS; 1490 unsigned int s_bits = abs_s % GMP_LIMB_BITS;
1491 mpn_t pow5;
1492 mpn_t z;
1493 void *z_memory;
1233 if (n >= 0 ? s >= 0 : s <= 0) 1494 if (n >= 0 ? s >= 0 : s <= 0)
1234 { 1495 {
1235 /* Multiply with 2^|s|. */ 1496 /* Multiply with 2^|s|. */
@@ -1237,8 +1498,7 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1237 { 1498 {
1238 mp_limb_t *ptr = pow5_ptr; 1499 mp_limb_t *ptr = pow5_ptr;
1239 mp_twolimb_t accu = 0; 1500 mp_twolimb_t accu = 0;
1240 size_t count; 1501 for (size_t count = pow5_len; count > 0; count--)
1241 for (count = pow5_len; count > 0; count--)
1242 { 1502 {
1243 accu += (mp_twolimb_t) *ptr << s_bits; 1503 accu += (mp_twolimb_t) *ptr << s_bits;
1244 *ptr++ = (mp_limb_t) accu; 1504 *ptr++ = (mp_limb_t) accu;
@@ -1252,13 +1512,12 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1252 } 1512 }
1253 if (s_limbs > 0) 1513 if (s_limbs > 0)
1254 { 1514 {
1255 size_t count; 1515 for (size_t count = pow5_len; count > 0;)
1256 for (count = pow5_len; count > 0;)
1257 { 1516 {
1258 count--; 1517 count--;
1259 pow5_ptr[s_limbs + count] = pow5_ptr[count]; 1518 pow5_ptr[s_limbs + count] = pow5_ptr[count];
1260 } 1519 }
1261 for (count = s_limbs; count > 0;) 1520 for (size_t count = s_limbs; count > 0;)
1262 { 1521 {
1263 count--; 1522 count--;
1264 pow5_ptr[count] = 0; 1523 pow5_ptr[count] = 0;
@@ -1290,7 +1549,7 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1290 mpn_t denominator; 1549 mpn_t denominator;
1291 void *tmp_memory; 1550 void *tmp_memory;
1292 tmp_memory = multiply (m, pow5, &numerator); 1551 tmp_memory = multiply (m, pow5, &numerator);
1293 if (tmp_memory == NULL) 1552 if (tmp_memory == NOMEM_PTR)
1294 { 1553 {
1295 free (pow5_ptr); 1554 free (pow5_ptr);
1296 free (memory); 1555 free (memory);
@@ -1299,8 +1558,7 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1299 /* Construct 2^|s|. */ 1558 /* Construct 2^|s|. */
1300 { 1559 {
1301 mp_limb_t *ptr = pow5_ptr + pow5_len; 1560 mp_limb_t *ptr = pow5_ptr + pow5_len;
1302 size_t i; 1561 for (size_t i = 0; i < s_limbs; i++)
1303 for (i = 0; i < s_limbs; i++)
1304 ptr[i] = 0; 1562 ptr[i] = 0;
1305 ptr[s_limbs] = (mp_limb_t) 1 << s_bits; 1563 ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
1306 denominator.limbs = ptr; 1564 denominator.limbs = ptr;
@@ -1325,17 +1583,13 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1325 } 1583 }
1326 { 1584 {
1327 mp_limb_t *destptr = num_ptr; 1585 mp_limb_t *destptr = num_ptr;
1328 { 1586 for (size_t i = 0; i < s_limbs; i++)
1329 size_t i; 1587 *destptr++ = 0;
1330 for (i = 0; i < s_limbs; i++)
1331 *destptr++ = 0;
1332 }
1333 if (s_bits > 0) 1588 if (s_bits > 0)
1334 { 1589 {
1335 const mp_limb_t *sourceptr = m.limbs; 1590 const mp_limb_t *sourceptr = m.limbs;
1336 mp_twolimb_t accu = 0; 1591 mp_twolimb_t accu = 0;
1337 size_t count; 1592 for (size_t count = m.nlimbs; count > 0; count--)
1338 for (count = m.nlimbs; count > 0; count--)
1339 { 1593 {
1340 accu += (mp_twolimb_t) *sourceptr++ << s_bits; 1594 accu += (mp_twolimb_t) *sourceptr++ << s_bits;
1341 *destptr++ = (mp_limb_t) accu; 1595 *destptr++ = (mp_limb_t) accu;
@@ -1347,8 +1601,7 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1347 else 1601 else
1348 { 1602 {
1349 const mp_limb_t *sourceptr = m.limbs; 1603 const mp_limb_t *sourceptr = m.limbs;
1350 size_t count; 1604 for (size_t count = m.nlimbs; count > 0; count--)
1351 for (count = m.nlimbs; count > 0; count--)
1352 *destptr++ = *sourceptr++; 1605 *destptr++ = *sourceptr++;
1353 } 1606 }
1354 numerator.limbs = num_ptr; 1607 numerator.limbs = num_ptr;
@@ -1363,9 +1616,9 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1363 1616
1364 /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */ 1617 /* Here y = round (x * 10^n) = z * 10^extra_zeroes. */
1365 1618
1366 if (z_memory == NULL) 1619 if (z_memory == NOMEM_PTR)
1367 return NULL; 1620 return NULL;
1368 digits = convert_to_decimal (z, extra_zeroes); 1621 char *digits = convert_to_decimal (z, extra_zeroes);
1369 free (z_memory); 1622 free (z_memory);
1370 return digits; 1623 return digits;
1371} 1624}
@@ -1380,10 +1633,13 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1380static char * 1633static char *
1381scale10_round_decimal_long_double (long double x, int n) 1634scale10_round_decimal_long_double (long double x, int n)
1382{ 1635{
1383 int e IF_LINT(= 0); 1636 int e;
1384 mpn_t m; 1637 mpn_t m;
1385 void *memory = decode_long_double (x, &e, &m); 1638 void *memory = decode_long_double (x, &e, &m);
1386 return scale10_round_decimal_decoded (e, m, memory, n); 1639 if (memory != NULL)
1640 return scale10_round_decimal_decoded (e, m, memory, n);
1641 else
1642 return NULL;
1387} 1643}
1388 1644
1389# endif 1645# endif
@@ -1398,10 +1654,13 @@ scale10_round_decimal_long_double (long double x, int n)
1398static char * 1654static char *
1399scale10_round_decimal_double (double x, int n) 1655scale10_round_decimal_double (double x, int n)
1400{ 1656{
1401 int e IF_LINT(= 0); 1657 int e;
1402 mpn_t m; 1658 mpn_t m;
1403 void *memory = decode_double (x, &e, &m); 1659 void *memory = decode_double (x, &e, &m);
1404 return scale10_round_decimal_decoded (e, m, memory, n); 1660 if (memory != NULL)
1661 return scale10_round_decimal_decoded (e, m, memory, n);
1662 else
1663 return NULL;
1405} 1664}
1406 1665
1407# endif 1666# endif
@@ -1414,13 +1673,9 @@ scale10_round_decimal_double (double x, int n)
1414static int 1673static int
1415floorlog10l (long double x) 1674floorlog10l (long double x)
1416{ 1675{
1417 int exp;
1418 long double y;
1419 double z;
1420 double l;
1421
1422 /* Split into exponential part and mantissa. */ 1676 /* Split into exponential part and mantissa. */
1423 y = frexpl (x, &exp); 1677 int exp;
1678 long double y = safe_frexpl (x, &exp);
1424 if (!(y >= 0.0L && y < 1.0L)) 1679 if (!(y >= 0.0L && y < 1.0L))
1425 abort (); 1680 abort ();
1426 if (y == 0.0L) 1681 if (y == 0.0L)
@@ -1461,8 +1716,8 @@ floorlog10l (long double x)
1461 if (!(y >= 0.5L && y < 1.0L)) 1716 if (!(y >= 0.5L && y < 1.0L))
1462 abort (); 1717 abort ();
1463 /* Compute an approximation for l = log2(x) = exp + log2(y). */ 1718 /* Compute an approximation for l = log2(x) = exp + log2(y). */
1464 l = exp; 1719 double l = exp;
1465 z = y; 1720 double z = y;
1466 if (z < 0.70710678118654752444) 1721 if (z < 0.70710678118654752444)
1467 { 1722 {
1468 z *= 1.4142135623730950488; 1723 z *= 1.4142135623730950488;
@@ -1505,13 +1760,9 @@ floorlog10l (long double x)
1505static int 1760static int
1506floorlog10 (double x) 1761floorlog10 (double x)
1507{ 1762{
1508 int exp;
1509 double y;
1510 double z;
1511 double l;
1512
1513 /* Split into exponential part and mantissa. */ 1763 /* Split into exponential part and mantissa. */
1514 y = frexp (x, &exp); 1764 int exp;
1765 double y = frexp (x, &exp);
1515 if (!(y >= 0.0 && y < 1.0)) 1766 if (!(y >= 0.0 && y < 1.0))
1516 abort (); 1767 abort ();
1517 if (y == 0.0) 1768 if (y == 0.0)
@@ -1552,8 +1803,8 @@ floorlog10 (double x)
1552 if (!(y >= 0.5 && y < 1.0)) 1803 if (!(y >= 0.5 && y < 1.0))
1553 abort (); 1804 abort ();
1554 /* Compute an approximation for l = log2(x) = exp + log2(y). */ 1805 /* Compute an approximation for l = log2(x) = exp + log2(y). */
1555 l = exp; 1806 double l = exp;
1556 z = y; 1807 double z = y;
1557 if (z < 0.70710678118654752444) 1808 if (z < 0.70710678118654752444)
1558 { 1809 {
1559 z *= 1.4142135623730950488; 1810 z *= 1.4142135623730950488;
@@ -1604,7 +1855,7 @@ is_borderline (const char *digits, size_t precision)
1604 1855
1605#endif 1856#endif
1606 1857
1607#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF 1858#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
1608 1859
1609/* Use a different function name, to make it possible that the 'wchar_t' 1860/* Use a different function name, to make it possible that the 'wchar_t'
1610 parametrization and the 'char' parametrization get compiled in the same 1861 parametrization and the 'char' parametrization get compiled in the same
@@ -1627,51 +1878,323 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1627 switch (conversion) 1878 switch (conversion)
1628 { 1879 {
1629 case 'd': case 'i': case 'u': 1880 case 'd': case 'i': case 'u':
1630 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1881 switch (type)
1631 tmp_length = 1882 {
1632 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1883 default:
1633 * 0.30103 /* binary -> decimal */ 1884 tmp_length =
1634 ) 1885 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
1635 + 1; /* turn floor into ceil */ 1886 * 0.30103 /* binary -> decimal */
1636 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) 1887 )
1637 tmp_length = 1888 + 1; /* turn floor into ceil */
1638 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1889 break;
1639 * 0.30103 /* binary -> decimal */ 1890 case TYPE_LONGINT:
1640 ) 1891 tmp_length =
1641 + 1; /* turn floor into ceil */ 1892 (unsigned int) (sizeof (long int) * CHAR_BIT
1642 else 1893 * 0.30103 /* binary -> decimal */
1643 tmp_length = 1894 )
1644 (unsigned int) (sizeof (unsigned int) * CHAR_BIT 1895 + 1; /* turn floor into ceil */
1645 * 0.30103 /* binary -> decimal */ 1896 break;
1646 ) 1897 case TYPE_ULONGINT:
1647 + 1; /* turn floor into ceil */ 1898 tmp_length =
1899 (unsigned int) (sizeof (unsigned long int) * CHAR_BIT
1900 * 0.30103 /* binary -> decimal */
1901 )
1902 + 1; /* turn floor into ceil */
1903 break;
1904 case TYPE_LONGLONGINT:
1905 tmp_length =
1906 (unsigned int) (sizeof (long long int) * CHAR_BIT
1907 * 0.30103 /* binary -> decimal */
1908 )
1909 + 1; /* turn floor into ceil */
1910 break;
1911 case TYPE_ULONGLONGINT:
1912 tmp_length =
1913 (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT
1914 * 0.30103 /* binary -> decimal */
1915 )
1916 + 1; /* turn floor into ceil */
1917 break;
1918 case TYPE_INT8_T:
1919 tmp_length =
1920 (unsigned int) (sizeof (int8_t) * CHAR_BIT
1921 * 0.30103 /* binary -> decimal */
1922 )
1923 + 1; /* turn floor into ceil */
1924 break;
1925 case TYPE_UINT8_T:
1926 tmp_length =
1927 (unsigned int) (sizeof (uint8_t) * CHAR_BIT
1928 * 0.30103 /* binary -> decimal */
1929 )
1930 + 1; /* turn floor into ceil */
1931 break;
1932 case TYPE_INT16_T:
1933 tmp_length =
1934 (unsigned int) (sizeof (int16_t) * CHAR_BIT
1935 * 0.30103 /* binary -> decimal */
1936 )
1937 + 1; /* turn floor into ceil */
1938 break;
1939 case TYPE_UINT16_T:
1940 tmp_length =
1941 (unsigned int) (sizeof (uint16_t) * CHAR_BIT
1942 * 0.30103 /* binary -> decimal */
1943 )
1944 + 1; /* turn floor into ceil */
1945 break;
1946 case TYPE_INT32_T:
1947 tmp_length =
1948 (unsigned int) (sizeof (int32_t) * CHAR_BIT
1949 * 0.30103 /* binary -> decimal */
1950 )
1951 + 1; /* turn floor into ceil */
1952 break;
1953 case TYPE_UINT32_T:
1954 tmp_length =
1955 (unsigned int) (sizeof (uint32_t) * CHAR_BIT
1956 * 0.30103 /* binary -> decimal */
1957 )
1958 + 1; /* turn floor into ceil */
1959 break;
1960 case TYPE_INT64_T:
1961 tmp_length =
1962 (unsigned int) (sizeof (int64_t) * CHAR_BIT
1963 * 0.30103 /* binary -> decimal */
1964 )
1965 + 1; /* turn floor into ceil */
1966 break;
1967 case TYPE_UINT64_T:
1968 tmp_length =
1969 (unsigned int) (sizeof (uint64_t) * CHAR_BIT
1970 * 0.30103 /* binary -> decimal */
1971 )
1972 + 1; /* turn floor into ceil */
1973 break;
1974 case TYPE_INT_FAST8_T:
1975 tmp_length =
1976 (unsigned int) (sizeof (int_fast8_t) * CHAR_BIT
1977 * 0.30103 /* binary -> decimal */
1978 )
1979 + 1; /* turn floor into ceil */
1980 break;
1981 case TYPE_UINT_FAST8_T:
1982 tmp_length =
1983 (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT
1984 * 0.30103 /* binary -> decimal */
1985 )
1986 + 1; /* turn floor into ceil */
1987 break;
1988 case TYPE_INT_FAST16_T:
1989 tmp_length =
1990 (unsigned int) (sizeof (int_fast16_t) * CHAR_BIT
1991 * 0.30103 /* binary -> decimal */
1992 )
1993 + 1; /* turn floor into ceil */
1994 break;
1995 case TYPE_UINT_FAST16_T:
1996 tmp_length =
1997 (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT
1998 * 0.30103 /* binary -> decimal */
1999 )
2000 + 1; /* turn floor into ceil */
2001 break;
2002 case TYPE_INT_FAST32_T:
2003 tmp_length =
2004 (unsigned int) (sizeof (int_fast32_t) * CHAR_BIT
2005 * 0.30103 /* binary -> decimal */
2006 )
2007 + 1; /* turn floor into ceil */
2008 break;
2009 case TYPE_UINT_FAST32_T:
2010 tmp_length =
2011 (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT
2012 * 0.30103 /* binary -> decimal */
2013 )
2014 + 1; /* turn floor into ceil */
2015 break;
2016 case TYPE_INT_FAST64_T:
2017 tmp_length =
2018 (unsigned int) (sizeof (int_fast64_t) * CHAR_BIT
2019 * 0.30103 /* binary -> decimal */
2020 )
2021 + 1; /* turn floor into ceil */
2022 break;
2023 case TYPE_UINT_FAST64_T:
2024 tmp_length =
2025 (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT
2026 * 0.30103 /* binary -> decimal */
2027 )
2028 + 1; /* turn floor into ceil */
2029 break;
2030 }
1648 if (tmp_length < precision) 2031 if (tmp_length < precision)
1649 tmp_length = precision; 2032 tmp_length = precision;
1650 /* Multiply by 2, as an estimate for FLAG_GROUP. */ 2033 /* Account for thousands separators. */
1651 tmp_length = xsum (tmp_length, tmp_length); 2034 if (flags & FLAG_GROUP)
2035 {
2036 /* A thousands separator needs to be inserted at most every 2 digits.
2037 This is the case in the ta_IN locale. */
2038# if WIDE_CHAR_VERSION
2039 tmp_length = xsum (tmp_length, tmp_length / 2 * THOUSEP_WCHAR_MAXLEN);
2040# else
2041 tmp_length = xsum (tmp_length, tmp_length / 2 * THOUSEP_CHAR_MAXLEN);
2042# endif
2043 }
1652 /* Add 1, to account for a leading sign. */ 2044 /* Add 1, to account for a leading sign. */
1653 tmp_length = xsum (tmp_length, 1); 2045 tmp_length = xsum (tmp_length, 1);
1654 break; 2046 break;
1655 2047
2048 case 'b':
2049 #if SUPPORT_GNU_PRINTF_DIRECTIVES \
2050 || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2)
2051 case 'B':
2052 #endif
2053 switch (type)
2054 {
2055 default:
2056 tmp_length =
2057 (unsigned int) (sizeof (unsigned int) * CHAR_BIT)
2058 + 1; /* turn floor into ceil */
2059 break;
2060 case TYPE_ULONGINT:
2061 tmp_length =
2062 (unsigned int) (sizeof (unsigned long int) * CHAR_BIT)
2063 + 1; /* turn floor into ceil */
2064 break;
2065 case TYPE_ULONGLONGINT:
2066 tmp_length =
2067 (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT)
2068 + 1; /* turn floor into ceil */
2069 break;
2070 case TYPE_UINT8_T:
2071 tmp_length =
2072 (unsigned int) (sizeof (uint8_t) * CHAR_BIT)
2073 + 1; /* turn floor into ceil */
2074 break;
2075 case TYPE_UINT16_T:
2076 tmp_length =
2077 (unsigned int) (sizeof (uint16_t) * CHAR_BIT)
2078 + 1; /* turn floor into ceil */
2079 break;
2080 case TYPE_UINT32_T:
2081 tmp_length =
2082 (unsigned int) (sizeof (uint32_t) * CHAR_BIT)
2083 + 1; /* turn floor into ceil */
2084 break;
2085 case TYPE_UINT64_T:
2086 tmp_length =
2087 (unsigned int) (sizeof (uint64_t) * CHAR_BIT)
2088 + 1; /* turn floor into ceil */
2089 break;
2090 case TYPE_UINT_FAST8_T:
2091 tmp_length =
2092 (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT)
2093 + 1; /* turn floor into ceil */
2094 break;
2095 case TYPE_UINT_FAST16_T:
2096 tmp_length =
2097 (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT)
2098 + 1; /* turn floor into ceil */
2099 break;
2100 case TYPE_UINT_FAST32_T:
2101 tmp_length =
2102 (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT)
2103 + 1; /* turn floor into ceil */
2104 break;
2105 case TYPE_UINT_FAST64_T:
2106 tmp_length =
2107 (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT)
2108 + 1; /* turn floor into ceil */
2109 break;
2110 }
2111 if (tmp_length < precision)
2112 tmp_length = precision;
2113 /* Add 2, to account for a prefix from the alternate form. */
2114 tmp_length = xsum (tmp_length, 2);
2115 break;
2116
1656 case 'o': 2117 case 'o':
1657 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 2118 switch (type)
1658 tmp_length = 2119 {
1659 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 2120 default:
1660 * 0.333334 /* binary -> octal */ 2121 tmp_length =
1661 ) 2122 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
1662 + 1; /* turn floor into ceil */ 2123 * 0.333334 /* binary -> octal */
1663 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) 2124 )
1664 tmp_length = 2125 + 1; /* turn floor into ceil */
1665 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 2126 break;
1666 * 0.333334 /* binary -> octal */ 2127 case TYPE_ULONGINT:
1667 ) 2128 tmp_length =
1668 + 1; /* turn floor into ceil */ 2129 (unsigned int) (sizeof (unsigned long int) * CHAR_BIT
1669 else 2130 * 0.333334 /* binary -> octal */
1670 tmp_length = 2131 )
1671 (unsigned int) (sizeof (unsigned int) * CHAR_BIT 2132 + 1; /* turn floor into ceil */
1672 * 0.333334 /* binary -> octal */ 2133 break;
1673 ) 2134 case TYPE_ULONGLONGINT:
1674 + 1; /* turn floor into ceil */ 2135 tmp_length =
2136 (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT
2137 * 0.333334 /* binary -> octal */
2138 )
2139 + 1; /* turn floor into ceil */
2140 break;
2141 case TYPE_UINT8_T:
2142 tmp_length =
2143 (unsigned int) (sizeof (uint8_t) * CHAR_BIT
2144 * 0.333334 /* binary -> octal */
2145 )
2146 + 1; /* turn floor into ceil */
2147 break;
2148 case TYPE_UINT16_T:
2149 tmp_length =
2150 (unsigned int) (sizeof (uint16_t) * CHAR_BIT
2151 * 0.333334 /* binary -> octal */
2152 )
2153 + 1; /* turn floor into ceil */
2154 break;
2155 case TYPE_UINT32_T:
2156 tmp_length =
2157 (unsigned int) (sizeof (uint32_t) * CHAR_BIT
2158 * 0.333334 /* binary -> octal */
2159 )
2160 + 1; /* turn floor into ceil */
2161 break;
2162 case TYPE_UINT64_T:
2163 tmp_length =
2164 (unsigned int) (sizeof (uint64_t) * CHAR_BIT
2165 * 0.333334 /* binary -> octal */
2166 )
2167 + 1; /* turn floor into ceil */
2168 break;
2169 case TYPE_UINT_FAST8_T:
2170 tmp_length =
2171 (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT
2172 * 0.333334 /* binary -> octal */
2173 )
2174 + 1; /* turn floor into ceil */
2175 break;
2176 case TYPE_UINT_FAST16_T:
2177 tmp_length =
2178 (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT
2179 * 0.333334 /* binary -> octal */
2180 )
2181 + 1; /* turn floor into ceil */
2182 break;
2183 case TYPE_UINT_FAST32_T:
2184 tmp_length =
2185 (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT
2186 * 0.333334 /* binary -> octal */
2187 )
2188 + 1; /* turn floor into ceil */
2189 break;
2190 case TYPE_UINT_FAST64_T:
2191 tmp_length =
2192 (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT
2193 * 0.333334 /* binary -> octal */
2194 )
2195 + 1; /* turn floor into ceil */
2196 break;
2197 }
1675 if (tmp_length < precision) 2198 if (tmp_length < precision)
1676 tmp_length = precision; 2199 tmp_length = precision;
1677 /* Add 1, to account for a leading sign. */ 2200 /* Add 1, to account for a leading sign. */
@@ -1679,36 +2202,104 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1679 break; 2202 break;
1680 2203
1681 case 'x': case 'X': 2204 case 'x': case 'X':
1682 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 2205 switch (type)
1683 tmp_length = 2206 {
1684 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 2207 default:
1685 * 0.25 /* binary -> hexadecimal */ 2208 tmp_length =
1686 ) 2209 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
1687 + 1; /* turn floor into ceil */ 2210 * 0.25 /* binary -> hexadecimal */
1688 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) 2211 )
1689 tmp_length = 2212 + 1; /* turn floor into ceil */
1690 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 2213 break;
1691 * 0.25 /* binary -> hexadecimal */ 2214 case TYPE_ULONGINT:
1692 ) 2215 tmp_length =
1693 + 1; /* turn floor into ceil */ 2216 (unsigned int) (sizeof (unsigned long int) * CHAR_BIT
1694 else 2217 * 0.25 /* binary -> hexadecimal */
1695 tmp_length = 2218 )
1696 (unsigned int) (sizeof (unsigned int) * CHAR_BIT 2219 + 1; /* turn floor into ceil */
1697 * 0.25 /* binary -> hexadecimal */ 2220 break;
1698 ) 2221 case TYPE_ULONGLONGINT:
1699 + 1; /* turn floor into ceil */ 2222 tmp_length =
2223 (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT
2224 * 0.25 /* binary -> hexadecimal */
2225 )
2226 + 1; /* turn floor into ceil */
2227 break;
2228 case TYPE_UINT8_T:
2229 tmp_length =
2230 (unsigned int) (sizeof (uint8_t) * CHAR_BIT
2231 * 0.25 /* binary -> hexadecimal */
2232 )
2233 + 1; /* turn floor into ceil */
2234 break;
2235 case TYPE_UINT16_T:
2236 tmp_length =
2237 (unsigned int) (sizeof (uint16_t) * CHAR_BIT
2238 * 0.25 /* binary -> hexadecimal */
2239 )
2240 + 1; /* turn floor into ceil */
2241 break;
2242 case TYPE_UINT32_T:
2243 tmp_length =
2244 (unsigned int) (sizeof (uint32_t) * CHAR_BIT
2245 * 0.25 /* binary -> hexadecimal */
2246 )
2247 + 1; /* turn floor into ceil */
2248 break;
2249 case TYPE_UINT64_T:
2250 tmp_length =
2251 (unsigned int) (sizeof (uint64_t) * CHAR_BIT
2252 * 0.25 /* binary -> hexadecimal */
2253 )
2254 + 1; /* turn floor into ceil */
2255 break;
2256 case TYPE_UINT_FAST8_T:
2257 tmp_length =
2258 (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT
2259 * 0.25 /* binary -> hexadecimal */
2260 )
2261 + 1; /* turn floor into ceil */
2262 break;
2263 case TYPE_UINT_FAST16_T:
2264 tmp_length =
2265 (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT
2266 * 0.25 /* binary -> hexadecimal */
2267 )
2268 + 1; /* turn floor into ceil */
2269 break;
2270 case TYPE_UINT_FAST32_T:
2271 tmp_length =
2272 (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT
2273 * 0.25 /* binary -> hexadecimal */
2274 )
2275 + 1; /* turn floor into ceil */
2276 break;
2277 case TYPE_UINT_FAST64_T:
2278 tmp_length =
2279 (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT
2280 * 0.25 /* binary -> hexadecimal */
2281 )
2282 + 1; /* turn floor into ceil */
2283 break;
2284 }
1700 if (tmp_length < precision) 2285 if (tmp_length < precision)
1701 tmp_length = precision; 2286 tmp_length = precision;
1702 /* Add 2, to account for a leading sign or alternate form. */ 2287 /* Add 2, to account for a prefix from the alternate form. */
1703 tmp_length = xsum (tmp_length, 2); 2288 tmp_length = xsum (tmp_length, 2);
1704 break; 2289 break;
1705 2290
2291 case 'e': case 'E':
2292 tmp_length =
2293 12; /* sign, decimal point, exponent etc. */
2294 tmp_length = xsum (tmp_length, precision);
2295 break;
2296
1706 case 'f': case 'F': 2297 case 'f': case 'F':
1707 if (type == TYPE_LONGDOUBLE) 2298 if (type == TYPE_LONGDOUBLE)
1708 tmp_length = 2299 tmp_length =
1709 (unsigned int) (LDBL_MAX_EXP 2300 (unsigned int) (LDBL_MAX_EXP
1710 * 0.30103 /* binary -> decimal */ 2301 * 0.30103 /* binary -> decimal */
1711 * 2 /* estimate for FLAG_GROUP */ 2302 * 0.5 * 3 /* estimate for FLAG_GROUP */
1712 ) 2303 )
1713 + 1 /* turn floor into ceil */ 2304 + 1 /* turn floor into ceil */
1714 + 10; /* sign, decimal point etc. */ 2305 + 10; /* sign, decimal point etc. */
@@ -1716,17 +2307,20 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1716 tmp_length = 2307 tmp_length =
1717 (unsigned int) (DBL_MAX_EXP 2308 (unsigned int) (DBL_MAX_EXP
1718 * 0.30103 /* binary -> decimal */ 2309 * 0.30103 /* binary -> decimal */
1719 * 2 /* estimate for FLAG_GROUP */ 2310 * 0.5 * 3 /* estimate for FLAG_GROUP */
1720 ) 2311 )
1721 + 1 /* turn floor into ceil */ 2312 + 1 /* turn floor into ceil */
1722 + 10; /* sign, decimal point etc. */ 2313 + 10; /* sign, decimal point etc. */
1723 tmp_length = xsum (tmp_length, precision); 2314 tmp_length = xsum (tmp_length, precision);
1724 break; 2315 break;
1725 2316
1726 case 'e': case 'E': case 'g': case 'G': 2317 case 'g': case 'G':
1727 tmp_length = 2318 tmp_length =
1728 12; /* sign, decimal point, exponent etc. */ 2319 12; /* sign, decimal point, exponent etc. */
1729 tmp_length = xsum (tmp_length, precision); 2320 tmp_length = xsum (tmp_length,
2321 precision
2322 * 0.5 * 3 /* estimate for FLAG_GROUP */
2323 );
1730 break; 2324 break;
1731 2325
1732 case 'a': case 'A': 2326 case 'a': case 'A':
@@ -1764,10 +2358,9 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1764 break; 2358 break;
1765 2359
1766 case 's': 2360 case 's':
1767# if HAVE_WCHAR_T
1768 if (type == TYPE_WIDE_STRING) 2361 if (type == TYPE_WIDE_STRING)
1769 { 2362 {
1770# if WIDE_CHAR_VERSION 2363# if WIDE_CHAR_VERSION
1771 /* ISO C says about %ls in fwprintf: 2364 /* ISO C says about %ls in fwprintf:
1772 "If the precision is not specified or is greater than the size 2365 "If the precision is not specified or is greater than the size
1773 of the array, the array shall contain a null wide character." 2366 of the array, the array shall contain a null wide character."
@@ -1778,7 +2371,7 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1778 tmp_length = local_wcsnlen (arg, precision); 2371 tmp_length = local_wcsnlen (arg, precision);
1779 else 2372 else
1780 tmp_length = local_wcslen (arg); 2373 tmp_length = local_wcslen (arg);
1781# else 2374# else
1782 /* ISO C says about %ls in fprintf: 2375 /* ISO C says about %ls in fprintf:
1783 "If a precision is specified, no more than that many bytes are 2376 "If a precision is specified, no more than that many bytes are
1784 written (including shift sequences, if any), and the array 2377 written (including shift sequences, if any), and the array
@@ -1789,10 +2382,9 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1789 So if there is a precision, we must not use wcslen. */ 2382 So if there is a precision, we must not use wcslen. */
1790 /* This case has already been handled separately in VASNPRINTF. */ 2383 /* This case has already been handled separately in VASNPRINTF. */
1791 abort (); 2384 abort ();
1792# endif 2385# endif
1793 } 2386 }
1794 else 2387 else
1795# endif
1796 { 2388 {
1797# if WIDE_CHAR_VERSION 2389# if WIDE_CHAR_VERSION
1798 /* ISO C says about %s in fwprintf: 2390 /* ISO C says about %s in fwprintf:
@@ -1875,21 +2467,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1875 goto fail_1_with_EINVAL; 2467 goto fail_1_with_EINVAL;
1876 2468
1877 { 2469 {
1878 size_t buf_neededlength;
1879 TCHAR_T *buf;
1880 TCHAR_T *buf_malloced;
1881 const FCHAR_T *cp;
1882 size_t i;
1883 DIRECTIVE *dp;
1884 /* Output string accumulator. */
1885 DCHAR_T *result;
1886 size_t allocated;
1887 size_t length;
1888
1889 /* Allocate a small buffer that will hold a directive passed to 2470 /* Allocate a small buffer that will hold a directive passed to
1890 sprintf or snprintf. */ 2471 sprintf or snprintf. */
1891 buf_neededlength = 2472 size_t buf_neededlength =
1892 xsum4 (7, d.max_width_length, d.max_precision_length, 6); 2473 xsum4 (7, d.max_width_length, d.max_precision_length, 6);
2474 TCHAR_T *buf;
2475 TCHAR_T *buf_malloced;
1893#if HAVE_ALLOCA 2476#if HAVE_ALLOCA
1894 if (buf_neededlength < 4000 / sizeof (TCHAR_T)) 2477 if (buf_neededlength < 4000 / sizeof (TCHAR_T))
1895 { 2478 {
@@ -1908,9 +2491,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1908 buf_malloced = buf; 2491 buf_malloced = buf;
1909 } 2492 }
1910 2493
1911 result = resultbuf; 2494 /* Output string accumulator. */
1912 allocated = (resultbuf != NULL ? *lengthp : 0); 2495 DCHAR_T *result = resultbuf;
1913 length = 0; 2496 size_t allocated = (resultbuf != NULL ? *lengthp : 0);
2497 size_t length = 0;
2498
1914 /* Invariants: 2499 /* Invariants:
1915 result is either == resultbuf or malloc-allocated. 2500 result is either == resultbuf or malloc-allocated.
1916 If result == NULL, resultbuf is == NULL as well. 2501 If result == NULL, resultbuf is == NULL as well.
@@ -1921,15 +2506,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1921#define ENSURE_ALLOCATION_ELSE(needed, oom_statement) \ 2506#define ENSURE_ALLOCATION_ELSE(needed, oom_statement) \
1922 if ((needed) > allocated) \ 2507 if ((needed) > allocated) \
1923 { \ 2508 { \
1924 size_t memory_size; \
1925 DCHAR_T *memory; \
1926 \
1927 allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ 2509 allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
1928 if ((needed) > allocated) \ 2510 if ((needed) > allocated) \
1929 allocated = (needed); \ 2511 allocated = (needed); \
1930 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ 2512 size_t memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
1931 if (size_overflow_p (memory_size)) \ 2513 if (size_overflow_p (memory_size)) \
1932 oom_statement \ 2514 oom_statement \
2515 DCHAR_T *memory; \
1933 if (result == resultbuf) \ 2516 if (result == resultbuf) \
1934 memory = (DCHAR_T *) malloc (memory_size); \ 2517 memory = (DCHAR_T *) malloc (memory_size); \
1935 else \ 2518 else \
@@ -1943,7 +2526,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1943#define ENSURE_ALLOCATION(needed) \ 2526#define ENSURE_ALLOCATION(needed) \
1944 ENSURE_ALLOCATION_ELSE((needed), goto out_of_memory; ) 2527 ENSURE_ALLOCATION_ELSE((needed), goto out_of_memory; )
1945 2528
1946 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) 2529 const FCHAR_T *cp;
2530 size_t di;
2531 DIRECTIVE *dp;
2532 for (cp = format, di = 0, dp = &d.dir[0]; ; cp = dp->dir_end, di++, dp++)
1947 { 2533 {
1948 if (cp != dp->dir_start) 2534 if (cp != dp->dir_start)
1949 { 2535 {
@@ -1966,7 +2552,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1966 while (--n > 0); 2552 while (--n > 0);
1967 } 2553 }
1968 } 2554 }
1969 if (i == d.count) 2555 if (di == d.count)
1970 break; 2556 break;
1971 2557
1972 /* Execute a single directive. */ 2558 /* Execute a single directive. */
@@ -1988,6 +2574,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1988 2574
1989 if (dp->conversion == 'n') 2575 if (dp->conversion == 'n')
1990 { 2576 {
2577#if NEED_PRINTF_WITH_N_DIRECTIVE
1991 switch (a.arg[dp->arg_index].type) 2578 switch (a.arg[dp->arg_index].type)
1992 { 2579 {
1993 case TYPE_COUNT_SCHAR_POINTER: 2580 case TYPE_COUNT_SCHAR_POINTER:
@@ -2005,9 +2592,36 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2005 case TYPE_COUNT_LONGLONGINT_POINTER: 2592 case TYPE_COUNT_LONGLONGINT_POINTER:
2006 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; 2593 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
2007 break; 2594 break;
2595 case TYPE_COUNT_INT8_T_POINTER:
2596 *a.arg[dp->arg_index].a.a_count_int8_t_pointer = length;
2597 break;
2598 case TYPE_COUNT_INT16_T_POINTER:
2599 *a.arg[dp->arg_index].a.a_count_int16_t_pointer = length;
2600 break;
2601 case TYPE_COUNT_INT32_T_POINTER:
2602 *a.arg[dp->arg_index].a.a_count_int32_t_pointer = length;
2603 break;
2604 case TYPE_COUNT_INT64_T_POINTER:
2605 *a.arg[dp->arg_index].a.a_count_int64_t_pointer = length;
2606 break;
2607 case TYPE_COUNT_INT_FAST8_T_POINTER:
2608 *a.arg[dp->arg_index].a.a_count_int_fast8_t_pointer = length;
2609 break;
2610 case TYPE_COUNT_INT_FAST16_T_POINTER:
2611 *a.arg[dp->arg_index].a.a_count_int_fast16_t_pointer = length;
2612 break;
2613 case TYPE_COUNT_INT_FAST32_T_POINTER:
2614 *a.arg[dp->arg_index].a.a_count_int_fast32_t_pointer = length;
2615 break;
2616 case TYPE_COUNT_INT_FAST64_T_POINTER:
2617 *a.arg[dp->arg_index].a.a_count_int_fast64_t_pointer = length;
2618 break;
2008 default: 2619 default:
2009 abort (); 2620 abort ();
2010 } 2621 }
2622#else
2623 abort ();
2624#endif
2011 } 2625 }
2012#if ENABLE_UNISTDIO 2626#if ENABLE_UNISTDIO
2013 /* The unistdio extensions. */ 2627 /* The unistdio extensions. */
@@ -2015,22 +2629,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2015 { 2629 {
2016 arg_type type = a.arg[dp->arg_index].type; 2630 arg_type type = a.arg[dp->arg_index].type;
2017 int flags = dp->flags; 2631 int flags = dp->flags;
2018 int has_width;
2019 size_t width;
2020 int has_precision;
2021 size_t precision;
2022 2632
2023 has_width = 0; 2633 int has_width = 0;
2024 width = 0; 2634 size_t width = 0;
2025 if (dp->width_start != dp->width_end) 2635 if (dp->width_start != dp->width_end)
2026 { 2636 {
2027 if (dp->width_arg_index != ARG_NONE) 2637 if (dp->width_arg_index != ARG_NONE)
2028 { 2638 {
2029 int arg;
2030
2031 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 2639 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2032 abort (); 2640 abort ();
2033 arg = a.arg[dp->width_arg_index].a.a_int; 2641 int arg = a.arg[dp->width_arg_index].a.a_int;
2034 width = arg; 2642 width = arg;
2035 if (arg < 0) 2643 if (arg < 0)
2036 { 2644 {
@@ -2048,20 +2656,20 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2048 width = xsum (xtimes (width, 10), *digitp++ - '0'); 2656 width = xsum (xtimes (width, 10), *digitp++ - '0');
2049 while (digitp != dp->width_end); 2657 while (digitp != dp->width_end);
2050 } 2658 }
2659 if (width > (size_t) INT_MAX)
2660 goto overflow;
2051 has_width = 1; 2661 has_width = 1;
2052 } 2662 }
2053 2663
2054 has_precision = 0; 2664 int has_precision = 0;
2055 precision = 0; 2665 size_t precision = 0;
2056 if (dp->precision_start != dp->precision_end) 2666 if (dp->precision_start != dp->precision_end)
2057 { 2667 {
2058 if (dp->precision_arg_index != ARG_NONE) 2668 if (dp->precision_arg_index != ARG_NONE)
2059 { 2669 {
2060 int arg;
2061
2062 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 2670 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
2063 abort (); 2671 abort ();
2064 arg = a.arg[dp->precision_arg_index].a.a_int; 2672 int arg = a.arg[dp->precision_arg_index].a.a_int;
2065 /* "A negative precision is taken as if the precision 2673 /* "A negative precision is taken as if the precision
2066 were omitted." */ 2674 were omitted." */
2067 if (arg >= 0) 2675 if (arg >= 0)
@@ -2126,11 +2734,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2126 { 2734 {
2127 /* Use the entire string. */ 2735 /* Use the entire string. */
2128 arg_end = arg + u8_strlen (arg); 2736 arg_end = arg + u8_strlen (arg);
2129 /* The number of characters doesn't matter. */ 2737 /* The number of characters doesn't matter,
2738 because !has_width and therefore width==0. */
2130 characters = 0; 2739 characters = 0;
2131 } 2740 }
2132 2741
2133 if (characters < width && !(dp->flags & FLAG_LEFT)) 2742 if (characters < width && !(flags & FLAG_LEFT))
2134 { 2743 {
2135 size_t n = width - characters; 2744 size_t n = width - characters;
2136 ENSURE_ALLOCATION (xsum (length, n)); 2745 ENSURE_ALLOCATION (xsum (length, n));
@@ -2167,7 +2776,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2167 if (converted != result + length) 2776 if (converted != result + length)
2168 { 2777 {
2169 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len), 2778 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2170 { free (converted); goto out_of_memory; }); 2779 { free (converted); goto out_of_memory; });
2171 DCHAR_CPY (result + length, converted, converted_len); 2780 DCHAR_CPY (result + length, converted, converted_len);
2172 free (converted); 2781 free (converted);
2173 } 2782 }
@@ -2175,7 +2784,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2175 } 2784 }
2176# endif 2785# endif
2177 2786
2178 if (characters < width && (dp->flags & FLAG_LEFT)) 2787 if (characters < width && (flags & FLAG_LEFT))
2179 { 2788 {
2180 size_t n = width - characters; 2789 size_t n = width - characters;
2181 ENSURE_ALLOCATION (xsum (length, n)); 2790 ENSURE_ALLOCATION (xsum (length, n));
@@ -2228,11 +2837,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2228 { 2837 {
2229 /* Use the entire string. */ 2838 /* Use the entire string. */
2230 arg_end = arg + u16_strlen (arg); 2839 arg_end = arg + u16_strlen (arg);
2231 /* The number of characters doesn't matter. */ 2840 /* The number of characters doesn't matter,
2841 because !has_width and therefore width==0. */
2232 characters = 0; 2842 characters = 0;
2233 } 2843 }
2234 2844
2235 if (characters < width && !(dp->flags & FLAG_LEFT)) 2845 if (characters < width && !(flags & FLAG_LEFT))
2236 { 2846 {
2237 size_t n = width - characters; 2847 size_t n = width - characters;
2238 ENSURE_ALLOCATION (xsum (length, n)); 2848 ENSURE_ALLOCATION (xsum (length, n));
@@ -2269,7 +2879,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2269 if (converted != result + length) 2879 if (converted != result + length)
2270 { 2880 {
2271 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len), 2881 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2272 { free (converted); goto out_of_memory; }); 2882 { free (converted); goto out_of_memory; });
2273 DCHAR_CPY (result + length, converted, converted_len); 2883 DCHAR_CPY (result + length, converted, converted_len);
2274 free (converted); 2884 free (converted);
2275 } 2885 }
@@ -2277,7 +2887,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2277 } 2887 }
2278# endif 2888# endif
2279 2889
2280 if (characters < width && (dp->flags & FLAG_LEFT)) 2890 if (characters < width && (flags & FLAG_LEFT))
2281 { 2891 {
2282 size_t n = width - characters; 2892 size_t n = width - characters;
2283 ENSURE_ALLOCATION (xsum (length, n)); 2893 ENSURE_ALLOCATION (xsum (length, n));
@@ -2330,11 +2940,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2330 { 2940 {
2331 /* Use the entire string. */ 2941 /* Use the entire string. */
2332 arg_end = arg + u32_strlen (arg); 2942 arg_end = arg + u32_strlen (arg);
2333 /* The number of characters doesn't matter. */ 2943 /* The number of characters doesn't matter,
2944 because !has_width and therefore width==0. */
2334 characters = 0; 2945 characters = 0;
2335 } 2946 }
2336 2947
2337 if (characters < width && !(dp->flags & FLAG_LEFT)) 2948 if (characters < width && !(flags & FLAG_LEFT))
2338 { 2949 {
2339 size_t n = width - characters; 2950 size_t n = width - characters;
2340 ENSURE_ALLOCATION (xsum (length, n)); 2951 ENSURE_ALLOCATION (xsum (length, n));
@@ -2371,7 +2982,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2371 if (converted != result + length) 2982 if (converted != result + length)
2372 { 2983 {
2373 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len), 2984 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2374 { free (converted); goto out_of_memory; }); 2985 { free (converted); goto out_of_memory; });
2375 DCHAR_CPY (result + length, converted, converted_len); 2986 DCHAR_CPY (result + length, converted, converted_len);
2376 free (converted); 2987 free (converted);
2377 } 2988 }
@@ -2379,7 +2990,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2379 } 2990 }
2380# endif 2991# endif
2381 2992
2382 if (characters < width && (dp->flags & FLAG_LEFT)) 2993 if (characters < width && (flags & FLAG_LEFT))
2383 { 2994 {
2384 size_t n = width - characters; 2995 size_t n = width - characters;
2385 ENSURE_ALLOCATION (xsum (length, n)); 2996 ENSURE_ALLOCATION (xsum (length, n));
@@ -2394,7 +3005,313 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2394 } 3005 }
2395 } 3006 }
2396#endif 3007#endif
2397#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T 3008#if !WIDE_CHAR_VERSION && (PTRDIFF_MAX > INT_MAX)
3009 else if (dp->conversion == 's'
3010 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING)
3011 {
3012 /* %s in vasnprintf. See the specification of fprintf.
3013 We handle it ourselves here, because the string may be longer
3014 than INT_MAX characters, whence snprintf or sprintf would
3015 fail to process it. */
3016 int flags = dp->flags;
3017
3018 int has_width = 0;
3019 size_t width = 0;
3020 if (dp->width_start != dp->width_end)
3021 {
3022 if (dp->width_arg_index != ARG_NONE)
3023 {
3024 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3025 abort ();
3026 int arg = a.arg[dp->width_arg_index].a.a_int;
3027 width = arg;
3028 if (arg < 0)
3029 {
3030 /* "A negative field width is taken as a '-' flag
3031 followed by a positive field width." */
3032 flags |= FLAG_LEFT;
3033 width = -width;
3034 }
3035 }
3036 else
3037 {
3038 const FCHAR_T *digitp = dp->width_start;
3039
3040 do
3041 width = xsum (xtimes (width, 10), *digitp++ - '0');
3042 while (digitp != dp->width_end);
3043 }
3044 if (width > (size_t) INT_MAX)
3045 goto overflow;
3046 has_width = 1;
3047 }
3048
3049 int has_precision = 0;
3050 size_t precision = 6;
3051 if (dp->precision_start != dp->precision_end)
3052 {
3053 if (dp->precision_arg_index != ARG_NONE)
3054 {
3055 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
3056 abort ();
3057 int arg = a.arg[dp->precision_arg_index].a.a_int;
3058 /* "A negative precision is taken as if the precision
3059 were omitted." */
3060 if (arg >= 0)
3061 {
3062 precision = arg;
3063 has_precision = 1;
3064 }
3065 }
3066 else
3067 {
3068 const FCHAR_T *digitp = dp->precision_start + 1;
3069
3070 precision = 0;
3071 while (digitp != dp->precision_end)
3072 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
3073 has_precision = 1;
3074 }
3075 }
3076
3077 {
3078 const char *arg = a.arg[dp->arg_index].a.a_string;
3079
3080 size_t bytes;
3081 if (has_precision)
3082 {
3083 /* Use only at most PRECISION bytes, from the left. */
3084 bytes = local_strnlen (arg, precision);
3085 }
3086 else
3087 {
3088 /* Use the entire string, and count the number of
3089 bytes. */
3090 bytes = strlen (arg);
3091 }
3092
3093# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
3094 size_t characters;
3095 if (has_width)
3096 characters = mbsnlen (arg, bytes);
3097 else
3098 {
3099 /* The number of characters doesn't matter,
3100 because !has_width and therefore width==0. */
3101 characters = 0;
3102 }
3103# endif
3104
3105# if !DCHAR_IS_TCHAR
3106 /* This code assumes that TCHAR_T is 'char'. */
3107 static_assert (sizeof (TCHAR_T) == 1);
3108 DCHAR_T *tmpdst;
3109 size_t tmpdst_len;
3110 /* Convert from TCHAR_T[] to DCHAR_T[]. */
3111 tmpdst =
3112 DCHAR_CONV_FROM_ENCODING (locale_charset (),
3113 iconveh_question_mark,
3114 arg, bytes,
3115 NULL,
3116 NULL, &tmpdst_len);
3117 if (tmpdst == NULL)
3118 goto fail_with_errno;
3119# endif
3120
3121 size_t w;
3122 if (has_width)
3123 {
3124# if ENABLE_UNISTDIO
3125 /* Outside POSIX, it's preferable to compare the width
3126 against the number of _characters_ of the converted
3127 value. */
3128# if DCHAR_IS_TCHAR
3129 w = characters;
3130# else
3131 w = DCHAR_MBSNLEN (tmpdst, tmpdst_len);
3132# endif
3133# else
3134 /* The width is compared against the number of _bytes_
3135 of the converted value, says POSIX. */
3136 w = bytes;
3137# endif
3138 }
3139 else
3140 /* w doesn't matter. */
3141 w = 0;
3142
3143 {
3144# if DCHAR_IS_TCHAR
3145 size_t total = bytes + (w < width ? width - w : 0);
3146 ENSURE_ALLOCATION (xsum (length, total));
3147# else
3148 size_t total = tmpdst_len + (w < width ? width - w : 0);
3149 ENSURE_ALLOCATION_ELSE (xsum (length, total),
3150 { free (tmpdst); goto out_of_memory; });
3151# endif
3152
3153 if (w < width && !(flags & FLAG_LEFT))
3154 {
3155 size_t n = width - w;
3156 DCHAR_SET (result + length, ' ', n);
3157 length += n;
3158 }
3159
3160# if DCHAR_IS_TCHAR
3161 memcpy (result + length, arg, bytes);
3162 length += bytes;
3163# else
3164 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
3165 free (tmpdst);
3166 length += tmpdst_len;
3167# endif
3168
3169 if (w < width && (flags & FLAG_LEFT))
3170 {
3171 size_t n = width - w;
3172 DCHAR_SET (result + length, ' ', n);
3173 length += n;
3174 }
3175 }
3176 }
3177 }
3178#endif
3179#if WIDE_CHAR_VERSION && ((PTRDIFF_MAX > INT_MAX) || !DCHAR_IS_TCHAR || NEED_WPRINTF_DIRECTIVE_LC)
3180 else if ((dp->conversion == 's'
3181 && a.arg[dp->arg_index].type == TYPE_WIDE_STRING)
3182 || (dp->conversion == 'c'
3183 && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR))
3184 {
3185 /* %ls or %lc in vasnwprintf. See the specification of
3186 fwprintf. */
3187 /* It would be silly to use snprintf ("%ls", ...) and then
3188 convert back the result from a char[] to a wchar_t[].
3189 Instead, just copy the argument wchar_t[] to the result. */
3190 int flags = dp->flags;
3191
3192 size_t width = 0;
3193 if (dp->width_start != dp->width_end)
3194 {
3195 if (dp->width_arg_index != ARG_NONE)
3196 {
3197 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3198 abort ();
3199 int arg = a.arg[dp->width_arg_index].a.a_int;
3200 width = arg;
3201 if (arg < 0)
3202 {
3203 /* "A negative field width is taken as a '-' flag
3204 followed by a positive field width." */
3205 flags |= FLAG_LEFT;
3206 width = -width;
3207 }
3208 }
3209 else
3210 {
3211 const FCHAR_T *digitp = dp->width_start;
3212
3213 do
3214 width = xsum (xtimes (width, 10), *digitp++ - '0');
3215 while (digitp != dp->width_end);
3216 }
3217 if (width > (size_t) INT_MAX)
3218 goto overflow;
3219 }
3220
3221 {
3222 const wchar_t *ls_arg;
3223 wchar_t lc_arg[1];
3224 size_t characters;
3225
3226 if (dp->conversion == 's')
3227 {
3228 int has_precision = 0;
3229 size_t precision = 6;
3230 if (dp->precision_start != dp->precision_end)
3231 {
3232 if (dp->precision_arg_index != ARG_NONE)
3233 {
3234 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
3235 abort ();
3236 int arg = a.arg[dp->precision_arg_index].a.a_int;
3237 /* "A negative precision is taken as if the precision
3238 were omitted." */
3239 if (arg >= 0)
3240 {
3241 precision = arg;
3242 has_precision = 1;
3243 }
3244 }
3245 else
3246 {
3247 const FCHAR_T *digitp = dp->precision_start + 1;
3248
3249 precision = 0;
3250 while (digitp != dp->precision_end)
3251 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
3252 has_precision = 1;
3253 }
3254 }
3255
3256 ls_arg = a.arg[dp->arg_index].a.a_wide_string;
3257
3258 if (has_precision)
3259 {
3260 /* Use only at most PRECISION wide characters, from
3261 the left. */
3262 const wchar_t *ls_arg_end = ls_arg;
3263 characters = 0;
3264 for (; precision > 0; precision--)
3265 {
3266 if (*ls_arg_end == 0)
3267 /* Found the terminating null wide character. */
3268 break;
3269 ls_arg_end++;
3270 characters++;
3271 }
3272 }
3273 else
3274 {
3275 /* Use the entire string, and count the number of wide
3276 characters. */
3277 characters = local_wcslen (ls_arg);
3278 }
3279 }
3280 else /* dp->conversion == 'c' */
3281 {
3282 lc_arg[0] = (wchar_t) a.arg[dp->arg_index].a.a_wide_char;
3283 ls_arg = lc_arg;
3284 characters = 1;
3285 }
3286
3287 {
3288 size_t total = (characters < width ? width : characters);
3289 ENSURE_ALLOCATION (xsum (length, total));
3290
3291 if (characters < width && !(flags & FLAG_LEFT))
3292 {
3293 size_t n = width - characters;
3294 DCHAR_SET (result + length, ' ', n);
3295 length += n;
3296 }
3297
3298 if (characters > 0)
3299 {
3300 DCHAR_CPY (result + length, ls_arg, characters);
3301 length += characters;
3302 }
3303
3304 if (characters < width && (flags & FLAG_LEFT))
3305 {
3306 size_t n = width - characters;
3307 DCHAR_SET (result + length, ' ', n);
3308 length += n;
3309 }
3310 }
3311 }
3312 }
3313#endif
3314#if WIDE_CHAR_VERSION || !USE_SNPRINTF || (PTRDIFF_MAX > INT_MAX) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK
2398 else if (dp->conversion == 's' 3315 else if (dp->conversion == 's'
2399# if WIDE_CHAR_VERSION 3316# if WIDE_CHAR_VERSION
2400 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING 3317 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -2414,22 +3331,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2414 such bugs, we implement the entire processing of the 's' 3331 such bugs, we implement the entire processing of the 's'
2415 directive ourselves. */ 3332 directive ourselves. */
2416 int flags = dp->flags; 3333 int flags = dp->flags;
2417 int has_width;
2418 size_t width;
2419 int has_precision;
2420 size_t precision;
2421 3334
2422 has_width = 0; 3335 int has_width = 0;
2423 width = 0; 3336 size_t width = 0;
2424 if (dp->width_start != dp->width_end) 3337 if (dp->width_start != dp->width_end)
2425 { 3338 {
2426 if (dp->width_arg_index != ARG_NONE) 3339 if (dp->width_arg_index != ARG_NONE)
2427 { 3340 {
2428 int arg;
2429
2430 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 3341 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2431 abort (); 3342 abort ();
2432 arg = a.arg[dp->width_arg_index].a.a_int; 3343 int arg = a.arg[dp->width_arg_index].a.a_int;
2433 width = arg; 3344 width = arg;
2434 if (arg < 0) 3345 if (arg < 0)
2435 { 3346 {
@@ -2447,20 +3358,20 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2447 width = xsum (xtimes (width, 10), *digitp++ - '0'); 3358 width = xsum (xtimes (width, 10), *digitp++ - '0');
2448 while (digitp != dp->width_end); 3359 while (digitp != dp->width_end);
2449 } 3360 }
3361 if (width > (size_t) INT_MAX)
3362 goto overflow;
2450 has_width = 1; 3363 has_width = 1;
2451 } 3364 }
2452 3365
2453 has_precision = 0; 3366 int has_precision = 0;
2454 precision = 6; 3367 size_t precision = 6;
2455 if (dp->precision_start != dp->precision_end) 3368 if (dp->precision_start != dp->precision_end)
2456 { 3369 {
2457 if (dp->precision_arg_index != ARG_NONE) 3370 if (dp->precision_arg_index != ARG_NONE)
2458 { 3371 {
2459 int arg;
2460
2461 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 3372 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
2462 abort (); 3373 abort ();
2463 arg = a.arg[dp->precision_arg_index].a.a_int; 3374 int arg = a.arg[dp->precision_arg_index].a.a_int;
2464 /* "A negative precision is taken as if the precision 3375 /* "A negative precision is taken as if the precision
2465 were omitted." */ 3376 were omitted." */
2466 if (arg >= 0) 3377 if (arg >= 0)
@@ -2493,7 +3404,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2493 wide characters, from the left. */ 3404 wide characters, from the left. */
2494# if HAVE_MBRTOWC 3405# if HAVE_MBRTOWC
2495 mbstate_t state; 3406 mbstate_t state;
2496 memset (&state, '\0', sizeof (mbstate_t)); 3407 mbszero (&state);
2497# endif 3408# endif
2498 arg_end = arg; 3409 arg_end = arg;
2499 characters = 0; 3410 characters = 0;
@@ -2521,7 +3432,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2521 characters. */ 3432 characters. */
2522# if HAVE_MBRTOWC 3433# if HAVE_MBRTOWC
2523 mbstate_t state; 3434 mbstate_t state;
2524 memset (&state, '\0', sizeof (mbstate_t)); 3435 mbszero (&state);
2525# endif 3436# endif
2526 arg_end = arg; 3437 arg_end = arg;
2527 characters = 0; 3438 characters = 0;
@@ -2551,7 +3462,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2551 characters = 0; 3462 characters = 0;
2552 } 3463 }
2553 3464
2554 if (characters < width && !(dp->flags & FLAG_LEFT)) 3465 if (characters < width && !(flags & FLAG_LEFT))
2555 { 3466 {
2556 size_t n = width - characters; 3467 size_t n = width - characters;
2557 ENSURE_ALLOCATION (xsum (length, n)); 3468 ENSURE_ALLOCATION (xsum (length, n));
@@ -2562,13 +3473,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2562 if (has_precision || has_width) 3473 if (has_precision || has_width)
2563 { 3474 {
2564 /* We know the number of wide characters in advance. */ 3475 /* We know the number of wide characters in advance. */
2565 size_t remaining;
2566# if HAVE_MBRTOWC 3476# if HAVE_MBRTOWC
2567 mbstate_t state; 3477 mbstate_t state;
2568 memset (&state, '\0', sizeof (mbstate_t)); 3478 mbszero (&state);
2569# endif 3479# endif
2570 ENSURE_ALLOCATION (xsum (length, characters)); 3480 ENSURE_ALLOCATION (xsum (length, characters));
2571 for (remaining = characters; remaining > 0; remaining--) 3481 for (size_t remaining = characters; remaining > 0; remaining--)
2572 { 3482 {
2573 wchar_t wc; 3483 wchar_t wc;
2574 int count; 3484 int count;
@@ -2591,7 +3501,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2591 { 3501 {
2592# if HAVE_MBRTOWC 3502# if HAVE_MBRTOWC
2593 mbstate_t state; 3503 mbstate_t state;
2594 memset (&state, '\0', sizeof (mbstate_t)); 3504 mbszero (&state);
2595# endif 3505# endif
2596 while (arg < arg_end) 3506 while (arg < arg_end)
2597 { 3507 {
@@ -2602,17 +3512,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2602# else 3512# else
2603 count = mbtowc (&wc, arg, arg_end - arg); 3513 count = mbtowc (&wc, arg, arg_end - arg);
2604# endif 3514# endif
2605 if (count <= 0) 3515 if (count == 0)
2606 /* mbrtowc not consistent with mbrlen, or mbtowc 3516 /* mbrtowc not consistent with strlen. */
2607 not consistent with mblen. */
2608 abort (); 3517 abort ();
3518 if (count < 0)
3519 /* Invalid or incomplete multibyte character. */
3520 goto fail_with_EILSEQ;
2609 ENSURE_ALLOCATION (xsum (length, 1)); 3521 ENSURE_ALLOCATION (xsum (length, 1));
2610 result[length++] = wc; 3522 result[length++] = wc;
2611 arg += count; 3523 arg += count;
2612 } 3524 }
2613 } 3525 }
2614 3526
2615 if (characters < width && (dp->flags & FLAG_LEFT)) 3527 if (characters < width && (flags & FLAG_LEFT))
2616 { 3528 {
2617 size_t n = width - characters; 3529 size_t n = width - characters;
2618 ENSURE_ALLOCATION (xsum (length, n)); 3530 ENSURE_ALLOCATION (xsum (length, n));
@@ -2625,11 +3537,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2625 { 3537 {
2626 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; 3538 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
2627 const wchar_t *arg_end; 3539 const wchar_t *arg_end;
3540 size_t bytes;
3541# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
2628 size_t characters; 3542 size_t characters;
3543# endif
2629# if !DCHAR_IS_TCHAR 3544# if !DCHAR_IS_TCHAR
2630 /* This code assumes that TCHAR_T is 'char'. */ 3545 /* This code assumes that TCHAR_T is 'char'. */
2631 static_assert (sizeof (TCHAR_T) == 1); 3546 static_assert (sizeof (TCHAR_T) == 1);
2632 TCHAR_T *tmpsrc;
2633 DCHAR_T *tmpdst; 3547 DCHAR_T *tmpdst;
2634 size_t tmpdst_len; 3548 size_t tmpdst_len;
2635# endif 3549# endif
@@ -2641,26 +3555,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2641 at most PRECISION bytes, from the left. */ 3555 at most PRECISION bytes, from the left. */
2642# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3556# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2643 mbstate_t state; 3557 mbstate_t state;
2644 memset (&state, '\0', sizeof (mbstate_t)); 3558 mbszero (&state);
2645# endif 3559# endif
2646 arg_end = arg; 3560 arg_end = arg;
3561 bytes = 0;
3562# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
2647 characters = 0; 3563 characters = 0;
3564# endif
2648 while (precision > 0) 3565 while (precision > 0)
2649 { 3566 {
2650 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2651 int count;
2652
2653 if (*arg_end == 0) 3567 if (*arg_end == 0)
2654 /* Found the terminating null wide character. */ 3568 /* Found the terminating null wide character. */
2655 break; 3569 break;
2656 count = local_wcrtomb (cbuf, *arg_end, &state); 3570 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3571 int count = local_wcrtomb (cbuf, *arg_end, &state);
2657 if (count < 0) 3572 if (count < 0)
2658 /* Cannot convert. */ 3573 /* Cannot convert. */
2659 goto fail_with_EILSEQ; 3574 goto fail_with_EILSEQ;
2660 if (precision < (unsigned int) count) 3575 if (precision < (unsigned int) count)
2661 break; 3576 break;
2662 arg_end++; 3577 arg_end++;
2663 characters += count; 3578 bytes += count;
3579# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
3580 characters += mbsnlen (cbuf, count);
3581# endif
2664 precision -= count; 3582 precision -= count;
2665 } 3583 }
2666 } 3584 }
@@ -2674,24 +3592,28 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2674 bytes. */ 3592 bytes. */
2675# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3593# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2676 mbstate_t state; 3594 mbstate_t state;
2677 memset (&state, '\0', sizeof (mbstate_t)); 3595 mbszero (&state);
2678# endif 3596# endif
2679 arg_end = arg; 3597 arg_end = arg;
3598 bytes = 0;
3599# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
2680 characters = 0; 3600 characters = 0;
3601# endif
2681 for (;;) 3602 for (;;)
2682 { 3603 {
2683 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2684 int count;
2685
2686 if (*arg_end == 0) 3604 if (*arg_end == 0)
2687 /* Found the terminating null wide character. */ 3605 /* Found the terminating null wide character. */
2688 break; 3606 break;
2689 count = local_wcrtomb (cbuf, *arg_end, &state); 3607 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3608 int count = local_wcrtomb (cbuf, *arg_end, &state);
2690 if (count < 0) 3609 if (count < 0)
2691 /* Cannot convert. */ 3610 /* Cannot convert. */
2692 goto fail_with_EILSEQ; 3611 goto fail_with_EILSEQ;
2693 arg_end++; 3612 arg_end++;
2694 characters += count; 3613 bytes += count;
3614# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
3615 characters += mbsnlen (cbuf, count);
3616# endif
2695 } 3617 }
2696 } 3618 }
2697# if DCHAR_IS_TCHAR 3619# if DCHAR_IS_TCHAR
@@ -2699,56 +3621,59 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2699 { 3621 {
2700 /* Use the entire string. */ 3622 /* Use the entire string. */
2701 arg_end = arg + local_wcslen (arg); 3623 arg_end = arg + local_wcslen (arg);
2702 /* The number of bytes doesn't matter. */ 3624 /* The number of bytes and characters doesn't matter,
3625 because !has_width and therefore width==0. */
3626 bytes = 0;
3627# if ENABLE_UNISTDIO
2703 characters = 0; 3628 characters = 0;
3629# endif
2704 } 3630 }
2705# endif 3631# endif
2706 3632
2707# if !DCHAR_IS_TCHAR 3633# if !DCHAR_IS_TCHAR
2708 /* Convert the string into a piece of temporary memory. */
2709 tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
2710 if (tmpsrc == NULL)
2711 goto out_of_memory;
2712 { 3634 {
2713 TCHAR_T *tmpptr = tmpsrc; 3635 /* Convert the string into a piece of temporary memory. */
2714 size_t remaining; 3636 TCHAR_T *tmpsrc = (TCHAR_T *) malloc (bytes * sizeof (TCHAR_T));
3637 if (tmpsrc == NULL)
3638 goto out_of_memory;
3639 {
3640 TCHAR_T *tmpptr = tmpsrc;
2715# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3641# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2716 mbstate_t state; 3642 mbstate_t state;
2717 memset (&state, '\0', sizeof (mbstate_t)); 3643 mbszero (&state);
2718# endif 3644# endif
2719 for (remaining = characters; remaining > 0; ) 3645 for (size_t remaining = bytes; remaining > 0; )
2720 { 3646 {
2721 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ 3647 if (*arg == 0)
2722 int count; 3648 abort ();
3649 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3650 int count = local_wcrtomb (cbuf, *arg, &state);
3651 if (count <= 0)
3652 /* Inconsistency. */
3653 abort ();
3654 memcpy (tmpptr, cbuf, count);
3655 tmpptr += count;
3656 arg++;
3657 remaining -= count;
3658 }
3659 if (!(arg == arg_end))
3660 abort ();
3661 }
2723 3662
2724 if (*arg == 0) 3663 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2725 abort (); 3664 tmpdst =
2726 count = local_wcrtomb (cbuf, *arg, &state); 3665 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2727 if (count <= 0) 3666 iconveh_question_mark,
2728 /* Inconsistency. */ 3667 tmpsrc, bytes,
2729 abort (); 3668 NULL,
2730 memcpy (tmpptr, cbuf, count); 3669 NULL, &tmpdst_len);
2731 tmpptr += count; 3670 if (tmpdst == NULL)
2732 arg++; 3671 {
2733 remaining -= count; 3672 free (tmpsrc);
3673 goto fail_with_errno;
2734 } 3674 }
2735 if (!(arg == arg_end)) 3675 free (tmpsrc);
2736 abort ();
2737 } 3676 }
2738
2739 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2740 tmpdst =
2741 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2742 iconveh_question_mark,
2743 tmpsrc, characters,
2744 NULL,
2745 NULL, &tmpdst_len);
2746 if (tmpdst == NULL)
2747 {
2748 free (tmpsrc);
2749 goto fail_with_errno;
2750 }
2751 free (tmpsrc);
2752# endif 3677# endif
2753 3678
2754 if (has_width) 3679 if (has_width)
@@ -2757,21 +3682,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2757 /* Outside POSIX, it's preferable to compare the width 3682 /* Outside POSIX, it's preferable to compare the width
2758 against the number of _characters_ of the converted 3683 against the number of _characters_ of the converted
2759 value. */ 3684 value. */
2760 w = DCHAR_MBSNLEN (result + length, characters); 3685# if DCHAR_IS_TCHAR
3686 w = characters;
3687# else
3688 w = DCHAR_MBSNLEN (tmpdst, tmpdst_len);
3689# endif
2761# else 3690# else
2762 /* The width is compared against the number of _bytes_ 3691 /* The width is compared against the number of _bytes_
2763 of the converted value, says POSIX. */ 3692 of the converted value, says POSIX. */
2764 w = characters; 3693 w = bytes;
2765# endif 3694# endif
2766 } 3695 }
2767 else 3696 else
2768 /* w doesn't matter. */ 3697 /* w doesn't matter. */
2769 w = 0; 3698 w = 0;
2770 3699
2771 if (w < width && !(dp->flags & FLAG_LEFT)) 3700 if (w < width && !(flags & FLAG_LEFT))
2772 { 3701 {
2773 size_t n = width - w; 3702 size_t n = width - w;
3703# if DCHAR_IS_TCHAR
2774 ENSURE_ALLOCATION (xsum (length, n)); 3704 ENSURE_ALLOCATION (xsum (length, n));
3705# else
3706 ENSURE_ALLOCATION_ELSE (xsum (length, n),
3707 { free (tmpdst); goto out_of_memory; });
3708# endif
2775 DCHAR_SET (result + length, ' ', n); 3709 DCHAR_SET (result + length, ' ', n);
2776 length += n; 3710 length += n;
2777 } 3711 }
@@ -2780,20 +3714,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2780 if (has_precision || has_width) 3714 if (has_precision || has_width)
2781 { 3715 {
2782 /* We know the number of bytes in advance. */ 3716 /* We know the number of bytes in advance. */
2783 size_t remaining;
2784# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3717# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2785 mbstate_t state; 3718 mbstate_t state;
2786 memset (&state, '\0', sizeof (mbstate_t)); 3719 mbszero (&state);
2787# endif 3720# endif
2788 ENSURE_ALLOCATION (xsum (length, characters)); 3721 ENSURE_ALLOCATION (xsum (length, bytes));
2789 for (remaining = characters; remaining > 0; ) 3722 for (size_t remaining = bytes; remaining > 0; )
2790 { 3723 {
2791 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2792 int count;
2793
2794 if (*arg == 0) 3724 if (*arg == 0)
2795 abort (); 3725 abort ();
2796 count = local_wcrtomb (cbuf, *arg, &state); 3726 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3727 int count = local_wcrtomb (cbuf, *arg, &state);
2797 if (count <= 0) 3728 if (count <= 0)
2798 /* Inconsistency. */ 3729 /* Inconsistency. */
2799 abort (); 3730 abort ();
@@ -2809,16 +3740,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2809 { 3740 {
2810# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3741# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2811 mbstate_t state; 3742 mbstate_t state;
2812 memset (&state, '\0', sizeof (mbstate_t)); 3743 mbszero (&state);
2813# endif 3744# endif
2814 while (arg < arg_end) 3745 while (arg < arg_end)
2815 { 3746 {
2816 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2817 int count;
2818
2819 if (*arg == 0) 3747 if (*arg == 0)
2820 abort (); 3748 abort ();
2821 count = local_wcrtomb (cbuf, *arg, &state); 3749 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3750 int count = local_wcrtomb (cbuf, *arg, &state);
2822 if (count <= 0) 3751 if (count <= 0)
2823 /* Cannot convert. */ 3752 /* Cannot convert. */
2824 goto fail_with_EILSEQ; 3753 goto fail_with_EILSEQ;
@@ -2830,13 +3759,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2830 } 3759 }
2831# else 3760# else
2832 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), 3761 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
2833 { free (tmpdst); goto out_of_memory; }); 3762 { free (tmpdst); goto out_of_memory; });
2834 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 3763 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
2835 free (tmpdst); 3764 free (tmpdst);
2836 length += tmpdst_len; 3765 length += tmpdst_len;
2837# endif 3766# endif
2838 3767
2839 if (w < width && (dp->flags & FLAG_LEFT)) 3768 if (w < width && (flags & FLAG_LEFT))
2840 { 3769 {
2841 size_t n = width - w; 3770 size_t n = width - w;
2842 ENSURE_ALLOCATION (xsum (length, n)); 3771 ENSURE_ALLOCATION (xsum (length, n));
@@ -2847,27 +3776,24 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2847# endif 3776# endif
2848 } 3777 }
2849#endif 3778#endif
2850#if ENABLE_WCHAR_FALLBACK && HAVE_WINT_T && !WIDE_CHAR_VERSION 3779#if (NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T && !WIDE_CHAR_VERSION
2851 else if (dp->conversion == 'c' 3780 else if (dp->conversion == 'c'
2852 && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR) 3781 && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR)
2853 { 3782 {
2854 /* Implement the 'lc' directive ourselves, in order to provide 3783 /* Implement the 'lc' directive ourselves, in order to provide
2855 the fallback that avoids EILSEQ. */ 3784 a correct behaviour for the null wint_t argument and/or the
3785 fallback that avoids EILSEQ. */
2856 int flags = dp->flags; 3786 int flags = dp->flags;
2857 int has_width;
2858 size_t width;
2859 3787
2860 has_width = 0; 3788 int has_width = 0;
2861 width = 0; 3789 size_t width = 0;
2862 if (dp->width_start != dp->width_end) 3790 if (dp->width_start != dp->width_end)
2863 { 3791 {
2864 if (dp->width_arg_index != ARG_NONE) 3792 if (dp->width_arg_index != ARG_NONE)
2865 { 3793 {
2866 int arg;
2867
2868 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 3794 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2869 abort (); 3795 abort ();
2870 arg = a.arg[dp->width_arg_index].a.a_int; 3796 int arg = a.arg[dp->width_arg_index].a.a_int;
2871 width = arg; 3797 width = arg;
2872 if (arg < 0) 3798 if (arg < 0)
2873 { 3799 {
@@ -2885,17 +3811,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2885 width = xsum (xtimes (width, 10), *digitp++ - '0'); 3811 width = xsum (xtimes (width, 10), *digitp++ - '0');
2886 while (digitp != dp->width_end); 3812 while (digitp != dp->width_end);
2887 } 3813 }
3814 if (width > (size_t) INT_MAX)
3815 goto overflow;
2888 has_width = 1; 3816 has_width = 1;
2889 } 3817 }
2890 3818
2891 /* %lc in vasnprintf. See the specification of fprintf. */ 3819 /* %lc in vasnprintf. See the specification of fprintf. */
2892 { 3820 {
2893 wchar_t arg = (wchar_t) a.arg[dp->arg_index].a.a_wide_char; 3821 wchar_t arg = (wchar_t) a.arg[dp->arg_index].a.a_wide_char;
3822 size_t bytes;
3823# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
2894 size_t characters; 3824 size_t characters;
3825# endif
2895# if !DCHAR_IS_TCHAR 3826# if !DCHAR_IS_TCHAR
2896 /* This code assumes that TCHAR_T is 'char'. */ 3827 /* This code assumes that TCHAR_T is 'char'. */
2897 static_assert (sizeof (TCHAR_T) == 1); 3828 static_assert (sizeof (TCHAR_T) == 1);
2898 TCHAR_T tmpsrc[64]; /* Assume MB_CUR_MAX <= 64. */
2899 DCHAR_T *tmpdst; 3829 DCHAR_T *tmpdst;
2900 size_t tmpdst_len; 3830 size_t tmpdst_len;
2901# endif 3831# endif
@@ -2906,58 +3836,63 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2906# endif 3836# endif
2907 { 3837 {
2908 /* Count the number of bytes. */ 3838 /* Count the number of bytes. */
2909 characters = 0;
2910 if (arg != 0)
2911 {
2912 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2913 int count;
2914# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3839# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2915 mbstate_t state; 3840 mbstate_t state;
2916 memset (&state, '\0', sizeof (mbstate_t)); 3841 mbszero (&state);
2917# endif 3842# endif
2918 3843
2919 count = local_wcrtomb (cbuf, arg, &state); 3844 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2920 if (count < 0) 3845 int count = local_wcrtomb (cbuf, arg, &state);
2921 /* Inconsistency. */ 3846 if (count < 0)
2922 abort (); 3847 /* Cannot convert. */
2923 characters = count; 3848 goto fail_with_EILSEQ;
2924 } 3849 bytes = count;
3850# if ENABLE_UNISTDIO && DCHAR_IS_TCHAR
3851 characters = mbsnlen (cbuf, count);
3852# endif
2925 } 3853 }
2926# if DCHAR_IS_TCHAR 3854# if DCHAR_IS_TCHAR
2927 else 3855 else
2928 { 3856 {
2929 /* The number of bytes doesn't matter. */ 3857 /* The number of bytes and characters doesn't matter,
3858 because !has_width and therefore width==0. */
3859 bytes = 0;
3860# if ENABLE_UNISTDIO
2930 characters = 0; 3861 characters = 0;
3862# endif
2931 } 3863 }
2932# endif 3864# endif
2933 3865
2934# if !DCHAR_IS_TCHAR 3866# if !DCHAR_IS_TCHAR
2935 /* Convert the string into a piece of temporary memory. */ 3867 {
2936 if (characters > 0) /* implies arg != 0 */ 3868 TCHAR_T tmpsrc[64]; /* Assume MB_CUR_MAX <= 64. */
2937 { 3869
2938 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ 3870 /* Convert the string into a piece of temporary memory. */
2939 int count; 3871 if (bytes > 0)
3872 {
2940# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3873# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2941 mbstate_t state; 3874 mbstate_t state;
2942 memset (&state, '\0', sizeof (mbstate_t)); 3875 mbszero (&state);
2943# endif 3876# endif
2944 3877
2945 count = local_wcrtomb (cbuf, arg, &state); 3878 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2946 if (count <= 0) 3879 int count = local_wcrtomb (cbuf, arg, &state);
2947 /* Inconsistency. */ 3880 if (count <= 0)
2948 abort (); 3881 /* Inconsistency. */
2949 memcpy (tmpsrc, cbuf, count); 3882 abort ();
2950 } 3883 memcpy (tmpsrc, cbuf, count);
3884 }
2951 3885
2952 /* Convert from TCHAR_T[] to DCHAR_T[]. */ 3886 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2953 tmpdst = 3887 tmpdst =
2954 DCHAR_CONV_FROM_ENCODING (locale_charset (), 3888 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2955 iconveh_question_mark, 3889 iconveh_question_mark,
2956 tmpsrc, characters, 3890 tmpsrc, bytes,
2957 NULL, 3891 NULL,
2958 NULL, &tmpdst_len); 3892 NULL, &tmpdst_len);
2959 if (tmpdst == NULL) 3893 if (tmpdst == NULL)
2960 goto fail_with_errno; 3894 goto fail_with_errno;
3895 }
2961# endif 3896# endif
2962 3897
2963 if (has_width) 3898 if (has_width)
@@ -2966,21 +3901,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2966 /* Outside POSIX, it's preferable to compare the width 3901 /* Outside POSIX, it's preferable to compare the width
2967 against the number of _characters_ of the converted 3902 against the number of _characters_ of the converted
2968 value. */ 3903 value. */
2969 w = DCHAR_MBSNLEN (result + length, characters); 3904# if DCHAR_IS_TCHAR
3905 w = characters;
3906# else
3907 w = DCHAR_MBSNLEN (tmpdst, tmpdst_len);
3908# endif
2970# else 3909# else
2971 /* The width is compared against the number of _bytes_ 3910 /* The width is compared against the number of _bytes_
2972 of the converted value, says POSIX. */ 3911 of the converted value, says POSIX. */
2973 w = characters; 3912 w = bytes;
2974# endif 3913# endif
2975 } 3914 }
2976 else 3915 else
2977 /* w doesn't matter. */ 3916 /* w doesn't matter. */
2978 w = 0; 3917 w = 0;
2979 3918
2980 if (w < width && !(dp->flags & FLAG_LEFT)) 3919 if (w < width && !(flags & FLAG_LEFT))
2981 { 3920 {
2982 size_t n = width - w; 3921 size_t n = width - w;
3922# if DCHAR_IS_TCHAR
2983 ENSURE_ALLOCATION (xsum (length, n)); 3923 ENSURE_ALLOCATION (xsum (length, n));
3924# else
3925 ENSURE_ALLOCATION_ELSE (xsum (length, n),
3926 { free (tmpdst); goto out_of_memory; });
3927# endif
2984 DCHAR_SET (result + length, ' ', n); 3928 DCHAR_SET (result + length, ' ', n);
2985 length += n; 3929 length += n;
2986 } 3930 }
@@ -2989,16 +3933,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2989 if (has_width) 3933 if (has_width)
2990 { 3934 {
2991 /* We know the number of bytes in advance. */ 3935 /* We know the number of bytes in advance. */
2992 ENSURE_ALLOCATION (xsum (length, characters)); 3936 ENSURE_ALLOCATION (xsum (length, bytes));
2993 if (characters > 0) /* implies arg != 0 */ 3937 if (bytes > 0)
2994 { 3938 {
2995 int count;
2996# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3939# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2997 mbstate_t state; 3940 mbstate_t state;
2998 memset (&state, '\0', sizeof (mbstate_t)); 3941 mbszero (&state);
2999# endif 3942# endif
3000 3943
3001 count = local_wcrtomb (result + length, arg, &state); 3944 int count = local_wcrtomb (result + length, arg, &state);
3002 if (count <= 0) 3945 if (count <= 0)
3003 /* Inconsistency. */ 3946 /* Inconsistency. */
3004 abort (); 3947 abort ();
@@ -3007,33 +3950,29 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3007 } 3950 }
3008 else 3951 else
3009 { 3952 {
3010 if (arg != 0)
3011 {
3012 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3013 int count;
3014# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 3953# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
3015 mbstate_t state; 3954 mbstate_t state;
3016 memset (&state, '\0', sizeof (mbstate_t)); 3955 mbszero (&state);
3017# endif 3956# endif
3018 3957
3019 count = local_wcrtomb (cbuf, arg, &state); 3958 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3020 if (count <= 0) 3959 int count = local_wcrtomb (cbuf, arg, &state);
3021 /* Inconsistency. */ 3960 if (count < 0)
3022 abort (); 3961 /* Cannot convert. */
3023 ENSURE_ALLOCATION (xsum (length, count)); 3962 goto fail_with_EILSEQ;
3024 memcpy (result + length, cbuf, count); 3963 ENSURE_ALLOCATION (xsum (length, count));
3025 length += count; 3964 memcpy (result + length, cbuf, count);
3026 } 3965 length += count;
3027 } 3966 }
3028# else 3967# else
3029 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), 3968 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
3030 { free (tmpdst); goto out_of_memory; }); 3969 { free (tmpdst); goto out_of_memory; });
3031 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 3970 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
3032 free (tmpdst); 3971 free (tmpdst);
3033 length += tmpdst_len; 3972 length += tmpdst_len;
3034# endif 3973# endif
3035 3974
3036 if (w < width && (dp->flags & FLAG_LEFT)) 3975 if (w < width && (flags & FLAG_LEFT))
3037 { 3976 {
3038 size_t n = width - w; 3977 size_t n = width - w;
3039 ENSURE_ALLOCATION (xsum (length, n)); 3978 ENSURE_ALLOCATION (xsum (length, n));
@@ -3043,14 +3982,390 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3043 } 3982 }
3044 } 3983 }
3045#endif 3984#endif
3046#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 3985#if NEED_WPRINTF_DIRECTIVE_C && WIDE_CHAR_VERSION
3986 else if (dp->conversion == 'c'
3987 && a.arg[dp->arg_index].type != TYPE_WIDE_CHAR)
3988 {
3989 /* Implement the 'c' directive ourselves, in order to avoid
3990 EILSEQ in the "C" locale. */
3991 int flags = dp->flags;
3992
3993 size_t width = 0;
3994 if (dp->width_start != dp->width_end)
3995 {
3996 if (dp->width_arg_index != ARG_NONE)
3997 {
3998 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3999 abort ();
4000 int arg = a.arg[dp->width_arg_index].a.a_int;
4001 width = arg;
4002 if (arg < 0)
4003 {
4004 /* "A negative field width is taken as a '-' flag
4005 followed by a positive field width." */
4006 flags |= FLAG_LEFT;
4007 width = -width;
4008 }
4009 }
4010 else
4011 {
4012 const FCHAR_T *digitp = dp->width_start;
4013
4014 do
4015 width = xsum (xtimes (width, 10), *digitp++ - '0');
4016 while (digitp != dp->width_end);
4017 }
4018 if (width > (size_t) INT_MAX)
4019 goto overflow;
4020 }
4021
4022 /* %c in vasnwprintf. See the specification of fwprintf. */
4023 {
4024 char arg = (char) a.arg[dp->arg_index].a.a_char;
4025 mbstate_t state;
4026 mbszero (&state);
4027
4028 wchar_t wc;
4029 int count = mbrtowc (&wc, &arg, 1, &state);
4030 if (count < 0)
4031 /* Invalid or incomplete multibyte character. */
4032 goto fail_with_EILSEQ;
4033
4034 {
4035 size_t total = (1 < width ? width : 1);
4036 ENSURE_ALLOCATION (xsum (length, total));
4037
4038 if (1 < width && !(flags & FLAG_LEFT))
4039 {
4040 size_t n = width - 1;
4041 DCHAR_SET (result + length, ' ', n);
4042 length += n;
4043 }
4044
4045 result[length++] = wc;
4046
4047 if (1 < width && (flags & FLAG_LEFT))
4048 {
4049 size_t n = width - 1;
4050 DCHAR_SET (result + length, ' ', n);
4051 length += n;
4052 }
4053 }
4054 }
4055 }
4056#endif
4057#if NEED_PRINTF_DIRECTIVE_B || NEED_PRINTF_DIRECTIVE_UPPERCASE_B
4058 else if (0
4059# if NEED_PRINTF_DIRECTIVE_B
4060 || (dp->conversion == 'b')
4061# endif
4062# if NEED_PRINTF_DIRECTIVE_UPPERCASE_B
4063 || (dp->conversion == 'B')
4064# endif
4065 )
4066 {
4067 arg_type type = a.arg[dp->arg_index].type;
4068 int flags = dp->flags;
4069
4070 int has_width = 0;
4071 size_t width = 0;
4072 if (dp->width_start != dp->width_end)
4073 {
4074 if (dp->width_arg_index != ARG_NONE)
4075 {
4076 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4077 abort ();
4078 int arg = a.arg[dp->width_arg_index].a.a_int;
4079 width = arg;
4080 if (arg < 0)
4081 {
4082 /* "A negative field width is taken as a '-' flag
4083 followed by a positive field width." */
4084 flags |= FLAG_LEFT;
4085 width = -width;
4086 }
4087 }
4088 else
4089 {
4090 const FCHAR_T *digitp = dp->width_start;
4091
4092 do
4093 width = xsum (xtimes (width, 10), *digitp++ - '0');
4094 while (digitp != dp->width_end);
4095 }
4096 if (width > (size_t) INT_MAX)
4097 goto overflow;
4098 has_width = 1;
4099 }
4100
4101 int has_precision = 0;
4102 size_t precision = 1;
4103 if (dp->precision_start != dp->precision_end)
4104 {
4105 if (dp->precision_arg_index != ARG_NONE)
4106 {
4107 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4108 abort ();
4109 int arg = a.arg[dp->precision_arg_index].a.a_int;
4110 /* "A negative precision is taken as if the precision
4111 were omitted." */
4112 if (arg >= 0)
4113 {
4114 precision = arg;
4115 has_precision = 1;
4116 }
4117 }
4118 else
4119 {
4120 const FCHAR_T *digitp = dp->precision_start + 1;
4121
4122 precision = 0;
4123 while (digitp != dp->precision_end)
4124 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
4125 has_precision = 1;
4126 }
4127 }
4128
4129 /* Allocate a temporary buffer of sufficient size. */
4130 size_t tmp_length;
4131 switch (type)
4132 {
4133 default:
4134 tmp_length =
4135 (unsigned int) (sizeof (unsigned int) * CHAR_BIT)
4136 + 1; /* turn floor into ceil */
4137 break;
4138 case TYPE_ULONGINT:
4139 tmp_length =
4140 (unsigned int) (sizeof (unsigned long int) * CHAR_BIT)
4141 + 1; /* turn floor into ceil */
4142 break;
4143 case TYPE_ULONGLONGINT:
4144 tmp_length =
4145 (unsigned int) (sizeof (unsigned long long int) * CHAR_BIT)
4146 + 1; /* turn floor into ceil */
4147 break;
4148 case TYPE_UINT8_T:
4149 tmp_length =
4150 (unsigned int) (sizeof (uint8_t) * CHAR_BIT)
4151 + 1; /* turn floor into ceil */
4152 break;
4153 case TYPE_UINT16_T:
4154 tmp_length =
4155 (unsigned int) (sizeof (uint16_t) * CHAR_BIT)
4156 + 1; /* turn floor into ceil */
4157 break;
4158 case TYPE_UINT32_T:
4159 tmp_length =
4160 (unsigned int) (sizeof (uint32_t) * CHAR_BIT)
4161 + 1; /* turn floor into ceil */
4162 break;
4163 case TYPE_UINT64_T:
4164 tmp_length =
4165 (unsigned int) (sizeof (uint64_t) * CHAR_BIT)
4166 + 1; /* turn floor into ceil */
4167 break;
4168 case TYPE_UINT_FAST8_T:
4169 tmp_length =
4170 (unsigned int) (sizeof (uint_fast8_t) * CHAR_BIT)
4171 + 1; /* turn floor into ceil */
4172 break;
4173 case TYPE_UINT_FAST16_T:
4174 tmp_length =
4175 (unsigned int) (sizeof (uint_fast16_t) * CHAR_BIT)
4176 + 1; /* turn floor into ceil */
4177 break;
4178 case TYPE_UINT_FAST32_T:
4179 tmp_length =
4180 (unsigned int) (sizeof (uint_fast32_t) * CHAR_BIT)
4181 + 1; /* turn floor into ceil */
4182 break;
4183 case TYPE_UINT_FAST64_T:
4184 tmp_length =
4185 (unsigned int) (sizeof (uint_fast64_t) * CHAR_BIT)
4186 + 1; /* turn floor into ceil */
4187 break;
4188 }
4189 if (tmp_length < precision)
4190 tmp_length = precision;
4191 /* Add 2, to account for a prefix from the alternate form. */
4192 tmp_length = xsum (tmp_length, 2);
4193
4194 if (tmp_length < width)
4195 tmp_length = width;
4196
4197 DCHAR_T tmpbuf[700];
4198 DCHAR_T *tmp;
4199 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
4200 tmp = tmpbuf;
4201 else
4202 {
4203 size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
4204
4205 if (size_overflow_p (tmp_memsize))
4206 /* Overflow, would lead to out of memory. */
4207 goto out_of_memory;
4208 tmp = (DCHAR_T *) malloc (tmp_memsize);
4209 if (tmp == NULL)
4210 /* Out of memory. */
4211 goto out_of_memory;
4212 }
4213
4214 DCHAR_T *tmp_end = tmp + tmp_length;
4215
4216 unsigned long long arg;
4217 switch (type)
4218 {
4219 case TYPE_UCHAR:
4220 arg = a.arg[dp->arg_index].a.a_uchar;
4221 break;
4222 case TYPE_USHORT:
4223 arg = a.arg[dp->arg_index].a.a_ushort;
4224 break;
4225 case TYPE_UINT:
4226 arg = a.arg[dp->arg_index].a.a_uint;
4227 break;
4228 case TYPE_ULONGINT:
4229 arg = a.arg[dp->arg_index].a.a_ulongint;
4230 break;
4231 case TYPE_ULONGLONGINT:
4232 arg = a.arg[dp->arg_index].a.a_ulonglongint;
4233 break;
4234 case TYPE_UINT8_T:
4235 arg = a.arg[dp->arg_index].a.a_uint8_t;
4236 break;
4237 case TYPE_UINT16_T:
4238 arg = a.arg[dp->arg_index].a.a_uint16_t;
4239 break;
4240 case TYPE_UINT32_T:
4241 arg = a.arg[dp->arg_index].a.a_uint32_t;
4242 break;
4243 case TYPE_UINT64_T:
4244 arg = a.arg[dp->arg_index].a.a_uint64_t;
4245 break;
4246 case TYPE_UINT_FAST8_T:
4247 arg = a.arg[dp->arg_index].a.a_uint_fast8_t;
4248 break;
4249 case TYPE_UINT_FAST16_T:
4250 arg = a.arg[dp->arg_index].a.a_uint_fast16_t;
4251 break;
4252 case TYPE_UINT_FAST32_T:
4253 arg = a.arg[dp->arg_index].a.a_uint_fast32_t;
4254 break;
4255 case TYPE_UINT_FAST64_T:
4256 arg = a.arg[dp->arg_index].a.a_uint_fast64_t;
4257 break;
4258 default:
4259 abort ();
4260 }
4261 int need_prefix = ((flags & FLAG_ALT) && arg != 0);
4262
4263 DCHAR_T *p = tmp_end;
4264 /* "The result of converting a zero value with a precision
4265 of zero is no characters." */
4266 if (!(has_precision && precision == 0 && arg == 0))
4267 {
4268 do
4269 {
4270 *--p = '0' + (arg & 1);
4271 arg = arg >> 1;
4272 }
4273 while (arg != 0);
4274 }
4275
4276 if (has_precision)
4277 {
4278 DCHAR_T *digits_start = tmp_end - precision;
4279 while (p > digits_start)
4280 *--p = '0';
4281 }
4282
4283 DCHAR_T *pad_ptr = p;
4284
4285 if (need_prefix)
4286 {
4287# if NEED_PRINTF_DIRECTIVE_B && !NEED_PRINTF_DIRECTIVE_UPPERCASE_B
4288 *--p = 'b';
4289# elif NEED_PRINTF_DIRECTIVE_UPPERCASE_B && !NEED_PRINTF_DIRECTIVE_B
4290 *--p = 'B';
4291# else
4292 *--p = dp->conversion;
4293# endif
4294 *--p = '0';
4295 }
4296 DCHAR_T *tmp_start = p;
4297
4298 /* The generated string now extends from tmp_start to tmp_end,
4299 with the zero padding insertion point being at pad_ptr,
4300 tmp_start <= pad_ptr <= tmp_end. */
4301 size_t count = tmp_end - tmp_start;
4302
4303 if (count < width)
4304 {
4305 size_t pad = width - count;
4306
4307 if (flags & FLAG_LEFT)
4308 {
4309 /* Pad with spaces on the right. */
4310 for (p = tmp_start; p < tmp_end; p++)
4311 *(p - pad) = *p;
4312 for (p = tmp_end - pad; p < tmp_end; p++)
4313 *p = ' ';
4314 }
4315 else if ((flags & FLAG_ZERO)
4316 /* Neither ISO C nor POSIX specify that the '0'
4317 flag is ignored when a width and a precision
4318 are both present. But most implementations
4319 do so. */
4320 && !(has_width && has_precision))
4321 {
4322 /* Pad with zeroes. */
4323 for (p = tmp_start; p < pad_ptr; p++)
4324 *(p - pad) = *p;
4325 for (p = pad_ptr - pad; p < pad_ptr; p++)
4326 *p = '0';
4327 }
4328 else
4329 {
4330 /* Pad with spaces on the left. */
4331 for (p = tmp_start - pad; p < tmp_start; p++)
4332 *p = ' ';
4333 }
4334
4335 tmp_start = tmp_start - pad;
4336 }
4337
4338 count = tmp_end - tmp_start;
4339
4340 if (count > tmp_length)
4341 /* tmp_length was incorrectly calculated - fix the
4342 code above! */
4343 abort ();
4344
4345 /* Make room for the result. */
4346 if (count >= allocated - length)
4347 {
4348 size_t n = xsum (length, count);
4349
4350 ENSURE_ALLOCATION_ELSE (n,
4351 { if (tmp != tmpbuf) free (tmp); goto out_of_memory; });
4352 }
4353
4354 /* Append the result. */
4355 memcpy (result + length, tmp_start, count * sizeof (DCHAR_T));
4356 if (tmp != tmpbuf)
4357 free (tmp);
4358 length += count;
4359 }
4360#endif
4361#if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION)
3047 else if ((dp->conversion == 'a' || dp->conversion == 'A') 4362 else if ((dp->conversion == 'a' || dp->conversion == 'A')
3048# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) 4363# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
3049 && (0 4364 && (0
3050# if NEED_PRINTF_DOUBLE 4365# if NEED_PRINTF_DOUBLE
3051 || a.arg[dp->arg_index].type == TYPE_DOUBLE 4366 || a.arg[dp->arg_index].type == TYPE_DOUBLE
3052# endif 4367# endif
3053# if NEED_PRINTF_LONG_DOUBLE 4368# if NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION)
3054 || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE 4369 || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
3055# endif 4370# endif
3056 ) 4371 )
@@ -3059,26 +4374,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3059 { 4374 {
3060 arg_type type = a.arg[dp->arg_index].type; 4375 arg_type type = a.arg[dp->arg_index].type;
3061 int flags = dp->flags; 4376 int flags = dp->flags;
3062 size_t width;
3063 int has_precision;
3064 size_t precision;
3065 size_t tmp_length;
3066 size_t count;
3067 DCHAR_T tmpbuf[700];
3068 DCHAR_T *tmp;
3069 DCHAR_T *pad_ptr;
3070 DCHAR_T *p;
3071 4377
3072 width = 0; 4378 size_t width = 0;
3073 if (dp->width_start != dp->width_end) 4379 if (dp->width_start != dp->width_end)
3074 { 4380 {
3075 if (dp->width_arg_index != ARG_NONE) 4381 if (dp->width_arg_index != ARG_NONE)
3076 { 4382 {
3077 int arg;
3078
3079 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 4383 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3080 abort (); 4384 abort ();
3081 arg = a.arg[dp->width_arg_index].a.a_int; 4385 int arg = a.arg[dp->width_arg_index].a.a_int;
3082 width = arg; 4386 width = arg;
3083 if (arg < 0) 4387 if (arg < 0)
3084 { 4388 {
@@ -3096,19 +4400,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3096 width = xsum (xtimes (width, 10), *digitp++ - '0'); 4400 width = xsum (xtimes (width, 10), *digitp++ - '0');
3097 while (digitp != dp->width_end); 4401 while (digitp != dp->width_end);
3098 } 4402 }
4403 if (width > (size_t) INT_MAX)
4404 goto overflow;
3099 } 4405 }
3100 4406
3101 has_precision = 0; 4407 int has_precision = 0;
3102 precision = 0; 4408 size_t precision = 0;
3103 if (dp->precision_start != dp->precision_end) 4409 if (dp->precision_start != dp->precision_end)
3104 { 4410 {
3105 if (dp->precision_arg_index != ARG_NONE) 4411 if (dp->precision_arg_index != ARG_NONE)
3106 { 4412 {
3107 int arg;
3108
3109 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 4413 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
3110 abort (); 4414 abort ();
3111 arg = a.arg[dp->precision_arg_index].a.a_int; 4415 int arg = a.arg[dp->precision_arg_index].a.a_int;
3112 /* "A negative precision is taken as if the precision 4416 /* "A negative precision is taken as if the precision
3113 were omitted." */ 4417 were omitted." */
3114 if (arg >= 0) 4418 if (arg >= 0)
@@ -3129,6 +4433,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3129 } 4433 }
3130 4434
3131 /* Allocate a temporary buffer of sufficient size. */ 4435 /* Allocate a temporary buffer of sufficient size. */
4436 size_t tmp_length;
3132 if (type == TYPE_LONGDOUBLE) 4437 if (type == TYPE_LONGDOUBLE)
3133 tmp_length = 4438 tmp_length =
3134 (unsigned int) ((LDBL_DIG + 1) 4439 (unsigned int) ((LDBL_DIG + 1)
@@ -3151,6 +4456,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3151 4456
3152 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ 4457 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
3153 4458
4459 DCHAR_T tmpbuf[700];
4460 DCHAR_T *tmp;
3154 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) 4461 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
3155 tmp = tmpbuf; 4462 tmp = tmpbuf;
3156 else 4463 else
@@ -3166,11 +4473,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3166 goto out_of_memory; 4473 goto out_of_memory;
3167 } 4474 }
3168 4475
3169 pad_ptr = NULL; 4476 DCHAR_T *pad_ptr = NULL;
3170 p = tmp; 4477 DCHAR_T *p = tmp;
3171 if (type == TYPE_LONGDOUBLE) 4478 if (type == TYPE_LONGDOUBLE)
3172 { 4479 {
3173# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE 4480# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || (NEED_WPRINTF_DIRECTIVE_LA && WIDE_CHAR_VERSION)
3174 long double arg = a.arg[dp->arg_index].a.a_longdouble; 4481 long double arg = a.arg[dp->arg_index].a.a_longdouble;
3175 4482
3176 if (isnanl (arg)) 4483 if (isnanl (arg))
@@ -3186,11 +4493,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3186 } 4493 }
3187 else 4494 else
3188 { 4495 {
3189 int sign = 0;
3190 DECL_LONG_DOUBLE_ROUNDING 4496 DECL_LONG_DOUBLE_ROUNDING
3191 4497
3192 BEGIN_LONG_DOUBLE_ROUNDING (); 4498 BEGIN_LONG_DOUBLE_ROUNDING ();
3193 4499
4500 int sign = 0;
3194 if (signbit (arg)) /* arg < 0.0L or negative zero */ 4501 if (signbit (arg)) /* arg < 0.0L or negative zero */
3195 { 4502 {
3196 sign = -1; 4503 sign = -1;
@@ -3219,7 +4526,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3219 { 4526 {
3220 int exponent; 4527 int exponent;
3221 long double mantissa; 4528 long double mantissa;
3222
3223 if (arg > 0.0L) 4529 if (arg > 0.0L)
3224 mantissa = printf_frexpl (arg, &exponent); 4530 mantissa = printf_frexpl (arg, &exponent);
3225 else 4531 else
@@ -3233,9 +4539,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3233 { 4539 {
3234 /* Round the mantissa. */ 4540 /* Round the mantissa. */
3235 long double tail = mantissa; 4541 long double tail = mantissa;
3236 size_t q;
3237 4542
3238 for (q = precision; ; q--) 4543 for (size_t q = precision; ; q--)
3239 { 4544 {
3240 int digit = (int) tail; 4545 int digit = (int) tail;
3241 tail -= digit; 4546 tail -= digit;
@@ -3250,7 +4555,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3250 tail *= 16.0L; 4555 tail *= 16.0L;
3251 } 4556 }
3252 if (tail != 0.0L) 4557 if (tail != 0.0L)
3253 for (q = precision; q > 0; q--) 4558 for (size_t q = precision; q > 0; q--)
3254 tail *= 0.0625L; 4559 tail *= 0.0625L;
3255 mantissa += tail; 4560 mantissa += tail;
3256 } 4561 }
@@ -3259,9 +4564,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3259 *p++ = dp->conversion - 'A' + 'X'; 4564 *p++ = dp->conversion - 'A' + 'X';
3260 pad_ptr = p; 4565 pad_ptr = p;
3261 { 4566 {
3262 int digit; 4567 int digit = (int) mantissa;
3263
3264 digit = (int) mantissa;
3265 mantissa -= digit; 4568 mantissa -= digit;
3266 *p++ = '0' + digit; 4569 *p++ = '0' + digit;
3267 if ((flags & FLAG_ALT) 4570 if ((flags & FLAG_ALT)
@@ -3290,7 +4593,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3290 } 4593 }
3291 } 4594 }
3292 *p++ = dp->conversion - 'A' + 'P'; 4595 *p++ = dp->conversion - 'A' + 'P';
3293# if WIDE_CHAR_VERSION 4596# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
3294 { 4597 {
3295 static const wchar_t decimal_format[] = 4598 static const wchar_t decimal_format[] =
3296 { '%', '+', 'd', '\0' }; 4599 { '%', '+', 'd', '\0' };
@@ -3308,9 +4611,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3308 else 4611 else
3309 { 4612 {
3310 char expbuf[6 + 1]; 4613 char expbuf[6 + 1];
3311 const char *ep;
3312 sprintf (expbuf, "%+d", exponent); 4614 sprintf (expbuf, "%+d", exponent);
3313 for (ep = expbuf; (*p = *ep) != '\0'; ep++) 4615 for (const char *ep = expbuf; (*p = *ep) != '\0'; ep++)
3314 p++; 4616 p++;
3315 } 4617 }
3316# endif 4618# endif
@@ -3341,7 +4643,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3341 else 4643 else
3342 { 4644 {
3343 int sign = 0; 4645 int sign = 0;
3344
3345 if (signbit (arg)) /* arg < 0.0 or negative zero */ 4646 if (signbit (arg)) /* arg < 0.0 or negative zero */
3346 { 4647 {
3347 sign = -1; 4648 sign = -1;
@@ -3370,7 +4671,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3370 { 4671 {
3371 int exponent; 4672 int exponent;
3372 double mantissa; 4673 double mantissa;
3373
3374 if (arg > 0.0) 4674 if (arg > 0.0)
3375 mantissa = printf_frexp (arg, &exponent); 4675 mantissa = printf_frexp (arg, &exponent);
3376 else 4676 else
@@ -3384,9 +4684,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3384 { 4684 {
3385 /* Round the mantissa. */ 4685 /* Round the mantissa. */
3386 double tail = mantissa; 4686 double tail = mantissa;
3387 size_t q;
3388 4687
3389 for (q = precision; ; q--) 4688 for (size_t q = precision; ; q--)
3390 { 4689 {
3391 int digit = (int) tail; 4690 int digit = (int) tail;
3392 tail -= digit; 4691 tail -= digit;
@@ -3401,7 +4700,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3401 tail *= 16.0; 4700 tail *= 16.0;
3402 } 4701 }
3403 if (tail != 0.0) 4702 if (tail != 0.0)
3404 for (q = precision; q > 0; q--) 4703 for (size_t q = precision; q > 0; q--)
3405 tail *= 0.0625; 4704 tail *= 0.0625;
3406 mantissa += tail; 4705 mantissa += tail;
3407 } 4706 }
@@ -3410,9 +4709,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3410 *p++ = dp->conversion - 'A' + 'X'; 4709 *p++ = dp->conversion - 'A' + 'X';
3411 pad_ptr = p; 4710 pad_ptr = p;
3412 { 4711 {
3413 int digit; 4712 int digit = (int) mantissa;
3414
3415 digit = (int) mantissa;
3416 mantissa -= digit; 4713 mantissa -= digit;
3417 *p++ = '0' + digit; 4714 *p++ = '0' + digit;
3418 if ((flags & FLAG_ALT) 4715 if ((flags & FLAG_ALT)
@@ -3441,7 +4738,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3441 } 4738 }
3442 } 4739 }
3443 *p++ = dp->conversion - 'A' + 'P'; 4740 *p++ = dp->conversion - 'A' + 'P';
3444# if WIDE_CHAR_VERSION 4741# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
3445 { 4742 {
3446 static const wchar_t decimal_format[] = 4743 static const wchar_t decimal_format[] =
3447 { '%', '+', 'd', '\0' }; 4744 { '%', '+', 'd', '\0' };
@@ -3459,9 +4756,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3459 else 4756 else
3460 { 4757 {
3461 char expbuf[6 + 1]; 4758 char expbuf[6 + 1];
3462 const char *ep;
3463 sprintf (expbuf, "%+d", exponent); 4759 sprintf (expbuf, "%+d", exponent);
3464 for (ep = expbuf; (*p = *ep) != '\0'; ep++) 4760 for (const char *ep = expbuf; (*p = *ep) != '\0'; ep++)
3465 p++; 4761 p++;
3466 } 4762 }
3467# endif 4763# endif
@@ -3474,7 +4770,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3474 4770
3475 /* The generated string now extends from tmp to p, with the 4771 /* The generated string now extends from tmp to p, with the
3476 zero padding insertion point being at pad_ptr. */ 4772 zero padding insertion point being at pad_ptr. */
3477 count = p - tmp; 4773 size_t count = p - tmp;
3478 4774
3479 if (count < width) 4775 if (count < width)
3480 { 4776 {
@@ -3523,7 +4819,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3523 { 4819 {
3524 size_t n = xsum (length, count); 4820 size_t n = xsum (length, count);
3525 4821
3526 ENSURE_ALLOCATION (n); 4822 ENSURE_ALLOCATION_ELSE (n,
4823 { if (tmp != tmpbuf) free (tmp); goto out_of_memory; });
3527 } 4824 }
3528 4825
3529 /* Append the result. */ 4826 /* Append the result. */
@@ -3533,7 +4830,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3533 length += count; 4830 length += count;
3534 } 4831 }
3535#endif 4832#endif
3536#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 4833#if NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE
3537 else if ((dp->conversion == 'f' || dp->conversion == 'F' 4834 else if ((dp->conversion == 'f' || dp->conversion == 'F'
3538 || dp->conversion == 'e' || dp->conversion == 'E' 4835 || dp->conversion == 'e' || dp->conversion == 'E'
3539 || dp->conversion == 'g' || dp->conversion == 'G' 4836 || dp->conversion == 'g' || dp->conversion == 'G'
@@ -3554,8 +4851,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3554 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE 4851 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
3555 /* Some systems produce wrong output for Inf, 4852 /* Some systems produce wrong output for Inf,
3556 -Inf, and NaN. Some systems in this category 4853 -Inf, and NaN. Some systems in this category
3557 (IRIX 5.3) also do so for -0.0. Therefore we 4854 also do so for -0.0. Therefore we treat this
3558 treat this case here as well. */ 4855 case here as well. */
3559 && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble)) 4856 && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
3560# endif 4857# endif
3561 )) 4858 ))
@@ -3564,26 +4861,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3564 arg_type type = a.arg[dp->arg_index].type; 4861 arg_type type = a.arg[dp->arg_index].type;
3565# endif 4862# endif
3566 int flags = dp->flags; 4863 int flags = dp->flags;
3567 size_t width;
3568 size_t count;
3569 int has_precision;
3570 size_t precision;
3571 size_t tmp_length;
3572 DCHAR_T tmpbuf[700];
3573 DCHAR_T *tmp;
3574 DCHAR_T *pad_ptr;
3575 DCHAR_T *p;
3576 4864
3577 width = 0; 4865 size_t width = 0;
3578 if (dp->width_start != dp->width_end) 4866 if (dp->width_start != dp->width_end)
3579 { 4867 {
3580 if (dp->width_arg_index != ARG_NONE) 4868 if (dp->width_arg_index != ARG_NONE)
3581 { 4869 {
3582 int arg;
3583
3584 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 4870 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3585 abort (); 4871 abort ();
3586 arg = a.arg[dp->width_arg_index].a.a_int; 4872 int arg = a.arg[dp->width_arg_index].a.a_int;
3587 width = arg; 4873 width = arg;
3588 if (arg < 0) 4874 if (arg < 0)
3589 { 4875 {
@@ -3601,19 +4887,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3601 width = xsum (xtimes (width, 10), *digitp++ - '0'); 4887 width = xsum (xtimes (width, 10), *digitp++ - '0');
3602 while (digitp != dp->width_end); 4888 while (digitp != dp->width_end);
3603 } 4889 }
4890 if (width > (size_t) INT_MAX)
4891 goto overflow;
3604 } 4892 }
3605 4893
3606 has_precision = 0; 4894 int has_precision = 0;
3607 precision = 0; 4895 size_t precision = 0;
3608 if (dp->precision_start != dp->precision_end) 4896 if (dp->precision_start != dp->precision_end)
3609 { 4897 {
3610 if (dp->precision_arg_index != ARG_NONE) 4898 if (dp->precision_arg_index != ARG_NONE)
3611 { 4899 {
3612 int arg;
3613
3614 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 4900 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
3615 abort (); 4901 abort ();
3616 arg = a.arg[dp->precision_arg_index].a.a_int; 4902 int arg = a.arg[dp->precision_arg_index].a.a_int;
3617 /* "A negative precision is taken as if the precision 4903 /* "A negative precision is taken as if the precision
3618 were omitted." */ 4904 were omitted." */
3619 if (arg >= 0) 4905 if (arg >= 0)
@@ -3642,6 +4928,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3642 precision = 6; 4928 precision = 6;
3643 4929
3644 /* Allocate a temporary buffer of sufficient size. */ 4930 /* Allocate a temporary buffer of sufficient size. */
4931 size_t tmp_length;
3645# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE 4932# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
3646 tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); 4933 tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
3647# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE 4934# elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE
@@ -3687,6 +4974,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3687 } 4974 }
3688 } 4975 }
3689# endif 4976# endif
4977 /* Account for thousands separators. */
4978 if (flags & FLAG_GROUP)
4979 {
4980 /* A thousands separator needs to be inserted at most every 2 digits.
4981 This is the case in the ta_IN locale. */
4982# if WIDE_CHAR_VERSION
4983 tmp_length = xsum (tmp_length, tmp_length / 2 * THOUSEP_WCHAR_MAXLEN);
4984# else
4985 tmp_length = xsum (tmp_length, tmp_length / 2 * THOUSEP_CHAR_MAXLEN);
4986# endif
4987 }
3690 /* Account for sign, decimal point etc. */ 4988 /* Account for sign, decimal point etc. */
3691 tmp_length = xsum (tmp_length, 12); 4989 tmp_length = xsum (tmp_length, 12);
3692 4990
@@ -3695,6 +4993,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3695 4993
3696 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ 4994 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
3697 4995
4996 DCHAR_T tmpbuf[700];
4997 DCHAR_T *tmp;
3698 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) 4998 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
3699 tmp = tmpbuf; 4999 tmp = tmpbuf;
3700 else 5000 else
@@ -3710,8 +5010,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3710 goto out_of_memory; 5010 goto out_of_memory;
3711 } 5011 }
3712 5012
3713 pad_ptr = NULL; 5013 DCHAR_T *pad_ptr = NULL;
3714 p = tmp; 5014 DCHAR_T *p = tmp;
3715 5015
3716# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE 5016# if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
3717# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE 5017# if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
@@ -3733,11 +5033,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3733 } 5033 }
3734 else 5034 else
3735 { 5035 {
3736 int sign = 0;
3737 DECL_LONG_DOUBLE_ROUNDING 5036 DECL_LONG_DOUBLE_ROUNDING
3738 5037
3739 BEGIN_LONG_DOUBLE_ROUNDING (); 5038 BEGIN_LONG_DOUBLE_ROUNDING ();
3740 5039
5040 int sign = 0;
3741 if (signbit (arg)) /* arg < 0.0L or negative zero */ 5041 if (signbit (arg)) /* arg < 0.0L or negative zero */
3742 { 5042 {
3743 sign = -1; 5043 sign = -1;
@@ -3769,25 +5069,94 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3769 5069
3770 if (dp->conversion == 'f' || dp->conversion == 'F') 5070 if (dp->conversion == 'f' || dp->conversion == 'F')
3771 { 5071 {
3772 char *digits; 5072 char *digits =
3773 size_t ndigits;
3774
3775 digits =
3776 scale10_round_decimal_long_double (arg, precision); 5073 scale10_round_decimal_long_double (arg, precision);
3777 if (digits == NULL) 5074 if (digits == NULL)
3778 { 5075 {
3779 END_LONG_DOUBLE_ROUNDING (); 5076 END_LONG_DOUBLE_ROUNDING ();
3780 goto out_of_memory; 5077 goto out_of_memory;
3781 } 5078 }
3782 ndigits = strlen (digits); 5079 size_t ndigits = strlen (digits);
3783 5080
3784 if (ndigits > precision) 5081 if (ndigits > precision)
3785 do 5082 {
3786 { 5083 /* Number of digits before the decimal point. */
3787 --ndigits; 5084 size_t intpart_digits = ndigits - precision;
3788 *p++ = digits[ndigits]; 5085
3789 } 5086 const DCHAR_T *thousep = NULL;
3790 while (ndigits > precision); 5087 DCHAR_T thousep_buf[10];
5088# if !WIDE_CHAR_VERSION
5089 size_t thousep_len = 0;
5090# endif
5091 const signed char *grouping;
5092 size_t insert = 0;
5093
5094 if ((flags & FLAG_GROUP) && (intpart_digits > 1))
5095 {
5096 /* Determine the thousands separator and
5097 the grouping rule of the current locale. */
5098# if WIDE_CHAR_VERSION
5099 /* DCHAR_T is wchar_t. */
5100 thousep = thousands_separator_wchar (thousep_buf);
5101# define thousep_len 1
5102# elif defined DCHAR_CONV_FROM_ENCODING
5103 /* DCHAR_T is uintN_t. */
5104 thousep = thousands_separator_DCHAR (thousep_buf);
5105 thousep_len = DCHAR_STRLEN (thousep);
5106# else
5107 /* DCHAR_T is char. */
5108 thousep = thousands_separator_char (thousep_buf);
5109 thousep_len = strlen (thousep);
5110# endif
5111 if (*thousep == 0)
5112 thousep = NULL;
5113 if (thousep != NULL)
5114 {
5115 grouping = grouping_rule ();
5116 insert =
5117 num_thousands_separators (grouping, intpart_digits);
5118 }
5119 }
5120
5121 const char *digitp = digits + precision;
5122 DCHAR_T *p_before_intpart = p;
5123 p += intpart_digits + insert * thousep_len;
5124 DCHAR_T *p_after_intpart = p;
5125 if (insert > 0) /* implies (flag & FLAG_GROUP) && (thousep != NULL) */
5126 {
5127 const signed char *g = grouping;
5128 for (;;)
5129 {
5130 int h = *g;
5131 if (h <= 0)
5132 abort ();
5133 int i = h;
5134 do
5135 *--p = *digitp++;
5136 while (--i > 0);
5137# if WIDE_CHAR_VERSION
5138 *--p = thousep[0];
5139# else
5140 p -= thousep_len;
5141 DCHAR_CPY (p, thousep, thousep_len);
5142# endif
5143 insert--;
5144 if (insert == 0)
5145 break;
5146 if (g[1] != 0)
5147 g++;
5148 }
5149 }
5150 for (;;)
5151 {
5152 *--p = *digitp++;
5153 if (p == p_before_intpart)
5154 break;
5155 }
5156 p = p_after_intpart;
5157 ndigits = precision;
5158# undef thousep_len
5159 }
3791 else 5160 else
3792 *p++ = '0'; 5161 *p++ = '0';
3793 /* Here ndigits <= precision. */ 5162 /* Here ndigits <= precision. */
@@ -3823,12 +5192,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3823 else 5192 else
3824 { 5193 {
3825 /* arg > 0.0L. */ 5194 /* arg > 0.0L. */
3826 int adjusted; 5195 exponent = floorlog10l (arg);
5196 int adjusted = 0;
3827 char *digits; 5197 char *digits;
3828 size_t ndigits; 5198 size_t ndigits;
3829
3830 exponent = floorlog10l (arg);
3831 adjusted = 0;
3832 for (;;) 5199 for (;;)
3833 { 5200 {
3834 digits = 5201 digits =
@@ -3901,7 +5268,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3901 } 5268 }
3902 5269
3903 *p++ = dp->conversion; /* 'e' or 'E' */ 5270 *p++ = dp->conversion; /* 'e' or 'E' */
3904# if WIDE_CHAR_VERSION 5271# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
3905 { 5272 {
3906 static const wchar_t decimal_format[] = 5273 static const wchar_t decimal_format[] =
3907 { '%', '+', '.', '2', 'd', '\0' }; 5274 { '%', '+', '.', '2', 'd', '\0' };
@@ -3919,9 +5286,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3919 else 5286 else
3920 { 5287 {
3921 char expbuf[6 + 1]; 5288 char expbuf[6 + 1];
3922 const char *ep;
3923 sprintf (expbuf, "%+.2d", exponent); 5289 sprintf (expbuf, "%+.2d", exponent);
3924 for (ep = expbuf; (*p = *ep) != '\0'; ep++) 5290 for (const char *ep = expbuf; (*p = *ep) != '\0'; ep++)
3925 p++; 5291 p++;
3926 } 5292 }
3927# endif 5293# endif
@@ -3957,14 +5323,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3957 else 5323 else
3958 { 5324 {
3959 /* arg > 0.0L. */ 5325 /* arg > 0.0L. */
3960 int exponent; 5326 int exponent = floorlog10l (arg);
3961 int adjusted; 5327 int adjusted = 0;
3962 char *digits; 5328 char *digits;
3963 size_t ndigits; 5329 size_t ndigits;
3964 size_t nzeroes;
3965
3966 exponent = floorlog10l (arg);
3967 adjusted = 0;
3968 for (;;) 5330 for (;;)
3969 { 5331 {
3970 digits = 5332 digits =
@@ -4024,7 +5386,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4024 5386
4025 /* Determine the number of trailing zeroes 5387 /* Determine the number of trailing zeroes
4026 that have to be dropped. */ 5388 that have to be dropped. */
4027 nzeroes = 0; 5389 size_t nzeroes = 0;
4028 if ((flags & FLAG_ALT) == 0) 5390 if ((flags & FLAG_ALT) == 0)
4029 while (nzeroes < ndigits 5391 while (nzeroes < ndigits
4030 && digits[nzeroes] == '0') 5392 && digits[nzeroes] == '0')
@@ -4040,10 +5402,84 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4040 digits without trailing zeroes. */ 5402 digits without trailing zeroes. */
4041 if (exponent >= 0) 5403 if (exponent >= 0)
4042 { 5404 {
4043 size_t ecount = exponent + 1; 5405 /* Number of digits before the decimal point. */
4044 /* Note: count <= precision = ndigits. */ 5406 size_t intpart_digits = exponent + 1;
4045 for (; ecount > 0; ecount--) 5407 /* Note: intpart_digits <= precision = ndigits. */
4046 *p++ = digits[--ndigits]; 5408
5409 const DCHAR_T *thousep = NULL;
5410 DCHAR_T thousep_buf[10];
5411# if !WIDE_CHAR_VERSION
5412 size_t thousep_len = 0;
5413# endif
5414 const signed char *grouping;
5415 size_t insert = 0;
5416
5417 if ((flags & FLAG_GROUP) && (intpart_digits > 1))
5418 {
5419 /* Determine the thousands separator and
5420 the grouping rule of the current locale. */
5421# if WIDE_CHAR_VERSION
5422 /* DCHAR_T is wchar_t. */
5423 thousep = thousands_separator_wchar (thousep_buf);
5424# define thousep_len 1
5425# elif defined DCHAR_CONV_FROM_ENCODING
5426 /* DCHAR_T is uintN_t. */
5427 thousep = thousands_separator_DCHAR (thousep_buf);
5428 thousep_len = DCHAR_STRLEN (thousep);
5429# else
5430 /* DCHAR_T is char. */
5431 thousep = thousands_separator_char (thousep_buf);
5432 thousep_len = strlen (thousep);
5433# endif
5434 if (*thousep == 0)
5435 thousep = NULL;
5436 if (thousep != NULL)
5437 {
5438 grouping = grouping_rule ();
5439 insert =
5440 num_thousands_separators (grouping, intpart_digits);
5441 }
5442 }
5443
5444 const char *digitp = digits + ndigits - intpart_digits;
5445 DCHAR_T *p_before_intpart = p;
5446 p += intpart_digits + insert * thousep_len;
5447 DCHAR_T *p_after_intpart = p;
5448 if (insert > 0) /* implies (flag & FLAG_GROUP) && (thousep != NULL) */
5449 {
5450 const signed char *g = grouping;
5451 for (;;)
5452 {
5453 int h = *g;
5454 if (h <= 0)
5455 abort ();
5456 int i = h;
5457 do
5458 *--p = *digitp++;
5459 while (--i > 0);
5460# if WIDE_CHAR_VERSION
5461 *--p = thousep[0];
5462# else
5463 p -= thousep_len;
5464 DCHAR_CPY (p, thousep, thousep_len);
5465# endif
5466 insert--;
5467 if (insert == 0)
5468 break;
5469 if (g[1] != 0)
5470 g++;
5471 }
5472 }
5473 for (;;)
5474 {
5475 *--p = *digitp++;
5476 if (p == p_before_intpart)
5477 break;
5478 }
5479 p = p_after_intpart;
5480 ndigits -= intpart_digits;
5481# undef thousep_len
5482
4047 if ((flags & FLAG_ALT) || ndigits > nzeroes) 5483 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4048 { 5484 {
4049 *p++ = decimal_point_char (); 5485 *p++ = decimal_point_char ();
@@ -4082,7 +5518,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4082 } 5518 }
4083 } 5519 }
4084 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ 5520 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
4085# if WIDE_CHAR_VERSION 5521# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
4086 { 5522 {
4087 static const wchar_t decimal_format[] = 5523 static const wchar_t decimal_format[] =
4088 { '%', '+', '.', '2', 'd', '\0' }; 5524 { '%', '+', '.', '2', 'd', '\0' };
@@ -4100,9 +5536,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4100 else 5536 else
4101 { 5537 {
4102 char expbuf[6 + 1]; 5538 char expbuf[6 + 1];
4103 const char *ep;
4104 sprintf (expbuf, "%+.2d", exponent); 5539 sprintf (expbuf, "%+.2d", exponent);
4105 for (ep = expbuf; (*p = *ep) != '\0'; ep++) 5540 for (const char *ep = expbuf; (*p = *ep) != '\0'; ep++)
4106 p++; 5541 p++;
4107 } 5542 }
4108# endif 5543# endif
@@ -4202,7 +5637,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4202 else 5637 else
4203 { 5638 {
4204 int sign = 0; 5639 int sign = 0;
4205
4206 if (signbit (arg)) /* arg < 0.0 or negative zero */ 5640 if (signbit (arg)) /* arg < 0.0 or negative zero */
4207 { 5641 {
4208 sign = -1; 5642 sign = -1;
@@ -4234,22 +5668,91 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4234 5668
4235 if (dp->conversion == 'f' || dp->conversion == 'F') 5669 if (dp->conversion == 'f' || dp->conversion == 'F')
4236 { 5670 {
4237 char *digits; 5671 char *digits =
4238 size_t ndigits;
4239
4240 digits =
4241 scale10_round_decimal_double (arg, precision); 5672 scale10_round_decimal_double (arg, precision);
4242 if (digits == NULL) 5673 if (digits == NULL)
4243 goto out_of_memory; 5674 goto out_of_memory;
4244 ndigits = strlen (digits); 5675 size_t ndigits = strlen (digits);
4245 5676
4246 if (ndigits > precision) 5677 if (ndigits > precision)
4247 do 5678 {
4248 { 5679 /* Number of digits before the decimal point. */
4249 --ndigits; 5680 size_t intpart_digits = ndigits - precision;
4250 *p++ = digits[ndigits]; 5681
4251 } 5682 const DCHAR_T *thousep = NULL;
4252 while (ndigits > precision); 5683 DCHAR_T thousep_buf[10];
5684# if !WIDE_CHAR_VERSION
5685 size_t thousep_len = 0;
5686# endif
5687 const signed char *grouping;
5688 size_t insert = 0;
5689
5690 if ((flags & FLAG_GROUP) && (intpart_digits > 1))
5691 {
5692 /* Determine the thousands separator and
5693 the grouping rule of the current locale. */
5694# if WIDE_CHAR_VERSION
5695 /* DCHAR_T is wchar_t. */
5696 thousep = thousands_separator_wchar (thousep_buf);
5697# define thousep_len 1
5698# elif defined DCHAR_CONV_FROM_ENCODING
5699 /* DCHAR_T is uintN_t. */
5700 thousep = thousands_separator_DCHAR (thousep_buf);
5701 thousep_len = DCHAR_STRLEN (thousep);
5702# else
5703 /* DCHAR_T is char. */
5704 thousep = thousands_separator_char (thousep_buf);
5705 thousep_len = strlen (thousep);
5706# endif
5707 if (*thousep == 0)
5708 thousep = NULL;
5709 if (thousep != NULL)
5710 {
5711 grouping = grouping_rule ();
5712 insert =
5713 num_thousands_separators (grouping, intpart_digits);
5714 }
5715 }
5716
5717 const char *digitp = digits + precision;
5718 DCHAR_T *p_before_intpart = p;
5719 p += intpart_digits + insert * thousep_len;
5720 DCHAR_T *p_after_intpart = p;
5721 if (insert > 0) /* implies (flag & FLAG_GROUP) && (thousep != NULL) */
5722 {
5723 const signed char *g = grouping;
5724 for (;;)
5725 {
5726 int h = *g;
5727 if (h <= 0)
5728 abort ();
5729 int i = h;
5730 do
5731 *--p = *digitp++;
5732 while (--i > 0);
5733# if WIDE_CHAR_VERSION
5734 *--p = thousep[0];
5735# else
5736 p -= thousep_len;
5737 DCHAR_CPY (p, thousep, thousep_len);
5738# endif
5739 insert--;
5740 if (insert == 0)
5741 break;
5742 if (g[1] != 0)
5743 g++;
5744 }
5745 }
5746 for (;;)
5747 {
5748 *--p = *digitp++;
5749 if (p == p_before_intpart)
5750 break;
5751 }
5752 p = p_after_intpart;
5753 ndigits = precision;
5754# undef thousep_len
5755 }
4253 else 5756 else
4254 *p++ = '0'; 5757 *p++ = '0';
4255 /* Here ndigits <= precision. */ 5758 /* Here ndigits <= precision. */
@@ -4285,12 +5788,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4285 else 5788 else
4286 { 5789 {
4287 /* arg > 0.0. */ 5790 /* arg > 0.0. */
4288 int adjusted; 5791 exponent = floorlog10 (arg);
5792 int adjusted = 0;
4289 char *digits; 5793 char *digits;
4290 size_t ndigits; 5794 size_t ndigits;
4291
4292 exponent = floorlog10 (arg);
4293 adjusted = 0;
4294 for (;;) 5795 for (;;)
4295 { 5796 {
4296 digits = 5797 digits =
@@ -4359,7 +5860,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4359 } 5860 }
4360 5861
4361 *p++ = dp->conversion; /* 'e' or 'E' */ 5862 *p++ = dp->conversion; /* 'e' or 'E' */
4362# if WIDE_CHAR_VERSION 5863# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
4363 { 5864 {
4364 static const wchar_t decimal_format[] = 5865 static const wchar_t decimal_format[] =
4365 /* Produce the same number of exponent digits 5866 /* Produce the same number of exponent digits
@@ -4392,9 +5893,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4392 else 5893 else
4393 { 5894 {
4394 char expbuf[6 + 1]; 5895 char expbuf[6 + 1];
4395 const char *ep;
4396 sprintf (expbuf, decimal_format, exponent); 5896 sprintf (expbuf, decimal_format, exponent);
4397 for (ep = expbuf; (*p = *ep) != '\0'; ep++) 5897 for (const char *ep = expbuf; (*p = *ep) != '\0'; ep++)
4398 p++; 5898 p++;
4399 } 5899 }
4400 } 5900 }
@@ -4431,14 +5931,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4431 else 5931 else
4432 { 5932 {
4433 /* arg > 0.0. */ 5933 /* arg > 0.0. */
4434 int exponent; 5934 int exponent = floorlog10 (arg);
4435 int adjusted; 5935 int adjusted = 0;
4436 char *digits; 5936 char *digits;
4437 size_t ndigits; 5937 size_t ndigits;
4438 size_t nzeroes;
4439
4440 exponent = floorlog10 (arg);
4441 adjusted = 0;
4442 for (;;) 5938 for (;;)
4443 { 5939 {
4444 digits = 5940 digits =
@@ -4494,7 +5990,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4494 5990
4495 /* Determine the number of trailing zeroes 5991 /* Determine the number of trailing zeroes
4496 that have to be dropped. */ 5992 that have to be dropped. */
4497 nzeroes = 0; 5993 size_t nzeroes = 0;
4498 if ((flags & FLAG_ALT) == 0) 5994 if ((flags & FLAG_ALT) == 0)
4499 while (nzeroes < ndigits 5995 while (nzeroes < ndigits
4500 && digits[nzeroes] == '0') 5996 && digits[nzeroes] == '0')
@@ -4510,10 +6006,84 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4510 digits without trailing zeroes. */ 6006 digits without trailing zeroes. */
4511 if (exponent >= 0) 6007 if (exponent >= 0)
4512 { 6008 {
4513 size_t ecount = exponent + 1; 6009 /* Number of digits before the decimal point. */
4514 /* Note: ecount <= precision = ndigits. */ 6010 size_t intpart_digits = exponent + 1;
4515 for (; ecount > 0; ecount--) 6011 /* Note: intpart_digits <= precision = ndigits. */
4516 *p++ = digits[--ndigits]; 6012
6013 const DCHAR_T *thousep = NULL;
6014 DCHAR_T thousep_buf[10];
6015# if !WIDE_CHAR_VERSION
6016 size_t thousep_len = 0;
6017# endif
6018 const signed char *grouping;
6019 size_t insert = 0;
6020
6021 if ((flags & FLAG_GROUP) && (intpart_digits > 1))
6022 {
6023 /* Determine the thousands separator and
6024 the grouping rule of the current locale. */
6025# if WIDE_CHAR_VERSION
6026 /* DCHAR_T is wchar_t. */
6027 thousep = thousands_separator_wchar (thousep_buf);
6028# define thousep_len 1
6029# elif defined DCHAR_CONV_FROM_ENCODING
6030 /* DCHAR_T is uintN_t. */
6031 thousep = thousands_separator_DCHAR (thousep_buf);
6032 thousep_len = DCHAR_STRLEN (thousep);
6033# else
6034 /* DCHAR_T is char. */
6035 thousep = thousands_separator_char (thousep_buf);
6036 thousep_len = strlen (thousep);
6037# endif
6038 if (*thousep == 0)
6039 thousep = NULL;
6040 if (thousep != NULL)
6041 {
6042 grouping = grouping_rule ();
6043 insert =
6044 num_thousands_separators (grouping, intpart_digits);
6045 }
6046 }
6047
6048 const char *digitp = digits + ndigits - intpart_digits;
6049 DCHAR_T *p_before_intpart = p;
6050 p += intpart_digits + insert * thousep_len;
6051 DCHAR_T *p_after_intpart = p;
6052 if (insert > 0) /* implies (flag & FLAG_GROUP) && (thousep != NULL) */
6053 {
6054 const signed char *g = grouping;
6055 for (;;)
6056 {
6057 int h = *g;
6058 if (h <= 0)
6059 abort ();
6060 int i = h;
6061 do
6062 *--p = *digitp++;
6063 while (--i > 0);
6064# if WIDE_CHAR_VERSION
6065 *--p = thousep[0];
6066# else
6067 p -= thousep_len;
6068 DCHAR_CPY (p, thousep, thousep_len);
6069# endif
6070 insert--;
6071 if (insert == 0)
6072 break;
6073 if (g[1] != 0)
6074 g++;
6075 }
6076 }
6077 for (;;)
6078 {
6079 *--p = *digitp++;
6080 if (p == p_before_intpart)
6081 break;
6082 }
6083 p = p_after_intpart;
6084 ndigits -= intpart_digits;
6085# undef thousep_len
6086
4517 if ((flags & FLAG_ALT) || ndigits > nzeroes) 6087 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4518 { 6088 {
4519 *p++ = decimal_point_char (); 6089 *p++ = decimal_point_char ();
@@ -4552,7 +6122,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4552 } 6122 }
4553 } 6123 }
4554 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ 6124 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
4555# if WIDE_CHAR_VERSION 6125# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
4556 { 6126 {
4557 static const wchar_t decimal_format[] = 6127 static const wchar_t decimal_format[] =
4558 /* Produce the same number of exponent digits 6128 /* Produce the same number of exponent digits
@@ -4585,9 +6155,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4585 else 6155 else
4586 { 6156 {
4587 char expbuf[6 + 1]; 6157 char expbuf[6 + 1];
4588 const char *ep;
4589 sprintf (expbuf, decimal_format, exponent); 6158 sprintf (expbuf, decimal_format, exponent);
4590 for (ep = expbuf; (*p = *ep) != '\0'; ep++) 6159 for (const char *ep = expbuf; (*p = *ep) != '\0'; ep++)
4591 p++; 6160 p++;
4592 } 6161 }
4593 } 6162 }
@@ -4657,7 +6226,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4657 6226
4658 /* The generated string now extends from tmp to p, with the 6227 /* The generated string now extends from tmp to p, with the
4659 zero padding insertion point being at pad_ptr. */ 6228 zero padding insertion point being at pad_ptr. */
4660 count = p - tmp; 6229 size_t count = p - tmp;
4661 6230
4662 if (count < width) 6231 if (count < width)
4663 { 6232 {
@@ -4706,7 +6275,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4706 { 6275 {
4707 size_t n = xsum (length, count); 6276 size_t n = xsum (length, count);
4708 6277
4709 ENSURE_ALLOCATION (n); 6278 ENSURE_ALLOCATION_ELSE (n,
6279 { if (tmp != tmpbuf) free (tmp); goto out_of_memory; });
4710 } 6280 }
4711 6281
4712 /* Append the result. */ 6282 /* Append the result. */
@@ -4720,24 +6290,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4720 { 6290 {
4721 arg_type type = a.arg[dp->arg_index].type; 6291 arg_type type = a.arg[dp->arg_index].type;
4722 int flags = dp->flags; 6292 int flags = dp->flags;
4723#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 6293#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4724 int has_width;
4725#endif
4726#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4727 size_t width;
4728#endif
4729#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4730 int has_precision;
4731 size_t precision;
4732#endif
4733#if NEED_PRINTF_UNBOUNDED_PRECISION
4734 int prec_ourselves; 6294 int prec_ourselves;
4735#else 6295#else
4736# define prec_ourselves 0 6296# define prec_ourselves 0
4737#endif 6297#endif
4738#if NEED_PRINTF_FLAG_LEFTADJUST 6298#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
6299 int group_ourselves;
6300#else
6301# define group_ourselves 0
6302#endif
6303#if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST
4739# define pad_ourselves 1 6304# define pad_ourselves 1
4740#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 6305#elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
4741 int pad_ourselves; 6306 int pad_ourselves;
4742#else 6307#else
4743# define pad_ourselves 0 6308# define pad_ourselves 0
@@ -4752,20 +6317,18 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4752 TCHAR_T *tmp; 6317 TCHAR_T *tmp;
4753#endif 6318#endif
4754 6319
4755#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 6320#if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
4756 has_width = 0; 6321 int has_width = 0;
4757#endif 6322#endif
4758#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 6323#if !USE_SNPRINTF || WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_FLAG_LEFTADJUST || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
4759 width = 0; 6324 size_t width = 0;
4760 if (dp->width_start != dp->width_end) 6325 if (dp->width_start != dp->width_end)
4761 { 6326 {
4762 if (dp->width_arg_index != ARG_NONE) 6327 if (dp->width_arg_index != ARG_NONE)
4763 { 6328 {
4764 int arg;
4765
4766 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 6329 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4767 abort (); 6330 abort ();
4768 arg = a.arg[dp->width_arg_index].a.a_int; 6331 int arg = a.arg[dp->width_arg_index].a.a_int;
4769 width = arg; 6332 width = arg;
4770 if (arg < 0) 6333 if (arg < 0)
4771 { 6334 {
@@ -4783,24 +6346,25 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4783 width = xsum (xtimes (width, 10), *digitp++ - '0'); 6346 width = xsum (xtimes (width, 10), *digitp++ - '0');
4784 while (digitp != dp->width_end); 6347 while (digitp != dp->width_end);
4785 } 6348 }
4786#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 6349 if (width > (size_t) INT_MAX)
6350 goto overflow;
6351# define WIDTH_IS_CHECKED 1
6352# if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
4787 has_width = 1; 6353 has_width = 1;
4788#endif 6354# endif
4789 } 6355 }
4790#endif 6356#endif
4791 6357
4792#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION 6358#if !USE_SNPRINTF || (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
4793 has_precision = 0; 6359 int has_precision = 0;
4794 precision = 6; 6360 size_t precision = 6;
4795 if (dp->precision_start != dp->precision_end) 6361 if (dp->precision_start != dp->precision_end)
4796 { 6362 {
4797 if (dp->precision_arg_index != ARG_NONE) 6363 if (dp->precision_arg_index != ARG_NONE)
4798 { 6364 {
4799 int arg;
4800
4801 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 6365 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4802 abort (); 6366 abort ();
4803 arg = a.arg[dp->precision_arg_index].a.a_int; 6367 int arg = a.arg[dp->precision_arg_index].a.a_int;
4804 /* "A negative precision is taken as if the precision 6368 /* "A negative precision is taken as if the precision
4805 were omitted." */ 6369 were omitted." */
4806 if (arg >= 0) 6370 if (arg >= 0)
@@ -4822,39 +6386,88 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4822#endif 6386#endif
4823 6387
4824 /* Decide whether to handle the precision ourselves. */ 6388 /* Decide whether to handle the precision ourselves. */
4825#if NEED_PRINTF_UNBOUNDED_PRECISION 6389#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4826 switch (dp->conversion) 6390 switch (dp->conversion)
4827 { 6391 {
6392# if NEED_PRINTF_UNBOUNDED_PRECISION
4828 case 'd': case 'i': case 'u': 6393 case 'd': case 'i': case 'u':
6394 case 'b':
6395 #if SUPPORT_GNU_PRINTF_DIRECTIVES \
6396 || (__GLIBC__ + (__GLIBC_MINOR__ >= 35) > 2)
6397 case 'B':
6398 #endif
4829 case 'o': 6399 case 'o':
4830 case 'x': case 'X': case 'p':
4831 prec_ourselves = has_precision && (precision > 0); 6400 prec_ourselves = has_precision && (precision > 0);
4832 break; 6401 break;
6402# endif
6403 case 'x': case 'X': case 'p':
6404 prec_ourselves =
6405 has_precision
6406 && (0
6407# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO
6408 || (precision == 0)
6409# endif
6410# if NEED_PRINTF_UNBOUNDED_PRECISION
6411 || (precision > 0)
6412# endif
6413 );
6414 break;
4833 default: 6415 default:
4834 prec_ourselves = 0; 6416 prec_ourselves = 0;
4835 break; 6417 break;
4836 } 6418 }
4837#endif 6419#endif
4838 6420
6421 /* Decide whether to add the thousands separators ourselves. */
6422#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
6423 if (flags & FLAG_GROUP)
6424 {
6425 switch (dp->conversion)
6426 {
6427 case 'd': case 'i': case 'u':
6428# if NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
6429 group_ourselves = 1;
6430# else
6431 group_ourselves = prec_ourselves;
6432# endif
6433 break;
6434 case 'f': case 'F': case 'g': case 'G':
6435# if NEED_PRINTF_FLAG_GROUPING
6436 group_ourselves = 1;
6437# else
6438 group_ourselves = prec_ourselves;
6439# endif
6440 break;
6441 default:
6442 group_ourselves = 0;
6443 break;
6444 }
6445 }
6446 else
6447 group_ourselves = 0;
6448#endif
6449
4839 /* Decide whether to perform the padding ourselves. */ 6450 /* Decide whether to perform the padding ourselves. */
4840#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) 6451#if !((WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST) && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT)
4841 switch (dp->conversion) 6452 switch (dp->conversion)
4842 { 6453 {
4843# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO 6454# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO
6455# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
4844 /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need 6456 /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
4845 to perform the padding after this conversion. Functions 6457 to perform the padding after this conversion. Functions
4846 with unistdio extensions perform the padding based on 6458 with unistdio extensions perform the padding based on
4847 character count rather than element count. */ 6459 character count rather than element count. */
4848 case 'c': case 's': 6460 case 'c': case 's':
4849# endif 6461# endif
4850# if NEED_PRINTF_FLAG_ZERO 6462# if NEED_PRINTF_FLAG_ZERO
4851 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': 6463 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
4852 case 'a': case 'A': 6464 case 'a': case 'A':
4853# endif 6465# endif
4854 pad_ourselves = 1; 6466 pad_ourselves = 1;
4855 break; 6467 break;
6468# endif
4856 default: 6469 default:
4857 pad_ourselves = prec_ourselves; 6470 pad_ourselves = prec_ourselves | group_ourselves;
4858 break; 6471 break;
4859 } 6472 }
4860#endif 6473#endif
@@ -4887,14 +6500,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4887 sprintf. */ 6500 sprintf. */
4888 fbp = buf; 6501 fbp = buf;
4889 *fbp++ = '%'; 6502 *fbp++ = '%';
4890#if NEED_PRINTF_FLAG_GROUPING 6503 if ((flags & FLAG_GROUP) && !group_ourselves)
4891 /* The underlying implementation doesn't support the ' flag.
4892 Produce no grouping characters in this case; this is
4893 acceptable because the grouping is locale dependent. */
4894#else
4895 if (flags & FLAG_GROUP)
4896 *fbp++ = '\''; 6504 *fbp++ = '\'';
4897#endif
4898 if (flags & FLAG_LEFT) 6505 if (flags & FLAG_LEFT)
4899 *fbp++ = '-'; 6506 *fbp++ = '-';
4900 if (flags & FLAG_SHOWSIGN) 6507 if (flags & FLAG_SHOWSIGN)
@@ -4914,6 +6521,41 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4914 if (dp->width_start != dp->width_end) 6521 if (dp->width_start != dp->width_end)
4915 { 6522 {
4916 size_t n = dp->width_end - dp->width_start; 6523 size_t n = dp->width_end - dp->width_start;
6524#if !WIDTH_IS_CHECKED
6525 size_t width;
6526 /* Reject an out-of-range width.
6527 The underlying SNPRINTF already does this on some
6528 platforms (glibc, musl, macOS, FreeBSD, NetBSD,
6529 OpenBSD, Cygwin, Solaris, MSVC). However, on others
6530 (AIX, mingw), it doesn't; thus this vasnprintf
6531 invocation would succeed and produce a wrong result.
6532 So, this is redundant on some platforms, but it's a
6533 quick check anyway. */
6534 if (dp->width_arg_index != ARG_NONE)
6535 {
6536 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
6537 abort ();
6538 int arg = a.arg[dp->width_arg_index].a.a_int;
6539 width = arg;
6540 if (arg < 0)
6541 {
6542 /* "A negative field width is taken as a '-' flag
6543 followed by a positive field width." */
6544 width = -width;
6545 }
6546 }
6547 else
6548 {
6549 const FCHAR_T *digitp = dp->width_start;
6550
6551 width = 0;
6552 do
6553 width = xsum (xtimes (width, 10), *digitp++ - '0');
6554 while (digitp != dp->width_end);
6555 }
6556 if (width > (size_t) INT_MAX)
6557 goto overflow;
6558#endif
4917 /* The width specification is known to consist only 6559 /* The width specification is known to consist only
4918 of standard ASCII characters. */ 6560 of standard ASCII characters. */
4919 if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) 6561 if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
@@ -4952,10 +6594,58 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4952 } 6594 }
4953 } 6595 }
4954 6596
4955 switch (type) 6597 switch (+type)
4956 { 6598 {
4957 case TYPE_LONGLONGINT: 6599 case TYPE_LONGLONGINT:
4958 case TYPE_ULONGLONGINT: 6600 case TYPE_ULONGLONGINT:
6601 #if INT8_WIDTH > LONG_WIDTH
6602 case TYPE_INT8_T:
6603 #endif
6604 #if UINT8_WIDTH > LONG_WIDTH
6605 case TYPE_UINT8_T:
6606 #endif
6607 #if INT16_WIDTH > LONG_WIDTH
6608 case TYPE_INT16_T:
6609 #endif
6610 #if UINT16_WIDTH > LONG_WIDTH
6611 case TYPE_UINT16_T:
6612 #endif
6613 #if INT32_WIDTH > LONG_WIDTH
6614 case TYPE_INT32_T:
6615 #endif
6616 #if UINT32_WIDTH > LONG_WIDTH
6617 case TYPE_UINT32_T:
6618 #endif
6619 #if INT64_WIDTH > LONG_WIDTH
6620 case TYPE_INT64_T:
6621 #endif
6622 #if UINT64_WIDTH > LONG_WIDTH
6623 case TYPE_UINT64_T:
6624 #endif
6625 #if INT_FAST8_WIDTH > LONG_WIDTH
6626 case TYPE_INT_FAST8_T:
6627 #endif
6628 #if UINT_FAST8_WIDTH > LONG_WIDTH
6629 case TYPE_UINT_FAST8_T:
6630 #endif
6631 #if INT_FAST16_WIDTH > LONG_WIDTH
6632 case TYPE_INT_FAST16_T:
6633 #endif
6634 #if UINT_FAST16_WIDTH > LONG_WIDTH
6635 case TYPE_UINT_FAST16_T:
6636 #endif
6637 #if INT_FAST32_WIDTH > LONG_WIDTH
6638 case TYPE_INT3_FAST2_T:
6639 #endif
6640 #if UINT_FAST32_WIDTH > LONG_WIDTH
6641 case TYPE_UINT_FAST32_T:
6642 #endif
6643 #if INT_FAST64_WIDTH > LONG_WIDTH
6644 case TYPE_INT_FAST64_T:
6645 #endif
6646 #if UINT_FAST64_WIDTH > LONG_WIDTH
6647 case TYPE_UINT_FAST64_T:
6648 #endif
4959#if defined _WIN32 && ! defined __CYGWIN__ 6649#if defined _WIN32 && ! defined __CYGWIN__
4960 *fbp++ = 'I'; 6650 *fbp++ = 'I';
4961 *fbp++ = '6'; 6651 *fbp++ = '6';
@@ -4967,12 +6657,58 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4967 FALLTHROUGH; 6657 FALLTHROUGH;
4968 case TYPE_LONGINT: 6658 case TYPE_LONGINT:
4969 case TYPE_ULONGINT: 6659 case TYPE_ULONGINT:
4970#if HAVE_WINT_T 6660 #if INT8_WIDTH > INT_WIDTH && INT8_WIDTH <= LONG_WIDTH
6661 case TYPE_INT8_T:
6662 #endif
6663 #if UINT8_WIDTH > INT_WIDTH && UINT8_WIDTH <= LONG_WIDTH
6664 case TYPE_UINT8_T:
6665 #endif
6666 #if INT16_WIDTH > INT_WIDTH && INT16_WIDTH <= LONG_WIDTH
6667 case TYPE_INT16_T:
6668 #endif
6669 #if UINT16_WIDTH > INT_WIDTH && UINT16_WIDTH <= LONG_WIDTH
6670 case TYPE_UINT16_T:
6671 #endif
6672 #if INT32_WIDTH > INT_WIDTH && INT32_WIDTH <= LONG_WIDTH
6673 case TYPE_INT32_T:
6674 #endif
6675 #if UINT32_WIDTH > INT_WIDTH && UINT32_WIDTH <= LONG_WIDTH
6676 case TYPE_UINT32_T:
6677 #endif
6678 #if INT64_WIDTH > INT_WIDTH && INT64_WIDTH <= LONG_WIDTH
6679 case TYPE_INT64_T:
6680 #endif
6681 #if UINT64_WIDTH > INT_WIDTH && UINT64_WIDTH <= LONG_WIDTH
6682 case TYPE_UINT64_T:
6683 #endif
6684 #if INT_FAST8_WIDTH > INT_WIDTH && INT_FAST8_WIDTH <= LONG_WIDTH
6685 case TYPE_INT_FAST8_T:
6686 #endif
6687 #if UINT_FAST8_WIDTH > INT_WIDTH && UINT_FAST8_WIDTH <= LONG_WIDTH
6688 case TYPE_UINT_FAST8_T:
6689 #endif
6690 #if INT_FAST16_WIDTH > INT_WIDTH && INT_FAST16_WIDTH <= LONG_WIDTH
6691 case TYPE_INT_FAST16_T:
6692 #endif
6693 #if UINT_FAST16_WIDTH > INT_WIDTH && UINT_FAST16_WIDTH <= LONG_WIDTH
6694 case TYPE_UINT_FAST16_T:
6695 #endif
6696 #if INT_FAST32_WIDTH > INT_WIDTH && INT_FAST32_WIDTH <= LONG_WIDTH
6697 case TYPE_INT_FAST32_T:
6698 #endif
6699 #if UINT_FAST32_WIDTH > INT_WIDTH && UINT_FAST32_WIDTH <= LONG_WIDTH
6700 case TYPE_UINT_FAST32_T:
6701 #endif
6702 #if INT_FAST64_WIDTH > INT_WIDTH && INT_FAST64_WIDTH <= LONG_WIDTH
6703 case TYPE_INT_FAST64_T:
6704 #endif
6705 #if UINT_FAST64_WIDTH > INT_WIDTH && UINT_FAST64_WIDTH <= LONG_WIDTH
6706 case TYPE_UINT_FAST64_T:
6707 #endif
6708 #if HAVE_WINT_T
4971 case TYPE_WIDE_CHAR: 6709 case TYPE_WIDE_CHAR:
4972#endif 6710 #endif
4973#if HAVE_WCHAR_T
4974 case TYPE_WIDE_STRING: 6711 case TYPE_WIDE_STRING:
4975#endif
4976 *fbp++ = 'l'; 6712 *fbp++ = 'l';
4977 break; 6713 break;
4978 case TYPE_LONGDOUBLE: 6714 case TYPE_LONGDOUBLE:
@@ -4988,49 +6724,76 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4988#endif 6724#endif
4989 *fbp = dp->conversion; 6725 *fbp = dp->conversion;
4990#if USE_SNPRINTF 6726#if USE_SNPRINTF
4991# if ((HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99) \ 6727 /* Decide whether to pass %n in the format string
6728 to SNPRINTF. */
6729# if (((!WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR) \
6730 && (HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99)) \
4992 || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ 6731 || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
4993 && !defined __UCLIBC__) \ 6732 && !defined __UCLIBC__) \
4994 || (defined __APPLE__ && defined __MACH__) \ 6733 || (defined __APPLE__ && defined __MACH__) \
6734 || defined __OpenBSD__ \
4995 || defined __ANDROID__ \ 6735 || defined __ANDROID__ \
4996 || (defined _WIN32 && ! defined __CYGWIN__)) 6736 || (defined _WIN32 && ! defined __CYGWIN__)) \
4997 /* On systems where we know that snprintf's return value 6737 || (WIDE_CHAR_VERSION && MUSL_LIBC)
4998 conforms to ISO C 99 (HAVE_SNPRINTF_RETVAL_C99) and that 6738 /* We can avoid passing %n and instead rely on SNPRINTF's
4999 snprintf always produces NUL-terminated strings 6739 return value if
5000 (HAVE_SNPRINTF_TRUNCATION_C99), it is possible to avoid 6740 - !WIDE_CHAR_VERSION || !DCHAR_IS_TCHAR, because otherwise,
5001 using %n. And it is desirable to do so, because more and 6741 when WIDE_CHAR_VERSION && DCHAR_IS_TCHAR,
5002 more platforms no longer support %n, for "security reasons". 6742 snwprintf()/_snwprintf() (Windows) and swprintf() (Unix)
5003 In particular, the following platforms: 6743 don't return the needed buffer size,
6744 and
6745 - we're compiling for a system where we know
6746 - that snprintf's return value conforms to ISO C 99
6747 (HAVE_SNPRINTF_RETVAL_C99) and
6748 - that snprintf always produces NUL-terminated strings
6749 (HAVE_SNPRINTF_TRUNCATION_C99).
6750 And it is desirable to do so, because more and more platforms
6751 no longer support %n, for "security reasons". */
6752 /* On specific platforms, listed below, we *must* avoid %n.
6753 In the case
6754 !WIDE_CHAR_VERSION && HAVE_SNPRINTF_RETVAL_C99 && !USE_MSVC__SNPRINTF
6755 we can rely on the return value of snprintf instead. Whereas
6756 in the opposite case
6757 WIDE_CHAR_VERSION || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
6758 we need to make room based on an estimation, computed by
6759 MAX_ROOM_NEEDED. */
6760 /* The following platforms forbid %n:
5004 - On glibc2 systems from 2004-10-18 or newer, the use of 6761 - On glibc2 systems from 2004-10-18 or newer, the use of
5005 %n in format strings in writable memory may crash the 6762 %n in format strings in writable memory may crash the
5006 program (if compiled with _FORTIFY_SOURCE=2). 6763 program (if compiled with _FORTIFY_SOURCE >= 2).
5007 - On Mac OS X 10.13 or newer, the use of %n in format 6764 - On macOS 10.13 or newer, the use of %n in format
5008 strings in writable memory by default crashes the 6765 strings in writable memory by default crashes the
5009 program. 6766 program.
6767 - On OpenBSD, since 2021-08-30, the use of %n in format
6768 strings produces an abort (see
6769 <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/vfprintf.c.diff?r1=1.79&r2=1.80&f=h>,
6770 <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/vfwprintf.c.diff?r1=1.20&r2=1.21&f=h>).
5010 - On Android, starting on 2018-03-07, the use of %n in 6771 - On Android, starting on 2018-03-07, the use of %n in
5011 format strings produces a fatal error (see 6772 format strings produces a fatal error (see
5012 <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>). 6773 <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>).
5013 On these platforms, HAVE_SNPRINTF_RETVAL_C99 and 6774 - On native Windows systems (such as mingw) where the OS is
5014 HAVE_SNPRINTF_TRUNCATION_C99 are 1. We have listed them 6775 Windows Vista, the use of %n in format strings by default
5015 explicitly in the condition above, in case of cross- 6776 crashes the program. See
5016 compilation (just to be sure). */ 6777 <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
5017 /* On native Windows systems (such as mingw), we can avoid using 6778 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
5018 %n because: 6779 On the first four of these platforms, if !WIDE_CHAR_VERSION,
6780 it is not a big deal to avoid %n, because on these platforms,
6781 HAVE_SNPRINTF_RETVAL_C99 and HAVE_SNPRINTF_TRUNCATION_C99 are
6782 1.
6783 On native Windows, if !WIDE_CHAR_VERSION, it's not a big deal
6784 either because:
5019 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, 6785 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
5020 snprintf does not write more than the specified number 6786 snprintf does not write more than the specified number
5021 of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes 6787 of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
5022 '4', '5', '6' into buf, not '4', '5', '\0'.) 6788 '4', '5', '6' into buf, not '4', '5', '\0'.)
5023 - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf 6789 - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
5024 allows us to recognize the case of an insufficient 6790 allows us to recognize the case of an insufficient
5025 buffer size: it returns -1 in this case. 6791 buffer size: it returns -1 in this case. */
5026 On native Windows systems (such as mingw) where the OS is 6792 /* Additionally, in the WIDE_CHAR_VERSION case, we cannot use %n
5027 Windows Vista, the use of %n in format strings by default 6793 on musl libc because we would run into an swprintf() bug.
5028 crashes the program. See 6794 See <https://www.openwall.com/lists/musl/2023/03/19/1>. */
5029 <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
5030 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
5031 So we should avoid %n in this situation. */
5032 fbp[1] = '\0'; 6795 fbp[1] = '\0';
5033# else /* AIX <= 5.1, HP-UX, IRIX, OSF/1, Solaris <= 9, BeOS */ 6796# else /* AIX <= 5.1, HP-UX, Solaris <= 9, BeOS */
5034 fbp[1] = '%'; 6797 fbp[1] = '%';
5035 fbp[2] = 'n'; 6798 fbp[2] = 'n';
5036 fbp[3] = '\0'; 6799 fbp[3] = '\0';
@@ -5127,7 +6890,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5127#endif 6890#endif
5128 6891
5129 errno = 0; 6892 errno = 0;
5130 switch (type) 6893 switch (+type)
5131 { 6894 {
5132 case TYPE_SCHAR: 6895 case TYPE_SCHAR:
5133 { 6896 {
@@ -5189,6 +6952,102 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5189 SNPRINTF_BUF (arg); 6952 SNPRINTF_BUF (arg);
5190 } 6953 }
5191 break; 6954 break;
6955 case TYPE_INT8_T:
6956 {
6957 int8_t arg = a.arg[dp->arg_index].a.a_int8_t;
6958 SNPRINTF_BUF (arg);
6959 }
6960 break;
6961 case TYPE_UINT8_T:
6962 {
6963 uint8_t arg = a.arg[dp->arg_index].a.a_uint8_t;
6964 SNPRINTF_BUF (arg);
6965 }
6966 break;
6967 case TYPE_INT16_T:
6968 {
6969 int16_t arg = a.arg[dp->arg_index].a.a_int16_t;
6970 SNPRINTF_BUF (arg);
6971 }
6972 break;
6973 case TYPE_UINT16_T:
6974 {
6975 uint16_t arg = a.arg[dp->arg_index].a.a_uint16_t;
6976 SNPRINTF_BUF (arg);
6977 }
6978 break;
6979 case TYPE_INT32_T:
6980 {
6981 int32_t arg = a.arg[dp->arg_index].a.a_int32_t;
6982 SNPRINTF_BUF (arg);
6983 }
6984 break;
6985 case TYPE_UINT32_T:
6986 {
6987 uint32_t arg = a.arg[dp->arg_index].a.a_uint32_t;
6988 SNPRINTF_BUF (arg);
6989 }
6990 break;
6991 case TYPE_INT64_T:
6992 {
6993 int64_t arg = a.arg[dp->arg_index].a.a_int64_t;
6994 SNPRINTF_BUF (arg);
6995 }
6996 break;
6997 case TYPE_UINT64_T:
6998 {
6999 uint64_t arg = a.arg[dp->arg_index].a.a_uint64_t;
7000 SNPRINTF_BUF (arg);
7001 }
7002 break;
7003 case TYPE_INT_FAST8_T:
7004 {
7005 int_fast8_t arg = a.arg[dp->arg_index].a.a_int_fast8_t;
7006 SNPRINTF_BUF (arg);
7007 }
7008 break;
7009 case TYPE_UINT_FAST8_T:
7010 {
7011 uint_fast8_t arg = a.arg[dp->arg_index].a.a_uint_fast8_t;
7012 SNPRINTF_BUF (arg);
7013 }
7014 break;
7015 case TYPE_INT_FAST16_T:
7016 {
7017 int_fast16_t arg = a.arg[dp->arg_index].a.a_int_fast16_t;
7018 SNPRINTF_BUF (arg);
7019 }
7020 break;
7021 case TYPE_UINT_FAST16_T:
7022 {
7023 uint_fast16_t arg = a.arg[dp->arg_index].a.a_uint_fast16_t;
7024 SNPRINTF_BUF (arg);
7025 }
7026 break;
7027 case TYPE_INT_FAST32_T:
7028 {
7029 int_fast32_t arg = a.arg[dp->arg_index].a.a_int_fast32_t;
7030 SNPRINTF_BUF (arg);
7031 }
7032 break;
7033 case TYPE_UINT_FAST32_T:
7034 {
7035 uint_fast32_t arg = a.arg[dp->arg_index].a.a_uint_fast32_t;
7036 SNPRINTF_BUF (arg);
7037 }
7038 break;
7039 case TYPE_INT_FAST64_T:
7040 {
7041 int_fast64_t arg = a.arg[dp->arg_index].a.a_int_fast64_t;
7042 SNPRINTF_BUF (arg);
7043 }
7044 break;
7045 case TYPE_UINT_FAST64_T:
7046 {
7047 uint_fast64_t arg = a.arg[dp->arg_index].a.a_uint_fast64_t;
7048 SNPRINTF_BUF (arg);
7049 }
7050 break;
5192 case TYPE_DOUBLE: 7051 case TYPE_DOUBLE:
5193 { 7052 {
5194 double arg = a.arg[dp->arg_index].a.a_double; 7053 double arg = a.arg[dp->arg_index].a.a_double;
@@ -5221,14 +7080,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5221 SNPRINTF_BUF (arg); 7080 SNPRINTF_BUF (arg);
5222 } 7081 }
5223 break; 7082 break;
5224#if HAVE_WCHAR_T
5225 case TYPE_WIDE_STRING: 7083 case TYPE_WIDE_STRING:
5226 { 7084 {
5227 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; 7085 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
5228 SNPRINTF_BUF (arg); 7086 SNPRINTF_BUF (arg);
5229 } 7087 }
5230 break; 7088 break;
5231#endif
5232 case TYPE_POINTER: 7089 case TYPE_POINTER:
5233 { 7090 {
5234 void *arg = a.arg[dp->arg_index].a.a_pointer; 7091 void *arg = a.arg[dp->arg_index].a.a_pointer;
@@ -5271,12 +7128,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5271 /* Look at the snprintf() return value. */ 7128 /* Look at the snprintf() return value. */
5272 if (retcount < 0) 7129 if (retcount < 0)
5273 { 7130 {
5274# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF 7131# if (WIDE_CHAR_VERSION && DCHAR_IS_TCHAR) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
5275 /* HP-UX 10.20 snprintf() is doubly deficient: 7132 /* HP-UX 10.20 snprintf() is doubly deficient:
5276 It doesn't understand the '%n' directive, 7133 It doesn't understand the '%n' directive,
5277 *and* it returns -1 (rather than the length 7134 *and* it returns -1 (rather than the length
5278 that would have been required) when the 7135 that would have been required) when the
5279 buffer is too small. 7136 buffer is too small.
7137 Likewise, in case of
7138 WIDE_CHAR_VERSION && DCHAR_IS_TCHAR, the
7139 functions snwprintf()/_snwprintf() (Windows)
7140 or swprintf() (Unix).
5280 But a failure at this point can also come 7141 But a failure at this point can also come
5281 from other reasons than a too small buffer, 7142 from other reasons than a too small buffer,
5282 such as an invalid wide string argument to 7143 such as an invalid wide string argument to
@@ -5312,7 +7173,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5312# endif 7173# endif
5313 } 7174 }
5314 else 7175 else
5315 count = retcount; 7176 {
7177 count = retcount;
7178# if WIDE_CHAR_VERSION && defined __MINGW32__
7179 if (count == 0 && dp->conversion == 'c')
7180 /* snwprintf returned 0 instead of 1. But it
7181 wrote a null wide character. */
7182 count = 1;
7183# endif
7184 }
5316 } 7185 }
5317 } 7186 }
5318#endif 7187#endif
@@ -5370,7 +7239,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5370 } 7239 }
5371#endif 7240#endif
5372 7241
5373#if NEED_PRINTF_UNBOUNDED_PRECISION 7242#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
5374 if (prec_ourselves) 7243 if (prec_ourselves)
5375 { 7244 {
5376 /* Handle the precision. */ 7245 /* Handle the precision. */
@@ -5390,10 +7259,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5390 || *prec_ptr == ' ')) 7259 || *prec_ptr == ' '))
5391 prefix_count = 1; 7260 prefix_count = 1;
5392 /* Put the additional zeroes after the 0x prefix if 7261 /* Put the additional zeroes after the 0x prefix if
5393 (flags & FLAG_ALT) || (dp->conversion == 'p'). */ 7262 (flags & FLAG_ALT) || (dp->conversion == 'p'), or
7263 after the 0b prefix if (flags & FLAG_ALT). */
5394 else if (count >= 2 7264 else if (count >= 2
5395 && prec_ptr[0] == '0' 7265 && prec_ptr[0] == '0'
5396 && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) 7266 && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'
7267 || prec_ptr[1] == 'b'
7268 || prec_ptr[1] == 'B'))
5397 prefix_count = 2; 7269 prefix_count = 2;
5398 7270
5399 move = count - prefix_count; 7271 move = count - prefix_count;
@@ -5430,9 +7302,147 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5430 7302
5431 count += insert; 7303 count += insert;
5432 } 7304 }
7305# if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO
7306 else if (precision == 0
7307 && move == 1
7308 && prec_ptr[prefix_count] == '0')
7309 {
7310 /* Replace the "0" result with an empty string. */
7311 count = prefix_count;
7312 }
7313# endif
5433 } 7314 }
5434#endif 7315#endif
5435 7316
7317#if NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
7318 if (group_ourselves) /* implies (flags & FLAG_GROUP) */
7319 /* Handle the grouping. */
7320 switch (dp->conversion)
7321 {
7322 /* These are the only conversion to which grouping
7323 applies. */
7324 case 'd': case 'i': case 'u':
7325 case 'f': case 'F': case 'g': case 'G':
7326 {
7327 /* Determine the thousands separator of the current
7328 locale. */
7329 const TCHAR_T *thousep;
7330 TCHAR_T thousep_buf[10];
7331
7332# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
7333 /* TCHAR_T is wchar_t. */
7334 thousep = thousands_separator_wchar (thousep_buf);
7335# else
7336 /* TCHAR_T is char. */
7337 thousep = thousands_separator_char (thousep_buf);
7338# endif
7339
7340 /* Nothing to do in locales where thousep is the empty
7341 string. */
7342 if (*thousep != 0)
7343 {
7344 /* Since FLAG_LOCALIZED is only supported on glibc
7345 systems, here we can assume that all digits are
7346 the ASCII digits '0'..'9'. */
7347 TCHAR_T *number_ptr =
7348# if USE_SNPRINTF
7349 (TCHAR_T *) (result + length);
7350# else
7351 tmp;
7352# endif
7353 TCHAR_T *end_ptr = number_ptr + count;
7354
7355 /* Find where the leading digits start. */
7356 TCHAR_T *digits_ptr = number_ptr;
7357 if (count >= 1
7358 && (*digits_ptr == '-' || *digits_ptr == '+'
7359 || *digits_ptr == ' '))
7360 digits_ptr++;
7361
7362 /* Find where the leading digits end. */
7363 TCHAR_T *digits_end_ptr;
7364 switch (dp->conversion)
7365 {
7366 case 'd': case 'i': case 'u':
7367 digits_end_ptr = end_ptr;
7368 break;
7369 case 'f': case 'F': case 'g': case 'G':
7370 {
7371 TCHAR_T decimal_point = decimal_point_char ();
7372 for (digits_end_ptr = digits_ptr;
7373 digits_end_ptr < end_ptr;
7374 digits_end_ptr++)
7375 if (*digits_end_ptr == decimal_point
7376 || *digits_end_ptr == 'e')
7377 break;
7378 }
7379 break;
7380 }
7381
7382 /* Determine the number of thousands separators
7383 to insert. */
7384 const signed char *grouping = grouping_rule ();
7385 size_t insert =
7386 num_thousands_separators (grouping, digits_end_ptr - digits_ptr);
7387 if (insert > 0)
7388 {
7389# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
7390# define thousep_len 1
7391# else
7392 size_t thousep_len = strlen (thousep);
7393# endif
7394# if USE_SNPRINTF
7395 size_t digits_offset = digits_ptr - number_ptr;
7396 size_t digits_end_offset = digits_end_ptr - number_ptr;
7397 size_t n =
7398 xsum (length,
7399 (count + insert * thousep_len + TCHARS_PER_DCHAR - 1)
7400 / TCHARS_PER_DCHAR);
7401 length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
7402 ENSURE_ALLOCATION (n);
7403 length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
7404 number_ptr = (TCHAR_T *) (result + length);
7405 end_ptr = number_ptr + count;
7406 digits_ptr = number_ptr + digits_offset;
7407 digits_end_ptr = number_ptr + digits_end_offset;
7408# endif
7409
7410 count += insert * thousep_len;
7411
7412 const TCHAR_T *p = end_ptr;
7413 TCHAR_T *q = end_ptr + insert * thousep_len;
7414 while (p > digits_end_ptr)
7415 *--q = *--p;
7416 const signed char *g = grouping;
7417 for (;;)
7418 {
7419 int h = *g;
7420 if (h <= 0)
7421 abort ();
7422 int i = h;
7423 do
7424 *--q = *--p;
7425 while (--i > 0);
7426# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
7427 *--q = *thousep;
7428# else
7429 q -= thousep_len;
7430 memcpy (q, thousep, thousep_len);
7431# endif
7432 insert--;
7433 if (insert == 0)
7434 break;
7435 if (g[1] != 0)
7436 g++;
7437 }
7438 /* Here q == p. Done with the insertions. */
7439 }
7440 }
7441 }
7442 break;
7443 }
7444#endif
7445
5436#if !USE_SNPRINTF 7446#if !USE_SNPRINTF
5437 if (count >= tmp_length) 7447 if (count >= tmp_length)
5438 /* tmp_length was incorrectly calculated - fix the 7448 /* tmp_length was incorrectly calculated - fix the
@@ -5442,21 +7452,74 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5442 7452
5443#if !DCHAR_IS_TCHAR 7453#if !DCHAR_IS_TCHAR
5444 /* Convert from TCHAR_T[] to DCHAR_T[]. */ 7454 /* Convert from TCHAR_T[] to DCHAR_T[]. */
5445 if (dp->conversion == 'c' || dp->conversion == 's') 7455 if (dp->conversion == 'c' || dp->conversion == 's'
7456 || (flags & FLAG_GROUP)
7457# if __GLIBC__ >= 2 && !defined __UCLIBC__
7458 || (flags & FLAG_LOCALIZED)
7459# endif
7460 )
5446 { 7461 {
5447 /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING 7462 /* The result string is not guaranteed to be ASCII. */
5448 TYPE_WIDE_STRING.
5449 The result string is not certainly ASCII. */
5450 const TCHAR_T *tmpsrc;
5451 DCHAR_T *tmpdst;
5452 size_t tmpdst_len;
5453 /* This code assumes that TCHAR_T is 'char'. */ 7463 /* This code assumes that TCHAR_T is 'char'. */
5454 static_assert (sizeof (TCHAR_T) == 1); 7464 static_assert (sizeof (TCHAR_T) == 1);
7465 const TCHAR_T *tmpsrc;
5455# if USE_SNPRINTF 7466# if USE_SNPRINTF
5456 tmpsrc = (TCHAR_T *) (result + length); 7467 tmpsrc = (TCHAR_T *) (result + length);
5457# else 7468# else
5458 tmpsrc = tmp; 7469 tmpsrc = tmp;
5459# endif 7470# endif
7471 DCHAR_T *tmpdst;
7472 size_t tmpdst_len;
7473# if WIDE_CHAR_VERSION
7474 /* Convert tmpsrc[0..count-1] to a freshly allocated
7475 wide character array. */
7476 mbstate_t state;
7477
7478 mbszero (&state);
7479 tmpdst_len = 0;
7480 {
7481 const TCHAR_T *src = tmpsrc;
7482 size_t srclen = count;
7483
7484 for (; srclen > 0; tmpdst_len++)
7485 {
7486 /* Parse the next multibyte character. */
7487 size_t ret = mbrtowc (NULL, src, srclen, &state);
7488 if (ret == (size_t)(-2) || ret == (size_t)(-1))
7489 goto fail_with_EILSEQ;
7490 if (ret == 0)
7491 ret = 1;
7492 src += ret;
7493 srclen -= ret;
7494 }
7495 }
7496
7497 tmpdst =
7498 (wchar_t *) malloc ((tmpdst_len + 1) * sizeof (wchar_t));
7499 if (tmpdst == NULL)
7500 goto out_of_memory;
7501
7502 mbszero (&state);
7503 {
7504 DCHAR_T *destptr = tmpdst;
7505 const TCHAR_T *src = tmpsrc;
7506 size_t srclen = count;
7507
7508 for (; srclen > 0; destptr++)
7509 {
7510 /* Parse the next multibyte character. */
7511 size_t ret = mbrtowc (destptr, src, srclen, &state);
7512 if (ret == (size_t)(-2) || ret == (size_t)(-1))
7513 /* Should already have been caught in the first
7514 loop, above. */
7515 abort ();
7516 if (ret == 0)
7517 ret = 1;
7518 src += ret;
7519 srclen -= ret;
7520 }
7521 }
7522# else
5460 tmpdst = 7523 tmpdst =
5461 DCHAR_CONV_FROM_ENCODING (locale_charset (), 7524 DCHAR_CONV_FROM_ENCODING (locale_charset (),
5462 iconveh_question_mark, 7525 iconveh_question_mark,
@@ -5465,8 +7528,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5465 NULL, &tmpdst_len); 7528 NULL, &tmpdst_len);
5466 if (tmpdst == NULL) 7529 if (tmpdst == NULL)
5467 goto fail_with_errno; 7530 goto fail_with_errno;
7531# endif
5468 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len), 7532 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
5469 { free (tmpdst); goto out_of_memory; }); 7533 { free (tmpdst); goto out_of_memory; });
5470 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 7534 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
5471 free (tmpdst); 7535 free (tmpdst);
5472 count = tmpdst_len; 7536 count = tmpdst_len;
@@ -5483,9 +7547,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5483# endif 7547# endif
5484 { 7548 {
5485 const TCHAR_T *tmpsrc; 7549 const TCHAR_T *tmpsrc;
5486 DCHAR_T *tmpdst;
5487 size_t n;
5488
5489# if USE_SNPRINTF 7550# if USE_SNPRINTF
5490 if (result == resultbuf) 7551 if (result == resultbuf)
5491 { 7552 {
@@ -5505,11 +7566,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5505 tmpsrc = tmp; 7566 tmpsrc = tmp;
5506 ENSURE_ALLOCATION (xsum (length, count)); 7567 ENSURE_ALLOCATION (xsum (length, count));
5507# endif 7568# endif
5508 tmpdst = result + length; 7569 DCHAR_T *tmpdst = result + length;
5509 /* Copy backwards, because of overlapping. */ 7570 /* Copy backwards, because of overlapping. */
5510 tmpsrc += count; 7571 tmpsrc += count;
5511 tmpdst += count; 7572 tmpdst += count;
5512 for (n = count; n > 0; n--) 7573 for (size_t n = count; n > 0; n--)
5513 *--tmpdst = *--tmpsrc; 7574 *--tmpdst = *--tmpsrc;
5514 } 7575 }
5515 } 7576 }
@@ -5531,7 +7592,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5531 /* Here count <= allocated - length. */ 7592 /* Here count <= allocated - length. */
5532 7593
5533 /* Perform padding. */ 7594 /* Perform padding. */
5534#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 7595#if (WIDE_CHAR_VERSION && MUSL_LIBC) || NEED_PRINTF_FLAG_LEFTADJUST || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_FLAG_ALT_PRECISION_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION || NEED_PRINTF_FLAG_GROUPING || NEED_PRINTF_FLAG_GROUPING_INT
5535 if (pad_ourselves && has_width) 7596 if (pad_ourselves && has_width)
5536 { 7597 {
5537 size_t w; 7598 size_t w;
@@ -5540,6 +7601,23 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5540 against the number of _characters_ of the converted 7601 against the number of _characters_ of the converted
5541 value. */ 7602 value. */
5542 w = DCHAR_MBSNLEN (result + length, count); 7603 w = DCHAR_MBSNLEN (result + length, count);
7604# elif __GLIBC__ >= 2
7605 /* glibc prefers to compare the width against the number
7606 of characters as well, but only for numeric conversion
7607 specifiers. See
7608 <https://sourceware.org/PR28943>
7609 <https://sourceware.org/PR30883>
7610 <https://sourceware.org/PR31542> */
7611 switch (dp->conversion)
7612 {
7613 case 'd': case 'i': case 'u':
7614 case 'f': case 'F': case 'g': case 'G':
7615 w = DCHAR_MBSNLEN (result + length, count);
7616 break;
7617 default:
7618 w = count;
7619 break;
7620 }
5543# else 7621# else
5544 /* The width is compared against the number of _bytes_ 7622 /* The width is compared against the number of _bytes_
5545 of the converted value, says POSIX. */ 7623 of the converted value, says POSIX. */
@@ -5590,6 +7668,22 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5590 if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') 7668 if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
5591 || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) 7669 || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
5592 pad_ptr = NULL; 7670 pad_ptr = NULL;
7671 else
7672 /* Do the zero-padding after the "0x" or
7673 "0b" prefix, not before. */
7674 if (p - rp >= 2
7675 && *rp == '0'
7676 && (((dp->conversion == 'a'
7677 || dp->conversion == 'x')
7678 && rp[1] == 'x')
7679 || ((dp->conversion == 'A'
7680 || dp->conversion == 'X')
7681 && rp[1] == 'X')
7682 || (dp->conversion == 'b'
7683 && rp[1] == 'b')
7684 || (dp->conversion == 'B'
7685 && rp[1] == 'B')))
7686 pad_ptr += 2;
5593 } 7687 }
5594 /* The generated string now extends from rp to p, 7688 /* The generated string now extends from rp to p,
5595 with the zero padding insertion point being at 7689 with the zero padding insertion point being at
@@ -5603,7 +7697,22 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5603 for (; pad > 0; pad--) 7697 for (; pad > 0; pad--)
5604 *p++ = ' '; 7698 *p++ = ' ';
5605 } 7699 }
5606 else if ((flags & FLAG_ZERO) && pad_ptr != NULL) 7700 else if ((flags & FLAG_ZERO) && pad_ptr != NULL
7701 /* ISO C says: "For d, i, o, u, x, and X
7702 conversions, if a precision is
7703 specified, the 0 flag is ignored. */
7704 && !(has_precision
7705 && (dp->conversion == 'd'
7706 || dp->conversion == 'i'
7707 || dp->conversion == 'o'
7708 || dp->conversion == 'u'
7709 || dp->conversion == 'x'
7710 || dp->conversion == 'X'
7711 /* Although ISO C does not
7712 require it, treat 'b' and 'B'
7713 like 'x' and 'X'. */
7714 || dp->conversion == 'b'
7715 || dp->conversion == 'B')))
5607 { 7716 {
5608 /* Pad with zeroes. */ 7717 /* Pad with zeroes. */
5609 DCHAR_T *q = end; 7718 DCHAR_T *q = end;
@@ -5646,8 +7755,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5646 { 7755 {
5647 /* Convert the %f result to upper case for %F. */ 7756 /* Convert the %f result to upper case for %F. */
5648 DCHAR_T *rp = result + length; 7757 DCHAR_T *rp = result + length;
5649 size_t rc; 7758 for (size_t rc = count; rc > 0; rc--, rp++)
5650 for (rc = count; rc > 0; rc--, rp++)
5651 if (*rp >= 'a' && *rp <= 'z') 7759 if (*rp >= 'a' && *rp <= 'z')
5652 *rp = *rp - 'a' + 'A'; 7760 *rp = *rp - 'a' + 'A';
5653 } 7761 }
@@ -5670,9 +7778,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5670 if (result != resultbuf && length + 1 < allocated) 7778 if (result != resultbuf && length + 1 < allocated)
5671 { 7779 {
5672 /* Shrink the allocated memory if possible. */ 7780 /* Shrink the allocated memory if possible. */
5673 DCHAR_T *memory; 7781 DCHAR_T *memory =
5674 7782 (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
5675 memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
5676 if (memory != NULL) 7783 if (memory != NULL)
5677 result = memory; 7784 result = memory;
5678 } 7785 }
@@ -5687,17 +7794,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5687 not have this limitation. */ 7794 not have this limitation. */
5688 return result; 7795 return result;
5689 7796
5690#if USE_SNPRINTF
5691 overflow: 7797 overflow:
5692 errno = EOVERFLOW; 7798 errno = EOVERFLOW;
5693 goto fail_with_errno; 7799 goto fail_with_errno;
5694#endif
5695 7800
5696 out_of_memory: 7801 out_of_memory:
5697 errno = ENOMEM; 7802 errno = ENOMEM;
5698 goto fail_with_errno; 7803 goto fail_with_errno;
5699 7804
5700#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) 7805#if ENABLE_UNISTDIO || (WIDE_CHAR_VERSION || !USE_SNPRINTF || (PTRDIFF_MAX > INT_MAX) || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_DIRECTIVE_LS || ENABLE_WCHAR_FALLBACK) || ((NEED_PRINTF_DIRECTIVE_LC || ENABLE_WCHAR_FALLBACK) && HAVE_WINT_T && !WIDE_CHAR_VERSION) || (NEED_WPRINTF_DIRECTIVE_C && WIDE_CHAR_VERSION)
5701 fail_with_EILSEQ: 7806 fail_with_EILSEQ:
5702 errno = EILSEQ; 7807 errno = EILSEQ;
5703 goto fail_with_errno; 7808 goto fail_with_errno;
diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h
index f69649fb..27b9585b 100644
--- a/gl/vasnprintf.h
+++ b/gl/vasnprintf.h
@@ -1,5 +1,5 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc. 2 Copyright (C) 2002-2004, 2007-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -17,6 +17,11 @@
17#ifndef _VASNPRINTF_H 17#ifndef _VASNPRINTF_H
18#define _VASNPRINTF_H 18#define _VASNPRINTF_H
19 19
20/* This file uses _GL_ATTRIBUTE_FORMAT. */
21#if !_GL_CONFIG_H_INCLUDED
22 #error "Please include config.h first."
23#endif
24
20/* Get va_list. */ 25/* Get va_list. */
21#include <stdarg.h> 26#include <stdarg.h>
22 27
diff --git a/gl/vasprintf.c b/gl/vasprintf.c
index d2878cd9..a22305b8 100644
--- a/gl/vasprintf.c
+++ b/gl/vasprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2023 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -25,6 +25,7 @@
25 25
26#include <errno.h> 26#include <errno.h>
27#include <limits.h> 27#include <limits.h>
28#include <stdint.h>
28#include <stdlib.h> 29#include <stdlib.h>
29 30
30#include "vasnprintf.h" 31#include "vasnprintf.h"
@@ -37,12 +38,21 @@ vasprintf (char **resultp, const char *format, va_list args)
37 if (result == NULL) 38 if (result == NULL)
38 return -1; 39 return -1;
39 40
41#if PTRDIFF_MAX > INT_MAX
40 if (length > INT_MAX) 42 if (length > INT_MAX)
41 { 43 {
42 free (result); 44 free (result);
43 errno = EOVERFLOW; 45 errno = (length > PTRDIFF_MAX ? ENOMEM : EOVERFLOW);
44 return -1; 46 return -1;
45 } 47 }
48#else
49 if (length > PTRDIFF_MAX)
50 {
51 free (result);
52 errno = ENOMEM;
53 return -1;
54 }
55#endif
46 56
47 *resultp = result; 57 *resultp = result;
48 /* Return the number of resulting bytes, excluding the trailing NUL. */ 58 /* Return the number of resulting bytes, excluding the trailing NUL. */
diff --git a/gl/verify.h b/gl/verify.h
index b63cb264..ad45c39d 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -1,6 +1,6 @@
1/* Compile-time assert-like macros. 1/* Compile-time assert-like macros.
2 2
3 Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2009-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -34,11 +34,12 @@
34#ifndef __cplusplus 34#ifndef __cplusplus
35# if (201112 <= __STDC_VERSION__ \ 35# if (201112 <= __STDC_VERSION__ \
36 || (!defined __STRICT_ANSI__ \ 36 || (!defined __STRICT_ANSI__ \
37 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__))) 37 && ((4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__) \
38 || 5 <= __clang_major__)))
38# define _GL_HAVE__STATIC_ASSERT 1 39# define _GL_HAVE__STATIC_ASSERT 1
39# endif 40# endif
40# if (202311 <= __STDC_VERSION__ \ 41# if (202311 <= __STDC_VERSION__ \
41 || (!defined __STRICT_ANSI__ && 9 <= __GNUC__)) 42 || (!defined __STRICT_ANSI__ && 9 <= __GNUC__ && !defined __clang__))
42# define _GL_HAVE__STATIC_ASSERT1 1 43# define _GL_HAVE__STATIC_ASSERT1 1
43# endif 44# endif
44#endif 45#endif
@@ -156,9 +157,10 @@
156#define _GL_CONCAT0(x, y) x##y 157#define _GL_CONCAT0(x, y) x##y
157 158
158/* _GL_COUNTER is an integer, preferably one that changes each time we 159/* _GL_COUNTER is an integer, preferably one that changes each time we
159 use it. Use __COUNTER__ if it works, falling back on __LINE__ 160 use it. Use __COUNTER__ if it works (it does so with most compilers,
160 otherwise. __LINE__ isn't perfect, but it's better than a 161 see <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm>),
161 constant. */ 162 falling back on __LINE__ otherwise. __LINE__ isn't perfect, but it's
163 better than a constant. */
162#if defined __COUNTER__ && __COUNTER__ != __COUNTER__ 164#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
163# define _GL_COUNTER __COUNTER__ 165# define _GL_COUNTER __COUNTER__
164#else 166#else
@@ -188,9 +190,9 @@ template <int w>
188 _gl_verify_type<(R) ? 1 : -1> 190 _gl_verify_type<(R) ? 1 : -1>
189#elif defined _GL_HAVE__STATIC_ASSERT 191#elif defined _GL_HAVE__STATIC_ASSERT
190# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ 192# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
191 struct { \ 193 struct { \
192 _Static_assert (R, DIAGNOSTIC); \ 194 _Static_assert (R, DIAGNOSTIC); \
193 int _gl_dummy; \ 195 int _gl_dummy; \
194 } 196 }
195#else 197#else
196# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ 198# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
@@ -212,37 +214,74 @@ template <int w>
212#elif defined _GL_HAVE__STATIC_ASSERT 214#elif defined _GL_HAVE__STATIC_ASSERT
213# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) 215# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
214#else 216#else
215# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ 217# define _GL_VERIFY(R, DIAGNOSTIC, ...) \
216 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ 218 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
217 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] 219 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
218# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 220# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) && !defined __clang__
219# pragma GCC diagnostic ignored "-Wnested-externs" 221# pragma GCC diagnostic ignored "-Wnested-externs"
220# endif 222# endif
221#endif 223#endif
222 224
223/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ 225/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
224#ifdef _GL_STATIC_ASSERT_H 226#ifdef _GL_STATIC_ASSERT_H
225# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert 227/* Define _Static_assert if needed. */
228/* With clang ≥ 3.8.0 in C++ mode, _Static_assert already works and accepts
229 1 or 2 arguments. We better don't override it, because clang's standard
230 C++ library uses static_assert inside classes in several places, and our
231 replacement via _GL_VERIFY does not work in these contexts. */
232# if (defined __cplusplus && defined __clang__ \
233 && (4 <= __clang_major__ + (8 <= __clang_minor__)))
234# if 5 <= __clang_major__
235/* Avoid "warning: 'static_assert' with no message is a C++17 extension". */
236# pragma clang diagnostic ignored "-Wc++17-extensions"
237# else
238/* Avoid "warning: static_assert with no message is a C++1z extension". */
239# pragma clang diagnostic ignored "-Wc++1z-extensions"
240# endif
241# elif !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert
226# if !defined _MSC_VER || defined __clang__ 242# if !defined _MSC_VER || defined __clang__
227# define _Static_assert(...) \ 243# define _Static_assert(...) \
228 _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) 244 _GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
229# else 245# else
230 /* Work around MSVC preprocessor incompatibility with ISO C; see 246# if defined __cplusplus && _MSC_VER >= 1910
231 <https://stackoverflow.com/questions/5134523/>. */ 247 /* In MSVC 14.1 or newer, static_assert accepts one or two arguments,
232# define _Static_assert(R, ...) \ 248 but _Static_assert is not defined. */
233 _GL_VERIFY ((R), "static assertion failed", -) 249# define _Static_assert static_assert
250# else
251 /* Work around MSVC preprocessor incompatibility with ISO C; see
252 <https://stackoverflow.com/questions/5134523/>. */
253# define _Static_assert(R, ...) \
254 _GL_VERIFY ((R), "static assertion failed", -)
255# endif
234# endif 256# endif
235# endif 257# endif
258/* Define static_assert if needed. */
259# if defined __cplusplus && defined __clang__ && __clang_major__ < 9
260/* clang++ before commit 5c739665a8721228cf6143fd4ef95870a59f55ae had a
261 two-arguments static_assert but not the one-argument static_assert. */
262# undef static_assert
263# endif
236# if (!defined static_assert \ 264# if (!defined static_assert \
237 && __STDC_VERSION__ < 202311 \ 265 && __STDC_VERSION__ < 202311 \
238 && (!defined __cplusplus \ 266 && (!defined __cplusplus \
239 || (__cpp_static_assert < 201411 \ 267 || (__cpp_static_assert < 201411 \
240 && __GNUG__ < 6 && __clang_major__ < 6))) 268 && __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910)))
241# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__ 269# if (defined __cplusplus && defined __GNUG__ && __GNUG__ < 6 \
270 && __cplusplus == 201103L && !defined __clang__)
271/* g++ >= 4.7, < 6 with option -std=c++11 or -std=gnu++11 supports the
272 two-arguments static_assert but not the one-argument static_assert, and
273 it does not support _Static_assert.
274 We have to play preprocessor tricks to distinguish the two cases. */
275# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
276# define _GL_SA2 static_assert
277# define _GL_SA3 static_assert
278# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
279# define static_assert(...) _GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1) (__VA_ARGS__)
280# elif defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
242/* MSVC 14 in C++ mode supports the two-arguments static_assert but not 281/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
243 the one-argument static_assert, and it does not support _Static_assert. 282 the one-argument static_assert, and it does not support _Static_assert.
244 We have to play preprocessor tricks to distinguish the two cases. 283 We have to play preprocessor tricks to distinguish the two cases.
245 Since the MSVC preprocessor is not ISO C compliant (see above),. 284 Since the MSVC preprocessor is not ISO C compliant (see above),
246 the solution is specific to MSVC. */ 285 the solution is specific to MSVC. */
247# define _GL_EXPAND(x) x 286# define _GL_EXPAND(x) x
248# define _GL_SA1(a1) static_assert ((a1), "static assertion failed") 287# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
@@ -250,6 +289,8 @@ template <int w>
250# define _GL_SA3 static_assert 289# define _GL_SA3 static_assert
251# define _GL_SA_PICK(x1,x2,x3,x4,...) x4 290# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
252# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__) 291# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
292/* Avoid "fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords." */
293# define _ALLOW_KEYWORD_MACROS 1
253# else 294# else
254# define static_assert _Static_assert /* C11 requires this #define. */ 295# define static_assert _Static_assert /* C11 requires this #define. */
255# endif 296# endif
@@ -268,14 +309,16 @@ template <int w>
268# define _GL_HAS_BUILTIN_TRAP 0 309# define _GL_HAS_BUILTIN_TRAP 0
269#endif 310#endif
270 311
271#if defined __clang_major__ && __clang_major__ < 5 312#ifndef _GL_HAS_BUILTIN_UNREACHABLE
272# define _GL_HAS_BUILTIN_UNREACHABLE 0 313# if defined __clang_major__ && __clang_major__ < 5
273#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) 314# define _GL_HAS_BUILTIN_UNREACHABLE 0
274# define _GL_HAS_BUILTIN_UNREACHABLE 1 315# elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && !defined __clang__
275#elif defined __has_builtin 316# define _GL_HAS_BUILTIN_UNREACHABLE 1
276# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable) 317# elif defined __has_builtin
277#else 318# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
278# define _GL_HAS_BUILTIN_UNREACHABLE 0 319# else
320# define _GL_HAS_BUILTIN_UNREACHABLE 0
321# endif
279#endif 322#endif
280 323
281/* Each of these macros verifies that its argument R is nonzero. To 324/* Each of these macros verifies that its argument R is nonzero. To
diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c
index acd4e2d4..444562e6 100644
--- a/gl/vsnprintf.c
+++ b/gl/vsnprintf.c
@@ -1,6 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2026 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 3
5 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -25,46 +24,20 @@
25#include <errno.h> 24#include <errno.h>
26#include <limits.h> 25#include <limits.h>
27#include <stdarg.h> 26#include <stdarg.h>
28#include <stdlib.h> 27#include <stdint.h>
29#include <string.h>
30 28
31#include "vasnprintf.h"
32
33/* Print formatted output to string STR. Similar to vsprintf, but
34 additional length SIZE limit how much is written into STR. Returns
35 string length of formatted string (which may be larger than SIZE).
36 STR may be NULL, in which case nothing will be written. On error,
37 return a negative value. */
38int 29int
39vsnprintf (char *str, size_t size, const char *format, va_list args) 30vsnprintf (char *str, size_t size, const char *format, va_list args)
40{ 31{
41 char *output; 32 ptrdiff_t ret = vsnzprintf (str, size, format, args);
42 size_t len;
43 size_t lenbuf = size;
44
45 output = vasnprintf (str, &lenbuf, format, args);
46 len = lenbuf;
47
48 if (!output)
49 return -1;
50
51 if (output != str)
52 {
53 if (size)
54 {
55 size_t pruned_len = (len < size ? len : size - 1);
56 memcpy (str, output, pruned_len);
57 str[pruned_len] = '\0';
58 }
59
60 free (output);
61 }
62 33
63 if (len > INT_MAX) 34#if PTRDIFF_MAX > INT_MAX
35 if (ret > INT_MAX)
64 { 36 {
65 errno = EOVERFLOW; 37 errno = EOVERFLOW;
66 return -1; 38 return -1;
67 } 39 }
40#endif
68 41
69 return len; 42 return ret;
70} 43}
diff --git a/gl/vsnzprintf.c b/gl/vsnzprintf.c
new file mode 100644
index 00000000..0d35195f
--- /dev/null
+++ b/gl/vsnzprintf.c
@@ -0,0 +1,62 @@
1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2026 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifdef HAVE_CONFIG_H
19# include <config.h>
20#endif
21
22/* Specification. */
23#include <stdio.h>
24
25#include <errno.h>
26#include <stdarg.h>
27#include <stdint.h>
28#include <stdlib.h>
29#include <string.h>
30
31#include "vasnprintf.h"
32
33ptrdiff_t
34vsnzprintf (char *str, size_t size, const char *format, va_list args)
35{
36 size_t lenbuf = size;
37 char *output = vasnprintf (str, &lenbuf, format, args);
38 size_t len = lenbuf;
39
40 if (!output)
41 return -1;
42
43 if (output != str)
44 {
45 if (size)
46 {
47 size_t pruned_len = (len < size ? len : size - 1);
48 memcpy (str, output, pruned_len);
49 str[pruned_len] = '\0';
50 }
51
52 free (output);
53 }
54
55 if (len > PTRDIFF_MAX)
56 {
57 errno = ENOMEM;
58 return -1;
59 }
60
61 return len;
62}
diff --git a/gl/w32sock.h b/gl/w32sock.h
index 84e46e33..a3201ad9 100644
--- a/gl/w32sock.h
+++ b/gl/w32sock.h
@@ -1,6 +1,6 @@
1/* w32sock.h --- internal auxiliary functions for Windows socket functions 1/* w32sock.h --- internal auxiliary functions for Windows socket functions
2 2
3 Copyright (C) 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/warn-on-use.h b/gl/warn-on-use.h
index 30756034..97f36ea2 100644
--- a/gl/warn-on-use.h
+++ b/gl/warn-on-use.h
@@ -1,5 +1,5 @@
1/* A C macro for emitting warnings if a function is used. 1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2023 Free Software Foundation, Inc. 2 Copyright (C) 2010-2026 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published 5 under the terms of the GNU Lesser General Public License as published
@@ -32,6 +32,10 @@
32 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 32 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
33 linkage. 33 linkage.
34 34
35 _GL_WARN_ON_USE should not be used more than once for a given function
36 in a given compilation unit (because this may generate a warning even
37 if the function is never called).
38
35 However, one of the reasons that a function is a portability trap is 39 However, one of the reasons that a function is a portability trap is
36 if it has the wrong signature. Declaring FUNCTION with a different 40 if it has the wrong signature. Declaring FUNCTION with a different
37 signature in C is a compilation error, so this macro must use the 41 signature in C is a compilation error, so this macro must use the
@@ -81,7 +85,7 @@
81 */ 85 */
82#ifndef _GL_WARN_ON_USE 86#ifndef _GL_WARN_ON_USE
83 87
84# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 88# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
85/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 89/* A compiler attribute is available in gcc versions 4.3.0 and later. */
86# define _GL_WARN_ON_USE(function, message) \ 90# define _GL_WARN_ON_USE(function, message) \
87_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) 91_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
@@ -94,7 +98,7 @@ _GL_WARN_EXTERN_C __typeof__ (function) function \
94 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 98 __attribute__ ((__diagnose_if__ (1, message, "warning")))
95# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 99# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
96 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 100 __attribute__ ((__diagnose_if__ (1, message, "warning")))
97# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 101# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
98/* Verify the existence of the function. */ 102/* Verify the existence of the function. */
99# define _GL_WARN_ON_USE(function, message) \ 103# define _GL_WARN_ON_USE(function, message) \
100_GL_WARN_EXTERN_C __typeof__ (function) function 104_GL_WARN_EXTERN_C __typeof__ (function) function
@@ -117,7 +121,7 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
117# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 121# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
118 _GL_WARN_ON_USE (function, msg) 122 _GL_WARN_ON_USE (function, msg)
119# else 123# else
120# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 124# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
121/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 125/* A compiler attribute is available in gcc versions 4.3.0 and later. */
122# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 126# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
123extern rettype_gcc function parameters_and_attributes \ 127extern rettype_gcc function parameters_and_attributes \
@@ -127,7 +131,7 @@ extern rettype_gcc function parameters_and_attributes \
127# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 131# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
128extern rettype_clang function parameters_and_attributes \ 132extern rettype_clang function parameters_and_attributes \
129 __attribute__ ((__diagnose_if__ (1, msg, "warning"))) 133 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
130# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 134# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
131/* Verify the existence of the function. */ 135/* Verify the existence of the function. */
132# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 136# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
133extern rettype_gcc function parameters_and_attributes 137extern rettype_gcc function parameters_and_attributes
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index 09c9185f..a60a4dfc 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. 1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3 Copyright (C) 2007-2023 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -36,8 +36,7 @@
36 && ((defined _INTTYPES_INCLUDED \ 36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \ 37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \ 38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \ 39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__))
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
41/* Special invocation convention: 40/* Special invocation convention:
42 - Inside glibc and uClibc header files, but not MinGW. 41 - Inside glibc and uClibc header files, but not MinGW.
43 - On HP-UX 11.00 we have a sequence of nested includes 42 - On HP-UX 11.00 we have a sequence of nested includes
@@ -47,20 +46,18 @@
47 therefore we cannot provide the function overrides; instead include only 46 therefore we cannot provide the function overrides; instead include only
48 the system's <wchar.h>. 47 the system's <wchar.h>.
49 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of 48 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
50 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'. 49 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'. */
51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
52 the latter includes <wchar.h>. But here, we have no way to detect whether
53 <wctype.h> is completely included or is still being included. */
54 50
55#@INCLUDE_NEXT@ @NEXT_WCHAR_H@ 51#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
52/* The glibc 2.5 /usr/include/wchar.h defines __need_wint_t but never undefines
53 it. We need to do that here. */
54#undef __need_wint_t
56 55
57#else 56#else
58/* Normal invocation convention. */ 57/* Normal invocation convention. */
59 58
60#ifndef _@GUARD_PREFIX@_WCHAR_H 59#ifndef _@GUARD_PREFIX@_WCHAR_H
61 60
62#define _GL_ALREADY_INCLUDING_WCHAR_H
63
64#if @HAVE_FEATURES_H@ 61#if @HAVE_FEATURES_H@
65# include <features.h> /* for __GLIBC__ */ 62# include <features.h> /* for __GLIBC__ */
66#endif 63#endif
@@ -79,16 +76,21 @@
79# @INCLUDE_NEXT@ @NEXT_WCHAR_H@ 76# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
80#endif 77#endif
81 78
82#undef _GL_ALREADY_INCLUDING_WCHAR_H
83
84#ifndef _@GUARD_PREFIX@_WCHAR_H 79#ifndef _@GUARD_PREFIX@_WCHAR_H
85#define _@GUARD_PREFIX@_WCHAR_H 80#define _@GUARD_PREFIX@_WCHAR_H
86 81
82/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
83 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
84 HAVE_RAW_DECL_*. */
85#if !_GL_CONFIG_H_INCLUDED
86 #error "Please include config.h first."
87#endif
88
87/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 89/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
88 that can be freed by passing them as the Ith argument to the 90 that can be freed by passing them as the Ith argument to the
89 function F. */ 91 function F. */
90#ifndef _GL_ATTRIBUTE_DEALLOC 92#ifndef _GL_ATTRIBUTE_DEALLOC
91# if __GNUC__ >= 11 93# if __GNUC__ >= 11 && !defined __clang__
92# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 94# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
93# else 95# else
94# define _GL_ATTRIBUTE_DEALLOC(f, i) 96# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -100,7 +102,7 @@
100/* Applies to: functions. Cannot be used on inline functions. */ 102/* Applies to: functions. Cannot be used on inline functions. */
101#ifndef _GL_ATTRIBUTE_DEALLOC_FREE 103#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
102# if defined __cplusplus && defined __GNUC__ && !defined __clang__ 104# if defined __cplusplus && defined __GNUC__ && !defined __clang__
103/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */ 105/* Work around GCC bug <https://gcc.gnu.org/PR108231> */
104# define _GL_ATTRIBUTE_DEALLOC_FREE \ 106# define _GL_ATTRIBUTE_DEALLOC_FREE \
105 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) 107 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
106# else 108# else
@@ -130,6 +132,40 @@
130# endif 132# endif
131#endif 133#endif
132 134
135/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
136 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
137/* Applies to: functions. */
138#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
139# if __GNUC__ >= 15 && !defined __clang__
140# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
141 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
142# else
143# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
144# endif
145#endif
146
147/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
148 */
149#ifndef _GL_ATTRIBUTE_NOTHROW
150# if defined __cplusplus
151# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
152# if __cplusplus >= 201103L
153# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
154# else
155# define _GL_ATTRIBUTE_NOTHROW throw ()
156# endif
157# else
158# define _GL_ATTRIBUTE_NOTHROW
159# endif
160# else
161# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
162# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
163# else
164# define _GL_ATTRIBUTE_NOTHROW
165# endif
166# endif
167#endif
168
133/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 169/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
134 170
135/* The definition of _GL_ARG_NONNULL is copied here. */ 171/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -167,17 +203,11 @@ typedef unsigned int rpl_wint_t;
167 203
168 204
169/* Override mbstate_t if it is too small. 205/* Override mbstate_t if it is too small.
170 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for 206 On AIX, MSVC, and OpenBSD 6.0, mbrtowc needs to be overridden, but
171 implementing mbrtowc for encodings like UTF-8. 207 mbstate_t exists and is large enough and overriding it would cause problems
172 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is 208 in C++ mode. */
173 large enough and overriding it would cause problems in C++ mode. */
174#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ 209#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
175# if !GNULIB_defined_mbstate_t 210# if !GNULIB_defined_mbstate_t
176# if !(defined _AIX || defined _MSC_VER)
177typedef int rpl_mbstate_t;
178# undef mbstate_t
179# define mbstate_t rpl_mbstate_t
180# endif
181# define GNULIB_defined_mbstate_t 1 211# define GNULIB_defined_mbstate_t 1
182# endif 212# endif
183#endif 213#endif
@@ -188,7 +218,11 @@ typedef int rpl_mbstate_t;
188# if (@REPLACE_FREE@ && !defined free \ 218# if (@REPLACE_FREE@ && !defined free \
189 && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 219 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
190/* We can't do '#define free rpl_free' here. */ 220/* We can't do '#define free rpl_free' here. */
221# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
222_GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW;
223# else
191_GL_EXTERN_C void rpl_free (void *); 224_GL_EXTERN_C void rpl_free (void *);
225# endif
192# undef _GL_ATTRIBUTE_DEALLOC_FREE 226# undef _GL_ATTRIBUTE_DEALLOC_FREE
193# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 227# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
194# else 228# else
@@ -200,7 +234,7 @@ _GL_EXTERN_C
200 void __cdecl free (void *); 234 void __cdecl free (void *);
201# else 235# else
202# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 236# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
203_GL_EXTERN_C void free (void *) throw (); 237_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
204# else 238# else
205_GL_EXTERN_C void free (void *); 239_GL_EXTERN_C void free (void *);
206# endif 240# endif
@@ -215,13 +249,69 @@ _GL_EXTERN_C
215 void __cdecl free (void *); 249 void __cdecl free (void *);
216# else 250# else
217# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 251# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
218_GL_EXTERN_C void free (void *) throw (); 252_GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW;
219# else 253# else
220_GL_EXTERN_C void free (void *); 254_GL_EXTERN_C void free (void *);
221# endif 255# endif
222# endif 256# endif
223#endif 257#endif
224 258
259
260#if @GNULIB_MBSZERO@
261/* Get memset(). */
262# include <string.h>
263#endif
264
265
266/* Declarations for ISO C N3322. */
267#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
268_GL_EXTERN_C wchar_t *wmemcpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
269# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
270 _GL_ATTRIBUTE_NOTHROW
271# endif
272 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
273 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
274_GL_EXTERN_C wchar_t *wmemmove (wchar_t *__dest, const wchar_t *__src, size_t __n)
275# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
276 _GL_ATTRIBUTE_NOTHROW
277# endif
278 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
279 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
280_GL_EXTERN_C wchar_t *wcsncpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
281# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
282 _GL_ATTRIBUTE_NOTHROW
283# endif
284 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
285 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
286_GL_EXTERN_C wchar_t *wcsncat (wchar_t *__dest, const wchar_t *__src, size_t __n)
287# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
288 _GL_ATTRIBUTE_NOTHROW
289# endif
290 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
291_GL_EXTERN_C int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
292# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
293 _GL_ATTRIBUTE_NOTHROW
294# endif
295 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
296 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
297_GL_EXTERN_C int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
298# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
299 _GL_ATTRIBUTE_NOTHROW
300# endif
301 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
302 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
303# ifndef __cplusplus
304_GL_EXTERN_C wchar_t *(wmemchr) (const wchar_t *__s, wchar_t __wc, size_t __n)
305 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
306# endif
307_GL_EXTERN_C wchar_t *wmemset (wchar_t *__s, wchar_t __wc, size_t __n)
308# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
309 _GL_ATTRIBUTE_NOTHROW
310# endif
311 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
312#endif
313
314
225/* Convert a single-byte character to a wide character. */ 315/* Convert a single-byte character to a wide character. */
226#if @GNULIB_BTOWC@ 316#if @GNULIB_BTOWC@
227# if @REPLACE_BTOWC@ 317# if @REPLACE_BTOWC@
@@ -229,11 +319,11 @@ _GL_EXTERN_C void free (void *);
229# undef btowc 319# undef btowc
230# define btowc rpl_btowc 320# define btowc rpl_btowc
231# endif 321# endif
232_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 322_GL_FUNCDECL_RPL (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
233_GL_CXXALIAS_RPL (btowc, wint_t, (int c)); 323_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
234# else 324# else
235# if !@HAVE_BTOWC@ 325# if !@HAVE_BTOWC@
236_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 326_GL_FUNCDECL_SYS (btowc, wint_t, (int c), _GL_ATTRIBUTE_PURE);
237# endif 327# endif
238/* Need to cast, because on mingw, the return type is 'unsigned short'. */ 328/* Need to cast, because on mingw, the return type is 'unsigned short'. */
239_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c)); 329_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
@@ -242,7 +332,6 @@ _GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
242_GL_CXXALIASWARN (btowc); 332_GL_CXXALIASWARN (btowc);
243# endif 333# endif
244#elif defined GNULIB_POSIXCHECK 334#elif defined GNULIB_POSIXCHECK
245# undef btowc
246# if HAVE_RAW_DECL_BTOWC 335# if HAVE_RAW_DECL_BTOWC
247_GL_WARN_ON_USE (btowc, "btowc is unportable - " 336_GL_WARN_ON_USE (btowc, "btowc is unportable - "
248 "use gnulib module btowc for portability"); 337 "use gnulib module btowc for portability");
@@ -257,12 +346,12 @@ _GL_WARN_ON_USE (btowc, "btowc is unportable - "
257# undef wctob 346# undef wctob
258# define wctob rpl_wctob 347# define wctob rpl_wctob
259# endif 348# endif
260_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); 349_GL_FUNCDECL_RPL (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
261_GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); 350_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
262# else 351# else
263# if !defined wctob && !@HAVE_DECL_WCTOB@ 352# if !defined wctob && !@HAVE_WCTOB@
264/* wctob is provided by gnulib, or wctob exists but is not declared. */ 353/* wctob is provided by gnulib. */
265_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE); 354_GL_FUNCDECL_SYS (wctob, int, (wint_t wc), _GL_ATTRIBUTE_PURE);
266# endif 355# endif
267_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); 356_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
268# endif 357# endif
@@ -270,7 +359,6 @@ _GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
270_GL_CXXALIASWARN (wctob); 359_GL_CXXALIASWARN (wctob);
271# endif 360# endif
272#elif defined GNULIB_POSIXCHECK 361#elif defined GNULIB_POSIXCHECK
273# undef wctob
274# if HAVE_RAW_DECL_WCTOB 362# if HAVE_RAW_DECL_WCTOB
275_GL_WARN_ON_USE (wctob, "wctob is unportable - " 363_GL_WARN_ON_USE (wctob, "wctob is unportable - "
276 "use gnulib module wctob for portability"); 364 "use gnulib module wctob for portability");
@@ -278,18 +366,18 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - "
278#endif 366#endif
279 367
280 368
281/* Test whether *PS is in the initial state. */ 369/* Test whether *PS is in an initial state. */
282#if @GNULIB_MBSINIT@ 370#if @GNULIB_MBSINIT@
283# if @REPLACE_MBSINIT@ 371# if @REPLACE_MBSINIT@
284# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 372# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
285# undef mbsinit 373# undef mbsinit
286# define mbsinit rpl_mbsinit 374# define mbsinit rpl_mbsinit
287# endif 375# endif
288_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); 376_GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps), );
289_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); 377_GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps));
290# else 378# else
291# if !@HAVE_MBSINIT@ 379# if !@HAVE_MBSINIT@
292_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); 380_GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps), );
293# endif 381# endif
294_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); 382_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
295# endif 383# endif
@@ -297,7 +385,6 @@ _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
297_GL_CXXALIASWARN (mbsinit); 385_GL_CXXALIASWARN (mbsinit);
298# endif 386# endif
299#elif defined GNULIB_POSIXCHECK 387#elif defined GNULIB_POSIXCHECK
300# undef mbsinit
301# if HAVE_RAW_DECL_MBSINIT 388# if HAVE_RAW_DECL_MBSINIT
302_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " 389_GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
303 "use gnulib module mbsinit for portability"); 390 "use gnulib module mbsinit for portability");
@@ -305,6 +392,211 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
305#endif 392#endif
306 393
307 394
395/* Put *PS into an initial state. */
396#if @GNULIB_MBSZERO@
397/* ISO C 23 § 7.31.6.(3) says that zeroing an mbstate_t is a way to put the
398 mbstate_t into an initial state. However, on many platforms an mbstate_t
399 is large, and it is possible - as an optimization - to get away with zeroing
400 only part of it. So, instead of
401
402 mbstate_t state = { 0 };
403
404 or
405
406 mbstate_t state;
407 memset (&state, 0, sizeof (mbstate_t));
408
409 we can write this faster code:
410
411 mbstate_t state;
412 mbszero (&state);
413 */
414/* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of
415 bytes at the beginning of an mbstate_t that need to be zero, for mbsinit()
416 to return true.
417 _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t
418 that need to be zero,
419 - for mbsinit() to return true, and
420 - for all other multibyte-aware functions to operate properly.
421 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t).
422 These values are determined by source code inspection, where possible, and
423 by running the gnulib unit tests.
424 We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE
425 without considering what mbsinit() does, we get test failures such as
426 assertion "mbsinit (&iter->state)" failed
427 */
428# if GNULIB_defined_mbstate_t /* AIX */
429/* mbstate_t has at least 4 bytes. They are used as coded in
430 gnulib/lib/mbrtowc.c. */
431# define _GL_MBSTATE_INIT_SIZE 1
432/* define _GL_MBSTATE_ZERO_SIZE 4
433 does not work: it causes test failures.
434 So, use the safe fallback value, below. */
435# elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */
436/* mbstate_t is defined in <bits/types/__mbstate_t.h>.
437 For more details, see glibc/iconv/skeleton.c. */
438# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */
439# define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t)
440# elif defined MUSL_LIBC /* musl libc */
441/* mbstate_t is defined in <bits/alltypes.h>.
442 It is an opaque aligned 8-byte struct, of which at most the first
443 4 bytes are used.
444 For more details, see src/multibyte/mbrtowc.c. */
445# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */
446# define _GL_MBSTATE_ZERO_SIZE 4
447# elif defined __APPLE__ && defined __MACH__ /* macOS */
448/* On macOS, mbstate_t is defined in <machine/_types.h>.
449 It is an opaque aligned 128-byte struct, of which at most the first
450 12 bytes are used.
451 For more details, see the __mbsinit implementations in
452 Libc-<version>/locale/FreeBSD/
453 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */
454/* File INIT_SIZE ZERO_SIZE
455 ascii.c 0 0
456 none.c 0 0
457 euc.c 12 12
458 mskanji.c 4 4
459 big5.c 4 4
460 gb2312.c 4 6
461 gbk.c 4 4
462 gb18030.c 4 8
463 utf8.c 8 10
464 utf2.c 8 12 */
465# define _GL_MBSTATE_INIT_SIZE 12
466# define _GL_MBSTATE_ZERO_SIZE 12
467# elif defined __FreeBSD__ /* FreeBSD */
468/* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h.
469 It is an opaque aligned 128-byte struct, of which at most the first
470 12 bytes are used.
471 For more details, see the __mbsinit implementations in
472 src/lib/libc/locale/
473 {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
474/* File INIT_SIZE ZERO_SIZE
475 ascii.c 0 0
476 none.c 0 0
477 euc.c 12 12
478 mskanji.c 4 4
479 big5.c 4 4
480 gb2312.c 4 6
481 gbk.c 4 4
482 gb18030.c 4 8
483 utf8.c 8 12 */
484# define _GL_MBSTATE_INIT_SIZE 12
485# define _GL_MBSTATE_ZERO_SIZE 12
486# elif defined __NetBSD__ /* NetBSD */
487/* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h.
488 It is an opaque aligned 128-byte struct, of which at most the first
489 28 bytes are used.
490 For more details, see the *State types in
491 src/lib/libc/citrus/modules/citrus_*.c
492 (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement
493 stateful encodings, not usable as locale encodings). */
494/* File ZERO_SIZE
495 citrus/citrus_none.c 0
496 citrus/modules/citrus_euc.c 8
497 citrus/modules/citrus_euctw.c 8
498 citrus/modules/citrus_mskanji.c 8
499 citrus/modules/citrus_big5.c 8
500 citrus/modules/citrus_gbk2k.c 8
501 citrus/modules/citrus_dechanyu.c 8
502 citrus/modules/citrus_johab.c 6
503 citrus/modules/citrus_utf8.c 12 */
504/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
505 failures for values < 28. */
506# define _GL_MBSTATE_ZERO_SIZE 28
507# elif defined __OpenBSD__ /* OpenBSD */
508/* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h.
509 It is an opaque aligned 128-byte struct, of which at most the first
510 12 bytes are used.
511 For more details, see src/lib/libc/citrus/citrus_*.c. */
512/* File INIT_SIZE ZERO_SIZE
513 citrus_none.c 0 0
514 citrus_utf8.c 12 12 */
515# define _GL_MBSTATE_INIT_SIZE 12
516# define _GL_MBSTATE_ZERO_SIZE 12
517# elif defined __minix /* Minix */
518/* On Minix, mbstate_t is defined in sys/sys/ansi.h.
519 It is an opaque aligned 128-byte struct.
520 For more details, see the *State types in
521 lib/libc/citrus/citrus_*.c. */
522/* File INIT_SIZE ZERO_SIZE
523 citrus_none.c 0 0 */
524/* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
525 failures for values < 4. */
526# define _GL_MBSTATE_ZERO_SIZE 4
527# elif defined __sun /* Solaris */
528/* On Solaris, mbstate_t is defined in <wchar_impl.h>.
529 It is an opaque aligned 24-byte or 32-byte struct, of which at most the first
530 20 or 28 bytes are used.
531 For more details on OpenSolaris derivatives, see the *State types in
532 illumos-gate/usr/src/lib/libc/port/locale/
533 {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */
534/* File INIT_SIZE ZERO_SIZE
535 none.c 0 0
536 euc.c 12 12
537 mskanji.c 4 4
538 big5.c 4 4
539 gb2312.c 4 6
540 gbk.c 4 4
541 gb18030.c 4 8
542 utf8.c 12 12 */
543/* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test
544 failures
545 - in OpenIndiana and OmniOS: for values < 16,
546 - in Solaris 10 and 11: for values < 20 (in 32-bit mode)
547 or < 28 (in 64-bit mode).
548 Since we don't have a good way to distinguish the OpenSolaris derivatives
549 from the proprietary Solaris versions, and can't inspect the Solaris source
550 code, use the safe fallback values, below. */
551# elif defined __CYGWIN__ /* Cygwin */
552/* On Cygwin, mbstate_t is defined in <sys/_types.h>.
553 For more details, see newlib/libc/stdlib/mbtowc_r.c and
554 winsup/cygwin/strfuncs.cc. */
555# define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */
556# define _GL_MBSTATE_ZERO_SIZE 8
557# elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */
558/* MSVC defines 'mbstate_t' as an aligned 8-byte struct.
559 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined
560 as an aligned 8-byte struct, of which the first 4 bytes matter.
561 Use the safe values, below. */
562# elif defined __ANDROID__ /* Android */
563/* Android defines 'mbstate_t' in <bits/mbstate_t.h>.
564 It is an opaque 4-byte or 8-byte struct.
565 For more details, see
566 bionic/libc/private/bionic_mbstate.h
567 bionic/libc/bionic/mbrtoc32.cpp
568 bionic/libc/bionic/mbrtoc16.cpp
569 */
570# define _GL_MBSTATE_INIT_SIZE 4
571# define _GL_MBSTATE_ZERO_SIZE 4
572# endif
573/* Use safe values as defaults. */
574# ifndef _GL_MBSTATE_INIT_SIZE
575# define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t)
576# endif
577# ifndef _GL_MBSTATE_ZERO_SIZE
578# define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t)
579# endif
580_GL_BEGIN_C_LINKAGE
581# if !GNULIB_defined_mbszero
582# if defined IN_MBSZERO
583_GL_EXTERN_INLINE
584# else
585_GL_INLINE
586# endif
587_GL_ARG_NONNULL ((1)) void
588mbszero (mbstate_t *ps)
589{
590 memset (ps, 0, _GL_MBSTATE_ZERO_SIZE);
591}
592# define GNULIB_defined_mbszero 1
593# endif
594_GL_END_C_LINKAGE
595_GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps));
596_GL_CXXALIASWARN (mbszero);
597#endif
598
599
308/* Convert a multibyte character to a wide character. */ 600/* Convert a multibyte character to a wide character. */
309#if @GNULIB_MBRTOWC@ 601#if @GNULIB_MBRTOWC@
310# if @REPLACE_MBRTOWC@ 602# if @REPLACE_MBRTOWC@
@@ -314,7 +606,7 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
314# endif 606# endif
315_GL_FUNCDECL_RPL (mbrtowc, size_t, 607_GL_FUNCDECL_RPL (mbrtowc, size_t,
316 (wchar_t *restrict pwc, const char *restrict s, size_t n, 608 (wchar_t *restrict pwc, const char *restrict s, size_t n,
317 mbstate_t *restrict ps)); 609 mbstate_t *restrict ps), );
318_GL_CXXALIAS_RPL (mbrtowc, size_t, 610_GL_CXXALIAS_RPL (mbrtowc, size_t,
319 (wchar_t *restrict pwc, const char *restrict s, size_t n, 611 (wchar_t *restrict pwc, const char *restrict s, size_t n,
320 mbstate_t *restrict ps)); 612 mbstate_t *restrict ps));
@@ -322,7 +614,7 @@ _GL_CXXALIAS_RPL (mbrtowc, size_t,
322# if !@HAVE_MBRTOWC@ 614# if !@HAVE_MBRTOWC@
323_GL_FUNCDECL_SYS (mbrtowc, size_t, 615_GL_FUNCDECL_SYS (mbrtowc, size_t,
324 (wchar_t *restrict pwc, const char *restrict s, size_t n, 616 (wchar_t *restrict pwc, const char *restrict s, size_t n,
325 mbstate_t *restrict ps)); 617 mbstate_t *restrict ps), );
326# endif 618# endif
327_GL_CXXALIAS_SYS (mbrtowc, size_t, 619_GL_CXXALIAS_SYS (mbrtowc, size_t,
328 (wchar_t *restrict pwc, const char *restrict s, size_t n, 620 (wchar_t *restrict pwc, const char *restrict s, size_t n,
@@ -332,7 +624,6 @@ _GL_CXXALIAS_SYS (mbrtowc, size_t,
332_GL_CXXALIASWARN (mbrtowc); 624_GL_CXXALIASWARN (mbrtowc);
333# endif 625# endif
334#elif defined GNULIB_POSIXCHECK 626#elif defined GNULIB_POSIXCHECK
335# undef mbrtowc
336# if HAVE_RAW_DECL_MBRTOWC 627# if HAVE_RAW_DECL_MBRTOWC
337_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - " 628_GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
338 "use gnulib module mbrtowc for portability"); 629 "use gnulib module mbrtowc for portability");
@@ -348,13 +639,13 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
348# define mbrlen rpl_mbrlen 639# define mbrlen rpl_mbrlen
349# endif 640# endif
350_GL_FUNCDECL_RPL (mbrlen, size_t, 641_GL_FUNCDECL_RPL (mbrlen, size_t,
351 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 642 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
352_GL_CXXALIAS_RPL (mbrlen, size_t, 643_GL_CXXALIAS_RPL (mbrlen, size_t,
353 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 644 (const char *restrict s, size_t n, mbstate_t *restrict ps));
354# else 645# else
355# if !@HAVE_MBRLEN@ 646# if !@HAVE_MBRLEN@
356_GL_FUNCDECL_SYS (mbrlen, size_t, 647_GL_FUNCDECL_SYS (mbrlen, size_t,
357 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 648 (const char *restrict s, size_t n, mbstate_t *restrict ps), );
358# endif 649# endif
359_GL_CXXALIAS_SYS (mbrlen, size_t, 650_GL_CXXALIAS_SYS (mbrlen, size_t,
360 (const char *restrict s, size_t n, mbstate_t *restrict ps)); 651 (const char *restrict s, size_t n, mbstate_t *restrict ps));
@@ -363,7 +654,6 @@ _GL_CXXALIAS_SYS (mbrlen, size_t,
363_GL_CXXALIASWARN (mbrlen); 654_GL_CXXALIASWARN (mbrlen);
364# endif 655# endif
365#elif defined GNULIB_POSIXCHECK 656#elif defined GNULIB_POSIXCHECK
366# undef mbrlen
367# if HAVE_RAW_DECL_MBRLEN 657# if HAVE_RAW_DECL_MBRLEN
368_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - " 658_GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
369 "use gnulib module mbrlen for portability"); 659 "use gnulib module mbrlen for portability");
@@ -381,7 +671,7 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
381_GL_FUNCDECL_RPL (mbsrtowcs, size_t, 671_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
382 (wchar_t *restrict dest, 672 (wchar_t *restrict dest,
383 const char **restrict srcp, size_t len, 673 const char **restrict srcp, size_t len,
384 mbstate_t *restrict ps) 674 mbstate_t *restrict ps),
385 _GL_ARG_NONNULL ((2))); 675 _GL_ARG_NONNULL ((2)));
386_GL_CXXALIAS_RPL (mbsrtowcs, size_t, 676_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
387 (wchar_t *restrict dest, 677 (wchar_t *restrict dest,
@@ -392,7 +682,7 @@ _GL_CXXALIAS_RPL (mbsrtowcs, size_t,
392_GL_FUNCDECL_SYS (mbsrtowcs, size_t, 682_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
393 (wchar_t *restrict dest, 683 (wchar_t *restrict dest,
394 const char **restrict srcp, size_t len, 684 const char **restrict srcp, size_t len,
395 mbstate_t *restrict ps) 685 mbstate_t *restrict ps),
396 _GL_ARG_NONNULL ((2))); 686 _GL_ARG_NONNULL ((2)));
397# endif 687# endif
398_GL_CXXALIAS_SYS (mbsrtowcs, size_t, 688_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
@@ -404,7 +694,6 @@ _GL_CXXALIAS_SYS (mbsrtowcs, size_t,
404_GL_CXXALIASWARN (mbsrtowcs); 694_GL_CXXALIASWARN (mbsrtowcs);
405# endif 695# endif
406#elif defined GNULIB_POSIXCHECK 696#elif defined GNULIB_POSIXCHECK
407# undef mbsrtowcs
408# if HAVE_RAW_DECL_MBSRTOWCS 697# if HAVE_RAW_DECL_MBSRTOWCS
409_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - " 698_GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
410 "use gnulib module mbsrtowcs for portability"); 699 "use gnulib module mbsrtowcs for portability");
@@ -422,7 +711,7 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
422_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, 711_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
423 (wchar_t *restrict dest, 712 (wchar_t *restrict dest,
424 const char **restrict srcp, size_t srclen, size_t len, 713 const char **restrict srcp, size_t srclen, size_t len,
425 mbstate_t *restrict ps) 714 mbstate_t *restrict ps),
426 _GL_ARG_NONNULL ((2))); 715 _GL_ARG_NONNULL ((2)));
427_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, 716_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
428 (wchar_t *restrict dest, 717 (wchar_t *restrict dest,
@@ -433,7 +722,7 @@ _GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
433_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, 722_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
434 (wchar_t *restrict dest, 723 (wchar_t *restrict dest,
435 const char **restrict srcp, size_t srclen, size_t len, 724 const char **restrict srcp, size_t srclen, size_t len,
436 mbstate_t *restrict ps) 725 mbstate_t *restrict ps),
437 _GL_ARG_NONNULL ((2))); 726 _GL_ARG_NONNULL ((2)));
438# endif 727# endif
439_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, 728_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
@@ -441,9 +730,10 @@ _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
441 const char **restrict srcp, size_t srclen, size_t len, 730 const char **restrict srcp, size_t srclen, size_t len,
442 mbstate_t *restrict ps)); 731 mbstate_t *restrict ps));
443# endif 732# endif
733# if __GLIBC__ >= 2
444_GL_CXXALIASWARN (mbsnrtowcs); 734_GL_CXXALIASWARN (mbsnrtowcs);
735# endif
445#elif defined GNULIB_POSIXCHECK 736#elif defined GNULIB_POSIXCHECK
446# undef mbsnrtowcs
447# if HAVE_RAW_DECL_MBSNRTOWCS 737# if HAVE_RAW_DECL_MBSNRTOWCS
448_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - " 738_GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
449 "use gnulib module mbsnrtowcs for portability"); 739 "use gnulib module mbsnrtowcs for portability");
@@ -459,13 +749,13 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
459# define wcrtomb rpl_wcrtomb 749# define wcrtomb rpl_wcrtomb
460# endif 750# endif
461_GL_FUNCDECL_RPL (wcrtomb, size_t, 751_GL_FUNCDECL_RPL (wcrtomb, size_t,
462 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 752 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
463_GL_CXXALIAS_RPL (wcrtomb, size_t, 753_GL_CXXALIAS_RPL (wcrtomb, size_t,
464 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 754 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
465# else 755# else
466# if !@HAVE_WCRTOMB@ 756# if !@HAVE_WCRTOMB@
467_GL_FUNCDECL_SYS (wcrtomb, size_t, 757_GL_FUNCDECL_SYS (wcrtomb, size_t,
468 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 758 (char *restrict s, wchar_t wc, mbstate_t *restrict ps), );
469# endif 759# endif
470_GL_CXXALIAS_SYS (wcrtomb, size_t, 760_GL_CXXALIAS_SYS (wcrtomb, size_t,
471 (char *restrict s, wchar_t wc, mbstate_t *restrict ps)); 761 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
@@ -474,7 +764,6 @@ _GL_CXXALIAS_SYS (wcrtomb, size_t,
474_GL_CXXALIASWARN (wcrtomb); 764_GL_CXXALIASWARN (wcrtomb);
475# endif 765# endif
476#elif defined GNULIB_POSIXCHECK 766#elif defined GNULIB_POSIXCHECK
477# undef wcrtomb
478# if HAVE_RAW_DECL_WCRTOMB 767# if HAVE_RAW_DECL_WCRTOMB
479_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - " 768_GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
480 "use gnulib module wcrtomb for portability"); 769 "use gnulib module wcrtomb for portability");
@@ -492,7 +781,7 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
492_GL_FUNCDECL_RPL (wcsrtombs, size_t, 781_GL_FUNCDECL_RPL (wcsrtombs, size_t,
493 (char *restrict dest, const wchar_t **restrict srcp, 782 (char *restrict dest, const wchar_t **restrict srcp,
494 size_t len, 783 size_t len,
495 mbstate_t *restrict ps) 784 mbstate_t *restrict ps),
496 _GL_ARG_NONNULL ((2))); 785 _GL_ARG_NONNULL ((2)));
497_GL_CXXALIAS_RPL (wcsrtombs, size_t, 786_GL_CXXALIAS_RPL (wcsrtombs, size_t,
498 (char *restrict dest, const wchar_t **restrict srcp, 787 (char *restrict dest, const wchar_t **restrict srcp,
@@ -503,7 +792,7 @@ _GL_CXXALIAS_RPL (wcsrtombs, size_t,
503_GL_FUNCDECL_SYS (wcsrtombs, size_t, 792_GL_FUNCDECL_SYS (wcsrtombs, size_t,
504 (char *restrict dest, const wchar_t **restrict srcp, 793 (char *restrict dest, const wchar_t **restrict srcp,
505 size_t len, 794 size_t len,
506 mbstate_t *restrict ps) 795 mbstate_t *restrict ps),
507 _GL_ARG_NONNULL ((2))); 796 _GL_ARG_NONNULL ((2)));
508# endif 797# endif
509_GL_CXXALIAS_SYS (wcsrtombs, size_t, 798_GL_CXXALIAS_SYS (wcsrtombs, size_t,
@@ -515,7 +804,6 @@ _GL_CXXALIAS_SYS (wcsrtombs, size_t,
515_GL_CXXALIASWARN (wcsrtombs); 804_GL_CXXALIASWARN (wcsrtombs);
516# endif 805# endif
517#elif defined GNULIB_POSIXCHECK 806#elif defined GNULIB_POSIXCHECK
518# undef wcsrtombs
519# if HAVE_RAW_DECL_WCSRTOMBS 807# if HAVE_RAW_DECL_WCSRTOMBS
520_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - " 808_GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
521 "use gnulib module wcsrtombs for portability"); 809 "use gnulib module wcsrtombs for portability");
@@ -534,7 +822,7 @@ _GL_FUNCDECL_RPL (wcsnrtombs, size_t,
534 (char *restrict dest, 822 (char *restrict dest,
535 const wchar_t **restrict srcp, size_t srclen, 823 const wchar_t **restrict srcp, size_t srclen,
536 size_t len, 824 size_t len,
537 mbstate_t *restrict ps) 825 mbstate_t *restrict ps),
538 _GL_ARG_NONNULL ((2))); 826 _GL_ARG_NONNULL ((2)));
539_GL_CXXALIAS_RPL (wcsnrtombs, size_t, 827_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
540 (char *restrict dest, 828 (char *restrict dest,
@@ -547,7 +835,7 @@ _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
547 (char *restrict dest, 835 (char *restrict dest,
548 const wchar_t **restrict srcp, size_t srclen, 836 const wchar_t **restrict srcp, size_t srclen,
549 size_t len, 837 size_t len,
550 mbstate_t *restrict ps) 838 mbstate_t *restrict ps),
551 _GL_ARG_NONNULL ((2))); 839 _GL_ARG_NONNULL ((2)));
552# endif 840# endif
553_GL_CXXALIAS_SYS (wcsnrtombs, size_t, 841_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
@@ -560,7 +848,6 @@ _GL_CXXALIAS_SYS (wcsnrtombs, size_t,
560_GL_CXXALIASWARN (wcsnrtombs); 848_GL_CXXALIASWARN (wcsnrtombs);
561# endif 849# endif
562#elif defined GNULIB_POSIXCHECK 850#elif defined GNULIB_POSIXCHECK
563# undef wcsnrtombs
564# if HAVE_RAW_DECL_WCSNRTOMBS 851# if HAVE_RAW_DECL_WCSNRTOMBS
565_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " 852_GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
566 "use gnulib module wcsnrtombs for portability"); 853 "use gnulib module wcsnrtombs for portability");
@@ -575,12 +862,12 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
575# undef wcwidth 862# undef wcwidth
576# define wcwidth rpl_wcwidth 863# define wcwidth rpl_wcwidth
577# endif 864# endif
578_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); 865_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
579_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); 866_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
580# else 867# else
581# if !@HAVE_DECL_WCWIDTH@ 868# if !@HAVE_DECL_WCWIDTH@
582/* wcwidth exists but is not declared. */ 869/* wcwidth exists but is not declared. */
583_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE); 870_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t), _GL_ATTRIBUTE_PURE);
584# endif 871# endif
585_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); 872_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
586# endif 873# endif
@@ -588,7 +875,6 @@ _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
588_GL_CXXALIASWARN (wcwidth); 875_GL_CXXALIASWARN (wcwidth);
589# endif 876# endif
590#elif defined GNULIB_POSIXCHECK 877#elif defined GNULIB_POSIXCHECK
591# undef wcwidth
592# if HAVE_RAW_DECL_WCWIDTH 878# if HAVE_RAW_DECL_WCWIDTH
593_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - " 879_GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
594 "use gnulib module wcwidth for portability"); 880 "use gnulib module wcwidth for portability");
@@ -599,8 +885,9 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
599/* Search N wide characters of S for C. */ 885/* Search N wide characters of S for C. */
600#if @GNULIB_WMEMCHR@ 886#if @GNULIB_WMEMCHR@
601# if !@HAVE_WMEMCHR@ 887# if !@HAVE_WMEMCHR@
602_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n) 888_GL_FUNCDECL_SYS (wmemchr, wchar_t *,
603 _GL_ATTRIBUTE_PURE); 889 (const wchar_t *s, wchar_t c, size_t n),
890 _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
604# endif 891# endif
605 /* On some systems, this function is defined as an overloaded function: 892 /* On some systems, this function is defined as an overloaded function:
606 extern "C++" { 893 extern "C++" {
@@ -611,15 +898,15 @@ _GL_CXXALIAS_SYS_CAST2 (wmemchr,
611 wchar_t *, (const wchar_t *, wchar_t, size_t), 898 wchar_t *, (const wchar_t *, wchar_t, size_t),
612 const wchar_t *, (const wchar_t *, wchar_t, size_t)); 899 const wchar_t *, (const wchar_t *, wchar_t, size_t));
613# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 900# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
614 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 901 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
902 && !defined __clang__
615_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 903_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
616_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, 904_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
617 (const wchar_t *s, wchar_t c, size_t n)); 905 (const wchar_t *s, wchar_t c, size_t n));
618# elif __GLIBC__ >= 2 906# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
619_GL_CXXALIASWARN (wmemchr); 907_GL_CXXALIASWARN (wmemchr);
620# endif 908# endif
621#elif defined GNULIB_POSIXCHECK 909#elif defined GNULIB_POSIXCHECK
622# undef wmemchr
623# if HAVE_RAW_DECL_WMEMCHR 910# if HAVE_RAW_DECL_WMEMCHR
624_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " 911_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
625 "use gnulib module wmemchr for portability"); 912 "use gnulib module wmemchr for portability");
@@ -629,18 +916,33 @@ _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
629 916
630/* Compare N wide characters of S1 and S2. */ 917/* Compare N wide characters of S1 and S2. */
631#if @GNULIB_WMEMCMP@ 918#if @GNULIB_WMEMCMP@
632# if !@HAVE_WMEMCMP@ 919# if @REPLACE_WMEMCMP@
920# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
921# undef wmemcmp
922# define wmemcmp rpl_wmemcmp
923# endif
924_GL_FUNCDECL_RPL (wmemcmp, int,
925 (const wchar_t *s1, const wchar_t *s2, size_t n),
926 _GL_ATTRIBUTE_PURE
927 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
928 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
929_GL_CXXALIAS_RPL (wmemcmp, int,
930 (const wchar_t *s1, const wchar_t *s2, size_t n));
931# else
932# if !@HAVE_WMEMCMP@
633_GL_FUNCDECL_SYS (wmemcmp, int, 933_GL_FUNCDECL_SYS (wmemcmp, int,
634 (const wchar_t *s1, const wchar_t *s2, size_t n) 934 (const wchar_t *s1, const wchar_t *s2, size_t n),
635 _GL_ATTRIBUTE_PURE); 935 _GL_ATTRIBUTE_PURE
636# endif 936 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
937 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
938# endif
637_GL_CXXALIAS_SYS (wmemcmp, int, 939_GL_CXXALIAS_SYS (wmemcmp, int,
638 (const wchar_t *s1, const wchar_t *s2, size_t n)); 940 (const wchar_t *s1, const wchar_t *s2, size_t n));
941# endif
639# if __GLIBC__ >= 2 942# if __GLIBC__ >= 2
640_GL_CXXALIASWARN (wmemcmp); 943_GL_CXXALIASWARN (wmemcmp);
641# endif 944# endif
642#elif defined GNULIB_POSIXCHECK 945#elif defined GNULIB_POSIXCHECK
643# undef wmemcmp
644# if HAVE_RAW_DECL_WMEMCMP 946# if HAVE_RAW_DECL_WMEMCMP
645_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - " 947_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
646 "use gnulib module wmemcmp for portability"); 948 "use gnulib module wmemcmp for portability");
@@ -653,7 +955,9 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
653# if !@HAVE_WMEMCPY@ 955# if !@HAVE_WMEMCPY@
654_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, 956_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
655 (wchar_t *restrict dest, 957 (wchar_t *restrict dest,
656 const wchar_t *restrict src, size_t n)); 958 const wchar_t *restrict src, size_t n),
959 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
960 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
657# endif 961# endif
658_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, 962_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
659 (wchar_t *restrict dest, 963 (wchar_t *restrict dest,
@@ -662,7 +966,6 @@ _GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
662_GL_CXXALIASWARN (wmemcpy); 966_GL_CXXALIASWARN (wmemcpy);
663# endif 967# endif
664#elif defined GNULIB_POSIXCHECK 968#elif defined GNULIB_POSIXCHECK
665# undef wmemcpy
666# if HAVE_RAW_DECL_WMEMCPY 969# if HAVE_RAW_DECL_WMEMCPY
667_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - " 970_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
668 "use gnulib module wmemcpy for portability"); 971 "use gnulib module wmemcpy for portability");
@@ -675,7 +978,9 @@ _GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
675#if @GNULIB_WMEMMOVE@ 978#if @GNULIB_WMEMMOVE@
676# if !@HAVE_WMEMMOVE@ 979# if !@HAVE_WMEMMOVE@
677_GL_FUNCDECL_SYS (wmemmove, wchar_t *, 980_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
678 (wchar_t *dest, const wchar_t *src, size_t n)); 981 (wchar_t *dest, const wchar_t *src, size_t n),
982 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
983 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
679# endif 984# endif
680_GL_CXXALIAS_SYS (wmemmove, wchar_t *, 985_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
681 (wchar_t *dest, const wchar_t *src, size_t n)); 986 (wchar_t *dest, const wchar_t *src, size_t n));
@@ -683,7 +988,6 @@ _GL_CXXALIAS_SYS (wmemmove, wchar_t *,
683_GL_CXXALIASWARN (wmemmove); 988_GL_CXXALIASWARN (wmemmove);
684# endif 989# endif
685#elif defined GNULIB_POSIXCHECK 990#elif defined GNULIB_POSIXCHECK
686# undef wmemmove
687# if HAVE_RAW_DECL_WMEMMOVE 991# if HAVE_RAW_DECL_WMEMMOVE
688_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " 992_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
689 "use gnulib module wmemmove for portability"); 993 "use gnulib module wmemmove for portability");
@@ -694,19 +998,31 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
694/* Copy N wide characters of SRC to DEST. 998/* Copy N wide characters of SRC to DEST.
695 Return pointer to wide characters after the last written wide character. */ 999 Return pointer to wide characters after the last written wide character. */
696#if @GNULIB_WMEMPCPY@ 1000#if @GNULIB_WMEMPCPY@
697# if !@HAVE_WMEMPCPY@ 1001# if @REPLACE_WMEMPCPY@
698_GL_FUNCDECL_SYS (wmempcpy, wchar_t *, 1002# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1003# undef wmempcpy
1004# define wmempcpy rpl_wmempcpy
1005# endif
1006_GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
1007 (wchar_t *restrict dest,
1008 const wchar_t *restrict src, size_t n), );
1009_GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
699 (wchar_t *restrict dest, 1010 (wchar_t *restrict dest,
700 const wchar_t *restrict src, size_t n)); 1011 const wchar_t *restrict src, size_t n));
701# endif 1012# else
1013# if !@HAVE_WMEMPCPY@
1014_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
1015 (wchar_t *restrict dest,
1016 const wchar_t *restrict src, size_t n), );
1017# endif
702_GL_CXXALIAS_SYS (wmempcpy, wchar_t *, 1018_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
703 (wchar_t *restrict dest, 1019 (wchar_t *restrict dest,
704 const wchar_t *restrict src, size_t n)); 1020 const wchar_t *restrict src, size_t n));
1021# endif
705# if __GLIBC__ >= 2 1022# if __GLIBC__ >= 2
706_GL_CXXALIASWARN (wmempcpy); 1023_GL_CXXALIASWARN (wmempcpy);
707# endif 1024# endif
708#elif defined GNULIB_POSIXCHECK 1025#elif defined GNULIB_POSIXCHECK
709# undef wmempcpy
710# if HAVE_RAW_DECL_WMEMPCPY 1026# if HAVE_RAW_DECL_WMEMPCPY
711_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - " 1027_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
712 "use gnulib module wmempcpy for portability"); 1028 "use gnulib module wmempcpy for portability");
@@ -717,14 +1033,14 @@ _GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
717/* Set N wide characters of S to C. */ 1033/* Set N wide characters of S to C. */
718#if @GNULIB_WMEMSET@ 1034#if @GNULIB_WMEMSET@
719# if !@HAVE_WMEMSET@ 1035# if !@HAVE_WMEMSET@
720_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 1036_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n),
1037 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3));
721# endif 1038# endif
722_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 1039_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
723# if __GLIBC__ >= 2 1040# if __GLIBC__ >= 2
724_GL_CXXALIASWARN (wmemset); 1041_GL_CXXALIASWARN (wmemset);
725# endif 1042# endif
726#elif defined GNULIB_POSIXCHECK 1043#elif defined GNULIB_POSIXCHECK
727# undef wmemset
728# if HAVE_RAW_DECL_WMEMSET 1044# if HAVE_RAW_DECL_WMEMSET
729_GL_WARN_ON_USE (wmemset, "wmemset is unportable - " 1045_GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
730 "use gnulib module wmemset for portability"); 1046 "use gnulib module wmemset for portability");
@@ -735,14 +1051,13 @@ _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
735/* Return the number of wide characters in S. */ 1051/* Return the number of wide characters in S. */
736#if @GNULIB_WCSLEN@ 1052#if @GNULIB_WCSLEN@
737# if !@HAVE_WCSLEN@ 1053# if !@HAVE_WCSLEN@
738_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); 1054_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s), _GL_ATTRIBUTE_PURE);
739# endif 1055# endif
740_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); 1056_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
741# if __GLIBC__ >= 2 1057# if __GLIBC__ >= 2
742_GL_CXXALIASWARN (wcslen); 1058_GL_CXXALIASWARN (wcslen);
743# endif 1059# endif
744#elif defined GNULIB_POSIXCHECK 1060#elif defined GNULIB_POSIXCHECK
745# undef wcslen
746# if HAVE_RAW_DECL_WCSLEN 1061# if HAVE_RAW_DECL_WCSLEN
747_GL_WARN_ON_USE (wcslen, "wcslen is unportable - " 1062_GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
748 "use gnulib module wcslen for portability"); 1063 "use gnulib module wcslen for portability");
@@ -756,13 +1071,12 @@ _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
756 namespace, not in the global namespace. So, force a declaration in 1071 namespace, not in the global namespace. So, force a declaration in
757 the global namespace. */ 1072 the global namespace. */
758# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus) 1073# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
759_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) 1074_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen),
760 _GL_ATTRIBUTE_PURE); 1075 _GL_ATTRIBUTE_PURE);
761# endif 1076# endif
762_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)); 1077_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
763_GL_CXXALIASWARN (wcsnlen); 1078_GL_CXXALIASWARN (wcsnlen);
764#elif defined GNULIB_POSIXCHECK 1079#elif defined GNULIB_POSIXCHECK
765# undef wcsnlen
766# if HAVE_RAW_DECL_WCSNLEN 1080# if HAVE_RAW_DECL_WCSNLEN
767_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - " 1081_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
768 "use gnulib module wcsnlen for portability"); 1082 "use gnulib module wcsnlen for portability");
@@ -774,7 +1088,7 @@ _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
774#if @GNULIB_WCSCPY@ 1088#if @GNULIB_WCSCPY@
775# if !@HAVE_WCSCPY@ 1089# if !@HAVE_WCSCPY@
776_GL_FUNCDECL_SYS (wcscpy, wchar_t *, 1090_GL_FUNCDECL_SYS (wcscpy, wchar_t *,
777 (wchar_t *restrict dest, const wchar_t *restrict src)); 1091 (wchar_t *restrict dest, const wchar_t *restrict src), );
778# endif 1092# endif
779_GL_CXXALIAS_SYS (wcscpy, wchar_t *, 1093_GL_CXXALIAS_SYS (wcscpy, wchar_t *,
780 (wchar_t *restrict dest, const wchar_t *restrict src)); 1094 (wchar_t *restrict dest, const wchar_t *restrict src));
@@ -782,7 +1096,6 @@ _GL_CXXALIAS_SYS (wcscpy, wchar_t *,
782_GL_CXXALIASWARN (wcscpy); 1096_GL_CXXALIASWARN (wcscpy);
783# endif 1097# endif
784#elif defined GNULIB_POSIXCHECK 1098#elif defined GNULIB_POSIXCHECK
785# undef wcscpy
786# if HAVE_RAW_DECL_WCSCPY 1099# if HAVE_RAW_DECL_WCSCPY
787_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - " 1100_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
788 "use gnulib module wcscpy for portability"); 1101 "use gnulib module wcscpy for portability");
@@ -797,13 +1110,12 @@ _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
797 the global namespace. */ 1110 the global namespace. */
798# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus) 1111# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
799_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, 1112_GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
800 (wchar_t *restrict dest, const wchar_t *restrict src)); 1113 (wchar_t *restrict dest, const wchar_t *restrict src), );
801# endif 1114# endif
802_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, 1115_GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
803 (wchar_t *restrict dest, const wchar_t *restrict src)); 1116 (wchar_t *restrict dest, const wchar_t *restrict src));
804_GL_CXXALIASWARN (wcpcpy); 1117_GL_CXXALIASWARN (wcpcpy);
805#elif defined GNULIB_POSIXCHECK 1118#elif defined GNULIB_POSIXCHECK
806# undef wcpcpy
807# if HAVE_RAW_DECL_WCPCPY 1119# if HAVE_RAW_DECL_WCPCPY
808_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - " 1120_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
809 "use gnulib module wcpcpy for portability"); 1121 "use gnulib module wcpcpy for portability");
@@ -816,7 +1128,9 @@ _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
816# if !@HAVE_WCSNCPY@ 1128# if !@HAVE_WCSNCPY@
817_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, 1129_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
818 (wchar_t *restrict dest, 1130 (wchar_t *restrict dest,
819 const wchar_t *restrict src, size_t n)); 1131 const wchar_t *restrict src, size_t n),
1132 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1133 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
820# endif 1134# endif
821_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, 1135_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
822 (wchar_t *restrict dest, 1136 (wchar_t *restrict dest,
@@ -825,7 +1139,6 @@ _GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
825_GL_CXXALIASWARN (wcsncpy); 1139_GL_CXXALIASWARN (wcsncpy);
826# endif 1140# endif
827#elif defined GNULIB_POSIXCHECK 1141#elif defined GNULIB_POSIXCHECK
828# undef wcsncpy
829# if HAVE_RAW_DECL_WCSNCPY 1142# if HAVE_RAW_DECL_WCSNCPY
830_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - " 1143_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
831 "use gnulib module wcsncpy for portability"); 1144 "use gnulib module wcsncpy for portability");
@@ -842,14 +1155,13 @@ _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
842# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus) 1155# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
843_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, 1156_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
844 (wchar_t *restrict dest, 1157 (wchar_t *restrict dest,
845 const wchar_t *restrict src, size_t n)); 1158 const wchar_t *restrict src, size_t n), );
846# endif 1159# endif
847_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, 1160_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
848 (wchar_t *restrict dest, 1161 (wchar_t *restrict dest,
849 const wchar_t *restrict src, size_t n)); 1162 const wchar_t *restrict src, size_t n));
850_GL_CXXALIASWARN (wcpncpy); 1163_GL_CXXALIASWARN (wcpncpy);
851#elif defined GNULIB_POSIXCHECK 1164#elif defined GNULIB_POSIXCHECK
852# undef wcpncpy
853# if HAVE_RAW_DECL_WCPNCPY 1165# if HAVE_RAW_DECL_WCPNCPY
854_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - " 1166_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
855 "use gnulib module wcpncpy for portability"); 1167 "use gnulib module wcpncpy for portability");
@@ -861,7 +1173,7 @@ _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
861#if @GNULIB_WCSCAT@ 1173#if @GNULIB_WCSCAT@
862# if !@HAVE_WCSCAT@ 1174# if !@HAVE_WCSCAT@
863_GL_FUNCDECL_SYS (wcscat, wchar_t *, 1175_GL_FUNCDECL_SYS (wcscat, wchar_t *,
864 (wchar_t *restrict dest, const wchar_t *restrict src)); 1176 (wchar_t *restrict dest, const wchar_t *restrict src), );
865# endif 1177# endif
866_GL_CXXALIAS_SYS (wcscat, wchar_t *, 1178_GL_CXXALIAS_SYS (wcscat, wchar_t *,
867 (wchar_t *restrict dest, const wchar_t *restrict src)); 1179 (wchar_t *restrict dest, const wchar_t *restrict src));
@@ -869,7 +1181,6 @@ _GL_CXXALIAS_SYS (wcscat, wchar_t *,
869_GL_CXXALIASWARN (wcscat); 1181_GL_CXXALIASWARN (wcscat);
870# endif 1182# endif
871#elif defined GNULIB_POSIXCHECK 1183#elif defined GNULIB_POSIXCHECK
872# undef wcscat
873# if HAVE_RAW_DECL_WCSCAT 1184# if HAVE_RAW_DECL_WCSCAT
874_GL_WARN_ON_USE (wcscat, "wcscat is unportable - " 1185_GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
875 "use gnulib module wcscat for portability"); 1186 "use gnulib module wcscat for portability");
@@ -879,19 +1190,35 @@ _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
879 1190
880/* Append no more than N wide characters of SRC onto DEST. */ 1191/* Append no more than N wide characters of SRC onto DEST. */
881#if @GNULIB_WCSNCAT@ 1192#if @GNULIB_WCSNCAT@
882# if !@HAVE_WCSNCAT@ 1193# if @REPLACE_WCSNCAT@
883_GL_FUNCDECL_SYS (wcsncat, wchar_t *, 1194# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1195# undef wcsncat
1196# define wcsncat rpl_wcsncat
1197# endif
1198_GL_FUNCDECL_RPL (wcsncat, wchar_t *,
1199 (wchar_t *restrict dest, const wchar_t *restrict src,
1200 size_t n),
1201 _GL_ARG_NONNULL ((1))
1202 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1203_GL_CXXALIAS_RPL (wcsncat, wchar_t *,
884 (wchar_t *restrict dest, const wchar_t *restrict src, 1204 (wchar_t *restrict dest, const wchar_t *restrict src,
885 size_t n)); 1205 size_t n));
886# endif 1206# else
1207# if !@HAVE_WCSNCAT@
1208_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
1209 (wchar_t *restrict dest, const wchar_t *restrict src,
1210 size_t n),
1211 _GL_ARG_NONNULL ((1))
1212 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1213# endif
887_GL_CXXALIAS_SYS (wcsncat, wchar_t *, 1214_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
888 (wchar_t *restrict dest, const wchar_t *restrict src, 1215 (wchar_t *restrict dest, const wchar_t *restrict src,
889 size_t n)); 1216 size_t n));
1217# endif
890# if __GLIBC__ >= 2 1218# if __GLIBC__ >= 2
891_GL_CXXALIASWARN (wcsncat); 1219_GL_CXXALIASWARN (wcsncat);
892# endif 1220# endif
893#elif defined GNULIB_POSIXCHECK 1221#elif defined GNULIB_POSIXCHECK
894# undef wcsncat
895# if HAVE_RAW_DECL_WCSNCAT 1222# if HAVE_RAW_DECL_WCSNCAT
896_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " 1223_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
897 "use gnulib module wcsncat for portability"); 1224 "use gnulib module wcsncat for portability");
@@ -901,16 +1228,25 @@ _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
901 1228
902/* Compare S1 and S2. */ 1229/* Compare S1 and S2. */
903#if @GNULIB_WCSCMP@ 1230#if @GNULIB_WCSCMP@
904# if !@HAVE_WCSCMP@ 1231# if @REPLACE_WCSCMP@
905_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) 1232# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1233# undef wcscmp
1234# define wcscmp rpl_wcscmp
1235# endif
1236_GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
906 _GL_ATTRIBUTE_PURE); 1237 _GL_ATTRIBUTE_PURE);
907# endif 1238_GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1239# else
1240# if !@HAVE_WCSCMP@
1241_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2),
1242 _GL_ATTRIBUTE_PURE);
1243# endif
908_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); 1244_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
1245# endif
909# if __GLIBC__ >= 2 1246# if __GLIBC__ >= 2
910_GL_CXXALIASWARN (wcscmp); 1247_GL_CXXALIASWARN (wcscmp);
911# endif 1248# endif
912#elif defined GNULIB_POSIXCHECK 1249#elif defined GNULIB_POSIXCHECK
913# undef wcscmp
914# if HAVE_RAW_DECL_WCSCMP 1250# if HAVE_RAW_DECL_WCSCMP
915_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " 1251_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
916 "use gnulib module wcscmp for portability"); 1252 "use gnulib module wcscmp for portability");
@@ -920,18 +1256,33 @@ _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
920 1256
921/* Compare no more than N wide characters of S1 and S2. */ 1257/* Compare no more than N wide characters of S1 and S2. */
922#if @GNULIB_WCSNCMP@ 1258#if @GNULIB_WCSNCMP@
923# if !@HAVE_WCSNCMP@ 1259# if @REPLACE_WCSNCMP@
1260# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1261# undef wcsncmp
1262# define wcsncmp rpl_wcsncmp
1263# endif
1264_GL_FUNCDECL_RPL (wcsncmp, int,
1265 (const wchar_t *s1, const wchar_t *s2, size_t n),
1266 _GL_ATTRIBUTE_PURE
1267 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1268 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1269_GL_CXXALIAS_RPL (wcsncmp, int,
1270 (const wchar_t *s1, const wchar_t *s2, size_t n));
1271# else
1272# if !@HAVE_WCSNCMP@
924_GL_FUNCDECL_SYS (wcsncmp, int, 1273_GL_FUNCDECL_SYS (wcsncmp, int,
925 (const wchar_t *s1, const wchar_t *s2, size_t n) 1274 (const wchar_t *s1, const wchar_t *s2, size_t n),
926 _GL_ATTRIBUTE_PURE); 1275 _GL_ATTRIBUTE_PURE
927# endif 1276 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
1277 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
1278# endif
928_GL_CXXALIAS_SYS (wcsncmp, int, 1279_GL_CXXALIAS_SYS (wcsncmp, int,
929 (const wchar_t *s1, const wchar_t *s2, size_t n)); 1280 (const wchar_t *s1, const wchar_t *s2, size_t n));
1281# endif
930# if __GLIBC__ >= 2 1282# if __GLIBC__ >= 2
931_GL_CXXALIASWARN (wcsncmp); 1283_GL_CXXALIASWARN (wcsncmp);
932# endif 1284# endif
933#elif defined GNULIB_POSIXCHECK 1285#elif defined GNULIB_POSIXCHECK
934# undef wcsncmp
935# if HAVE_RAW_DECL_WCSNCMP 1286# if HAVE_RAW_DECL_WCSNCMP
936_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - " 1287_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
937 "use gnulib module wcsncmp for portability"); 1288 "use gnulib module wcsncmp for portability");
@@ -945,13 +1296,12 @@ _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
945 namespace, not in the global namespace. So, force a declaration in 1296 namespace, not in the global namespace. So, force a declaration in
946 the global namespace. */ 1297 the global namespace. */
947# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus) 1298# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
948_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) 1299_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2),
949 _GL_ATTRIBUTE_PURE); 1300 _GL_ATTRIBUTE_PURE);
950# endif 1301# endif
951_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)); 1302_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
952_GL_CXXALIASWARN (wcscasecmp); 1303_GL_CXXALIASWARN (wcscasecmp);
953#elif defined GNULIB_POSIXCHECK 1304#elif defined GNULIB_POSIXCHECK
954# undef wcscasecmp
955# if HAVE_RAW_DECL_WCSCASECMP 1305# if HAVE_RAW_DECL_WCSCASECMP
956_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - " 1306_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
957 "use gnulib module wcscasecmp for portability"); 1307 "use gnulib module wcscasecmp for portability");
@@ -966,14 +1316,13 @@ _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
966 the global namespace. */ 1316 the global namespace. */
967# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus) 1317# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
968_GL_FUNCDECL_SYS (wcsncasecmp, int, 1318_GL_FUNCDECL_SYS (wcsncasecmp, int,
969 (const wchar_t *s1, const wchar_t *s2, size_t n) 1319 (const wchar_t *s1, const wchar_t *s2, size_t n),
970 _GL_ATTRIBUTE_PURE); 1320 _GL_ATTRIBUTE_PURE);
971# endif 1321# endif
972_GL_CXXALIAS_SYS (wcsncasecmp, int, 1322_GL_CXXALIAS_SYS (wcsncasecmp, int,
973 (const wchar_t *s1, const wchar_t *s2, size_t n)); 1323 (const wchar_t *s1, const wchar_t *s2, size_t n));
974_GL_CXXALIASWARN (wcsncasecmp); 1324_GL_CXXALIASWARN (wcsncasecmp);
975#elif defined GNULIB_POSIXCHECK 1325#elif defined GNULIB_POSIXCHECK
976# undef wcsncasecmp
977# if HAVE_RAW_DECL_WCSNCASECMP 1326# if HAVE_RAW_DECL_WCSNCASECMP
978_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - " 1327_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
979 "use gnulib module wcsncasecmp for portability"); 1328 "use gnulib module wcsncasecmp for portability");
@@ -985,14 +1334,13 @@ _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
985 category of the current locale. */ 1334 category of the current locale. */
986#if @GNULIB_WCSCOLL@ 1335#if @GNULIB_WCSCOLL@
987# if !@HAVE_WCSCOLL@ 1336# if !@HAVE_WCSCOLL@
988_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 1337_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2), );
989# endif 1338# endif
990_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 1339_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
991# if __GLIBC__ >= 2 1340# if __GLIBC__ >= 2
992_GL_CXXALIASWARN (wcscoll); 1341_GL_CXXALIASWARN (wcscoll);
993# endif 1342# endif
994#elif defined GNULIB_POSIXCHECK 1343#elif defined GNULIB_POSIXCHECK
995# undef wcscoll
996# if HAVE_RAW_DECL_WCSCOLL 1344# if HAVE_RAW_DECL_WCSCOLL
997_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - " 1345_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
998 "use gnulib module wcscoll for portability"); 1346 "use gnulib module wcscoll for portability");
@@ -1006,7 +1354,7 @@ _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
1006#if @GNULIB_WCSXFRM@ 1354#if @GNULIB_WCSXFRM@
1007# if !@HAVE_WCSXFRM@ 1355# if !@HAVE_WCSXFRM@
1008_GL_FUNCDECL_SYS (wcsxfrm, size_t, 1356_GL_FUNCDECL_SYS (wcsxfrm, size_t,
1009 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n)); 1357 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n), );
1010# endif 1358# endif
1011_GL_CXXALIAS_SYS (wcsxfrm, size_t, 1359_GL_CXXALIAS_SYS (wcsxfrm, size_t,
1012 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n)); 1360 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
@@ -1014,7 +1362,6 @@ _GL_CXXALIAS_SYS (wcsxfrm, size_t,
1014_GL_CXXALIASWARN (wcsxfrm); 1362_GL_CXXALIASWARN (wcsxfrm);
1015# endif 1363# endif
1016#elif defined GNULIB_POSIXCHECK 1364#elif defined GNULIB_POSIXCHECK
1017# undef wcsxfrm
1018# if HAVE_RAW_DECL_WCSXFRM 1365# if HAVE_RAW_DECL_WCSXFRM
1019_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - " 1366_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
1020 "use gnulib module wcsxfrm for portability"); 1367 "use gnulib module wcsxfrm for portability");
@@ -1034,23 +1381,37 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1034/* On Solaris 11.3, the header files declare the function in the std:: 1381/* On Solaris 11.3, the header files declare the function in the std::
1035 namespace, not in the global namespace. So, force a declaration in 1382 namespace, not in the global namespace. So, force a declaration in
1036 the global namespace. */ 1383 the global namespace. */
1037# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 1384# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) \
1385 || (__GNUC__ >= 11 && !defined __clang__)
1386# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1387_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1388 (const wchar_t *s),
1389 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1390 _GL_ATTRIBUTE_NOTHROW;
1391# else
1038_GL_FUNCDECL_SYS (wcsdup, wchar_t *, 1392_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1039 (const wchar_t *s) 1393 (const wchar_t *s),
1040 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1394 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1395# endif
1041# endif 1396# endif
1042_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1397_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1043# endif 1398# endif
1044_GL_CXXALIASWARN (wcsdup); 1399_GL_CXXALIASWARN (wcsdup);
1045#else 1400#else
1046# if __GNUC__ >= 11 && !defined wcsdup 1401# if (__GNUC__ >= 11 && !defined __clang__) && !defined wcsdup
1047/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ 1402/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1403# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1048_GL_FUNCDECL_SYS (wcsdup, wchar_t *, 1404_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1049 (const wchar_t *s) 1405 (const wchar_t *s),
1406 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1407 _GL_ATTRIBUTE_NOTHROW;
1408# else
1409_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1410 (const wchar_t *s),
1050 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1411 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1412# endif
1051# endif 1413# endif
1052# if defined GNULIB_POSIXCHECK 1414# if defined GNULIB_POSIXCHECK
1053# undef wcsdup
1054# if HAVE_RAW_DECL_WCSDUP 1415# if HAVE_RAW_DECL_WCSDUP
1055_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " 1416_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
1056 "use gnulib module wcsdup for portability"); 1417 "use gnulib module wcsdup for portability");
@@ -1066,9 +1427,16 @@ _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
1066# endif 1427# endif
1067_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); 1428_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1068# else 1429# else
1430# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
1431_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1432 (const wchar_t *s),
1433 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
1434 _GL_ATTRIBUTE_NOTHROW;
1435# else
1069_GL_FUNCDECL_SYS (wcsdup, wchar_t *, 1436_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1070 (const wchar_t *s) 1437 (const wchar_t *s),
1071 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1438 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1439# endif
1072# if @HAVE_DECL_WCSDUP@ 1440# if @HAVE_DECL_WCSDUP@
1073_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1441_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1074# endif 1442# endif
@@ -1083,7 +1451,7 @@ _GL_CXXALIASWARN (wcsdup);
1083/* Find the first occurrence of WC in WCS. */ 1451/* Find the first occurrence of WC in WCS. */
1084#if @GNULIB_WCSCHR@ 1452#if @GNULIB_WCSCHR@
1085# if !@HAVE_WCSCHR@ 1453# if !@HAVE_WCSCHR@
1086_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc) 1454_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1087 _GL_ATTRIBUTE_PURE); 1455 _GL_ATTRIBUTE_PURE);
1088# endif 1456# endif
1089 /* On some systems, this function is defined as an overloaded function: 1457 /* On some systems, this function is defined as an overloaded function:
@@ -1095,14 +1463,14 @@ _GL_CXXALIAS_SYS_CAST2 (wcschr,
1095 wchar_t *, (const wchar_t *, wchar_t), 1463 wchar_t *, (const wchar_t *, wchar_t),
1096 const wchar_t *, (const wchar_t *, wchar_t)); 1464 const wchar_t *, (const wchar_t *, wchar_t));
1097# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1465# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1098 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1466 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1467 && !defined __clang__
1099_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1468_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1100_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1469_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1101# elif __GLIBC__ >= 2 1470# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1102_GL_CXXALIASWARN (wcschr); 1471_GL_CXXALIASWARN (wcschr);
1103# endif 1472# endif
1104#elif defined GNULIB_POSIXCHECK 1473#elif defined GNULIB_POSIXCHECK
1105# undef wcschr
1106# if HAVE_RAW_DECL_WCSCHR 1474# if HAVE_RAW_DECL_WCSCHR
1107_GL_WARN_ON_USE (wcschr, "wcschr is unportable - " 1475_GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
1108 "use gnulib module wcschr for portability"); 1476 "use gnulib module wcschr for portability");
@@ -1113,7 +1481,7 @@ _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
1113/* Find the last occurrence of WC in WCS. */ 1481/* Find the last occurrence of WC in WCS. */
1114#if @GNULIB_WCSRCHR@ 1482#if @GNULIB_WCSRCHR@
1115# if !@HAVE_WCSRCHR@ 1483# if !@HAVE_WCSRCHR@
1116_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc) 1484_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc),
1117 _GL_ATTRIBUTE_PURE); 1485 _GL_ATTRIBUTE_PURE);
1118# endif 1486# endif
1119 /* On some systems, this function is defined as an overloaded function: 1487 /* On some systems, this function is defined as an overloaded function:
@@ -1125,14 +1493,14 @@ _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
1125 wchar_t *, (const wchar_t *, wchar_t), 1493 wchar_t *, (const wchar_t *, wchar_t),
1126 const wchar_t *, (const wchar_t *, wchar_t)); 1494 const wchar_t *, (const wchar_t *, wchar_t));
1127# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1495# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1128 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1496 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1497 && !defined __clang__
1129_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1498_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
1130_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1499_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
1131# elif __GLIBC__ >= 2 1500# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1132_GL_CXXALIASWARN (wcsrchr); 1501_GL_CXXALIASWARN (wcsrchr);
1133# endif 1502# endif
1134#elif defined GNULIB_POSIXCHECK 1503#elif defined GNULIB_POSIXCHECK
1135# undef wcsrchr
1136# if HAVE_RAW_DECL_WCSRCHR 1504# if HAVE_RAW_DECL_WCSRCHR
1137_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " 1505_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
1138 "use gnulib module wcsrchr for portability"); 1506 "use gnulib module wcsrchr for portability");
@@ -1140,11 +1508,11 @@ _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
1140#endif 1508#endif
1141 1509
1142 1510
1143/* Return the length of the initial segmet of WCS which consists entirely 1511/* Return the length of the initial segment of WCS which consists entirely
1144 of wide characters not in REJECT. */ 1512 of wide characters not in REJECT. */
1145#if @GNULIB_WCSCSPN@ 1513#if @GNULIB_WCSCSPN@
1146# if !@HAVE_WCSCSPN@ 1514# if !@HAVE_WCSCSPN@
1147_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject) 1515_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject),
1148 _GL_ATTRIBUTE_PURE); 1516 _GL_ATTRIBUTE_PURE);
1149# endif 1517# endif
1150_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); 1518_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
@@ -1152,7 +1520,6 @@ _GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
1152_GL_CXXALIASWARN (wcscspn); 1520_GL_CXXALIASWARN (wcscspn);
1153# endif 1521# endif
1154#elif defined GNULIB_POSIXCHECK 1522#elif defined GNULIB_POSIXCHECK
1155# undef wcscspn
1156# if HAVE_RAW_DECL_WCSCSPN 1523# if HAVE_RAW_DECL_WCSCSPN
1157_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " 1524_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
1158 "use gnulib module wcscspn for portability"); 1525 "use gnulib module wcscspn for portability");
@@ -1160,11 +1527,11 @@ _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
1160#endif 1527#endif
1161 1528
1162 1529
1163/* Return the length of the initial segmet of WCS which consists entirely 1530/* Return the length of the initial segment of WCS which consists entirely
1164 of wide characters in ACCEPT. */ 1531 of wide characters in ACCEPT. */
1165#if @GNULIB_WCSSPN@ 1532#if @GNULIB_WCSSPN@
1166# if !@HAVE_WCSSPN@ 1533# if !@HAVE_WCSSPN@
1167_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept) 1534_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept),
1168 _GL_ATTRIBUTE_PURE); 1535 _GL_ATTRIBUTE_PURE);
1169# endif 1536# endif
1170_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); 1537_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
@@ -1172,7 +1539,6 @@ _GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
1172_GL_CXXALIASWARN (wcsspn); 1539_GL_CXXALIASWARN (wcsspn);
1173# endif 1540# endif
1174#elif defined GNULIB_POSIXCHECK 1541#elif defined GNULIB_POSIXCHECK
1175# undef wcsspn
1176# if HAVE_RAW_DECL_WCSSPN 1542# if HAVE_RAW_DECL_WCSSPN
1177_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - " 1543_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
1178 "use gnulib module wcsspn for portability"); 1544 "use gnulib module wcsspn for portability");
@@ -1184,7 +1550,7 @@ _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
1184#if @GNULIB_WCSPBRK@ 1550#if @GNULIB_WCSPBRK@
1185# if !@HAVE_WCSPBRK@ 1551# if !@HAVE_WCSPBRK@
1186_GL_FUNCDECL_SYS (wcspbrk, wchar_t *, 1552_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
1187 (const wchar_t *wcs, const wchar_t *accept) 1553 (const wchar_t *wcs, const wchar_t *accept),
1188 _GL_ATTRIBUTE_PURE); 1554 _GL_ATTRIBUTE_PURE);
1189# endif 1555# endif
1190 /* On some systems, this function is defined as an overloaded function: 1556 /* On some systems, this function is defined as an overloaded function:
@@ -1196,16 +1562,16 @@ _GL_CXXALIAS_SYS_CAST2 (wcspbrk,
1196 wchar_t *, (const wchar_t *, const wchar_t *), 1562 wchar_t *, (const wchar_t *, const wchar_t *),
1197 const wchar_t *, (const wchar_t *, const wchar_t *)); 1563 const wchar_t *, (const wchar_t *, const wchar_t *));
1198# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1564# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1199 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1565 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1566 && !defined __clang__
1200_GL_CXXALIASWARN1 (wcspbrk, wchar_t *, 1567_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
1201 (wchar_t *wcs, const wchar_t *accept)); 1568 (wchar_t *wcs, const wchar_t *accept));
1202_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, 1569_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
1203 (const wchar_t *wcs, const wchar_t *accept)); 1570 (const wchar_t *wcs, const wchar_t *accept));
1204# elif __GLIBC__ >= 2 1571# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1205_GL_CXXALIASWARN (wcspbrk); 1572_GL_CXXALIASWARN (wcspbrk);
1206# endif 1573# endif
1207#elif defined GNULIB_POSIXCHECK 1574#elif defined GNULIB_POSIXCHECK
1208# undef wcspbrk
1209# if HAVE_RAW_DECL_WCSPBRK 1575# if HAVE_RAW_DECL_WCSPBRK
1210_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " 1576_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
1211 "use gnulib module wcspbrk for portability"); 1577 "use gnulib module wcspbrk for portability");
@@ -1215,12 +1581,25 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
1215 1581
1216/* Find the first occurrence of NEEDLE in HAYSTACK. */ 1582/* Find the first occurrence of NEEDLE in HAYSTACK. */
1217#if @GNULIB_WCSSTR@ 1583#if @GNULIB_WCSSTR@
1218# if !@HAVE_WCSSTR@ 1584# if @REPLACE_WCSSTR@
1585# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1586# undef wcsstr
1587# define wcsstr rpl_wcsstr
1588# endif
1589_GL_FUNCDECL_RPL (wcsstr, wchar_t *,
1590 (const wchar_t *restrict haystack,
1591 const wchar_t *restrict needle),
1592 _GL_ATTRIBUTE_PURE);
1593_GL_CXXALIAS_RPL (wcsstr, wchar_t *,
1594 (const wchar_t *restrict haystack,
1595 const wchar_t *restrict needle));
1596# else
1597# if !@HAVE_WCSSTR@
1219_GL_FUNCDECL_SYS (wcsstr, wchar_t *, 1598_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
1220 (const wchar_t *restrict haystack, 1599 (const wchar_t *restrict haystack,
1221 const wchar_t *restrict needle) 1600 const wchar_t *restrict needle),
1222 _GL_ATTRIBUTE_PURE); 1601 _GL_ATTRIBUTE_PURE);
1223# endif 1602# endif
1224 /* On some systems, this function is defined as an overloaded function: 1603 /* On some systems, this function is defined as an overloaded function:
1225 extern "C++" { 1604 extern "C++" {
1226 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); 1605 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
@@ -1231,19 +1610,20 @@ _GL_CXXALIAS_SYS_CAST2 (wcsstr,
1231 (const wchar_t *restrict, const wchar_t *restrict), 1610 (const wchar_t *restrict, const wchar_t *restrict),
1232 const wchar_t *, 1611 const wchar_t *,
1233 (const wchar_t *restrict, const wchar_t *restrict)); 1612 (const wchar_t *restrict, const wchar_t *restrict));
1613# endif
1234# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1614# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
1235 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1615 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) \
1616 && !defined __clang__
1236_GL_CXXALIASWARN1 (wcsstr, wchar_t *, 1617_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
1237 (wchar_t *restrict haystack, 1618 (wchar_t *restrict haystack,
1238 const wchar_t *restrict needle)); 1619 const wchar_t *restrict needle));
1239_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, 1620_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
1240 (const wchar_t *restrict haystack, 1621 (const wchar_t *restrict haystack,
1241 const wchar_t *restrict needle)); 1622 const wchar_t *restrict needle));
1242# elif __GLIBC__ >= 2 1623# elif __GLIBC__ >= 2 && !defined __CORRECT_ISO_CPP_WCHAR_H_PROTO
1243_GL_CXXALIASWARN (wcsstr); 1624_GL_CXXALIASWARN (wcsstr);
1244# endif 1625# endif
1245#elif defined GNULIB_POSIXCHECK 1626#elif defined GNULIB_POSIXCHECK
1246# undef wcsstr
1247# if HAVE_RAW_DECL_WCSSTR 1627# if HAVE_RAW_DECL_WCSSTR
1248_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - " 1628_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
1249 "use gnulib module wcsstr for portability"); 1629 "use gnulib module wcsstr for portability");
@@ -1260,7 +1640,7 @@ _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
1260# endif 1640# endif
1261_GL_FUNCDECL_RPL (wcstok, wchar_t *, 1641_GL_FUNCDECL_RPL (wcstok, wchar_t *,
1262 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1642 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1263 wchar_t **restrict ptr)); 1643 wchar_t **restrict ptr), );
1264_GL_CXXALIAS_RPL (wcstok, wchar_t *, 1644_GL_CXXALIAS_RPL (wcstok, wchar_t *,
1265 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1645 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1266 wchar_t **restrict ptr)); 1646 wchar_t **restrict ptr));
@@ -1268,7 +1648,7 @@ _GL_CXXALIAS_RPL (wcstok, wchar_t *,
1268# if !@HAVE_WCSTOK@ 1648# if !@HAVE_WCSTOK@
1269_GL_FUNCDECL_SYS (wcstok, wchar_t *, 1649_GL_FUNCDECL_SYS (wcstok, wchar_t *,
1270 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1650 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1271 wchar_t **restrict ptr)); 1651 wchar_t **restrict ptr), );
1272# endif 1652# endif
1273_GL_CXXALIAS_SYS (wcstok, wchar_t *, 1653_GL_CXXALIAS_SYS (wcstok, wchar_t *,
1274 (wchar_t *restrict wcs, const wchar_t *restrict delim, 1654 (wchar_t *restrict wcs, const wchar_t *restrict delim,
@@ -1278,7 +1658,6 @@ _GL_CXXALIAS_SYS (wcstok, wchar_t *,
1278_GL_CXXALIASWARN (wcstok); 1658_GL_CXXALIASWARN (wcstok);
1279# endif 1659# endif
1280#elif defined GNULIB_POSIXCHECK 1660#elif defined GNULIB_POSIXCHECK
1281# undef wcstok
1282# if HAVE_RAW_DECL_WCSTOK 1661# if HAVE_RAW_DECL_WCSTOK
1283_GL_WARN_ON_USE (wcstok, "wcstok is unportable - " 1662_GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1284 "use gnulib module wcstok for portability"); 1663 "use gnulib module wcstok for portability");
@@ -1294,12 +1673,12 @@ _GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
1294# undef wcswidth 1673# undef wcswidth
1295# define wcswidth rpl_wcswidth 1674# define wcswidth rpl_wcswidth
1296# endif 1675# endif
1297_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n) 1676_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n),
1298 _GL_ATTRIBUTE_PURE); 1677 _GL_ATTRIBUTE_PURE);
1299_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n)); 1678_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1300# else 1679# else
1301# if !@HAVE_WCSWIDTH@ 1680# if !@HAVE_WCSWIDTH@
1302_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n) 1681_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n),
1303 _GL_ATTRIBUTE_PURE); 1682 _GL_ATTRIBUTE_PURE);
1304# endif 1683# endif
1305_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); 1684_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
@@ -1308,7 +1687,6 @@ _GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1308_GL_CXXALIASWARN (wcswidth); 1687_GL_CXXALIASWARN (wcswidth);
1309# endif 1688# endif
1310#elif defined GNULIB_POSIXCHECK 1689#elif defined GNULIB_POSIXCHECK
1311# undef wcswidth
1312# if HAVE_RAW_DECL_WCSWIDTH 1690# if HAVE_RAW_DECL_WCSWIDTH
1313_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - " 1691_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1314 "use gnulib module wcswidth for portability"); 1692 "use gnulib module wcswidth for portability");
@@ -1327,7 +1705,7 @@ _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1327_GL_FUNCDECL_RPL (wcsftime, size_t, 1705_GL_FUNCDECL_RPL (wcsftime, size_t,
1328 (wchar_t *restrict __buf, size_t __bufsize, 1706 (wchar_t *restrict __buf, size_t __bufsize,
1329 const wchar_t *restrict __fmt, 1707 const wchar_t *restrict __fmt,
1330 const struct tm *restrict __tp) 1708 const struct tm *restrict __tp),
1331 _GL_ARG_NONNULL ((1, 3, 4))); 1709 _GL_ARG_NONNULL ((1, 3, 4)));
1332_GL_CXXALIAS_RPL (wcsftime, size_t, 1710_GL_CXXALIAS_RPL (wcsftime, size_t,
1333 (wchar_t *restrict __buf, size_t __bufsize, 1711 (wchar_t *restrict __buf, size_t __bufsize,
@@ -1338,7 +1716,7 @@ _GL_CXXALIAS_RPL (wcsftime, size_t,
1338_GL_FUNCDECL_SYS (wcsftime, size_t, 1716_GL_FUNCDECL_SYS (wcsftime, size_t,
1339 (wchar_t *restrict __buf, size_t __bufsize, 1717 (wchar_t *restrict __buf, size_t __bufsize,
1340 const wchar_t *restrict __fmt, 1718 const wchar_t *restrict __fmt,
1341 const struct tm *restrict __tp) 1719 const struct tm *restrict __tp),
1342 _GL_ARG_NONNULL ((1, 3, 4))); 1720 _GL_ARG_NONNULL ((1, 3, 4)));
1343# endif 1721# endif
1344_GL_CXXALIAS_SYS (wcsftime, size_t, 1722_GL_CXXALIAS_SYS (wcsftime, size_t,
@@ -1350,7 +1728,6 @@ _GL_CXXALIAS_SYS (wcsftime, size_t,
1350_GL_CXXALIASWARN (wcsftime); 1728_GL_CXXALIASWARN (wcsftime);
1351# endif 1729# endif
1352#elif defined GNULIB_POSIXCHECK 1730#elif defined GNULIB_POSIXCHECK
1353# undef wcsftime
1354# if HAVE_RAW_DECL_WCSFTIME 1731# if HAVE_RAW_DECL_WCSFTIME
1355_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - " 1732_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1356 "use gnulib module wcsftime for portability"); 1733 "use gnulib module wcsftime for portability");
@@ -1358,6 +1735,24 @@ _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1358#endif 1735#endif
1359 1736
1360 1737
1738#if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__)
1739/* Gets the name of the current working directory.
1740 (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters.
1741 This function stores the working directory (NUL-terminated) in BUF and
1742 returns BUF.
1743 (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE
1744 wide characters long, unless SIZE == 0, in which case it is as big as
1745 necessary.
1746 If the directory couldn't be determined or SIZE was too small, this function
1747 returns NULL and sets errno. For a directory of length LEN, SIZE should be
1748 >= LEN + 3 in case (a) or >= LEN + 1 in case (b).
1749 Possible errno values include:
1750 - ERANGE if SIZE is too small.
1751 - ENOMEM if the memory could no be allocated. */
1752_GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size), );
1753#endif
1754
1755
1361#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1756#endif /* _@GUARD_PREFIX@_WCHAR_H */
1362#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1757#endif /* _@GUARD_PREFIX@_WCHAR_H */
1363#endif 1758#endif
diff --git a/gl/wcrtomb.c b/gl/wcrtomb.c
index 48a6c8eb..a9b8de78 100644
--- a/gl/wcrtomb.c
+++ b/gl/wcrtomb.c
@@ -1,5 +1,5 @@
1/* Convert wide character to multibyte character. 1/* Convert wide character to multibyte character.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc. 2 Copyright (C) 2008-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
@@ -29,14 +29,14 @@ wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
29#undef wcrtomb 29#undef wcrtomb
30{ 30{
31 /* This implementation of wcrtomb supports only stateless encodings. 31 /* This implementation of wcrtomb supports only stateless encodings.
32 ps must be in the initial state. */ 32 ps must be in an initial state. */
33 if (ps != NULL && !mbsinit (ps)) 33 if (ps != NULL && !mbsinit (ps))
34 { 34 {
35 errno = EINVAL; 35 errno = EINVAL;
36 return (size_t)(-1); 36 return (size_t)(-1);
37 } 37 }
38 38
39#if !HAVE_WCRTOMB /* IRIX 6.5 */ \ 39#if !HAVE_WCRTOMB /* HP-UX 11.00, mingw */ \
40 || WCRTOMB_RETVAL_BUG /* Solaris 11.3, MSVC */ \ 40 || WCRTOMB_RETVAL_BUG /* Solaris 11.3, MSVC */ \
41 || WCRTOMB_C_LOCALE_BUG /* Android */ 41 || WCRTOMB_C_LOCALE_BUG /* Android */
42 if (s == NULL) 42 if (s == NULL)
@@ -62,7 +62,7 @@ wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
62# else 62# else
63 return wcrtomb (s, wc, ps); 63 return wcrtomb (s, wc, ps);
64# endif 64# endif
65#else /* IRIX 6.5 */ 65#else /* HP-UX 11.00, mingw */
66 /* Fallback for platforms that don't have wcrtomb(). 66 /* Fallback for platforms that don't have wcrtomb().
67 Implement on top of wctomb(). 67 Implement on top of wctomb().
68 This code is not multithread-safe. */ 68 This code is not multithread-safe. */
diff --git a/gl/wctype-h.c b/gl/wctype-h.c
index 7d3e14a6..f773d0cb 100644
--- a/gl/wctype-h.c
+++ b/gl/wctype-h.c
@@ -1,6 +1,6 @@
1/* Inline functions for <wctype.h>. 1/* Inline functions for <wctype.h>.
2 2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc. 3 Copyright (C) 2012-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -17,7 +17,7 @@
17 17
18/* Normally this would be wctype.c, but that name's already taken. */ 18/* Normally this would be wctype.c, but that name's already taken. */
19 19
20#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE
20#include <config.h> 21#include <config.h>
21 22
22#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE 23#include <wctype.h>
23#include "wctype.h"
diff --git a/gl/wctype-impl.h b/gl/wctype-impl.h
new file mode 100644
index 00000000..675ea31c
--- /dev/null
+++ b/gl/wctype-impl.h
@@ -0,0 +1,96 @@
1/* Get descriptor for a wide character property.
2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18wctype_t
19wctype (const char* name)
20{
21 switch (name[0])
22 {
23 case 'a':
24 switch (name[1])
25 {
26 case 'l':
27 switch (name[2])
28 {
29 case 'n':
30 if (streq (name + 3, "um"))
31 return (wctype_t) iswalnum;
32 break;
33 case 'p':
34 if (streq (name + 3, "ha"))
35 return (wctype_t) iswalpha;
36 break;
37 default:
38 break;
39 }
40 break;
41 default:
42 break;
43 }
44 break;
45 case 'b':
46 if (streq (name + 1, "lank"))
47 return (wctype_t) iswblank;
48 break;
49 case 'c':
50 if (streq (name + 1, "ntrl"))
51 return (wctype_t) iswcntrl;
52 break;
53 case 'd':
54 if (streq (name + 1, "igit"))
55 return (wctype_t) iswdigit;
56 break;
57 case 'g':
58 if (streq (name + 1, "raph"))
59 return (wctype_t) iswgraph;
60 break;
61 case 'l':
62 if (streq (name + 1, "ower"))
63 return (wctype_t) iswlower;
64 break;
65 case 'p':
66 switch (name[1])
67 {
68 case 'r':
69 if (streq (name + 2, "int"))
70 return (wctype_t) iswprint;
71 break;
72 case 'u':
73 if (streq (name + 2, "nct"))
74 return (wctype_t) iswpunct;
75 break;
76 default:
77 break;
78 }
79 break;
80 case 's':
81 if (streq (name + 1, "pace"))
82 return (wctype_t) iswspace;
83 break;
84 case 'u':
85 if (streq (name + 1, "pper"))
86 return (wctype_t) iswupper;
87 break;
88 case 'x':
89 if (streq (name + 1, "digit"))
90 return (wctype_t) iswxdigit;
91 break;
92 default:
93 break;
94 }
95 return NULL;
96}
diff --git a/gl/wctype.c b/gl/wctype.c
new file mode 100644
index 00000000..205b244c
--- /dev/null
+++ b/gl/wctype.c
@@ -0,0 +1,25 @@
1/* Get descriptor for a wide character property.
2 Copyright (C) 2011-2026 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <wctype.h>
22
23#include <string.h>
24
25#include "wctype-impl.h"
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index f6e474d3..15f310ce 100644
--- a/gl/wctype.in.h
+++ b/gl/wctype.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it. 1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
2 2
3 Copyright (C) 2006-2023 Free Software Foundation, Inc. 3 Copyright (C) 2006-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -44,6 +44,12 @@
44 44
45#ifndef _@GUARD_PREFIX@_WCTYPE_H 45#ifndef _@GUARD_PREFIX@_WCTYPE_H
46 46
47/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK,
48 HAVE_RAW_DECL_*. */
49#if !_GL_CONFIG_H_INCLUDED
50 #error "Please include config.h first."
51#endif
52
47#if @HAVE_WINT_T@ 53#if @HAVE_WINT_T@
48/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */ 54/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
49# include <wchar.h> 55# include <wchar.h>
@@ -68,9 +74,6 @@
68#ifndef _@GUARD_PREFIX@_WCTYPE_H 74#ifndef _@GUARD_PREFIX@_WCTYPE_H
69#define _@GUARD_PREFIX@_WCTYPE_H 75#define _@GUARD_PREFIX@_WCTYPE_H
70 76
71#ifndef _GL_INLINE_HEADER_BEGIN
72 #error "Please include config.h first."
73#endif
74_GL_INLINE_HEADER_BEGIN 77_GL_INLINE_HEADER_BEGIN
75#ifndef _GL_WCTYPE_INLINE 78#ifndef _GL_WCTYPE_INLINE
76# define _GL_WCTYPE_INLINE _GL_INLINE 79# define _GL_WCTYPE_INLINE _GL_INLINE
@@ -78,6 +81,8 @@ _GL_INLINE_HEADER_BEGIN
78 81
79/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 82/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
80 83
84/* The definition of _GL_ARG_NONNULL is copied here. */
85
81/* The definition of _GL_WARN_ON_USE is copied here. */ 86/* The definition of _GL_WARN_ON_USE is copied here. */
82 87
83/* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which 88/* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
@@ -127,7 +132,8 @@ typedef unsigned int rpl_wint_t;
127/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. 132/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
128 Linux libc5 has <wctype.h> and the functions but they are broken. 133 Linux libc5 has <wctype.h> and the functions but they are broken.
129 mingw and MSVC have <wctype.h> and the functions but they take a wchar_t 134 mingw and MSVC have <wctype.h> and the functions but they take a wchar_t
130 as argument, not an rpl_wint_t. 135 as argument, not an rpl_wint_t. Additionally, the mingw iswprint function
136 and the Android iswpunct function are broken.
131 Assume all 11 functions (all isw* except iswblank) are implemented the 137 Assume all 11 functions (all isw* except iswblank) are implemented the
132 same way, or not at all. */ 138 same way, or not at all. */
133# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ 139# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
@@ -179,7 +185,11 @@ rpl_iswlower (wint_t wc)
179_GL_WCTYPE_INLINE int 185_GL_WCTYPE_INLINE int
180rpl_iswprint (wint_t wc) 186rpl_iswprint (wint_t wc)
181{ 187{
188# ifdef __MINGW32__
189 return ((wchar_t) wc == wc ? wc == ' ' || iswgraph ((wchar_t) wc) : 0);
190# else
182 return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0); 191 return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0);
192# endif
183} 193}
184 194
185_GL_WCTYPE_INLINE int 195_GL_WCTYPE_INLINE int
@@ -254,27 +264,7 @@ rpl_towupper (wint_t wc)
254 264
255# else 265# else
256 266
257/* IRIX 5.3 has macros but no functions, its isw* macros refer to an 267/* On some old platforms the functions are broken. */
258 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
259 refer to system functions like _iswctype that are not in the
260 standard C library. Rather than try to get ancient buggy
261 implementations like this to work, just disable them. */
262# undef iswalnum
263# undef iswalpha
264# undef iswblank
265# undef iswcntrl
266# undef iswdigit
267# undef iswgraph
268# undef iswlower
269# undef iswprint
270# undef iswpunct
271# undef iswspace
272# undef iswupper
273# undef iswxdigit
274# undef towlower
275# undef towupper
276
277/* Linux libc5 has <wctype.h> and the functions but they are broken. */
278# if @REPLACE_ISWCNTRL@ 268# if @REPLACE_ISWCNTRL@
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 269# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# define iswalnum rpl_iswalnum 270# define iswalnum rpl_iswalnum
@@ -468,9 +458,9 @@ towupper
468# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 458# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
469# define iswblank rpl_iswblank 459# define iswblank rpl_iswblank
470# endif 460# endif
471_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); 461_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc), );
472# else 462# else
473_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); 463_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc), );
474# endif 464# endif
475# endif 465# endif
476 466
@@ -480,7 +470,17 @@ _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
480# undef iswdigit 470# undef iswdigit
481# define iswdigit rpl_iswdigit 471# define iswdigit rpl_iswdigit
482# endif 472# endif
483_GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc)); 473_GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc), );
474# endif
475# endif
476
477# if @GNULIB_ISWPUNCT@
478# if @REPLACE_ISWPUNCT@
479# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
480# undef iswpunct
481# define iswpunct rpl_iswpunct
482# endif
483_GL_FUNCDECL_RPL (iswpunct, int, (wint_t wc), );
484# endif 484# endif
485# endif 485# endif
486 486
@@ -490,7 +490,7 @@ _GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc));
490# undef iswxdigit 490# undef iswxdigit
491# define iswxdigit rpl_iswxdigit 491# define iswxdigit rpl_iswxdigit
492# endif 492# endif
493_GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc)); 493_GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc), );
494# endif 494# endif
495# endif 495# endif
496 496
@@ -623,19 +623,36 @@ _GL_CXXALIASWARN (iswblank);
623typedef void * wctype_t; 623typedef void * wctype_t;
624# define GNULIB_defined_wctype_t 1 624# define GNULIB_defined_wctype_t 1
625# endif 625# endif
626#elif @REPLACE_WCTYPE@
627# if !GNULIB_defined_wctype_t
628typedef void *rpl_wctype_t;
629# undef wctype_t
630# define wctype_t rpl_wctype_t
631# define GNULIB_defined_wctype_t 1
632# endif
626#endif 633#endif
627 634
628/* Get a descriptor for a wide character property. */ 635/* Get a descriptor for a wide character property. */
629#if @GNULIB_WCTYPE@ 636#if @GNULIB_WCTYPE@
630# if !@HAVE_WCTYPE_T@ 637# if @REPLACE_WCTYPE@
631_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); 638# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
632# endif 639# undef wctype
640# define wctype rpl_wctype
641# endif
642_GL_FUNCDECL_RPL (wctype, wctype_t, (const char *name),
643 _GL_ARG_NONNULL ((1)));
644_GL_CXXALIAS_RPL (wctype, wctype_t, (const char *name));
645# else
646# if !@HAVE_WCTYPE_T@
647_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name),
648 _GL_ARG_NONNULL ((1)));
649# endif
633_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); 650_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
651# endif
634# if __GLIBC__ >= 2 652# if __GLIBC__ >= 2
635_GL_CXXALIASWARN (wctype); 653_GL_CXXALIASWARN (wctype);
636# endif 654# endif
637#elif defined GNULIB_POSIXCHECK 655#elif defined GNULIB_POSIXCHECK
638# undef wctype
639# if HAVE_RAW_DECL_WCTYPE 656# if HAVE_RAW_DECL_WCTYPE
640_GL_WARN_ON_USE (wctype, "wctype is unportable - " 657_GL_WARN_ON_USE (wctype, "wctype is unportable - "
641 "use gnulib module wctype for portability"); 658 "use gnulib module wctype for portability");
@@ -646,16 +663,16 @@ _GL_WARN_ON_USE (wctype, "wctype is unportable - "
646 The argument WC must be either a wchar_t value or WEOF. 663 The argument WC must be either a wchar_t value or WEOF.
647 The argument DESC must have been returned by the wctype() function. */ 664 The argument DESC must have been returned by the wctype() function. */
648#if @GNULIB_ISWCTYPE@ 665#if @GNULIB_ISWCTYPE@
649# if @GNULIBHEADERS_OVERRIDE_WINT_T@ 666# if @GNULIBHEADERS_OVERRIDE_WINT_T@ || @REPLACE_WCTYPE@
650# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 667# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
651# undef iswctype 668# undef iswctype
652# define iswctype rpl_iswctype 669# define iswctype rpl_iswctype
653# endif 670# endif
654_GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc)); 671_GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc), );
655_GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc)); 672_GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc));
656# else 673# else
657# if !@HAVE_WCTYPE_T@ 674# if !@HAVE_WCTYPE_T@
658_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); 675_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc), );
659# endif 676# endif
660_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); 677_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
661# endif 678# endif
@@ -663,7 +680,6 @@ _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
663_GL_CXXALIASWARN (iswctype); 680_GL_CXXALIASWARN (iswctype);
664# endif 681# endif
665#elif defined GNULIB_POSIXCHECK 682#elif defined GNULIB_POSIXCHECK
666# undef iswctype
667# if HAVE_RAW_DECL_ISWCTYPE 683# if HAVE_RAW_DECL_ISWCTYPE
668_GL_WARN_ON_USE (iswctype, "iswctype is unportable - " 684_GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
669 "use gnulib module iswctype for portability"); 685 "use gnulib module iswctype for portability");
@@ -687,19 +703,36 @@ _GL_CXXALIASWARN (towupper);
687typedef void * wctrans_t; 703typedef void * wctrans_t;
688# define GNULIB_defined_wctrans_t 1 704# define GNULIB_defined_wctrans_t 1
689# endif 705# endif
706#elif @REPLACE_WCTRANS@
707# if !GNULIB_defined_wctrans_t
708typedef void *rpl_wctrans_t;
709# undef wctrans_t
710# define wctrans_t rpl_wctrans_t
711# define GNULIB_defined_wctrans_t 1
712# endif
690#endif 713#endif
691 714
692/* Get a descriptor for a wide character case conversion. */ 715/* Get a descriptor for a wide character case conversion. */
693#if @GNULIB_WCTRANS@ 716#if @GNULIB_WCTRANS@
694# if !@HAVE_WCTRANS_T@ 717# if @REPLACE_WCTRANS@
695_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); 718# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
696# endif 719# undef wctrans
720# define wctrans rpl_wctrans
721# endif
722_GL_FUNCDECL_RPL (wctrans, wctrans_t, (const char *name),
723 _GL_ARG_NONNULL ((1)));
724_GL_CXXALIAS_RPL (wctrans, wctrans_t, (const char *name));
725# else
726# if !@HAVE_WCTRANS_T@
727_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name),
728 _GL_ARG_NONNULL ((1)));
729# endif
697_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); 730_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
731# endif
698# if __GLIBC__ >= 2 732# if __GLIBC__ >= 2
699_GL_CXXALIASWARN (wctrans); 733_GL_CXXALIASWARN (wctrans);
700# endif 734# endif
701#elif defined GNULIB_POSIXCHECK 735#elif defined GNULIB_POSIXCHECK
702# undef wctrans
703# if HAVE_RAW_DECL_WCTRANS 736# if HAVE_RAW_DECL_WCTRANS
704_GL_WARN_ON_USE (wctrans, "wctrans is unportable - " 737_GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
705 "use gnulib module wctrans for portability"); 738 "use gnulib module wctrans for portability");
@@ -710,15 +743,23 @@ _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
710 The argument WC must be either a wchar_t value or WEOF. 743 The argument WC must be either a wchar_t value or WEOF.
711 The argument DESC must have been returned by the wctrans() function. */ 744 The argument DESC must have been returned by the wctrans() function. */
712#if @GNULIB_TOWCTRANS@ 745#if @GNULIB_TOWCTRANS@
713# if !@HAVE_WCTRANS_T@ 746# if @REPLACE_WCTRANS@
714_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); 747# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
715# endif 748# undef towctrans
749# define towctrans rpl_towctrans
750# endif
751_GL_FUNCDECL_RPL (towctrans, wint_t, (wint_t wc, wctrans_t desc), );
752_GL_CXXALIAS_RPL (towctrans, wint_t, (wint_t wc, wctrans_t desc));
753# else
754# if !@HAVE_WCTRANS_T@
755_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc), );
756# endif
716_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); 757_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
758# endif
717# if __GLIBC__ >= 2 759# if __GLIBC__ >= 2
718_GL_CXXALIASWARN (towctrans); 760_GL_CXXALIASWARN (towctrans);
719# endif 761# endif
720#elif defined GNULIB_POSIXCHECK 762#elif defined GNULIB_POSIXCHECK
721# undef towctrans
722# if HAVE_RAW_DECL_TOWCTRANS 763# if HAVE_RAW_DECL_TOWCTRANS
723_GL_WARN_ON_USE (towctrans, "towctrans is unportable - " 764_GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
724 "use gnulib module towctrans for portability"); 765 "use gnulib module towctrans for portability");
diff --git a/gl/wcwidth.c b/gl/wcwidth.c
new file mode 100644
index 00000000..ffcc9778
--- /dev/null
+++ b/gl/wcwidth.c
@@ -0,0 +1,73 @@
1/* Determine the number of screen columns needed for a character.
2 Copyright (C) 2006-2007, 2010-2026 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <wchar.h>
21
22/* Get iswprint. */
23#include <wctype.h>
24
25#include "localcharset.h"
26#include "streq.h"
27#include "uniwidth.h"
28
29/* Returns 1 if the current locale is an UTF-8 locale, 0 otherwise. */
30static inline int
31is_locale_utf8 (void)
32{
33 const char *encoding = locale_charset ();
34 return STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0);
35}
36
37#if GNULIB_WCHAR_SINGLE_LOCALE
38/* When we know that the locale does not change, provide a speedup by
39 caching the value of is_locale_utf8. */
40static int cached_is_locale_utf8 = -1;
41static inline int
42is_locale_utf8_cached (void)
43{
44 if (cached_is_locale_utf8 < 0)
45 cached_is_locale_utf8 = is_locale_utf8 ();
46 return cached_is_locale_utf8;
47}
48#else
49/* By default, don't make assumptions, hence no caching. */
50# define is_locale_utf8_cached is_locale_utf8
51#endif
52
53int
54wcwidth (wchar_t wc)
55#undef wcwidth
56{
57 /* In UTF-8 locales, use a Unicode aware width function. */
58 if (is_locale_utf8_cached ())
59 {
60 /* We assume that in a UTF-8 locale, a wide character is the same as a
61 Unicode character. */
62 return uc_width (wc, "UTF-8");
63 }
64 else
65 {
66 /* Otherwise, fall back to the system's wcwidth function. */
67#if HAVE_WCWIDTH
68 return wcwidth (wc);
69#else
70 return wc == 0 ? 0 : iswprint (wc) ? 1 : -1;
71#endif
72 }
73}
diff --git a/gl/windows-initguard.h b/gl/windows-initguard.h
index 9d36f53c..e7da4735 100644
--- a/gl/windows-initguard.h
+++ b/gl/windows-initguard.h
@@ -1,5 +1,5 @@
1/* Init guards, somewhat like spinlocks (native Windows implementation). 1/* Init guards, somewhat like spinlocks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/windows-mutex.c b/gl/windows-mutex.c
index ab7258c9..a8460fab 100644
--- a/gl/windows-mutex.c
+++ b/gl/windows-mutex.c
@@ -1,5 +1,5 @@
1/* Plain mutexes (native Windows implementation). 1/* Plain mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -23,10 +23,12 @@
23#include "windows-mutex.h" 23#include "windows-mutex.h"
24 24
25#include <errno.h> 25#include <errno.h>
26#include <stdlib.h>
26 27
27void 28void
28glwthread_mutex_init (glwthread_mutex_t *mutex) 29glwthread_mutex_init (glwthread_mutex_t *mutex)
29{ 30{
31 mutex->owner = 0;
30 InitializeCriticalSection (&mutex->lock); 32 InitializeCriticalSection (&mutex->lock);
31 mutex->guard.done = 1; 33 mutex->guard.done = 1;
32} 34}
@@ -49,7 +51,13 @@ glwthread_mutex_lock (glwthread_mutex_t *mutex)
49 Sleep (0); 51 Sleep (0);
50 } 52 }
51 } 53 }
54 /* If this thread already owns the mutex, POSIX pthread_mutex_lock() is
55 required to deadlock here. But let's not do that on purpose. */
52 EnterCriticalSection (&mutex->lock); 56 EnterCriticalSection (&mutex->lock);
57 {
58 DWORD self = GetCurrentThreadId ();
59 mutex->owner = self;
60 }
53 return 0; 61 return 0;
54} 62}
55 63
@@ -72,6 +80,21 @@ glwthread_mutex_trylock (glwthread_mutex_t *mutex)
72 } 80 }
73 if (!TryEnterCriticalSection (&mutex->lock)) 81 if (!TryEnterCriticalSection (&mutex->lock))
74 return EBUSY; 82 return EBUSY;
83 {
84 DWORD self = GetCurrentThreadId ();
85 /* TryEnterCriticalSection succeeded. This means that the mutex was either
86 previously unlocked (and thus mutex->owner == 0) or previously locked by
87 this thread (and thus mutex->owner == self). Since the mutex is meant to
88 be plain, we need to fail in the latter case. */
89 if (mutex->owner == self)
90 {
91 LeaveCriticalSection (&mutex->lock);
92 return EBUSY;
93 }
94 if (mutex->owner != 0)
95 abort ();
96 mutex->owner = self;
97 }
75 return 0; 98 return 0;
76} 99}
77 100
@@ -80,6 +103,7 @@ glwthread_mutex_unlock (glwthread_mutex_t *mutex)
80{ 103{
81 if (!mutex->guard.done) 104 if (!mutex->guard.done)
82 return EINVAL; 105 return EINVAL;
106 mutex->owner = 0;
83 LeaveCriticalSection (&mutex->lock); 107 LeaveCriticalSection (&mutex->lock);
84 return 0; 108 return 0;
85} 109}
diff --git a/gl/windows-mutex.h b/gl/windows-mutex.h
index 039eb707..38eab652 100644
--- a/gl/windows-mutex.h
+++ b/gl/windows-mutex.h
@@ -1,5 +1,5 @@
1/* Plain mutexes (native Windows implementation). 1/* Plain mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -28,6 +28,7 @@
28typedef struct 28typedef struct
29 { 29 {
30 glwthread_initguard_t guard; /* protects the initialization */ 30 glwthread_initguard_t guard; /* protects the initialization */
31 DWORD owner;
31 CRITICAL_SECTION lock; 32 CRITICAL_SECTION lock;
32 } 33 }
33 glwthread_mutex_t; 34 glwthread_mutex_t;
diff --git a/gl/windows-once.c b/gl/windows-once.c
index 0d28281f..b3c8a982 100644
--- a/gl/windows-once.c
+++ b/gl/windows-once.c
@@ -1,5 +1,5 @@
1/* Once-only control (native Windows implementation). 1/* Once-only control (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -29,7 +29,9 @@ glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void))
29{ 29{
30 if (once_control->inited <= 0) 30 if (once_control->inited <= 0)
31 { 31 {
32 if (InterlockedIncrement (&once_control->started) == 0) 32 InterlockedIncrement (&once_control->num_threads);
33 /* If once_control->started is == -1, set it to 0. */
34 if (InterlockedCompareExchange (&once_control->started, 0, -1) < 0)
33 { 35 {
34 /* This thread is the first one to come to this once_control. */ 36 /* This thread is the first one to come to this once_control. */
35 InitializeCriticalSection (&once_control->lock); 37 InitializeCriticalSection (&once_control->lock);
@@ -41,8 +43,6 @@ glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void))
41 } 43 }
42 else 44 else
43 { 45 {
44 /* Don't let once_control->started grow and wrap around. */
45 InterlockedDecrement (&once_control->started);
46 /* Some other thread has already started the initialization. 46 /* Some other thread has already started the initialization.
47 Yield the CPU while waiting for the other thread to finish 47 Yield the CPU while waiting for the other thread to finish
48 initializing and taking the lock. */ 48 initializing and taking the lock. */
@@ -58,5 +58,48 @@ glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void))
58 abort (); 58 abort ();
59 } 59 }
60 } 60 }
61 /* Here once_control->started == 0 and once_control->inited > 0. */
62 if (InterlockedDecrement (&once_control->num_threads) == 0)
63 /* once_control->num_threads is now zero, and
64 once_control->started == 0 and once_control->inited > 0.
65 No other thread will need to use the lock.
66 We can therefore destroy the lock, to free resources. */
67 /* If once_control->inited is == 1, set it to 2. */
68 if (InterlockedCompareExchange (&once_control->inited, 2, 1) == 1)
69 DeleteCriticalSection (&once_control->lock);
61 } 70 }
71 /* Proof of correctness:
72 * num_threads is incremented and then decremented by some threads.
73 Therefore, num_threads always stays >= 0, and is == 0 at the end.
74 * The first thread to go through the once_control->started fence
75 initializes the lock and moves inited from <= 0 to > 0. The other
76 threads don't move inited from <= 0 to > 0.
77 * started, once == 0, stays == 0.
78 * inited, once > 0, stays > 0 (since at the place where it is assigned 0,
79 it cannot be > 0).
80 * inited does not change any more once it is 2.
81 Therefore, it can be changed from 1 to 2 only once.
82 * DeleteCriticalSection gets invoked right after inited has been changed
83 from 1 to 2. Therefore, DeleteCriticalSection gets invoked only once.
84 * After a moment where num_threads was 0 and started was 0 and
85 inited was > 0, no thread can reach an InitializeCriticalSection or
86 EnterCriticalSection invocation. Proof:
87 - At such a moment, no thread is in the code range between
88 InterlockedIncrement (&once_control->num_threads)
89 and
90 InterlockedDecrement (&once_control->num_threads)
91 - After such a moment, some thread can increment num_threads, but from
92 there they cannot reach the InitializeCriticalSection invocation,
93 because the once_control->started test prevents that, and they cannot
94 reach the EnterCriticalSection invocation in the other branch because
95 the
96 if (once_control->inited <= 0)
97 test prevents that.
98 * From this it follows that:
99 - DeleteCriticalSection cannot be executed while the lock is taken
100 (because DeleteCriticalSection is only executed after a moment where
101 num_threads was 0 and started was 0 and inited was > 0).
102 - Once DeleteCriticalSection has been executed, the lock is not used any
103 more.
104 */
62} 105}
diff --git a/gl/windows-once.h b/gl/windows-once.h
index 54885680..886ddb45 100644
--- a/gl/windows-once.h
+++ b/gl/windows-once.h
@@ -1,5 +1,5 @@
1/* Once-only control (native Windows implementation). 1/* Once-only control (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -25,13 +25,14 @@
25 25
26typedef struct 26typedef struct
27 { 27 {
28 volatile int inited; 28 volatile LONG inited;
29 volatile LONG num_threads;
29 volatile LONG started; 30 volatile LONG started;
30 CRITICAL_SECTION lock; 31 CRITICAL_SECTION lock;
31 } 32 }
32 glwthread_once_t; 33 glwthread_once_t;
33 34
34#define GLWTHREAD_ONCE_INIT { -1, -1 } 35#define GLWTHREAD_ONCE_INIT { -1, 0, -1 }
35 36
36#ifdef __cplusplus 37#ifdef __cplusplus
37extern "C" { 38extern "C" {
diff --git a/gl/windows-recmutex.c b/gl/windows-recmutex.c
index a8ce9a04..fd6f04db 100644
--- a/gl/windows-recmutex.c
+++ b/gl/windows-recmutex.c
@@ -1,5 +1,5 @@
1/* Plain recursive mutexes (native Windows implementation). 1/* Plain recursive mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/windows-recmutex.h b/gl/windows-recmutex.h
index 08ff4597..1b5773c1 100644
--- a/gl/windows-recmutex.h
+++ b/gl/windows-recmutex.h
@@ -1,5 +1,5 @@
1/* Plain recursive mutexes (native Windows implementation). 1/* Plain recursive mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/windows-rwlock.c b/gl/windows-rwlock.c
index 7cbd7bb1..4a5fbfc2 100644
--- a/gl/windows-rwlock.c
+++ b/gl/windows-rwlock.c
@@ -1,5 +1,5 @@
1/* Read-write locks (native Windows implementation). 1/* Read-write locks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -46,9 +46,6 @@ glwthread_waitqueue_init (glwthread_waitqueue_t *wq)
46static HANDLE 46static HANDLE
47glwthread_waitqueue_add (glwthread_waitqueue_t *wq) 47glwthread_waitqueue_add (glwthread_waitqueue_t *wq)
48{ 48{
49 HANDLE event;
50 unsigned int index;
51
52 if (wq->count == wq->alloc) 49 if (wq->count == wq->alloc)
53 { 50 {
54 unsigned int new_alloc = 2 * wq->alloc + 1; 51 unsigned int new_alloc = 2 * wq->alloc + 1;
@@ -64,14 +61,13 @@ glwthread_waitqueue_add (glwthread_waitqueue_t *wq)
64 unsigned int old_count = wq->count; 61 unsigned int old_count = wq->count;
65 unsigned int old_alloc = wq->alloc; 62 unsigned int old_alloc = wq->alloc;
66 unsigned int old_offset = wq->offset; 63 unsigned int old_offset = wq->offset;
67 unsigned int i;
68 if (old_offset + old_count > old_alloc) 64 if (old_offset + old_count > old_alloc)
69 { 65 {
70 unsigned int limit = old_offset + old_count - old_alloc; 66 unsigned int limit = old_offset + old_count - old_alloc;
71 for (i = 0; i < limit; i++) 67 for (unsigned int i = 0; i < limit; i++)
72 new_array[old_alloc + i] = new_array[i]; 68 new_array[old_alloc + i] = new_array[i];
73 } 69 }
74 for (i = 0; i < old_count; i++) 70 for (unsigned int i = 0; i < old_count; i++)
75 new_array[i] = new_array[old_offset + i]; 71 new_array[i] = new_array[old_offset + i];
76 wq->offset = 0; 72 wq->offset = 0;
77 } 73 }
@@ -80,11 +76,11 @@ glwthread_waitqueue_add (glwthread_waitqueue_t *wq)
80 } 76 }
81 /* Whether the created event is a manual-reset one or an auto-reset one, 77 /* Whether the created event is a manual-reset one or an auto-reset one,
82 does not matter, since we will wait on it only once. */ 78 does not matter, since we will wait on it only once. */
83 event = CreateEvent (NULL, TRUE, FALSE, NULL); 79 HANDLE event = CreateEvent (NULL, TRUE, FALSE, NULL);
84 if (event == INVALID_HANDLE_VALUE) 80 if (event == INVALID_HANDLE_VALUE)
85 /* No way to allocate an event. */ 81 /* No way to allocate an event. */
86 return INVALID_HANDLE_VALUE; 82 return INVALID_HANDLE_VALUE;
87 index = wq->offset + wq->count; 83 unsigned int index = wq->offset + wq->count;
88 if (index >= wq->alloc) 84 if (index >= wq->alloc)
89 index -= wq->alloc; 85 index -= wq->alloc;
90 wq->array[index] = event; 86 wq->array[index] = event;
@@ -107,9 +103,7 @@ glwthread_waitqueue_notify_first (glwthread_waitqueue_t *wq)
107static void 103static void
108glwthread_waitqueue_notify_all (glwthread_waitqueue_t *wq) 104glwthread_waitqueue_notify_all (glwthread_waitqueue_t *wq)
109{ 105{
110 unsigned int i; 106 for (unsigned int i = 0; i < wq->count; i++)
111
112 for (i = 0; i < wq->count; i++)
113 { 107 {
114 unsigned int index = wq->offset + i; 108 unsigned int index = wq->offset + i;
115 if (index >= wq->alloc) 109 if (index >= wq->alloc)
@@ -160,10 +154,9 @@ glwthread_rwlock_rdlock (glwthread_rwlock_t *lock)
160 HANDLE event = glwthread_waitqueue_add (&lock->waiting_readers); 154 HANDLE event = glwthread_waitqueue_add (&lock->waiting_readers);
161 if (event != INVALID_HANDLE_VALUE) 155 if (event != INVALID_HANDLE_VALUE)
162 { 156 {
163 DWORD result;
164 LeaveCriticalSection (&lock->lock); 157 LeaveCriticalSection (&lock->lock);
165 /* Wait until another thread signals this event. */ 158 /* Wait until another thread signals this event. */
166 result = WaitForSingleObject (event, INFINITE); 159 DWORD result = WaitForSingleObject (event, INFINITE);
167 if (result == WAIT_FAILED || result == WAIT_TIMEOUT) 160 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
168 abort (); 161 abort ();
169 CloseHandle (event); 162 CloseHandle (event);
@@ -217,10 +210,9 @@ glwthread_rwlock_wrlock (glwthread_rwlock_t *lock)
217 HANDLE event = glwthread_waitqueue_add (&lock->waiting_writers); 210 HANDLE event = glwthread_waitqueue_add (&lock->waiting_writers);
218 if (event != INVALID_HANDLE_VALUE) 211 if (event != INVALID_HANDLE_VALUE)
219 { 212 {
220 DWORD result;
221 LeaveCriticalSection (&lock->lock); 213 LeaveCriticalSection (&lock->lock);
222 /* Wait until another thread signals this event. */ 214 /* Wait until another thread signals this event. */
223 result = WaitForSingleObject (event, INFINITE); 215 DWORD result = WaitForSingleObject (event, INFINITE);
224 if (result == WAIT_FAILED || result == WAIT_TIMEOUT) 216 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
225 abort (); 217 abort ();
226 CloseHandle (event); 218 CloseHandle (event);
diff --git a/gl/windows-rwlock.h b/gl/windows-rwlock.h
index fe8381e8..5b0a6613 100644
--- a/gl/windows-rwlock.h
+++ b/gl/windows-rwlock.h
@@ -1,5 +1,5 @@
1/* Read-write locks (native Windows implementation). 1/* Read-write locks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc. 2 Copyright (C) 2005-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
diff --git a/gl/xalloc-die.c b/gl/xalloc-die.c
index 7605eee1..1a51976e 100644
--- a/gl/xalloc-die.c
+++ b/gl/xalloc-die.c
@@ -1,6 +1,6 @@
1/* Report a memory allocation failure and exit. 1/* Report a memory allocation failure and exit.
2 2
3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2023 Free Software 3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2026 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
@@ -22,11 +22,11 @@
22 22
23#include <stdlib.h> 23#include <stdlib.h>
24 24
25#include "error.h" 25#include <error.h>
26#include "exitfail.h" 26#include "exitfail.h"
27 27
28#include "gettext.h" 28#include "gettext.h"
29#define _(msgid) gettext (msgid) 29#define _(msgid) dgettext (GNULIB_TEXT_DOMAIN, msgid)
30 30
31void 31void
32xalloc_die (void) 32xalloc_die (void)
diff --git a/gl/xalloc-oversized.h b/gl/xalloc-oversized.h
index 5dbdfb55..cecdaec5 100644
--- a/gl/xalloc-oversized.h
+++ b/gl/xalloc-oversized.h
@@ -1,6 +1,6 @@
1/* xalloc-oversized.h -- memory allocation size checking 1/* xalloc-oversized.h -- memory allocation size checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -29,8 +29,7 @@
29 is SIZE_MAX - 1. */ 29 is SIZE_MAX - 1. */
30#define __xalloc_oversized(n, s) \ 30#define __xalloc_oversized(n, s) \
31 ((s) != 0 \ 31 ((s) != 0 \
32 && ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) \ 32 && (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) < (n))
33 < (n)))
34 33
35/* Return 1 if and only if an array of N objects, each of size S, 34/* Return 1 if and only if an array of N objects, each of size S,
36 cannot exist reliably because its total size in bytes would exceed 35 cannot exist reliably because its total size in bytes would exceed
@@ -48,13 +47,14 @@
48#if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX 47#if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX
49# define xalloc_oversized(n, s) \ 48# define xalloc_oversized(n, s) \
50 __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1) 49 __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1)
51#elif (5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ \ 50#elif 5 <= __GNUC__ && !defined __clang__ && !defined __ICC \
52 && PTRDIFF_MAX < SIZE_MAX) 51 && PTRDIFF_MAX < SIZE_MAX
53# define xalloc_oversized(n, s) \ 52# define xalloc_oversized(n, s) \
54 (__builtin_constant_p (n) && __builtin_constant_p (s) \ 53 (__builtin_constant_p (n) && __builtin_constant_p (s) \
55 ? __xalloc_oversized (n, s) \ 54 ? __xalloc_oversized (n, s) \
56 : ({ ptrdiff_t __xalloc_count; \ 55 : __extension__ \
57 __builtin_mul_overflow (n, s, &__xalloc_count); })) 56 ({ ptrdiff_t __xalloc_count; \
57 __builtin_mul_overflow (n, s, &__xalloc_count); }))
58 58
59/* Other compilers use integer division; this may be slower but is 59/* Other compilers use integer division; this may be slower but is
60 more portable. */ 60 more portable. */
diff --git a/gl/xalloc.h b/gl/xalloc.h
index f373c2fe..d3948270 100644
--- a/gl/xalloc.h
+++ b/gl/xalloc.h
@@ -1,6 +1,6 @@
1/* xalloc.h -- malloc with out-of-memory checking 1/* xalloc.h -- malloc with out-of-memory checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -18,6 +18,13 @@
18#ifndef XALLOC_H_ 18#ifndef XALLOC_H_
19#define XALLOC_H_ 19#define XALLOC_H_
20 20
21/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _Noreturn,
22 _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_MALLOC,
23 _GL_ATTRIBUTE_RETURNS_NONNULL. */
24#if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26#endif
27
21#include <stddef.h> 28#include <stddef.h>
22#include <stdlib.h> 29#include <stdlib.h>
23 30
@@ -25,9 +32,6 @@
25# include "idx.h" 32# include "idx.h"
26#endif 33#endif
27 34
28#ifndef _GL_INLINE_HEADER_BEGIN
29 #error "Please include config.h first."
30#endif
31_GL_INLINE_HEADER_BEGIN 35_GL_INLINE_HEADER_BEGIN
32#ifndef XALLOC_INLINE 36#ifndef XALLOC_INLINE
33# define XALLOC_INLINE _GL_INLINE 37# define XALLOC_INLINE _GL_INLINE
@@ -46,7 +50,7 @@ extern "C" {
46 or by using gnulib's xalloc-die module. This is the 50 or by using gnulib's xalloc-die module. This is the
47 function to call when one wants the program to die because of a 51 function to call when one wants the program to die because of a
48 memory allocation failure. */ 52 memory allocation failure. */
49/*extern*/ _Noreturn void xalloc_die (void); 53_Noreturn void xalloc_die (void);
50 54
51#endif /* GNULIB_XALLOC_DIE */ 55#endif /* GNULIB_XALLOC_DIE */
52 56
diff --git a/gl/xmalloc.c b/gl/xmalloc.c
index 289cbd05..6adc43c0 100644
--- a/gl/xmalloc.c
+++ b/gl/xmalloc.c
@@ -1,6 +1,6 @@
1/* xmalloc.c -- malloc with out of memory checking 1/* xmalloc.c -- malloc with out of memory checking
2 2
3 Copyright (C) 1990-2000, 2002-2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2002-2006, 2008-2026 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -15,10 +15,8 @@
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h>
19
20#define XALLOC_INLINE _GL_EXTERN_INLINE 18#define XALLOC_INLINE _GL_EXTERN_INLINE
21 19#include <config.h>
22#include "xalloc.h" 20#include "xalloc.h"
23 21
24#include "ialloc.h" 22#include "ialloc.h"
@@ -29,8 +27,14 @@
29#include <stdint.h> 27#include <stdint.h>
30#include <string.h> 28#include <string.h>
31 29
32static void * _GL_ATTRIBUTE_PURE 30/* Pacify GCC up to at least 15.2, which otherwise would incorrectly
33nonnull (void *p) 31 complain about check_nonnull. */
32#if _GL_GNUC_PREREQ (4, 6)
33# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
34#endif
35
36static void *
37check_nonnull (void *p)
34{ 38{
35 if (!p) 39 if (!p)
36 xalloc_die (); 40 xalloc_die ();
@@ -42,13 +46,13 @@ nonnull (void *p)
42void * 46void *
43xmalloc (size_t s) 47xmalloc (size_t s)
44{ 48{
45 return nonnull (malloc (s)); 49 return check_nonnull (malloc (s));
46} 50}
47 51
48void * 52void *
49ximalloc (idx_t s) 53ximalloc (idx_t s)
50{ 54{
51 return nonnull (imalloc (s)); 55 return check_nonnull (imalloc (s));
52} 56}
53 57
54char * 58char *
@@ -64,7 +68,7 @@ void *
64xrealloc (void *p, size_t s) 68xrealloc (void *p, size_t s)
65{ 69{
66 void *r = realloc (p, s); 70 void *r = realloc (p, s);
67 if (!r && (!p || s)) 71 if (!r)
68 xalloc_die (); 72 xalloc_die ();
69 return r; 73 return r;
70} 74}
@@ -72,7 +76,7 @@ xrealloc (void *p, size_t s)
72void * 76void *
73xirealloc (void *p, idx_t s) 77xirealloc (void *p, idx_t s)
74{ 78{
75 return nonnull (irealloc (p, s)); 79 return check_nonnull (irealloc (p, s));
76} 80}
77 81
78/* Change the size of an allocated block of memory P to an array of N 82/* Change the size of an allocated block of memory P to an array of N
@@ -82,7 +86,7 @@ void *
82xreallocarray (void *p, size_t n, size_t s) 86xreallocarray (void *p, size_t n, size_t s)
83{ 87{
84 void *r = reallocarray (p, n, s); 88 void *r = reallocarray (p, n, s);
85 if (!r && (!p || (n && s))) 89 if (!r)
86 xalloc_die (); 90 xalloc_die ();
87 return r; 91 return r;
88} 92}
@@ -90,7 +94,7 @@ xreallocarray (void *p, size_t n, size_t s)
90void * 94void *
91xireallocarray (void *p, idx_t n, idx_t s) 95xireallocarray (void *p, idx_t n, idx_t s)
92{ 96{
93 return nonnull (ireallocarray (p, n, s)); 97 return check_nonnull (ireallocarray (p, n, s));
94} 98}
95 99
96/* Allocate an array of N objects, each with S bytes of memory, 100/* Allocate an array of N objects, each with S bytes of memory,
@@ -224,13 +228,13 @@ x2nrealloc (void *p, size_t *pn, size_t s)
224void * 228void *
225xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s) 229xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
226{ 230{
227 idx_t n0 = *pn;
228
229 /* The approximate size to use for initial small allocation 231 /* The approximate size to use for initial small allocation
230 requests. This is the largest "small" request for the GNU C 232 requests. This is the largest "small" request for the GNU C
231 library malloc. */ 233 library malloc. */
232 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; 234 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
233 235
236 idx_t n0 = *pn;
237
234 /* If the array is tiny, grow it to about (but no greater than) 238 /* If the array is tiny, grow it to about (but no greater than)
235 DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%. 239 DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%.
236 Adjust the growth according to three constraints: N_INCR_MIN, 240 Adjust the growth according to three constraints: N_INCR_MIN,
@@ -295,13 +299,13 @@ xizalloc (idx_t s)
295void * 299void *
296xcalloc (size_t n, size_t s) 300xcalloc (size_t n, size_t s)
297{ 301{
298 return nonnull (calloc (n, s)); 302 return check_nonnull (calloc (n, s));
299} 303}
300 304
301void * 305void *
302xicalloc (idx_t n, idx_t s) 306xicalloc (idx_t n, idx_t s)
303{ 307{
304 return nonnull (icalloc (n, s)); 308 return check_nonnull (icalloc (n, s));
305} 309}
306 310
307/* Clone an object P of size S, with error checking. There's no need 311/* Clone an object P of size S, with error checking. There's no need
diff --git a/gl/xsize.c b/gl/xsize.c
index 279ae824..22856eb6 100644
--- a/gl/xsize.c
+++ b/gl/xsize.c
@@ -1,6 +1,6 @@
1/* Checked size_t computations. 1/* Checked size_t computations.
2 2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc. 3 Copyright (C) 2012-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -15,7 +15,6 @@
15 You should have received a copy of the GNU Lesser General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h>
19
20#define XSIZE_INLINE _GL_EXTERN_INLINE 18#define XSIZE_INLINE _GL_EXTERN_INLINE
19#include <config.h>
21#include "xsize.h" 20#include "xsize.h"
diff --git a/gl/xsize.h b/gl/xsize.h
index 1ec78e77..b76cf49f 100644
--- a/gl/xsize.h
+++ b/gl/xsize.h
@@ -1,6 +1,6 @@
1/* xsize.h -- Checked size_t computations. 1/* xsize.h -- Checked size_t computations.
2 2
3 Copyright (C) 2003, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -18,10 +18,15 @@
18#ifndef _XSIZE_H 18#ifndef _XSIZE_H
19#define _XSIZE_H 19#define _XSIZE_H
20 20
21/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, HAVE_STDINT_H. */
22#if !_GL_CONFIG_H_INCLUDED
23 #error "Please include config.h first."
24#endif
25
21/* Get size_t. */ 26/* Get size_t. */
22#include <stddef.h> 27#include <stddef.h>
23 28
24/* Get SIZE_MAX. */ 29/* Get INT_MAX, SIZE_MAX. */
25#include <limits.h> 30#include <limits.h>
26#if HAVE_STDINT_H 31#if HAVE_STDINT_H
27# include <stdint.h> 32# include <stdint.h>
@@ -30,14 +35,16 @@
30/* Get ATTRIBUTE_PURE. */ 35/* Get ATTRIBUTE_PURE. */
31#include "attribute.h" 36#include "attribute.h"
32 37
33#ifndef _GL_INLINE_HEADER_BEGIN
34 #error "Please include config.h first."
35#endif
36_GL_INLINE_HEADER_BEGIN 38_GL_INLINE_HEADER_BEGIN
37#ifndef XSIZE_INLINE 39#ifndef XSIZE_INLINE
38# define XSIZE_INLINE _GL_INLINE 40# define XSIZE_INLINE _GL_INLINE
39#endif 41#endif
40 42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47
41/* The size of memory objects is often computed through expressions of 48/* The size of memory objects is often computed through expressions of
42 type size_t. Example: 49 type size_t. Example:
43 void* p = malloc (header_size + n * element_size). 50 void* p = malloc (header_size + n * element_size).
@@ -54,7 +61,8 @@ _GL_INLINE_HEADER_BEGIN
54 void *p = (size_in_bounds_p (size) ? malloc (size) : NULL); 61 void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
55*/ 62*/
56 63
57/* Convert an arbitrary value >= 0 to type size_t. */ 64/* Convert an arbitrary N >= 0 to type size_t.
65 N should not have side effects. */
58#define xcast_size_t(N) \ 66#define xcast_size_t(N) \
59 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) 67 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
60 68
@@ -62,8 +70,15 @@ _GL_INLINE_HEADER_BEGIN
62XSIZE_INLINE size_t ATTRIBUTE_PURE 70XSIZE_INLINE size_t ATTRIBUTE_PURE
63xsum (size_t size1, size_t size2) 71xsum (size_t size1, size_t size2)
64{ 72{
65 size_t sum = size1 + size2; 73 if (INT_MAX < SIZE_MAX)
66 return (sum >= size1 ? sum : SIZE_MAX); 74 {
75 /* Optimize for the common case where size_t arithmetic wraps
76 around without undefined behavior. */
77 size_t sum = size1 + size2;
78 return size1 <= sum ? sum : SIZE_MAX;
79 }
80
81 return size1 <= SIZE_MAX - size2 ? size1 + size2 : SIZE_MAX;
67} 82}
68 83
69/* Sum of three sizes, with overflow check. */ 84/* Sum of three sizes, with overflow check. */
@@ -91,6 +106,8 @@ xmax (size_t size1, size_t size2)
91 106
92/* Multiplication of a count with an element size, with overflow check. 107/* Multiplication of a count with an element size, with overflow check.
93 The count must be >= 0 and the element size must be > 0. 108 The count must be >= 0 and the element size must be > 0.
109 Arguments should not have side effects.
110 The element size's type should be no wider than size_t.
94 This is a macro, not a function, so that it works correctly even 111 This is a macro, not a function, so that it works correctly even
95 when N is of a wider type and N > SIZE_MAX. */ 112 when N is of a wider type and N > SIZE_MAX. */
96#define xtimes(N, ELSIZE) \ 113#define xtimes(N, ELSIZE) \
@@ -103,6 +120,11 @@ xmax (size_t size1, size_t size2)
103#define size_in_bounds_p(SIZE) \ 120#define size_in_bounds_p(SIZE) \
104 ((SIZE) != SIZE_MAX) 121 ((SIZE) != SIZE_MAX)
105 122
123
124#ifdef __cplusplus
125}
126#endif
127
106_GL_INLINE_HEADER_END 128_GL_INLINE_HEADER_END
107 129
108#endif /* _XSIZE_H */ 130#endif /* _XSIZE_H */