September 30, 2019 9:17 AM, "Hans-Kristian Arntzen" post@arntzen-software.no wrote:
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 1ac8a63..fab0cd4 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -78,7 +84,11 @@ static inline bool vkd3d_bitmask_is_contiguous(unsigned int mask) /* Undefined for x == 0. */ static inline unsigned int vkd3d_log2i(unsigned int x) { -#ifdef HAVE_BUILTIN_CLZ +#ifdef _MSC_VER
- unsigned long result;
- _BitScanReverse(&result, x);
- return (unsigned int)x;
Are you sure this is correct?
diff --git a/include/private/vkd3d_threads.h b/include/private/vkd3d_threads.h new file mode 100644 index 0000000..b613b50 --- /dev/null +++ b/include/private/vkd3d_threads.h @@ -0,0 +1,166 @@
[...]
+typedef struct pthread_mutex +{
- CRITICAL_SECTION *lock;
+} pthread_mutex_t;
+typedef struct pthread_cond +{
- CONDITION_VARIABLE *cond;
+} pthread_cond_t;
Why not simply store the objects directly in the struct, instead of allocating them on the heap?
[...]
+static DWORD WINAPI win32_thread_wrapper_routine(struct vkd3d_pthread_wrapper_struct *wrapper) +{
- struct vkd3d_pthread_wrapper_struct tmp = *wrapper;
- vkd3d_free(wrapper);
I get why this is on the heap--if it were on the stack, then if pthread_create() returns before the new thread can access the struct, the new thread may end up using garbage. But I can't help thinking there has to be another way.
Chip