#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <sys/time.h>
+#include <fcntl.h>
+#ifdef _WIN32
+ #include <windows.h>
+ #include <io.h>
+#else
+ #include <sys/time.h>
+#endif
#include "util.h"
unsigned int
solv_timems(unsigned int subtract)
{
+#ifdef _WIN32
+ return GetTickCount() - subtract;
+#else
struct timeval tv;
unsigned int r;
r += ((unsigned int)tv.tv_sec & 0xffff) * 1000;
r += (unsigned int)tv.tv_usec / 1000;
return r - subtract;
+#endif
+}
+
+int
+solv_setcloexec(int fd, int state)
+{
+ #ifdef _WIN32
+ return SetHandleInformation((HANDLE) _get_osfhandle(fd), HANDLE_FLAG_INHERIT, state ? 0 : HANDLE_FLAG_INHERIT);
+ #else
+ return fcntl(fd, F_SETFD, state ? FD_CLOEXEC : 0) == 0;
+ #endif
}
/* bsd's qsort_r has different arguments, so we define our
see also: http://sources.redhat.com/ml/libc-alpha/2008-12/msg00003.html
*/
-#if defined(__GLIBC__) && (defined(HAVE_QSORT_R) || defined(HAVE___QSORT_R))
+#if (defined(__GLIBC__) || defined(__NEWLIB__)) && (defined(HAVE_QSORT_R) || defined(HAVE___QSORT_R))
void
solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard)
d = c - ('A' - 10);
else
break;
- c = *++str;
+ c = str[1];
d <<= 4;
if (c >= '0' && c <= '9')
d |= c - '0';
else
break;
buf[i] = d;
- ++str;
+ str += 2;
}
*strp = str;
return i;