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
aab266c9
Commit
aab266c9
authored
Jun 20, 2016
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
threads: add platform-independent thread initialization function
parent
8aaa9fb6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
32 deletions
+32
-32
src/global.c
+1
-1
src/unix/pthread.h
+1
-0
src/win32/thread.c
+28
-29
src/win32/thread.h
+2
-2
No files found.
src/global.c
View file @
aab266c9
...
...
@@ -134,7 +134,7 @@ static int synchronized_threads_init(void)
_tls_index
=
TlsAlloc
();
win32_pthread_initialize
();
git_threads_init
();
if
(
git_mutex_init
(
&
git__mwindow_mutex
))
return
-
1
;
...
...
src/unix/pthread.h
View file @
aab266c9
...
...
@@ -12,6 +12,7 @@ typedef struct {
pthread_t
thread
;
}
git_thread
;
#define git_threads_init() (void)0
#define git_thread_create(git_thread_ptr, start_routine, arg) \
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
#define git_thread_join(git_thread_ptr, status) \
...
...
src/win32/thread.c
View file @
aab266c9
...
...
@@ -10,6 +10,14 @@
#define CLEAN_THREAD_EXIT 0x6F012842
typedef
void
(
WINAPI
*
win32_srwlock_fn
)(
GIT_SRWLOCK
*
);
static
win32_srwlock_fn
win32_srwlock_initialize
;
static
win32_srwlock_fn
win32_srwlock_acquire_shared
;
static
win32_srwlock_fn
win32_srwlock_release_shared
;
static
win32_srwlock_fn
win32_srwlock_acquire_exclusive
;
static
win32_srwlock_fn
win32_srwlock_release_exclusive
;
/* The thread procedure stub used to invoke the caller's procedure
* and capture the return value for later collection. Windows will
* only hold a DWORD, but we need to be able to store an entire
...
...
@@ -25,6 +33,26 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
return
CLEAN_THREAD_EXIT
;
}
int
git_threads_init
(
void
)
{
HMODULE
hModule
=
GetModuleHandleW
(
L"kernel32"
);
if
(
hModule
)
{
win32_srwlock_initialize
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"InitializeSRWLock"
);
win32_srwlock_acquire_shared
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"AcquireSRWLockShared"
);
win32_srwlock_release_shared
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"ReleaseSRWLockShared"
);
win32_srwlock_acquire_exclusive
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"AcquireSRWLockExclusive"
);
win32_srwlock_release_exclusive
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"ReleaseSRWLockExclusive"
);
}
return
0
;
}
int
git_thread_create
(
git_thread
*
GIT_RESTRICT
thread
,
void
*
(
*
start_routine
)(
void
*
),
...
...
@@ -152,15 +180,6 @@ int git_cond_signal(git_cond *cond)
return
0
;
}
typedef
void
(
WINAPI
*
win32_srwlock_fn
)(
GIT_SRWLOCK
*
);
static
win32_srwlock_fn
win32_srwlock_initialize
;
static
win32_srwlock_fn
win32_srwlock_acquire_shared
;
static
win32_srwlock_fn
win32_srwlock_release_shared
;
static
win32_srwlock_fn
win32_srwlock_acquire_exclusive
;
static
win32_srwlock_fn
win32_srwlock_release_exclusive
;
int
git_rwlock_init
(
git_rwlock
*
GIT_RESTRICT
lock
)
{
if
(
win32_srwlock_initialize
)
...
...
@@ -218,23 +237,3 @@ int git_rwlock_free(git_rwlock *lock)
git__memzero
(
lock
,
sizeof
(
*
lock
));
return
0
;
}
int
win32_pthread_initialize
(
void
)
{
HMODULE
hModule
=
GetModuleHandleW
(
L"kernel32"
);
if
(
hModule
)
{
win32_srwlock_initialize
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"InitializeSRWLock"
);
win32_srwlock_acquire_shared
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"AcquireSRWLockShared"
);
win32_srwlock_release_shared
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"ReleaseSRWLockShared"
);
win32_srwlock_acquire_exclusive
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"AcquireSRWLockExclusive"
);
win32_srwlock_release_exclusive
=
(
win32_srwlock_fn
)
GetProcAddress
(
hModule
,
"ReleaseSRWLockExclusive"
);
}
return
0
;
}
src/win32/thread.h
View file @
aab266c9
...
...
@@ -35,6 +35,8 @@ typedef struct {
}
native
;
}
git_rwlock
;
int
git_threads_init
(
void
);
int
git_thread_create
(
git_thread
*
GIT_RESTRICT
,
void
*
(
*
)
(
void
*
),
void
*
GIT_RESTRICT
);
...
...
@@ -57,6 +59,4 @@ int git_rwlock_wrlock(git_rwlock *);
int
git_rwlock_wrunlock
(
git_rwlock
*
);
int
git_rwlock_free
(
git_rwlock
*
);
extern
int
win32_pthread_initialize
(
void
);
#endif
/* INCLUDE_win32_thread_h__ */
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