Added camutex no operation file.
authorvimala.v <vimala.v@samsung.com>
Tue, 30 Jun 2015 04:52:23 +0000 (10:22 +0530)
committerErich Keane <erich.keane@intel.com>
Thu, 2 Jul 2015 16:21:32 +0000 (16:21 +0000)
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 <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1455
Reviewed-by: Abhishek Sharma <ce.abhishek@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/common/SConscript
resource/csdk/connectivity/common/src/camutex_noop.c [new file with mode: 0644]

index 6810416..2336f2e 100644 (file)
@@ -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 (file)
index 0000000..2250cb3
--- /dev/null
@@ -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;
+}
+