Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
651078ec
Commit
651078ec
authored
Dec 18, 2006
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added initial support for TLS (Thread Local Storage) variables
parent
965e95ec
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
1 deletion
+148
-1
include/vlc_threads.h
include/vlc_threads.h
+26
-0
include/vlc_threads_funcs.h
include/vlc_threads_funcs.h
+66
-0
src/misc/threads.c
src/misc/threads.c
+30
-0
test/NativeLibvlcTest.py
test/NativeLibvlcTest.py
+3
-0
test/native/init.c
test/native/init.c
+1
-0
test/native/tests.h
test/native/tests.h
+2
-0
test/native/threads.c
test/native/threads.c
+19
-0
test/setup.py
test/setup.py
+1
-1
No files found.
include/vlc_threads.h
View file @
651078ec
...
...
@@ -139,6 +139,9 @@ typedef struct
pth_cond_t
cond
;
vlc_object_t
*
p_this
;
}
vlc_cond_t
;
typedef
struct
{
}
vlc_threadvar_t
;
#elif defined( ST_INIT_IN_ST_H )
typedef
st_thread_t
vlc_thread_t
;
...
...
@@ -152,6 +155,9 @@ typedef struct
st_cond_t
cond
;
vlc_object_t
*
p_this
;
}
vlc_cond_t
;
typedef
struct
{
}
vlc_threadvar_t
;
#elif defined( WIN32 ) || defined( UNDER_CE )
typedef
HANDLE
vlc_thread_t
;
...
...
@@ -182,6 +188,11 @@ typedef struct
vlc_object_t
*
p_this
;
}
vlc_cond_t
;
typedef
struct
{
DWORD
handle
;
}
vlc_threadvar_t
;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
/* This is the BeOS implementation of the vlc threads, note that the mutex is
* not a real mutex and the cond_var is not like a pthread cond_var but it is
...
...
@@ -205,6 +216,11 @@ typedef struct
vlc_object_t
*
p_this
;
}
vlc_cond_t
;
typedef
struct
{
}
vlc_threadvar_t
;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
typedef
pthread_t
vlc_thread_t
;
typedef
struct
...
...
@@ -218,6 +234,11 @@ typedef struct
vlc_object_t
*
p_this
;
}
vlc_cond_t
;
typedef
struct
{
pthread_key_t
handle
;
}
vlc_threadvar_t
;
#elif defined( HAVE_CTHREADS_H )
typedef
cthread_t
vlc_thread_t
;
...
...
@@ -244,5 +265,10 @@ typedef struct
vlc_object_t
*
p_this
;
}
vlc_cond_t
;
typedef
struct
{
cthread_key_t
handle
;
}
vlc_threadvar_t
;
#endif
include/vlc_threads_funcs.h
View file @
651078ec
...
...
@@ -38,6 +38,7 @@ VLC_EXPORT( int, __vlc_mutex_init, ( vlc_object_t *, vlc_mutex_t * ) );
VLC_EXPORT
(
int
,
__vlc_mutex_destroy
,
(
const
char
*
,
int
,
vlc_mutex_t
*
)
);
VLC_EXPORT
(
int
,
__vlc_cond_init
,
(
vlc_object_t
*
,
vlc_cond_t
*
)
);
VLC_EXPORT
(
int
,
__vlc_cond_destroy
,
(
const
char
*
,
int
,
vlc_cond_t
*
)
);
VLC_EXPORT
(
int
,
__vlc_threadvar_create
,
(
vlc_object_t
*
,
vlc_threadvar_t
*
)
);
VLC_EXPORT
(
int
,
__vlc_thread_create
,
(
vlc_object_t
*
,
const
char
*
,
int
,
const
char
*
,
void
*
(
*
)
(
void
*
),
int
,
vlc_bool_t
)
);
VLC_EXPORT
(
int
,
__vlc_thread_set_priority
,
(
vlc_object_t
*
,
const
char
*
,
int
,
int
)
);
VLC_EXPORT
(
void
,
__vlc_thread_ready
,
(
vlc_object_t
*
)
);
...
...
@@ -547,6 +548,71 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
#define vlc_cond_destroy( P_COND ) \
__vlc_cond_destroy( __FILE__, __LINE__, P_COND )
/*****************************************************************************
* vlc_threadvar_create: create a thread-local variable
*****************************************************************************/
#define vlc_threadvar_create( PTHIS, P_TLS ) \
__vlc_threadvar_create( PTHIS, P_TLS )
/*****************************************************************************
* vlc_threadvar_set: create: set the value of a thread-local variable
*****************************************************************************/
#define vlc_threadvar_set( P_TLS , P_VAL ) \
__vlc_threadvar_set( __FILE__, __LINE__, P_TLS, P_VAL )
static
inline
int
__vlc_threadvar_set
(
char
*
psz_file
,
int
line
,
vlc_threadvar_t
*
p_tls
,
void
*
p_value
)
{
int
i_ret
;
#if defined( PTH_INIT_IN_PTH_H ) || \
defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H )
return
-
1
;
#elif defined( UNDER_CE ) || defined( WIN32 )
i_ret
=
(
TlsSetValue
(
&
p_tls
->
handle
,
p_value
)
!=
0
);
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_ret
=
pthread_setspecific
(
p_tls
->
handle
,
p_value
);
#elif defined( HAVE_CTHREADS_H )
i_ret
=
cthread_setspecific
(
p_tls
->
handle
,
p_value
);
#endif
return
i_ret
;
}
/*****************************************************************************
* vlc_threadvar_get: create: get the value of a thread-local variable
*****************************************************************************/
#define vlc_threadvar_get( P_TLS ) \
__vlc_threadvar_get( __FILE__, __LINE__, P_TLS )
static
inline
void
*
__vlc_threadvar_get
(
char
*
psz_file
,
int
line
,
vlc_threadvar_t
*
p_tls
)
{
void
*
p_ret
;
#if defined( PTH_INIT_IN_PTH_H ) || \
defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H )
return
NULL
;
#elif defined( UNDER_CE ) || defined( WIN32 )
p_ret
=
TlsGetValue
(
&
p_tls
->
handle
);
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
p_ret
=
pthread_getspecific
(
p_tls
->
handle
);
#elif defined( HAVE_CTHREADS_H )
if
(
!
cthread_getspecific
(
p_tls
->
handle
,
&
p_ret
)
)
{
p_ret
=
NULL
;
}
#endif
return
p_ret
;
}
/*****************************************************************************
* vlc_thread_create: create a thread
*****************************************************************************/
...
...
src/misc/threads.c
View file @
651078ec
...
...
@@ -500,6 +500,36 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar
return
i_result
;
}
/*****************************************************************************
* vlc_tls_create: create a thread-local variable
*****************************************************************************/
int
__vlc_threadvar_create
(
vlc_object_t
*
p_this
,
vlc_threadvar_t
*
p_tls
)
{
#if defined( PTH_INIT_IN_PTH_H )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( ST_INIT_IN_ST_H )
msg_Err
(
p_this
,
"TLS not implemented"
);
return
VLC_EGENERIC
;
#elif defined( UNDER_CE ) || defined( WIN32 )
#elif defined( WIN32 )
p_tls
->
handle
=
TlsAlloc
();
if
(
p_tls
->
handle
==
0xFFFFFFFF
)
{
return
VLC_EGENERIC
;
}
msg_Err
(
p_this
,
"TLS not implemented"
);
return
VLC_EGENERIC
;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
return
pthread_key_create
(
&
p_tls
->
handle
,
NULL
);
#elif defined( HAVE_CTHREADS_H )
return
cthread_keycreate
(
&
p_tls
-
handle
);
#endif
}
/*****************************************************************************
* vlc_thread_create: create a thread, inner version
*****************************************************************************
...
...
test/NativeLibvlcTest.py
View file @
651078ec
...
...
@@ -3,6 +3,9 @@ import unittest
import
native_libvlc_test
class
NativeLibvlcTestCase
(
unittest
.
TestCase
):
def
testTls
(
self
):
"""[Thread] Set TLS"""
native_libvlc_test
.
threadvar_test
()
def
test1Exception
(
self
):
"""[LibVLC] Checks libvlc_exception"""
# native_libvlc_test.exception_test()
...
...
test/native/init.c
View file @
651078ec
...
...
@@ -24,6 +24,7 @@ static PyMethodDef native_libvlc_test_methods[] = {
DEF_METHOD
(
bsearch_direct_test
,
"Test Bsearch without structure"
)
DEF_METHOD
(
bsearch_member_test
,
"Test Bsearch with structure"
)
DEF_METHOD
(
dict_test
,
"Test dictionnaries"
)
DEF_METHOD
(
threadvar_test
,
"Test TLS"
)
{
NULL
,
NULL
,
0
,
NULL
}
};
...
...
test/native/tests.h
View file @
651078ec
...
...
@@ -6,6 +6,8 @@ PyObject *create_destroy( PyObject *self, PyObject *args );
PyObject
*
playlist_test
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
vlm_test
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
threadvar_test
(
PyObject
*
self
,
PyObject
*
args
);
/* Stats */
PyObject
*
timers_test
(
PyObject
*
self
,
PyObject
*
args
);
...
...
test/native/threads.c
0 → 100644
View file @
651078ec
#include "../pyunit.h"
#include <vlc/vlc.h>
PyObject
*
threadvar_test
(
PyObject
*
self
,
PyObject
*
args
)
{
void
*
p_foo
=
malloc
(
1
);
vlc_threadvar_t
key
,
key2
;
vlc_threadvar_create
(
NULL
,
&
key
);
vlc_threadvar_set
(
&
key
,
p_foo
);
ASSERT
(
vlc_threadvar_get
(
&
key
)
==
p_foo
,
"key does not match"
);
vlc_threadvar_create
(
NULL
,
&
key2
);
vlc_threadvar_set
(
&
key2
,
NULL
);
ASSERT
(
vlc_threadvar_get
(
&
key2
)
==
NULL
,
"key2 does not match"
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
test/setup.py
View file @
651078ec
...
...
@@ -42,7 +42,7 @@ def get_ldflags():
native_libvlc_test
=
Extension
(
'native_libvlc_test'
,
sources
=
[
'native/init.c'
,
'native/url.c'
,
'native/i18n.c'
,
'native/stats.c'
,
'native/libvlc.c'
,
'native/profiles.c'
,
'native/algo.c'
],
'native/algo.c'
,
'native/threads.c'
],
include_dirs
=
[
'../include'
,
'../'
,
'/usr/win32/include'
],
extra_objects
=
[
'../src/.libs/libvlc.so'
,
'../src/.libs/libvlc-control.so'
],
extra_compile_args
=
get_cflags
(),
...
...
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