1*4882a593SmuzhiyunFrom 7f41ef32c8c887ee23ca83da4dfd7a4f27e01186 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 3*4882a593SmuzhiyunDate: Wed, 10 Feb 2016 23:09:51 +0100 4*4882a593SmuzhiyunSubject: [PATCH] sysdep.h: don't assume <error.h> is available on all Linux 5*4882a593Smuzhiyun platforms 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThe current logic in sysdep.h assumes that whenever you have __linux__ 8*4882a593Smuzhiyunor __GLIBC__ defined, then <error.h> functionality is 9*4882a593Smuzhiyunavailable. However, the <error.h> functionality is a glibc-ism, not 10*4882a593Smuzhiyunavailable in more standard-conformant C libraries such as the musl C 11*4882a593Smuzhiyunlibrary. With musl, __linux__ is defined (but of course not 12*4882a593Smuzhiyun__GLIBC__). With the current logic, sysdep.h assumes that <error.h> is 13*4882a593Smuzhiyunavailable, which isn't the case. 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunThis patch therefore changes the logic to only use <error.h> when 16*4882a593Smuzhiyun__GLIBC__ is defined. It fixes the following build error: 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunIn file included from tunip.c:87:0: 19*4882a593Smuzhiyunsysdep.h:41:19: fatal error: error.h: No such file or directory 20*4882a593Smuzhiyun #include <error.h> 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunOriginal patch from 23*4882a593Smuzhiyunhttp://git.alpinelinux.org/cgit/aports/tree/testing/vpnc/working.patch. 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunSigned-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 26*4882a593Smuzhiyun--- 27*4882a593Smuzhiyun sysdep.h | 5 ++++- 28*4882a593Smuzhiyun 1 file changed, 4 insertions(+), 1 deletion(-) 29*4882a593Smuzhiyun 30*4882a593Smuzhiyundiff --git a/sysdep.h b/sysdep.h 31*4882a593Smuzhiyunindex 137bf6d..fb65b31 100644 32*4882a593Smuzhiyun--- a/sysdep.h 33*4882a593Smuzhiyun+++ b/sysdep.h 34*4882a593Smuzhiyun@@ -38,11 +38,14 @@ int tun_get_hwaddr(int fd, char *dev, uint8_t *hwaddr); 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /***************************************************************************/ 37*4882a593Smuzhiyun #if defined(__linux__) || defined(__GLIBC__) 38*4882a593Smuzhiyun+ 39*4882a593Smuzhiyun+#ifdef __GLIBC__ 40*4882a593Smuzhiyun #include <error.h> 41*4882a593Smuzhiyun+#define HAVE_ERROR 1 42*4882a593Smuzhiyun+#endif 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun #define HAVE_VASPRINTF 1 45*4882a593Smuzhiyun #define HAVE_ASPRINTF 1 46*4882a593Smuzhiyun-#define HAVE_ERROR 1 47*4882a593Smuzhiyun #define HAVE_UNSETENV 1 48*4882a593Smuzhiyun #define HAVE_SETENV 1 49*4882a593Smuzhiyun #endif 50*4882a593Smuzhiyun-- 51*4882a593Smuzhiyun2.6.4 52*4882a593Smuzhiyun 53