diff options
| author | Akihiko Odaki <[email protected]> | 2016-10-13 09:16:48 +0900 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-10-13 11:24:03 +0200 |
| commit | a24d52ac205b4983c80657b5aa2a7d90d7032837 (patch) | |
| tree | 1fc2966e22391592ba4a6d94da7c68d86f64e51e /lib/system.h | |
| parent | 60b2bf1b08c621492410b24e469b2bdf58d167d5 (diff) | |
Do not depend on some non-POSIX features.
Define/open code memrchr, rawmemchr, powerof2 and TEMP_FAILURE_RETRY if
not available through system headers.
Signed-off-by: Akihiko Odaki <[email protected]>
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'lib/system.h')
| -rw-r--r-- | lib/system.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/system.h b/lib/system.h index ec387c31..e1c1c698 100644 --- a/lib/system.h +++ b/lib/system.h @@ -29,7 +29,12 @@ #ifndef LIB_SYSTEM_H #define LIB_SYSTEM_H 1 +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <argp.h> +#include <errno.h> #include <stddef.h> #include <stdint.h> #include <sys/param.h> @@ -59,6 +64,9 @@ #define MIN(m, n) ((m) < (n) ? (m) : (n)) #endif +#if !HAVE_DECL_POWEROF2 +#define powerof2(x) (((x) & ((x) - 1)) == 0) +#endif /* A special gettext function we use if the strings are too short. */ #define sgettext(Str) \ @@ -67,6 +75,14 @@ #define gettext_noop(Str) Str +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(expression) \ + ({ ssize_t __res; \ + do \ + __res = expression; \ + while (__res == -1 && errno == EINTR); \ + __res; }); +#endif static inline ssize_t __attribute__ ((unused)) pwrite_retry (int fd, const void *buf, size_t len, off_t off) |
