diff options
Diffstat (limited to 'src')
35 files changed, 122 insertions, 91 deletions
diff --git a/src/headers/error-addrinuse b/src/headers/error-addrinuse deleted file mode 100644 index 6f1e4fe..0000000 --- a/src/headers/error-addrinuse +++ /dev/null @@ -1,3 +0,0 @@ - -/* BSD sucks */ -#define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS) || ((e) == EADDRINUSE)) diff --git a/src/headers/error-already b/src/headers/error-already deleted file mode 100644 index ac6b8a7..0000000 --- a/src/headers/error-already +++ /dev/null @@ -1 +0,0 @@ -#define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS)) diff --git a/src/headers/error-footer b/src/headers/error-footer deleted file mode 100644 index ddd5dae..0000000 --- a/src/headers/error-footer +++ /dev/null @@ -1,2 +0,0 @@ - -#endif diff --git a/src/headers/error-header b/src/headers/error-header deleted file mode 100644 index f9913e5..0000000 --- a/src/headers/error-header +++ /dev/null @@ -1,9 +0,0 @@ -/* ISC license. */ - -#ifndef ERROR_H -#define ERROR_H - -#include <skalibs/gccattributes.h> - -extern int error_temp (int) gccattr_const ; -#define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK)) diff --git a/src/headers/error-proto b/src/headers/error-proto deleted file mode 100644 index fd0c01d..0000000 --- a/src/headers/error-proto +++ /dev/null @@ -1,3 +0,0 @@ - -/* Did I ever mention that BSD sucks ? */ -#define EPROTO EPROTOTYPE diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h index b20a34d..a0dc027 100644 --- a/src/include/skalibs/bytestr.h +++ b/src/include/skalibs/bytestr.h @@ -10,7 +10,7 @@ #include <string.h> #include <strings.h> -#include <skalibs/posixplz.h> +#include <skalibs/posixishard.h> #define byte_copy(to, n, from) memmove(to, (from), n) #define byte_copyr(to, n, from) memmove(to, (from), n) diff --git a/src/include/skalibs/error.h b/src/include/skalibs/error.h new file mode 100644 index 0000000..353e879 --- /dev/null +++ b/src/include/skalibs/error.h @@ -0,0 +1,18 @@ +/* ISC license. */ + +#ifndef ERROR_H +#define ERROR_H + +#include <skalibs/sysdeps.h> +#include <skalibs/gccattributes.h> + +extern int error_temp (int) gccattr_const ; +#define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK)) + +#ifdef SKALIBS_BSD_SUCKS +# define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS) || ((e) == EADDRINUSE)) +#else +# define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS)) +#endif + +#endif diff --git a/src/include/skalibs/nonposix.h b/src/include/skalibs/nonposix.h index 4ce165c..cf87674 100644 --- a/src/include/skalibs/nonposix.h +++ b/src/include/skalibs/nonposix.h @@ -35,12 +35,25 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif + + + /* BSD and Linux libcs that are not glibc: _BSD_SOURCE opens up a + lot of extensions. Of course, glibc insisted on changing to a + different macro, because coordination and consistency would make + developers' life too easy. */ + +#ifdef __GLIBC__ #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif +#else +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif +#endif - /* NetBSD: of course they had to have their own macros. */ + /* NetBSD: of course they had to have their own macro too. */ #ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE @@ -50,22 +63,13 @@ #endif - /* MacOS: needs this for full SUSv3 conformance. Don't ask. */ + /* MacOS: needs this for full SUSv3 conformance. Standards are hard. */ #ifndef _DARWIN_C_SOURCE #define _DARWIN_C_SOURCE #endif - /* Unfortunately we can't fully avoid #ifdef forests, - because the BSDs are bloody snowflakes. See: setgroups(). */ - -#undef SKALIBS_BSD_SUCKS -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__) -# define SKALIBS_BSD_SUCKS -#endif - - /* old versions of BSD and some broken GNU toolchains: system headers are not self-contained, starting with sys/types.h normally always works. */ diff --git a/src/include/skalibs/posixishard.h b/src/include/skalibs/posixishard.h new file mode 100644 index 0000000..b5da077 --- /dev/null +++ b/src/include/skalibs/posixishard.h @@ -0,0 +1,30 @@ +/* ISC license. */ + +#ifndef SKALIBS_POSIXISHARD_H +#define SKALIBS_POSIXISHARD_H + +#include <stddef.h> + +#include <skalibs/gccattributes.h> + + /* + This header must be used with some broken OSes who have + serious trouble implementing even easy parts of POSIX. + It's supposed to be included *after* system headers, so + it won't catch behaviour such as "this macro must be defined + prior to including system headers in order to define that + symbol". If that's what you need, include skalibs/nonposix.h + instead, which must happen *before* system headers. + */ + +extern size_t strnlen (char const *, size_t) gccattr_pure ; + +#ifndef EPROTO +#define EPROTO EPROTOTYPE +#endif + +#ifndef MSG_NOSIGNAL +#define MSG_NOSIGNAL 0 +#endif + +#endif diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h index dda66ee..639a7c4 100644 --- a/src/include/skalibs/posixplz.h +++ b/src/include/skalibs/posixplz.h @@ -18,17 +18,6 @@ extern char **environ ; /* - Stuff that _is_ POSIX, but some OSes still don't have it. - openat() et al. should be here, but they're impossible to - emulate correctly, and I don't want an app using openat() - to think it has safe POSIX semantics when it doesn't :/ - EPROTO et al. should be here, but ugh ifdef forests. - */ - -extern size_t strnlen (char const *, size_t) gccattr_pure ; - - - /* Non-POSIX functions that some OSes provide and others don't. setgroups() isn't included because it's its own kind of broken. */ diff --git a/src/include/skalibs/skalibs.h b/src/include/skalibs/skalibs.h index 2924e1c..ceaad27 100644 --- a/src/include/skalibs/skalibs.h +++ b/src/include/skalibs/skalibs.h @@ -4,8 +4,11 @@ #define SKALIBS_H /* - This header includes everything in skalibs except skalibs/config.h - It's heavy! + This header is heavy! It includes everything in skalibs except: + - skalibs/config.h: package configuration + - skalibs/sysdeps.h: system-dependent feature test macros + - skalibs/nonposix.h: pre-system headers definitions for POSIX extensions + - skalibs/posixishard.h: workarounds for failures to respect POSIX */ #include <skalibs/posixplz.h> diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h index aa90f6a..232b5f3 100644 --- a/src/include/skalibs/stddjb.h +++ b/src/include/skalibs/stddjb.h @@ -3,7 +3,6 @@ #ifndef STDDJB_H #define STDDJB_H -#include <skalibs/config.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/uint64.h> diff --git a/src/libposixplz/strnlen.c b/src/libposixplz/strnlen.c index 1699771..1c4145c 100644 --- a/src/libposixplz/strnlen.c +++ b/src/libposixplz/strnlen.c @@ -6,7 +6,7 @@ #include <string.h> #include <skalibs/bytestr.h> -#include <skalibs/posixplz.h> +#include <skalibs/posixishard.h> size_t strnlen (char const *s, size_t max) { diff --git a/src/libstddjb/cdb_read.c b/src/libstddjb/cdb_read.c index fa7b1d3..85e8dea 100644 --- a/src/libstddjb/cdb_read.c +++ b/src/libstddjb/cdb_read.c @@ -3,7 +3,8 @@ #include <unistd.h> #include <string.h> #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/allreadwrite.h> #include <skalibs/cdb.h> diff --git a/src/libstddjb/ipc_bind.c b/src/libstddjb/ipc_bind.c index 8686591..b3388d7 100644 --- a/src/libstddjb/ipc_bind.c +++ b/src/libstddjb/ipc_bind.c @@ -1,11 +1,13 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <sys/un.h> #include <string.h> #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/webipc.h> int ipc_bind (int s, char const *p) diff --git a/src/libstddjb/ipc_connect.c b/src/libstddjb/ipc_connect.c index 9aa4dd9..bb0422e 100644 --- a/src/libstddjb/ipc_connect.c +++ b/src/libstddjb/ipc_connect.c @@ -1,11 +1,13 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <sys/un.h> #include <string.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/webipc.h> int ipc_connect (int s, char const *p) diff --git a/src/libstddjb/ipc_recv.c b/src/libstddjb/ipc_recv.c index 5aa1c2b..e15e3c5 100644 --- a/src/libstddjb/ipc_recv.c +++ b/src/libstddjb/ipc_recv.c @@ -1,11 +1,13 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <sys/un.h> #include <string.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/webipc.h> ssize_t ipc_recv (int fd, char *s, size_t len, char *path) diff --git a/src/libstddjb/ipc_send.c b/src/libstddjb/ipc_send.c index 967a64f..65826a6 100644 --- a/src/libstddjb/ipc_send.c +++ b/src/libstddjb/ipc_send.c @@ -1,11 +1,13 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <sys/un.h> #include <string.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/webipc.h> ssize_t ipc_send (int fd, char const *s, size_t len, char const *path) diff --git a/src/libstddjb/netstring_get.c b/src/libstddjb/netstring_get.c index 9756b2e..0dfa907 100644 --- a/src/libstddjb/netstring_get.c +++ b/src/libstddjb/netstring_get.c @@ -1,11 +1,12 @@ /* ISC license. */ #include <errno.h> + +#include <skalibs/posixishard.h> #include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/bytestr.h> #include <skalibs/buffer.h> -#include <skalibs/error.h> #include <skalibs/stralloc.h> #include <skalibs/netstring.h> diff --git a/src/libstddjb/string_unquote_withdelim.c b/src/libstddjb/string_unquote_withdelim.c index 3ebd07d..702d3a5 100644 --- a/src/libstddjb/string_unquote_withdelim.c +++ b/src/libstddjb/string_unquote_withdelim.c @@ -1,7 +1,8 @@ /* ISC license. */ #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/bytestr.h> #include <skalibs/fmtscan.h> #include <skalibs/skamisc.h> diff --git a/src/libunixonacid/ipc_timed_send.c b/src/libunixonacid/ipc_timed_send.c index eeae453..e1e75a4 100644 --- a/src/libunixonacid/ipc_timed_send.c +++ b/src/libunixonacid/ipc_timed_send.c @@ -1,17 +1,15 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <errno.h> + +#include <skalibs/posixishard.h> #include <skalibs/error.h> #include <skalibs/iopause.h> #include <skalibs/unix-timed.h> - /* For MacOS, that still doesn't know what POSIX says */ -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - int ipc_timed_send (int fd, char const *s, size_t len, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ; diff --git a/src/libunixonacid/ipc_timed_sendv.c b/src/libunixonacid/ipc_timed_sendv.c index 220b2e3..0fe5b1e 100644 --- a/src/libunixonacid/ipc_timed_sendv.c +++ b/src/libunixonacid/ipc_timed_sendv.c @@ -1,18 +1,16 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <errno.h> + +#include <skalibs/posixishard.h> #include <skalibs/error.h> #include <skalibs/iopause.h> #include <skalibs/siovec.h> #include <skalibs/unix-timed.h> - /* For MacOS, that still doesn't know what POSIX says */ -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - int ipc_timed_sendv (int fd, struct iovec const *v, unsigned int n, tain_t const *deadline, tain_t *stamp) { struct msghdr hdr = diff --git a/src/libunixonacid/skaclient_default_cb.c b/src/libunixonacid/skaclient_default_cb.c index 10934e5..5bf0268 100644 --- a/src/libunixonacid/skaclient_default_cb.c +++ b/src/libunixonacid/skaclient_default_cb.c @@ -1,7 +1,8 @@ /* ISC license. */ #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> diff --git a/src/libunixonacid/skaclient_server_ack.c b/src/libunixonacid/skaclient_server_ack.c index 715e128..b55eb07 100644 --- a/src/libunixonacid/skaclient_server_ack.c +++ b/src/libunixonacid/skaclient_server_ack.c @@ -2,8 +2,9 @@ #include <errno.h> #include <string.h> + +#include <skalibs/posixishard.h> #include <skalibs/djbunix.h> -#include <skalibs/error.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> #include <skalibs/webipc.h> diff --git a/src/libunixonacid/skaclient_start_cb.c b/src/libunixonacid/skaclient_start_cb.c index 80cb6c3..0c4ef49 100644 --- a/src/libunixonacid/skaclient_start_cb.c +++ b/src/libunixonacid/skaclient_start_cb.c @@ -2,7 +2,8 @@ #include <errno.h> #include <string.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> #include "skaclient-internal.h" diff --git a/src/libunixonacid/textclient_command.c b/src/libunixonacid/textclient_command.c index 2e72a4c..56c7122 100644 --- a/src/libunixonacid/textclient_command.c +++ b/src/libunixonacid/textclient_command.c @@ -2,7 +2,8 @@ #include <sys/uio.h> #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/textclient.h> int textclient_command (textclient_t *a, char const *s, size_t len, tain_t const *deadline, tain_t *stamp) diff --git a/src/libunixonacid/textclient_commandv.c b/src/libunixonacid/textclient_commandv.c index 5bcd411..ec61498 100644 --- a/src/libunixonacid/textclient_commandv.c +++ b/src/libunixonacid/textclient_commandv.c @@ -2,7 +2,8 @@ #include <sys/uio.h> #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/textclient.h> int textclient_commandv (textclient_t *a, struct iovec const *v, unsigned int n, tain_t const *deadline, tain_t *stamp) diff --git a/src/libunixonacid/textclient_server_init_frompipe.c b/src/libunixonacid/textclient_server_init_frompipe.c index fb85b44..e606eeb 100644 --- a/src/libunixonacid/textclient_server_init_frompipe.c +++ b/src/libunixonacid/textclient_server_init_frompipe.c @@ -4,8 +4,9 @@ #include <stdlib.h> #include <fcntl.h> #include <errno.h> + +#include <skalibs/posixishard.h> #include <skalibs/types.h> -#include <skalibs/error.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/textmessage.h> diff --git a/src/libunixonacid/textclient_server_init_fromsocket.c b/src/libunixonacid/textclient_server_init_fromsocket.c index e58df2b..b7f4e84 100644 --- a/src/libunixonacid/textclient_server_init_fromsocket.c +++ b/src/libunixonacid/textclient_server_init_fromsocket.c @@ -1,22 +1,20 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/uio.h> #include <errno.h> #include <string.h> #include <sys/socket.h> + +#include <skalibs/posixishard.h> #include <skalibs/types.h> -#include <skalibs/error.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/unix-timed.h> #include <skalibs/textmessage.h> #include <skalibs/textclient.h> -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - union aligner_u { struct cmsghdr cmsghdr ; diff --git a/src/libunixonacid/textclient_start.c b/src/libunixonacid/textclient_start.c index 8cb7bcd..8eb8b13 100644 --- a/src/libunixonacid/textclient_start.c +++ b/src/libunixonacid/textclient_start.c @@ -2,11 +2,13 @@ #include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> + #include <sys/uio.h> #include <string.h> #include <errno.h> #include <sys/socket.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/allreadwrite.h> #include <skalibs/webipc.h> #include <skalibs/djbunix.h> diff --git a/src/libunixonacid/textclient_startf.c b/src/libunixonacid/textclient_startf.c index 6a6f0fc..12c2b20 100644 --- a/src/libunixonacid/textclient_startf.c +++ b/src/libunixonacid/textclient_startf.c @@ -3,7 +3,8 @@ #include <sys/uio.h> #include <string.h> #include <errno.h> -#include <skalibs/error.h> + +#include <skalibs/posixishard.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/textmessage.h> diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c index a8701ee..a2ac302 100644 --- a/src/libunixonacid/unixmessage_put.c +++ b/src/libunixonacid/unixmessage_put.c @@ -2,9 +2,10 @@ #include <string.h> #include <errno.h> + +#include <skalibs/posixishard.h> #include <skalibs/bitarray.h> #include <skalibs/disize.h> -#include <skalibs/error.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/siovec.h> diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c index 15d08ae..811baae 100644 --- a/src/libunixonacid/unixmessage_receive.c +++ b/src/libunixonacid/unixmessage_receive.c @@ -2,14 +2,16 @@ #include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <sys/uio.h> + +#include <skalibs/posixishard.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/cbuffer.h> #include <skalibs/djbunix.h> -#include <skalibs/error.h> #include <skalibs/allreadwrite.h> #include <skalibs/stralloc.h> #include <skalibs/unixmessage.h> diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c index fa1438f..3f096f0 100644 --- a/src/libunixonacid/unixmessage_sender_flush.c +++ b/src/libunixonacid/unixmessage_sender_flush.c @@ -1,12 +1,15 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <sys/uio.h> #include <string.h> #include <stdint.h> #include <unistd.h> #include <errno.h> + +#include <skalibs/posixishard.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/disize.h> @@ -15,11 +18,6 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> - /* MacOS X tries hard to be POSIX-compliant... and fails. */ -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - union aligner_u { struct cmsghdr cmsghdr ; diff --git a/src/sysdeps/tryeproto.c b/src/sysdeps/tryeproto.c deleted file mode 100644 index e7a0942..0000000 --- a/src/sysdeps/tryeproto.c +++ /dev/null @@ -1,9 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -static int dummy ; - -#ifndef EPROTO - syntax error ! -#endif |