File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ add_library(uuid
65
65
target_compile_options (uuid
66
66
PUBLIC
67
67
-I${install_dir}/System/Library/Frameworks/CoreFoundation.framework/Headers )
68
+ if (CMAKE_SYSTEM_NAME STREQUAL Windows )
69
+ target_compile_definitions (uuid
70
+ PRIVATE
71
+ _CRT_NONSTDC_NO_WARNINGS
72
+ _CRT_SECURE_NO_DEPRECATE
73
+ _CRT_SECURE_NO_WARNINGS )
74
+ endif ()
68
75
add_dependencies (uuid CoreFoundation )
69
76
70
77
set (swift_optimization_flags )
Original file line number Diff line number Diff line change 35
35
#include <stdint.h>
36
36
#include <string.h>
37
37
#include <fcntl.h>
38
+ #if defined(__unix__ ) || (defined(__APPLE__ ) && defined(__MACH__ ))
38
39
#include <unistd.h>
40
+ #elif defined(_WIN32 )
41
+ #include <io.h>
42
+ #endif
39
43
#include <stdio.h>
40
44
41
45
#if TARGET_OS_MAC
@@ -61,9 +65,25 @@ static inline void nanotime(struct timespec *tv) {
61
65
clock_gettime (CLOCK_MONOTONIC , tv );
62
66
}
63
67
68
+ #elif TARGET_OS_WINDOWS
69
+ #include <time.h>
70
+
71
+ #define WIN32_LEAN_AND_MEAN
72
+ #include <windows.h>
73
+
74
+ static inline void nanotime (struct timespec * tv ) {
75
+ FILETIME ftTime ;
76
+
77
+ GetSystemTimePreciseAsFileTime (& ftTime );
78
+
79
+ uint64_t Value = (((uint64_t )ftTime .dwHighDateTime << 32 ) | ftTime .dwLowDateTime );
80
+
81
+ tv -> tv_sec = Value / 1000000000 ;
82
+ tv -> tv_nsec = Value - (tv -> tv_sec * 1000000000 );
83
+ }
64
84
#endif
65
85
66
- static inline void read_random (void * buffer , u_int numBytes ) {
86
+ static inline void read_random (void * buffer , unsigned numBytes ) {
67
87
int fd = open ("/dev/urandom" , O_RDONLY );
68
88
read (fd , buffer , numBytes );
69
89
close (fd );
227
247
uuid_unparse (const uuid_t uu , uuid_string_t out )
228
248
{
229
249
uuid_unparse_upper (uu , out );
230
- }
250
+ }
You can’t perform that action at this time.
0 commit comments