From f8a314ea075745c244172173391e44c146837b87 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 29 Nov 2024 00:58:33 -0500 Subject: performance: reference counters can use relaxed order when incrementing --- src/platform/windows/win_thread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/platform/windows') diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index a6416cd8..9e74056d 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -22,6 +22,8 @@ static pfnSetThreadDescription set_thread_desc; // mingw does not define InterlockedAddNoFence64, use the mingw equivalent #if defined(__MINGW32__) || defined(__MINGW64__) #define InterlockedAddNoFence(a, b) __atomic_add_fetch(a, b, __ATOMIC_RELAXED) +#define InterlockedIncrementNoFence(a) \ + __atomic_add_fetch(a, 1, __ATOMIC_RELAXED) #define InterlockedAddNoFence64(a, b) \ __atomic_add_fetch(a, b, __ATOMIC_RELAXED) #define InterlockedIncrementAcquire64(a) \ @@ -326,7 +328,7 @@ nni_atomic_init(nni_atomic_int *v) void nni_atomic_inc(nni_atomic_int *v) { - (void) InterlockedIncrementAcquire(&v->v); + (void) InterlockedIncrementNoFence(&v->v); } int -- cgit v1.2.3-70-g09d2