Commit Graph

685 Commits

Author SHA1 Message Date
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
Guillem Jover
6777eb62b8 pwcache: Do not declare uidtb and gidtb when not used
When the system provides implementations for user_from_uid() or
group_from_gid() we are not using these variables, so better not declare
them.

Fixes: commit 21d12b0211
2023-09-05 03:02:20 +02:00
Guillem Jover
d4e0cdc916 fgetln: Include <stdio.h> after <sys/*>
The <sys/*> headers tend to define things that might be used by other
headers, so while they should be self-contained, it is better to simply
include them first.
2023-09-05 03:02:20 +02:00
Guillem Jover
f41d6c12aa build: Refactor GNU .init_array support check into a new m4 function 2023-09-05 03:02:12 +02:00
Guillem Jover
30b48ed9ea build: Refactor linker script detection into a new m4 function 2023-07-29 20:11:53 +02:00
Guillem Jover
d0d8d0197f build: Do not provide prototypes for arc4random() on Solaris
These functions are provided by the system.
2023-07-29 20:11:53 +02:00
Guillem Jover
cf61ebb845 build: Do not build the progname module if it is not needed
This was made conditional, but the code part was accidentally left
untouched due to having ported it locally to use __progname, which
caused build failures on the stock repo.

Fixes: commit 046621d7967e7a0f08ae988bcf7e4cd1b6cf204c
2023-07-29 20:11:53 +02:00
Guillem Jover
73b25a8f87 build: Sort entries alphabetically 2023-04-29 03:53:52 +02:00
Guillem Jover
5434ba169b build: Conditionalize wcslcpy() and wcslcat() functions on macOS
These functions are provided by the system libc.
2023-04-29 03:52:49 +02:00
Guillem Jover
dc1bd1a2cb build: Conditionalize only id-from-name functions not the entire pwcache
On macOS the name-from-id functions are present, but not the
id-from-name ones, so we want to provide those instead of suppressing
the entire file.
2023-04-29 03:52:42 +02:00
Guillem Jover
edc746ea7b build: Conditionalize getprogname()/setprogname on macOS
These functions are provided by the system libc, so there is no need for
us to provide them.
2023-04-22 22:47:33 +02:00
Guillem Jover
8f998d1d20 progname: Include <procinfo.h> if available
We need this header on AIX. Missed transplanting the code from the AIX
porting system.

Fixes: commit 9fa06763a1
2023-04-22 22:42:30 +02:00
Guillem Jover
d08163b4fe build: Check whether we need libperfstat on AIX
The getentropy() implementation makes use of this library on AIX.
2023-04-22 19:30:15 +02:00
Guillem Jover
1186cf8822 build: Annotate droppable functions for musl on next SOVERSION bump
These are already provided by the musl libc, and can thus be dropped on
the next SOVERSION bump.
2023-04-22 19:30:15 +02:00
Guillem Jover
6385ccc977 build: Conditionalize bsd_getopt() on macOS
The system library provides a getopt() with BSD semantics.
2023-04-22 19:30:05 +02:00
Guillem Jover
c12068179c Move the version script comments before the symbols
When generating the .sym export file from the .map file, we are not
stripping these comments that are part of the same line as the symbol,
which causes ld(1) implementations to error out. Moving them before
the symbols avoids the need to strip them, as we are only keeping
actual symbol lines.
2023-04-21 05:20:27 +02:00
Guillem Jover
9fa06763a1 Port getprogname() to AIX
Get the program name from the COMM field from the proc filesystem.

We could use instead the information from the psinfo binary file under
/proc, but that seems to have a shorter string limit.
2023-04-21 05:20:27 +02:00
Guillem Jover
92337b15a2 Make getprogname() porting mandatory
Although the function is documented as possibly returning NULL if it
cannot find a known source of information, we should still at least
attempt to port it to any supported system, and otherwise explicitly
mark it as not implementable for such systems if that was to be the
case.
2023-04-21 05:20:27 +02:00
Guillem Jover
90b7f3aeba test: Do not use /dev/null as compiler output file
Some ld(1) implementations, such as the one on AIX, do not support using
/dev/null as the output filename for the compiled object.

Use an actual filename that we will then clean up.
2023-04-18 01:09:05 +02:00
Guillem Jover
426bf45278 build: Add generated *.sym files to .gitignore 2023-04-18 01:09:05 +02:00
Guillem Jover
21d12b0211 build: On macOS do not build functions provided by the system
We have never built before on macOS, so we can exclude all the functions
that are currently provided in the system.

Closes: #1
Closes: !3
2023-04-17 04:12:42 +02:00
Guillem Jover
bc65806ce2 build: Select whether to include funopen() in the build system
This makes sure we include it when expected, alongside the man pages,
and the test cases, and do not accidentally break the ABI if the system
starts providing such interface.
2023-04-17 04:12:42 +02:00
Guillem Jover
8b7a4d9d3b build: Move Windows OS detection to the OS features section
This was placed here to make use of the same AS_CASE, but it does not
really fit with the section. Move it to the more appropriate place, and
detangle the AS_CASE.
2023-04-17 04:12:42 +02:00
Guillem Jover
ccbfd1c241 build: Remove __MUSL__ definition from configure
We stopped relying on this macro when we turned the funopen() cpp error
into a warning in commit e50896286c.
2023-04-17 04:12:42 +02:00
Guillem Jover
e0976d7e90 build: Add a new libbsd_strong_alias() macro and switch users to it
We had several cases of code needing a strong alias, so we switch those
to use the new macro. This covers systems that support the alias
attribute and others such as macOS where we need to use assembler
directives to add the alias as the attribute is not supported.
2023-04-17 04:12:42 +02:00