StdLib|LibC: Implement the sleep() function.

Implement the sleep() function and make both sleep() and usleep() public.  Required initially for Python, but these functions have general applicability.

Signed-off-by: duanev@gmail.com
Reviewed-by:   darylm503


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12323 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503 2011-09-11 20:09:02 +00:00
parent 6c0ebd5f2f
commit 5252c2920c
2 changed files with 16 additions and 15 deletions

View File

@ -37,6 +37,8 @@ extern int optind;
pid_t getpgrp(void); pid_t getpgrp(void);
pid_t tcgetpgrp(int); pid_t tcgetpgrp(int);
char *getpass(const char *); char *getpass(const char *);
int usleep(useconds_t);
unsigned int sleep(unsigned int);
// Networking // Networking
long gethostid(void); long gethostid(void);
@ -84,7 +86,6 @@ int setgid(gid_t);
int setpgid(pid_t, pid_t); int setpgid(pid_t, pid_t);
pid_t setsid(void); pid_t setsid(void);
int setuid(uid_t); int setuid(uid_t);
unsigned int sleep(unsigned int);
long sysconf(int); long sysconf(int);
int tcsetpgrp(int, pid_t); int tcsetpgrp(int, pid_t);
@ -127,7 +128,6 @@ void swab(const void *, void *, size_t);
int symlink(const char *, const char *); int symlink(const char *, const char *);
void sync(void); void sync(void);
useconds_t ualarm(useconds_t, useconds_t); useconds_t ualarm(useconds_t, useconds_t);
int usleep(useconds_t);
pid_t vfork(void) __RENAME(__vfork14); pid_t vfork(void) __RENAME(__vfork14);
/* /*

View File

@ -74,19 +74,14 @@
#define MAX_SLEEP_DELAY 0xfffffffe #define MAX_SLEEP_DELAY 0xfffffffe
// /** Sleep for the specified number of Microseconds.
// Name:
// usleep Implements the usleep(3) function.
//
// Description: @param[in] Microseconds Number of microseconds to sleep.
// Implement usleep(3) function.
// @retval 0 Always returns zero.
// Arguments: **/
// Microseconds to sleep.
//
// Returns:
// 0
//
int int
usleep( useconds_t Microseconds ) usleep( useconds_t Microseconds )
{ {
@ -98,6 +93,12 @@ usleep( useconds_t Microseconds )
return (0); return (0);
} }
unsigned int
sleep( unsigned int Seconds )
{
return (usleep( useconds_t(Seconds * 1000000) ));
}
static int static int
selscan( selscan(
fd_mask **ibits, fd_mask **ibits,