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 @@ -68,6 +68,13 @@ set_target_properties(uuid
68
68
target_compile_options (uuid
69
69
PUBLIC
70
70
-I${install_dir}/System/Library/Frameworks/CoreFoundation.framework/Headers )
71
+ if (CMAKE_SYSTEM_NAME STREQUAL Windows )
72
+ target_compile_definitions (uuid
73
+ PRIVATE
74
+ _CRT_NONSTDC_NO_WARNINGS
75
+ _CRT_SECURE_NO_DEPRECATE
76
+ _CRT_SECURE_NO_WARNINGS )
77
+ endif ()
71
78
add_dependencies (uuid CoreFoundation )
72
79
73
80
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