changeset 1856:84fd9cd991df draft

Change from ppoll(2) to pollts(2). I was going to go with ppoll(2) because I would guess the Open Group would prefer the name of it over pollts(2) if they ever standardised it. However that causes a problem with _GNU_SOURCE and my code base so I've gone to pollts(2) and suck in the compat header for Linux users to avoid that sillyness.
author Roy Marples <roy@marples.name>
date Mon, 18 Feb 2013 21:25:07 +0000
parents 407f259434ff
children a03db7acafeb
files common.h configure eloop.c if-linux-wireless.c
diffstat 4 files changed, 38 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/common.h	Mon Feb 18 20:56:55 2013 +0000
+++ b/common.h	Mon Feb 18 21:25:07 2013 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2011 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2013 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,6 @@
 #include <sys/time.h>
 #include <stdio.h>
 
-#include "config.h"
 #include "defs.h"
 
 #define UNCONST(a)		((void *)(unsigned long)(const void *)(a))
--- a/configure	Mon Feb 18 20:56:55 2013 +0000
+++ b/configure	Mon Feb 18 21:25:07 2013 +0000
@@ -57,7 +57,8 @@
 	--without-getline) GETLINE=no;;
 	--without-strlcpy) STRLCPY=no;;
         --without-posix_spawn) POSIX_SPAWN=no;;
-        --without-ppoll) PPOLL=no;;
+        --without-pollts) POLLTS=no;;
+	--with-pollts) POLLTS=$var;;
 	--serviceexists) SERVICEEXISTS=$var;;
 	--servicecmd) SERVICECMD=$var;;
 	--servicestatus) SERVICESTATUS=$var;;
@@ -525,25 +526,7 @@
 	echo "#include <spawn.h>" >>$CONFIG_H
 fi
 
-if [ -z "$PPOLL" ]; then
-	printf "Testing for ppoll ... "
-	cat <<EOF >_ppoll.c
-#include <poll.h>
-#include <stdlib.h>
-int main(void) {
-	ppoll(NULL, 0, NULL, NULL);
-	return 0;
-}
-EOF
-	if $XCC _ppoll.c -o _ppoll 2>/dev/null; then
-		PPOLL=yes
-	else
-		PPOLL=no
-	fi
-	echo "$PPOLL"
-	rm -f _ppoll.c _ppoll
-fi
-if [ "$PPOLL" = no ]; then
+if [ -z "$POLLTS" ]; then
 	printf "Testing for pollts ... "
 	cat <<EOF >_pollts.c
 #include <poll.h>
@@ -556,15 +539,34 @@
 }
 EOF
 	if $XCC _pollts.c -o _pollts 2>/dev/null; then
-		PPOLL=pollts
+		POLLTS=yes
+	else
+		POLLTS=no
+	fi
+	echo "$POLLTS"
+	rm -f _pollts.c _pollts
+fi
+if [ "$POLLTS" = no ]; then
+	printf "Testing for ppoll ... "
+	cat <<EOF >_ppoll.c
+#include <poll.h>
+#include <stdlib.h>
+int main(void) {
+	ppoll(NULL, 0, NULL, NULL);
+	return 0;
+}
+EOF
+	if $XCC _ppoll.c -o _ppoll 2>/dev/null; then
+		POLLTS=ppoll
 		echo "yes"
 	else
-		PPOLL=no
+		POLLTS=no
 		echo "no"
 	fi
-	rm -f _pollts.c _pollts
+	echo "$POLLTS"
+	rm -f _ppoll.c _ppoll
 fi
-if [ "$PPOLL" = no ]; then
+if [ "$POLLTS" = no ]; then
 	printf "Testing for pselect ... "
 	cat <<EOF >_pselect.c
 #include <sys/select.h>
@@ -575,17 +577,20 @@
 }
 EOF
 	if $XCC _pselect.c -o _pselect 2>/dev/null; then
-		PPOLL=pselect
+		POLLTS=pselect
 		echo "yes"
 	else
-		PPOLL=no
+		POLLTS=no
 		echo "no"
 	fi
 	rm -f _pselect.c _pselect
 fi
-case "$PPOLL" in
-pollts)
-	echo "#define ppoll pollts" >>$CONFIG_H
+case "$POLLTS" in
+yes)
+	;;
+ppoll)
+	echo "#include \"compat/ppoll.h\"" >>$CONFIG_H
+	echo "#define pollts ppoll" >>$CONFIG_H
 	;;
 pselect)
 	echo "COMPAT_SRCS+=	compat/pselect.c" >>$CONFIG_MK
--- a/eloop.c	Mon Feb 18 20:56:55 2013 +0000
+++ b/eloop.c	Mon Feb 18 21:25:07 2013 +0000
@@ -367,7 +367,7 @@
 			exit(EXIT_FAILURE);
 		}
 
-		n = ppoll(fds, events_len, tsp, sigmask);
+		n = pollts(fds, events_len, tsp, sigmask);
 		if (n == -1) {
 			if (errno == EAGAIN || errno == EINTR)
 				continue;
--- a/if-linux-wireless.c	Mon Feb 18 20:56:55 2013 +0000
+++ b/if-linux-wireless.c	Mon Feb 18 21:25:07 2013 +0000
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2009-2010 Roy Marples <roy@marples.name>
+ * Copyright (c) 2009-2013 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -55,6 +55,7 @@
 #include <unistd.h>
 
 #include "common.h"
+#include "config.h"
 
 /* We can't include net.h or dhcpcd.h because
  * they would pull in net/if.h, which defeats the purpose of this hack. */