Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
ae58abea
Commit
ae58abea
authored
9 years ago
by
Matt Oliver
Browse files
Options
Downloads
Patches
Plain Diff
compat/w32pthreads: Add return values to match the simulated pthread functions.
parent
73347516
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compat/w32pthreads.h
+23
-13
23 additions, 13 deletions
compat/w32pthreads.h
with
23 additions
and
13 deletions
compat/w32pthreads.h
+
23
−
13
View file @
ae58abea
...
@@ -87,14 +87,19 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
...
@@ -87,14 +87,19 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
return
!
thread
->
handle
;
return
!
thread
->
handle
;
}
}
static
av_unused
void
pthread_join
(
pthread_t
thread
,
void
**
value_ptr
)
static
av_unused
int
pthread_join
(
pthread_t
thread
,
void
**
value_ptr
)
{
{
DWORD
ret
=
WaitForSingleObject
(
thread
.
handle
,
INFINITE
);
DWORD
ret
=
WaitForSingleObject
(
thread
.
handle
,
INFINITE
);
if
(
ret
!=
WAIT_OBJECT_0
)
if
(
ret
!=
WAIT_OBJECT_0
)
{
return
;
if
(
ret
==
WAIT_ABANDONED
)
return
EINVAL
;
else
return
EDEADLK
;
}
if
(
value_ptr
)
if
(
value_ptr
)
*
value_ptr
=
thread
.
ret
;
*
value_ptr
=
thread
.
ret
;
CloseHandle
(
thread
.
handle
);
CloseHandle
(
thread
.
handle
);
return
0
;
}
}
static
inline
int
pthread_mutex_init
(
pthread_mutex_t
*
m
,
void
*
attr
)
static
inline
int
pthread_mutex_init
(
pthread_mutex_t
*
m
,
void
*
attr
)
...
@@ -126,14 +131,15 @@ static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_att
...
@@ -126,14 +131,15 @@ static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused_att
}
}
/* native condition variables do not destroy */
/* native condition variables do not destroy */
static
inline
void
pthread_cond_destroy
(
pthread_cond_t
*
cond
)
static
inline
int
pthread_cond_destroy
(
pthread_cond_t
*
cond
)
{
{
return
;
return
0
;
}
}
static
inline
void
pthread_cond_broadcast
(
pthread_cond_t
*
cond
)
static
inline
int
pthread_cond_broadcast
(
pthread_cond_t
*
cond
)
{
{
WakeAllConditionVariable
(
cond
);
WakeAllConditionVariable
(
cond
);
return
0
;
}
}
static
inline
int
pthread_cond_wait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
)
static
inline
int
pthread_cond_wait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
)
...
@@ -142,9 +148,10 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex
...
@@ -142,9 +148,10 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex
return
0
;
return
0
;
}
}
static
inline
void
pthread_cond_signal
(
pthread_cond_t
*
cond
)
static
inline
int
pthread_cond_signal
(
pthread_cond_t
*
cond
)
{
{
WakeConditionVariable
(
cond
);
WakeConditionVariable
(
cond
);
return
0
;
}
}
#else // _WIN32_WINNT < 0x0600
#else // _WIN32_WINNT < 0x0600
...
@@ -191,12 +198,12 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
...
@@ -191,12 +198,12 @@ static av_unused int pthread_cond_init(pthread_cond_t *cond, const void *unused_
return
0
;
return
0
;
}
}
static
av_unused
void
pthread_cond_destroy
(
pthread_cond_t
*
cond
)
static
av_unused
int
pthread_cond_destroy
(
pthread_cond_t
*
cond
)
{
{
win32_cond_t
*
win32_cond
=
cond
->
Ptr
;
win32_cond_t
*
win32_cond
=
cond
->
Ptr
;
/* native condition variables do not destroy */
/* native condition variables do not destroy */
if
(
cond_init
)
if
(
cond_init
)
return
;
return
0
;
/* non native condition variables */
/* non native condition variables */
CloseHandle
(
win32_cond
->
semaphore
);
CloseHandle
(
win32_cond
->
semaphore
);
...
@@ -205,16 +212,17 @@ static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
...
@@ -205,16 +212,17 @@ static av_unused void pthread_cond_destroy(pthread_cond_t *cond)
pthread_mutex_destroy
(
&
win32_cond
->
mtx_broadcast
);
pthread_mutex_destroy
(
&
win32_cond
->
mtx_broadcast
);
av_freep
(
&
win32_cond
);
av_freep
(
&
win32_cond
);
cond
->
Ptr
=
NULL
;
cond
->
Ptr
=
NULL
;
return
0
;
}
}
static
av_unused
void
pthread_cond_broadcast
(
pthread_cond_t
*
cond
)
static
av_unused
int
pthread_cond_broadcast
(
pthread_cond_t
*
cond
)
{
{
win32_cond_t
*
win32_cond
=
cond
->
Ptr
;
win32_cond_t
*
win32_cond
=
cond
->
Ptr
;
int
have_waiter
;
int
have_waiter
;
if
(
cond_broadcast
)
{
if
(
cond_broadcast
)
{
cond_broadcast
(
cond
);
cond_broadcast
(
cond
);
return
;
return
0
;
}
}
/* non native condition variables */
/* non native condition variables */
...
@@ -236,6 +244,7 @@ static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
...
@@ -236,6 +244,7 @@ static av_unused void pthread_cond_broadcast(pthread_cond_t *cond)
}
else
}
else
pthread_mutex_unlock
(
&
win32_cond
->
mtx_waiter_count
);
pthread_mutex_unlock
(
&
win32_cond
->
mtx_waiter_count
);
pthread_mutex_unlock
(
&
win32_cond
->
mtx_broadcast
);
pthread_mutex_unlock
(
&
win32_cond
->
mtx_broadcast
);
return
0
;
}
}
static
av_unused
int
pthread_cond_wait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
)
static
av_unused
int
pthread_cond_wait
(
pthread_cond_t
*
cond
,
pthread_mutex_t
*
mutex
)
...
@@ -270,13 +279,13 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu
...
@@ -270,13 +279,13 @@ static av_unused int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu
return
pthread_mutex_lock
(
mutex
);
return
pthread_mutex_lock
(
mutex
);
}
}
static
av_unused
void
pthread_cond_signal
(
pthread_cond_t
*
cond
)
static
av_unused
int
pthread_cond_signal
(
pthread_cond_t
*
cond
)
{
{
win32_cond_t
*
win32_cond
=
cond
->
Ptr
;
win32_cond_t
*
win32_cond
=
cond
->
Ptr
;
int
have_waiter
;
int
have_waiter
;
if
(
cond_signal
)
{
if
(
cond_signal
)
{
cond_signal
(
cond
);
cond_signal
(
cond
);
return
;
return
0
;
}
}
pthread_mutex_lock
(
&
win32_cond
->
mtx_broadcast
);
pthread_mutex_lock
(
&
win32_cond
->
mtx_broadcast
);
...
@@ -293,6 +302,7 @@ static av_unused void pthread_cond_signal(pthread_cond_t *cond)
...
@@ -293,6 +302,7 @@ static av_unused void pthread_cond_signal(pthread_cond_t *cond)
}
}
pthread_mutex_unlock
(
&
win32_cond
->
mtx_broadcast
);
pthread_mutex_unlock
(
&
win32_cond
->
mtx_broadcast
);
return
0
;
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment