From f39c00bbc5258d72328c1f37e993893b9ec321e4 Mon Sep 17 00:00:00 2001 From: Rachel Bousfield Date: Mon, 31 Jul 2023 13:29:28 -0600 Subject: [PATCH] add C sdk --- .gitmodules | 3 ++ arbitrator/langs/c | 1 + arbitrator/langs/c/arbitrum.h | 52 ----------------------------------- 3 files changed, 4 insertions(+), 52 deletions(-) create mode 160000 arbitrator/langs/c delete mode 100644 arbitrator/langs/c/arbitrum.h diff --git a/.gitmodules b/.gitmodules index 5310a56f4..71e8415cf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "arbitrator/langs/rust"] path = arbitrator/langs/rust url = https://github.com/OffchainLabs/stylus-sdk-rs.git +[submodule "arbitrator/langs/c"] + path = arbitrator/langs/c + url = https://github.com/OffchainLabs/stylus-sdk-c.git diff --git a/arbitrator/langs/c b/arbitrator/langs/c new file mode 160000 index 000000000..94331a5fc --- /dev/null +++ b/arbitrator/langs/c @@ -0,0 +1 @@ +Subproject commit 94331a5fc321fb93f607b6ec131985fa2d070eb3 diff --git a/arbitrator/langs/c/arbitrum.h b/arbitrator/langs/c/arbitrum.h deleted file mode 100644 index e9263dc70..000000000 --- a/arbitrator/langs/c/arbitrum.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2022, Offchain Labs, Inc. -// For license information, see https://github.com/nitro/blob/master/LICENSE - -#ifndef ARBITRUM_HEADER_GUARD -#define ARBITRUM_HEADER_GUARD - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define USER_HOST import_module("vm_hooks") - -extern __attribute__((USER_HOST, import_name("read_args"))) void read_args(const uint8_t * data); -extern __attribute__((USER_HOST, import_name("write_result"))) void write_result(const uint8_t * data, size_t len); -extern __attribute__((USER_HOST, import_name("memory_grow"))) void memory_grow(uint32_t pages); - -typedef enum ArbStatus { - Success = 0, - Failure, -} ArbStatus; - -typedef struct ArbResult { - const ArbStatus status; - const uint8_t * output; - const size_t output_len; -} ArbResult; - -#define ARBITRUM_MAIN(user_main) \ - /* Force the compiler to import these symbols */ \ - /* Note: calling these functions will unproductively consume gas */ \ - __attribute__((export_name("mark_used"))) \ - void mark_used() { \ - memory_grow(0); \ - } \ - \ - __attribute__((export_name("arbitrum_main"))) \ - int arbitrum_main(int args_len) { \ - const uint8_t args[args_len]; \ - read_args(args); \ - const ArbResult result = user_main(args, args_len); \ - write_result(result.output, result.output_len); \ - return result.status; \ - } - -#ifdef __cplusplus -} -#endif - -#endif