summaryrefslogtreecommitdiff
path: root/thirdparty/pcre2/src/sljit/sljitUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/pcre2/src/sljit/sljitUtils.c')
-rw-r--r--thirdparty/pcre2/src/sljit/sljitUtils.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/thirdparty/pcre2/src/sljit/sljitUtils.c b/thirdparty/pcre2/src/sljit/sljitUtils.c
index 08ca35cf37..9bce714735 100644
--- a/thirdparty/pcre2/src/sljit/sljitUtils.c
+++ b/thirdparty/pcre2/src/sljit/sljitUtils.c
@@ -48,7 +48,7 @@ static HANDLE allocator_lock;
static SLJIT_INLINE void allocator_grab_lock(void)
{
HANDLE lock;
- if (SLJIT_UNLIKELY(!allocator_lock)) {
+ if (SLJIT_UNLIKELY(!InterlockedCompareExchangePointer(&allocator_lock, NULL, NULL))) {
lock = CreateMutex(NULL, FALSE, NULL);
if (InterlockedCompareExchangePointer(&allocator_lock, lock, NULL))
CloseHandle(lock);
@@ -146,9 +146,13 @@ static SLJIT_INLINE sljit_sw get_page_alignment(void) {
#include <unistd.h>
static SLJIT_INLINE sljit_sw get_page_alignment(void) {
- static sljit_sw sljit_page_align;
- if (!sljit_page_align) {
+ static sljit_sw sljit_page_align = -1;
+ if (sljit_page_align < 0) {
+#ifdef _SC_PAGESIZE
sljit_page_align = sysconf(_SC_PAGESIZE);
+#else
+ sljit_page_align = getpagesize();
+#endif
/* Should never happen. */
if (sljit_page_align < 0)
sljit_page_align = 4096;