2014-11-23 21:25:05 +01:00
|
|
|
/*
|
2014-11-27 22:07:53 +01:00
|
|
|
* This file is part of FFmpeg.
|
2014-11-23 21:25:05 +01:00
|
|
|
*
|
2014-11-27 22:07:53 +01:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2014-11-23 21:25:05 +01:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2014-11-27 22:07:53 +01:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2014-11-23 21:25:05 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-11-27 22:07:53 +01:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2014-11-23 21:25:05 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This header should only be used to simplify code where
|
|
|
|
// threading is optional, not as a generic threading abstraction.
|
|
|
|
|
|
|
|
#ifndef AVUTIL_THREAD_H
|
|
|
|
#define AVUTIL_THREAD_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2014-11-29 08:34:20 +01:00
|
|
|
#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
|
2014-11-23 21:25:05 +01:00
|
|
|
|
2014-11-29 12:06:03 +01:00
|
|
|
#define USE_ATOMICS 0
|
|
|
|
|
2014-11-23 21:25:05 +01:00
|
|
|
#if HAVE_PTHREADS
|
|
|
|
#include <pthread.h>
|
2014-11-29 08:34:20 +01:00
|
|
|
#elif HAVE_OS2THREADS
|
|
|
|
#include "compat/os2threads.h"
|
2014-11-23 21:25:05 +01:00
|
|
|
#else
|
2014-11-29 08:36:06 +01:00
|
|
|
#include "compat/w32pthreads.h"
|
2014-11-23 21:25:05 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define AVMutex pthread_mutex_t
|
|
|
|
|
|
|
|
#define ff_mutex_init pthread_mutex_init
|
|
|
|
#define ff_mutex_lock pthread_mutex_lock
|
|
|
|
#define ff_mutex_unlock pthread_mutex_unlock
|
|
|
|
#define ff_mutex_destroy pthread_mutex_destroy
|
|
|
|
|
2015-10-07 22:43:38 +02:00
|
|
|
#define AVOnce pthread_once_t
|
|
|
|
#define AV_ONCE_INIT PTHREAD_ONCE_INIT
|
|
|
|
|
|
|
|
#define ff_thread_once(control, routine) pthread_once(control, routine)
|
|
|
|
|
2014-11-23 21:25:05 +01:00
|
|
|
#else
|
|
|
|
|
2014-11-29 12:06:03 +01:00
|
|
|
#define USE_ATOMICS 1
|
|
|
|
|
2014-11-23 21:25:05 +01:00
|
|
|
#define AVMutex char
|
|
|
|
|
|
|
|
#define ff_mutex_init(mutex, attr) (0)
|
|
|
|
#define ff_mutex_lock(mutex) (0)
|
|
|
|
#define ff_mutex_unlock(mutex) (0)
|
|
|
|
#define ff_mutex_destroy(mutex) (0)
|
|
|
|
|
2015-10-07 22:43:38 +02:00
|
|
|
#define AVOnce char
|
|
|
|
#define AV_ONCE_INIT 0
|
|
|
|
|
|
|
|
static inline int ff_thread_once(char *control, void (*routine)(void))
|
|
|
|
{
|
|
|
|
if (!*control) {
|
|
|
|
routine();
|
|
|
|
*control = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-23 21:25:05 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* AVUTIL_THREAD_H */
|