diff options
author | Johns <johns98@gmx.net> | 2014-06-25 15:17:00 +0200 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2014-06-25 15:17:00 +0200 |
commit | 37f409cb9aae06c99a6dff910b1b1d9278190ef1 (patch) | |
tree | b9cc5937e1ab239098e0cc9bc6f6f96f89565580 | |
parent | 5207af6b2da0df19a58db4932811d38526fde51b (diff) | |
download | vdr-plugin-softhddevice-37f409cb9aae06c99a6dff910b1b1d9278190ef1.tar.gz vdr-plugin-softhddevice-37f409cb9aae06c99a6dff910b1b1d9278190ef1.tar.bz2 |
Use GCC built-in functions for atomic operations.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | audio.c | 2 | ||||
-rw-r--r-- | codec.c | 2 | ||||
-rw-r--r-- | iatomic.h | 97 | ||||
-rw-r--r-- | ringbuffer.c | 5 | ||||
-rw-r--r-- | softhddev.c | 3 | ||||
-rw-r--r-- | video.c | 3 |
7 files changed, 104 insertions, 9 deletions
@@ -2,6 +2,7 @@ User johns Date: Config for automatic AES parameters. + Use GCC built-in functions for atomic operations. User master_red Date: Wed Jun 4 14:44:32 CEST 2014 @@ -88,7 +88,7 @@ #endif #endif -#include <alsa/iatomic.h> // portable atomic_t +#include "iatomic.h" // portable atomic_t #include "ringbuffer.h" #include "misc.h" @@ -58,7 +58,6 @@ #define _(str) gettext(str) ///< gettext shortcut #define _N(str) str ///< gettext_noop shortcut -#include <alsa/iatomic.h> #include <libavcodec/avcodec.h> #include <libavutil/mem.h> // support old ffmpeg versions <1.0 @@ -88,6 +87,7 @@ #ifdef MAIN_H #include MAIN_H #endif +#include "iatomic.h" #include "misc.h" #include "video.h" #include "audio.h" diff --git a/iatomic.h b/iatomic.h new file mode 100644 index 0000000..59e1684 --- /dev/null +++ b/iatomic.h @@ -0,0 +1,97 @@ +/// +/// @file iatomic.h @brief Misc function header file +/// +/// Copyright (c) 2014 by Johns. All Rights Reserved. +/// +/// Contributor(s): +/// +/// License: AGPLv3 +/// +/// This program is free software: you can redistribute it and/or modify +/// it under the terms of the GNU Affero General Public License as +/// published by the Free Software Foundation, either version 3 of the +/// License. +/// +/// 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 Affero General Public License for more details. +/// +/// $Id$ +////////////////////////////////////////////////////////////////////////////// + +/// @addtogroup iatomic +/// @{ + +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +// gcc before 4.7 didn't support atomic builtins, +// use alsa atomic functions. +#if GCC_VERSION < 40700 + +#include <alsa/iatomic.h> + +#else + +////////////////////////////////////////////////////////////////////////////// +// Defines +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// Declares +////////////////////////////////////////////////////////////////////////////// + +/// +/// atomic type, 24 bit useable, +/// +typedef volatile int atomic_t; + +////////////////////////////////////////////////////////////////////////////// +// Prototypes +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// Inlines +////////////////////////////////////////////////////////////////////////////// + +/// +/// Set atomic value. +/// +#define atomic_set(ptr, val) \ + __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST) + +/// +/// Read atomic value. +/// +#define atomic_read(ptr) \ + __atomic_load_n(ptr, __ATOMIC_SEQ_CST) + +/// +/// Increment atomic value. +/// +#define atomic_inc(ptr) \ + __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST) + +/// +/// Decrement atomic value. +/// +#define atomic_dec(ptr) \ + __atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST) + +/// +/// Add to atomic value. +/// +#define atomic_add(val, ptr) \ + __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST) + +/// +/// Subtract from atomic value. +/// +#define atomic_sub(val, ptr) \ + __atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST) + +#endif + +/// @} diff --git a/ringbuffer.c b/ringbuffer.c index 9466852..c9497b1 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -1,7 +1,7 @@ /// /// @file ringbuffer.c @brief Ringbuffer module /// -/// Copyright (c) 2009, 2011 by Johns. All Rights Reserved. +/// Copyright (c) 2009, 2011, 2014 by Johns. All Rights Reserved. /// /// Contributor(s): /// @@ -30,8 +30,7 @@ #include <stdlib.h> #include <string.h> -#include <alsa/iatomic.h> - +#include "iatomic.h" #include "ringbuffer.h" /// ring buffer structure diff --git a/softhddev.c b/softhddev.c index 2f873c0..1759109 100644 --- a/softhddev.c +++ b/softhddev.c @@ -63,6 +63,7 @@ #endif #include <pthread.h> +#include "iatomic.h" // portable atomic_t #include "misc.h" #include "softhddev.h" @@ -1307,8 +1308,6 @@ void SetVolumeDevice(int volume) // Video ////////////////////////////////////////////////////////////////////////////// -#include <alsa/iatomic.h> // portable atomic_t - #define VIDEO_BUFFER_SIZE (512 * 1024) ///< video PES buffer default size #define VIDEO_PACKET_MAX 192 ///< max number of video packets @@ -70,8 +70,6 @@ #define _(str) gettext(str) ///< gettext shortcut #define _N(str) str ///< gettext_noop shortcut -#include <alsa/iatomic.h> // portable atomic_t - #ifdef USE_VIDEO_THREAD #ifndef __USE_GNU #define __USE_GNU @@ -179,6 +177,7 @@ typedef enum #define FFMPEG_BUG1_WORKAROUND ///< get_format bug workaround #endif +#include "iatomic.h" // portable atomic_t #include "misc.h" #include "video.h" #include "audio.h" |