1 /* IOInternal.h - IOMultiplexer v2
2 * Copyright (C) 2014 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _IOHandler_internals
20 #include "IOHandler.h"
26 #ifdef PTHREAD_MUTEX_RECURSIVE_NP
27 #define PTHREAD_MUTEX_RECURSIVE_VAL PTHREAD_MUTEX_RECURSIVE_NP
29 #define PTHREAD_MUTEX_RECURSIVE_VAL PTHREAD_MUTEX_RECURSIVE
31 #define IOTHREAD_MUTEX_INIT(var) { \
32 pthread_mutexattr_t mutex_attr; \
33 pthread_mutexattr_init(&mutex_attr);\
34 pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_VAL);\
35 pthread_mutex_init(&var, &mutex_attr); \
37 #define IOSYNCHRONIZE(var) pthread_mutex_lock(&var)
38 #define IODESYNCHRONIZE(var) pthread_mutex_unlock(&var)
40 #define IOTHREAD_MUTEX_INIT(var)
41 #define IOSYNCHRONIZE(var)
42 #define IODESYNCHRONIZE(var)
46 #define IOGC_FREE(NAME) void NAME(void *object)
47 typedef IOGC_FREE(iogc_free);
48 void iogc_add(void *object);
49 void iogc_add_callback(void *object, iogc_free *free_callback);