# True if binary needs to be installed on board. (Might need root permissions)
# set to 'no', 'false' or 0 for only compilation
-require_upload = ARGUMENTS.get('UPLOAD', False)
+require_upload = ARGUMENTS.get('UPLOAD', False)
if ARGUMENTS.get('TEST'):
logging_default = False
######################################################################
if target_os == "yocto":
'''
- This code injects Yocto cross-compilation tools+flags into scons'
- build environment in order to invoke the relevant tools while
+ This code injects Yocto cross-compilation tools+flags into scons'
+ build environment in order to invoke the relevant tools while
performing a build.
'''
import os.path
env['TARGET_OS'] = 'linux'
'''
We want to preserve debug symbols to allow BitBake to generate both DEBUG and
- RELEASE packages for OIC.
+ RELEASE packages for OIC.
'''
env['CCFLAGS'].append('-g')
Export('env')
else:
env.SConscript(target_os + '/SConscript')
-env.SConscript('external_libs.scons')
-
# Delete the temp files of configuration
if env.GetOption('clean'):
dir = env.get('SRC_DIR')
if os.path.exists(dir + '/config.log'):
Execute(Delete(dir + '/config.log'))
+ if os.path.exists(dir + '/.sconsign.dblite'):
Execute(Delete(dir + '/.sconsign.dblite'))
+ if os.path.exists(dir + '/.sconf_temp'):
Execute(Delete(dir + '/.sconf_temp'))
+######################################################################
+# Check for PThreads support
+######################################################################
+import iotivityconfig
+from iotivityconfig import *
+
+conf = Configure(env,
+ custom_tests =
+ {
+ 'CheckPThreadsSupport' : iotivityconfig.check_pthreads
+ } )
+
+# Identify whether we have pthreads support, which is necessary for
+# threading and mutexes. This will set the environment variable
+# POSIX_SUPPORTED, 1 if it is supported, 0 otherwise
+conf.CheckPThreadsSupport()
+
+env = conf.Finish()
+######################################################################
+
+env.SConscript('external_libs.scons')
Return('env')
'''
Exit(1)
-# check 'glib' library
-src_dir = env.get('SRC_DIR')
-if not os.path.exists(src_dir + '/extlibs/glib/glib-2.40.2'):
- print '''
-*********************************** Error: **************************************
-* Android glib library does not exist. please download gnome glib to *
-* extlibs/glib directory *
-* To build Android glib libraries please follow the instructions as below : *
-* Download Gnome Glib from http://ftp.gnome.org/pub/GNOME/sources/glib/2.40/ *
-* Please go through build instructions at : *
-* resource/csdk/connectivity/lib/android/glibpatch_Readme.txt *
-*********************************************************************************
- '''
- Exit(1)
# Overwrite suffixes and prefixes
if env['HOST_OS'] == 'win32':
env['OBJSUFFIX'] = '.o'
env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
env.AppendUnique(LIBPATH = [src_dir + '/resource/csdk/connectivity/lib/android'])
-env.AppendUnique(LIBS = ['log', 'glib-2.40.2', 'gthread-2.40.2', 'coap'])
+env.AppendUnique(LIBS = ['log', 'coap'])
if env.get('SECURED') == '1':
env.AppendUnique(LIBS = ['tinydtls'])
-
+
# From android-5 (API > 20), all application must be built with flags '-fPIE' '-pie'.
# Due to the limitation of Scons, it's required to added it into the command line
# directly (otherwise, it will also be added when build share library)
env.AppendUnique(CCFLAGS = ['-g'])
env.AppendUnique(LINKFLAGS = ['-g'])
-env.ParseConfig("pkg-config glib-2.0 gthread-2.0 --cflags --libs")
-
if target_os == 'darwin':
sys_root = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
else:
if target_os == 'darwin':
flag = '-mmacosx-version-min=' + sys_version
env.AppendUnique(CCFLAGS = [flag])
- env.AppendUnique(LINKFLAGS = [flag])
\ No newline at end of file
+ env.AppendUnique(LINKFLAGS = [flag])
_inform_user_of_broken_gcc_headers(context, ret)
return ret
+
+def check_pthreads(context):
+ """
+ Check if pthreads are supported for this platform.
+
+ Sets POSIX_SUPPORTED based on the result.
+ """
+ context.Message('Checking for POSIX Thread Support...')
+ config = factory.make_c_compiler_config(context)
+
+ ret = config.has_pthreads_support()
+ context.env['POSIX_SUPPORTED'] = ret
+ context.Result(ret)
+ return ret
'.cpp',
'CXXFLAGS')
+ def has_pthreads_support(self):
+ """
+ Check if PThreads are supported by this system
+
+ Returns 1 if this system DOES support pthreads, 0
+ otherwise
+ """
+
+ return self._context.TryCompile(self._pthreads_test_program(), '.c')
+
# --------------------------------------------------------------
# Check if flag is required to build the given test program.
#
# --------------------------------------------------------------
def _cxx11_flags(self):
raise NotImplementedError('unimplemented method')
+
+ # --------------------------------------------------------------
+ # Return a test program to be used when checking for PThreads
+ # support
+ #
+ # --------------------------------------------------------------
+ def _pthreads_test_program(self):
+ return """
+#include <unistd.h>
+#include <pthread.h>
+int main()
+{
+ #ifndef _POSIX_THREADS
+ # error POSIX Threads support not available
+ #endif
+ return 0;
+}
+"""
env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
-env.ParseConfig("pkg-config glib-2.0 gthread-2.0 --cflags --libs")
-
if env.get('TARGET_OS') == 'tizen':
env.AppendUnique(CCFLAGS = ['-D__TIZEN__', '-DSLP_SDK_LOG', '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE'])
+ env.ParseConfig("pkg-config glib-2.0 gthread-2.0 --cflags --libs")
env.ParseConfig("pkg-config dlog --cflags --libs")
# Set arch flags
examples_env.AppendUnique(LIBS = ['-lpthread'])
examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
+examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction',
+ 'coap', 'rt'])
if env.get('SECURED') == '1':
examples_env.AppendUnique(LIBS = ['tinydtls'])
-examples_env.ParseConfig('pkg-config --libs glib-2.0');
-
if target_os == 'android':
examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
examples_env.AppendUnique(LIBS = ['gnustl_static'])
target_os = env.get('TARGET_OS')
src_dir = env.get('SRC_DIR')
+if target_os not in ['arduino', 'darwin', 'ios']:
+ env.AppendUnique(LIBS=['rt'])
+
# Build libcoap
SConscript('csdk/connectivity/lib/libcoap-4.1.1/SConscript')
===================================
•Preconditons :
Please download the following
- 1) glib directory and keep at $(CA_HOME)/lib/android/glib-2.40.2
- 2) tinydlts library and keep at $(CA_HOME)/lib/tinydtls
+ 1) tinydlts library and keep at $(CA_HOME)/lib/tinydtls
•Supported version : 5.0 ( Lollipop )
•Required NDK version : android-ndk-r10d ( https://developer.android.com/tools/sdk/ndk/index.html )
• Modify Makefile ( connectivity/build/android/Makefile )
'''
Exit(1)
-# check 'glib' library
-src_dir = env.get('SRC_DIR')
-if not os.path.exists(src_dir + '/../../../../extlibs/glib/glib-2.40.2'):
- print '''
-*********************************** Error: **************************************
-* Android glib library does not exist. please download gnome glib to *
-* extlibs/glib directory *
-* To build Android glib libraries please follow the instructions as below : *
-* Download Gnome Glib from http://ftp.gnome.org/pub/GNOME/sources/glib/2.40/ *
-* Please go through build instructions at : *
-* lib/android/glibpatch_Readme.txt *
-*********************************************************************************
- '''
# Overwrite suffixes and prefixes
if env['HOST_OS'] == 'win32':
env['OBJSUFFIX'] = '.o'
env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
env.AppendUnique(LIBPATH = [src_dir + '/lib/android'])
-env.AppendUnique(LIBS = ['log', 'glib-2.40.2', 'gthread-2.40.2', 'coap'])
+env.AppendUnique(LIBS = ['log', 'coap'])
if env.get('SECURED') == '1':
env.AppendUnique(LIBS = ['tinydtls'])
##
## file declaration
##
-COMPONENT_SRCS := logger.c oic_logger.c oic_console_logger.c oic_malloc.c oic_string.c uqueue.c uarraylist.c umutex.c uthreadpool.c
+COMPONENT_SRCS := logger.c oic_logger.c oic_console_logger.c oic_malloc.c oic_string.c uqueue.c uarraylist.c umutex.c cathreadpool_pthreads.c
COMPONENT_SRCS += caretransmission.c
COMPONENT_SRCS += caconnectivitymanager.c caremotehandler.c cainterfacecontroller.c camessagehandler.c caqueueingthread.c canetworkconfigurator.c caprotocolmessage.c
COMPONENT_SRCS += caadapterutils.c
env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
-env.ParseConfig("pkg-config --cflags --libs glib-2.0 gthread-2.0")
-
# Set arch flags
target_arch = env.get('TARGET_ARCH')
if target_arch in ['x86']:
cp -f %{ROOTDIR}/con/lib/libcoap-4.1.1/libcoap.a %{buildroot}/%{_libdir}
cp -rf %{ROOTDIR}/con/api/cacommon.h* %{DEST_INC_DIR}/
cp -rf %{ROOTDIR}/con/inc/caadapterinterface.h* %{DEST_INC_DIR}/
-cp -rf %{ROOTDIR}/con/common/inc/uthreadpool.h* %{DEST_INC_DIR}/
+cp -rf %{ROOTDIR}/con/common/inc/cathreadpool.h* %{DEST_INC_DIR}/
cp -rf %{ROOTDIR}/con/inc/cawifiadapter.h* %{DEST_INC_DIR}/
cp -rf %{ROOTDIR}/con/inc/caethernetadapter.h* %{DEST_INC_DIR}/
cp -rf %{ROOTDIR}/con/inc/caedradapter.h* %{DEST_INC_DIR}/
ca_common_path = root_dir + 'common/'
ca_common_src_path = ca_common_path + 'src/'
-no_glib = 'darwin,ios'
env.AppendUnique(CPPPATH = [
'common/inc/',
])
-
-if ca_os == 'android':
- main_dir = Dir('.').srcnode().abspath
- glib_dir = main_dir + '/../../../../extlibs/glib/glib-2.40.2/'
- env.AppendUnique(CPPPATH = [
- glib_dir,
- glib_dir + 'glib',
- glib_dir + 'gthread'])
temp = env['CPPPATH']
header = ' '
platform_src = [
env.get('BUILD_DIR') + 'logger.c.o',
]
-else:
- if ca_os in no_glib:
- 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 + 'uthreadpool.c',
- ca_common_src_path + 'camutex_pthread.c'
- ]
- else:
- platform_src = [
+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 + 'uthreadpool.c',
- ca_common_src_path + 'camutex_glib.c'
+ ca_common_src_path + 'cathreadpool_pthreads.c',
+ ca_common_src_path + 'camutex_pthreads.c'
+ ]
+else:
+ platform_src = [
+ ca_common_src_path + 'logger.c',
+ ca_common_src_path + 'oic_logger.c',
+ ca_common_src_path + 'oic_console_logger.c'
]
+
env.AppendUnique(CA_SRC = ca_common_src)
env.AppendUnique(CA_SRC = platform_src)
typedef struct ca_cond_internal *ca_cond;
/**
- * Enums for ca_cond_wait_until return values
+ * Enums for ca_cond_wait_for return values
*/
typedef enum
{
/**
* Waits until this thread woken up on @cond,
- * but not longer than until the time specified by microseconds.
+ * but not longer than the interval specified by microseconds.
* The mutex is unlocked before falling asleep and locked again before resuming.
- * If microseconds is 0 or under, ca_cond_wait_until() acts like ca_cond_wait().
+ * If microseconds is 0, ca_cond_wait_for() acts like ca_cond_wait().
*
* @param cond The condtion to be wait for to signal
* @param mutex The mutex which is currently locked from calling thread
- * @param microseconds absolute time for waiting, microseconds
+ * @param microseconds relative time for waiting, microseconds
*
* @return CA_WAIT_SUCCESS if the condition was signaled.
* CA_WAIT_TIMEDDOUT if wait period exceeded
* CA_WAIT_INVAL for invalid parameters
*
*/
-CAWaitResult_t ca_cond_wait_until(ca_cond cond, ca_mutex mutex, uint64_t microseconds);
+CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds);
/**
* Free the condition.
/**
* @file
*
- * This file provides APIs related to thread pool.
+ * This file provides APIs related to thread pool. Implementations are provided
+ * by adding a new .c file for each implementation, and adding them conditionally
+ * via the SCONS build script. Currently, cathreadpool_pthreads.c is implemented,
+ * with cathreadpool_winthreads.c being considered. RTOS implementations should use
+ * a name that best describes the used technology, not the OS.
*/
-#ifndef __UTHREAD_POOL_H_
-#define __UTHREAD_POOL_H_
-
-#include <glib.h>
+#ifndef CATHREAD_POOL_H_
+#define CATHREAD_POOL_H_
#include "cacommon.h"
#ifdef __cplusplus
extern "C"
{
-#endif /* __cplusplus */
+#endif // __cplusplus
/**
- * @var u_thread_func
- * @brief Callback type can be registered to thread pool.
+ * Callback type can be registered to thread pool.
*/
-typedef void (*u_thread_func)(void *);
+typedef void (*ca_thread_func)(void *);
+struct ca_thread_pool_details_t;
/**
- * @struct u_thread_msg_t
- * @brief Structure to maintain the data which needs to send to task function.
+ * Thread pool type.
*/
-typedef struct
+typedef struct ca_thread_pool
{
- void *data;
- u_thread_func func;
-} u_thread_msg_t;
-
-/**
- * @var u_thread_pool_t
- * @brief Thread pool type.
- */
-typedef void *u_thread_pool_t;
+ struct ca_thread_pool_details_t* details;
+}*ca_thread_pool_t;
/**
* This function creates a newly allocated thread pool.
* @param thread_pool_handle Handle to newly create thread pool.
* @return Error code, CA_STATUS_OK if success, else error number.
*/
-CAResult_t u_thread_pool_init(uint32_t num_of_threads, u_thread_pool_t *thread_pool_handle);
+CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_pool_handle);
/**
* This function adds a routine to be executed by the thread pool at some future time.
* @return CA_STATUS_OK on success.
* @return Error on failure.
*/
-CAResult_t u_thread_pool_add_task(u_thread_pool_t thread_pool, u_thread_func method,
+CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func method,
void *data);
/**
*
* @param thread_pool The thread pool structure.
*/
-void u_thread_pool_free(u_thread_pool_t thread_pool);
+void ca_thread_pool_free(ca_thread_pool_t thread_pool);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
-#endif /* __UTHREAD_POOL_H_ */
+#endif /* CATHREAD_POOL_H_ */
+++ /dev/null
-/* ****************************************************************
- *
- * Copyright 2014 Samsung Electronics 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 and semaphores.
- */
-
-#include "camutex.h"
-#include <glib.h>
-#include <string.h>
-#include "logger.h"
-
-/**
- * @def TAG
- * @brief Logging tag for module name
- */
-#define TAG PCF("UMUTEX")
-
-ca_mutex ca_mutex_new(void)
-{
- GMutex *mutexLock = g_new(GMutex, 1);
- g_mutex_init(mutexLock);
- return (ca_mutex) mutexLock;
-}
-
-void ca_mutex_lock(ca_mutex mutex)
-{
- if (NULL == mutex)
- {
- OIC_LOG(ERROR, TAG , "ca_mutex_lock, Invalid mutex !");
- return;
- }
-
- GMutex *mutexLock = (GMutex *) mutex;
- g_mutex_lock(mutexLock);
-}
-
-bool ca_mutex_trylock(ca_mutex mutex)
-{
- if (NULL == mutex)
- {
- OIC_LOG(ERROR, TAG, "ca_mutex_trylock, Invalid mutex !");
- return false;
- }
-
- GMutex *mutexLock = (GMutex *) mutex;
-
- return(g_mutex_trylock(mutexLock));
-}
-
-void ca_mutex_unlock(ca_mutex mutex)
-{
- if (NULL == mutex)
- {
- OIC_LOG(ERROR, TAG, "ca_mutex_unlock, Invalid mutex !");
- return;
- }
-
- GMutex *mutexLock = (GMutex *) mutex;
- g_mutex_unlock(mutexLock);
-}
-
-bool ca_mutex_free(ca_mutex mutex)
-{
- if (NULL == mutex)
- {
- OIC_LOG(ERROR, TAG, "ca_mutex_free, Invalid mutex !");
- return false;
- }
-
- GMutex *mutexLock = (GMutex *) mutex;
- g_mutex_clear(mutexLock);
- g_free(mutexLock);
- return true;
-}
-
-ca_cond ca_cond_new(void)
-{
- GCond *condition = g_new(GCond, 1);
- g_cond_init(condition);
- return (ca_cond) condition;
-}
-
-void ca_cond_signal(ca_cond cond)
-{
- if (NULL == cond)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_signal, Invalid condition !");
- return;
- }
-
- GCond *condition = (GCond *) cond;
- g_cond_signal(condition);
-}
-
-void ca_cond_broadcast(ca_cond cond)
-{
- if (NULL == cond)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_broadcast, Invalid condition !");
- return;
- }
-
- GCond *condition = (GCond *) cond;
- g_cond_broadcast(condition);
-}
-
-void ca_cond_wait(ca_cond cond, ca_mutex mutex)
-{
- if (NULL == mutex)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_wait, Invalid mutex !");
- return;
- }
-
- if (NULL == cond)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_wait, Invalid condition !");
- return;
- }
-
- GMutex *mutexLock = (GMutex *) mutex;
- GCond *condition = (GCond *) cond;
- g_cond_wait(condition, mutexLock);
-}
-
-CAWaitResult_t ca_cond_wait_until(ca_cond cond, ca_mutex mutex, uint64_t microseconds)
-{
- if (NULL == mutex)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_wait, Invalid mutex !");
- return CA_WAIT_INVAL;
- }
-
- if (NULL == cond)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_wait, Invalid condition !");
- return CA_WAIT_INVAL;
- }
-
- GMutex *mutexLock = (GMutex *) mutex;
- GCond *condition = (GCond *) cond;
-
- if (microseconds == 0)
- {
- g_cond_wait(condition, mutexLock);
- return CA_WAIT_SUCCESS;
- }
-
- gboolean bRet = g_cond_wait_until(condition, mutexLock, microseconds);
- return bRet ? CA_WAIT_SUCCESS : CA_WAIT_TIMEDOUT;
-}
-
-void ca_cond_free(ca_cond cond)
-{
- if (NULL == cond)
- {
- OIC_LOG(ERROR, TAG, "ca_cond_free, Invalid condition !");
- return;
- }
-
- GCond *condition = (GCond *) cond;
- g_cond_clear(condition);
- g_free(condition);
-}
-
-
* This file provides APIs related to mutex and semaphores.
*/
+// Defining _POSIX_C_SOURCE macro with 199309L (or greater) as value
+// causes header files to expose definitions
+// corresponding to the POSIX.1b, Real-time extensions
+// (IEEE Std 1003.1b-1993) specification
+//
+// For this specific file, see use of clock_gettime and PTHREAD_MUTEX_DEFAULT
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#endif
+
#include <string.h>
#include <pthread.h>
#include <errno.h>
*/
#define TAG PCF("UMUTEX")
-static const uint64_t USECS_PER_SEC = 1000000;
-static const uint64_t NANOSECS_PER_USECS = 1000;
+static const uint64_t USECS_PER_SEC = 1000000;
+static const uint64_t NANOSECS_PER_USECS = 1000;
+static const uint64_t NANOSECS_PER_SEC = 1000000000L;
typedef struct _tagMutexInfo_t
{
typedef struct _tagEventInfo_t
{
pthread_cond_t cond;
+ pthread_condattr_t condattr;
} ca_cond_internal;
ca_mutex ca_mutex_new(void)
{
int ret = pthread_mutex_lock(&mutexInfo->mutex);
assert(0 == ret);
+ (void)ret;
}
else
{
if (mutexInfo)
{
int ret = pthread_mutex_unlock(&mutexInfo->mutex);
- assert(ret == 0);
+ assert ( 0 == ret);
+ (void)ret;
}
else
{
ca_cond_internal *eventInfo = (ca_cond_internal*) OICMalloc(sizeof(ca_cond_internal));
if (NULL != eventInfo)
{
- int ret = pthread_cond_init(&(eventInfo->cond), NULL);
+ int ret = pthread_condattr_init(&(eventInfo->condattr));
+ if(0 != ret)
+ {
+ OIC_LOG_V(ERROR, TAG, "%s: Failed to initialize condition variable attribute %d!",
+ __func__, ret);
+ return retVal;
+ }
+
+#if defined(__ANDROID__) || _POSIX_TIMERS > 0
+ ret = pthread_condattr_setclock(&(eventInfo->condattr), CLOCK_MONOTONIC);
+
+ if(0 != ret)
+ {
+ OIC_LOG_V(ERROR, TAG, "%s: Failed to set condition variable clock %d!",
+ __func__, ret);
+ return retVal;
+ }
+#endif
+ ret = pthread_cond_init(&(eventInfo->cond), &(eventInfo->condattr));
if (0 == ret)
{
retVal = (ca_cond) eventInfo;
if (eventInfo != NULL)
{
int ret = pthread_cond_destroy(&(eventInfo->cond));
- if (0 == ret)
+ int ret2 = pthread_condattr_destroy(&(eventInfo->condattr));
+ if (0 == ret && 0 == ret2)
{
OICFree(cond);
}
else
{
- OIC_LOG_V(ERROR, TAG, "%s: Failed to destroy condition variable %d", __func__, ret);
+ OIC_LOG_V(ERROR, TAG, "%s: Failed to destroy condition variable %d, %d",
+ __func__, ret, ret2);
}
}
else
void ca_cond_wait(ca_cond cond, ca_mutex mutex)
{
- ca_cond_wait_until(cond, mutex, 0L);
+ ca_cond_wait_for(cond, mutex, 0L);
+}
+
+struct timespec ca_get_current_time()
+{
+#if defined(__ANDROID__) || _POSIX_TIMERS > 0
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts;
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC(&tv, &ts);
+ return ts;
+#endif
+}
+
+void ca_add_microseconds_to_timespec(struct timespec* ts, uint64_t microseconds)
+{
+ time_t secPart = microseconds/USECS_PER_SEC;
+ uint64_t nsecPart = (microseconds % USECS_PER_SEC) * NANOSECS_PER_USECS;
+ uint64_t totalNs = ts->tv_nsec + nsecPart;
+ time_t secOfNs = totalNs/NANOSECS_PER_SEC;
+
+ ts->tv_nsec = (totalNs)% NANOSECS_PER_SEC;
+ ts->tv_sec += secPart + secOfNs;
}
-CAWaitResult_t ca_cond_wait_until(ca_cond cond, ca_mutex mutex, uint64_t microseconds)
+CAWaitResult_t ca_cond_wait_for(ca_cond cond, ca_mutex mutex, uint64_t microseconds)
{
CAWaitResult_t retVal = CA_WAIT_INVAL;
if (microseconds > 0)
{
- struct timespec abstime;
- abstime.tv_sec = (microseconds / USECS_PER_SEC);
- abstime.tv_nsec = ((microseconds % USECS_PER_SEC) * NANOSECS_PER_USECS);
+ struct timespec abstime = ca_get_current_time();
+ ca_add_microseconds_to_timespec(&abstime, microseconds);
//Wait for the given time
int ret = pthread_cond_timedwait(&(eventInfo->cond), &(mutexInfo->mutex), &abstime);
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2014 Samsung Electronics 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 thread pool.
+ */
+
+#include <pthread.h>
+#include "cathreadpool.h"
+#include "logger.h"
+#include "oic_malloc.h"
+
+#define TAG PCF("UTHREADPOOL")
+
+/**
+ * empty struct to represent the details. This implementation has no data
+ * that it needs to keep track of, so it only uses NULL for the internal value.
+ */
+typedef struct ca_thread_pool_details_t
+{
+} ca_thread_pool_details_t;
+
+/**
+ * struct to wrap the pthreads callback properly. The function pointer for
+ * pthreads requires a void* return value, however u_thread_func is a void.
+ */
+typedef struct ca_thread_pool_callback_info_t
+{
+ ca_thread_func func;
+ void* data;
+} ca_thread_pool_callback_info_t;
+
+// passthrough function to convert the pthreads call to a u_thread_func call
+void* ca_thread_pool_pthreads_delegate(void* data)
+{
+ ca_thread_pool_callback_info_t* info = (ca_thread_pool_callback_info_t*)data;
+ info->func(info->data);
+ OICFree(info);
+ return NULL;
+}
+
+// this implementation doesn't do a thread pool, so this function is essentially
+// a no-op besides creating a valid ca_thread_pool_t object. It was determined after
+// reading through the existing implementation that the thread-pooling was unnecessary
+// for the posix platforms. Behavior shouldn't be changed since previously num_of_threads
+// was greater than the number of requested threads.
+CAResult_t ca_thread_pool_init(int32_t num_of_threads, ca_thread_pool_t *thread_pool)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ if(!thread_pool)
+ {
+ OIC_LOG(ERROR, TAG, "Parameter thraed_pool was null!");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ if(num_of_threads <= 0)
+ {
+ OIC_LOG(ERROR, TAG, "num_of_threads must be positive and non-zero");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ *thread_pool = OICMalloc(sizeof(struct ca_thread_pool));
+
+ if(!*thread_pool)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to allocate for thread-pool");
+ return CA_MEMORY_ALLOC_FAILED;
+ }
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return CA_STATUS_OK;
+}
+
+CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func method,
+ void *data)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ if(NULL == thread_pool || NULL == method)
+ {
+ OIC_LOG(ERROR, TAG, "thread_pool or method was NULL");
+ return CA_STATUS_INVALID_PARAM;
+ }
+
+ ca_thread_pool_callback_info_t* info = OICMalloc(sizeof(ca_thread_pool_callback_info_t));
+ if(!info)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to allocate for memory wrapper");
+ return CA_MEMORY_ALLOC_FAILED;
+ }
+
+ info->func = method;
+ info->data = data;
+
+ pthread_t threadHandle;
+
+ int result = pthread_create(&threadHandle, NULL, ca_thread_pool_pthreads_delegate, info);
+
+ if(result != 0)
+ {
+ OIC_LOG_V(ERROR, TAG, "Thread start failed with error %d", result);
+ return CA_STATUS_FAILED;
+ }
+
+ // detach will cause the thread to either terminate normally and clean up after
+ // itself, which prevents us from having to do any manual join/cleanup later, or
+ // it will be terminated upon application exit.
+ result = pthread_detach(threadHandle);
+
+ if(result != 0)
+ {
+ OIC_LOG_V(ERROR, TAG, "Thread detach failed with error %d", result);
+ return CA_STATUS_FAILED;
+ }
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return CA_STATUS_OK;
+}
+
+void ca_thread_pool_free(ca_thread_pool_t thread_pool)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ OICFree(thread_pool);
+ OIC_LOG(DEBUG, TAG, "OUT");
+}
+++ /dev/null
-/* ****************************************************************
- *
- * Copyright 2014 Samsung Electronics 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 thread pool.
- */
-
-#include "uthreadpool.h"
-#include "logger.h"
-#include "oic_malloc.h"
-
-#define TAG PCF("UTHREADPOOL")
-
-/**
- * @fn run
- * @brief function which is registed to glib thread pool.
- */
-static void run(void *thread_data, void *user_data);
-
-CAResult_t u_thread_pool_init(uint32_t num_of_threads, u_thread_pool_t *thread_pool)
-{
- OIC_LOG(DEBUG, TAG, "IN");
-
- GError *error = NULL;
-
- GThreadPool *threadPool = g_thread_pool_new(run, NULL, num_of_threads, TRUE, &error);
-
- if (NULL == threadPool)
- {
- OIC_LOG(ERROR, TAG, "g_thread_pool_new failed!");
- if (NULL != error)
- {
- OIC_LOG_V(ERROR, TAG, "Error is: %s", error->message);
- g_error_free(error);
- }
- return CA_STATUS_FAILED;
- }
-
- *thread_pool = (u_thread_pool_t) threadPool;
-
- OIC_LOG(DEBUG, TAG, "OUT");
- return CA_STATUS_OK;
-}
-
-CAResult_t u_thread_pool_add_task(u_thread_pool_t thread_pool, u_thread_func method,
- void *data)
-{
- OIC_LOG(DEBUG, TAG, "IN");
-
- if (NULL == method)
- {
- OIC_LOG(ERROR, TAG, "routine is NULL!");
- return CA_STATUS_FAILED;
- }
-
- u_thread_msg_t *message = (u_thread_msg_t *) OICMalloc(sizeof(u_thread_msg_t));
- if (NULL == message)
- {
- OIC_LOG(ERROR, TAG, "Memory allocation failed!");
- return CA_MEMORY_ALLOC_FAILED;
- }
-
- message->data = data;
- message->func = method;
-
- g_thread_pool_push((GThreadPool *) thread_pool, (void *) message, NULL);
-
- OIC_LOG(DEBUG, TAG, "OUT");
- return CA_STATUS_OK;
-}
-
-void u_thread_pool_free(u_thread_pool_t thread_pool)
-{
- OIC_LOG(DEBUG, TAG, "IN");
- if (NULL == thread_pool)
- {
- OIC_LOG(DEBUG, TAG, "thread_pool is NULL. Its already freed.");
- return;
- }
-
- GThreadPool *threadpool = (GThreadPool *) thread_pool;
- g_thread_pool_free(threadpool, TRUE, TRUE);
-
- OIC_LOG(DEBUG, TAG, "OUT");
-}
-
-void run(void *thread_data, void *user_data)
-{
- u_thread_msg_t *message = (u_thread_msg_t *) thread_data;
-
- if (NULL == message)
- {
- OIC_LOG(ERROR, TAG, "Invalid task data");
- return;
- }
-
- if(message->func)
- {
- OIC_LOG(DEBUG, TAG, "Calling routine with data as parameter");
- message->func(message->data);
- }
-
- // Free message
- OICFree(message);
-}
-
**/
#include "cacommon.h"
#include "caadapterinterface.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#ifdef __cplusplus
extern "C"
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
CANetworkChangeCallback netCallback,
- u_thread_pool_t handle);
+ ca_thread_pool_t handle);
/**
* @brief Starts EDR connectivity adapters. As its peer to peer it doesnot require to start
#include <stdbool.h>
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "jni.h"
* @param handle [IN] thread pool handle object
* @return None
*/
-void CAEDRInitialize(u_thread_pool_t handle);
+void CAEDRInitialize(ca_thread_pool_t handle);
/**
* @brief Terminate server for EDR
* @brief Used to initialize the EDR client module where mutex is initialized
* @return NONE
*/
-void CAEDRInitializeClient(u_thread_pool_t handle);
+void CAEDRInitializeClient(ca_thread_pool_t handle);
/**
* @brief Destroys the Device list and mutex.
* @retval #CA_STATUS_FAILED Operation failed
*
*/
-CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, u_thread_pool_t handle);
+CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_pool_t handle);
/**
* @brief Stop RFCOMM server
#include <stdbool.h>
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "jni.h"
* @param handle [IN] thread pool handle object
* @return None
*/
-void CAEDRServerInitialize(u_thread_pool_t handle);
+void CAEDRServerInitialize(ca_thread_pool_t handle);
/**
* @brief Start unicast server
#define __CA_EDRUTILES_H_
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#include "jni.h"
#include "cacommon.h"
#include "caadapterinterface.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#ifdef __cplusplus
extern "C"
*/
CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback, u_thread_pool_t handle);
+ CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
/**
* @brief Start Ethernet Interface adapter.
#include <stdbool.h>
#include "cacommon.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#ifdef __cplusplus
extern "C"
* @retval #CA_STATUS_INVALID_PARAM Invalid input data
* @retval #CA_STATUS_FAILED Initialization failed
*/
-CAResult_t CAEthernetInitializeServer(const u_thread_pool_t threadPool);
+CAResult_t CAEthernetInitializeServer(const ca_thread_pool_t threadPool);
/**
* @brief Terminate Ethernet server
* @retval #CA_STATUS_INVALID_PARAM Invalid input data
* @retval #CA_STATUS_FAILED Initialization failed
*/
-CAResult_t CAEthernetInitializeNetworkMonitor(const u_thread_pool_t threadPool);
+CAResult_t CAEthernetInitializeNetworkMonitor(const ca_thread_pool_t threadPool);
/**
* @brief Terminate Ethernet network monitor
#define __CA_INTERFACE_CONTROLLER_H_
#include "caadapterinterface.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#ifdef __cplusplus
extern "C"
* @param handle [IN] thread pool handle created by message handler for different adapters.
* @return none
*/
-void CAInitializeAdapters(u_thread_pool_t handle);
+void CAInitializeAdapters(ca_thread_pool_t handle);
/**
* @brief Set the received packets callback for message handler
#include "cacommon.h"
#include "caadapterinterface.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
/**
* BLE Interface APIs.
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
CANetworkChangeCallback netCallback,
- u_thread_pool_t handle);
+ ca_thread_pool_t handle);
/**
* @brief Starting LE connectivity adapters.
#define __CA_LECORE_H_
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "jni.h"
#ifdef __cplusplus
* @param handle [IN] thread pool handle object
* @return None
*/
-void CALEInitialize(u_thread_pool_t handle);
+void CALEInitialize(ca_thread_pool_t handle);
/**
* @brief terminate client for BLE
* @retval #CA_STATUS_INVALID_PARAM Invalid input argumets
* @retval #CA_STATUS_FAILED Operation failed
*/
-void CASetBleServerThreadPoolHandle(u_thread_pool_t handle);
+void CASetBleServerThreadPoolHandle(ca_thread_pool_t handle);
/**
* @brief Used to Set the gThreadPool handle which is required for spawning new thread.
* task.
* @return NONE
*/
-void CASetBleClientThreadPoolHandle(u_thread_pool_t handle);
+void CASetBleClientThreadPoolHandle(ca_thread_pool_t handle);
/**
* @brief Used to unset the callback of adapter connection state change.
#define __CA_LENWMONITOR_H_
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#include "jni.h"
#define __CA_LESERVER_H_
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#include "jni.h"
* @param handle [IN] thread pool handle object
* @return None
*/
-void CALEServerInitialize(u_thread_pool_t handle);
+void CALEServerInitialize(ca_thread_pool_t handle);
/**
* @brief terminate client for BLE
#define __CA_LEUTILES_H_
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#include "jni.h"
#include <stdint.h>
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "camutex.h"
#include "uqueue.h"
#include "cacommon.h"
typedef struct
{
/** Thread pool of the thread started **/
- u_thread_pool_t threadPool;
+ ca_thread_pool_t threadPool;
/** mutex for synchrnoization **/
ca_mutex threadMutex;
/** conditional mutex for synchrnoization **/
* @param destroy [IN] function to data destroy
* @return CA_STATUS_OK or ERROR CODES ( CAResult_t error codes in cacommon.h)
*/
-CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, u_thread_pool_t handle,
+CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, ca_thread_pool_t handle,
CAThreadTask task, CADataDestroyFunction destroy);
/**
#include <stdint.h>
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "camutex.h"
#include "uarraylist.h"
#include "cacommon.h"
typedef struct
{
/** Thread pool of the thread started **/
- u_thread_pool_t threadPool;
+ ca_thread_pool_t threadPool;
/** mutex for synchronization **/
ca_mutex threadMutex;
* if NULL is coming, it will set default values.
* @return CA_STATUS_OK or ERROR CODES (CAResult_t error codes in cacommon.h)
*/
-CAResult_t CARetransmissionInitialize(CARetransmission_t *context, u_thread_pool_t handle,
+CAResult_t CARetransmissionInitialize(CARetransmission_t *context, ca_thread_pool_t handle,
CADataSendMethod_t retransmissionSendMethod,
CATimeoutCallback_t timeoutCallback,
CARetransmissionConfig_t* config);
#include "cacommon.h"
#include "caadapterinterface.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#ifdef __cplusplus
extern "C"
*/
CAResult_t CAInitializeWIFI(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback, u_thread_pool_t handle);
+ CANetworkChangeCallback netCallback, ca_thread_pool_t handle);
/**
* @brief Start WIFI Interface adapter.
#include <stdbool.h>
#include "cacommon.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#ifdef __cplusplus
extern "C"
* @retval #CA_STATUS_INVALID_PARAM Invalid input data
* @retval #CA_STATUS_FAILED Initialization failed
*/
-CAResult_t CAWiFiInitializeServer(const u_thread_pool_t threadPool);
+CAResult_t CAWiFiInitializeServer(const ca_thread_pool_t threadPool);
/**
* @retval #CA_STATUS_INVALID_PARAM Invalid input data
* @retval #CA_STATUS_FAILED Initialization failed
*/
-CAResult_t CAWiFiInitializeNetworkMonitor(const u_thread_pool_t threadPool);
+CAResult_t CAWiFiInitializeNetworkMonitor(const ca_thread_pool_t threadPool);
/**
* @brief Terminate WIFI network monitor
+++ /dev/null
-#/******************************************************************
-#*
-#* Copyright 2015 Samsung Electronics 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.
-#*
-#******************************************************************/
-rm -f *.so
-
-set NDK_PATH="~/ndk"
-$NDK_PATH/ndk-build clean
-$NDK_PATH/ndk-build
-
-#change the folder path as per TARGET_ARCH
-cp libs/armeabi/*.* .
-
+++ /dev/null
-/******************************************************************
-*
-* Copyright 2014 Samsung Electronics 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.
-*
-******************************************************************/
-
-Pre-requisites :
-Install libffi6 and libffi-dev packages
-#sudo apt-get install libffi6 libffi-dev
-
-
-Download Gnome Glib 2.40.2 from http://ftp.gnome.org/pub/GNOME/sources/glib/2.40/
-1.Download glib-2.40.2.tar.xz
-
-2.untar the Downloaded file
-#tar -xJf glib-2.40.2.tar.xz
-
-3.change to glib-2.40.2 directory
-#cd glib-2.40.2
-
-4.
-#./configure
-
-5.If configure is successful, your base folder is ready to apply the patch :
-#cd ..
-#patch -p1 < resource/csdk/connectivity/lib/android/patches/glib-2.40.2.patch
-
-There are two kinds of patches :
- - with Android.mk files, automatically added in the respective folders
- - without Android.mk files (If you want to use your own Android.mk files)
-
- glib-2.40.2.patch
- glib-2.40.2-wihtoutMakefile.patch
-
- glib-2.40.2-x64.patch
- glib-2.40.2-x64-wihtoutMakefile.patch
-
-If you are using 64-bit linux build, please apply the patch named with "x64"
-
-6.To build glib libraries for Android, Andoroid.mk and Application.mk are placed at
-resource/csdk/connectivity/lib/android/jni
-#cd resource/csdk/connectivity/lib/android
-
-7.Edit the resource/csdk/connectivity/lib/android/jni/Android.mk
-#vi jni/Android.mk
-
-8.Copy your glib-2.40.2 directory to extlibs/glib.
-Edit the GLIB_SRC_PATH and add the path to glib source directory
-GLIB_SRC_PATH ?= ../../../../../extlibs/glib/glib-2.40.2
-
-9a-1.run the ndk-build
-#$(NDK_PATH)/ndk-build
-
-9a-2.copy libglib-2.40.2.so and libgthread-2.40.2.so from libs/armeabi folder to
-resource/csdk/connectivity/lib/android directory
-Change the folder path as per the TARGET_ARCH
-#cp libs/armeabi/*.* ./
-
-or
-
-9b-1.
-#chmod 777 ./glib_build.sh
-
-9b-2. Edit the NDK_PATH and set the ndk folder path
-#vi glib_build.sh
-NDK_PATH = ~/ndk
-
-9b-3 Edit the folder path as per TARGET_ARCH
-#cp libs/armeabi/*.* .
-
-9b-4.
-#./glib_build.sh
-
-10.This will build the glib libraries and copy to the current folder
-
-11. To build with NDK Edit the resource/csdk/connectivity/build/Android.mk file.
-set the GLIB_PATH to your glib-2.40.2 folder path.
-
-GLIB_PATH = $(PROJECT_LIB_PATH)/android/glib-2.40.2
-
#define build type
BUILD = debug
-#you can set the path to ../../../../../extlibs/glib
-GLIB_SRC_PATH ?= $(YOUR_GLIB_PATH)/glib-2.40.2
-
DEFINE_FLAG = -D__ANDROID__
LOCAL_PATH = ../
-#Build glib
include $(CLEAR_VARS)
-include $(GLIB_SRC_PATH)/Android.mk
+++ /dev/null
-diff -rupN glibref/glib-2.40.2/config.h glibpatch/glib-2.40.2/config.h
---- glibref/glib-2.40.2/config.h 2015-03-31 16:25:56.882894898 +0900
-+++ glibpatch/glib-2.40.2/config.h 2015-04-01 13:21:19.593558693 +0900
-@@ -31,8 +31,9 @@
- /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
-
- /* always defined to indicate that i18n is enabled */
-+#ifndef _GLIB_ANDROID_
- #define ENABLE_NLS 1
--
-+#endif /* _GLIB_ANDROID__ */
- /* Define the gettext package to be used */
- #define GETTEXT_PACKAGE "glib20"
-
-@@ -100,8 +101,9 @@
- /* #undef HAVE_COCOA */
-
- /* Have nl_langinfo (CODESET) */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_CODESET 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <crt_externs.h> header file. */
- /* #undef HAVE_CRT_EXTERNS_H */
-
-@@ -130,8 +132,10 @@
- /* we have the eventfd(2) system call */
- #define HAVE_EVENTFD 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `fallocate' function. */
- #define HAVE_FALLOCATE 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define if we have FAM */
- /* #undef HAVE_FAM */
-@@ -224,6 +228,7 @@
- /* Define to 1 if you have the `kqueue' function. */
- /* #undef HAVE_KQUEUE */
-
-+#ifndef _GLIB_ANDROID_
- /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
- #define HAVE_LANGINFO_CODESET 1
-
-@@ -232,6 +237,7 @@
-
- /* Have nl_langinfo (PM_STR) */
- #define HAVE_LANGINFO_TIME 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `lchmod' function. */
- /* #undef HAVE_LCHMOD */
-@@ -283,9 +289,10 @@
-
- /* Define to 1 if you have the <memory.h> header file. */
- #define HAVE_MEMORY_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `mmap' function. */
- #define HAVE_MMAP 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the <mntent.h> header file. */
- #define HAVE_MNTENT_H 1
-@@ -317,8 +324,10 @@
- /* Have POSIX function getgrgid_r */
- #define HAVE_POSIX_GETGRGID_R 1
-
-+#ifndef _GLIB_ANDROID_
- /* Have POSIX function getpwuid_r */
- #define HAVE_POSIX_GETPWUID_R 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `posix_memalign' function. */
- #define HAVE_POSIX_MEMALIGN 1
-@@ -333,8 +342,11 @@
- #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
-
- /* Have function pthread_cond_timedwait_relative_np */
-+#ifndef _GLIB_ANDROID_
- /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
--
-+#else
-+#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if the system has the type `ptrdiff_t'. */
- #define HAVE_PTRDIFF_T 1
-
-@@ -384,8 +396,10 @@
- /* Define to 1 if you have the <stdlib.h> header file. */
- #define HAVE_STDLIB_H 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `stpcpy' function. */
- #define HAVE_STPCPY 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `strcasecmp' function. */
- #define HAVE_STRCASECMP 1
-@@ -532,10 +546,10 @@
-
- /* Define to 1 if you have the <sys/xattr.h> header file. */
- #define HAVE_SYS_XATTR_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `timegm' function. */
- #define HAVE_TIMEGM 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <unistd.h> header file. */
- #define HAVE_UNISTD_H 1
-
-@@ -563,7 +577,7 @@
-
- /* Define to 1 if you have the `vsnprintf' function. */
- #define HAVE_VSNPRINTF 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define if you have the 'wchar_t' type. */
- #define HAVE_WCHAR_T 1
-
-@@ -575,12 +589,14 @@
-
- /* Define to 1 if xattr is available */
- #define HAVE_XATTR 1
--
-+#endif
- /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
- /* #undef HAVE_XATTR_NOFOLLOW */
-
- /* Define to 1 if you have the <xlocale.h> header file. */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_XLOCALE_H 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `_NSGetEnviron' function. */
- /* #undef HAVE__NSGETENVIRON */
-diff -rupN glibref/glib-2.40.2/glib/gconvert.c glibpatch/glib-2.40.2/glib/gconvert.c
---- glibref/glib-2.40.2/glib/gconvert.c 2015-03-31 16:25:56.946894901 +0900
-+++ glibpatch/glib-2.40.2/glib/gconvert.c 2015-03-31 16:40:50.546926503 +0900
-@@ -22,7 +22,11 @@
- #include "glibconfig.h"
-
- #ifndef G_OS_WIN32
-+
-+#ifndef _GLIB_ANDROID_
- #include <iconv.h>
-+#endif /* _GLIB_ANDROID_ */
-+
- #endif
- #include <errno.h>
- #include <stdio.h>
-@@ -168,6 +172,7 @@
-
- G_DEFINE_QUARK (g_convert_error, g_convert_error)
-
-+#ifndef _GLIB_ANDROID_
- static gboolean
- try_conversion (const char *to_codeset,
- const char *from_codeset,
-@@ -197,9 +202,9 @@ try_to_aliases (const char **to_aliases,
- p++;
- }
- }
--
- return FALSE;
- }
-+#endif /* _GLIB_ANDROID_ */
-
- /**
- * g_iconv_open:
-@@ -220,6 +225,7 @@ GIConv
- g_iconv_open (const gchar *to_codeset,
- const gchar *from_codeset)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd;
-
- if (!try_conversion (to_codeset, from_codeset, &cd))
-@@ -248,6 +254,9 @@ g_iconv_open (const gchar *to_codeset,
-
- out:
- return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
-+#else
-+ return (GIConv)-1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -274,9 +283,13 @@ g_iconv (GIConv converter,
- gchar **outbuf,
- gsize *outbytes_left)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -297,9 +310,13 @@ g_iconv (GIConv converter,
- gint
- g_iconv_close (GIConv converter)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv_close (cd);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- static GIConv
-diff -rupN glibref/glib-2.40.2/glib/gfileutils.c glibpatch/glib-2.40.2/glib/gfileutils.c
---- glibref/glib-2.40.2/glib/gfileutils.c 2015-03-31 16:25:57.170894910 +0900
-+++ glibpatch/glib-2.40.2/glib/gfileutils.c 2015-03-31 16:37:29.594919396 +0900
-@@ -54,7 +54,9 @@
-
- #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
- #include <linux/magic.h>
-+#ifndef _GLIB_ANDROID_
- #include <sys/vfs.h>
-+#endif /* _GLIB_ANDROID_ */
- #endif
-
-
-diff -rupN glibref/glib-2.40.2/glib/ggettext.c glibpatch/glib-2.40.2/glib/ggettext.c
---- glibref/glib-2.40.2/glib/ggettext.c 2015-03-31 16:25:57.182894907 +0900
-+++ glibpatch/glib-2.40.2/glib/ggettext.c 2015-03-31 16:37:55.538920314 +0900
-@@ -40,7 +40,10 @@
-
- #include <string.h>
- #include <locale.h>
-+
-+#ifndef _GLIB_ANDROID_
- #include <libintl.h>
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef G_OS_WIN32
-
-diff -rupN glibref/glib-2.40.2/glib/glibconfig.h glibpatch/glib-2.40.2/glib/glibconfig.h
---- glibref/glib-2.40.2/glib/glibconfig.h 2015-03-31 16:25:57.166894909 +0900
-+++ glibpatch/glib-2.40.2/glib/glibconfig.h 2015-03-31 16:38:06.954920717 +0900
-@@ -154,7 +154,9 @@ typedef unsigned int guintptr;
- #define G_THREADS_ENABLED
- #define G_THREADS_IMPL_POSIX
-
-+#ifndef _GLIB_ANDROID_
- #define G_ATOMIC_LOCK_FREE
-+#endif /* _GLIB_ANDROID_ */
-
- #define GINT16_TO_LE(val) ((gint16) (val))
- #define GUINT16_TO_LE(val) ((guint16) (val))
-diff -rupN glibref/glib-2.40.2/glib/gslice.c glibpatch/glib-2.40.2/glib/gslice.c
---- glibref/glib-2.40.2/glib/gslice.c 2015-03-31 16:25:56.946894901 +0900
-+++ glibpatch/glib-2.40.2/glib/gslice.c 2015-03-31 16:38:38.302921827 +0900
-@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
- * This way it's possible to force gslice to be enabled under
- * valgrind just by setting G_SLICE to the empty string.
- */
-+ #ifndef _GLIB_ANDROID_
- if (RUNNING_ON_VALGRIND)
-+#endif /* _GLIB_ANDROID_ */
- config->always_malloc = TRUE;
- }
- }
-diff -rupN glibref/glib-2.40.2/glib/gstrfuncs.c glibpatch/glib-2.40.2/glib/gstrfuncs.c
---- glibref/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 16:25:56.950894901 +0900
-+++ glibpatch/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 16:39:00.154922598 +0900
-@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
-
- const guint16 * const g_ascii_table = ascii_table_data;
-
-+#ifndef _GLIB_ANDROID_
- #if defined (HAVE_NEWLOCALE) && \
- defined (HAVE_USELOCALE) && \
- defined (HAVE_STRTOD_L) && \
-@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
- defined (HAVE_STRTOLL_L)
- #define USE_XLOCALE 1
- #endif
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef USE_XLOCALE
- static locale_t
+++ /dev/null
-diff -rupN glibremake/glibbase/glib-2.40.2/config.h glibremake/glib-2.40.2/config.h
---- glibremake/glibbase/glib-2.40.2/config.h 2015-03-31 18:56:48.099484578 +0900
-+++ glibremake/glib-2.40.2/config.h 2015-03-31 19:36:57.139558379 +0900
-@@ -8,10 +8,10 @@
- #define ALIGNOF_GUINT32 4
-
- /* The normal alignment of `guint64', in bytes. */
--#define ALIGNOF_GUINT64 8
-+#define ALIGNOF_GUINT64 4
-
- /* The normal alignment of `unsigned long', in bytes. */
--#define ALIGNOF_UNSIGNED_LONG 8
-+#define ALIGNOF_UNSIGNED_LONG 4
-
- /* poll doesn't work on devices */
- /* #undef BROKEN_POLL */
-@@ -31,8 +31,9 @@
- /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
-
- /* always defined to indicate that i18n is enabled */
-+#ifndef _GLIB_ANDROID_
- #define ENABLE_NLS 1
--
-+#endif /* _GLIB_ANDROID__ */
- /* Define the gettext package to be used */
- #define GETTEXT_PACKAGE "glib20"
-
-@@ -100,8 +101,9 @@
- /* #undef HAVE_COCOA */
-
- /* Have nl_langinfo (CODESET) */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_CODESET 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <crt_externs.h> header file. */
- /* #undef HAVE_CRT_EXTERNS_H */
-
-@@ -130,8 +132,10 @@
- /* we have the eventfd(2) system call */
- #define HAVE_EVENTFD 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `fallocate' function. */
- #define HAVE_FALLOCATE 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define if we have FAM */
- /* #undef HAVE_FAM */
-@@ -224,6 +228,7 @@
- /* Define to 1 if you have the `kqueue' function. */
- /* #undef HAVE_KQUEUE */
-
-+#ifndef _GLIB_ANDROID_
- /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
- #define HAVE_LANGINFO_CODESET 1
-
-@@ -232,6 +237,7 @@
-
- /* Have nl_langinfo (PM_STR) */
- #define HAVE_LANGINFO_TIME 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `lchmod' function. */
- /* #undef HAVE_LCHMOD */
-@@ -283,9 +289,10 @@
-
- /* Define to 1 if you have the <memory.h> header file. */
- #define HAVE_MEMORY_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `mmap' function. */
- #define HAVE_MMAP 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the <mntent.h> header file. */
- #define HAVE_MNTENT_H 1
-@@ -317,8 +324,10 @@
- /* Have POSIX function getgrgid_r */
- #define HAVE_POSIX_GETGRGID_R 1
-
-+#ifndef _GLIB_ANDROID_
- /* Have POSIX function getpwuid_r */
- #define HAVE_POSIX_GETPWUID_R 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `posix_memalign' function. */
- #define HAVE_POSIX_MEMALIGN 1
-@@ -333,8 +342,11 @@
- #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
-
- /* Have function pthread_cond_timedwait_relative_np */
-+#ifndef _GLIB_ANDROID_
- /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
--
-+#else
-+#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if the system has the type `ptrdiff_t'. */
- #define HAVE_PTRDIFF_T 1
-
-@@ -384,8 +396,10 @@
- /* Define to 1 if you have the <stdlib.h> header file. */
- #define HAVE_STDLIB_H 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `stpcpy' function. */
- #define HAVE_STPCPY 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `strcasecmp' function. */
- #define HAVE_STRCASECMP 1
-@@ -532,10 +546,10 @@
-
- /* Define to 1 if you have the <sys/xattr.h> header file. */
- #define HAVE_SYS_XATTR_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `timegm' function. */
- #define HAVE_TIMEGM 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <unistd.h> header file. */
- #define HAVE_UNISTD_H 1
-
-@@ -563,7 +577,7 @@
-
- /* Define to 1 if you have the `vsnprintf' function. */
- #define HAVE_VSNPRINTF 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define if you have the 'wchar_t' type. */
- #define HAVE_WCHAR_T 1
-
-@@ -575,12 +589,14 @@
-
- /* Define to 1 if xattr is available */
- #define HAVE_XATTR 1
--
-+#endif
- /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
- /* #undef HAVE_XATTR_NOFOLLOW */
-
- /* Define to 1 if you have the <xlocale.h> header file. */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_XLOCALE_H 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `_NSGetEnviron' function. */
- /* #undef HAVE__NSGETENVIRON */
-@@ -628,7 +644,7 @@
- #define SIZEOF_INT 4
-
- /* The size of `long', as computed by sizeof. */
--#define SIZEOF_LONG 8
-+#define SIZEOF_LONG 4
-
- /* The size of `long long', as computed by sizeof. */
- #define SIZEOF_LONG_LONG 8
-@@ -637,13 +653,13 @@
- #define SIZEOF_SHORT 2
-
- /* The size of `size_t', as computed by sizeof. */
--#define SIZEOF_SIZE_T 8
-+#define SIZEOF_SIZE_T 4
-
- /* The size of `ssize_t', as computed by sizeof. */
--#define SIZEOF_SSIZE_T 8
-+#define SIZEOF_SSIZE_T 4
-
- /* The size of `void *', as computed by sizeof. */
--#define SIZEOF_VOID_P 8
-+#define SIZEOF_VOID_P 4
-
- /* The size of `__int64', as computed by sizeof. */
- #define SIZEOF___INT64 0
-@@ -720,13 +736,8 @@
- # endif
- #endif
-
--/* Enable large inode numbers on Mac OS X 10.5. */
--#ifndef _DARWIN_USE_64_BIT_INODE
--# define _DARWIN_USE_64_BIT_INODE 1
--#endif
--
- /* Number of bits in a file offset, on hosts where this is settable. */
--/* #undef _FILE_OFFSET_BITS */
-+#define _FILE_OFFSET_BITS 64
-
- /* defines how to decorate public symbols while building */
- #define _GLIB_EXTERN __attribute__((visibility("default"))) extern
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gconvert.c glibremake/glib-2.40.2/glib/gconvert.c
---- glibremake/glibbase/glib-2.40.2/glib/gconvert.c 2015-03-31 18:56:47.783484568 +0900
-+++ glibremake/glib-2.40.2/glib/gconvert.c 2015-03-31 19:00:09.863490759 +0900
-@@ -22,7 +22,11 @@
- #include "glibconfig.h"
-
- #ifndef G_OS_WIN32
-+
-+#ifndef _GLIB_ANDROID_
- #include <iconv.h>
-+#endif /* _GLIB_ANDROID_ */
-+
- #endif
- #include <errno.h>
- #include <stdio.h>
-@@ -168,6 +172,7 @@
-
- G_DEFINE_QUARK (g_convert_error, g_convert_error)
-
-+#ifndef _GLIB_ANDROID_
- static gboolean
- try_conversion (const char *to_codeset,
- const char *from_codeset,
-@@ -200,6 +205,7 @@ try_to_aliases (const char **to_aliases,
-
- return FALSE;
- }
-+#endif /* _GLIB_ANDROID_ */
-
- /**
- * g_iconv_open:
-@@ -220,6 +226,7 @@ GIConv
- g_iconv_open (const gchar *to_codeset,
- const gchar *from_codeset)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd;
-
- if (!try_conversion (to_codeset, from_codeset, &cd))
-@@ -248,6 +255,9 @@ g_iconv_open (const gchar *to_codeset,
-
- out:
- return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
-+#else
-+ return (GIConv)-1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -274,9 +284,13 @@ g_iconv (GIConv converter,
- gchar **outbuf,
- gsize *outbytes_left)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -297,9 +311,13 @@ g_iconv (GIConv converter,
- gint
- g_iconv_close (GIConv converter)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv_close (cd);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- static GIConv
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gfileutils.c glibremake/glib-2.40.2/glib/gfileutils.c
---- glibremake/glibbase/glib-2.40.2/glib/gfileutils.c 2015-03-31 18:56:47.687484565 +0900
-+++ glibremake/glib-2.40.2/glib/gfileutils.c 2015-03-31 18:59:50.395490162 +0900
-@@ -54,7 +54,7 @@
-
- #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
- #include <linux/magic.h>
--#include <sys/vfs.h>
-+//#include <sys/vfs.h>
- #endif
-
-
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/ggettext.c glibremake/glib-2.40.2/glib/ggettext.c
---- glibremake/glibbase/glib-2.40.2/glib/ggettext.c 2015-03-31 18:56:47.687484565 +0900
-+++ glibremake/glib-2.40.2/glib/ggettext.c 2015-03-31 19:27:28.671540964 +0900
-@@ -40,7 +40,10 @@
-
- #include <string.h>
- #include <locale.h>
-+
-+#ifndef _GLIB_ANDROID_
- #include <libintl.h>
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef G_OS_WIN32
-
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/glibconfig.h glibremake/glib-2.40.2/glib/glibconfig.h
---- glibremake/glibbase/glib-2.40.2/glib/glibconfig.h 2015-03-31 18:56:47.783484568 +0900
-+++ glibremake/glib-2.40.2/glib/glibconfig.h 2015-03-31 19:33:14.071551545 +0900
-@@ -48,30 +48,30 @@ typedef unsigned int guint32;
- #define G_GUINT32_FORMAT "u"
- #define G_HAVE_GINT64 1 /* deprecated, always true */
-
--typedef signed long gint64;
--typedef unsigned long guint64;
-+G_GNUC_EXTENSION typedef signed long long gint64;
-+G_GNUC_EXTENSION typedef unsigned long long guint64;
-
--#define G_GINT64_CONSTANT(val) (val##L)
--#define G_GUINT64_CONSTANT(val) (val##UL)
--#define G_GINT64_MODIFIER "l"
--#define G_GINT64_FORMAT "li"
--#define G_GUINT64_FORMAT "lu"
--
--#define GLIB_SIZEOF_VOID_P 8
--#define GLIB_SIZEOF_LONG 8
--#define GLIB_SIZEOF_SIZE_T 8
--#define GLIB_SIZEOF_SSIZE_T 8
--
--typedef signed long gssize;
--typedef unsigned long gsize;
--#define G_GSIZE_MODIFIER "l"
--#define G_GSSIZE_MODIFIER "l"
--#define G_GSIZE_FORMAT "lu"
--#define G_GSSIZE_FORMAT "li"
--
--#define G_MAXSIZE G_MAXULONG
--#define G_MINSSIZE G_MINLONG
--#define G_MAXSSIZE G_MAXLONG
-+#define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL))
-+#define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL))
-+#define G_GINT64_MODIFIER "ll"
-+#define G_GINT64_FORMAT "lli"
-+#define G_GUINT64_FORMAT "llu"
-+
-+#define GLIB_SIZEOF_VOID_P 4
-+#define GLIB_SIZEOF_LONG 4
-+#define GLIB_SIZEOF_SIZE_T 4
-+#define GLIB_SIZEOF_SSIZE_T 4
-+
-+typedef signed int gssize;
-+typedef unsigned int gsize;
-+#define G_GSIZE_MODIFIER ""
-+#define G_GSSIZE_MODIFIER ""
-+#define G_GSIZE_FORMAT "u"
-+#define G_GSSIZE_FORMAT "i"
-+
-+#define G_MAXSIZE G_MAXUINT
-+#define G_MINSSIZE G_MININT
-+#define G_MAXSSIZE G_MAXINT
-
- typedef gint64 goffset;
- #define G_MINOFFSET G_MININT64
-@@ -82,18 +82,18 @@ typedef gint64 goffset;
- #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
-
-
--#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
--#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
-+#define GPOINTER_TO_INT(p) ((gint) (gint) (p))
-+#define GPOINTER_TO_UINT(p) ((guint) (guint) (p))
-
--#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
--#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
-+#define GINT_TO_POINTER(i) ((gpointer) (gint) (i))
-+#define GUINT_TO_POINTER(u) ((gpointer) (guint) (u))
-
--typedef signed long gintptr;
--typedef unsigned long guintptr;
-+typedef signed int gintptr;
-+typedef unsigned int guintptr;
-
--#define G_GINTPTR_MODIFIER "l"
--#define G_GINTPTR_FORMAT "li"
--#define G_GUINTPTR_FORMAT "lu"
-+#define G_GINTPTR_MODIFIER ""
-+#define G_GINTPTR_FORMAT "i"
-+#define G_GUINTPTR_FORMAT "u"
- #ifndef G_DISABLE_DEPRECATED
- #define g_ATEXIT(proc) (atexit (proc))
- #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
-@@ -107,7 +107,6 @@ typedef unsigned long guintptr;
-
-
- #define G_VA_COPY va_copy
--#define G_VA_COPY_AS_ARRAY 1
-
- #ifdef __cplusplus
- #define G_HAVE_INLINE 1
-@@ -155,7 +154,9 @@ typedef unsigned long guintptr;
- #define G_THREADS_ENABLED
- #define G_THREADS_IMPL_POSIX
-
-+#ifndef _GLIB_ANDROID_
- #define G_ATOMIC_LOCK_FREE
-+#endif /* _GLIB_ANDROID_ */
-
- #define GINT16_TO_LE(val) ((gint16) (val))
- #define GUINT16_TO_LE(val) ((guint16) (val))
-@@ -169,18 +170,18 @@ typedef unsigned long guintptr;
- #define GUINT64_TO_LE(val) ((guint64) (val))
- #define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
- #define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
--#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
--#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
--#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
--#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
-+#define GLONG_TO_LE(val) ((glong) GINT32_TO_LE (val))
-+#define GULONG_TO_LE(val) ((gulong) GUINT32_TO_LE (val))
-+#define GLONG_TO_BE(val) ((glong) GINT32_TO_BE (val))
-+#define GULONG_TO_BE(val) ((gulong) GUINT32_TO_BE (val))
- #define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
- #define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
- #define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
- #define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
--#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
--#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
--#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
--#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
-+#define GSIZE_TO_LE(val) ((gsize) GUINT32_TO_LE (val))
-+#define GSSIZE_TO_LE(val) ((gssize) GINT32_TO_LE (val))
-+#define GSIZE_TO_BE(val) ((gsize) GUINT32_TO_BE (val))
-+#define GSSIZE_TO_BE(val) ((gssize) GINT32_TO_BE (val))
- #define G_BYTE_ORDER G_LITTLE_ENDIAN
-
- #define GLIB_SYSDEF_POLLIN =1
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gslice.c glibremake/glib-2.40.2/glib/gslice.c
---- glibremake/glibbase/glib-2.40.2/glib/gslice.c 2015-03-31 18:56:47.775484568 +0900
-+++ glibremake/glib-2.40.2/glib/gslice.c 2015-03-31 18:57:16.255485440 +0900
-@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
- * This way it's possible to force gslice to be enabled under
- * valgrind just by setting G_SLICE to the empty string.
- */
-+ #if 0
- if (RUNNING_ON_VALGRIND)
-+#endif
- config->always_malloc = TRUE;
- }
- }
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c glibremake/glib-2.40.2/glib/gstrfuncs.c
---- glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 18:56:47.683484565 +0900
-+++ glibremake/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 18:57:07.783485181 +0900
-@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
-
- const guint16 * const g_ascii_table = ascii_table_data;
-
-+#ifndef _GLIB_ANDROID_
- #if defined (HAVE_NEWLOCALE) && \
- defined (HAVE_USELOCALE) && \
- defined (HAVE_STRTOD_L) && \
-@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
- defined (HAVE_STRTOLL_L)
- #define USE_XLOCALE 1
- #endif
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef USE_XLOCALE
- static locale_t
+++ /dev/null
-diff -rupN glibremake/glibbase/glib-2.40.2/Android.mk glibremake/glib-2.40.2/Android.mk
---- glibremake/glibbase/glib-2.40.2/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibremake/glib-2.40.2/Android.mk 2015-03-31 19:38:39.067561502 +0900
-@@ -0,0 +1,14 @@
-+#GLIB Android Makefile to build GLIB modules
-+
-+LOCAL_PATH := $(call my-dir)
-+GLIB_MAIN_DIR := $(LOCAL_PATH)
-+
-+GLIB_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib
-+
-+GTHREAD_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/gthread
-+
-+include $(GLIB_MAIN_DIR)/glib/Android.mk
-+include $(GLIB_MAIN_DIR)/gthread/Android.mk
-+
-diff -rupN glibremake/glibbase/glib-2.40.2/config.h glibremake/glib-2.40.2/config.h
---- glibremake/glibbase/glib-2.40.2/config.h 2015-03-31 18:56:48.099484578 +0900
-+++ glibremake/glib-2.40.2/config.h 2015-03-31 19:36:57.139558379 +0900
-@@ -8,10 +8,10 @@
- #define ALIGNOF_GUINT32 4
-
- /* The normal alignment of `guint64', in bytes. */
--#define ALIGNOF_GUINT64 8
-+#define ALIGNOF_GUINT64 4
-
- /* The normal alignment of `unsigned long', in bytes. */
--#define ALIGNOF_UNSIGNED_LONG 8
-+#define ALIGNOF_UNSIGNED_LONG 4
-
- /* poll doesn't work on devices */
- /* #undef BROKEN_POLL */
-@@ -31,8 +31,9 @@
- /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
-
- /* always defined to indicate that i18n is enabled */
-+#ifndef _GLIB_ANDROID_
- #define ENABLE_NLS 1
--
-+#endif /* _GLIB_ANDROID__ */
- /* Define the gettext package to be used */
- #define GETTEXT_PACKAGE "glib20"
-
-@@ -100,8 +101,9 @@
- /* #undef HAVE_COCOA */
-
- /* Have nl_langinfo (CODESET) */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_CODESET 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <crt_externs.h> header file. */
- /* #undef HAVE_CRT_EXTERNS_H */
-
-@@ -130,8 +132,10 @@
- /* we have the eventfd(2) system call */
- #define HAVE_EVENTFD 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `fallocate' function. */
- #define HAVE_FALLOCATE 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define if we have FAM */
- /* #undef HAVE_FAM */
-@@ -224,6 +228,7 @@
- /* Define to 1 if you have the `kqueue' function. */
- /* #undef HAVE_KQUEUE */
-
-+#ifndef _GLIB_ANDROID_
- /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
- #define HAVE_LANGINFO_CODESET 1
-
-@@ -232,6 +237,7 @@
-
- /* Have nl_langinfo (PM_STR) */
- #define HAVE_LANGINFO_TIME 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `lchmod' function. */
- /* #undef HAVE_LCHMOD */
-@@ -283,9 +289,10 @@
-
- /* Define to 1 if you have the <memory.h> header file. */
- #define HAVE_MEMORY_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `mmap' function. */
- #define HAVE_MMAP 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the <mntent.h> header file. */
- #define HAVE_MNTENT_H 1
-@@ -317,8 +324,10 @@
- /* Have POSIX function getgrgid_r */
- #define HAVE_POSIX_GETGRGID_R 1
-
-+#ifndef _GLIB_ANDROID_
- /* Have POSIX function getpwuid_r */
- #define HAVE_POSIX_GETPWUID_R 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `posix_memalign' function. */
- #define HAVE_POSIX_MEMALIGN 1
-@@ -333,8 +342,11 @@
- #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
-
- /* Have function pthread_cond_timedwait_relative_np */
-+#ifndef _GLIB_ANDROID_
- /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
--
-+#else
-+#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if the system has the type `ptrdiff_t'. */
- #define HAVE_PTRDIFF_T 1
-
-@@ -384,8 +396,10 @@
- /* Define to 1 if you have the <stdlib.h> header file. */
- #define HAVE_STDLIB_H 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `stpcpy' function. */
- #define HAVE_STPCPY 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `strcasecmp' function. */
- #define HAVE_STRCASECMP 1
-@@ -532,10 +546,10 @@
-
- /* Define to 1 if you have the <sys/xattr.h> header file. */
- #define HAVE_SYS_XATTR_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `timegm' function. */
- #define HAVE_TIMEGM 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <unistd.h> header file. */
- #define HAVE_UNISTD_H 1
-
-@@ -563,7 +577,7 @@
-
- /* Define to 1 if you have the `vsnprintf' function. */
- #define HAVE_VSNPRINTF 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define if you have the 'wchar_t' type. */
- #define HAVE_WCHAR_T 1
-
-@@ -575,12 +589,14 @@
-
- /* Define to 1 if xattr is available */
- #define HAVE_XATTR 1
--
-+#endif
- /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
- /* #undef HAVE_XATTR_NOFOLLOW */
-
- /* Define to 1 if you have the <xlocale.h> header file. */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_XLOCALE_H 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `_NSGetEnviron' function. */
- /* #undef HAVE__NSGETENVIRON */
-@@ -628,7 +644,7 @@
- #define SIZEOF_INT 4
-
- /* The size of `long', as computed by sizeof. */
--#define SIZEOF_LONG 8
-+#define SIZEOF_LONG 4
-
- /* The size of `long long', as computed by sizeof. */
- #define SIZEOF_LONG_LONG 8
-@@ -637,13 +653,13 @@
- #define SIZEOF_SHORT 2
-
- /* The size of `size_t', as computed by sizeof. */
--#define SIZEOF_SIZE_T 8
-+#define SIZEOF_SIZE_T 4
-
- /* The size of `ssize_t', as computed by sizeof. */
--#define SIZEOF_SSIZE_T 8
-+#define SIZEOF_SSIZE_T 4
-
- /* The size of `void *', as computed by sizeof. */
--#define SIZEOF_VOID_P 8
-+#define SIZEOF_VOID_P 4
-
- /* The size of `__int64', as computed by sizeof. */
- #define SIZEOF___INT64 0
-@@ -720,13 +736,8 @@
- # endif
- #endif
-
--/* Enable large inode numbers on Mac OS X 10.5. */
--#ifndef _DARWIN_USE_64_BIT_INODE
--# define _DARWIN_USE_64_BIT_INODE 1
--#endif
--
- /* Number of bits in a file offset, on hosts where this is settable. */
--/* #undef _FILE_OFFSET_BITS */
-+#define _FILE_OFFSET_BITS 64
-
- /* defines how to decorate public symbols while building */
- #define _GLIB_EXTERN __attribute__((visibility("default"))) extern
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/Android.mk glibremake/glib-2.40.2/glib/Android.mk
---- glibremake/glibbase/glib-2.40.2/glib/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibremake/glib-2.40.2/glib/Android.mk 2015-03-31 19:40:22.323564665 +0900
-@@ -0,0 +1,115 @@
-+#glib Android Make File
-+
-+LOCAL_PATH := $(call my-dir)
-+
-+include $(CLEAR_VARS)
-+
-+LOCAL_MODULE := glib-2.40.2
-+
-+LOCAL_SRC_FILES := \
-+ libcharset/localcharset.c \
-+ garray.c \
-+ gasyncqueue.c \
-+ gatomic.c \
-+ gbacktrace.c \
-+ gbase64.c \
-+ gbitlock.c \
-+ gbookmarkfile.c \
-+ gbytes.c \
-+ gcharset.c \
-+ gchecksum.c \
-+ gconvert.c \
-+ gdataset.c \
-+ gdate.c \
-+ gdatetime.c \
-+ gdir.c \
-+ gerror.c \
-+ genviron.c \
-+ gfileutils.c \
-+ ggettext.c \
-+ ghash.c \
-+ ghmac.c \
-+ ghook.c \
-+ ghostutils.c \
-+ giochannel.c \
-+ gkeyfile.c \
-+ glib-init.c \
-+ glib-private.c \
-+ glib-unix.c \
-+ glist.c \
-+ gmain.c \
-+ gmappedfile.c \
-+ gmarkup.c \
-+ gmem.c \
-+ gmessages.c \
-+ gnode.c \
-+ goption.c \
-+ gpattern.c \
-+ gpoll.c \
-+ gprimes.c \
-+ gqsort.c \
-+ gquark.c \
-+ gqueue.c \
-+ grand.c \
-+ gregex.c \
-+ gscanner.c \
-+ gsequence.c \
-+ gshell.c \
-+ gslice.c \
-+ gslist.c \
-+ gstdio.c \
-+ gstrfuncs.c \
-+ gstring.c \
-+ gstringchunk.c \
-+ gtestutils.c \
-+ gthread.c \
-+ gthreadpool.c \
-+ gthread-posix.c \
-+ gtimer.c \
-+ gtimezone.c \
-+ gtranslit.c \
-+ gtrashstack.c \
-+ gtree.c \
-+ guniprop.c \
-+ gutf8.c \
-+ gunibreak.c \
-+ gunicollate.c \
-+ gunidecomp.c \
-+ gurifuncs.c \
-+ gutils.c \
-+ gvariant.c \
-+ gvariant-core.c \
-+ gvariant-parser.c \
-+ gvariant-serialiser.c \
-+ gvarianttypeinfo.c \
-+ gvarianttype.c \
-+ gprintf.c \
-+ giounix.c \
-+ gspawn.c \
-+ gversion.c \
-+ gwakeup.c
-+
-+LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib \
-+ $(GLIB_MAIN_DIR)/glib/deprecated \
-+ $(GLIB_MAIN_DIR)/glib/libcharset \
-+ $(GLIB_MAIN_DIR)/pcre \
-+
-+LOCAL_STATIC_LIBRARIES := pcre
-+
-+LOCAL_LD_LIBS := -llog
-+
-+LOCAL_CFLAGS := \
-+ -D_GLIB_ANDROID_ \
-+ -DLIBDIR=\"$(libdir)\" \
-+ -DHAVE_CONFIG_H \
-+ -DG_LOG_DOMAIN=\"GLib\" \
-+ -DGLIB_COMPILATION \
-+ -DPCRE_STATIC \
-+ -DG_DISABLE_CAST_CHECKS
-+
-+include $(BUILD_SHARED_LIBRARY)
-+
-+include $(GLIB_MAIN_DIR)/glib/pcre/Android.mk
-+
-+
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gconvert.c glibremake/glib-2.40.2/glib/gconvert.c
---- glibremake/glibbase/glib-2.40.2/glib/gconvert.c 2015-03-31 18:56:47.783484568 +0900
-+++ glibremake/glib-2.40.2/glib/gconvert.c 2015-03-31 19:00:09.863490759 +0900
-@@ -22,7 +22,11 @@
- #include "glibconfig.h"
-
- #ifndef G_OS_WIN32
-+
-+#ifndef _GLIB_ANDROID_
- #include <iconv.h>
-+#endif /* _GLIB_ANDROID_ */
-+
- #endif
- #include <errno.h>
- #include <stdio.h>
-@@ -168,6 +172,7 @@
-
- G_DEFINE_QUARK (g_convert_error, g_convert_error)
-
-+#ifndef _GLIB_ANDROID_
- static gboolean
- try_conversion (const char *to_codeset,
- const char *from_codeset,
-@@ -200,6 +205,7 @@ try_to_aliases (const char **to_aliases,
-
- return FALSE;
- }
-+#endif /* _GLIB_ANDROID_ */
-
- /**
- * g_iconv_open:
-@@ -220,6 +226,7 @@ GIConv
- g_iconv_open (const gchar *to_codeset,
- const gchar *from_codeset)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd;
-
- if (!try_conversion (to_codeset, from_codeset, &cd))
-@@ -248,6 +255,9 @@ g_iconv_open (const gchar *to_codeset,
-
- out:
- return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
-+#else
-+ return (GIConv)-1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -274,9 +284,13 @@ g_iconv (GIConv converter,
- gchar **outbuf,
- gsize *outbytes_left)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -297,9 +311,13 @@ g_iconv (GIConv converter,
- gint
- g_iconv_close (GIConv converter)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv_close (cd);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- static GIConv
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gfileutils.c glibremake/glib-2.40.2/glib/gfileutils.c
---- glibremake/glibbase/glib-2.40.2/glib/gfileutils.c 2015-03-31 18:56:47.687484565 +0900
-+++ glibremake/glib-2.40.2/glib/gfileutils.c 2015-03-31 18:59:50.395490162 +0900
-@@ -54,7 +54,7 @@
-
- #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
- #include <linux/magic.h>
--#include <sys/vfs.h>
-+//#include <sys/vfs.h>
- #endif
-
-
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/ggettext.c glibremake/glib-2.40.2/glib/ggettext.c
---- glibremake/glibbase/glib-2.40.2/glib/ggettext.c 2015-03-31 18:56:47.687484565 +0900
-+++ glibremake/glib-2.40.2/glib/ggettext.c 2015-03-31 19:27:28.671540964 +0900
-@@ -40,7 +40,10 @@
-
- #include <string.h>
- #include <locale.h>
-+
-+#ifndef _GLIB_ANDROID_
- #include <libintl.h>
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef G_OS_WIN32
-
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/glibconfig.h glibremake/glib-2.40.2/glib/glibconfig.h
---- glibremake/glibbase/glib-2.40.2/glib/glibconfig.h 2015-03-31 18:56:47.783484568 +0900
-+++ glibremake/glib-2.40.2/glib/glibconfig.h 2015-03-31 19:33:14.071551545 +0900
-@@ -48,30 +48,30 @@ typedef unsigned int guint32;
- #define G_GUINT32_FORMAT "u"
- #define G_HAVE_GINT64 1 /* deprecated, always true */
-
--typedef signed long gint64;
--typedef unsigned long guint64;
-+G_GNUC_EXTENSION typedef signed long long gint64;
-+G_GNUC_EXTENSION typedef unsigned long long guint64;
-
--#define G_GINT64_CONSTANT(val) (val##L)
--#define G_GUINT64_CONSTANT(val) (val##UL)
--#define G_GINT64_MODIFIER "l"
--#define G_GINT64_FORMAT "li"
--#define G_GUINT64_FORMAT "lu"
--
--#define GLIB_SIZEOF_VOID_P 8
--#define GLIB_SIZEOF_LONG 8
--#define GLIB_SIZEOF_SIZE_T 8
--#define GLIB_SIZEOF_SSIZE_T 8
--
--typedef signed long gssize;
--typedef unsigned long gsize;
--#define G_GSIZE_MODIFIER "l"
--#define G_GSSIZE_MODIFIER "l"
--#define G_GSIZE_FORMAT "lu"
--#define G_GSSIZE_FORMAT "li"
--
--#define G_MAXSIZE G_MAXULONG
--#define G_MINSSIZE G_MINLONG
--#define G_MAXSSIZE G_MAXLONG
-+#define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL))
-+#define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL))
-+#define G_GINT64_MODIFIER "ll"
-+#define G_GINT64_FORMAT "lli"
-+#define G_GUINT64_FORMAT "llu"
-+
-+#define GLIB_SIZEOF_VOID_P 4
-+#define GLIB_SIZEOF_LONG 4
-+#define GLIB_SIZEOF_SIZE_T 4
-+#define GLIB_SIZEOF_SSIZE_T 4
-+
-+typedef signed int gssize;
-+typedef unsigned int gsize;
-+#define G_GSIZE_MODIFIER ""
-+#define G_GSSIZE_MODIFIER ""
-+#define G_GSIZE_FORMAT "u"
-+#define G_GSSIZE_FORMAT "i"
-+
-+#define G_MAXSIZE G_MAXUINT
-+#define G_MINSSIZE G_MININT
-+#define G_MAXSSIZE G_MAXINT
-
- typedef gint64 goffset;
- #define G_MINOFFSET G_MININT64
-@@ -82,18 +82,18 @@ typedef gint64 goffset;
- #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
-
-
--#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
--#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
-+#define GPOINTER_TO_INT(p) ((gint) (gint) (p))
-+#define GPOINTER_TO_UINT(p) ((guint) (guint) (p))
-
--#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
--#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
-+#define GINT_TO_POINTER(i) ((gpointer) (gint) (i))
-+#define GUINT_TO_POINTER(u) ((gpointer) (guint) (u))
-
--typedef signed long gintptr;
--typedef unsigned long guintptr;
-+typedef signed int gintptr;
-+typedef unsigned int guintptr;
-
--#define G_GINTPTR_MODIFIER "l"
--#define G_GINTPTR_FORMAT "li"
--#define G_GUINTPTR_FORMAT "lu"
-+#define G_GINTPTR_MODIFIER ""
-+#define G_GINTPTR_FORMAT "i"
-+#define G_GUINTPTR_FORMAT "u"
- #ifndef G_DISABLE_DEPRECATED
- #define g_ATEXIT(proc) (atexit (proc))
- #define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
-@@ -107,7 +107,6 @@ typedef unsigned long guintptr;
-
-
- #define G_VA_COPY va_copy
--#define G_VA_COPY_AS_ARRAY 1
-
- #ifdef __cplusplus
- #define G_HAVE_INLINE 1
-@@ -155,7 +154,9 @@ typedef unsigned long guintptr;
- #define G_THREADS_ENABLED
- #define G_THREADS_IMPL_POSIX
-
-+#ifndef _GLIB_ANDROID_
- #define G_ATOMIC_LOCK_FREE
-+#endif /* _GLIB_ANDROID_ */
-
- #define GINT16_TO_LE(val) ((gint16) (val))
- #define GUINT16_TO_LE(val) ((guint16) (val))
-@@ -169,18 +170,18 @@ typedef unsigned long guintptr;
- #define GUINT64_TO_LE(val) ((guint64) (val))
- #define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
- #define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
--#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
--#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
--#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
--#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
-+#define GLONG_TO_LE(val) ((glong) GINT32_TO_LE (val))
-+#define GULONG_TO_LE(val) ((gulong) GUINT32_TO_LE (val))
-+#define GLONG_TO_BE(val) ((glong) GINT32_TO_BE (val))
-+#define GULONG_TO_BE(val) ((gulong) GUINT32_TO_BE (val))
- #define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
- #define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
- #define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
- #define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
--#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
--#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
--#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
--#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
-+#define GSIZE_TO_LE(val) ((gsize) GUINT32_TO_LE (val))
-+#define GSSIZE_TO_LE(val) ((gssize) GINT32_TO_LE (val))
-+#define GSIZE_TO_BE(val) ((gsize) GUINT32_TO_BE (val))
-+#define GSSIZE_TO_BE(val) ((gssize) GINT32_TO_BE (val))
- #define G_BYTE_ORDER G_LITTLE_ENDIAN
-
- #define GLIB_SYSDEF_POLLIN =1
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gslice.c glibremake/glib-2.40.2/glib/gslice.c
---- glibremake/glibbase/glib-2.40.2/glib/gslice.c 2015-03-31 18:56:47.775484568 +0900
-+++ glibremake/glib-2.40.2/glib/gslice.c 2015-03-31 18:57:16.255485440 +0900
-@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
- * This way it's possible to force gslice to be enabled under
- * valgrind just by setting G_SLICE to the empty string.
- */
-+ #if 0
- if (RUNNING_ON_VALGRIND)
-+#endif
- config->always_malloc = TRUE;
- }
- }
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c glibremake/glib-2.40.2/glib/gstrfuncs.c
---- glibremake/glibbase/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 18:56:47.683484565 +0900
-+++ glibremake/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 18:57:07.783485181 +0900
-@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
-
- const guint16 * const g_ascii_table = ascii_table_data;
-
-+#ifndef _GLIB_ANDROID_
- #if defined (HAVE_NEWLOCALE) && \
- defined (HAVE_USELOCALE) && \
- defined (HAVE_STRTOD_L) && \
-@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
- defined (HAVE_STRTOLL_L)
- #define USE_XLOCALE 1
- #endif
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef USE_XLOCALE
- static locale_t
-diff -rupN glibremake/glibbase/glib-2.40.2/glib/pcre/Android.mk glibremake/glib-2.40.2/glib/pcre/Android.mk
---- glibremake/glibbase/glib-2.40.2/glib/pcre/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibremake/glib-2.40.2/glib/pcre/Android.mk 2015-01-13 08:04:00.000000000 +0900
-@@ -0,0 +1,42 @@
-+#libpcre Android Make File
-+
-+LOCAL_PATH := $(call my-dir)
-+
-+include $(CLEAR_VARS)
-+
-+LOCAL_MODULE := pcre
-+
-+LOCAL_LD_LIBS := -llog
-+
-+LOCAL_CFLAGS := \
-+ -DG_LOG_DOMAIN=\"GLib-GRegex\" \
-+ -DHAVE_CONFIG_H \
-+ -DHAVE_MEMMOVE \
-+ -DSUPPORT_UCP \
-+ -DSUPPORT_UTF \
-+ -DSUPPORT_UTF8 \
-+ -DNEWLINE=-1 \
-+ -DMATCH_LIMIT=10000000 \
-+ -DMATCH_LIMIT_RECURSION=8192 \
-+ -DMAX_NAME_SIZE=32 \
-+ -DMAX_NAME_COUNT=10000 \
-+ -DMAX_DUPLENGTH=30000 \
-+ -DLINK_SIZE=2 \
-+ -DPOSIX_MALLOC_THRESHOLD=10 \
-+ -DPCRE_STATIC \
-+ -DG_DISABLE_CAST_CHECKS \
-+ -DGLIB_COMPILATION \
-+ -D_GLIB_ANDROID_
-+
-+LOCAL_SRC_FILES := pcre_xclass.c pcre_valid_utf8.c pcre_tables.c \
-+ pcre_study.c pcre_string_utils.c pcre_ord2utf8.c \
-+ pcre_newline.c pcre_jit_compile.c pcre_globals.c \
-+ pcre_get.c pcre_fullinfo.c pcre_exec.c \
-+ pcre_dfa_exec.c pcre_config.c pcre_compile.c \
-+ pcre_chartables.c pcre_byte_order.c
-+
-+LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib
-+
-+
-+include $(BUILD_STATIC_LIBRARY)
-\ No newline at end of file
-diff -rupN glibremake/glibbase/glib-2.40.2/gthread/Android.mk glibremake/glib-2.40.2/gthread/Android.mk
---- glibremake/glibbase/glib-2.40.2/gthread/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibremake/glib-2.40.2/gthread/Android.mk 2015-03-31 19:39:47.151563588 +0900
-@@ -0,0 +1,25 @@
-+#gthread Android Make File
-+
-+LOCAL_PATH := $(call my-dir)
-+
-+include $(CLEAR_VARS)
-+
-+LOCAL_MODULE := gthread-2.40.2
-+
-+LOCAL_SRC_FILES := gthread-impl.c
-+
-+LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib \
-+ $(GLIB_MAIN_DIR)/gthread
-+
-+
-+LOCAL_CFLAGS := \
-+ -DG_LOG_DOMAIN=\"GThread\" \
-+ -DHAVE_CONFIG_H \
-+ -DG_DISABLE_CAST_CHECKS \
-+ -DG_DISABLE_DEPRECATED \
-+ -D_GLIB_ANDROID_
-+
-+
-+LOCAL_SHARED_LIBRARIES := glib-2.40.2
-+include $(BUILD_SHARED_LIBRARY)
-\ No newline at end of file
+++ /dev/null
-diff -rupN glibref/glib-2.40.2/Android.mk glibpatch/glib-2.40.2/Android.mk
---- glibref/glib-2.40.2/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibpatch/glib-2.40.2/Android.mk 2015-04-01 13:20:38.597557242 +0900
-@@ -0,0 +1,14 @@
-+#GLIB Android Makefile to build GLIB modules
-+
-+LOCAL_PATH := $(call my-dir)
-+GLIB_MAIN_DIR := $(LOCAL_PATH)
-+
-+GLIB_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib
-+
-+GTHREAD_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/gthread
-+
-+include $(GLIB_MAIN_DIR)/glib/Android.mk
-+include $(GLIB_MAIN_DIR)/gthread/Android.mk
-+
-diff -rupN glibref/glib-2.40.2/config.h glibpatch/glib-2.40.2/config.h
---- glibref/glib-2.40.2/config.h 2015-03-31 16:25:56.882894898 +0900
-+++ glibpatch/glib-2.40.2/config.h 2015-04-01 13:21:19.593558693 +0900
-@@ -31,8 +31,9 @@
- /* #undef ENABLE_GC_FRIENDLY_DEFAULT */
-
- /* always defined to indicate that i18n is enabled */
-+#ifndef _GLIB_ANDROID_
- #define ENABLE_NLS 1
--
-+#endif /* _GLIB_ANDROID__ */
- /* Define the gettext package to be used */
- #define GETTEXT_PACKAGE "glib20"
-
-@@ -100,8 +101,9 @@
- /* #undef HAVE_COCOA */
-
- /* Have nl_langinfo (CODESET) */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_CODESET 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <crt_externs.h> header file. */
- /* #undef HAVE_CRT_EXTERNS_H */
-
-@@ -130,8 +132,10 @@
- /* we have the eventfd(2) system call */
- #define HAVE_EVENTFD 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `fallocate' function. */
- #define HAVE_FALLOCATE 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define if we have FAM */
- /* #undef HAVE_FAM */
-@@ -224,6 +228,7 @@
- /* Define to 1 if you have the `kqueue' function. */
- /* #undef HAVE_KQUEUE */
-
-+#ifndef _GLIB_ANDROID_
- /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
- #define HAVE_LANGINFO_CODESET 1
-
-@@ -232,6 +237,7 @@
-
- /* Have nl_langinfo (PM_STR) */
- #define HAVE_LANGINFO_TIME 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `lchmod' function. */
- /* #undef HAVE_LCHMOD */
-@@ -283,9 +289,10 @@
-
- /* Define to 1 if you have the <memory.h> header file. */
- #define HAVE_MEMORY_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `mmap' function. */
- #define HAVE_MMAP 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the <mntent.h> header file. */
- #define HAVE_MNTENT_H 1
-@@ -317,8 +324,10 @@
- /* Have POSIX function getgrgid_r */
- #define HAVE_POSIX_GETGRGID_R 1
-
-+#ifndef _GLIB_ANDROID_
- /* Have POSIX function getpwuid_r */
- #define HAVE_POSIX_GETPWUID_R 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `posix_memalign' function. */
- #define HAVE_POSIX_MEMALIGN 1
-@@ -333,8 +342,11 @@
- #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
-
- /* Have function pthread_cond_timedwait_relative_np */
-+#ifndef _GLIB_ANDROID_
- /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
--
-+#else
-+#define HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP 0
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if the system has the type `ptrdiff_t'. */
- #define HAVE_PTRDIFF_T 1
-
-@@ -384,8 +396,10 @@
- /* Define to 1 if you have the <stdlib.h> header file. */
- #define HAVE_STDLIB_H 1
-
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `stpcpy' function. */
- #define HAVE_STPCPY 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `strcasecmp' function. */
- #define HAVE_STRCASECMP 1
-@@ -532,10 +546,10 @@
-
- /* Define to 1 if you have the <sys/xattr.h> header file. */
- #define HAVE_SYS_XATTR_H 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define to 1 if you have the `timegm' function. */
- #define HAVE_TIMEGM 1
--
-+#endif /* _GLIB_ANDROID_ */
- /* Define to 1 if you have the <unistd.h> header file. */
- #define HAVE_UNISTD_H 1
-
-@@ -563,7 +577,7 @@
-
- /* Define to 1 if you have the `vsnprintf' function. */
- #define HAVE_VSNPRINTF 1
--
-+#ifndef _GLIB_ANDROID_
- /* Define if you have the 'wchar_t' type. */
- #define HAVE_WCHAR_T 1
-
-@@ -575,12 +589,14 @@
-
- /* Define to 1 if xattr is available */
- #define HAVE_XATTR 1
--
-+#endif
- /* Define to 1 if xattr API uses XATTR_NOFOLLOW */
- /* #undef HAVE_XATTR_NOFOLLOW */
-
- /* Define to 1 if you have the <xlocale.h> header file. */
-+#ifndef _GLIB_ANDROID_
- #define HAVE_XLOCALE_H 1
-+#endif /* _GLIB_ANDROID_ */
-
- /* Define to 1 if you have the `_NSGetEnviron' function. */
- /* #undef HAVE__NSGETENVIRON */
-diff -rupN glibref/glib-2.40.2/glib/Android.mk glibpatch/glib-2.40.2/glib/Android.mk
---- glibref/glib-2.40.2/glib/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibpatch/glib-2.40.2/glib/Android.mk 2015-03-31 17:10:22.722989176 +0900
-@@ -0,0 +1,115 @@
-+#glib Android Make File
-+
-+LOCAL_PATH := $(call my-dir)
-+
-+include $(CLEAR_VARS)
-+
-+LOCAL_MODULE := glib-2.40.2
-+
-+LOCAL_SRC_FILES := \
-+ libcharset/localcharset.c \
-+ garray.c \
-+ gasyncqueue.c \
-+ gatomic.c \
-+ gbacktrace.c \
-+ gbase64.c \
-+ gbitlock.c \
-+ gbookmarkfile.c \
-+ gbytes.c \
-+ gcharset.c \
-+ gchecksum.c \
-+ gconvert.c \
-+ gdataset.c \
-+ gdate.c \
-+ gdatetime.c \
-+ gdir.c \
-+ gerror.c \
-+ genviron.c \
-+ gfileutils.c \
-+ ggettext.c \
-+ ghash.c \
-+ ghmac.c \
-+ ghook.c \
-+ ghostutils.c \
-+ giochannel.c \
-+ gkeyfile.c \
-+ glib-init.c \
-+ glib-private.c \
-+ glib-unix.c \
-+ glist.c \
-+ gmain.c \
-+ gmappedfile.c \
-+ gmarkup.c \
-+ gmem.c \
-+ gmessages.c \
-+ gnode.c \
-+ goption.c \
-+ gpattern.c \
-+ gpoll.c \
-+ gprimes.c \
-+ gqsort.c \
-+ gquark.c \
-+ gqueue.c \
-+ grand.c \
-+ gregex.c \
-+ gscanner.c \
-+ gsequence.c \
-+ gshell.c \
-+ gslice.c \
-+ gslist.c \
-+ gstdio.c \
-+ gstrfuncs.c \
-+ gstring.c \
-+ gstringchunk.c \
-+ gtestutils.c \
-+ gthread.c \
-+ gthreadpool.c \
-+ gthread-posix.c \
-+ gtimer.c \
-+ gtimezone.c \
-+ gtranslit.c \
-+ gtrashstack.c \
-+ gtree.c \
-+ guniprop.c \
-+ gutf8.c \
-+ gunibreak.c \
-+ gunicollate.c \
-+ gunidecomp.c \
-+ gurifuncs.c \
-+ gutils.c \
-+ gvariant.c \
-+ gvariant-core.c \
-+ gvariant-parser.c \
-+ gvariant-serialiser.c \
-+ gvarianttypeinfo.c \
-+ gvarianttype.c \
-+ gprintf.c \
-+ giounix.c \
-+ gspawn.c \
-+ gversion.c \
-+ gwakeup.c
-+
-+LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib \
-+ $(GLIB_MAIN_DIR)/glib/deprecated \
-+ $(GLIB_MAIN_DIR)/glib/libcharset \
-+ $(GLIB_MAIN_DIR)/pcre \
-+
-+LOCAL_STATIC_LIBRARIES := pcre
-+
-+LOCAL_LD_LIBS := -llog
-+
-+LOCAL_CFLAGS := \
-+ -D_GLIB_ANDROID_ \
-+ -DLIBDIR=\"$(libdir)\" \
-+ -DHAVE_CONFIG_H \
-+ -DG_LOG_DOMAIN=\"GLib\" \
-+ -DGLIB_COMPILATION \
-+ -DPCRE_STATIC \
-+ -DG_DISABLE_CAST_CHECKS
-+
-+include $(BUILD_SHARED_LIBRARY)
-+
-+include $(GLIB_MAIN_DIR)/glib/pcre/Android.mk
-+
-+
-diff -rupN glibref/glib-2.40.2/glib/gconvert.c glibpatch/glib-2.40.2/glib/gconvert.c
---- glibref/glib-2.40.2/glib/gconvert.c 2015-03-31 16:25:56.946894901 +0900
-+++ glibpatch/glib-2.40.2/glib/gconvert.c 2015-03-31 16:40:50.546926503 +0900
-@@ -22,7 +22,11 @@
- #include "glibconfig.h"
-
- #ifndef G_OS_WIN32
-+
-+#ifndef _GLIB_ANDROID_
- #include <iconv.h>
-+#endif /* _GLIB_ANDROID_ */
-+
- #endif
- #include <errno.h>
- #include <stdio.h>
-@@ -168,6 +172,7 @@
-
- G_DEFINE_QUARK (g_convert_error, g_convert_error)
-
-+#ifndef _GLIB_ANDROID_
- static gboolean
- try_conversion (const char *to_codeset,
- const char *from_codeset,
-@@ -197,9 +202,9 @@ try_to_aliases (const char **to_aliases,
- p++;
- }
- }
--
- return FALSE;
- }
-+#endif /* _GLIB_ANDROID_ */
-
- /**
- * g_iconv_open:
-@@ -220,6 +225,7 @@ GIConv
- g_iconv_open (const gchar *to_codeset,
- const gchar *from_codeset)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd;
-
- if (!try_conversion (to_codeset, from_codeset, &cd))
-@@ -248,6 +254,9 @@ g_iconv_open (const gchar *to_codeset,
-
- out:
- return (cd == (iconv_t)-1) ? (GIConv)-1 : (GIConv)cd;
-+#else
-+ return (GIConv)-1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -274,9 +283,13 @@ g_iconv (GIConv converter,
- gchar **outbuf,
- gsize *outbytes_left)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- /**
-@@ -297,9 +310,13 @@ g_iconv (GIConv converter,
- gint
- g_iconv_close (GIConv converter)
- {
-+#ifndef _GLIB_ANDROID_
- iconv_t cd = (iconv_t)converter;
-
- return iconv_close (cd);
-+#else
-+ return -1;
-+#endif /* _GLIB_ANDROID_ */
- }
-
- static GIConv
-diff -rupN glibref/glib-2.40.2/glib/gfileutils.c glibpatch/glib-2.40.2/glib/gfileutils.c
---- glibref/glib-2.40.2/glib/gfileutils.c 2015-03-31 16:25:57.170894910 +0900
-+++ glibpatch/glib-2.40.2/glib/gfileutils.c 2015-03-31 16:37:29.594919396 +0900
-@@ -54,7 +54,9 @@
-
- #ifdef HAVE_LINUX_MAGIC_H /* for btrfs check */
- #include <linux/magic.h>
-+#ifndef _GLIB_ANDROID_
- #include <sys/vfs.h>
-+#endif /* _GLIB_ANDROID_ */
- #endif
-
-
-diff -rupN glibref/glib-2.40.2/glib/ggettext.c glibpatch/glib-2.40.2/glib/ggettext.c
---- glibref/glib-2.40.2/glib/ggettext.c 2015-03-31 16:25:57.182894907 +0900
-+++ glibpatch/glib-2.40.2/glib/ggettext.c 2015-03-31 16:37:55.538920314 +0900
-@@ -40,7 +40,10 @@
-
- #include <string.h>
- #include <locale.h>
-+
-+#ifndef _GLIB_ANDROID_
- #include <libintl.h>
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef G_OS_WIN32
-
-diff -rupN glibref/glib-2.40.2/glib/glibconfig.h glibpatch/glib-2.40.2/glib/glibconfig.h
---- glibref/glib-2.40.2/glib/glibconfig.h 2015-03-31 16:25:57.166894909 +0900
-+++ glibpatch/glib-2.40.2/glib/glibconfig.h 2015-03-31 16:38:06.954920717 +0900
-@@ -154,7 +154,9 @@ typedef unsigned int guintptr;
- #define G_THREADS_ENABLED
- #define G_THREADS_IMPL_POSIX
-
-+#ifndef _GLIB_ANDROID_
- #define G_ATOMIC_LOCK_FREE
-+#endif /* _GLIB_ANDROID_ */
-
- #define GINT16_TO_LE(val) ((gint16) (val))
- #define GUINT16_TO_LE(val) ((guint16) (val))
-diff -rupN glibref/glib-2.40.2/glib/gslice.c glibpatch/glib-2.40.2/glib/gslice.c
---- glibref/glib-2.40.2/glib/gslice.c 2015-03-31 16:25:56.946894901 +0900
-+++ glibpatch/glib-2.40.2/glib/gslice.c 2015-03-31 16:38:38.302921827 +0900
-@@ -388,7 +388,9 @@ slice_config_init (SliceConfig *config)
- * This way it's possible to force gslice to be enabled under
- * valgrind just by setting G_SLICE to the empty string.
- */
-+ #ifndef _GLIB_ANDROID_
- if (RUNNING_ON_VALGRIND)
-+#endif /* _GLIB_ANDROID_ */
- config->always_malloc = TRUE;
- }
- }
-diff -rupN glibref/glib-2.40.2/glib/gstrfuncs.c glibpatch/glib-2.40.2/glib/gstrfuncs.c
---- glibref/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 16:25:56.950894901 +0900
-+++ glibpatch/glib-2.40.2/glib/gstrfuncs.c 2015-03-31 16:39:00.154922598 +0900
-@@ -309,6 +309,7 @@ static const guint16 ascii_table_data[25
-
- const guint16 * const g_ascii_table = ascii_table_data;
-
-+#ifndef _GLIB_ANDROID_
- #if defined (HAVE_NEWLOCALE) && \
- defined (HAVE_USELOCALE) && \
- defined (HAVE_STRTOD_L) && \
-@@ -316,6 +317,7 @@ const guint16 * const g_ascii_table = as
- defined (HAVE_STRTOLL_L)
- #define USE_XLOCALE 1
- #endif
-+#endif /* _GLIB_ANDROID_ */
-
- #ifdef USE_XLOCALE
- static locale_t
-diff -rupN glibref/glib-2.40.2/glib/pcre/Android.mk glibpatch/glib-2.40.2/glib/pcre/Android.mk
---- glibref/glib-2.40.2/glib/pcre/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibpatch/glib-2.40.2/glib/pcre/Android.mk 2015-01-13 08:04:00.000000000 +0900
-@@ -0,0 +1,42 @@
-+#libpcre Android Make File
-+
-+LOCAL_PATH := $(call my-dir)
-+
-+include $(CLEAR_VARS)
-+
-+LOCAL_MODULE := pcre
-+
-+LOCAL_LD_LIBS := -llog
-+
-+LOCAL_CFLAGS := \
-+ -DG_LOG_DOMAIN=\"GLib-GRegex\" \
-+ -DHAVE_CONFIG_H \
-+ -DHAVE_MEMMOVE \
-+ -DSUPPORT_UCP \
-+ -DSUPPORT_UTF \
-+ -DSUPPORT_UTF8 \
-+ -DNEWLINE=-1 \
-+ -DMATCH_LIMIT=10000000 \
-+ -DMATCH_LIMIT_RECURSION=8192 \
-+ -DMAX_NAME_SIZE=32 \
-+ -DMAX_NAME_COUNT=10000 \
-+ -DMAX_DUPLENGTH=30000 \
-+ -DLINK_SIZE=2 \
-+ -DPOSIX_MALLOC_THRESHOLD=10 \
-+ -DPCRE_STATIC \
-+ -DG_DISABLE_CAST_CHECKS \
-+ -DGLIB_COMPILATION \
-+ -D_GLIB_ANDROID_
-+
-+LOCAL_SRC_FILES := pcre_xclass.c pcre_valid_utf8.c pcre_tables.c \
-+ pcre_study.c pcre_string_utils.c pcre_ord2utf8.c \
-+ pcre_newline.c pcre_jit_compile.c pcre_globals.c \
-+ pcre_get.c pcre_fullinfo.c pcre_exec.c \
-+ pcre_dfa_exec.c pcre_config.c pcre_compile.c \
-+ pcre_chartables.c pcre_byte_order.c
-+
-+LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib
-+
-+
-+include $(BUILD_STATIC_LIBRARY)
-\ No newline at end of file
-diff -rupN glibref/glib-2.40.2/gthread/Android.mk glibpatch/glib-2.40.2/gthread/Android.mk
---- glibref/glib-2.40.2/gthread/Android.mk 1970-01-01 09:00:00.000000000 +0900
-+++ glibpatch/glib-2.40.2/gthread/Android.mk 2015-03-31 17:11:02.782990592 +0900
-@@ -0,0 +1,25 @@
-+#gthread Android Make File
-+
-+LOCAL_PATH := $(call my-dir)
-+
-+include $(CLEAR_VARS)
-+
-+LOCAL_MODULE := gthread-2.40.2
-+
-+LOCAL_SRC_FILES := gthread-impl.c
-+
-+LOCAL_C_INCLUDES := $(GLIB_MAIN_DIR) \
-+ $(GLIB_MAIN_DIR)/glib \
-+ $(GLIB_MAIN_DIR)/gthread
-+
-+
-+LOCAL_CFLAGS := \
-+ -DG_LOG_DOMAIN=\"GThread\" \
-+ -DHAVE_CONFIG_H \
-+ -DG_DISABLE_CAST_CHECKS \
-+ -DG_DISABLE_DEPRECATED \
-+ -D_GLIB_ANDROID_
-+
-+
-+LOCAL_SHARED_LIBRARIES := glib-2.40.2
-+include $(BUILD_SHARED_LIBRARY)
-\ No newline at end of file
include $(BUILD_SHARED_LIBRARY)
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-#Build glib CACommon CACoap CA
+#Build CACommon CACoap CA
include $(CLEAR_VARS)
PROJECT_ROOT_PATH = ../../..
CA_LIB_PATH = $(PROJECT_ROOT_PATH)/build/android
sample_env.PrependUnique(RPATH = [sample_env.get('BUILD_DIR'), '.',])
sample_env.PrependUnique(LIBS = ['connectivity_abstraction', 'coap',])
-sample_env.ParseConfig('pkg-config --libs glib-2.0');
-
if secured == '1':
sample_env.AppendUnique(CPPPATH = [root_dir + 'external/inc/'])
sample_env.AppendUnique(LIBS = ['tinydtls'])
INC_DIR := -I$(ROOT_DIR)/api -I$(ROOT_DIR)/inc -I$(ROOT_DIR)/common/inc
SRC_DIR := $(ROOT_DIR)/common/src/
CFLAGS = -Wall
-COMPILEFLAGS = `pkg-config --cflags glib-2.0`
-LDFLAGS = `pkg-config --libs glib-2.0`
OUT = threadpool
all:
- $(CC) $(CFLAGS) $(INC_DIR) $(COMPILEFLAGS) $(SRC_DIR)uthreadpool.c $(SRC_DIR)umutex.c $(SRC_DIR)/logger.c $(SRC_DIR)/oic_malloc.c main.c -o $(OUT) $(LDFLAGS)
+ $(CC) $(CFLAGS) $(INC_DIR) $(COMPILEFLAGS) $(SRC_DIR)cathreadpool_pthreads.c $(SRC_DIR)umutex.c $(SRC_DIR)/logger.c $(SRC_DIR)/oic_malloc.c main.c -o $(OUT) $(LDFLAGS)
clean:
rm -f $(OUT)
#include <stdio.h>
#include <stdlib.h>
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "camutex.h"
-u_thread_pool_t g_threadPoolHandle = NULL;
+ca_thread_pool_t g_threadPoolHandle = NULL;
ca_mutex g_mutex = NULL;
ca_cond g_cond = NULL;
void testThreadPool(void)
{
- char *string = "Test glib thread pool";
+ char *string = "Test thread pool";
//Initialize the mutex
printf("[testThreadPool] Initializing mutex\n");
//Initialize the thread pool
printf("[testThreadPool] Initializing thread pool\n");
- if (CA_STATUS_OK != u_thread_pool_init(2, &g_threadPoolHandle))
+ if (CA_STATUS_OK != ca_thread_pool_init(2, &g_threadPoolHandle))
{
printf("thread_pool_init failed!\n");
return;
if (NULL == g_mutex)
{
printf("[testThreadPool] Failed to create mutex!\n");
- u_thread_pool_free(g_threadPoolHandle);
+ ca_thread_pool_free(g_threadPoolHandle);
return;
}
{
printf("[testThreadPool] Failed to create condition!\n");
ca_mutex_free(g_mutex);
- u_thread_pool_free(g_threadPoolHandle);
+ ca_thread_pool_free(g_threadPoolHandle);
return;
}
g_condFlag = false;
//Add task to thread pool
printf("[testThreadPool] Adding the task to thread pool\n");
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPoolHandle, task, (void *) string))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, task, (void *) string))
{
printf("[testThreadPool] thread_pool_add_task failed!\n");
- u_thread_pool_free(g_threadPoolHandle);
+ ca_thread_pool_free(g_threadPoolHandle);
ca_mutex_unlock(g_mutex);
ca_mutex_free(g_mutex);
ca_cond_free(g_cond);
printf("[testThreadPool] Task is completed and terminating threadpool\n");
ca_cond_free(g_cond);
ca_mutex_free(g_mutex);
- u_thread_pool_free(g_threadPoolHandle);
+ ca_thread_pool_free(g_threadPoolHandle);
printf("Exiting from testThreadPool\n");
}
#include "caleserver.h"
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#include "camutex.h"
#include "uarraylist.h"
#include "caadapterutils.h"
static u_arraylist_t *g_deviceStateList = NULL;
static u_arraylist_t *g_deviceObjectList = NULL;
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
static JavaVM *g_jvm;
static jobject g_context;
return CA_STATUS_OK;
}
-void CAEDRInitialize(u_thread_pool_t handle)
+void CAEDRInitialize(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "CAEDRInitialize");
g_deviceObjectList->length--;
}
-void CAEDRInitializeClient(u_thread_pool_t handle)
+void CAEDRInitializeClient(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
CAEDRInitialize(handle);
#include "caedrinterface.h"
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#include "camutex.h"
#include "uarraylist.h"
#include "caadapterutils.h"
#include "caedrserver.h"
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#include "camutex.h"
#include "uarraylist.h"
#include "caadapterutils.h"
static u_arraylist_t *g_deviceStateList = NULL;
static u_arraylist_t *g_deviceObjectList = NULL;
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
static JavaVM *g_jvm;
// adapter common method
-CAResult_t CAEDRServerStart(const char *serviceUUID, int32_t *serverFD, u_thread_pool_t handle)
+CAResult_t CAEDRServerStart(const char *serviceUUID, int32_t *serverFD, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
CAEDRServerInitialize(handle);
g_jvm = jvm;
}
-void CAEDRServerInitialize(u_thread_pool_t handle)
+void CAEDRServerInitialize(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "CAEDRServerInitialize");
}
ctx->stopFlag = &g_stopAccept;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPoolHandle, CAAcceptHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAAcceptHandler, (void *)ctx))
{
OIC_LOG(ERROR, TAG, "Failed to create read thread!");
OICFree((void *)ctx);
ctx->stopFlag = &g_stopUnicast;
ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, TAG, "Failed to create read thread!");
ca_mutex_unlock(g_mutexUnicastServer);
ctx->type = CA_MULTICAST_SERVER;
g_stopMulticast = false;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, TAG, "thread_pool_add_task failed!");
#include "caedrutils.h"
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#define ERROR_CODE (-1)
* @var g_edrThreadPool
* @brief Reference to threadpool.
*/
-static u_thread_pool_t g_edrThreadPool = NULL;
+static ca_thread_pool_t g_edrThreadPool = NULL;
/**
* @var g_sendQueueHandle
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback packetReceivedCallback,
CANetworkChangeCallback networkStateChangeCallback,
- u_thread_pool_t handle)
+ ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
// Setting g_serverState for starting Rfcommserver when adapter starts
- g_serverState = TRUE;
+ g_serverState = true;
return CA_STATUS_OK;
}
CAEDRNetworkEvent *event = CAEDRCreateNetworkEvent(g_localConnectivity, status);
if (NULL != event)
{
- if (CA_STATUS_OK != u_thread_pool_add_task(g_edrThreadPool, CAEDROnNetworkStatusChanged,
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool, CAEDROnNetworkStatusChanged,
event))
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create threadpool!");
#define TAG PCF("CA")
static CANetworkPacketReceivedCallback g_edrReceivedCallback = NULL;
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback,
- u_thread_pool_t handle)
+ ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "CAInitializeEDR");
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
-void CAEDRInitializeClient(u_thread_pool_t handle)
+void CAEDRInitializeClient(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
CAEDRManagerInitializeMutex();
static int32_t g_maxPendingConnections = 10;
-CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, u_thread_pool_t handle)
+CAResult_t CAEDRServerStart(const char *serviceUUID, int *serverFD, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
- CANetworkChangeCallback netCallback, u_thread_pool_t handle)
+ CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IntializeBLE");
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#include "camutex.h"
#include "uarraylist.h"
#include "com_iotivity_jar_caleinterface.h"
static u_arraylist_t *g_deviceList = NULL;
static u_arraylist_t *g_gattObjectList = NULL;
static CAPacketReceiveCallback g_packetReceiveCallback = NULL;
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
static jobject g_leScanCallback;
static jobject g_leGattCallback;
static jobject g_context;
return;
}
-void CALEInitialize(u_thread_pool_t handle)
+void CALEInitialize(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "CALEInitialize");
#include "caleutils.h"
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#include "com_iotivity_jar_caleinterface.h"
static CAPacketReceiveCallback g_packetReceiveCallback = NULL;
static u_arraylist_t *g_connectedDeviceList = NULL;
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
static jboolean g_isStartServer;
static jboolean g_isSendingMulticastData;
}
}
-void CALEServerInitialize(u_thread_pool_t handle)
+void CALEServerInitialize(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "CALEServerInitialize");
#include "caleutils.h"
#include "logger.h"
#include "oic_malloc.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "uarraylist.h"
#define TAG PCF("CA_LE_UTILS")
* @var gBleClientThreadPool
* @brief reference to threadpool
*/
-static u_thread_pool_t g_bleAdapterThreadPool = NULL;
+static ca_thread_pool_t g_bleAdapterThreadPool = NULL;
/**
* @var g_bleAdapterThreadPoolMutex
* @return void
*
*/
-void CASetBleAdapterThreadPoolHandle(u_thread_pool_t handle);
+void CASetBleAdapterThreadPoolHandle(ca_thread_pool_t handle);
/**
* @fn CALEDeviceStateChangedCb
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
CANetworkChangeCallback netCallback,
- u_thread_pool_t handle)
+ ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
if (CA_STATUS_OK != CAQueueingThreadStart(g_sendQueueHandle))
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "u_thread_pool_add_task failed ");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_thread_pool_add_task failed ");
OICFree(g_sendQueueHandle);
g_sendQueueHandle = NULL;
return CA_STATUS_FAILED;
if (CA_STATUS_OK != CAQueueingThreadStart(g_bLEClientSendQueueHandle))
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "u_thread_pool_add_task failed ");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_thread_pool_add_task failed ");
OICFree(g_bLEClientSendQueueHandle);
g_bLEClientSendQueueHandle = NULL;
return CA_STATUS_FAILED;
if (CA_STATUS_OK != CAQueueingThreadStart(g_bleServerReceiverQueue))
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "u_thread_pool_add_task failed ");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_thread_pool_add_task failed ");
OICFree(g_bleServerReceiverQueue);
g_bleServerReceiverQueue = NULL;
return CA_STATUS_FAILED;
}
if (CA_STATUS_OK != CAQueueingThreadStart(g_bleClientReceiverQueue))
{
- OIC_LOG(ERROR, CALEADAPTER_TAG, "u_thread_pool_add_task failed ");
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "ca_thread_pool_add_task failed ");
OICFree(g_bleClientReceiverQueue);
g_bleClientReceiverQueue = NULL;
return CA_STATUS_FAILED;
return CA_STATUS_OK;
}
-void CASetBleAdapterThreadPoolHandle(u_thread_pool_t handle)
+void CASetBleAdapterThreadPoolHandle(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
#define TAG PCF("CA")
static CANetworkPacketReceivedCallback g_leReceivedCallback = NULL;
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback, CANetworkChangeCallback netCallback,
- u_thread_pool_t handle)
+ ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "CAInitializeLE");
* @var g_bleClientThreadPool
* @brief reference to threadpool
*/
-static u_thread_pool_t g_bleClientThreadPool = NULL;
+static ca_thread_pool_t g_bleClientThreadPool = NULL;
/**
* @struct stGattServiceInfo_t
return;
}
- CAResult_t ret = u_thread_pool_add_task(g_bleClientThreadPool,
+ CAResult_t ret = ca_thread_pool_add_task(g_bleClientThreadPool,
CASetCharacteristicDescriptorValueThread,
stTemp);
if (CA_STATUS_OK != ret)
{
- OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "u_thread_pool_add_task failed");
+ OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "ca_thread_pool_add_task failed");
bt_gatt_destroy_attribute_handle(stTemp->characteristic);
OICFree(stTemp->desc);
OICFree(stTemp);
return false;
}
- retVal = u_thread_pool_add_task(g_bleClientThreadPool,
+ retVal = ca_thread_pool_add_task(g_bleClientThreadPool,
CADiscoverDescriptorThread,
stTemp);
if (CA_STATUS_OK != retVal)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
- "u_thread_pool_add_task failed with ret [%d]", retVal);
+ "ca_thread_pool_add_task failed with ret [%d]", retVal);
bt_gatt_destroy_attribute_handle(stTemp->serviceInfo);
OICFree(stTemp->address);
OICFree(stTemp);
return;
}
- CAResult_t ret = u_thread_pool_add_task(g_bleClientThreadPool,
+ CAResult_t ret = ca_thread_pool_add_task(g_bleClientThreadPool,
CADiscoverCharThread, stTemp);
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
- "u_thread_pool_add_task failed with ret [%d]", ret);
+ "ca_thread_pool_add_task failed with ret [%d]", ret);
bt_gatt_destroy_attribute_handle(stTemp->serviceInfo);
OICFree(stTemp->address);
OICFree(stTemp);
return false;
}
- result = u_thread_pool_add_task(g_bleClientThreadPool,
+ result = ca_thread_pool_add_task(g_bleClientThreadPool,
CAGATTCreateBondThread,
stTemp);
if (CA_STATUS_OK != result)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
- "u_thread_pool_add_task failed with ret [%d]", result);
+ "ca_thread_pool_add_task failed with ret [%d]", result);
OICFree(stTemp->address);
OICFree(stTemp);
ca_mutex_lock(g_bleServiceListMutex);
return;
}
- ret = u_thread_pool_add_task(g_bleClientThreadPool, CADiscoverBLEServicesThread,
+ ret = ca_thread_pool_add_task(g_bleClientThreadPool, CADiscoverBLEServicesThread,
addr);
if (CA_STATUS_OK != ret)
{
- OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG, "u_thread_pool_add_task failed with ret [%d]", ret);
+ OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG, "ca_thread_pool_add_task failed with ret [%d]", ret);
OICFree(addr);
ca_mutex_lock(g_bleServerBDAddressMutex);
return;
}
- CAResult_t ret = u_thread_pool_add_task(g_bleClientThreadPool,
+ CAResult_t ret = ca_thread_pool_add_task(g_bleClientThreadPool,
CAGattConnectThread, addr);
if (CA_STATUS_OK != ret)
{
OIC_LOG_V(ERROR, TZ_BLE_CLIENT_TAG,
- "u_thread_pool_add_task failed with ret [%d]", ret);
+ "ca_thread_pool_add_task failed with ret [%d]", ret);
OICFree(addr);
ca_mutex_unlock(g_bleClientThreadPoolMutex);
return;
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "OUT");
}
-void CASetBleClientThreadPoolHandle(u_thread_pool_t handle)
+void CASetBleClientThreadPoolHandle(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TZ_BLE_CLIENT_TAG, "IN");
return CA_STATUS_FAILED;
}
- retVal = u_thread_pool_add_task(g_bleClientThreadPool, CAStartBleGattClientThread,
+ retVal = ca_thread_pool_add_task(g_bleClientThreadPool, CAStartBleGattClientThread,
NULL);
if (CA_STATUS_OK != retVal)
{
- OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "u_thread_pool_add_task failed");
+ OIC_LOG(ERROR, TZ_BLE_CLIENT_TAG, "ca_thread_pool_add_task failed");
CATerminateGattClientMutexVariables();
ca_mutex_unlock(g_bleClientThreadPoolMutex);
return CA_STATUS_FAILED;
#include "cableutil.h"
#include "caadapterinterface.h"
#include "logger.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "caleinterface.h"
#include "oic_malloc.h"
* @var g_bleServerThreadPool
* @brief reference to threadpool
*/
-static u_thread_pool_t g_bleServerThreadPool = NULL;
+static ca_thread_pool_t g_bleServerThreadPool = NULL;
void CABleGattServerConnectionStateChangedCb(int result, bool connected,
const char *remoteAddress, void *userData)
return CA_STATUS_FAILED;
}
- ret = u_thread_pool_add_task(g_bleServerThreadPool, CAStartBleGattServerThread,
+ ret = ca_thread_pool_add_task(g_bleServerThreadPool, CAStartBleGattServerThread,
NULL);
if (CA_STATUS_OK != ret)
{
- OIC_LOG_V(ERROR, TZ_BLE_SERVER_TAG, "u_thread_pool_add_task failed with ret [%d]", ret);
+ OIC_LOG_V(ERROR, TZ_BLE_SERVER_TAG, "ca_thread_pool_add_task failed with ret [%d]", ret);
ca_mutex_unlock(g_bleServerThreadPoolMutex);
return CA_STATUS_FAILED;
}
return CA_STATUS_OK;
}
-void CASetBleServerThreadPoolHandle(u_thread_pool_t handle)
+void CASetBleServerThreadPoolHandle(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TZ_BLE_SERVER_TAG, "IN");
ca_mutex_lock(g_bleServerThreadPoolMutex);
#include "caadapterinterface.h"
#include "logger.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#include "caleinterface.h"
/**
#include "caremotehandler.h"
#include "oic_malloc.h"
#include "logger.h"
-#include "uthreadpool.h"
+#include "cathreadpool.h"
#define TAG PCF("CA")
}
}
-void CAInitializeAdapters(u_thread_pool_t handle)
+void CAInitializeAdapters(ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "initialize adapters..");
#include "uqueue.h"
#include "logger.h"
#include "config.h" /* for coap protocol */
-#include "uthreadpool.h" /* for thread pool */
+#include "cathreadpool.h" /* for thread pool */
#include "caqueueingthread.h"
#include "camutex.h"
#include "oic_malloc.h"
} CAData_t;
// thread pool handle
-static u_thread_pool_t g_threadPoolHandle = NULL;
+static ca_thread_pool_t g_threadPoolHandle = NULL;
// message handler main thread
static CAQueueingThread_t g_sendThread;
CASetNetworkChangeCallback(CANetworkChangedCallback);
// create thread pool
- CAResult_t res = u_thread_pool_init(MAX_THREAD_POOL_SIZE, &g_threadPoolHandle);
+ CAResult_t res = ca_thread_pool_init(MAX_THREAD_POOL_SIZE, &g_threadPoolHandle);
if (res != CA_STATUS_OK)
{
if (res != CA_STATUS_OK)
{
OIC_LOG(ERROR, TAG, "thread start error(send thread).");
- u_thread_pool_free(g_threadPoolHandle);
+ ca_thread_pool_free(g_threadPoolHandle);
g_threadPoolHandle = NULL;
return res;
}
// destroy thread pool
if (NULL != g_threadPoolHandle)
{
- u_thread_pool_free(g_threadPoolHandle);
+ ca_thread_pool_free(g_threadPoolHandle);
g_threadPoolHandle = NULL;
}
OIC_LOG(DEBUG, TAG, "message handler main thread end..");
}
-CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, u_thread_pool_t handle,
+CAResult_t CAQueueingThreadInitialize(CAQueueingThread_t *thread, ca_thread_pool_t handle,
CAThreadTask task, CADataDestroyFunction destroy)
{
if (NULL == thread)
// mutex unlock
ca_mutex_unlock(thread->threadMutex);
- CAResult_t res = u_thread_pool_add_task(thread->threadPool, CAQueueingThreadBaseRoutine,
+ CAResult_t res = ca_thread_pool_add_task(thread->threadPool, CAQueueingThreadBaseRoutine,
thread);
if (res != CA_STATUS_OK)
{
RETRANSMISSION_CHECK_PERIOD_SEC * (uint64_t) USECS_PER_SEC);
// wait
- uint64_t absTime=getCurrentTimeInMicroSeconds();
- absTime += RETRANSMISSION_CHECK_PERIOD_SEC * (uint64_t) USECS_PER_SEC;
- ca_cond_wait_until(context->threadCond, context->threadMutex, absTime );
+ uint64_t absTime = RETRANSMISSION_CHECK_PERIOD_SEC * (uint64_t) USECS_PER_SEC;
+ ca_cond_wait_for(context->threadCond, context->threadMutex, absTime );
}
// mutex unlock
}
-CAResult_t CARetransmissionInitialize(CARetransmission_t *context, u_thread_pool_t handle,
+CAResult_t CARetransmissionInitialize(CARetransmission_t *context, ca_thread_pool_t handle,
CADataSendMethod_t retransmissionSendMethod,
CATimeoutCallback_t timeoutCallback,
CARetransmissionConfig_t* config)
return CA_STATUS_INVALID_PARAM;
}
- CAResult_t res = u_thread_pool_add_task(context->threadPool, CARetransmissionBaseRoutine,
+ CAResult_t res = ca_thread_pool_add_task(context->threadPool, CARetransmissionBaseRoutine,
context);
if (CA_STATUS_OK != res)
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from CA
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from CA
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
static CAResult_t CAEthernetInitializeQueueHandles();
static void CAEthernetDeinitializeQueueHandles();
CAResult_t CAInitializeEthernet(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback, u_thread_pool_t handle)
+ CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, ETHERNET_ADAPTER_TAG, "IN");
VERIFY_NON_NULL(registerCallback, ETHERNET_ADAPTER_TAG, "registerCallback");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_stopNetworkMonitor
static void CANetworkMonitorThread(void *threadData);
-CAResult_t CAEthernetInitializeNetworkMonitor(const u_thread_pool_t threadPool)
+CAResult_t CAEthernetInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, ETHERNET_MONITOR_TAG, "IN");
return CA_STATUS_FAILED;
}
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, (void *) CANetworkMonitorThread,
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, (void *) CANetworkMonitorThread,
(void *)NULL))
{
OIC_LOG(ERROR, ETHERNET_MONITOR_TAG, "[ThreadPool] thread_pool_add_task failed!");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_multicastServerInterface
ctx->stopFd = pipefd[PIPE_READ_FD]; // The read end of the pipe
ctx->socket_fd = *serverFD;
ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, ETHERNET_SERVER_TAG, "Failed to create read thread!");
return CA_STATUS_OK;
}
-CAResult_t CAEthernetInitializeServer(const u_thread_pool_t threadPool)
+CAResult_t CAEthernetInitializeServer(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, ETHERNET_SERVER_TAG, "IN");
ctx->type = CA_MULTICAST_SERVER;
g_stopMulticast = false;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, ETHERNET_SERVER_TAG, "thread_pool_add_task failed!");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_stopNetworkMonitor
*/
void CASendNetworkChangeCallback(CANetworkStatus_t currNetworkStatus);
-CAResult_t CAWiFiInitializeNetworkMonitor(const u_thread_pool_t threadPool)
+CAResult_t CAWiFiInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, WIFI_MONITOR_TAG, "IN");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_multicastServerInterface
ctx->stopFlag = &g_stopUnicast;
ctx->socket_fd = *serverFD;
ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, WIFI_SERVER_TAG, "Failed to create read thread!");
OICFree(ctx);
return CA_STATUS_OK;
}
-CAResult_t CAWiFiInitializeServer(const u_thread_pool_t threadPool)
+CAResult_t CAWiFiInitializeServer(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, WIFI_SERVER_TAG, "IN");
ctx->type = CA_MULTICAST_SERVER;
g_stopMulticast = false;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, WIFI_SERVER_TAG, "thread_pool_add_task failed!");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from CA
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from CA
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
static CAResult_t CAWiFiInitializeQueueHandles();
static void CAWiFiDeinitializeQueueHandles();
CAResult_t CAInitializeWIFI(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback, u_thread_pool_t handle)
+ CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, WIFI_ADAPTER_TAG, "IN");
VERIFY_NON_NULL(registerCallback, WIFI_ADAPTER_TAG, "registerCallback");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_stopNetworkMonitor
static void CANetworkMonitorThread(void *threadData);
-CAResult_t CAWiFiInitializeNetworkMonitor(const u_thread_pool_t threadPool)
+CAResult_t CAWiFiInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, WIFI_MONITOR_TAG, "IN");
return CA_STATUS_FAILED;
}
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CANetworkMonitorThread,
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CANetworkMonitorThread,
NULL))
{
OIC_LOG(ERROR, WIFI_MONITOR_TAG, "[ThreadPool] thread_pool_add_task failed!");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_multicastServerInterface
ctx->stopFd = pipefd[PIPE_READ_FD]; // The read end of the pipe
ctx->socket_fd = *serverFD;
ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *) ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *) ctx))
{
OIC_LOG(ERROR, WIFI_SERVER_TAG, "Failed to create read thread!");
return CA_STATUS_OK;
}
-CAResult_t CAWiFiInitializeServer(const u_thread_pool_t threadPool)
+CAResult_t CAWiFiInitializeServer(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, WIFI_SERVER_TAG, "IN");
ctx->type = CA_MULTICAST_SERVER;
g_stopMulticast = false;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *) ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *) ctx))
{
OIC_LOG(ERROR, WIFI_SERVER_TAG, "thread_pool_add_task failed!");
static void CAWiFiGetInterfaceInformation(char **interfaceName, char **ipAddress,
char **subnetMask);
-CAResult_t CAWiFiInitializeNetworkMonitor(const u_thread_pool_t threadPool)
+CAResult_t CAWiFiInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, WIFI_MONITOR_TAG, "IN");
/**
* @var g_threadPool
- * @brief ThreadPool for storing u_thread_pool_t handle passed from adapter
+ * @brief ThreadPool for storing ca_thread_pool_t handle passed from adapter
*/
-static u_thread_pool_t g_threadPool = NULL;
+static ca_thread_pool_t g_threadPool = NULL;
/**
* @var g_multicastServerInterface
ctx->stopFlag = &g_stopUnicast;
ctx->socket_fd = *serverFD;
ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, WIFI_SERVER_TAG, "Failed to create read thread!");
OICFree(ctx);
return CA_STATUS_OK;
}
-CAResult_t CAWiFiInitializeServer(const u_thread_pool_t threadPool)
+CAResult_t CAWiFiInitializeServer(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, WIFI_SERVER_TAG, "IN");
ctx->type = CA_MULTICAST_SERVER;
g_stopMulticast = false;
- if (CA_STATUS_OK != u_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, (void *)ctx))
{
OIC_LOG(ERROR, WIFI_SERVER_TAG, "thread_pool_add_task failed!");
'gtest_main'])
target_os = env.get('TARGET_OS')
+
+if target_os not in ['arduino', 'darwin', 'ios']:
+ catest_env.AppendUnique(LIBS=['rt'])
+
if target_os != 'darwin':
catest_env.PrependUnique(LIBS = ['oc_logger'])
if env.get('SECURED') == '1':
catest_env.AppendUnique(LIBS = ['tinydtls'])
-catest_env.ParseConfig('pkg-config --libs glib-2.0');
if env.get('LOGGING'):
catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
#include "gtest/gtest.h"
#include <camutex.h>
-#include <uthreadpool.h>
+#include <cathreadpool.h>
#include <time.h>
#include <sys/time.h>
TEST(MutexTests, TC_03_THREAD_LOCKING)
{
- u_thread_pool_t mythreadpool;
+ ca_thread_pool_t mythreadpool;
- EXPECT_EQ(CA_STATUS_OK, u_thread_pool_init(3, &mythreadpool));
+ EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
_func1_struct pData = {};
DBG_printf("test: starting thread\n");
//start thread
EXPECT_EQ(CA_STATUS_OK,
- u_thread_pool_add_task(mythreadpool, mutexFunc, &pData));
+ ca_thread_pool_add_task(mythreadpool, mutexFunc, &pData));
DBG_printf("test: waiting for thread to be up.\n");
ca_mutex_free(pData.mutex);
}
- u_thread_pool_free(mythreadpool);
+ ca_thread_pool_free(mythreadpool);
}
TEST(ConditionTests, TC_01_CREATE)
TEST(ConditionTests, TC_02_SIGNAL)
{
const int MAX_WAIT_MS = 2000;
- u_thread_pool_t mythreadpool;
+ ca_thread_pool_t mythreadpool;
- EXPECT_EQ(CA_STATUS_OK, u_thread_pool_init(3, &mythreadpool));
+ EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
ca_mutex sharedMutex = ca_mutex_new();
ca_cond sharedCond = ca_cond_new();
if (pData1.mutex != NULL)
{
DBG_printf("starting thread\n");
- //start thread
+ // start threads
+ EXPECT_EQ(CA_STATUS_OK,
+ ca_thread_pool_add_task(mythreadpool, condFunc, &pData1));
EXPECT_EQ(CA_STATUS_OK,
- u_thread_pool_add_task(mythreadpool, condFunc, &pData1));
+ ca_thread_pool_add_task(mythreadpool, condFunc, &pData2));
//start thread
EXPECT_EQ(CA_STATUS_OK,
- u_thread_pool_add_task(mythreadpool, condFunc, &pData2));
+ ca_thread_pool_add_task(mythreadpool, condFunc, &pData2));
DBG_printf("test : sleeping\n");
ca_cond_free(pData1.condition);
- u_thread_pool_free(mythreadpool);
+ ca_thread_pool_free(mythreadpool);
}
TEST(ConditionTests, TC_03_BROADCAST)
{
const int MAX_WAIT_MS = 2000;
- u_thread_pool_t mythreadpool;
+ ca_thread_pool_t mythreadpool;
- EXPECT_EQ(CA_STATUS_OK, u_thread_pool_init(3, &mythreadpool));
+ EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
ca_mutex sharedMutex = ca_mutex_new();
ca_cond sharedCond = ca_cond_new();
if (pData1.mutex != NULL)
{
DBG_printf("starting thread\n");
- //start thread
+ // start threads
EXPECT_EQ(CA_STATUS_OK,
- u_thread_pool_add_task(mythreadpool, condFunc, &pData1));
+ ca_thread_pool_add_task(mythreadpool, condFunc, &pData1));
+ EXPECT_EQ(CA_STATUS_OK,
+ ca_thread_pool_add_task(mythreadpool, condFunc, &pData2));
//start thread
EXPECT_EQ(CA_STATUS_OK,
- u_thread_pool_add_task(mythreadpool, condFunc, &pData2));
+ ca_thread_pool_add_task(mythreadpool, condFunc, &pData2));
DBG_printf("test : sleeping\n");
ca_cond_free(sharedCond);
- u_thread_pool_free(mythreadpool);
+ ca_thread_pool_free(mythreadpool);
}
TEST(CondTests, TC_04_TIMECHECK)
ca_mutex_lock(pData->mutex);
- uint64_t abs = getAbsTime();
- abs += USECS_PER_SEC / 2; // 1/2 second
+ uint64_t abs = USECS_PER_SEC / 2; // 1/2 seconds
// test UTIMEDOUT
- CAWaitResult_t ret = ca_cond_wait_until(pData->condition,
- pData->mutex, abs);
+ CAWaitResult_t ret = ca_cond_wait_for(pData->condition,
+ pData->mutex, abs);
EXPECT_EQ(CA_WAIT_TIMEDOUT, ret);
pData->thread_up = true;
DBG_printf("Thread_%d: waiting for signal \n", pData->id);
- abs = getAbsTime();
- abs += 5 * USECS_PER_SEC; // 5 seconds
+ abs = 5 * USECS_PER_SEC; // 5 seconds
// test signal
- ret = ca_cond_wait_until(pData->condition, pData->mutex, abs);
+ ret = ca_cond_wait_for(pData->condition, pData->mutex, abs);
EXPECT_EQ(CA_WAIT_SUCCESS, ret);
pData->finished = true; // assignment guarded by lock
TEST(ConditionTests, TC_05_WAIT)
{
const int MAX_WAIT_MS = 5000;
- u_thread_pool_t mythreadpool;
+ ca_thread_pool_t mythreadpool;
- EXPECT_EQ(CA_STATUS_OK, u_thread_pool_init(3, &mythreadpool));
+ EXPECT_EQ(CA_STATUS_OK, ca_thread_pool_init(3, &mythreadpool));
ca_mutex sharedMutex = ca_mutex_new();
ca_cond sharedCond = ca_cond_new();
DBG_printf("test : starting thread\n");
//start thread
EXPECT_EQ(CA_STATUS_OK,
- u_thread_pool_add_task(mythreadpool, timedFunc, &pData1));
+ ca_thread_pool_add_task(mythreadpool, timedFunc, &pData1));
DBG_printf("test : waiting for thread to timeout once.\n");
ca_cond_free(sharedCond);
- u_thread_pool_free(mythreadpool);
- }
+ ca_thread_pool_free(mythreadpool);
+}
-TEST(ConditionTests, TC_06_INVALIDWAIT)
+// Disabled because this should no longer be a valid test
+TEST(ConditionTests, DISABLED_TC_06_INVALIDWAIT)
{
ca_mutex sharedMutex = ca_mutex_new();
ca_mutex_lock(sharedMutex);
- int ret = ca_cond_wait_until(NULL, sharedMutex, 5000);
+ int ret = ca_cond_wait_for(NULL, sharedMutex, 5000);
EXPECT_EQ(CA_WAIT_INVAL,ret);
- ret = ca_cond_wait_until(sharedCond, NULL, 5000);
+ ret = ca_cond_wait_for(sharedCond, NULL, 5000);
EXPECT_EQ(CA_WAIT_INVAL,ret);
- ret = ca_cond_wait_until(NULL, NULL, 5000);
+ ret = ca_cond_wait_for(NULL, NULL, 5000);
EXPECT_EQ(CA_WAIT_INVAL,ret);
ca_mutex_unlock(sharedMutex);
ca_mutex_lock(sharedMutex);
- uint64_t abs = getAbsTime();
- uint64_t beg = abs;
- abs += TARGET_WAIT * USECS_PER_SEC;
+ uint64_t beg = getAbsTime();
- CAWaitResult_t ret = ca_cond_wait_until(sharedCond, sharedMutex, abs);
+ CAWaitResult_t ret = ca_cond_wait_for(sharedCond, sharedMutex,
+ TARGET_WAIT * USECS_PER_SEC);
EXPECT_EQ(CA_WAIT_TIMEDOUT,ret);
uint64_t end = getAbsTime();
if target_os in ['darwin', 'ios']:
samples_env.PrependUnique(LIBS = ['m','octbstack', 'connectivity_abstraction','coap' ])
-else:
+elif target_os not in ['arduino']:
samples_env.PrependUnique(LIBS = ['m', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
+ samples_env.AppendUnique(LIBS = ['rt'])
if env.get('SECURED') == '1':
samples_env.AppendUnique(LIBS = ['tinydtls'])
-samples_env.ParseConfig('pkg-config --libs glib-2.0');
samples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
samples_env.Append(LINKFLAGS = ['-Wl,--no-as-needed'])
-samples_env.ParseConfig('pkg-config --libs glib-2.0');
-
if target_os == 'android':
samples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
samples_env.AppendUnique(LIBS = ['gnustl_static'])
if env.get('SECURED') == '1':
stacktest_env.AppendUnique(LIBS = ['tinydtls'])
-stacktest_env.ParseConfig('pkg-config --libs glib-2.0');
if env.get('LOGGING'):
stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
@paragraph caf_ovr_comm_netinterface_control Interface controller
-This directly controls the individual adapters. Calling CAInitializeAdapters(u_thread_pool_t handle)
+This directly controls the individual adapters. Calling CAInitializeAdapters(ca_thread_pool_t handle)
will invoke whatever config had been established by compile-time flags.
@paragraph caf_ovr_comm_netinterface_eth Ethernet Adapter
@dotfile ca_arch.gv
-*/
\ No newline at end of file
+*/
label = <<table border="1" cellspacing="0" cellborder="0">
<tr><td port="a" tooltip="Message Handler" bgcolor="gray">Message Handler</td></tr>
<hr/>
- <tr><td align="left" href="\ref g_threadPoolHandle" tooltip="-g_threadPoolHandle: u_thread_pool_t">-g_threadPoolHandle: u_thread_pool_t</td></tr>
+ <tr><td align="left" href="\ref g_threadPoolHandle" tooltip="-g_threadPoolHandle: ca_thread_pool_t">-g_threadPoolHandle: ca_thread_pool_t</td></tr>
<tr><td align="left" href="\ref g_sendThread" tooltip="-g_sendThread: CAQueueingThread_t">-g_sendThread: CAQueueingThread_t</td></tr>
<tr><td align="left" href="\ref g_receiveThread" tooltip="-g_receiveThread: CAQueueingThread_t">-g_receiveThread: CAQueueingThread_t</td></tr>
<tr><td align="left" href="\ref g_retransmissionContext" tooltip="-g_retransmissionContext: CARetransmission_t">-g_retransmissionContext: CARetransmission_t</td></tr>
threadpool [
shape = none
- margin = 0
+ margin = 0
label = <<table border="1" cellspacing="0" cellborder="0">
- <tr><td href="\ref u_thread_pool_t" tooltip="u_threadpool_t" bgcolor="gray">u_threadpool_t</td></tr>
+ <tr><td href="\ref ca_thread_pool_t" tooltip="ca_threadpool_t" bgcolor="gray">ca_threadpool_t</td></tr>
<hr/>
<tr><td> </td></tr>
<hr/>
- <tr><td align="left" href="\ref u_thread_pool_init()" tooltip="+u_thread_pool_init">+u_thread_pool_init</td></tr>
- <tr><td align="left" href="\ref u_thread_pool_free()" tooltip="+u_thread_pool_free">+u_thread_pool_free</td></tr>
- <tr><td align="left" href="\ref u_thread_pool_add_task()" tooltip="+u_thread_pool_add_task">+u_thread_pool_add_task</td></tr>
+ <tr><td align="left" href="\ref ca_thread_pool_init()" tooltip="+ca_thread_pool_init">+ca_thread_pool_init</td></tr>
+ <tr><td align="left" href="\ref ca_thread_pool_free()" tooltip="+ca_thread_pool_free">+ca_thread_pool_free</td></tr>
+ <tr><td align="left" href="\ref ca_thread_pool_add_task()" tooltip="+ca_thread_pool_add_task">+ca_thread_pool_add_task</td></tr>
</table>>
]
thread_out [
shape = none
- margin = 0
+ margin = 0
label = <<table border="1" cellspacing="0" cellborder="0">
<tr><td href="\ref CASendThreadProcess()" tooltip="Send Thread" bgcolor="gray">Send Thread</td></tr>
<hr/>
thread_in [
shape = none
- margin = 0
+ margin = 0
label = <<table border="1" cellspacing="0" cellborder="0">
<tr><td href="\ref CAReceiveThreadProcess()" tooltip="Receive Thread" bgcolor="gray">Receive Thread</td></tr>
<hr/>
thread_retrans [
shape = none
- margin = 0
+ margin = 0
label = <<table border="1" cellspacing="0" cellborder="0">
<tr><td href="\ref CASendUnicastData()" tooltip="Retransmit Thread" bgcolor="gray">Retransmit Thread</td></tr>
<hr/>
shape = none
- margin = 0
+ margin = 0
label = <<table border="1" cellspacing="0" cellborder="0">
<tr><td href="\ref CAInitializeAdapters()" tooltip="Interface Controller" bgcolor="gray">Interface Controller</td></tr>
<hr/>
conn_handler [
shape = none
- margin = 0
+ margin = 0
label = <<table border="1" cellspacing="0" cellborder="0">
<tr><td href="\ref CAConnectivityHandler_t" tooltip="CAConnectivityHandler_t" bgcolor="gray">CAConnectivityHandler_t</td></tr>
<hr/>
if env.get('SECURED') == '1':
examples_env.AppendUnique(LIBS = ['tinydtls'])
-examples_env.ParseConfig('pkg-config --libs glib-2.0');
-
if target_os == 'android':
examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
examples_env.AppendUnique(LIBS = ['gnustl_static'])
conf = Configure(lib_env)
- if not conf.CheckLib('glib-2.0'):
- print 'Install glib-2 on ubuntu with the following command'
- print 'sudo apt-get install libglib2.0-dev'
+ if target_os in ['tizen'] and not conf.CheckLib('glib-2.0'):
+ print 'Install glib-2.0 to compile on Tizen platforms'
Exit(1)
conf.Finish()
src_dir = env.get('SRC_DIR')
build_dir = env.get('BUILD_DIR')
-
if target_os == 'linux':
# Verify that 'google unit test' library is installed. If not,
# get it and install it
if env.get('SECURED') == '1':
unittests_env.AppendUnique(LIBS = ['tinydtls'])
-unittests_env.ParseConfig('pkg-config --libs glib-2.0');
if env.get('LOGGING'):
unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
if env.get('SECURED') == '1':
notimgr_env.AppendUnique(LIBS = ['tinydtls'])
-notimgr_env.ParseConfig('pkg-config --libs glib-2.0')
-notimgr_env.ParseConfig('pkg-config --cflags glib-2.0')
+ notimgr_c_env.AppendUnique(LIBS = ['tinydtls'])
if 'rt' in notimgr_env.get('LIBS'):
notimgr_env.Append(LIBS = ['rt'])
-
-if env.get('SECURED') == '1':
- notimgr_c_env.AppendUnique(LIBS = ['tinydtls'])
-notimgr_c_env.ParseConfig('pkg-config --libs glib-2.0')
-notimgr_c_env.ParseConfig('pkg-config --cflags glib-2.0')
if 'rt' in notimgr_c_env.get('LIBS'):
notimgr_c_env.Append(LIBS = ['rt'])
if env.get('SECURED') == '1':
sample_env.AppendUnique(LIBS = ['tinydtls'])
-sample_env.ParseConfig('pkg-config --libs glib-2.0')
-
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
if 'rt' in sample_env.get('LIBS'):
ssmcore_env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger',
'connectivity_abstraction', 'coap'])
-if target_os not in ['android']:
+if target_os in ['tizen']:
ssmcore_env.ParseConfig('pkg-config --libs glib-2.0');
shared_libssmcore = ssmcore_env.SharedLibrary(
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
-
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
if 'rt' in linux_sample_env.get('LIBS'):
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
-
+#
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
if 'rt' in linux_sample_env.get('LIBS'):
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
'libcoap', 'liboc_logger', 'dl', 'pthread'])
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
'libcoap', 'liboc_logger', 'dl', 'pthread'])
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.
'libcoap', 'liboc_logger', 'dl', 'pthread'])
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
-linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
-
# On some platforms link order can miss functions so librt needs to be
# re-scanned at the end if present. gcc 4.6 is one with this issue.