Commit Graph

709 Commits

Author SHA1 Message Date
Guillem Jover
04a24db27a Release libbsd 0.12.2 2024-03-18 03:17:06 +01:00
Sam James
b62f36f305 test: nlist: make resilient against -Wl,--gc-sections
With linker sections GC enabled, we get a test failure in `nlist.c`:
```
nlist: nlist.c:72: main: Assertion `rc == 0' failed.
```

This turns out to be because several sections used by the test can be discarded:
```
ld: removing unused section '.text.func_pub' in file 'nlist.o'
ld: removing unused section '.bss.data_pub_uninit' in file 'nlist.o'
ld: removing unused section '.data.data_pub_init' in file 'nlist.o'
```

Reproduced with `CFLAGS="-Og -fdata-sections -ffunction-sections"` and
`LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,-z,start-stop-gc"`.

Additionally, `LDFLAGS="... -Wl,--print-gc-sections"` can help with diagnosing
which sections get removed.

We already mark these symbols as `used`, but we need `retain` [0] for them
to survive linker GC too.

[0] https://releases.llvm.org/18.1.0/tools/lld/docs/ELF/start-stop-gc.html#annotate-c-identifier-name-sections

Closes: !29
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2024-03-14 09:33:34 +01:00
Guillem Jover
2a3d521318 build: Do not rely on internal autoconf ac_cv_sys_file_offset_bits variable
This is an internal implementation detail from AC_SYS_LARGEFILE, which
happened to change with autoconf 2.72. Instead compute our own size
for off_t.

Closes: #28
2024-03-14 02:00:36 +01:00
Guillem Jover
149aafe198 build: Use -eq instead of = as test operators for arithmetic tests 2024-03-14 01:59:19 +01:00
Guillem Jover
435825784f build: Fix typo in ABI selection description 2024-03-13 00:56:59 +01:00
Guillem Jover
31e9396bf2 build: Only install time struct conversion macros where missing
These macros are available in several systems, and we should not install
the man pages for them, otherwise we might end up shadowing the system
man pages if present.
2024-03-13 00:56:07 +01:00
Guillem Jover
3b8416acab man: Add links for errc module functions
Reported-by: Alejandro Colomar <alx@kernel.org>
2024-03-11 03:40:39 +01:00
Guillem Jover
94d0fb3c53 man: Do not install timeval(3bsd) nor timespec(3bsd)
These are system types, which we should not be documenting. Rewrite the
man pages around the TIMEVAL_TO_TIMESPEC and TIMESPEC_TO_TIMEVAL macros.
2024-03-11 03:40:26 +01:00
Duncan Overbruck
e848f5aa29 strtonum: Do not abort on EINVAL from strtoi()
With musl libc strtoimax(".", ...) returns EINVAL.

Closes: !28
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2024-03-06 02:22:11 +01:00
Duncan Overbruck
ee63bca525 closefrom: Ignore files starting with dot when scanning /proc/self/fd
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2024-03-06 02:22:11 +01:00
Guillem Jover
9cbd935d92 build: Match also gnu* for GNU/Hurd on the glibc ABI selection
The GNU/Hurd system does not specify a kernel part, so we need to match
on both *-gnu* and gnu* (to avoid overmatching with just *gnu*).
2024-03-06 02:22:04 +01:00
Guillem Jover
70f49a7028 Release libbsd 0.12.1 2024-02-28 04:50:34 +01:00
Guillem Jover
b6ccd03201 build: Add a comment to libbsd-overlay.pc about -isystem usage
Add the reasoning for why we use -isystem instead of -I, to avoid
confusing unsuspecting readers of the file.

Prompted-by: Alejandro Colomar <alx@kernel.org>
2024-02-28 04:44:02 +01:00
Guillem Jover
08188f3c13 build: Install err.h if either of the err or errc modules are built
Both modules expose their functions in err.h, so we need to install it
whenever any of them is being built.

Reported-by: Alejandro Colomar <alx@kernel.org>
2024-02-28 04:37:44 +01:00
Guillem Jover
644062da40 Release libbsd 0.12.0 2024-02-27 05:52:53 +01:00
Guillem Jover
32d18dcf47 Add explicit time32 and time64 support
Handle the three potential system scenarios:

 - system time_t is time64
 - system time_t is time32 and supports time64
 - system time_t is time32 and does not support time64

Add the explicit time32 and time64 functions when necessary and map
them accordingly for each of these cases.
2024-02-27 05:47:50 +01:00
Guillem Jover
605614d642 build: Add support for AIX 2024-02-25 04:19:24 +01:00
Guillem Jover
ec7f5ee984 Add vasprintf() and asprintf() functions missing on AIX
These functions are used by code in the library, even though these
functions started as GNU extensions, they are present in all BSDs,
so we expose them as part of our interface on AIX.
2024-02-25 04:18:51 +01:00
Guillem Jover
5392f0c1a4 build: Add support for Solaris 2024-02-25 04:18:01 +01:00
Guillem Jover
be4aced4c5 build: Make almost all exposed interfaces use the new ABI selection
Explicitly select what to include as part of the target ABI, instead of
letting autoconfiguration potentially break ABI if the system grows
functionality provided by the library.

Make almost all the library selectable per target. Do not install manual
pages for interfaces not included in the library. Control inclusion of
symbols in map file via pre-processor macros, and move the comments
describing the ABI selection to configure.ac.

For now the header files are included as is and filtered through
pre-processor conditionals. Eventually they might get switched to be
autogenerated at build time.
2024-02-25 03:50:40 +01:00
Guillem Jover
27503a1066 build: Rework ABI selection logic
Add a new LIBBSD_SELECT_ABI m4 macro, and use it to setup the ABI
interfaces to expose and the various variables and conditionals
to be used by the build system.

Switch to set the initial values to unknown and then set every one
of the selections explicitly by supported target.

Update comments for rationale for things to DROP, or for why some
selections are enabled.
2024-02-25 03:49:15 +01:00
Guillem Jover
99739877be build: Rename ABI selection variables from need_ to abi_
This should make the purpose of these variables more clear.
2024-02-25 03:47:54 +01:00
Guillem Jover
0bdbc0787e build: Revert accidental testing aid change
This was accidentally included in the commit, but should have only been
used during development.

Fixes: commit de124dcafa
Changelog: silent
2024-02-21 02:29:15 +01:00
Guillem Jover
de124dcafa build: Make digest function checks conditional on their use
The digest function checks where unconditionally requiring the functions
to exist or they would error out. But these functions are not required
on all systems, they depend on the ABI to be exposed.
2024-02-21 02:25:24 +01:00
Guillem Jover
1d28729514 build: Move ABI selection at the top of configure.ac
Merge the existing host_os block for the OS detection with the ABI
selection one, as these are related. This way we will be able to make
some of the latter checks conditional on the selected ABI.
2024-02-21 02:25:21 +01:00
Guillem Jover
a81d0b7113 build: Sort variables and their contents in automake files
This should make it easier to add new entries, and find them afterwards.
2024-02-21 02:09:48 +01:00
Guillem Jover
c8e5338a7c build: Rename LIBBSD_ABI to SOVERSION
This matches the semantics of the variable, and makes it independent of
the project, just as the package variables.
2024-02-21 02:09:48 +01:00
Guillem Jover
b6d6da4cd4 build: Refactor function checks into a new libbsd-funcs.m4 file
These are complex enough to clutter the main configure.ac. Move them
into their own file.
2024-02-21 02:09:48 +01:00
Guillem Jover
f8cb9d8b28 build: Remove space before shell redirection
This makes it more clear what the redirection applies to.
2024-02-21 02:09:17 +01:00
Guillem Jover
154624ab45 build: Add support for silent rules for the libbsd.map generation
The new rule was introduced w/o silent rule support.

Fixes: commit 19e06407eb
2024-02-21 02:07:38 +01:00
Guillem Jover
9fab225f26 Split errc family of functions from err ones
On most systems the err family of functions is already present, but are
missing the errc family of functions, which are also present on some
other systems. Splitting them into separate files will make it easer to
conditionally include one or the other.
2024-02-18 14:02:32 +01:00
Guillem Jover
461f10ac57 Sync strtoi()/strtou() implementations from NetBSD
These contain the fixes to the error handling logic.

In NetBSD the manual page for strtou.3 is generated from the strtoi.3
manual page applying some substitutions, the problem is that the
cross-references are then lost. We will still keep them separate.

Reported-by: Alejandro Colomar <alx@kernel.org>
2024-02-18 13:57:04 +01:00
Guillem Jover
f050160976 build: Swap symbol and alias arguments order in macros creating aliases
The current order is rather confusing, pass the real symbol first
and the alias we want to create next.
2024-02-18 13:57:03 +01:00
Guillem Jover
19e06407eb build: Generate the map file from the configured ABI
Some linkers require the map file definitions to contain only symbols
that are present on the linked object, either in the map file or in the
sym file we generate from the map file.

This is preparatory work to be able to conditionally include symbols
in the man and sym files depending on the ABI definitions.
2024-02-18 13:54:13 +01:00
Guillem Jover
10920c3084 build: Make name_from_id man pages conditional instead of id_from_name
The code is only making the name_from_id function conditional, and
assumes id_from_name are always to be included, so we need to match
the logic for the man page inclusion.
2024-02-17 05:00:58 +01:00
Guillem Jover
97b0fe84b8 man: Mention that funopen() can be made available on musl
As musl got fopencookie() implemented in 1.1.19, the funopen() function
can also be provided there. Note this in the documentation.
2024-01-09 00:00:06 +01:00
Guillem Jover
e87ae3be19 man: Fix manual page references
When referring to another manual page and their section number, we need
to use Xr instead of Fn, otherwise the section number is interpreted as
a function argument. For functions provided by libbsd itself we should
be using the 3bsd section instead of 3.
2024-01-08 23:47:26 +01:00
Guillem Jover
9275d134e5 man: Add closefrom(), strlcpy() and strlcat() as superseded functions
These were missing from the list of functions provided by some libc
implementation.
2024-01-08 23:39:19 +01:00
Guillem Jover
304a1f831c doc: Use macOS to refer to the operating system
This is the correct spelling, instead of capitalizing it.
2024-01-08 23:37:43 +01:00
Guillem Jover
edddd806df Release libbsd 0.11.8 2024-01-08 02:16:12 +01:00
Guillem Jover
dd0bdb58e0 test: Close all descriptors before initializing them for closefrom()
On macOS, closefrom() only sets the close-on-exec flag, so we cannot
check whether all file descriptors were closed, which means that if
on entry our file descriptor table was filled after the 4th file
descriptor, then we might fail the assertions for the flags for odd
file descriptors which we expect to be closed.

This can easily happen when running the test suite in parallel mode
with «make -j8 check» for example.

Closes: #23
2024-01-08 01:58:54 +01:00
Guillem Jover
0813f3786f build: Check out-of-tree builds in CI
Make sure the out-of-tree builds do not regress.
2024-01-07 20:21:08 +01:00
Guillem Jover
df116b5597 Adjust strlcpy() and strlcat() per glibc adoption
These functions were added in glibc 2.38, in anticipation of POSIX
adopting them too.

Closes: #26
2024-01-07 17:55:40 +01:00
Guillem Jover
ecb44e1655 Do not add a pointer to the NULL constant
Warned-by: cppcheck (nullPointerArithmetic)
2024-01-07 16:45:46 +01:00
Guillem Jover
459b7f7d24 Do not confuse code analyzers with out-of-bounds array access look alike
The code is only getting the address, but we might be performing an
addressing that is out-of-bounds. Avoid it and use the address form
instead.

Warned-by: cppcheck (objectIndex)
2024-01-07 16:45:42 +01:00
Guillem Jover
a44f885cd4 test: Fix short-lived memory leak
Warned-by: cppcheck
2024-01-07 16:45:39 +01:00
Guillem Jover
3f5ca0aae4 build: Add a coverage regex to the CI job
This is needed so that gitlab can know where to extract the coverage
percentage from in the output, to be able to track and report it.
2023-10-28 00:47:26 +02:00
Guillem Jover
9d3e59a01d man: Use VARIANTS instead of ALTERNATIVES in libbsd(7)
Using alternatives seems confusing in this context.
2023-10-10 01:53:32 +02:00
Guillem Jover
f02562d64a man: Markup function references with Xr instead of Fn
These references had man page sections in them, so using Fn meant that
these appeared as function arguments.
2023-10-10 01:52:37 +02:00
Guillem Jover
b7367c9ced build: Add missing dash to macro title bar 2023-09-05 03:02:44 +02:00