aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yml105
-rw-r--r--src/stdlib/intX.c.h10
-rw-r--r--src/stdlib/lists.h5
3 files changed, 114 insertions, 6 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..d153774f
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,105 @@
+name: Release binaries
+
+on:
+ [push]
+
+jobs:
+ linux-x86_64:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install deps
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y \
+ build-essential \
+ libgmp-dev \
+ libunistring-dev \
+ libgc-dev \
+ xxd \
+ binutils
+
+ - name: Build
+ run: |
+ make clean
+ make -j
+
+ - name: Package
+ run: |
+ mkdir -p tomo
+ cp tomo tomo/tomo
+ tar -czf tomo-linux-x86_64.tar.gz tomo
+ sha256sum tomo-linux-x86_64.tar.gz > tomo-linux-x86_64.tar.gz.sha256
+
+ - name: Upload
+ uses: softprops/action-gh-release@v2
+ with:
+ files: |
+ tomo-linux-x86_64.tar.gz
+ tomo-linux-x86_64.tar.gz.sha256
+
+ linux-aarch64:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install deps
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y \
+ build-essential \
+ libgmp-dev \
+ libunistring-dev \
+ libgc-dev \
+ xxd \
+ binutils
+
+ - name: Build
+ run: |
+ make clean
+ make -j
+
+ - name: Package
+ run: |
+ mkdir -p tomo
+ cp tomo tomo/tomo
+ tar -czf tomo-linux-aarch64.tar.gz tomo
+ sha256sum tomo-linux-aarch64.tar.gz > tomo-linux-aarch64.tar.gz.sha256
+
+ - name: Upload
+ uses: softprops/action-gh-release@v2
+ with:
+ files: |
+ tomo-linux-aarch64.tar.gz
+ tomo-linux-aarch64.tar.gz.sha256
+
+ macos:
+ runs-on: macos-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install deps
+ run: |
+ brew update
+ brew install gmp libunistring bdw-gc xxd llvm binutils
+
+ - name: Build
+ run: |
+ make clean
+ make -j
+
+ - name: Package
+ run: |
+ mkdir -p tomo
+ cp tomo tomo/tomo
+ tar -czf tomo-macos-universal.tar.gz tomo
+ shasum -a 256 tomo-macos-universal.tar.gz > tomo-macos-universal.tar.gz.sha256
+
+ - name: Upload
+ uses: softprops/action-gh-release@v2
+ with:
+ files: |
+ tomo-macos-universal.tar.gz
+ tomo-macos-universal.tar.gz.sha256
+
diff --git a/src/stdlib/intX.c.h b/src/stdlib/intX.c.h
index 0910c7f1..72dfe6ed 100644
--- a/src/stdlib/intX.c.h
+++ b/src/stdlib/intX.c.h
@@ -55,12 +55,12 @@ public
void NAMESPACED(serialize)(const void *obj, FILE *out, Table_t *pointers, const TypeInfo_t *info) {
(void)info, (void)pointers;
#if INTX_C_H__INT_BITS < 32
- fwrite(obj, sizeof(INT_T), 1, out);
+ if (fwrite(obj, sizeof(INT_T), 1, out) != sizeof(INT_T)) fail("Failed to write whole integer");
#else
INT_T i = *(INT_T *)obj;
UINT_T z = (UINT_T)((i << 1L) ^ (i >> (INTX_C_H__INT_BITS - 1L))); // Zigzag encode
while (z >= 0x80L) {
- fputc((uint8_t)(z | 0x80L), out);
+ if (fputc((uint8_t)(z | 0x80L), out) == EOF) fail("Failed to write full integer");
z >>= 7L;
}
fputc((uint8_t)z, out);
@@ -71,11 +71,13 @@ public
void NAMESPACED(deserialize)(FILE *in, void *outval, List_t *pointers, const TypeInfo_t *info) {
(void)info, (void)pointers;
#if INTX_C_H__INT_BITS < 32
- fread(outval, sizeof(INT_T), 1, in);
+ if (fread(outval, sizeof(INT_T), 1, in) != sizeof(INT_T)) fail("Failed to read full integer");
#else
UINT_T z = 0;
for (size_t shift = 0;; shift += 7) {
- uint8_t byte = (uint8_t)fgetc(in);
+ int i = fgetc(in);
+ if (i == EOF) fail("Failed to read whole integer");
+ uint8_t byte = (uint8_t)i;
z |= ((UINT_T)(byte & 0x7F)) << shift;
if ((byte & 0x80) == 0) break;
}
diff --git a/src/stdlib/lists.h b/src/stdlib/lists.h
index 457fed52..6a0a1d43 100644
--- a/src/stdlib/lists.h
+++ b/src/stdlib/lists.h
@@ -61,7 +61,8 @@ extern char _EMPTY_LIST_SENTINEL;
t items[] = {__VA_ARGS__}; \
(List_t){.length = sizeof(items) / sizeof(items[0]), \
.stride = (int64_t)&items[1] - (int64_t)&items[0], \
- .data = memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \
+ .data = sizeof(items) == 0 ? &_EMPTY_LIST_SENTINEL \
+ : memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \
.atomic = 0, \
.data_refcount = 0}; \
})
@@ -70,7 +71,7 @@ extern char _EMPTY_LIST_SENTINEL;
t items[N] = {__VA_ARGS__}; \
(List_t){.length = N, \
.stride = (int64_t)&items[1] - (int64_t)&items[0], \
- .data = memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \
+ .data = N == 0 ? &_EMPTY_LIST_SENTINEL : memcpy(GC_MALLOC(sizeof(items)), items, sizeof(items)), \
.atomic = 0, \
.data_refcount = 0}; \
})