Kay Sievers wrote: > Please drop such comments. Done. > This needs a better name. We better don't pass usecs to a function > called nsleep. :) I did a conditional replacement now with the same name. > Please remove the newline in the middle of the logical block (several > occurences). Done too. Reattached a new patch. -- Mierswa, Daniel If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do. --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
From 1c9936d92b2f9e80832180661aabcd7a4d93a2d7 Mon Sep 17 00:00:00 2001 From: Daniel Mierswa <impulze@xxxxxxxxxxx> Date: Mon, 17 Aug 2009 16:02:59 +0200 Subject: [PATCH] Use nanosleep() instead of usleep() POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008 removes it. If usleep() is no longer present on a system, we use nanosleep() instead. --- configure.ac | 1 + extras/modem-modeswitch/ma8280p_us.c | 1 + libudev/libudev-private.h | 11 +++++++++++ 3 files changed, 13 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index 3afb94a..c32e22b 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,7 @@ AC_PROG_AWK GTK_DOC_CHECK(1.10) AC_PREFIX_DEFAULT([/usr]) AC_PATH_PROG([XSLTPROC], [xsltproc]) +AC_CHECK_FUNCS([usleep]) AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=DIR], [rootfs directory to install shared libraries]), diff --git a/extras/modem-modeswitch/ma8280p_us.c b/extras/modem-modeswitch/ma8280p_us.c index 13d1116..626207e 100644 --- a/extras/modem-modeswitch/ma8280p_us.c +++ b/extras/modem-modeswitch/ma8280p_us.c @@ -91,6 +91,7 @@ #include "utils.h" #include "ma8280p_us.h" +#include "libudev-private.h" int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) { diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h index 16f9f2e..736df7a 100644 --- a/libudev/libudev-private.h +++ b/libudev/libudev-private.h @@ -15,6 +15,17 @@ #include <syslog.h> #include "libudev.h" +#ifndef HAVE_USLEEP +# include <time.h> +# define usleep(usec) \ + do { \ + struct timespec time; \ + time.tv_sec = usec / 1000000; \ + time.tv_nsec = (usec - (time.tv_sec * 1000000)) * 1000; \ + return nanosleep(&time, NULL); \ + } while (0) +#endif + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define READ_END 0 #define WRITE_END 1 -- 1.6.4