diff options
| author | Paul Eggert | 2025-01-15 19:31:07 -0800 |
|---|---|---|
| committer | Paul Eggert | 2025-01-15 19:31:39 -0800 |
| commit | 74dc2bd28007e68532d9813a57d3ec7da0c390e3 (patch) | |
| tree | 1dbf3c1106bfe8b240165710e73c18f3f1940f89 /lib | |
| parent | 4f946a652278cc72a777fe56999bc4525f53e03a (diff) | |
| download | emacs-74dc2bd28007e68532d9813a57d3ec7da0c390e3.tar.gz emacs-74dc2bd28007e68532d9813a57d3ec7da0c390e3.zip | |
Update from Gnulib by running admin/merge-gnulib
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/fcntl.in.h | 6 | ||||
| -rw-r--r-- | lib/file-has-acl.c | 46 | ||||
| -rw-r--r-- | lib/gnulib.mk.in | 8 | ||||
| -rw-r--r-- | lib/mktime-internal.h | 7 | ||||
| -rw-r--r-- | lib/mktime.c | 70 | ||||
| -rw-r--r-- | lib/stdlib.in.h | 5 | ||||
| -rw-r--r-- | lib/string.in.h | 36 | ||||
| -rw-r--r-- | lib/sys_select.in.h | 8 |
8 files changed, 136 insertions, 50 deletions
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 5f06c4fe10f..ac61c0865a4 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h | |||
| @@ -369,8 +369,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " | |||
| 369 | # define O_RSYNC 0 | 369 | # define O_RSYNC 0 |
| 370 | #endif | 370 | #endif |
| 371 | 371 | ||
| 372 | #if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH | ||
| 373 | # undef O_SEARCH /* musl mistakenly #defines O_SEARCH to O_PATH. */ | ||
| 374 | #endif | ||
| 375 | |||
| 372 | #ifndef O_SEARCH | 376 | #ifndef O_SEARCH |
| 373 | # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ | 377 | # define O_SEARCH O_RDONLY /* Often close enough in non-POSIX systems. */ |
| 374 | #endif | 378 | #endif |
| 375 | 379 | ||
| 376 | #ifndef O_SYNC | 380 | #ifndef O_SYNC |
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 35dcc19f169..e8413f8f85f 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c | |||
| @@ -99,6 +99,36 @@ enum { | |||
| 99 | ACE4_IDENTIFIER_GROUP = 0x00000040 | 99 | ACE4_IDENTIFIER_GROUP = 0x00000040 |
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | /* AI indicates XATTR may be present but wasn't accessible. | ||
| 103 | This is the case when [l]listxattr failed with E2BIG, | ||
| 104 | or failed with EACCES which in Linux kernel 6.12 NFS can mean merely | ||
| 105 | that we lack read access. | ||
| 106 | */ | ||
| 107 | |||
| 108 | static bool | ||
| 109 | aclinfo_may_indicate_xattr (struct aclinfo const *ai) | ||
| 110 | { | ||
| 111 | return ai->size < 0 && (ai->u.err == EACCES || ai->u.err == E2BIG); | ||
| 112 | } | ||
| 113 | |||
| 114 | /* Does NAME have XATTR? */ | ||
| 115 | |||
| 116 | static bool | ||
| 117 | has_xattr (char const *xattr, struct aclinfo const *ai, | ||
| 118 | MAYBE_UNUSED char const *restrict name, MAYBE_UNUSED int flags) | ||
| 119 | { | ||
| 120 | if (ai && aclinfo_has_xattr (ai, xattr)) | ||
| 121 | return true; | ||
| 122 | else if (!ai || aclinfo_may_indicate_xattr (ai)) | ||
| 123 | { | ||
| 124 | int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr) | ||
| 125 | (name, xattr, NULL, 0)); | ||
| 126 | if (0 <= ret || (errno == ERANGE || errno == E2BIG)) | ||
| 127 | return true; | ||
| 128 | } | ||
| 129 | return false; | ||
| 130 | } | ||
| 131 | |||
| 102 | /* Does AI's xattr set contain XATTR? */ | 132 | /* Does AI's xattr set contain XATTR? */ |
| 103 | 133 | ||
| 104 | bool | 134 | bool |
| @@ -176,11 +206,13 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) | |||
| 176 | } | 206 | } |
| 177 | } | 207 | } |
| 178 | 208 | ||
| 179 | if (0 < ai->size && flags & ACL_GET_SCONTEXT) | 209 | /* A security context can exist only if extended attributes do. */ |
| 210 | if (flags & ACL_GET_SCONTEXT | ||
| 211 | && (0 < ai->size || aclinfo_may_indicate_xattr (ai))) | ||
| 180 | { | 212 | { |
| 181 | if (is_smack_enabled ()) | 213 | if (is_smack_enabled ()) |
| 182 | { | 214 | { |
| 183 | if (aclinfo_has_xattr (ai, XATTR_NAME_SMACK)) | 215 | if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SMACK)) |
| 184 | { | 216 | { |
| 185 | ssize_t r = smack_new_label_from_path (name, "security.SMACK64", | 217 | ssize_t r = smack_new_label_from_path (name, "security.SMACK64", |
| 186 | flags & ACL_SYMLINK_FOLLOW, | 218 | flags & ACL_SYMLINK_FOLLOW, |
| @@ -191,7 +223,7 @@ get_aclinfo (char const *name, struct aclinfo *ai, int flags) | |||
| 191 | else | 223 | else |
| 192 | { | 224 | { |
| 193 | # if USE_SELINUX_SELINUX_H | 225 | # if USE_SELINUX_SELINUX_H |
| 194 | if (aclinfo_has_xattr (ai, XATTR_NAME_SELINUX)) | 226 | if (ai->size < 0 || aclinfo_has_xattr (ai, XATTR_NAME_SELINUX)) |
| 195 | { | 227 | { |
| 196 | ssize_t r = | 228 | ssize_t r = |
| 197 | ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) | 229 | ((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon) |
| @@ -352,7 +384,7 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, | |||
| 352 | int initial_errno = errno; | 384 | int initial_errno = errno; |
| 353 | get_aclinfo (name, ai, flags); | 385 | get_aclinfo (name, ai, flags); |
| 354 | 386 | ||
| 355 | if (ai->size <= 0) | 387 | if (!aclinfo_may_indicate_xattr (ai) && ai->size <= 0) |
| 356 | { | 388 | { |
| 357 | errno = ai->size < 0 ? ai->u.err : initial_errno; | 389 | errno = ai->size < 0 ? ai->u.err : initial_errno; |
| 358 | return ai->size; | 390 | return ai->size; |
| @@ -363,11 +395,11 @@ file_has_aclinfo (MAYBE_UNUSED char const *restrict name, | |||
| 363 | In earlier Fedora the two types of ACLs were mutually exclusive. | 395 | In earlier Fedora the two types of ACLs were mutually exclusive. |
| 364 | Attempt to work correctly on both kinds of systems. */ | 396 | Attempt to work correctly on both kinds of systems. */ |
| 365 | 397 | ||
| 366 | if (!aclinfo_has_xattr (ai, XATTR_NAME_NFSV4_ACL)) | 398 | if (!has_xattr (XATTR_NAME_NFSV4_ACL, ai, name, flags)) |
| 367 | return | 399 | return |
| 368 | (aclinfo_has_xattr (ai, XATTR_NAME_POSIX_ACL_ACCESS) | 400 | (has_xattr (XATTR_NAME_POSIX_ACL_ACCESS, ai, name, flags) |
| 369 | || ((d_type == DT_DIR || d_type == DT_UNKNOWN) | 401 | || ((d_type == DT_DIR || d_type == DT_UNKNOWN) |
| 370 | && aclinfo_has_xattr (ai, XATTR_NAME_POSIX_ACL_DEFAULT))); | 402 | && has_xattr (XATTR_NAME_POSIX_ACL_DEFAULT, ai, name, flags))); |
| 371 | 403 | ||
| 372 | /* A buffer large enough to hold any trivial NFSv4 ACL. | 404 | /* A buffer large enough to hold any trivial NFSv4 ACL. |
| 373 | The max length of a trivial NFSv4 ACL is 6 words for owner, | 405 | The max length of a trivial NFSv4 ACL is 6 words for owner, |
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index a42e77e99b8..b1f0053e582 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in | |||
| @@ -489,6 +489,8 @@ GL_GNULIB_MBSSPN = @GL_GNULIB_MBSSPN@ | |||
| 489 | GL_GNULIB_MBSSTR = @GL_GNULIB_MBSSTR@ | 489 | GL_GNULIB_MBSSTR = @GL_GNULIB_MBSSTR@ |
| 490 | GL_GNULIB_MBSTOK_R = @GL_GNULIB_MBSTOK_R@ | 490 | GL_GNULIB_MBSTOK_R = @GL_GNULIB_MBSTOK_R@ |
| 491 | GL_GNULIB_MBSTOWCS = @GL_GNULIB_MBSTOWCS@ | 491 | GL_GNULIB_MBSTOWCS = @GL_GNULIB_MBSTOWCS@ |
| 492 | GL_GNULIB_MBS_ENDSWITH = @GL_GNULIB_MBS_ENDSWITH@ | ||
| 493 | GL_GNULIB_MBS_STARTSWITH = @GL_GNULIB_MBS_STARTSWITH@ | ||
| 492 | GL_GNULIB_MBTOWC = @GL_GNULIB_MBTOWC@ | 494 | GL_GNULIB_MBTOWC = @GL_GNULIB_MBTOWC@ |
| 493 | GL_GNULIB_MDA_ACCESS = @GL_GNULIB_MDA_ACCESS@ | 495 | GL_GNULIB_MDA_ACCESS = @GL_GNULIB_MDA_ACCESS@ |
| 494 | GL_GNULIB_MDA_CHDIR = @GL_GNULIB_MDA_CHDIR@ | 496 | GL_GNULIB_MDA_CHDIR = @GL_GNULIB_MDA_CHDIR@ |
| @@ -642,6 +644,8 @@ GL_GNULIB_STRTOUL = @GL_GNULIB_STRTOUL@ | |||
| 642 | GL_GNULIB_STRTOULL = @GL_GNULIB_STRTOULL@ | 644 | GL_GNULIB_STRTOULL = @GL_GNULIB_STRTOULL@ |
| 643 | GL_GNULIB_STRTOUMAX = @GL_GNULIB_STRTOUMAX@ | 645 | GL_GNULIB_STRTOUMAX = @GL_GNULIB_STRTOUMAX@ |
| 644 | GL_GNULIB_STRVERSCMP = @GL_GNULIB_STRVERSCMP@ | 646 | GL_GNULIB_STRVERSCMP = @GL_GNULIB_STRVERSCMP@ |
| 647 | GL_GNULIB_STR_ENDSWITH = @GL_GNULIB_STR_ENDSWITH@ | ||
| 648 | GL_GNULIB_STR_STARTSWITH = @GL_GNULIB_STR_STARTSWITH@ | ||
| 645 | GL_GNULIB_SYMLINK = @GL_GNULIB_SYMLINK@ | 649 | GL_GNULIB_SYMLINK = @GL_GNULIB_SYMLINK@ |
| 646 | GL_GNULIB_SYMLINKAT = @GL_GNULIB_SYMLINKAT@ | 650 | GL_GNULIB_SYMLINKAT = @GL_GNULIB_SYMLINKAT@ |
| 647 | GL_GNULIB_SYSTEM_POSIX = @GL_GNULIB_SYSTEM_POSIX@ | 651 | GL_GNULIB_SYSTEM_POSIX = @GL_GNULIB_SYSTEM_POSIX@ |
| @@ -3655,6 +3659,8 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 3655 | -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \ | 3659 | -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \ |
| 3656 | -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \ | 3660 | -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \ |
| 3657 | -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \ | 3661 | -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \ |
| 3662 | -e 's/@''GNULIB_MBS_ENDSWITH''@/$(GL_GNULIB_MBS_ENDSWITH)/g' \ | ||
| 3663 | -e 's/@''GNULIB_MBS_STARTSWITH''@/$(GL_GNULIB_MBS_STARTSWITH)/g' \ | ||
| 3658 | -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \ | 3664 | -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \ |
| 3659 | -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \ | 3665 | -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \ |
| 3660 | -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \ | 3666 | -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \ |
| @@ -3673,6 +3679,8 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 3673 | -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \ | 3679 | -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \ |
| 3674 | -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \ | 3680 | -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \ |
| 3675 | -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \ | 3681 | -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \ |
| 3682 | -e 's/@''GNULIB_STR_ENDSWITH''@/$(GL_GNULIB_STR_ENDSWITH)/g' \ | ||
| 3683 | -e 's/@''GNULIB_STR_STARTSWITH''@/$(GL_GNULIB_STR_STARTSWITH)/g' \ | ||
| 3676 | -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \ | 3684 | -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \ |
| 3677 | -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \ | 3685 | -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \ |
| 3678 | -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \ | 3686 | -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \ |
diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h index 1da98b43732..215be914c2f 100644 --- a/lib/mktime-internal.h +++ b/lib/mktime-internal.h | |||
| @@ -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 |
| @@ -73,6 +76,8 @@ typedef int mktime_offset_t; | |||
| 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. If | 77 | normalize TP, given that a struct tm * maps to a time_t. If |
| 75 | LOCAL, the mapping is performed by localtime_r, otherwise by gmtime_r. | 78 | LOCAL, the mapping is performed by localtime_r, otherwise by gmtime_r. |
| 76 | Record next guess for localtime-gmtime offset in *OFFSET. */ | 79 | Record next guess for localtime-gmtime offset in *OFFSET. |
| 80 | |||
| 81 | If _LIBC, the caller must lock __tzset_lock. */ | ||
| 77 | extern __time64_t __mktime_internal (struct tm *tp, bool local, | 82 | extern __time64_t __mktime_internal (struct tm *tp, bool local, |
| 78 | mktime_offset_t *offset) attribute_hidden; | 83 | mktime_offset_t *offset) attribute_hidden; |
diff --git a/lib/mktime.c b/lib/mktime.c index 74403e4530e..4218fca69b1 100644 --- a/lib/mktime.c +++ b/lib/mktime.c | |||
| @@ -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 |
| @@ -250,6 +253,7 @@ 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 | ||
| 256 | #ifndef _LIBC | ||
| 253 | /* Convert T to a struct tm value in *TM. Use localtime64_r if LOCAL, | 257 | /* Convert T to a struct tm value in *TM. Use localtime64_r if LOCAL, |
| 254 | otherwise gmtime64_r. T must be in range for __time64_t. Return | 258 | otherwise gmtime64_r. T must be in range for __time64_t. Return |
| 255 | TM if successful, NULL (setting errno) on failure. */ | 259 | TM if successful, NULL (setting errno) on failure. */ |
| @@ -262,8 +266,8 @@ convert_time (long_int t, bool local, struct tm *tm) | |||
| 262 | else | 266 | else |
| 263 | return __gmtime64_r (&x, tm); | 267 | return __gmtime64_r (&x, tm); |
| 264 | } | 268 | } |
| 265 | /* Call it __tzconvert to sync with other parts of glibc. */ | 269 | # define __tz_convert convert_time |
| 266 | #define __tz_convert convert_time | 270 | #endif |
| 267 | 271 | ||
| 268 | /* Convert *T to a broken down time in *TP (as if by localtime if | 272 | /* Convert *T to a broken down time in *TP (as if by localtime if |
| 269 | LOCAL, otherwise as if by gmtime). If *T is out of range for | 273 | LOCAL, otherwise as if by gmtime). If *T is out of range for |
| @@ -320,7 +324,9 @@ ranged_convert (bool local, long_int *t, struct tm *tp) | |||
| 320 | If *OFFSET's guess is correct, only one reverse mapping call is | 324 | If *OFFSET's guess is correct, only one reverse mapping call is |
| 321 | needed. If successful, set *TP to the canonicalized struct tm; | 325 | needed. If successful, set *TP to the canonicalized struct tm; |
| 322 | otherwise leave *TP alone, return ((time_t) -1) and set errno. | 326 | otherwise leave *TP alone, return ((time_t) -1) and set errno. |
| 323 | 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. */ | ||
| 324 | __time64_t | 330 | __time64_t |
| 325 | __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | 331 | __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) |
| 326 | { | 332 | { |
| @@ -349,12 +355,10 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | |||
| 349 | int mday = tp->tm_mday; | 355 | int mday = tp->tm_mday; |
| 350 | int mon = tp->tm_mon; | 356 | int mon = tp->tm_mon; |
| 351 | int year_requested = tp->tm_year; | 357 | int year_requested = tp->tm_year; |
| 358 | int isdst = tp->tm_isdst; | ||
| 352 | 359 | ||
| 353 | /* Ignore any tm_isdst request for timegm. */ | 360 | /* True if the previous probe was DST. */ |
| 354 | int isdst = local ? tp->tm_isdst : 0; | 361 | bool dst2 = false; |
| 355 | |||
| 356 | /* 1 if the previous probe was DST. */ | ||
| 357 | int dst2 = 0; | ||
| 358 | 362 | ||
| 359 | /* Ensure that mon is in range, and set year accordingly. */ | 363 | /* Ensure that mon is in range, and set year accordingly. */ |
| 360 | int mon_remainder = mon % 12; | 364 | int mon_remainder = mon % 12; |
| @@ -443,13 +447,10 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | |||
| 443 | 447 | ||
| 444 | Heuristic: probe the adjacent timestamps in both directions, | 448 | Heuristic: probe the adjacent timestamps in both directions, |
| 445 | looking for the desired isdst. If none is found within a | 449 | looking for the desired isdst. If none is found within a |
| 446 | reasonable duration bound, assume a one-hour DST difference. | 450 | reasonable duration bound, ignore the disagreement. |
| 447 | 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 |
| 448 | database. */ | 452 | database. */ |
| 449 | 453 | ||
| 450 | /* +1 if we wanted standard time but got DST, -1 if the reverse. */ | ||
| 451 | int dst_difference = (isdst == 0) - (tm.tm_isdst == 0); | ||
| 452 | |||
| 453 | /* Distance between probes when looking for a DST boundary. In | 454 | /* Distance between probes when looking for a DST boundary. In |
| 454 | tzdata2003a, the shortest period of DST is 601200 seconds | 455 | tzdata2003a, the shortest period of DST is 601200 seconds |
| 455 | (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 |
| @@ -459,21 +460,17 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | |||
| 459 | periods when probing. */ | 460 | periods when probing. */ |
| 460 | int stride = 601200; | 461 | int stride = 601200; |
| 461 | 462 | ||
| 462 | /* In TZDB 2021e, the longest period of DST (or of non-DST), in | 463 | /* Do not probe too far away from the requested time, |
| 463 | 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. |
| 464 | is 457243209 seconds: e.g., America/Cambridge_Bay with leap | 465 | This helps avoid unexpected results in (for example) Asia/Kolkata, |
| 465 | 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 |
| 466 | double-daylight time (-05) to standard time (-07), and | 467 | did observe DST long ago. */ |
| 467 | continuing to 1980-04-27 02:00 in a switch from standard time | 468 | int year_seconds_bound = 366 * 24 * 60 * 60 + 1; |
| 468 | (-07) to daylight time (-06). */ | 469 | int delta_bound = year_seconds_bound + stride; |
| 469 | int duration_max = 457243209; | ||
| 470 | |||
| 471 | /* Search in both directions, so the maximum distance is half | ||
| 472 | the duration; add the stride to avoid off-by-1 problems. */ | ||
| 473 | int delta_bound = duration_max / 2 + stride; | ||
| 474 | 470 | ||
| 475 | int delta, direction; | 471 | int delta, direction; |
| 476 | 472 | ||
| 473 | /* Search in both directions, closest first. */ | ||
| 477 | for (delta = stride; delta < delta_bound; delta += stride) | 474 | for (delta = stride; delta < delta_bound; delta += stride) |
| 478 | for (direction = -1; direction <= 1; direction += 2) | 475 | for (direction = -1; direction <= 1; direction += 2) |
| 479 | { | 476 | { |
| @@ -503,13 +500,8 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | |||
| 503 | } | 500 | } |
| 504 | } | 501 | } |
| 505 | 502 | ||
| 506 | /* No unusual DST offset was found nearby. Assume one-hour DST. */ | 503 | /* No probe with the requested tm_isdst was found nearby. |
| 507 | t += 60 * 60 * dst_difference; | 504 | Ignore the requested tm_isdst. */ |
| 508 | if (mktime_min <= t && t <= mktime_max && __tz_convert (t, local, &tm)) | ||
| 509 | goto offset_found; | ||
| 510 | |||
| 511 | __set_errno (EOVERFLOW); | ||
| 512 | return -1; | ||
| 513 | } | 505 | } |
| 514 | 506 | ||
| 515 | offset_found: | 507 | offset_found: |
| @@ -548,17 +540,19 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset) | |||
| 548 | __time64_t | 540 | __time64_t |
| 549 | __mktime64 (struct tm *tp) | 541 | __mktime64 (struct tm *tp) |
| 550 | { | 542 | { |
| 551 | /* POSIX.1 requires mktime to set external variables like 'tzname' | 543 | __libc_lock_lock (__tzset_lock); |
| 552 | as though tzset had been called. */ | 544 | __tzset_unlocked (); |
| 553 | __tzset (); | ||
| 554 | 545 | ||
| 555 | # if defined _LIBC || NEED_MKTIME_WORKING | 546 | # if defined _LIBC || NEED_MKTIME_WORKING |
| 556 | static mktime_offset_t localtime_offset; | 547 | static mktime_offset_t localtime_offset; |
| 557 | return __mktime_internal (tp, true, &localtime_offset); | 548 | __time64_t result = __mktime_internal (tp, true, &localtime_offset); |
| 558 | # else | 549 | # else |
| 559 | # undef mktime | 550 | # undef mktime |
| 560 | return mktime (tp); | 551 | __time64_t result = mktime (tp); |
| 561 | # endif | 552 | # endif |
| 553 | |||
| 554 | __libc_lock_unlock (__tzset_lock); | ||
| 555 | return result; | ||
| 562 | } | 556 | } |
| 563 | #endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ | 557 | #endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ |
| 564 | 558 | ||
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index f8e2a6ce344..bd82086ff37 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h | |||
| @@ -62,8 +62,9 @@ | |||
| 62 | /* NetBSD 5.0 mis-defines NULL. */ | 62 | /* NetBSD 5.0 mis-defines NULL. */ |
| 63 | #include <stddef.h> | 63 | #include <stddef.h> |
| 64 | 64 | ||
| 65 | /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */ | 65 | /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. |
| 66 | #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS | 66 | glibc 2.40 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */ |
| 67 | #if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP) | ||
| 67 | # include <sys/wait.h> | 68 | # include <sys/wait.h> |
| 68 | #endif | 69 | #endif |
| 69 | 70 | ||
diff --git a/lib/string.in.h b/lib/string.in.h index 1bae32ad465..ce488299006 100644 --- a/lib/string.in.h +++ b/lib/string.in.h | |||
| @@ -1077,6 +1077,22 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " | |||
| 1077 | /* The following functions are not specified by POSIX. They are gnulib | 1077 | /* The following functions are not specified by POSIX. They are gnulib |
| 1078 | extensions. */ | 1078 | extensions. */ |
| 1079 | 1079 | ||
| 1080 | #if @GNULIB_STR_STARTSWITH@ | ||
| 1081 | /* Returns true if STRING starts with PREFIX. | ||
| 1082 | Returns false otherwise. */ | ||
| 1083 | _GL_EXTERN_C bool str_startswith (const char *string, const char *prefix) | ||
| 1084 | _GL_ATTRIBUTE_PURE | ||
| 1085 | _GL_ARG_NONNULL ((1, 2)); | ||
| 1086 | #endif | ||
| 1087 | |||
| 1088 | #if @GNULIB_STR_ENDSWITH@ | ||
| 1089 | /* Returns true if STRING ends with SUFFIX. | ||
| 1090 | Returns false otherwise. */ | ||
| 1091 | _GL_EXTERN_C bool str_endswith (const char *string, const char *prefix) | ||
| 1092 | _GL_ATTRIBUTE_PURE | ||
| 1093 | _GL_ARG_NONNULL ((1, 2)); | ||
| 1094 | #endif | ||
| 1095 | |||
| 1080 | #if @GNULIB_MBSLEN@ | 1096 | #if @GNULIB_MBSLEN@ |
| 1081 | /* Return the number of multibyte characters in the character string STRING. | 1097 | /* Return the number of multibyte characters in the character string STRING. |
| 1082 | This considers multibyte characters, unlike strlen, which counts bytes. */ | 1098 | This considers multibyte characters, unlike strlen, which counts bytes. */ |
| @@ -1301,6 +1317,26 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, | |||
| 1301 | _GL_ARG_NONNULL ((2, 3)); | 1317 | _GL_ARG_NONNULL ((2, 3)); |
| 1302 | #endif | 1318 | #endif |
| 1303 | 1319 | ||
| 1320 | #if @GNULIB_MBS_STARTSWITH@ | ||
| 1321 | /* Returns true if STRING starts with PREFIX. | ||
| 1322 | Returns false otherwise. */ | ||
| 1323 | _GL_EXTERN_C bool mbs_startswith (const char *string, const char *prefix) | ||
| 1324 | _GL_ATTRIBUTE_PURE | ||
| 1325 | _GL_ARG_NONNULL ((1, 2)); | ||
| 1326 | /* No extra code is needed for multibyte locales for this function. */ | ||
| 1327 | # define mbs_startswith str_startswith | ||
| 1328 | #endif | ||
| 1329 | |||
| 1330 | #if @GNULIB_MBS_ENDSWITH@ | ||
| 1331 | /* Returns true if STRING ends with SUFFIX. | ||
| 1332 | Returns false otherwise. | ||
| 1333 | Unlike str_endswith(), this function works correctly in multibyte locales. | ||
| 1334 | */ | ||
| 1335 | _GL_EXTERN_C bool mbs_endswith (const char *string, const char *suffix) | ||
| 1336 | _GL_ATTRIBUTE_PURE | ||
| 1337 | _GL_ARG_NONNULL ((1, 2)); | ||
| 1338 | #endif | ||
| 1339 | |||
| 1304 | /* Map any int, typically from errno, into an error message. */ | 1340 | /* Map any int, typically from errno, into an error message. */ |
| 1305 | #if @GNULIB_STRERROR@ | 1341 | #if @GNULIB_STRERROR@ |
| 1306 | # if @REPLACE_STRERROR@ | 1342 | # if @REPLACE_STRERROR@ |
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h index fd3e28fd8e0..a06725020d2 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h | |||
| @@ -165,12 +165,18 @@ | |||
| 165 | 165 | ||
| 166 | #if @HAVE_WINSOCK2_H@ | 166 | #if @HAVE_WINSOCK2_H@ |
| 167 | 167 | ||
| 168 | /* Define type 'suseconds_t'. */ | ||
| 169 | # if !GNULIB_defined_suseconds_t | ||
| 170 | typedef int suseconds_t; | ||
| 171 | # define GNULIB_defined_suseconds_t 1 | ||
| 172 | # endif | ||
| 173 | |||
| 168 | # if !GNULIB_defined_rpl_fd_isset | 174 | # if !GNULIB_defined_rpl_fd_isset |
| 169 | 175 | ||
| 170 | /* Re-define FD_ISSET to avoid a WSA call while we are not using | 176 | /* Re-define FD_ISSET to avoid a WSA call while we are not using |
| 171 | network sockets. */ | 177 | network sockets. */ |
| 172 | static int | 178 | static int |
| 173 | rpl_fd_isset (SOCKET fd, fd_set * set) | 179 | rpl_fd_isset (SOCKET fd, const fd_set * set) |
| 174 | { | 180 | { |
| 175 | u_int i; | 181 | u_int i; |
| 176 | if (set == NULL) | 182 | if (set == NULL) |