From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/lib/util/abstract/abs_thread.h | 123 +++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 mpeglib/lib/util/abstract/abs_thread.h (limited to 'mpeglib/lib/util/abstract/abs_thread.h') diff --git a/mpeglib/lib/util/abstract/abs_thread.h b/mpeglib/lib/util/abstract/abs_thread.h new file mode 100644 index 00000000..f65445d8 --- /dev/null +++ b/mpeglib/lib/util/abstract/abs_thread.h @@ -0,0 +1,123 @@ +/* + abstraction for threads + Copyright (C) 2000 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#ifndef __ABS_THREAD_H +#define __ABS_THREAD_H + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/** + This passed alle pthread_xxx calls to this interface, thus + it can be easier replaced with other thread "layers" + + All posix pthread calls are conveterd to abs_thread. +*/ + +extern "C" { +#include +#include +#include +#include +} + +#define _ABS_BUSY EBUSY + +#ifndef SDL_WRAPPER +// definitions for direct pthread support +#include + +typedef pthread_mutex_t abs_thread_mutex_t; +typedef pthread_cond_t abs_thread_cond_t; +typedef pthread_t abs_thread_t; + + + +#define abs_thread_cond_init(cond) pthread_cond_init(cond,NULL) +#define abs_thread_cond_destroy(cond) pthread_cond_destroy(cond) +#define abs_thread_cond_signal(cond) pthread_cond_signal(cond) +#define abs_thread_cond_wait(cond,mutex) pthread_cond_wait(cond,mutex) + +// CREATE / JOIN THREAD + +#define abs_thread_create(thread,func,arg) pthread_create(thread,NULL,func,arg) +#define abs_thread_join(th,thread_return) pthread_join(th,thread_return) + +// MUTEX FUNCTIONS + +#define abs_thread_mutex_lock(mutex) pthread_mutex_lock(mutex) +#define abs_thread_mutex_unlock(mutex) pthread_mutex_unlock(mutex) +#define abs_thread_mutex_init(mutex) pthread_mutex_init(mutex,NULL) +#define abs_thread_mutex_destroy(mutex) pthread_mutex_destroy(mutex) + +#endif +// not SDL_WRAPPER + +#ifdef SDL_WRAPPER + + +// SDL SUPPORT DISABLED + +#if defined WIN32 + #include + #include +#else + #include + #include +#endif + + +typedef SDL_mutex* abs_thread_mutex_t; +typedef SDL_cond* abs_thread_cond_t; +typedef SDL_Thread* abs_thread_t; + +// SIGNAL FUNCTIONS +// note we have _no_ cond attribut (not needed) +int abs_thread_cond_init(abs_thread_cond_t* cond); +int abs_thread_cond_destroy(abs_thread_cond_t *cond); + +int abs_thread_cond_signal(abs_thread_cond_t* cond); + +int abs_thread_cond_wait(abs_thread_cond_t* cond, + abs_thread_mutex_t *mutex); +// CREATE / JOIN THREAD +// Note: we have thread attribute +int abs_thread_create(abs_thread_t* thread, + void * (*start_routine)(void *), void * arg); + +int abs_thread_join(abs_thread_t th, + void **thread_return); + + +// MUTEX FUNCTIONS + +int abs_thread_mutex_lock(abs_thread_mutex_t *mutex); +int abs_thread_mutex_trylock(abs_thread_mutex_t *mutex); +int abs_thread_mutex_unlock(abs_thread_mutex_t *mutex); +// not attribute! +int abs_thread_mutex_init(abs_thread_mutex_t *mutex); + +int abs_thread_mutex_destroy(abs_thread_mutex_t *mutex); + + + +#endif +//SDL_WRAPPER + + + +#endif + + -- cgit v1.2.1