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
c6289186
Commit
c6289186
authored
Apr 15, 2013
by
Russell Belfer
Committed by
Vicent Marti
Apr 22, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for Windows cas/threading stuff
parent
e976b56d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
src/thread-utils.h
+4
-5
src/win32/pthread.c
+11
-6
No files found.
src/thread-utils.h
View file @
c6289186
...
...
@@ -71,16 +71,15 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
GIT_INLINE
(
void
*
)
git___compare_and_swap
(
volatile
void
**
ptr
,
void
*
oldval
,
void
*
newval
)
{
bool
swapped
;
void
*
foundval
;
#if defined(GIT_WIN32)
swapped
=
((
LONGLONG
)
oldval
==
InterlockedCompareExchange64
(
(
LONGLONG
volatile
*
)
ptr
,
(
LONGLONG
)
newval
,
(
LONGLONG
)
oldval
));
foundval
=
InterlockedCompareExchangePointer
(
ptr
,
newval
,
oldval
);
#elif defined(__GNUC__)
swapped
=
(
__sync_val_compare_and_swap
(
ptr
,
oldval
,
newval
)
==
old
val
);
foundval
=
__sync_val_compare_and_swap
(
ptr
,
oldval
,
new
val
);
#else
# error "Unsupported architecture for atomic operations"
#endif
return
swapped
?
oldval
:
newval
;
return
(
foundval
==
oldval
)
?
oldval
:
newval
;
}
#else
...
...
src/win32/pthread.c
View file @
c6289186
...
...
@@ -14,18 +14,23 @@ int pthread_create(
void
*
GIT_RESTRICT
arg
)
{
GIT_UNUSED
(
attr
);
*
thread
=
(
pthread_t
)
CreateThread
(
*
thread
=
CreateThread
(
NULL
,
0
,
(
LPTHREAD_START_ROUTINE
)
start_routine
,
arg
,
0
,
NULL
);
return
*
thread
?
0
:
-
1
;
}
int
pthread_join
(
pthread_t
thread
,
void
**
value_ptr
)
{
int
ret
;
ret
=
WaitForSingleObject
(
thread
,
INFINITE
);
if
(
ret
&&
value_ptr
)
GetExitCodeThread
(
thread
,
(
void
*
)
value_ptr
);
return
-
(
!!
ret
);
DWORD
ret
=
WaitForSingleObject
(
thread
,
INFINITE
);
if
(
ret
==
WAIT_OBJECT_0
)
{
if
(
value_ptr
!=
NULL
)
GetExitCodeThread
(
thread
,
(
void
*
)
value_ptr
);
CloseHandle
(
thread
);
return
0
;
}
return
-
1
;
}
int
pthread_mutex_init
(
pthread_mutex_t
*
GIT_RESTRICT
mutex
,
...
...
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