diff options
author | Miguel de Icaza <miguel@gnome.org> | 2009-12-24 07:20:11 +0300 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2009-12-24 07:20:11 +0300 |
commit | 947fda6c26ad696bb9f65f6177a8c031330371b2 (patch) | |
tree | 7ed92e3943a585d7bce04085217092974a5016dd /eglib | |
parent | a3f68b0145b9754fcb12dc82d2dc52dd9ae8e8e6 (diff) |
Add g_usleep
svn path=/trunk/mono/; revision=148884
Diffstat (limited to 'eglib')
-rw-r--r-- | eglib/src/gdate-unix.c | 15 | ||||
-rw-r--r-- | eglib/src/gdate-win32.c | 5 | ||||
-rw-r--r-- | eglib/src/glib.h | 1 |
3 files changed, 20 insertions, 1 deletions
diff --git a/eglib/src/gdate-unix.c b/eglib/src/gdate-unix.c index 55528e3f467..5573e0d3570 100644 --- a/eglib/src/gdate-unix.c +++ b/eglib/src/gdate-unix.c @@ -27,7 +27,8 @@ */ #include <stdio.h> #include <glib.h> - +#include <time.h> +#include <errno.h> #include <sys/time.h> void @@ -40,3 +41,15 @@ g_get_current_time (GTimeVal *result) result->tv_sec = tv.tv_sec; result->tv_usec = tv.tv_usec; } + +void +g_usleep (gulong microseconds) +{ + struct timespec req, rem; + + req.tv_sec = microseconds / 1000000; + req.tv_nsec = (microseconds % 1000000) * 1000; + + while (nanosleep (&req, &rem) == -1 && errno == EINTR) + req = rem; +} diff --git a/eglib/src/gdate-win32.c b/eglib/src/gdate-win32.c index 30dd4a029ae..b00e9b7bd36 100644 --- a/eglib/src/gdate-win32.c +++ b/eglib/src/gdate-win32.c @@ -42,3 +42,8 @@ g_get_current_time (GTimeVal *result) result->tv_usec = (l % 1000) * 1000; } +void +g_usleep (gulong microseconds) +{ + Sleep (microseconds/1000); +} diff --git a/eglib/src/glib.h b/eglib/src/glib.h index c41d4135e7a..2d1e5f39063 100644 --- a/eglib/src/glib.h +++ b/eglib/src/glib.h @@ -689,6 +689,7 @@ typedef struct { } GTimeVal; void g_get_current_time (GTimeVal *result); +void g_usleep (gulong microseconds); /* * File |