summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2016-10-13 09:16:48 +0900
committerMark Wielaard <mjw@redhat.com>2016-10-13 11:24:03 +0200
commita24d52ac205b4983c80657b5aa2a7d90d7032837 (patch)
tree1fc2966e22391592ba4a6d94da7c68d86f64e51e /lib
parent60b2bf1b08c621492410b24e469b2bdf58d167d5 (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 <akihiko.odaki.4i@stu.hosei.ac.jp> Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/ChangeLog7
-rw-r--r--lib/fixedsizehash.h6
-rw-r--r--lib/system.h16
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 88c71c9a..afb18b11 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,5 +1,12 @@
2015-10-11 Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
+ * fixedsizehash.h (CONCAT): Use __CONCAT when available.
+ * system.h: Include config.h and errno.h.
+ (powerof2): Define if not already defined.
+ (TEMP_FAILURE_RETRY): Define when not yet defined.
+
+2015-10-11 Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
+
* Makefile.am (noinst_HEADERS): Add libeu.h.
* color.c: Remove system.h include, add libeu.h include.
* crc32_file.c: Likewise.
diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
index 18921a44..dac2a5f5 100644
--- a/lib/fixedsizehash.h
+++ b/lib/fixedsizehash.h
@@ -34,7 +34,13 @@
#include <system.h>
+#ifdef __CONCAT
#define CONCAT(t1,t2) __CONCAT (t1,t2)
+#else
+#define STROF(t2) t2
+#define CONCAT_EXPANDED(t1,t2) t1 ## t2
+#define CONCAT(t1,t2) CONCAT_EXPANDED(t1,t2)
+#endif
/* Before including this file the following macros must be defined:
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)