diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-11-15 12:46:19 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-11-15 12:46:19 +0300 |
commit | 2a7f8d3cb332055f026cd09933136d6981b585e7 (patch) | |
tree | ae93233578e32570c1f5d47f83dd0b81a9bfefb9 /source/blender/blenlib | |
parent | 44517c5f2177d1f260ba691fb59fbacfef576915 (diff) | |
parent | 556b13f03e561b54d4f0186e207f080c786f8b66 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/intern/math_matrix.c
source/blender/blenlib/intern/rand.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/makesrna/intern/rna_mask.c
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_threads.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rand.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 27 |
3 files changed, 22 insertions, 11 deletions
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 0b1b4d8ee8c..60da6b39cbe 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -111,8 +111,10 @@ void BLI_mutex_unlock(ThreadMutex *mutex); /* Spin Lock */ -#ifdef __APPLE__ +#if defined(__APPLE__) typedef OSSpinLock SpinLock; +#elif defined(_MSC_VER) +typedef volatile int SpinLock; #else typedef pthread_spinlock_t SpinLock; #endif diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 9ab39dda9d0..1a178db1413 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -453,4 +453,4 @@ void BLI_hammersley_2D_sequence(unsigned int n, double *r) r[s * 2 + 0] = (double)(s + 0.5) / (double)n; r[s * 2 + 1] = radical_inverse(s); } -}
\ No newline at end of file +} diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index abf611d1245..fbb64f3ece2 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -472,8 +472,10 @@ void BLI_mutex_free(ThreadMutex *mutex) void BLI_spin_init(SpinLock *spin) { -#ifdef __APPLE__ +#if defined(__APPLE__) *spin = OS_SPINLOCK_INIT; +#elif defined(_MSC_VER) + *spin = 0; #else pthread_spin_init(spin, 0); #endif @@ -481,8 +483,14 @@ void BLI_spin_init(SpinLock *spin) void BLI_spin_lock(SpinLock *spin) { -#ifdef __APPLE__ +#if defined(__APPLE__) OSSpinLockLock(spin); +#elif defined(_MSC_VER) + while (InterlockedExchangeAcquire(spin, 1)) { + while (*spin) { + /* pass */ + } + } #else pthread_spin_lock(spin); #endif @@ -490,23 +498,24 @@ void BLI_spin_lock(SpinLock *spin) void BLI_spin_unlock(SpinLock *spin) { -#ifdef __APPLE__ +#if defined(__APPLE__) OSSpinLockUnlock(spin); +#elif defined(_MSC_VER) + _ReadWriteBarrier(); + *spin = 0; #else pthread_spin_unlock(spin); #endif } -#ifndef __APPLE__ void BLI_spin_end(SpinLock *spin) { - pthread_spin_destroy(spin); -} +#if defined(__APPLE__) +#elif defined(_MSC_VER) #else -void BLI_spin_end(SpinLock *UNUSED(spin)) -{ -} + pthread_spin_destroy(spin); #endif +} /* Read/Write Mutex Lock */ |