Skip to content

Commit

Permalink
Overhaul C Exports, Build More Combinations in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Nov 28, 2023
1 parent c79e5fa commit c83278d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 288 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,76 @@ jobs:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: "c_exports"
- os: ubuntu-latest
target: i686-unknown-linux-gnu
features: "c_exports"
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
features: "c_exports"
- os: windows-latest
target: x86_64-pc-windows-msvc
features: "c_exports"
- os: windows-latest
target: i686-pc-windows-msvc
features: "c_exports"
- os: windows-latest
target: aarch64-pc-windows-msvc
features: "c_exports"
- os: macos-latest
target: x86_64-apple-darwin
features: "c_exports"
- os: macos-latest
target: aarch64-apple-darwin
features: "c_exports"
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: "c_exports,size_opt"
- os: ubuntu-latest
target: i686-unknown-linux-gnu
features: "c_exports,size_opt"
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
features: "c_exports,size_opt"
- os: windows-latest
target: x86_64-pc-windows-msvc
features: "c_exports,size_opt"
- os: windows-latest
target: i686-pc-windows-msvc
features: "c_exports,size_opt"
- os: windows-latest
target: aarch64-pc-windows-msvc
features: "c_exports,size_opt"
- os: macos-latest
target: x86_64-apple-darwin
features: "c_exports,size_opt"
- os: macos-latest
target: aarch64-apple-darwin
features: "c_exports,size_opt"
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: "c_exports,size_opt,no_format"
- os: ubuntu-latest
target: i686-unknown-linux-gnu
features: "c_exports,size_opt,no_format"
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
features: "c_exports,size_opt,no_format"
- os: windows-latest
target: x86_64-pc-windows-msvc
features: "c_exports,size_opt,no_format"
- os: windows-latest
target: i686-pc-windows-msvc
features: "c_exports,size_opt,no_format"
- os: windows-latest
target: aarch64-pc-windows-msvc
features: "c_exports,size_opt,no_format"
- os: macos-latest
target: x86_64-apple-darwin
features: "c_exports,size_opt,no_format"
- os: macos-latest
target: aarch64-apple-darwin
features: "c_exports,size_opt,no_format"

runs-on: ${{ matrix.os }}

Expand All @@ -75,6 +131,7 @@ jobs:
with:
rust_project_path: src-rust
target: ${{ matrix.target }}
features: ${{ matrix.features }}

build-c-headers:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ You can specify another process with `TargetProcess = someProcess` in `BufferAll

- *no_format*: Disables formatting code in errors, saving ~8kB of space.
- *size_opt*: Makes cold paths optimized for size instead of optimized for speed. [Requires 'nightly' Rust]
- *c_exports*: Provides C exports for the library.

## Community Feedback

Expand Down
1 change: 1 addition & 0 deletions src-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license = "GPL-3.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
c_exports = []
no_format = []
size_opt = ["nightly"]
nightly = [] # Optimizations for nightly builds.
Expand Down
39 changes: 1 addition & 38 deletions src-rust/src/c/buffers_c_buffers.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
extern crate alloc;
use super::{
buffers_c_locatoritem::{
locatoritem_append_bytes, locatoritem_bytes_left, locatoritem_can_use,
locatoritem_is_allocated, locatoritem_is_taken, locatoritem_lock, locatoritem_max_address,
locatoritem_min_address, locatoritem_try_lock, locatoritem_unlock,
},
buffers_fnptr::BuffersFunctions,
};

use crate::{
buffers::Buffers,
structs::{
Expand Down Expand Up @@ -339,36 +332,6 @@ pub extern "C" fn overwrite_allocated_code_ex(
clear_instruction_cache(target, source.wrapping_add(size));
}

/// Returns all exported functions inside a struct.
#[no_mangle]
pub extern "C" fn get_functions() -> BuffersFunctions {
BuffersFunctions {
buffers_allocate_private_memory,
buffers_get_buffer_aligned,
buffers_get_buffer,
free_string,
free_private_allocation,
free_locator_item,
free_allocation_result,
free_get_buffer_result,
buffersearchsettings_from_proximity,
bufferallocatorsettings_from_proximity,
locatoritem_bytes_left,
locatoritem_min_address,
locatoritem_max_address,
locatoritem_is_allocated,
locatoritem_is_taken,
locatoritem_try_lock,
locatoritem_lock,
locatoritem_unlock,
locatoritem_can_use,
locatoritem_append_bytes,
utilities_clear_instruction_cache,
overwrite_allocated_code,
overwrite_allocated_code_ex,
}
}

#[cfg(test)]
mod tests {
use crate::c::buffers_c_buffers::{
Expand Down
Loading

0 comments on commit c83278d

Please sign in to comment.