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

add support for riscv64 #48

Open
yuzibo opened this issue Aug 5, 2022 · 4 comments
Open

add support for riscv64 #48

yuzibo opened this issue Aug 5, 2022 · 4 comments
Labels
A-misc Area: Misc C-enhancement Category: Enhancement of existing features

Comments

@yuzibo
Copy link

yuzibo commented Aug 5, 2022

Hi,
I am porting the package to riscv64 arch on Debian, the build is ok and it pass its test suite from my local build log. The patch is here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=1015787;filename=zycore-c-add-support-for-riscv64.patch;msg=5

And the reportbug is here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015787

If there is any issue please let me know, thanks

@flobernd
Copy link
Member

flobernd commented Aug 5, 2022

Hi there,

thanks for submitting your patch 🙂 We will try to integrate this upstream.

Pasting the patch here for reference:

--- a/include/Zycore/Defines.h
+++ b/include/Zycore/Defines.h
@@ -131,6 +131,8 @@
 #   define ZYAN_AARCH64
 #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__)
 #   define ZYAN_ARM
+#elif defined(_M_RISCV64) || defined(__riscv) && __riscv_xlen == 64
+#   define ZYAN_RISCV64
 #elif defined(__EMSCRIPTEN__)
     // Nothing to do, `ZYAN_EMSCRIPTEN` is both platform and arch macro for this one.
 #else
--- a/src/Format.c
+++ b/src/Format.c
@@ -423,7 +423,7 @@
 
 ZyanStatus ZyanStringAppendDecU(ZyanString* string, ZyanU64 value, ZyanU8 padding_length)
 {
-#if defined(ZYAN_X64) || defined(ZYAN_AARCH64)
+#if defined(ZYAN_X64) || defined(ZYAN_AARCH64) || defined(ZYAN_RISCV64)
     return ZyanStringAppendDecU64(string, value, padding_length);
 #else
     // Working with 64-bit values is slow on non 64-bit systems
@@ -464,7 +464,7 @@
 ZyanStatus ZyanStringAppendHexU(ZyanString* string, ZyanU64 value, ZyanU8 padding_length,
     ZyanBool uppercase)
 {
-#if defined(ZYAN_X64) || defined(ZYAN_AARCH64)
+#if defined(ZYAN_X64) || defined(ZYAN_AARCH64) || defined(ZYAN_RISCV64)
     return ZyanStringAppendHexU64(string, value, padding_length, uppercase);
 #else
     // Working with 64-bit values is slow on non 64-bit systems

@flobernd
Copy link
Member

flobernd commented Aug 5, 2022

@athre0z We should probably as well introduce a generic ZYAN_ARCH64 (open for better name suggestions). Same for 32-bit environments.

@flobernd flobernd added C-enhancement Category: Enhancement of existing features A-misc Area: Misc labels Aug 5, 2022
@athre0z
Copy link
Member

athre0z commented Aug 5, 2022

Yeah, was thinking the same thing when reading the patch: let's do that! Maybe ZYAN_64_BIT_ARCH? ZYAN_ARCH64 would be fine as well if ARM folks hadn't decided to call their ISA AARCH64... 😅

@yuzibo
Copy link
Author

yuzibo commented Aug 15, 2022

Hi, many thanks for working on this.
Please feel free to tell me if there need me to do some tests on real riscv64 hardware(Unmatched board). Or:
Applying for accessing to real riscv64 hardware(Unmatched board also) from here:
https://github.com/plctlab/riscv-lab-access

Tachi107 added a commit to Tachi107/zycore-c that referenced this issue Oct 4, 2022
The patch submitted by Bo in https://bugs.debian.org/1015787 and zyantific#48
also checked for this additional define, but it was not part of
3e95307. This patch adds the
additional check.

Co-authored-by: Bo YU <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-misc Area: Misc C-enhancement Category: Enhancement of existing features
Projects
None yet
Development

No branches or pull requests

3 participants