Commit Graph

695 Commits

Author SHA1 Message Date
Guillem Jover
bf697b900c Add symbol redirection support
We need this to be able to select different version symbols at
compile-time.
2018-05-22 15:45:37 +02:00
Guillem Jover
f1966385b3 Fix COPYING file format
We cannot refer to a License short-name if that is not on its own
License paragraph. Split several other common License fields into
their own paragraphs to avoid this problem in the future.
2018-05-22 13:47:05 +02:00
Guillem Jover
e007233cf0 Release libbsd 0.9.0 2018-05-21 04:48:32 +02:00
Guillem Jover
3cabf46bb0 Deprecate fgetwln()
This function has the same problems as fgetln() which is already marked
as deprecated.
2018-05-21 04:48:32 +02:00
Guillem Jover
6eebc1f264 Fix typo in fgetln() linker warning 2018-05-21 04:48:32 +02:00
Guillem Jover
a1730c1063 Add Windows support for getentropy() and arc4random()
Import from OpenBSD.
2018-05-21 04:48:32 +02:00
Guillem Jover
6f68c93076 Switch strtonum() implementation from strtoll() to strtoi()
Import from NetBSD.
2018-05-21 04:48:32 +02:00
Guillem Jover
e13b1a337a Import strtoi() and strtou() functions from NetBSD 2018-05-21 04:47:28 +02:00
Guillem Jover
ef5faeb575 Update few RCS keyword contents to match BSD originals
This will slightly reduce the delta, and makes it easier to compare the
sources.
2018-05-21 04:47:28 +02:00
Guillem Jover
2d7de186e9 Update vis/unvis modules from NetBSD 2018-05-21 04:47:28 +02:00
Guillem Jover
3efad64155 Update readpassphrase() from OpenBSD 2018-05-21 04:47:28 +02:00
Guillem Jover
a6f407ab0d Update heapsort() from OpenBSD 2018-05-21 04:47:28 +02:00
Guillem Jover
21edbb4f22 Update fmtcheck() from NetBSD 2018-05-21 04:47:28 +02:00
Guillem Jover
e3979d1a7c Update humanize_number() from FreeBSD
Implements HN_IEC_PREFIXES.
2018-05-21 04:47:28 +02:00
Guillem Jover
facbddb652 Update pidfile module from FreeBSD
Use EINVAL instead of EDOOFUS. Add a missing synopsis for
pidfile_fileno() in the man page. Move the definition of struct pidfh
from libutil.h into pidfile.c following upstream change.
2018-05-21 04:47:28 +02:00
Guillem Jover
3d88c999b4 Update arc4random() headers from OpenBSD
Split Linux support into its own header separate from the generic Unix
to fix a Linux-specific issue with clone(). Reset rsp to NULL on failure.
2018-05-21 04:47:28 +02:00
Guillem Jover
e42381dc51 Update getentropy() code from OpenBSD
Includes changes to handle the Linux syscall blocking when there is not
enough entropy during boot, by switching it to non-blocking mode and
falling back to the alternative implementations. Man page URL reference
fixes. Build fixes for Mac OS X.

Fixes: https://bugs.debian.org/898088
2018-05-21 04:47:28 +02:00
Guillem Jover
993828d84e Add flopenat() function from FreeBSD 2018-05-21 03:49:26 +02:00
Guillem Jover
30b4d50754 Add __arraycount() macro from NetBSD 2018-05-21 03:36:44 +02:00
Baruch Siach
f6ed7c278b Fix build for openrisc with uClibc
uClibc defines EM_OR1K instead of EM_OPENRISC for the OpenRISC ELF
e_machine ID. Use EM_OR1K when EM_OPENRISC is not defined.

This fixes the following build failure:

In file included from nlist.c:44:0:
nlist.c: In function ‘__elf_is_okay__’:
local-elf.h:224:23: error: ‘EM_OPENRISC’ undeclared (first use in this function)
 #define ELF_TARG_MACH EM_OPENRISC
                       ^
nlist.c:77:26: note: in expansion of macro ‘ELF_TARG_MACH’
   if (ehdr->e_machine == ELF_TARG_MACH &&
                          ^

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2018-04-04 02:29:15 +02:00
Guillem Jover
1f8a3f7bcc Fix function declaration protection for glibc already providing them
On non-glibc based systems we cannot unconditionally use the
__GLIBC_PREREQ macro as it gets expanded before evaluation. Instead,
if it is undefined, define it to 0.

We should also always declare these functions on non-glibc based
systems. And on systems with a new enough glibc, which provides these
functions, we should still provide the declarations if _GNU_SOURCE
is *not* defined.

Reported-by: Jörg Krause <joerg.krause@embedded.rocks>
2018-03-13 02:28:53 +01:00
Guillem Jover
b20272f5a9 Remove <features.h> inclusion from <bsd/libutil.h>
This is a non-portable header, and we should not assume it is present.
Let the first system header pull it in if needed.
2018-03-13 02:28:53 +01:00
Guillem Jover
11ec8f1e5d Handle systems missing <sys/cdefs.h>
This is a non-portable header, and we cannot expect it to be provided by
the system libc (e.g. musl). We just need and rely on declaration that
we have defined ourselves in our own <bsd/sys/cdefs.h>. So we switch to
only ever assume that.

Fixes: https://bugs.freedesktop.org/105281
2018-03-13 02:28:53 +01:00
Guillem Jover
5ba8c5bab0 progname: Port to Windows
Define the directory separator depending on the system targetted.

Reported-by: Progyan Bhattacharya <progyanb@acm.org>
2018-03-06 01:10:14 +01:00
Guillem Jover
0093ca2b0e Handle SPARC V8+ on Sun Studio compiler 2018-03-05 00:02:34 +01:00
James Clarke
0b65d43963 Add support for ELF machine EM_SPARC32PLUS
32-bit SPARC on V8+ uses a different ELF machine type.

Fixes: https://bugs.gentoo.org/634550
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2018-03-04 23:49:25 +01:00
Guillem Jover
0b61c5ffed Release libbsd 0.8.7 2018-01-13 16:20:35 +01:00
Jason Duerstock
9ceac74e91 test: Fix nlist(3) unit test on IA64
On IA64 this is only the case in the ELF binary, but it gets normalized
when loaded at run-time.

Fixes: https://bugs.debian.org/881611
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2018-01-13 16:17:28 +01:00
Adam Lackorzynski
9afc7100a1 Fix <sys/cdefs.h> for gcc with no __has_include or __has_include_next support
Fixes: https://bugs.freedesktop.org/103396
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2018-01-13 16:17:10 +01:00
Guillem Jover
22fbd62368 Handle several functions now being provided by glibc
We mention that these are now superseded by the glibc implementations,
make the headers cope with already declared functions on glibc-based
systems, and document this in the man pages.
2017-12-03 16:43:28 +01:00
Guillem Jover
b4f7c065ba man: Document on what other BSDs arc4random(3) is present 2017-12-03 16:41:55 +01:00
Guillem Jover
bbf90ac3cd Release libbsd 0.8.6 2017-07-17 01:01:13 +02:00
Guillem Jover
2a8514d8a5 Fix handling of non-contiguous argv + envp in setproctitle()
The two arrays might not reference contiguous memory, and assuming they
are does break at least now on GNU/Hurd, which contains an unmapped
memory block between the memory used by the two arrays.

Just check that each element is strictly after the previous one, so that
we know there are no unmapped memory blocks inbetween.
2017-07-17 00:58:06 +02:00
Guillem Jover
3b2b7938f7 test: Fix nlist() unit test on IA64 and PowerPC 64-bit ELFv1
At least on IA64 and PowerPC 64-bit ELFv1, the functions are stored in
the .text sections but they are accessed through a function descriptor
stored in a data section, for example for PowerPC 64-bit ELFv1 that
section is called .opd.

We should take this into account when checking the n_type for the
functions we have requested information from nlist().

Rationale-by: James Clarke <jrtc27@jrtc27.com>
2017-06-25 02:10:26 +02:00
Guillem Jover
415e3cb266 Release libbsd 0.8.5 2017-06-24 16:10:14 +02:00
Guillem Jover
9532cb39f4 man: Update man page sections in titles and references
We have moved all man pages to section 3bsd, let's do the same for the
page title, and in all the references for uniformity and to avoid
confusions.

Fixes: https://bugs.freedesktop.org/101545
2017-06-24 16:08:27 +02:00
Guillem Jover
a4dd754c8d man: Ship and install libbsd(7)
Fixes: https://bugs.freedesktop.org/101543
2017-06-24 16:08:27 +02:00
James Cowgill
b480b7a3f8 Fix ELF definitions for MIPS in local-elf.h
Add a check for _MIPS_SIM inside the __mips__ #elif to detect mips64el
and use ELFCLASS64 in that case. Note that we can't use defined(__mips64)
here because that is also defined when the n32 ABI is in use, which uses
ELFCLASS32.

Fixes: https://bugs.debian.org/865091
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2017-06-24 16:08:22 +02:00
James Cowgill
4cc20e23f5 Fix ELF definitions for PowerPC in local-elf.h
* ppc64el defines both __powerpc__ and __powerpc64__ but since the
  __powerpc64__ #elif is below the __powerpc__ one, it will never be hit.
* Both assumed that powerpc* was big-endian.

Fixes: https://bugs.debian.org/865091
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2017-06-24 16:08:14 +02:00
Guillem Jover
c4e58c0950 test: Remove unused variable in nlist() unit test 2017-06-24 16:06:15 +02:00
Guillem Jover
736e12e8d8 test: Handle libtool executable names in getprogname() unit test
Sometimes libtool will prefix the test programs with "lt-", we should
handle these and strip the prefix.

Fixes: https://bugs.debian.org/865090
2017-06-24 16:05:50 +02:00
Guillem Jover
8bff4b1fab Release libbsd 0.8.4 2017-06-19 03:17:21 +02:00
Guillem Jover
0071b97958 Import <sys/time.h> for some of its macros
Fixes: https://bugs.freedesktop.org/94320
2017-06-19 03:17:21 +02:00
Guillem Jover
cdbb9d0555 test: Add new strnstr() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
0365d0efda test: Add new setprogname() and getprogname() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
10b1328570 test: Add new setmode() and getmode() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
922eff5c5e test: Add new nlist() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
8e8834d8e5 Remove RCSID tags
These are obsolete markers, and in some cases they repeat the
information already present in the comment header.
2017-06-19 03:17:21 +02:00
Guillem Jover
7938619254 Update .gitignore for headers generator 2017-06-19 03:17:21 +02:00
Guillem Jover
ec5d9a685a Namespace header inclusion protection macros
Use LIBBSD_, and remove trailing underscores.
2017-06-19 03:17:21 +02:00