summaryrefslogtreecommitdiff
path: root/src/threadstate.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-05-15 11:47:09 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-10-11 20:13:04 +0100
commite316b0d3d64eb8f65f4109c1565d929b29e1d33a (patch)
tree1742e4956f2a8a91ef574cf67c6d05d91910407f /src/threadstate.c
parent8970acb750ecf4b86883d9ea1a8cb280517e6c86 (diff)
downloadlibgit2-e316b0d3d64eb8f65f4109c1565d929b29e1d33a.tar.gz
runtime: move init/shutdown into the "runtime"
Provide a mechanism for system components to register for initialization and shutdown of the libgit2 runtime.
Diffstat (limited to 'src/threadstate.c')
-rw-r--r--src/threadstate.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/threadstate.c b/src/threadstate.c
index 4aa1c034a..8e17124a2 100644
--- a/src/threadstate.c
+++ b/src/threadstate.c
@@ -6,7 +6,7 @@
*/
#include "threadstate.h"
-#include "global.h"
+#include "runtime.h"
static void threadstate_dispose(git_threadstate *threadstate);
@@ -57,9 +57,7 @@ int git_threadstate_global_init(void)
if ((fls_index = FlsAlloc(fls_free)) == FLS_OUT_OF_INDEXES)
return -1;
- git__on_shutdown(git_threadstate_global_shutdown);
-
- return 0;
+ return git_runtime_shutdown_register(git_threadstate_global_shutdown);
}
git_threadstate *git_threadstate_get(void)
@@ -105,9 +103,7 @@ int git_threadstate_global_init(void)
if (pthread_key_create(&tls_key, &tls_free) != 0)
return -1;
- git__on_shutdown(git_threadstate_global_shutdown);
-
- return 0;
+ return git_runtime_shutdown_register(git_threadstate_global_shutdown);
}
git_threadstate *git_threadstate_get(void)
@@ -134,14 +130,12 @@ static git_threadstate threadstate;
static void git_threadstate_global_shutdown(void)
{
threadstate_dispose(&threadstate);
- memset(&threadstate, 0, sizeof(git_threadstate);
+ memset(&threadstate, 0, sizeof(git_threadstate));
}
int git_threadstate_global_init(void)
{
- git__on_shutdown(git_threadstate_global_shutdown);
-
- return 0;
+ return git_runtime_shutdown_register(git_tlsdata_global_shutdown);
}
git_threadstate *git_threadstate_get(void)