Commit Graph

179 Commits

Author SHA1 Message Date
Guillem Jover
ec5d9a685a Namespace header inclusion protection macros
Use LIBBSD_, and remove trailing underscores.
2017-06-19 03:17:21 +02:00
Guillem Jover
e8d340de9e Remove a.out support from nlist()
Some libc libraries do not have an <a.out.h> header. And a.out as an
executable format is very much obsolete on pretty much all currently
supported systems, even if they might still support loading such
objects.

Remove the a.out support to increase portability.
2017-06-19 03:17:21 +02:00
Guillem Jover
07c76b666d Do not use legacy BSD u_* types
Some systems do not have these types available, and they are simply
convenience aliases. Instead use the expanded versions which are more
portable.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=101192
2017-06-05 06:18:27 +02:00
Guillem Jover
e4475738fe Try <linux/a.out.h> if <a.out.h> is not present
At least musl ships the former but not the latter.
2017-06-05 05:52:07 +02:00
Guillem Jover
db7470b048 Gracefully handle lack of system <sys/cdefs.h>
This is the case on musl.

Fixes: https://bugs.debian.org/810589
2017-06-05 05:52:07 +02:00
Guillem Jover
337e620275 Support GCC deprecated attribute for GCC older than 4.5
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=99190
Based-on-patch-by: Eric Smith <brouhaha@fedoraproject.org>
2017-06-05 05:51:52 +02:00
Guillem Jover
cdf998a056 Turn <bsd/bsd.h> inert when using LIBBSD_OVERLAY
Also print a warning stating this fact.
2015-12-14 00:58:59 +01:00
Guillem Jover
2c77ad593c Add missing include to <md5.h>
The header was not self-contained, it was missing definitions for some
types included in <sys/types.h>.
2015-12-14 00:58:59 +01:00
Guillem Jover
48ac79b188 Use the non-overlayed libbsd headers when we need our own definitions 2015-12-14 00:58:51 +01:00
Guillem Jover
6bcb1312f4 Relicense my contribution to BSD-2-clause
This avoids having two licenses on the same file.
2015-12-07 03:24:47 +01:00
Guillem Jover
45443583df Add explicit_bzero() function from OpenBSD 2015-09-24 05:47:58 +02:00
Guillem Jover
ee26e59e72 Mark functions handling format strings with __printflike 2015-09-23 07:59:34 +02:00
Guillem Jover
151bc71d64 Add compile and link-time deprecation warnings for fgetln()
Although the current implementation in libbsd is probably one of the
safest ones around, it still poses some problems when used with many
file streams. This function has now a replacement, that is both more
standard and portable. Ask users to switch to getline(3) instead.
2015-09-23 07:59:34 +02:00
Guillem Jover
c7e01e9884 Sync queue(3) from FreeBSD
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85147
2015-09-23 07:59:34 +02:00
Guillem Jover
3267114483 Add __offsetof, __rangeof and __containerof to sys/cdefs.h
Import and adapt from FreeBSD.
2015-09-23 07:59:27 +02:00
Guillem Jover
0e4e3ab269 Add __DECONST, __DEVOLATILE and __DEQUALIFY macros to sys/cdefs.h
Import from FreeBSD.
2015-09-23 07:59:24 +02:00
Guillem Jover
02b55488c5 Use stdint integer types instead of BSD legacy ones 2015-09-23 07:14:21 +02:00
Callum Davies
6378351169 Fix arc4random() and arc4random_stir() prototypes
These two functions accept no arguments.  The prototypes should reflect
this.  This change lets the compiler warn about certain (admittedly
silly) mistakes.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-08-12 12:18:13 +02:00
Benjamin Baier
faa005cb32 Add reallocarray() function from OpenBSD
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-07-17 05:13:05 +02:00
Guillem Jover
36aca8c06e Add stringlist module from NetBSD 2014-07-17 05:11:00 +02:00
Guillem Jover
e8f9300355 Add getbsize() function
Import code from DragonFlyBSD and man page from FreeBSD.
2014-07-15 10:57:42 +02:00
Guillem Jover
8d16c3df67 Add timeconv module from FreeBSD
Inline license information from FreeBSD root dir COPYRIGHT file.
2013-10-21 05:48:30 +02:00
Guillem Jover
f41fdcf186 Add funopen() function
This is a wrapper over the glibc fopencookie() function.

We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,
because seekfn() there wrongly uses fpos_t, assuming it's an integral
type, and any code using that on a system where fpos_t is a struct
(such as GNU-based systems or NetBSD) will fail to build. In which case,
as the code has to be modified anyway, we might just as well use the
correct declaration.
2013-10-21 05:35:44 +02:00
Guillem Jover
86cbff385a Handle glibc partial header inclusions
The glibc headers use selective inclusions through the __need_NAME
mechanism to avoid circular dependencies.

The problem is that if we are being overlaid, and have been requested
a partial inclusion, when we pass control to the system header, then
we might miss definitions needed by our own header, resulting in build
failures.

Workaround that by catching current partial requests, and skip the
current inclusion.
2013-10-21 05:35:17 +02:00
Guillem Jover
c5b9590287 Move setproctitle() automatic initialization to its own library
The automatic initialization cannot be part of the main shared library,
because there is no thread-safe way to change the environ global
variable. This is not a problem if the initializaion happens just at
program load time, but becomes one if the shared library is directly or
indirectly dlopen()ed during the execution of the program, which could
have either kept references to the old environ or could change it in
some other thread. This has been observed for example on systems using
Samba NSS modules.

To avoid any other possible fallout, the constructor is split into a
new static library that needs to be linked explicitly into programs
using setproctitle(). As an additional safety measure the pkg-config
linker flags will mark the program as not allowing to be dlopen()ed
so that we avoid the problem described above.

Reported-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66679
2013-07-14 13:32:11 +02:00
Guillem Jover
a97ce513e0 Add new fgetwln() function
Man page taken from FreeBSD.
2013-05-27 02:49:28 +02:00
Strake
ee0489eb2b Add new fparseln() function
Taken from NetBSD.

[guillem@hadrons.org:
 - Import from NetBSD instead of FreeBSD to get a 3-clause BSD license,
   instead of a 4-clause one.
 - Define compatibility macros.
 - Change library from libc to libbsd and header in man page.
 - Add copyright information to COPYING.
 - Add symbol to map file. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2013-05-27 02:47:32 +02:00
Guillem Jover
1be0bdb2c9 Add new strnstr() function
Taken from FreeBSD.
2013-05-27 02:12:43 +02:00
Guillem Jover
ff0d700df0 Add new wcslcat() and wcslcpy() functions
Taken from FreeBSD.
2013-05-27 02:11:59 +02:00
Guillem Jover
e7f3976088 Add email address to my name 2012-05-29 04:51:45 +02:00
Guillem Jover
e37293a18a Add <bitstring.h> for compatibility with NetBSD and OpenBSD 2012-05-29 04:51:16 +02:00
Robert Millan
4eab0cc351 Add inline endian encoding/decoding functions
Taken from FreeBSD.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2012-05-29 04:51:09 +02:00
Guillem Jover
866f73af91 Move overlay inclusions outside of header protection
Glibc tends to include standard headers with special definitions
that make few declarations or macros visible, this stomps over the
overlay #include_next <> logic.

Based-on-patch-by: Robert Millan <rmh@debian.org>
2012-05-29 04:51:04 +02:00
Guillem Jover
f71d8e0501 Remove bogus deprecation warning from <getopt.h> 2012-05-29 04:51:04 +02:00
Guillem Jover
0b96e1a218 Remove deprecated compatibility includes in headers 2012-05-29 04:51:04 +02:00
Guillem Jover
109cafb393 Remove deprecated headers 2012-05-29 04:51:04 +02:00
Robert Millan
6434858314 Add new expand_number() function
Taken from FreeBSD.

[guillem@hadrons.org:
 - Include <stdint.h> in <bsd/libutil.h>. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2012-05-29 04:50:55 +02:00
Guillem Jover
943939d0e5 Add new closefrom() function
Code taken from sudo, man page from FreeBSD.
2012-05-29 04:36:23 +02:00
Guillem Jover
dcaa93d984 build: Switch to autotools 2012-05-29 04:35:55 +02:00
Guillem Jover
059f89ca95 Add missing semicolon to bsd_getopt() declaration
Accidentally lost in commit 4a6303ba3b.
2011-07-09 22:28:00 +02:00
Guillem Jover
4a6303ba3b Constify bsd_getopt(3) arguments
This matches the standard declaration for getopt(3).
2011-06-08 02:10:38 +02:00
Guillem Jover
b891772ad6 Remove blank lines at EOF 2011-05-29 02:49:37 +02:00
Guillem Jover
b0eb19970a Move bsd_getopt() from <bsd/getopt.h> to <bsd/unistd.h>
Deprecate <bsd/getopt.h>.
2011-05-29 02:41:16 +02:00
Guillem Jover
0bf3d3913f Include the correct deprecated headeres when using the overlay 2011-05-29 02:41:15 +02:00
Guillem Jover
913cdd91b1 Do not use the same header inclusion protector for <nlist.h> and <bsd/nlist.h>
Regression introduced in commit f7caf2b30d.
2011-05-29 02:39:44 +02:00
Guillem Jover
200eeb1265 Add LIBBSD_DISABLE_DEPRECATED to deprecated headers
When enabled this will make the inclusion of deprecated headers a
fatal error so that it's easier to spot.
2011-05-29 02:39:29 +02:00
Guillem Jover
fbd622971d Condense and clarify header deprecation warnings
Mention the possibility of using libbsd-overlay.pc.
2011-05-28 10:58:26 +02:00
Guillem Jover
755d86be01 Rename LIBBSD_CLEAN_INCLUDES to LIBBSD_DISABLE_DEPRECATED 2011-05-28 10:58:26 +02:00
Guillem Jover
cd4996cebe Namespace header protector in <bsd/sys/cdefs.h> with LIBBSD_SYS_ 2011-05-28 10:58:26 +02:00
Guillem Jover
a7dd4457f5 Add new <bsd/sys/poll.h> header 2011-05-28 10:58:26 +02:00
Guillem Jover
8be40010ce Add new <bsd/sys/endian.h> header 2011-05-28 10:58:26 +02:00
Guillem Jover
e1f2a6f869 Add new __packed, __aligned and __nonnull attributes 2011-05-28 10:56:03 +02:00
Guillem Jover
87dd203c26 Define __dead2 and __pure2 to actual gcc attributes if possible 2011-05-28 10:31:07 +02:00
Guillem Jover
de2062873f Define <sys/cdefs.h> attributes conditional to the supported gcc version 2011-05-28 10:31:06 +02:00
Guillem Jover
71e5db4cde Define _SYS_CDEFS_H and _SYS_CDEFS_H after including <sys/cdefs.h>
This makes sure the “standard” inclusion protectors are in place, as at
least some FreeBSD kernel headers expect these to be defined to do some
sanity checks.
2011-05-28 10:31:06 +02:00
Guillem Jover
9d04217174 Map getopt to bsd_getopt if we are using the overlay
This will ensure the code can safely and correctly use optreset
transparently.
2011-05-28 10:31:06 +02:00
Guillem Jover
17a9a8472e Rename transparent support to overlay
This affects the pkg-config file now named libbsd-overlay.pc, and the
macro to use the overlay LIBBSD_OVERLAY.
2011-05-27 22:45:26 +02:00
Guillem Jover
28585a58bd Add fpurge function 2011-05-16 13:23:17 +02:00
Guillem Jover
b36c59c0ed Conditionalize <time.h> inclusion from <bsd/bsd.h>
This was added long time ago to fix some software which was implicitly
depending on the header through some other header, and to avoid having
to modify such software. Conditionalize it on LIBBSD_CLEAN_INCLUDES,
so that buildability can be tested for its future removal.
2011-05-14 14:18:22 +02:00
Guillem Jover
8b6a74775b Conditionalize temporary compatibility inclusions
These inclusions were in place for backward compatibility purposes,
when the headers were split so that code using them would not break.
Make it possible for applications to disable them by defining
LIBBSD_CLEAN_INCLUDES so that buildability can be tested and fixed
before they get removed in a subsequent release.
2011-05-14 14:18:22 +02:00
Guillem Jover
f7caf2b30d Move all header files to /usr/include/bsd/ and deprecate /usr/include/
First stage of the transition to avoid possible clashes with other
software by moving out of the way the remaining headers from
/usr/include/.

At least nlist.h is known to cause file conflicts with some libelf
implementations. libutil.h is not really complete and might cause
confusion if software detects its availability w/o someone actually
checking. And lastly vis.h is not known to cause any problem and it's
complete, but better be safe than sorry.

The compatibility headers will be removed in a later release.
2011-05-14 13:52:52 +02:00
Guillem Jover
520682e596 Add support for transparent compilation
This means that software being ported should not need to be modified in
the usual case, as the libbsd headers will take over the standard
namespace and fill the missing gaps, and include the system headers.

To use this the new libbsd-transparent.pc file can be used through
pkg-config, which should end up doing the right thing.
2011-05-14 13:43:49 +02:00
Kevin McCarthy
741eb58763 Add missing prototypes for arc4random_buf and arc4random_uniform
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=34511
2011-05-14 13:43:49 +02:00
Guillem Jover
9baf9640b9 Add new <bsd/sys/bitstring.h> header
Taken from FreeBSD.
2011-05-14 13:43:49 +02:00
Guillem Jover
4b95e82a32 Add new radixsort and sradixsort functions
Taken from FreeBSD.
2011-05-14 13:43:48 +02:00
Guillem Jover
be6ab54986 Add new mergesort function
Taken from FreeBSD.
2011-05-14 13:43:48 +02:00
Guillem Jover
5b19adfa82 Add getpeereid function 2011-05-14 13:43:41 +02:00
Aurelien Jarno
acb7c42d7c Add reallocf function 2011-02-23 14:44:37 +01:00
Guillem Jover
30c794083f Make setprogname and getprogname arguments and return value const
This is more correct as the strings are not going to be changed, and it
matches the function signatures on other BSDs.

Suggested-by: Aurelien Jarno <aurel32@debian.org>
2010-01-21 14:34:55 +01:00
Guillem Jover
3fed78e5b0 Replace setproctitle dummy macro with a function stub
This way we can replace it later on with a real implementation so that
applications can immediately benefit from it w/o the need to recompile
them.
2010-01-10 15:29:50 +01:00
Guillem Jover
2a81893cc0 Add pidfile functions
Taken from FreeBSD.

Remove MAXPATHLEN from ‘struct pidfh’ and allocate pf_path dynamically,
as some systems do not have such limits. Use dev_t instead of __dev_t.
Replace EDOOFUS with EINVAL.
2010-01-10 15:29:46 +01:00
Guillem Jover
98a2479f0b Add flopen function
Taken from FreeBSD.
2010-01-10 13:36:38 +01:00
Guillem Jover
7a70f1b019 Move fmtcheck and fgetln declarations to <bsd/stdio.h>
This is were they are located on the BSDs.
2009-12-12 01:13:29 +01:00
Guillem Jover
ca28f28046 Move setmode and getmode declarations to <bsd/unistd.h>
This is were they are located on the BSDs.
2009-12-12 01:11:56 +01:00
Guillem Jover
dd2756e000 Mark inclusion of <time.h> from <bsd/bsd.h> deprecated
This will be removed at some point in the future.
2009-12-12 01:11:08 +01:00
Guillem Jover
3c9182b85e Move arc4random declarations to <bsd/stdlib.h>
This is were they are located on the BSDs.
2009-12-12 01:11:08 +01:00
Guillem Jover
4d17a18db5 Deprecate <bsd/inet.h>
The only function declared in that header file was inet_net_pton, which
is already provided by glibc. Will be removed on the next SONAME bump.
2009-12-12 01:11:08 +01:00
Guillem Jover
7da57b293f Remove traces of fgetwln, it was never included
This function was exposed in the header file and the versioning symbol
file, but the actual code was never here.
2009-12-12 01:11:08 +01:00
Thorsten Glaser
a5dbef45e7 Make RCS macros take arguments
This was breaking code actually using those macros.

Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
2009-12-10 21:05:52 +01:00
Thorsten Glaser
27842d7f77 Track bug IDs for __unused collision
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
2009-12-10 21:05:33 +01:00
Guillem Jover
c5398adfe2 Add readpassphrase function
Taken from OpenBSD.
2009-12-10 20:54:03 +01:00
Guillem Jover
538bc87998 Add dehumanize_number function
Taken from NetBSD.
2009-12-10 20:54:00 +01:00
Guillem Jover
04250f6a7c Add strnvis and strnunvis functions
Taken from OpenBSD.
2009-10-24 01:47:26 +02:00
Guillem Jover
5c078ce2f5 Move <bsd/ip_icmp.h> to <bsd/netinet/ip_icmp.h>
This maps more closely the location of the real header. For
transitional purposes keep a <bsd/ip_icmp.h> that warns and includes
<bsd/netinet/ip_icmp.h>.
2009-10-24 01:47:26 +02:00
Guillem Jover
614eb0402a Add new <bsd/sys/tree.h> header 2009-10-24 01:47:25 +02:00
Guillem Jover
b6e8469059 Move <bsd/queue.h> to <bsd/sys/queue.h>
This maps more closely the location of the real header. For
transitional purposes keep a <bsd/queue.h> that warns and includes
<bsd/sys/queue.h>.
2009-10-24 01:47:25 +02:00
Guillem Jover
d3e14ea99e Move <bsd/cdefs.h> to <bsd/sys/cdefs.h>
This maps more closely the location of the real header. For
transitional purposes keep a <bsd/cdefs.h> that warns and includes
<bsd/sys/cdefs.h>.
2009-10-24 01:47:22 +02:00
Guillem Jover
e51be45c40 Update <sys/queue.h>
Taken from FreeBSD.
2009-10-24 01:11:23 +02:00
Guillem Jover
56ddcfe65a Add strtonum function
Taken from FreeBSD.
2009-10-24 01:11:23 +02:00
Guillem Jover
33ef70b9e1 Add __pure2 dummy macro 2009-07-17 13:35:37 +02:00
Guillem Jover
8ef0ecdf44 Add more dummy id macros 2009-07-17 13:34:30 +02:00
Guillem Jover
cb1346e5b3 Export public functions as extern C 2009-05-25 09:25:13 +02:00
Guillem Jover
61fa98ea9e Add missing <stdarg.h> include in <bsd/err.h> 2009-05-25 09:12:45 +02:00
Guillem Jover
931e043430 Add new __RCSID macro
Define it to nothing, so that source imported from BSDs can be easily
compiled w/o needing to modify them.
2009-05-25 08:56:34 +02:00
Guillem Jover
80c3954e3c Use the correct path when including a.out.h
Reported-by: Aurélien Jarno <aurelien@aurel32.net>
2009-05-25 06:23:01 +02:00
Guillem Jover
1f0b016e97 Use UTF-8 copyright symbols for non-imported files 2009-05-20 04:20:21 +02:00
Guillem Jover
dcaec44a6f Add nlist function 2009-05-20 04:14:19 +02:00
Guillem Jover
8dbfb3529b Add strmode function 2009-05-20 04:14:07 +02:00
Guillem Jover
4c9c8ed74c Add a new header file to expose inet_net_pton prototype 2008-07-26 22:35:31 +03:00
Guillem Jover
38829bdc8b Add new setmode and getmode functions from FreeBSD 2008-07-09 09:07:03 +03:00