-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interceptor: Add with_lock_held() and is_locked()
- Loading branch information
Showing
3 changed files
with
32 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,6 +1,7 @@ | ||
/* | ||
* Copyright (C) 2008-2022 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2008 Christian Berentsen <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -809,6 +810,26 @@ gum_interceptor_restore (GumInvocationState * state) | |
g_array_set_size (stack, old_depth); | ||
} | ||
|
||
void | ||
gum_interceptor_with_lock_held (GumInterceptor * self, | ||
GumInterceptorLockedFunc func, | ||
gpointer user_data) | ||
{ | ||
GUM_INTERCEPTOR_LOCK (self); | ||
func (user_data); | ||
GUM_INTERCEPTOR_UNLOCK (self); | ||
} | ||
|
||
gboolean | ||
gum_interceptor_is_locked (GumInterceptor * self) | ||
{ | ||
if (!g_rec_mutex_trylock (&self->mutex)) | ||
return TRUE; | ||
|
||
GUM_INTERCEPTOR_UNLOCK (self); | ||
return FALSE; | ||
} | ||
|
||
gpointer | ||
_gum_interceptor_peek_top_caller_return_address (void) | ||
{ | ||
|
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,6 +1,7 @@ | ||
/* | ||
* Copyright (C) 2008-2022 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2008 Christian Berentsen <[email protected]> | ||
* Copyright (C) 2024 Francesco Tamagni <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -19,6 +20,7 @@ GUM_DECLARE_FINAL_TYPE (GumInterceptor, gum_interceptor, GUM, INTERCEPTOR, | |
|
||
typedef GArray GumInvocationStack; | ||
typedef guint GumInvocationState; | ||
typedef void (* GumInterceptorLockedFunc) (gpointer user_data); | ||
|
||
typedef enum | ||
{ | ||
|
@@ -76,6 +78,10 @@ GUM_API gpointer gum_invocation_stack_translate (GumInvocationStack * self, | |
GUM_API void gum_interceptor_save (GumInvocationState * state); | ||
GUM_API void gum_interceptor_restore (GumInvocationState * state); | ||
|
||
GUM_API void gum_interceptor_with_lock_held (GumInterceptor * self, | ||
GumInterceptorLockedFunc func, gpointer user_data); | ||
GUM_API gboolean gum_interceptor_is_locked (GumInterceptor * self); | ||
|
||
G_END_DECLS | ||
|
||
#endif |
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