Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
22661448
Commit
22661448
authored
Oct 04, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use git_atomic as an integer
parent
cdc95a0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
src/global.c
+5
-4
No files found.
src/global.c
View file @
22661448
...
@@ -18,7 +18,6 @@ git_mutex git__mwindow_mutex;
...
@@ -18,7 +18,6 @@ git_mutex git__mwindow_mutex;
git_global_shutdown_fn
git__shutdown_callbacks
[
MAX_SHUTDOWN_CB
];
git_global_shutdown_fn
git__shutdown_callbacks
[
MAX_SHUTDOWN_CB
];
git_atomic
git__n_shutdown_callbacks
;
git_atomic
git__n_shutdown_callbacks
;
git_atomic
git__n_inits
;
void
git__on_shutdown
(
git_global_shutdown_fn
callback
)
void
git__on_shutdown
(
git_global_shutdown_fn
callback
)
{
{
...
@@ -75,6 +74,7 @@ static void git__shutdown(void)
...
@@ -75,6 +74,7 @@ static void git__shutdown(void)
static
DWORD
_tls_index
;
static
DWORD
_tls_index
;
static
DWORD
_mutex
=
0
;
static
DWORD
_mutex
=
0
;
static
DWORD
_n_inits
=
0
;
static
int
synchronized_threads_init
()
static
int
synchronized_threads_init
()
{
{
...
@@ -101,7 +101,7 @@ int git_threads_init(void)
...
@@ -101,7 +101,7 @@ int git_threads_init(void)
while
(
InterlockedCompareExchange
(
&
_mutex
,
1
,
0
))
{
Sleep
(
0
);
}
while
(
InterlockedCompareExchange
(
&
_mutex
,
1
,
0
))
{
Sleep
(
0
);
}
/* Only do work on a 0 -> 1 transition of the refcount */
/* Only do work on a 0 -> 1 transition of the refcount */
if
(
1
==
++
git__n_inits
.
val
)
if
(
1
==
++
_n_inits
)
error
=
synchronized_threads_init
();
error
=
synchronized_threads_init
();
/* Exit the lock */
/* Exit the lock */
...
@@ -124,7 +124,7 @@ void git_threads_shutdown(void)
...
@@ -124,7 +124,7 @@ void git_threads_shutdown(void)
while
(
InterlockedCompareExchange
(
&
_mutex
,
1
,
0
))
{
Sleep
(
0
);
}
while
(
InterlockedCompareExchange
(
&
_mutex
,
1
,
0
))
{
Sleep
(
0
);
}
/* Only do work on a 1 -> 0 transition of the refcount */
/* Only do work on a 1 -> 0 transition of the refcount */
if
(
0
==
--
git__n_inits
.
val
)
if
(
0
==
--
_n_inits
)
synchronized_threads_shutdown
();
synchronized_threads_shutdown
();
/* Exit the lock */
/* Exit the lock */
...
@@ -135,7 +135,7 @@ git_global_st *git__global_state(void)
...
@@ -135,7 +135,7 @@ git_global_st *git__global_state(void)
{
{
void
*
ptr
;
void
*
ptr
;
assert
(
git__n_inits
.
val
);
assert
(
_n_inits
);
if
((
ptr
=
TlsGetValue
(
_tls_index
))
!=
NULL
)
if
((
ptr
=
TlsGetValue
(
_tls_index
))
!=
NULL
)
return
ptr
;
return
ptr
;
...
@@ -153,6 +153,7 @@ git_global_st *git__global_state(void)
...
@@ -153,6 +153,7 @@ git_global_st *git__global_state(void)
static
pthread_key_t
_tls_key
;
static
pthread_key_t
_tls_key
;
static
pthread_once_t
_once_init
=
PTHREAD_ONCE_INIT
;
static
pthread_once_t
_once_init
=
PTHREAD_ONCE_INIT
;
static
git_atomic
git__n_inits
;
int
init_error
=
0
;
int
init_error
=
0
;
static
void
cb__free_status
(
void
*
st
)
static
void
cb__free_status
(
void
*
st
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment