my only real (visual) feedback is the workspace name indicator, it 
seems as it was before; also other stuff feel to be the same as 
before.

>From d223e14f85b8d29331f539fc30d87750291dc835 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Wed, 29 Sep 2010 02:52:19 +0200
Subject: [PATCH] Modernize WINGs/wusleep()

- Change the wusleep abomination to be a simple wrapper around
  nanosleep (man says it's been POSIX for almost a decade)
- Remove autoconf tests that became unnecessary along the way

Signed-off-by: Tamas TEVESZ <[email protected]>
---
 WINGs/WINGs/WUtil.h |    2 +-
 WINGs/usleep.c      |   53 +++++++++++++++-----------------------------------
 configure.ac        |    6 +---
 3 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h
index 19785d3..cc1a321 100644
--- a/WINGs/WINGs/WUtil.h
+++ b/WINGs/WINGs/WUtil.h
@@ -248,7 +248,7 @@ WMRange wmkrange(int start, int count);
 
 /* ---[ WINGs/usleep.c ]-------------------------------------------------- */
 
-void wusleep(unsigned int microsec);
+void wusleep(unsigned int usec);
 
 /* ---[ WINGs/handlers.c ]------------------------------------------------ */
 
diff --git a/WINGs/usleep.c b/WINGs/usleep.c
index 792b947..acf0583 100644
--- a/WINGs/usleep.c
+++ b/WINGs/usleep.c
@@ -1,46 +1,25 @@
 
-#include "wconfig.h"
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#include <unistd.h>
-#include <string.h>
-
-#if defined(HAVE_SELECT)
+#include <errno.h>
+#include <time.h>
 
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
+#include "wconfig.h"
 
-void wusleep(unsigned int microsecs)
+void wusleep(unsigned int usec)
 {
-       struct timeval tv;
-       fd_set rd, wr, ex;
-       FD_ZERO(&rd);
-       FD_ZERO(&wr);
-       FD_ZERO(&ex);
-       tv.tv_sec = microsecs / 1000000u;
-       tv.tv_usec = microsecs % 1000000u;
-       select(1, &rd, &wr, &ex, &tv);
-}
+       struct timespec tm;
 
-#else                          /* not HAVE_SELECT */
+       /* An arbitrary limit of 10 minutes -- in WM, if
+        * somethings wants to sleep anything even close to
+        * this, it's most likely an error.
+        */
+       if (usec > 600000000)
+               return;
 
-# ifdef HAVE_POLL
+       tm.tv_sec = usec / 1000000;
+       tm.tv_nsec = usec % 1000000;
 
-void wusleep(unsigned int microsecs)
-{
-       poll((struct poll *)0, (size_t) 0, microsecs / 1000);
-}
+       while (nanosleep(&tm, &tm) == -1 && errno == EINTR)
+               ;
 
-# else                         /* ! HAVE_POLL */
+}
 
-oops !
-# endif                                /* !HAVE_POLL */
-#endif                         /* !HAVE_SELECT */
diff --git a/configure.ac b/configure.ac
index 1df077c..89bde42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,10 +230,8 @@ dnl Checks for header files.
 dnl =======================
 AC_HEADER_SYS_WAIT
 AC_HEADER_TIME
-AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h sys/types.h \
-                libintl.h sys/select.h poll.h malloc.h ctype.h string.h \
-                strings.h)
-
+AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h libintl.h poll.h malloc.h 
ctype.h \
+                string.h strings.h)
 
 
 dnl Checks for typedefs, structures, and compiler characteristics.
-- 
1.7.0.4


-- 
[-]

mkdir /nonexistent
From d223e14f85b8d29331f539fc30d87750291dc835 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Wed, 29 Sep 2010 02:52:19 +0200
Subject: [PATCH] Modernize WINGs/wusleep()

- Change the wusleep abomination to be a simple wrapper around
  nanosleep (man says it's been POSIX for almost a decade)
- Remove autoconf tests that became unnecessary along the way

Signed-off-by: Tamas TEVESZ <[email protected]>
---
 WINGs/WINGs/WUtil.h |    2 +-
 WINGs/usleep.c      |   53 +++++++++++++++-----------------------------------
 configure.ac        |    6 +---
 3 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h
index 19785d3..cc1a321 100644
--- a/WINGs/WINGs/WUtil.h
+++ b/WINGs/WINGs/WUtil.h
@@ -248,7 +248,7 @@ WMRange wmkrange(int start, int count);
 
 /* ---[ WINGs/usleep.c ]-------------------------------------------------- */
 
-void wusleep(unsigned int microsec);
+void wusleep(unsigned int usec);
 
 /* ---[ WINGs/handlers.c ]------------------------------------------------ */
 
diff --git a/WINGs/usleep.c b/WINGs/usleep.c
index 792b947..acf0583 100644
--- a/WINGs/usleep.c
+++ b/WINGs/usleep.c
@@ -1,46 +1,25 @@
 
-#include "wconfig.h"
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#include <unistd.h>
-#include <string.h>
-
-#if defined(HAVE_SELECT)
+#include <errno.h>
+#include <time.h>
 
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
+#include "wconfig.h"
 
-void wusleep(unsigned int microsecs)
+void wusleep(unsigned int usec)
 {
-	struct timeval tv;
-	fd_set rd, wr, ex;
-	FD_ZERO(&rd);
-	FD_ZERO(&wr);
-	FD_ZERO(&ex);
-	tv.tv_sec = microsecs / 1000000u;
-	tv.tv_usec = microsecs % 1000000u;
-	select(1, &rd, &wr, &ex, &tv);
-}
+	struct timespec tm;
 
-#else				/* not HAVE_SELECT */
+	/* An arbitrary limit of 10 minutes -- in WM, if
+	 * somethings wants to sleep anything even close to
+	 * this, it's most likely an error.
+	 */
+	if (usec > 600000000)
+		return;
 
-# ifdef HAVE_POLL
+	tm.tv_sec = usec / 1000000;
+	tm.tv_nsec = usec % 1000000;
 
-void wusleep(unsigned int microsecs)
-{
-	poll((struct poll *)0, (size_t) 0, microsecs / 1000);
-}
+	while (nanosleep(&tm, &tm) == -1 && errno == EINTR)
+		;
 
-# else				/* ! HAVE_POLL */
+}
 
-oops !
-# endif				/* !HAVE_POLL */
-#endif				/* !HAVE_SELECT */
diff --git a/configure.ac b/configure.ac
index 1df077c..89bde42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,10 +230,8 @@ dnl Checks for header files.
 dnl =======================
 AC_HEADER_SYS_WAIT
 AC_HEADER_TIME
-AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h sys/types.h \
-		 libintl.h sys/select.h poll.h malloc.h ctype.h string.h \
-		 strings.h)
-
+AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h libintl.h poll.h malloc.h ctype.h \
+		 string.h strings.h)
 
 
 dnl Checks for typedefs, structures, and compiler characteristics.
-- 
1.7.0.4

Reply via email to