linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mierswa <impulze@impulze.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] Use nanosleep() instead of usleep()
Date: Tue, 18 Aug 2009 05:08:53 +0000	[thread overview]
Message-ID: <4A8A3765.5060504@impulze.org> (raw)
In-Reply-To: <4A896729.3010302@impulze.org>

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

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

[-- Attachment #2: 0001-Use-nanosleep-instead-of-usleep.patch --]
[-- Type: text/plain, Size: 1909 bytes --]

From 1c9936d92b2f9e80832180661aabcd7a4d93a2d7 Mon Sep 17 00:00:00 2001
From: Daniel Mierswa <impulze@impulze.org>
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


  parent reply	other threads:[~2009-08-18  5:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-17 14:20 [PATCH] Use nanosleep() instead of usleep() Daniel Mierswa
2009-08-18  0:22 ` Kay Sievers
2009-08-18  5:08 ` Daniel Mierswa [this message]
2009-08-19  2:17 ` Kay Sievers
2009-08-19  5:35 ` Daniel Mierswa
2009-08-24 16:41 ` Scott James Remnant
2009-08-24 17:23 ` Daniel Mierswa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A8A3765.5060504@impulze.org \
    --to=impulze@impulze.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).