diff --git a/lib/roken/roken.h.in b/lib/roken/roken.h.in index 2cf596c4f..6e76b3f63 100644 --- a/lib/roken/roken.h.in +++ b/lib/roken/roken.h.in @@ -969,6 +969,9 @@ gai_strerror(int); ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL sleep(unsigned int seconds); +ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL +usleep(unsigned int useconds); + #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL diff --git a/lib/roken/sleep.c b/lib/roken/sleep.c index 4773f7c02..a2599b90e 100644 --- a/lib/roken/sleep.c +++ b/lib/roken/sleep.c @@ -1,5 +1,5 @@ /*********************************************************************** - * Copyright (c) 2009, Secure Endpoints Inc. + * Copyright (c) 2009, 2014, Secure Endpoints Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,16 @@ ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL sleep(unsigned int seconds) { - SleepEx(1000 * (DWORD) seconds, FALSE); + if (SleepEx(1000 * (DWORD) seconds, FALSE) != 0) + return -1; + return 0; +} + +/* We can only sleep in millisecond increments */ +ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL +usleep(unsigned int useconds) +{ + if (SleepEx((DWORD)(useconds / 1000), FALSE) != 0) + return -1; return 0; }