Skip to content

Commit

Permalink
Fixed CLFuncFn and broken macros in cyber.h (#99)
Browse files Browse the repository at this point in the history
* Update cyber.h

added extern "C" if using C++ compiler and prevented redefinitions from occurring.

* Updated type macros and CLFuncFn

* resolved diffs for updating type macros and CLFuncFn parameters

* Hopefully fix build.

* Hopefully fix build.

---------

Co-authored-by: fubark <[email protected]>
  • Loading branch information
ccleavinger and fubark authored Nov 24, 2024
1 parent bab51c1 commit 33fffeb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/latest-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
- name: Install zig.
if: env.BUILD_HOST == 'ubuntu-22.04'
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install wasm3.
if: env.BUILD_HOST == 'ubuntu-22.04' && (env.BUILD_TARGET == 'wasm32-freestanding' || env.BUILD_TARGET == 'wasm32-wasi')
Expand All @@ -142,19 +142,19 @@ jobs:
- name: Install zig.
if: env.BUILD_HOST == 'macos-12'
run: |
wget -c https://ziglang.org/builds/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'macos-14'
run: |
wget -c https://ziglang.org/builds/zig-macos-aarch64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-macos-aarch64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'windows-2022'
run: |
Invoke-WebRequest -Uri 'https://ziglang.org/builds/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip'
Invoke-WebRequest -Uri 'https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip'
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH 'C:\zig-windows-x86_64-${{ env.ZIG_VERSION }}\'
Expand Down Expand Up @@ -332,7 +332,7 @@ jobs:

- name: Install zig.
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Build md4c.
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Install zig.
if: env.BUILD_HOST == 'ubuntu-22.04'
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install wasm3.
if: env.BUILD_HOST == 'ubuntu-22.04' && (env.BUILD_TARGET == 'wasm32-freestanding' || env.BUILD_TARGET == 'wasm32-wasi')
Expand All @@ -123,19 +123,19 @@ jobs:
- name: Install zig.
if: env.BUILD_HOST == 'macos-12'
run: |
wget -c https://ziglang.org/builds/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'macos-14'
run: |
wget -c https://ziglang.org/builds/zig-macos-aarch64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
wget -c https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-macos-aarch64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'windows-2022'
run: |
Invoke-WebRequest -Uri 'https://ziglang.org/builds/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip'
Invoke-WebRequest -Uri 'https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip'
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH 'C:\zig-windows-x86_64-${{ env.ZIG_VERSION }}\'
Expand Down Expand Up @@ -172,4 +172,4 @@ jobs:
wasm3/build/wasm3 zig-out/bin/trace_test.wasm
- name: Build.
run: zig build ${{ env.BUILD_CMD }} ${{ env.ZIG_MODE_FLAG }} ${{ env.ZIG_TARGET_FLAG }}
run: zig build ${{ env.BUILD_CMD }} ${{ env.ZIG_MODE_FLAG }} ${{ env.ZIG_TARGET_FLAG }}
6 changes: 3 additions & 3 deletions src/include/cyber.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ typedef struct CLModule {
} CLModule;

// @host func is binded to this function pointer signature.
typedef CLValue (*CLFuncFn)(CLVM* vm);
typedef CLValue (*CLFuncFn)(CLVM*, const CLValue*, uint8_t);

typedef struct CLResolverParams {
/// Chunk that invoked the resolver.
Expand Down Expand Up @@ -263,8 +263,8 @@ typedef struct CLHostType {
// #define CL_CORE_TYPE(t) ((CLHostType){ .data = { .core_custom = { .type_id = t, .get_children = NULL, .finalizer = NULL }}, .type = CL_BIND_TYPE_CORE_CUSTOM })
// #define CL_CORE_TYPE_EXT(t, gc, f) ((CLHostType){ .data = { .core_custom = { .type_id = t, .get_children = gc, .finalizer = f }}, .type = CL_BIND_TYPE_CORE_CUSTOM })
// #define CL_CORE_TYPE_DECL(t) ((CLHostType){ .data = { .core_decl = { .type_id = t }}, .type = CL_BIND_TYPE_CORE_DECL })
#define CL_CUSTOM_TYPE(name, ot, gc, f) ((CLHostTypeEntry){ CL_STR(name), (CLHostType){ .data = { .custom = { .out_type_id = ot, .get_children = gc, .finalizer = f, .pre = false }}, .type = CL_BIND_TYPE_CUSTOM }})
#define CL_CUSTOM_PRE_TYPE(name, ot, gc, f) ((CLHostTypeEntry){ CL_STR(name), (CLHostType){ .data = { .custom = { .out_type_id = ot, .get_children = gc, .finalizer = f, .pre = true }}, .type = CL_BIND_TYPE_CUSTOM }})
#define CL_CUSTOM_TYPE(name, ot, gc, f) ((CLHostTypeEntry){ CL_STR(name), (CLHostType){ .data = { .hostobj = { .out_type_id = ot, .pre = false, .get_children = gc, .finalizer = f }}, .type = CL_BIND_TYPE_HOSTOBJ }})
#define CL_CUSTOM_PRE_TYPE(name, ot, gc, f) ((CLHostTypeEntry){ CL_STR(name), (CLHostType){ .data = { .hostobj = { .out_type_id = ot, .pre = true, .get_children = gc, .finalizer = f }}, .type = CL_BIND_TYPE_HOSTOBJ }})

// A mapping from a matching symbol string to a CLHostType.
typedef struct CLHostTypeEntry {
Expand Down

0 comments on commit 33fffeb

Please sign in to comment.