diff options
author | Chris Sutcliffe <ir0nh34d@users.sourceforge.net> | 2008-05-04 16:18:52 +0400 |
---|---|---|
committer | Chris Sutcliffe <ir0nh34d@users.sourceforge.net> | 2008-05-04 16:18:52 +0400 |
commit | 1e6db69571b7cd4c3394c3efd7dd59fd0322a08e (patch) | |
tree | c405669b3826bfc86dbb7b0a9c6075015a21b7ee /winsup/mingw | |
parent | d5992b586e951e8aaeaeededf98bf78be0cd82cf (diff) |
2008-05-04 Ramiro Polla <ramiro@lisha.ufsc.br>
* include/sys/time.h (useconds_t): typedef.
* include/unistd.h (usleep): Add prototype.
* mingwex/usleep.c: New file.
* mingwex/makefile.in: Add usleep source and object.
Diffstat (limited to 'winsup/mingw')
-rw-r--r-- | winsup/mingw/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/mingw/include/unistd.h | 5 | ||||
-rw-r--r-- | winsup/mingw/mingwex/Makefile.in | 2 | ||||
-rwxr-xr-x | winsup/mingw/mingwex/usleep.c | 40 |
4 files changed, 55 insertions, 1 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 504797d2c..f3bcac30b 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,4 +1,11 @@ -2008-04-02 Ramiro Polla <ramiro@lisha.ufsc.br> +2008-05-04 Ramiro Polla <ramiro@lisha.ufsc.br> + + * include/sys/time.h (useconds_t): typedef. + * include/unistd.h (usleep): Add prototype. + * mingwex/usleep.c: New file. + * mingwex/makefile.in: Add usleep source and object. + +2008-05-02 Ramiro Polla <ramiro@lisha.ufsc.br> Make strtod() conform to C99. diff --git a/winsup/mingw/include/unistd.h b/winsup/mingw/include/unistd.h index 90934a0ed..54dbc6699 100644 --- a/winsup/mingw/include/unistd.h +++ b/winsup/mingw/include/unistd.h @@ -31,6 +31,11 @@ extern "C" { #endif +#if !defined __NO_ISOCEXT +#include <sys/types.h> /* For useconds_t. */ + +int __cdecl __MINGW_NOTHROW usleep(useconds_t useconds); +#endif /* Not __NO_ISOCEXT */ /* This is defined as a real library function to allow autoconf to verify its existence. */ diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index 3dd91a5b7..9010634cb 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -38,6 +38,7 @@ DISTFILES = Makefile.in configure configure.in aclocal.m4 \ wcrtomb.c wctob.c mbrtowc.c btowc.c mb_wc_common.h \ gettimeofday.c isblank.c iswblank.c \ basename.c dirname.c \ + usleep.c \ tsearch.c twalk.c tdelete.c tfind.c MATH_DISTFILES = \ @@ -174,6 +175,7 @@ FENV_OBJS = fesetround.o fegetround.o \ feraiseexcept.o fetestexcept.o fesetexceptflag.o POSIX_OBJS = \ dirent.o wdirent.o getopt.o ftruncate.o gettimeofday.o \ + usleep.o \ basename.o dirname.o tsearch.o twalk.o tdelete.o tfind.o REPLACE_OBJS = \ mingw-aligned-malloc.o mingw-fseek.o diff --git a/winsup/mingw/mingwex/usleep.c b/winsup/mingw/mingwex/usleep.c new file mode 100755 index 000000000..b322a7703 --- /dev/null +++ b/winsup/mingw/mingwex/usleep.c @@ -0,0 +1,40 @@ +/* + * usleep + * Implementation according to: + * The Open Group Base Specifications Issue 6 + * IEEE Std 1003.1, 2004 Edition + */ + +/* + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Contributed by: + * Ramiro Polla <ramiro@lisha.ufsc.br> + */ + +#include <sys/types.h> +#include <errno.h> + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +int __cdecl usleep(useconds_t useconds) +{ + if(useconds == 0) + return 0; + + if(useconds >= 1000000) + return EINVAL; + + Sleep(useconds / 1000); + + return 0; +} |