diff options
Diffstat (limited to 'examples/xusb.c')
-rw-r--r-- | examples/xusb.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/examples/xusb.c b/examples/xusb.c index a1d9f4a..46fb750 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -18,36 +18,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <stdarg.h> +#include <stdbool.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> +#include <time.h> #include "libusb.h" -#if defined(_WIN32) -#define msleep(msecs) Sleep(msecs) -#else -#include <time.h> -#define msleep(msecs) nanosleep(&(struct timespec){msecs / 1000, (msecs * 1000000) % 1000000000UL}, NULL); -#endif - #if defined(_MSC_VER) #define snprintf _snprintf #define putenv _putenv #endif -#if !defined(bool) -#define bool int -#endif -#if !defined(true) -#define true (1 == 1) -#endif -#if !defined(false) -#define false (!true) -#endif - // Future versions of libusb will use usb_interface instead of interface // in libusb_config_descriptor => catter for that #define usb_interface interface @@ -58,6 +43,16 @@ static bool extra_info = false; static bool force_device_request = false; // For WCID descriptor queries static const char* binary_name = NULL; +static inline void msleep(int msecs) +{ +#if defined(_WIN32) + Sleep(msecs); +#else + const struct timespec ts = { msecs / 1000, (msecs % 1000) * 1000000L }; + nanosleep(&ts, NULL); +#endif +} + static void perr(char const *format, ...) { va_list args; |