From 67d28bec545857b329f76ffe3cc9b98dbac7ce69 Mon Sep 17 00:00:00 2001 From: Martin Troxler Date: Thu, 6 Jan 2011 13:11:21 +0100 Subject: [PATCH] always use rt_mutex instead of semaphore for mutual exclusion on kernels >= 2.6.24 (removed --enable-mutex build option) --- configure.ac | 24 ------------------------ master/globals.h | 11 ++++++----- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index cd85a55a..387f4db0 100644 --- a/configure.ac +++ b/configure.ac @@ -536,30 +536,6 @@ if test "x${regalias}" = "x1"; then AC_DEFINE([EC_REGALIAS], [1], [Read alias adresses from register]) fi -#------------------------------------------------------------------------------ -# use mutexes instead of semaphores -#------------------------------------------------------------------------------ - -AC_ARG_ENABLE([mutex], - AS_HELP_STRING([--enable-mutex], - [Use mutex instead of semaphores for mutual exclusion (default: no)]), - [ - case "${enableval}" in - yes) mutex=1 - ;; - no) mutex=0 - ;; - *) AC_MSG_ERROR([Invalid value for --enable-mutex]) - ;; - esac - ], - [mutex=0] -) - -if test "x${mutex}" = "x1"; then - AC_DEFINE([EC_USE_MUTEX], [1], [Use mutex for mutual exclusion]) -fi - #------------------------------------------------------------------------------ # Command-line tool diff --git a/master/globals.h b/master/globals.h index 859eee94..d2c135df 100644 --- a/master/globals.h +++ b/master/globals.h @@ -40,9 +40,10 @@ #include "../include/ecrt.h" #ifdef __KERNEL__ -#ifdef EC_USE_MUTEX +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) #include -#endif // EC_USE_MUTEX +#endif // KERNEL_VERSION(2,6,24) #endif // __KERNEL__ /****************************************************************************** @@ -318,7 +319,7 @@ typedef struct ec_slave ec_slave_t; /**< \see ec_slave. */ /** Mutual exclusion helpers. * */ -#ifdef EC_USE_MUTEX +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) #define ec_mutex_t rt_mutex static inline void ec_mutex_init(struct ec_mutex_t *mutex) { @@ -340,7 +341,7 @@ static inline void ec_mutex_unlock(struct ec_mutex_t *mutex) { rt_mutex_unlock(mutex); } -#else // EC_USE_MUTEX +#else // < KERNEL_VERSION(2,6,24) #define ec_mutex_t semaphore static inline void ec_mutex_init(struct ec_mutex_t *sem) { @@ -364,7 +365,7 @@ static inline void ec_mutex_unlock(struct ec_mutex_t *sem) up(sem); } -#endif // EC_USE_MUTEX +#endif // KERNEL_VERSION(2,6,24) #endif // __KERNEL__ #endif