-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -35,6 +36,19 @@ gum_spinlock_acquire (GumSpinlock * spinlock) | |
#endif | ||
} | ||
|
||
gboolean | ||
gum_spinlock_try_acquire (GumSpinlock * spinlock) | ||
{ | ||
GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; | ||
|
||
if (self->is_held) | ||
return FALSE; | ||
|
||
gum_spinlock_acquire (spinlock); | ||
|
||
return TRUE; | ||
} | ||
|
||
void | ||
gum_spinlock_release (GumSpinlock * spinlock) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2014-2019 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -30,6 +31,19 @@ gum_spinlock_acquire (GumSpinlock * spinlock) | |
; | ||
} | ||
|
||
gboolean | ||
gum_spinlock_try_acquire (GumSpinlock * spinlock) | ||
{ | ||
GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; | ||
|
||
if (self->is_held) | ||
return FALSE; | ||
|
||
gum_spinlock_acquire (spinlock); | ||
|
||
return TRUE; | ||
} | ||
|
||
void | ||
gum_spinlock_release (GumSpinlock * spinlock) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2014-2019 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -30,6 +31,19 @@ gum_spinlock_acquire (GumSpinlock * spinlock) | |
; | ||
} | ||
|
||
gboolean | ||
gum_spinlock_try_acquire (GumSpinlock * spinlock) | ||
{ | ||
GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; | ||
|
||
if (self->is_held) | ||
return FALSE; | ||
|
||
gum_spinlock_acquire (spinlock); | ||
|
||
return TRUE; | ||
} | ||
|
||
void | ||
gum_spinlock_release (GumSpinlock * spinlock) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2010-2019 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -30,6 +31,19 @@ gum_spinlock_acquire (GumSpinlock * spinlock) | |
; | ||
} | ||
|
||
gboolean | ||
gum_spinlock_try_acquire (GumSpinlock * spinlock) | ||
{ | ||
GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; | ||
|
||
if (self->is_held) | ||
return FALSE; | ||
|
||
gum_spinlock_acquire (spinlock); | ||
|
||
return TRUE; | ||
} | ||
|
||
void | ||
gum_spinlock_release (GumSpinlock * spinlock) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2010-2019 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -35,6 +36,19 @@ gum_spinlock_acquire (GumSpinlock * spinlock) | |
} | ||
} | ||
|
||
gboolean | ||
gum_spinlock_try_acquire (GumSpinlock * spinlock) | ||
{ | ||
volatile guint32 is_held = *(guint32 *) spinlock; | ||
|
||
if (is_held == 1) | ||
return FALSE; | ||
|
||
gum_spinlock_acquire (spinlock); | ||
|
||
return TRUE; | ||
} | ||
|
||
__declspec (naked) void | ||
gum_spinlock_release (GumSpinlock * spinlock) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2010-2019 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -30,6 +31,19 @@ gum_spinlock_acquire (GumSpinlock * spinlock) | |
; | ||
} | ||
|
||
gboolean | ||
gum_spinlock_try_acquire (GumSpinlock * spinlock) | ||
{ | ||
GumSpinlockImpl * self = (GumSpinlockImpl *) spinlock; | ||
|
||
if (self->is_held) | ||
return FALSE; | ||
|
||
gum_spinlock_acquire (spinlock); | ||
|
||
return TRUE; | ||
} | ||
|
||
void | ||
gum_spinlock_release (GumSpinlock * spinlock) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2010-2019 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -23,6 +24,7 @@ struct _GumSpinlock | |
void gum_spinlock_init (GumSpinlock * spinlock); | ||
|
||
void gum_spinlock_acquire (GumSpinlock * spinlock); | ||
gboolean gum_spinlock_try_acquire (GumSpinlock * spinlock); | ||
void gum_spinlock_release (GumSpinlock * spinlock); | ||
|
||
G_END_DECLS | ||
|