@@ -78,23 +78,47 @@ py_UuidCreate(PyObject *Py_UNUSED(context),
78
78
return NULL ;
79
79
}
80
80
81
+ static int
82
+ py_windows_has_stable_node (void )
83
+ {
84
+ UUID uuid ;
85
+ RPC_STATUS res ;
86
+ Py_BEGIN_ALLOW_THREADS
87
+ res = UuidCreateSequential (& uuid );
88
+ Py_END_ALLOW_THREADS
89
+ return res == RPC_S_OK ;
90
+ }
81
91
#endif /* MS_WINDOWS */
82
92
83
93
84
94
static int
85
- uuid_exec (PyObject * module ) {
95
+ uuid_exec (PyObject * module )
96
+ {
97
+ #define ADD_INT (NAME , VALUE ) \
98
+ do { \
99
+ if (PyModule_AddIntConstant(module, (NAME), (VALUE)) < 0) { \
100
+ return -1; \
101
+ } \
102
+ } while (0)
103
+
86
104
assert (sizeof (uuid_t ) == 16 );
87
105
#if defined(MS_WINDOWS )
88
- int has_uuid_generate_time_safe = 0 ;
106
+ ADD_INT ( " has_uuid_generate_time_safe" , 0 ) ;
89
107
#elif defined(HAVE_UUID_GENERATE_TIME_SAFE )
90
- int has_uuid_generate_time_safe = 1 ;
108
+ ADD_INT ( " has_uuid_generate_time_safe" , 1 ) ;
91
109
#else
92
- int has_uuid_generate_time_safe = 0 ;
110
+ ADD_INT ( " has_uuid_generate_time_safe" , 0 ) ;
93
111
#endif
94
- if (PyModule_AddIntConstant (module , "has_uuid_generate_time_safe" ,
95
- has_uuid_generate_time_safe ) < 0 ) {
96
- return -1 ;
97
- }
112
+
113
+ #if defined(MS_WINDOWS )
114
+ ADD_INT ("has_stable_extractable_node" , py_windows_has_stable_node ());
115
+ #elif defined(HAVE_UUID_GENERATE_TIME_SAFE_STABLE_MAC )
116
+ ADD_INT ("has_stable_extractable_node" , 1 );
117
+ #else
118
+ ADD_INT ("has_stable_extractable_node" , 0 );
119
+ #endif
120
+
121
+ #undef ADD_INT
98
122
return 0 ;
99
123
}
100
124
0 commit comments