diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-31 18:46:23 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-31 18:46:23 +0200 |
commit | 80fabedc72b56664a4f6d77c253f9b3fe3939707 (patch) | |
tree | 35edd37dfb4bf34507826c78cf354bdc314d7fe2 /include | |
parent | d2b0696d8fa0ce47e0bc525581b6b9254637984b (diff) | |
download | wolfbones-80fabedc72b56664a4f6d77c253f9b3fe3939707.tar.gz wolfbones-80fabedc72b56664a4f6d77c253f9b3fe3939707.tar.bz2 |
started to add thread support (POSIX)
Diffstat (limited to 'include')
-rw-r--r-- | include/wolf/threads/threads.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/include/wolf/threads/threads.h b/include/wolf/threads/threads.h new file mode 100644 index 0000000..ff1e645 --- /dev/null +++ b/include/wolf/threads/threads.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef WOLF_THREADS_H +#define WOLF_THREADS_H + +/** + * @addtogroup wolf_threading Threading support + * @{ + */ + +/** + * @file mutex.h + * @brief Portable mutexes for thread synchronization + * @author Andreas Baumann <abaumann@yahoo.com> + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "port/sys.h" + +#include "errors.h" + +#ifdef HAVE_PTHREADS + +#include <pthread.h> /* for thread functions */ + +typedef pthread_t wolf_thread_t; + +typedef void *( *wolf_thread_func_t )( void * ); + +wolf_error_t wolf_thread_create( wolf_thread_t *thread, wolf_thread_func_t func ); +wolf_error_t wolf_thread_join( wolf_thread_t *thread ); + +#endif /* HAVE_PTHREADS */ + +#ifdef _WIN32 + +#include <windows.h> + +typedef HANDLE wolf_thread_t; + +typedef LPTHREAD_START_ROUTINE wolf_thread_func_t; + +wolf_error_t wolf_thread_create( wolf_thread_t *thread, wolf_thread_func_t func ); +wolf_error_t wolf_thread_join( wolf_thread_t *thread ); + +#endif /* _WIN32 */ + +#ifdef __cplusplus +} +#endif + +/** @} */ /* @addtogroup wolf_threading */ + +#endif /* ifndef WOLF_THREADS_H */ |