Commit Graph

600 Commits

Author SHA1 Message Date
Guillem Jover
00b538ffa3 build: Terminate lists in variables with «# EOL»
This means we can add a trailing «\» to every element, so that they
can be removed without requiring modification of other lines, and can
be easily sorted.

Replace the old usage of $(nil) which could possibly end up with junk
added if such variable is ever defined, in the environment.
2022-11-23 23:44:09 +01:00
Guillem Jover
5cfa39e5cd build: Use «yes» instead of «true» for AC_CHECK_FUNCS cache value
This autoconf macro sets the ac_cv_func_ cached variable to «yes» not
«true» so we were checking for an impossible condition.
2022-11-23 23:42:49 +01:00
Guillem Jover
084911ce87 Release libbsd 0.11.7 2022-10-06 04:07:52 +02:00
Guillem Jover
3538d38fe7 man: Discourage using the library in non-overlay mode
This makes code using it non-portable, and requires the namespeced
headers from libbsd, instead of any generic system headers. It also
requires more code changes than the overlay mode.
2022-10-06 03:59:33 +02:00
Guillem Jover
03fccd1505 include: Adjust reallocarray() per glibc adoption
On glibc 2.29 reallocarray() was moved to _DEFAULT_SOURCE.

Closes: !20
Based-on-patch-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-10-05 12:31:49 +02:00
Callum Farmer
6b6e686b23 include: Adjust arc4random() per glibc adoption
Some arc4random functions were added in glibc 2.36.

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-10-05 12:31:49 +02:00
Callum Farmer
da1f45ac71 include: explicit_bzero() requires _DEFAULT_SOURCE
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-10-05 12:15:36 +02:00
Guillem Jover
2f9eddc277 include: Simplify glibc version dependent macro handling
We test once whether __GLIBC__ is not defined, so we do not need to test
whether it is on the OR branch afterwards. We decouple the glibc version
restriction check from the _*_SOURCE variable, as that contains an
implicit opposite version check.
2022-10-05 12:12:34 +02:00
Guillem Jover
28298ac037 doc: Switch references from pkg-config to pkgconf
The former used to be the reference implementation, but it has been
stagnant to the point of not showing much signs of life. Switch to
the currently active and more complete implementation for references.
2022-10-05 01:36:28 +02:00
Guillem Jover
ef981f930b doc: Add missing empty line to separate README sections 2022-10-04 04:29:37 +02:00
Guillem Jover
6928d7895e doc: Refer to the main git repository as primary 2022-10-04 04:29:37 +02:00
Guillem Jover
d5865759f8 test: Fix explicit_bzero() test on the Hurd
On the Hurd a small read(3) might end up (indirectly) copying the data
on the stack, which we will end up finding even when we have cleared
the buffer.

To avoid these side effects, we add a new function, that we force not
to be inlined, so that we can reuse the same stack space, that will
blank any possible stack side effects. This should be portable
regardless of stack growing up or down.

Diagnosis-by: Samuel Thibault <sthibault@debian.org>
2022-10-04 04:29:37 +02:00
Guillem Jover
be327c6ebe fgetwln: Add comment about lack of getwline(3) for recommendation
Ideally we'd recommend getwline(3), but unfortunately even though it
was part of the ISO/IEC TR 24731-2:2010 draft, it did not make it into
C11 and is not widely implemented.
2022-10-04 04:29:07 +02:00
Guillem Jover
a14612d968 setmode: Dot not use saveset after free
While we are only doing a pointer difference and not dereferencing it,
it's easier and more correct to do the pointer difference before passing
it to reallocarray().

Warned-by: gcc
2022-08-23 23:51:05 +02:00
Guillem Jover
f4baceb82c man: Rewrite gerprogname(3bsd) from scratch
This gets rid of one of the last man pages with a BSD-4-clause license.
2022-08-03 11:39:31 +02:00
Guillem Jover
f35c545847 man: Lowercase man page title
While using fully uppercase man page titles has been the usual
convention for a very long time, it is rather ugly and something that
some other projects are switching away from.
2022-08-03 11:39:31 +02:00
Guillem Jover
b466b14afb man: Document that some arc4random(3) functions are now in glibc 2.36 2022-08-03 11:39:31 +02:00
Guillem Jover
1f6a48b209 Sync arc4random(3) implementation from OpenBSD
Closes: #12
2022-08-03 11:39:31 +02:00
Fabrice Fontaine
873639ebb5 Fix ELF support for big endian SH
Fix the following build failure with big endian SH (e.g. sh4aeb):

  ,---
  In file included from nlist.c:44:
  nlist.c: In function '__elf_is_okay__':
  local-elf.h:223:25: error: 'ELFDATA2LMSB' undeclared (first use in this function); did you mean 'ELFDATA2LSB'?
    223 | #define ELF_TARG_DATA   ELFDATA2LMSB
        |                         ^~~~~~~~~~~~
  `---

Fixes: http://autobuild.buildroot.org/results/2980fb79c208454195d77383f1ece9afbd7f981b
Closes: !19
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-06-08 11:51:55 +02:00
Guillem Jover
c9c78fdfd0 man: Use -compact also for alternative functions in libbsd(7)
The other function lists use the compact mode, let's be uniform about
this.
2022-06-08 11:50:47 +02:00
Guillem Jover
5f21307570 getentropy: Fix function cast for getauxval()
Fix also the Hurd implementation, missed in the original fix.

Extends: commit 72a82ee262
Warned-by: gcc
2022-06-08 11:49:16 +02:00
Guillem Jover
84acf21568 Release libbsd 0.11.6 2022-03-30 23:09:35 +02:00
WANG Xuerui
15200ec7ac Add LoongArch support to nlist()
Closes: !13
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-03-30 23:03:56 +02:00
Guillem Jover
f7465b93ec man: Document when functions were added to musl in libbsd(7)
The explicit_bzero(3) and reallocarray(3) functions are also present on
musl libc, mention it in the superseded section.
2022-03-30 22:58:47 +02:00
Guilherme Janczak
e5ed5fdd62 Remove arc4random() OpenBSD support
The arc4random() support for OpenBSD does not build. The intention was
to include any portability code so that the library could be easily
ported to such systems, but it makes little sense to build it on OpenBSD
where most of the functionality will be already present, or the software
would have been ported anyway.

[guillem@hadrons.org: Reword commit message to add rationale. ]

Closes: !15
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-03-30 22:55:56 +02:00
Duncan Overbruck
abb1a6b1a7 build: Add alpine to CI for tests with musl libc
Closes: !18
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-29 15:03:08 +01:00
Guillem Jover
c9ff83687c test: Import explicit_bzero and strtonum test cases from OpenBSD
- Remove trailing spaces.
- Declare file-scope functions and variables static.
- Declare functions with a proper prototype.
- Do not mix declarations and code for C90 conformance.
- Do not compare size_t and ssize_t variables.
2022-01-29 14:54:24 +01:00
Guillem Jover
62e67bb49e build: Sort test programs in .gitignore 2022-01-29 14:52:39 +01:00
Duncan Overbruck
87b1307040 test: Add fpurge() test case using open_memstream(3) FILE
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-29 14:10:55 +01:00
Duncan Overbruck
ba3c46b30f fpurge: Make it work with non fd based FILEs
Streams opened with for example open_memstream(3) will have no associated
file descriptor, and fileno(3) will fail.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-26 04:42:09 +01:00
Duncan Overbruck
091097e062 test: Remove static FILE declaration from fpurge test
This does not work with libcs that do not declare the structure
in a header file, like musl. And gets in the way of supporting
non-fd based streams.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-26 04:39:42 +01:00
Guillem Jover
5f9608c775 Release libbsd 0.11.5 2022-01-25 01:48:29 +01:00
Guillem Jover
eef07993c9 Revert "build: Add missing proctitle unit test program"
This reverts commit beafad2657.

This test was already handled later on as part of the BUILD_LIBBSD_CTOR
conditional. Adding it to the unconditional set made the build fail when
the system does not have GNU .init_array section support.

Closes: #9
Analysis-by: Duncan Overbruck <mail@duncano.de>
2022-01-25 01:41:14 +01:00
Guillem Jover
c6d589bc71 Document how to build from git and from a tarball release
Closes: #8
2022-01-23 21:09:05 +01:00
Guillem Jover
2975d809a0 build: Check for objdump explicitly
We should not assume that something will implicitly check for this tool,
as we need it ourselves, and this is an internal implementation detail
of right now libtool.

Fixes: commit f11ab67223
2022-01-23 20:52:26 +01:00
Sam James
f11ab67223 build: Respect $(OBJDUMP)
We already search for it in `./configure` so let's respect
the result of that search.

This helps with cross-compilation and any other cases
where one might want to choose a different toolchain.

Closes: !16
Bug: https://bugs.gentoo.org/831863
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-23 18:42:01 +01:00
Guillem Jover
54796231c7 Release libbsd 0.11.4 2022-01-22 22:41:51 +01:00
Guillem Jover
7aed0edf73 man: Add missing comma in .Dd for tree(3)
Reported-by: Thorsten Glaser <tg@mirbsd.de>
2021-12-02 00:35:40 +01:00
Guillem Jover
fafcc397ac man: Update tree(3) man page from OpenBSD
This man page has a BSD-3-clause-author license instead of the old
BSD-4-clause license.
2021-12-01 04:17:11 +01:00
Guillem Jover
48107fc8c4 build: Clarify link-time warnings
Mention the involved function instead of stating an implicit "this
function". Mention libbsd when proposing using an alternative libmd
to make the context clear.
2021-12-01 04:17:11 +01:00
Guillem Jover
e7cf8c5785 Switch md5 compatibility logic back to direct linking
When using the recent dlsym() based wrapper, we are not requiring any
symbol from libmd, as we resolve those dynamically at run-time. We were
ending up linking against libmd because in another part of the code we
require (depending on the architecture) the SHA512 functions for the
getentropy() local implementation. But that function might be provided
by the system libc on some systems, which means we end up not linking
against libmd at all.

To solve this we go back to the previous simpler solution of linking
directly, which had the main drawback of then making programs fail to
link when not specifying -lmd (on platforms that need it). And then
switch the .so link point from a symlink to a linker script, so that we
can inject the -lmd library as-needed. This is similar to what glibc is
doing.

Fixes: commit 31f034e386
2021-12-01 04:14:35 +01:00
Guillem Jover
25d35625eb build: Split libmd dependency due to MD5 functions from SHA requirements
To be able to rework the md5 deprecation logic, we need to detangle when
we depend on libmd due to requiring MD5 functions, which might be
otherwise provided by libc, or when we require SHA functions for the
internal getentropy() implementation.
2021-11-28 22:40:58 +01:00
Guillem Jover
500b3080a2 build: Add new libbsd_symver_weak() macro
We will use it for the reworked md5 deprecation logic.
2021-11-28 22:34:59 +01:00
Guillem Jover
1eba406021 test: Check that strdup() does not fail
Warned-by: gcc
2021-11-27 23:42:37 +01:00
Guillem Jover
8ad7570c20 getentropy: Add missing prototype for BSD variant
Warned-by: gcc
2021-11-27 23:42:37 +01:00
Guillem Jover
43a8270317 nlist: Remove condition which is always true
The nlist() function is limited to handle ELF binaries of the same class
as size as the size_t of the architecture built.

In addition the SIZE_T_MAX macro is BSD specific, and was falling back
to the wrong constant on most 64-bit non-BSD systems.

Warned-by: gcc
2021-11-27 23:36:34 +01:00
Guillem Jover
6a71b24b63 build: Append __ after __attribute and __typeof keywords
Be consistent with other usages in the code base.
2021-11-27 22:53:32 +01:00
Guillem Jover
7389fe8d24 build: Ignore backup files 2021-11-27 06:54:49 +01:00
Victor Westerhuis
2716dfd0b7 test: Explicitly mark symbols as used
Because some of the symbols are not otherwise referenced, GCC would like
to remove them.

Closes: !14
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2021-11-27 06:52:17 +01:00
Victor Westerhuis
54f8745657 build: Enable .init_array support when building with LTO
Because these symbols are not otherwise referenced, GCC would like
to remove them.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2021-11-27 06:51:02 +01:00