diff --git a/cmake/define.inc b/cmake/define.inc index 0a6e70f3750355b2391eeca979f24a0d1b7be314..a63b9f1732a8c404a1b701899fae4b8588e8f7ca 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -77,6 +77,11 @@ IF (TD_LINUX) ADD_DEFINITIONS(-D_LINUX) ADD_DEFINITIONS(-D_TD_LINUX) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) + + IF (TD_NINGSI_60) + ADD_DEFINITIONS(-D_TD_NINGSI_60_) + MESSAGE(STATUS "set ningsi macro to true") + ENDIF () SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(RELEASE_FLAGS "-O0") diff --git a/cmake/platform.inc b/cmake/platform.inc index 71eee9d5072764edee739fb33bbd4fe4827611f0..7834a3541127363539270a5a41282991cf7740d8 100755 --- a/cmake/platform.inc +++ b/cmake/platform.inc @@ -22,6 +22,9 @@ SET(TD_LINUX FALSE) SET(TD_MIPS_64 FALSE) SET(TD_MIPS_32 FALSE) SET(TD_APLHINE FALSE) + SET(TD_NINGSI FALSE) + SET(TD_NINGSI_60 FALSE) + SET(TD_NINGSI_80 FALSE) SET(TD_WINDOWS FALSE) SET(TD_WINDOWS_64 FALSE) SET(TD_WINDOWS_32 FALSE) @@ -99,3 +102,18 @@ ELSEIF (${CPUTYPE} MATCHES "x86") ELSE () MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE}) ENDIF () + +# cmake -DOSTYPE=Ningsi +IF (${OSTYPE} MATCHES "Ningsi60") + SET(TD_NINGSI TRUE) + SET(TD_NINGSI_60 TRUE) + MESSAGE(STATUS "input osType: Ningsi60") +ELSEIF (${OSTYPE} MATCHES "Ningsi80") + SET(TD_NINGSI TRUE) + SET(TD_NINGSI_80 TRUE) + MESSAGE(STATUS "input osType: Ningsi80") +ELSEIF (${OSTYPE} MATCHES "Linux") + MESSAGE(STATUS "input osType: Linux") +ELSE () + MESSAGE(STATUS "input osType unknown: " ${OSTYPE}) +ENDIF () \ No newline at end of file diff --git a/packaging/deb/tarbitratord b/packaging/deb/tarbitratord index bf4dba7258b8333e1ecff1733661b69562896e45..3f97c3c0c2143817ad4ecbb13fabd8c09fb44c69 100644 --- a/packaging/deb/tarbitratord +++ b/packaging/deb/tarbitratord @@ -7,19 +7,19 @@ # chkconfig: 2345 99 01 # ### BEGIN INIT INFO -# Provides: TDEngine +# Provides: taoscluster # Required-Start: $local_fs $network $syslog # Required-Stop: $local_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Starts TDEngine tarbitrator -# Description: Starts TDEngine tarbitrator, a arbitrator +# Short-Description: Starts taoscluster tarbitrator +# Description: Starts taoscluster tarbitrator, a arbitrator ### END INIT INFO set -e PATH="/bin:/usr/bin:/sbin:/usr/sbin" -NAME="tarbitrator" +NAME="taoscluster" USER="root" GROUP="root" DAEMON="/usr/local/taos/bin/tarbitrator" diff --git a/packaging/release.sh b/packaging/release.sh index dceb8791263474a4f5b2d722e97a95cab9f73ae5..3ba1ba72b2347b97cf020ad0e723fbd198137581 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -7,22 +7,20 @@ set -e # releash.sh -v [cluster | edge] # -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] -# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | ...] +# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] # -V [stable | beta] # -l [full | lite] -# -s [static | dynamic] # -n [2.0.0.3] # set parameters by default value verMode=edge # [cluster, edge] verType=stable # [stable, beta] cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...] -osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | ...] +osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] pagMode=full # [full | lite] -soMode=dynamic # [static | dynamic] verNumber="" -while getopts "hv:V:c:o:l:s:n:" arg +while getopts "hv:V:c:o:l:n:" arg do case $arg in v) @@ -41,10 +39,6 @@ do #echo "pagMode=$OPTARG" pagMode=$(echo $OPTARG) ;; - s) - #echo "soMode=$OPTARG" - soMode=$(echo $OPTARG) - ;; n) #echo "verNumber=$OPTARG" verNumber=$(echo $OPTARG) @@ -56,10 +50,9 @@ do h) echo "Usage: `basename $0` -v [cluster | edge] " echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] " - echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | ...] " + echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] " echo " -V [stable | beta] " echo " -l [full | lite] " - echo " -s [static | dynamic] " echo " -n [version number] " exit 0 ;; @@ -70,7 +63,7 @@ do esac done -echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} soMode=${soMode} verNumber=${verNumber}" +echo "verMode=${verMode} verType=${verType} cpuType=${cpuType} osType=${osType} pagMode=${pagMode} verNumber=${verNumber}" curr_dir=$(pwd) @@ -230,9 +223,9 @@ cd ${compile_dir} # check support cpu type if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "mips64" ]] ; then if [ "$verMode" != "cluster" ]; then - cmake ../ -DCPUTYPE=${cpuType} -DPAGMODE=${pagMode} -DSOMODE=${soMode} + cmake ../ -DCPUTYPE=${cpuType} -DPAGMODE=${pagMode} -DOSTYPE=${osType} else - cmake ../../ -DCPUTYPE=${cpuType} -DSOMODE=${soMode} + cmake ../../ -DCPUTYPE=${cpuType} -DOSTYPE=${osType} fi else echo "input cpuType=${cpuType} error!!!" diff --git a/packaging/rpm/tarbitratord b/packaging/rpm/tarbitratord index 5d3f2b9c79794435a21e33cc669e70f9ae9f41a0..68138f5c1d5d4491b5fda52b08cfd51a039ffc64 100644 --- a/packaging/rpm/tarbitratord +++ b/packaging/rpm/tarbitratord @@ -7,10 +7,10 @@ # # ### BEGIN INIT INFO -# Provides: TDEngine +# Provides: taoscluster # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs -# Short-Description: start and stop taosd +# Short-Description: start and stop tarbitrator # Description: tarbitrator is a arbitrator used in TDengine cluster. ### END INIT INFO diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 6f54993f915edd3e5270a3cb6c44b21198231154..64de09df6d244a0f9a3a213e2948f9a064b59e74 100644 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -76,7 +76,11 @@ fi # get the operating system type for using the corresponding init file # ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification #osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) -osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) +if [[ -d /etc/os-release ]]; then + osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) ||: +else + osinfo="" +fi #echo "osinfo: ${osinfo}" os_type=0 if echo $osinfo | grep -qwi "ubuntu" ; then @@ -95,8 +99,10 @@ elif echo $osinfo | grep -qwi "fedora" ; then # echo "This is fedora system" os_type=2 else - echo "${osinfo}: This is an officially unverified linux system, If there are any problems with the installation and operation, " - echo "please feel free to contact taosdata.com for support." + echo " osinfo: ${osinfo}" + echo " This is an officially unverified linux system," + echo " if there are any problems with the installation and operation, " + echo " please feel free to contact taosdata.com for support." os_type=1 fi @@ -192,13 +198,12 @@ function install_lib() { ${csudo} rm -f ${lib_link_dir}/libtaos.* || : ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : #${csudo} rm -rf ${v15_java_app_dir} || : - ${csudo} cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so - if [ -d ${lib64_link_dir} ]; then + if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then ${csudo} ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : ${csudo} ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : fi @@ -306,14 +311,27 @@ function clean_service_on_sysvinit() { fi if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} chkconfig --del taosd || : + fi + + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} chkconfig --del tarbitratord || : + fi elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} insserv -r taosd || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} insserv -r tarbitratord || : + fi elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} update-rc.d -f taosd remove || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} update-rc.d -f tarbitratord remove || : + fi fi ${csudo} rm -f ${service_config_dir}/taosd || : @@ -326,7 +344,6 @@ function clean_service_on_sysvinit() { function install_service_on_sysvinit() { clean_service_on_sysvinit - sleep 1 # Install taosd service @@ -446,7 +463,7 @@ function install_service_on_systemd() { ${csudo} bash -c "echo >> ${tarbitratord_service_config}" ${csudo} bash -c "echo '[Install]' >> ${tarbitratord_service_config}" ${csudo} bash -c "echo 'WantedBy=multi-user.target' >> ${tarbitratord_service_config}" - # ${csudo} systemctl enable tarbitratord + #${csudo} systemctl enable tarbitratord nginx_service_config="${service_config_dir}/nginxd.service" ${csudo} bash -c "echo '[Unit]' >> ${nginx_service_config}" diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 63e09dc56894a4e035c691be29b2bbc34e48bd7c..c775f98b83cd03c980c2855c1b64bf1dfb574221 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -72,7 +72,6 @@ function clean_bin() { ${csudo} rm -f ${bin_link_dir}/taos || : ${csudo} rm -f ${bin_link_dir}/taosd || : ${csudo} rm -f ${bin_link_dir}/taosdemo || : - ${csudo} rm -f ${bin_link_dir}/taosdump || : ${csudo} rm -f ${bin_link_dir}/rmtaos || : } @@ -86,7 +85,7 @@ function clean_lib() { function clean_header() { # Remove link ${csudo} rm -f ${inc_link_dir}/taos.h || : - ${csudo} rm -f ${inc_link_dir}/taoserror.h || : + ${csudo} rm -f ${inc_link_dir}/taoserror.h || : } function clean_config() { @@ -148,15 +147,27 @@ function clean_service_on_sysvinit() { ${csudo} service tarbitratord stop || : fi - if ((${initd_mod}==1)); then + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} chkconfig --del taosd || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} chkconfig --del tarbitratord || : - elif ((${initd_mod}==2)); then + fi + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} insserv -r taosd || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} insserv -r tarbitratord || : - elif ((${initd_mod}==3)); then + fi + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/taosd ]; then ${csudo} update-rc.d -f taosd remove || : + fi + if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo} update-rc.d -f tarbitratord remove || : + fi fi ${csudo} rm -f ${service_config_dir}/taosd || : @@ -196,13 +207,20 @@ ${csudo} rm -rf ${data_link_dir} || : ${csudo} rm -rf ${install_main_dir} ${csudo} rm -rf ${install_nginxd_dir} +if [[ -d /etc/os-release ]]; then + osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) +else + osinfo="" +fi -osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release) if echo $osinfo | grep -qwi "ubuntu" ; then # echo "this is ubuntu system" ${csudo} rm -f /var/lib/dpkg/info/tdengine* || : +elif echo $osinfo | grep -qwi "debian" ; then +# echo "this is debian system" + ${csudo} rm -f /var/lib/dpkg/info/tdengine* || : elif echo $osinfo | grep -qwi "centos" ; then - echo "this is centos system" +# echo "this is centos system" ${csudo} rpm -e --noscripts tdengine || : fi diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index 4bc278fcf06ec18534535547f2c60ae156bc5da1..7cbf524d04734e5b5a73b37c44bf23b2c0254157 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -37,7 +37,7 @@ function kill_client() { function clean_bin() { # Remove link ${csudo} rm -f ${bin_link_dir}/taos || : - ${csudo} rm -f ${bin_link_dir}/taosump || : + ${csudo} rm -f ${bin_link_dir}/taosdemo || : ${csudo} rm -f ${bin_link_dir}/rmtaos || : } diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 5c708dffeeeb6877467c52cf50eedab68c1f59d3..04c6ef47a5f8dc741015f1b2ae27e51feded439e 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -56,7 +56,8 @@ for (int32_t i = 0; i < (ctx)->tagInfo.numOfTagCols; ++i) { \ SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[i]; \ if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { \ - __ctx->tag = (tVariant){.i64Key = (ts), .nType = TSDB_DATA_TYPE_BIGINT}; \ + __ctx->tag.i64Key = (ts); \ + __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; \ } \ aAggs[TSDB_FUNC_TAG].xFunction(__ctx); \ } \ @@ -963,7 +964,8 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin, for (int32_t i = 0; i < (pCtx)->tagInfo.numOfTagCols; ++i) { SQLFunctionCtx *__ctx = pCtx->tagInfo.pTagCtxList[i]; if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { - __ctx->tag = (tVariant){.i64Key = key, .nType = TSDB_DATA_TYPE_BIGINT}; + __ctx->tag.i64Key = key; + __ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; } aAggs[TSDB_FUNC_TAG].xFunction(__ctx); @@ -1867,7 +1869,8 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 for (int32_t i = 0; i < pTagInfo->numOfTagCols; ++i) { SQLFunctionCtx* ctx = pTagInfo->pTagCtxList[i]; if (ctx->functionId == TSDB_FUNC_TS_DUMMY) { - ctx->tag = (tVariant) {.nType = TSDB_DATA_TYPE_BIGINT, .i64Key = tsKey}; + ctx->tag.nType = TSDB_DATA_TYPE_BIGINT; + ctx->tag.i64Key = tsKey; } tVariantDump(&ctx->tag, dst->pTags + size, ctx->tag.nType, true); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 42f339609ddd1505db12f7d1dacb0b144a75095d..c022e320a343531c5c6e5454a4b9a288c8ffb0c3 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -12,6 +12,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +#define _GNU_SOURCE + #include "os.h" #include "qAst.h" diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index c1071f9698a4f136681f38a3c10132775219cf07..1f41bc23eb266056973d86d80fbcbf37319faa5b 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -724,6 +724,9 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) { pStatus->clusterCfg.maxVgroupsPerDb = htonl(tsMaxVgroupsPerDb); tstrncpy(pStatus->clusterCfg.arbitrator, tsArbitrator, TSDB_EP_LEN); tstrncpy(pStatus->clusterCfg.timezone, tsTimezone, 64); + pStatus->clusterCfg.checkTime = 0; + char timestr[32] = "1970-01-01 00:00:00.00"; + (void)taosParseTime(timestr, &pStatus->clusterCfg.checkTime, strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); tstrncpy(pStatus->clusterCfg.locale, tsLocale, TSDB_LOCALE_LEN); tstrncpy(pStatus->clusterCfg.charset, tsCharset, TSDB_LOCALE_LEN); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 265bf47d6dce95b76e4dce930f0656da6156dbb3..1daa1da03805415ed58b9ec4b11c791656af2a9a 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -575,6 +575,7 @@ typedef struct { int32_t maxVgroupsPerDb; char arbitrator[TSDB_EP_LEN]; // tsArbitrator char timezone[64]; // tsTimezone + int64_t checkTime; // 1970-01-01 00:00:00.000 char locale[TSDB_LOCALE_LEN]; // tsLocale char charset[TSDB_LOCALE_LEN]; // tsCharset } SClusterCfg; diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 261f63d5cf17c4cd2d0eaa7d0d2230d38846263b..5da57a30934d75335ca28c0d7e6dcfe3e43b47b2 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -363,10 +363,15 @@ static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { mError("\"arbitrator\"[%s - %s] cfg parameters inconsistent", clusterCfg->arbitrator, tsArbitrator); return false; } - if (0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) { - mError("\"timezone\"[%s - %s] cfg parameters inconsistent", clusterCfg->timezone, tsTimezone); + + int64_t checkTime = 0; + char timestr[32] = "1970-01-01 00:00:00.00"; + (void)taosParseTime(timestr, &checkTime, strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); + if ((0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) && (checkTime != clusterCfg->checkTime)) { + mError("\"timezone\"[%s - %s] [%" PRId64 " - %" PRId64"] cfg parameters inconsistent", clusterCfg->timezone, tsTimezone, clusterCfg->checkTime, checkTime); return false; } + if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) { mError("\"locale\"[%s - %s] cfg parameters inconsistent", clusterCfg->locale, tsLocale); return false; diff --git a/src/os/inc/os.h b/src/os/inc/os.h index 4953416bde4ca380a4221c1517e5b5c916166cc1..df4b847fbb83c04cc5501dd73b6197b94ceff1c3 100644 --- a/src/os/inc/os.h +++ b/src/os/inc/os.h @@ -40,6 +40,10 @@ extern "C" { #include "osAlpine.h" #endif +#ifdef _TD_NINGSI_60_ +#include "osNingsi.h" +#endif + #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #include "osWindows.h" #endif diff --git a/src/os/inc/osNingsi.h b/src/os/inc/osNingsi.h new file mode 100644 index 0000000000000000000000000000000000000000..da7f796b595cf9303d6e178da46368f552030edd --- /dev/null +++ b/src/os/inc/osNingsi.h @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_NINGSI_H +#define TDENGINE_OS_NINGSI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define TAOS_OS_FUNC_ATOMIC +/* + * type __sync_fetch_and_add (type *ptr, type value); + * type __sync_fetch_and_sub (type *ptr, type value); + * type __sync_fetch_and_or (type *ptr, type value); + * type __sync_fetch_and_and (type *ptr, type value); + * type __sync_fetch_and_xor (type *ptr, type value); + * type __sync_fetch_and_nand (type *ptr, type value); + * type __sync_add_and_fetch (type *ptr, type value); + * type __sync_sub_and_fetch (type *ptr, type value); + * type __sync_or_and_fetch (type *ptr, type value); + * type __sync_and_and_fetch (type *ptr, type value); + * type __sync_xor_and_fetch (type *ptr, type value); + * type __sync_nand_and_fetch (type *ptr, type value); + * + * bool __sync_bool_compare_and_swap (type*ptr, type oldval, type newval, ...) + * type __sync_val_compare_and_swap (type *ptr, type oldval, ?type newval, ...) + * */ + +#define atomic_load_8(ptr) __sync_fetch_and_add((ptr), 0) +#define atomic_load_16(ptr) __sync_fetch_and_add((ptr), 0) +#define atomic_load_32(ptr) __sync_fetch_and_add((ptr), 0) +#define atomic_load_64(ptr) __sync_fetch_and_add((ptr), 0) +#define atomic_load_ptr(ptr) __sync_fetch_and_add((ptr), 0) + +#define atomic_store_8(ptr, val) (*(ptr)=(val)) +#define atomic_store_16(ptr, val) (*(ptr)=(val)) +#define atomic_store_32(ptr, val) (*(ptr)=(val)) +#define atomic_store_64(ptr, val) (*(ptr)=(val)) +#define atomic_store_ptr(ptr, val) (*(ptr)=(val)) + +int8_t atomic_exchange_8_impl(int8_t* ptr, int8_t val ); +int16_t atomic_exchange_16_impl(int16_t* ptr, int16_t val ); +int32_t atomic_exchange_32_impl(int32_t* ptr, int32_t val ); +int64_t atomic_exchange_64_impl(int64_t* ptr, int64_t val ); +void* atomic_exchange_ptr_impl( void **ptr, void *val ); + +#define atomic_exchange_8(ptr, val) atomic_exchange_8_impl((int8_t*)ptr, (int8_t)val) +#define atomic_exchange_16(ptr, val) atomic_exchange_16_impl((int16_t*)ptr, (int16_t)val) +#define atomic_exchange_32(ptr, val) atomic_exchange_32_impl((int32_t*)ptr, (int32_t)val) +#define atomic_exchange_64(ptr, val) atomic_exchange_64_impl((int64_t*)ptr, (int64_t)val) +#define atomic_exchange_ptr(ptr, val) atomic_exchange_ptr_impl((void **)ptr, (void*)val) + +#define atomic_val_compare_exchange_8 __sync_val_compare_and_swap +#define atomic_val_compare_exchange_16 __sync_val_compare_and_swap +#define atomic_val_compare_exchange_32 __sync_val_compare_and_swap +#define atomic_val_compare_exchange_64 __sync_val_compare_and_swap +#define atomic_val_compare_exchange_ptr __sync_val_compare_and_swap + +#define atomic_add_fetch_8(ptr, val) __sync_add_and_fetch((ptr), (val)) +#define atomic_add_fetch_16(ptr, val) __sync_add_and_fetch((ptr), (val)) +#define atomic_add_fetch_32(ptr, val) __sync_add_and_fetch((ptr), (val)) +#define atomic_add_fetch_64(ptr, val) __sync_add_and_fetch((ptr), (val)) +#define atomic_add_fetch_ptr(ptr, val) __sync_add_and_fetch((ptr), (val)) + +#define atomic_fetch_add_8(ptr, val) __sync_fetch_and_add((ptr), (val)) +#define atomic_fetch_add_16(ptr, val) __sync_fetch_and_add((ptr), (val)) +#define atomic_fetch_add_32(ptr, val) __sync_fetch_and_add((ptr), (val)) +#define atomic_fetch_add_64(ptr, val) __sync_fetch_and_add((ptr), (val)) +#define atomic_fetch_add_ptr(ptr, val) __sync_fetch_and_add((ptr), (val)) + +#define atomic_sub_fetch_8(ptr, val) __sync_sub_and_fetch((ptr), (val)) +#define atomic_sub_fetch_16(ptr, val) __sync_sub_and_fetch((ptr), (val)) +#define atomic_sub_fetch_32(ptr, val) __sync_sub_and_fetch((ptr), (val)) +#define atomic_sub_fetch_64(ptr, val) __sync_sub_and_fetch((ptr), (val)) +#define atomic_sub_fetch_ptr(ptr, val) __sync_sub_and_fetch((ptr), (val)) + +#define atomic_fetch_sub_8(ptr, val) __sync_fetch_and_sub((ptr), (val)) +#define atomic_fetch_sub_16(ptr, val) __sync_fetch_and_sub((ptr), (val)) +#define atomic_fetch_sub_32(ptr, val) __sync_fetch_and_sub((ptr), (val)) +#define atomic_fetch_sub_64(ptr, val) __sync_fetch_and_sub((ptr), (val)) +#define atomic_fetch_sub_ptr(ptr, val) __sync_fetch_and_sub((ptr), (val)) + +#define atomic_and_fetch_8(ptr, val) __sync_and_and_fetch((ptr), (val)) +#define atomic_and_fetch_16(ptr, val) __sync_and_and_fetch((ptr), (val)) +#define atomic_and_fetch_32(ptr, val) __sync_and_and_fetch((ptr), (val)) +#define atomic_and_fetch_64(ptr, val) __sync_and_and_fetch((ptr), (val)) +#define atomic_and_fetch_ptr(ptr, val) __sync_and_and_fetch((ptr), (val)) + +#define atomic_fetch_and_8(ptr, val) __sync_fetch_and_and((ptr), (val)) +#define atomic_fetch_and_16(ptr, val) __sync_fetch_and_and((ptr), (val)) +#define atomic_fetch_and_32(ptr, val) __sync_fetch_and_and((ptr), (val)) +#define atomic_fetch_and_64(ptr, val) __sync_fetch_and_and((ptr), (val)) +#define atomic_fetch_and_ptr(ptr, val) __sync_fetch_and_and((ptr), (val)) + +#define atomic_or_fetch_8(ptr, val) __sync_or_and_fetch((ptr), (val)) +#define atomic_or_fetch_16(ptr, val) __sync_or_and_fetch((ptr), (val)) +#define atomic_or_fetch_32(ptr, val) __sync_or_and_fetch((ptr), (val)) +#define atomic_or_fetch_64(ptr, val) __sync_or_and_fetch((ptr), (val)) +#define atomic_or_fetch_ptr(ptr, val) __sync_or_and_fetch((ptr), (val)) + +#define atomic_fetch_or_8(ptr, val) __sync_fetch_and_or((ptr), (val)) +#define atomic_fetch_or_16(ptr, val) __sync_fetch_and_or((ptr), (val)) +#define atomic_fetch_or_32(ptr, val) __sync_fetch_and_or((ptr), (val)) +#define atomic_fetch_or_64(ptr, val) __sync_fetch_and_or((ptr), (val)) +#define atomic_fetch_or_ptr(ptr, val) __sync_fetch_and_or((ptr), (val)) + +#define atomic_xor_fetch_8(ptr, val) __sync_xor_and_fetch((ptr), (val)) +#define atomic_xor_fetch_16(ptr, val) __sync_xor_and_fetch((ptr), (val)) +#define atomic_xor_fetch_32(ptr, val) __sync_xor_and_fetch((ptr), (val)) +#define atomic_xor_fetch_64(ptr, val) __sync_xor_and_fetch((ptr), (val)) +#define atomic_xor_fetch_ptr(ptr, val) __sync_xor_and_fetch((ptr), (val)) + +#define atomic_fetch_xor_8(ptr, val) __sync_fetch_and_xor((ptr), (val)) +#define atomic_fetch_xor_16(ptr, val) __sync_fetch_and_xor((ptr), (val)) +#define atomic_fetch_xor_32(ptr, val) __sync_fetch_and_xor((ptr), (val)) +#define atomic_fetch_xor_64(ptr, val) __sync_fetch_and_xor((ptr), (val)) +#define atomic_fetch_xor_ptr(ptr, val) __sync_fetch_and_xor((ptr), (val)) + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/os/src/linux/ningsi.c b/src/os/src/linux/ningsi.c new file mode 100644 index 0000000000000000000000000000000000000000..793ccac84adc05988c9fbb0b6b1d13170752c76a --- /dev/null +++ b/src/os/src/linux/ningsi.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" + +#ifdef _TD_NINGSI_60_ +void* atomic_exchange_ptr_impl(void** ptr, void* val ) { + void *old; + do { + old = *ptr; + } while( !__sync_bool_compare_and_swap(ptr, old, val) ); + return old; +} +int8_t atomic_exchange_8_impl(int8_t* ptr, int8_t val ) { + int8_t old; + do { + old = *ptr; + } while( !__sync_bool_compare_and_swap(ptr, old, val) ); + return old; +} +int16_t atomic_exchange_16_impl(int16_t* ptr, int16_t val ) { + int16_t old; + do { + old = *ptr; + } while( !__sync_bool_compare_and_swap(ptr, old, val) ); + return old; +} +int32_t atomic_exchange_32_impl(int32_t* ptr, int32_t val ) { + int32_t old; + do { + old = *ptr; + } while( !__sync_bool_compare_and_swap(ptr, old, val) ); + return old; +} +int64_t atomic_exchange_64_impl(int64_t* ptr, int64_t val ) { + int64_t old; + do { + old = *ptr; + } while( !__sync_bool_compare_and_swap(ptr, old, val) ); + return old; +} +#endif +