From 6cd3b68991cc23e1a5b4e0e68037059b79be48f0 Mon Sep 17 00:00:00 2001 From: "vimala.v" Date: Tue, 30 Jun 2015 10:22:23 +0530 Subject: [PATCH] Added camutex no operation file. This change will be used for singlethread and multithread integration to avoid the usage of #ifdef around camutex api's. Change-Id: Ie483c16cd0ac1d194a77fd94a8b9dd459e75509a Signed-off-by: vimala.v Reviewed-on: https://gerrit.iotivity.org/gerrit/1455 Reviewed-by: Abhishek Sharma Tested-by: jenkins-iotivity Reviewed-by: Erich Keane --- resource/csdk/connectivity/common/SConscript | 22 ++-- .../csdk/connectivity/common/src/camutex_noop.c | 112 +++++++++++++++++++++ 2 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 resource/csdk/connectivity/common/src/camutex_noop.c diff --git a/resource/csdk/connectivity/common/SConscript b/resource/csdk/connectivity/common/SConscript index 6810416..2336f2e 100644 --- a/resource/csdk/connectivity/common/SConscript +++ b/resource/csdk/connectivity/common/SConscript @@ -34,25 +34,27 @@ ca_common_src = [ if ca_os == 'arduino': env.Command(env.get('BUILD_DIR') + 'logger.c.o', None, '$CXX -o ' + env.get('BUILD_DIR') + 'logger.c.o' + ' $LINKFLAGS $CCFLAGS $CXXFLAGS ' + '-I' + Dir('.').srcnode().path + '/inc' + header + ' ' + Dir('.').srcnode().path + '/src/logger.c') - platform_src = [ + logger_src = [ env.get('BUILD_DIR') + 'logger.c.o', ] -elif env['POSIX_SUPPORTED']: - platform_src = [ - ca_common_src_path + 'logger.c', - ca_common_src_path + 'oic_logger.c', - ca_common_src_path + 'oic_console_logger.c', - ca_common_src_path + 'cathreadpool_pthreads.c', - ca_common_src_path + 'camutex_pthreads.c' - ] else: - platform_src = [ + logger_src = [ ca_common_src_path + 'logger.c', ca_common_src_path + 'oic_logger.c', ca_common_src_path + 'oic_console_logger.c' ] +if env['POSIX_SUPPORTED']: + platform_src = [ + ca_common_src_path + 'cathreadpool_pthreads.c', + ca_common_src_path + 'camutex_pthreads.c' + ] +else: + platform_src = [ + ca_common_src_path + 'camutex_noop.c' + ] env.AppendUnique(CA_SRC = ca_common_src) +env.AppendUnique(CA_SRC = logger_src) env.AppendUnique(CA_SRC = platform_src) diff --git a/resource/csdk/connectivity/common/src/camutex_noop.c b/resource/csdk/connectivity/common/src/camutex_noop.c new file mode 100644 index 0000000..2250cb3 --- /dev/null +++ b/resource/csdk/connectivity/common/src/camutex_noop.c @@ -0,0 +1,112 @@ +//****************************************************************** +// +// Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +// +// +//********************************************************************* + +/** + * @file + * This file provides APIs related to mutex with no operation + * for Singlethread implementation. + */ + +#include "camutex.h" + +/** + * TAG + * Logging tag for module name + */ +#define TAG "UMUTEX" + +typedef struct _tagMutexInfo_t +{ +} ca_mutex_internal; + +typedef struct _tagEventInfo_t +{ +} ca_cond_internal; + +/** + * @var g_mutexInfo + * @brief This is used to return a non NULL value for ca_mutex_new(). + */ +static ca_mutex_internal g_mutexInfo = { 0 }; + +/** + * @var g_condInfo + * @brief This is used to return a non NULL value for ca_cond_new(). + */ +static ca_cond_internal g_condInfo = { 0 }; + +ca_mutex ca_mutex_new(void) +{ + return &g_mutexInfo; +} + +bool ca_mutex_free(ca_mutex mutex) +{ + return true; +} + +void ca_mutex_lock(ca_mutex mutex) +{ + return; +} + +bool ca_mutex_trylock(ca_mutex mutex) +{ + return true; +} + +void ca_mutex_unlock(ca_mutex mutex) +{ + return; +} + +ca_cond ca_cond_new(void) +{ + return &g_condInfo; +} + +void ca_cond_free(ca_cond cond) +{ + return; +} + +void ca_cond_signal(ca_cond cond) +{ + return; +} + +void ca_cond_broadcast(ca_cond cond) +{ + return; +} + +void ca_cond_wait(ca_cond cond, ca_mutex mutex) +{ + return; +} + +CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds) +{ + return CA_WAIT_SUCCESS; +} + -- 2.7.4