summaryrefslogtreecommitdiffstats
path: root/package/systemd/systemd-03-uclibc-fix.patch
blob: f3b41c1a64e487e1a123a9700a277e0ea4edd3af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[PATCH] fix build with uClibc

Based on OE patch from Khem Raj:

http://cgit.openembedded.org/meta-openembedded/tree/meta-oe/recipes-core/systemd/systemd/paper-over-mkostemp.patch

But extended to also cover execvpe (OE carries a patch adding execvpe
support to uClibc).

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 src/journal/journal-file.c |    2 ++
 src/macro.h                |   15 +++++++++++++++
 2 files changed, 17 insertions(+)

Index: b/src/macro.h
===================================================================
--- a/src/macro.h
+++ b/src/macro.h
@@ -28,6 +28,33 @@
 #include <sys/uio.h>
 #include <inttypes.h>
 
+#ifdef __UCLIBC__
+/* uclibc does not implement mkostemp GNU extension */
+#define mkostemp(x,y) mkstemp(x)
+/* uclibc may not define MSG_CMSG_CLOEXEC */
+#if defined HAVE_DECL_MSG_CMSG_CLOEXEC && !HAVE_DECL_MSG_CMSG_CLOEXEC
+#define MSG_CMSG_CLOEXEC 0x40000000
+#endif
+/* uclibc does not implement execvpe GNU extension */
+#ifndef HAVE_EXECVPE
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <unistd.h>
+static inline int execvpe(const char *file, char *const argv[],
+                          char *const envp[])
+{
+        environ = (char **)envp;
+        return execvp(file, argv);
+}
+#endif /* HAVE_EXECVPE */
+#ifndef HAVE_DUP3
+#include <asm/unistd.h>
+static inline int dup3(int oldfd, int newfd, int flags) {
+        return syscall(__NR_dup3, oldfd, newfd, flags);
+}
+#endif /* HAVE_DUP3 */
+#endif /* __UCLIBC__ */
 #define _printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
 #define _sentinel_ __attribute__ ((sentinel))
 #define _noreturn_ __attribute__((noreturn))
Index: b/src/journal/journal-file.c
===================================================================
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -229,11 +229,13 @@
                 }
         }
 
+#ifndef __UCLIBC__
         /* Note that the glibc fallocate() fallback is very
            inefficient, hence we try to minimize the allocation area
            as we can. */
         if (posix_fallocate(f->fd, old_size, new_size - old_size) < 0)
                 return -errno;
+#endif
 
         if (fstat(f->fd, &f->last_stat) < 0)
                 return -errno;
Index: b/configure.ac
===================================================================
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,8 @@
 
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
+AC_CHECK_FUNCS([execvpe dup3])
+AC_CHECK_DECLS([MSG_CMSG_CLOEXEC], [], [], [#include <sys/socket.h>])
 
 save_LIBS="$LIBS"
 LIBS=
OpenPOWER on IntegriCloud