]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Give up on _BSD_SOURCE and use _GNU_SOURCE for Linux.
authorRoy Marples <roy@marples.name>
Mon, 20 Apr 2015 09:02:58 +0000 (09:02 +0000)
committerRoy Marples <roy@marples.name>
Mon, 20 Apr 2015 09:02:58 +0000 (09:02 +0000)
This is requires for newer Linux headers as there is no easy way to get at the
in6_pktinfo structure, so we have to fallback to the glibc variant which
requires _GNU_SOURCE being set.
This does have the advantage of no longer sprinkling _GNU_SOURCE around and
no longer having to cast ipi.ipi_ifindex but may break compile on older Linux.

common.c
configure
dhcp6.c
eloop.c
ipv6.h
ipv6nd.c

index 1b6a994eafd83ed6e0b48a1a6f97d56fb525dc57..f930ee00c517a535d25487c5b611a3fc892fe654 100644 (file)
--- a/common.c
+++ b/common.c
  * SUCH DAMAGE.
  */
 
-/* Needed define to get at getline for glibc and FreeBSD */
-#ifndef _GNU_SOURCE
-#  define _GNU_SOURCE
-#endif
-
 #ifdef __APPLE__
 #  include <mach/mach_time.h>
 #  include <mach/kern_return.h>
index 4ba9382c36d591ba185b7a5582f3cf3f839c2118..b13c23265653a48af65ed2cd5d9f61b7014ebe9b 100755 (executable)
--- a/configure
+++ b/configure
@@ -360,23 +360,21 @@ if [ -n "$FORK" -a "$FORK" != yes -a "$FORK" != true ]; then
 fi
 
 case "$OS" in
-kfreebsd*)
+freebsd*|kfreebsd*)
        echo "CPPFLAGS+=        -D_GNU_SOURCE" >>$CONFIG_MK
        echo "DHCPCD_SRCS+=     if-bsd.c" >>$CONFIG_MK
        ;;
 linux*)
-       echo "CPPFLAGS+=        -D_BSD_SOURCE -D_XOPEN_SOURCE=700" >>$CONFIG_MK
+       echo "CPPFLAGS+=        -D_GNU_SOURCE" >>$CONFIG_MK
        # Large File Support, should be fine for 32-bit systems.
        # But if this is the case, why is it not set by default?
        echo "CPPFLAGS+=        -D_FILE_OFFSET_BITS=64" >>$CONFIG_MK
        echo "CPPFLAGS+=        -D_LARGEFILE_SOURCE" >>$CONFIG_MK
        echo "CPPFLAGS+=        -D_LARGEFILE64_SOURCE" >>$CONFIG_MK
-       # glibc-2.20
-       echo "CPPFLAGS+=        -D_DEFAULT_SOURCE" >>$CONFIG_MK
        echo "DHCPCD_SRCS+=     if-linux.c" >>$CONFIG_MK
        # for RTM_NEWADDR and friends
-       echo "#include <asm/types.h> /* fix broken headers */" >>$CONFIG_H
-       echo "#include <linux/rtnetlink.h>" >>$CONFIG_H
+       echo "#include          <asm/types.h> /* fix broken headers */" >>$CONFIG_H
+       echo "#include          <linux/rtnetlink.h>" >>$CONFIG_H
        ;;
 qnx*)
        echo "CPPFLAGS+=        -D__EXT" >>$CONFIG_MK
@@ -594,7 +592,6 @@ fi
 if [ -z "$GETLINE" ]; then
        printf "Testing for getline ... "
        cat <<EOF >_getline.c
-#define _GNU_SOURCE
 #include <stdio.h>
 int main(void) {
        char *buf = NULL;
diff --git a/dhcp6.c b/dhcp6.c
index 15cdcfa4cefabb1a23b540aa3131c25cfb870c44..5b98180c6b0182ec0f41eacb523f42e1899c8fbf 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -1151,7 +1151,7 @@ logsend:
        cm->cmsg_type = IPV6_PKTINFO;
        cm->cmsg_len = CMSG_LEN(sizeof(pi));
        memset(&pi, 0, sizeof(pi));
-       pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
+       pi.ipi6_ifindex = ifp->index;
        memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
        if (sendmsg(ctx->dhcp_fd, &ctx->sndhdr, 0) == -1) {
diff --git a/eloop.c b/eloop.c
index 326148794543faed1ef91355e4d144ffa62c6242..e479ac161211a1c7ed02bb63e1e8d8d79e8ade96 100644 (file)
--- a/eloop.c
+++ b/eloop.c
@@ -25,9 +25,6 @@
  * SUCH DAMAGE.
  */
 
-/* Needed for ppoll(2) */
-#define _GNU_SOURCE
-
 #include <sys/time.h>
 
 #include <errno.h>
diff --git a/ipv6.h b/ipv6.h
index 5e7f2cdfb901e818242332db7aaee78f22d9dbfb..a2e3042ccd452a5d603663f45406f40248000324 100644 (file)
--- a/ipv6.h
+++ b/ipv6.h
 #define IPV6_H
 
 #include <sys/uio.h>
-
 #include <netinet/in.h>
 
-#if defined(__linux__) && defined(__GLIBC__)
-#  define _LINUX_IN6_H
-#  include <linux/ipv6.h>
-#endif
-
 #include "config.h"
 #include "dhcpcd.h"
 
@@ -196,13 +190,6 @@ struct ipv6_state {
                        CMSG_SPACE(sizeof(int)))
 
 
-/* ipi6.ifiindex differes between OS's so have a cast function */
-#ifdef __GLIBC__
-#define CAST_IPI6_IFINDEX(idx) (int)(idx)
-#else
-#define CAST_IPI6_IFINDEX(idx) (idx)
-#endif
-
 #ifdef INET6
 struct ipv6_ctx {
        struct sockaddr_in6 from;
index 4df88650745c21b7fce1f055a434fa9aefea542d..4f24163aa7286ca4b1046a8fcb475df1297fe67f 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -295,7 +295,7 @@ ipv6nd_sendrsprobe(void *arg)
        cm->cmsg_type = IPV6_PKTINFO;
        cm->cmsg_len = CMSG_LEN(sizeof(pi));
        memset(&pi, 0, sizeof(pi));
-       pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
+       pi.ipi6_ifindex = ifp->index;
        memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
        logger(ifp->ctx, LOG_DEBUG,