File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed
Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,8 @@ LDLIBS=
239239# -DEPOCH_OFFSET=N if the 'time' function returns a value N greater
240240# than what POSIX specifies, assuming local time is UT.
241241# For example, N is 252460800 on AmigaOS.
242+ # -DFREE_PRESERVES_ERRNO=[01] if the 'free' function munges or preserves errno
243+ # (default is guessed)
242244# -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r
243245# on POSIX platforms predating POSIX.1-2024
244246# -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ Unreleased, experimental changes
9393 option is incompatible with POSIX.1-2024 and earlier. It also
9494 costs CPU time and memory.
9595
96+ tzfree now preserves errno, consistently with POSIX.1-2024 'free'.
97+
9698 tzcode now uses mempcpy if available, guessing its availability.
9799 Compile with -DHAVE_MEMPCPY=1 or 0 to override the guess.
98100
Original file line number Diff line number Diff line change @@ -2061,10 +2061,25 @@ tzalloc(char const *name)
20612061 return sp ;
20622062}
20632063
2064+ #ifndef FREE_PRESERVES_ERRNO
2065+ # if ((defined _POSIX_VERSION && 202405 <= _POSIX_VERSION ) \
2066+ || (defined __GLIBC__ && 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__ )) \
2067+ || defined __OpenBSD__ || defined __sun )
2068+ # define FREE_PRESERVES_ERRNO 1
2069+ # else
2070+ # define FREE_PRESERVES_ERRNO 0
2071+ # endif
2072+ #endif
2073+
20642074void
20652075tzfree (timezone_t sp )
20662076{
2077+ int err ;
2078+ if (!FREE_PRESERVES_ERRNO )
2079+ err = errno ;
20672080 free (sp );
2081+ if (!FREE_PRESERVES_ERRNO )
2082+ errno = err ;
20682083}
20692084
20702085/*
Original file line number Diff line number Diff line change @@ -379,6 +379,10 @@ If successful, the
379379function returns a nonnull pointer to the newly allocated object.
380380Otherwise, it returns a null pointer and sets
381381.IR errno .
382+ The
383+ .B tzfree
384+ function does not modify
385+ .IR errno .
382386.SH ERRORS
383387.TP
384388.B EOVERFLOW
You can’t perform that action at this time.
0 commit comments