This fixes compiling libusb with uclibc.
Closes #141, #165
Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
#if defined(_WIN32)
#define msleep(msecs) Sleep(msecs)
#else
-#include <unistd.h>
-#define msleep(msecs) usleep(1000*msecs)
+#include <time.h>
+#define msleep(msecs) nanosleep(&(struct timespec){delay / 1000, (delay * 1000000) % 1000000000UL}, NULL);
#endif
#if defined(_MSC_VER)
\code
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <libusb.h>
static int count = 0;
while (count < 2) {
libusb_handle_events_completed(NULL, NULL);
- usleep(10000);
+ nanosleep(&(struct timespec){0, 10000000UL}, NULL);
}
libusb_hotplug_deregister_callback(NULL, callback_handle);
*/
#include "config.h"
+#include <time.h>
#include <ctype.h>
#include <errno.h>
#include <pthread.h>
if (kIOReturnSuccess != ret) {
usbi_dbg("kernel responded with code: 0x%08x. sleeping for %d ms before trying again", ret, delay/1000);
/* sleep for a little while before trying again */
- usleep (delay);
+ nanosleep(&(struct timespec){delay / 1000000, (delay * 1000) % 1000000000UL}, NULL);
}
} while (kIOReturnSuccess != ret && retries--);
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
-#include <unistd.h>
+#include <time.h>
#include "libusbi.h"
#include "linux_usbfs.h"
usbi_err(ctx, "File doesn't exist, wait %d ms and try again", delay/1000);
/* Wait 10ms for USB device path creation.*/
- usleep(delay);
+ nanosleep(&(struct timespec){delay / 1000000, (delay * 1000) % 1000000000UL}, NULL);
fd = open(path, mode);
if (fd != -1)
-#define LIBUSB_NANO 11089
+#define LIBUSB_NANO 11092