Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce riscv64 architecture support #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmake/cmake.platform
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ IF ("${CPUTYPE}" STREQUAL "")
SET(TD_ARM_64 TRUE)
ADD_DEFINITIONS("-D_TD_ARM_")
ADD_DEFINITIONS("-D_TD_ARM_64")
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64")
MESSAGE(STATUS "The current platform is riscv64")
SET(PLATFORM_ARCH_STR "riscv64")
SET(TD_RISCV_64 TRUE)
ADD_DEFINITIONS("-D_TD_RISCV_")
ADD_DEFINITIONS("-D_TD_RISCV_64")
ENDIF ()
ELSE ()
# if generate ARM version:
Expand All @@ -118,6 +124,12 @@ ELSE ()
ADD_DEFINITIONS("-D_TD_ARM_")
ADD_DEFINITIONS("-D_TD_ARM_64")
SET(TD_ARM_64 TRUE)
ELSEIF (${CPUTYPE} MATCHES "riscv64")
SET(PLATFORM_ARCH_STR "riscv64")
MESSAGE(STATUS "input cpuType: riscv64")
ADD_DEFINITIONS("-D_TD_RISCV_")
ADD_DEFINITIONS("-D_TD_RISCV_64")
SET(TD_ARM_64 TRUE)
ELSEIF (${CPUTYPE} MATCHES "mips64")
SET(PLATFORM_ARCH_STR "mips")
MESSAGE(STATUS "input cpuType: mips64")
Expand Down
6 changes: 3 additions & 3 deletions packaging/docker/dockerbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
#set -x

# dockerbuild.sh
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 | riscv64...]
# -n [version number]
# -p [password for docker hub]
# -V [stable | beta]
Expand Down Expand Up @@ -57,7 +57,7 @@ do
dockerLatest=$(echo $OPTARG)
;;
h)
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 | riscv64 ...] "
echo " -n [version number] "
echo " -p [password for docker hub] "
echo " -V [stable | beta] "
Expand Down Expand Up @@ -136,4 +136,4 @@ if [ "$cloudBuild" != "y" ] && [ ${dockerLatest} == 'y' ] ;then
docker push tdengine/tdengine-${dockername}:latest
fi

rm -f ${pkgFile}
rm -f ${pkgFile}
4 changes: 2 additions & 2 deletions packaging/docker/dockerbuildi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
#set -x

# dockerbuild.sh
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...]
# -c [aarch32 | aarch64 | amd64 | x86 | mips64 | riscv64 ...]
# -n [version number]
# -p [password for docker hub]

Expand All @@ -30,7 +30,7 @@ do
passWord=$(echo $OPTARG)
;;
h)
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] "
echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 | riscv64 ...] "
echo " -n [version number] "
echo " -p [password for docker hub] "
exit 0
Expand Down
8 changes: 4 additions & 4 deletions packaging/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
#set -x

# release.sh -v [cluster | edge]
# -c [aarch32 | aarch64 | x64 | x86 | mips64 ...]
# -c [aarch32 | aarch64 | x64 | x86 | mips64 | riscv64...]
# -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
# -V [stable | beta]
# -l [full | lite]
Expand All @@ -19,7 +19,7 @@ set -e
# set parameters by default value
verMode=edge # [cluster, edge, cloud]
verType=stable # [stable, beta]
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 ...]
cpuType=x64 # [aarch32 | aarch64 | x64 | x86 | mips64 | riscv64 ...]
osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...]
pagMode=full # [full | lite]
soMode=dynamic # [static | dynamic]
Expand Down Expand Up @@ -77,7 +77,7 @@ while getopts "hv:V:c:o:l:s:d:a:n:m:H:" arg; do
;;
h)
echo "Usage: $(basename $0) -v [cluster | edge] "
echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] "
echo " -c [aarch32 | aarch64 | x64 | x86 | mips64 | riscv64 ...] "
echo " -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] "
echo " -V [stable | beta] "
echo " -l [full | lite] "
Expand Down Expand Up @@ -216,7 +216,7 @@ else
fi

# check support cpu type
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]]; then
if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" == "aarch32" ]] || [[ "$cpuType" == "arm64" ]] || [[ "$cpuType" == "arm32" ]] || [[ "$cpuType" == "mips64" ]] || [[ "$cpuType" == "riscv64" ]]; then
if [ "$verMode" == "edge" ]; then
# community-version compile
cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
Expand Down
6 changes: 5 additions & 1 deletion source/os/src/osSysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,11 @@ void taosSetCoreDump(bool enable) {

old_len = sizeof(old_usespid);

#ifndef __riscv
if (syscall(SYS__sysctl, &args) == -1) {
// printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
#endif

// printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);

Expand All @@ -918,9 +920,11 @@ void taosSetCoreDump(bool enable) {

old_len = sizeof(old_usespid);

#ifndef __riscv
if (syscall(SYS__sysctl, &args) == -1) {
// printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
#endif

// printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
#endif
Expand Down Expand Up @@ -989,4 +993,4 @@ bool taosCheckCurrentInDll() {
#else
return false;
#endif
}
}
10 changes: 5 additions & 5 deletions source/util/src/tcrc32c.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

#define _DEFAULT_SOURCE
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) && !defined(_TD_RISCV_)
#include <nmmintrin.h>
#endif

Expand Down Expand Up @@ -512,7 +512,7 @@ static uint32_t table[16][256] = {
0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa}

};
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) && !defined(_TD_RISCV_)
static uint32_t long_shifts[4][256] = {
{0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f, 0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7,
0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2, 0x94b55c14, 0x74f5bcb8, 0x51d8ebbd, 0xb1980b11, 0x37048b6e, 0xd7446bc2,
Expand Down Expand Up @@ -846,7 +846,7 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) {
}
return (uint32_t)crc ^ 0xffffffff;
}
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) && !defined(_TD_RISCV_)
/* Apply the zeros operator table to crc. */
static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) {
return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^ shift_table[2][(crc >> 16) & 0xff] ^
Expand All @@ -857,7 +857,7 @@ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) {
version. Otherwise, use the software version. */
uint32_t (*crc32c)(uint32_t crci, crc_stream bytes, size_t len) = crc32c_sf;

#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
#if !defined(_TD_ARM_) && !defined(_TD_MIPS_) && !defined(_TD_RISCV_)
/* Compute CRC-32C using the Intel hardware instruction. */
uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
crc_stream next = buf;
Expand Down Expand Up @@ -1012,7 +1012,7 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
#endif // #ifndef _TD_ARM_

void taosResolveCRC() {
#if defined _TD_ARM_ || defined _TD_MIPS_ || defined WINDOWS
#if defined _TD_ARM_ || defined _TD_MIPS_ || defined WINDOWS || defined _TD_RISCV_
crc32c = crc32c_sf;
#else
int32_t sse42;
Expand Down