Skip to content

Commit

Permalink
Merge pull request #6 from antoyo/ci/update-ubuntu
Browse files Browse the repository at this point in the history
Update to Ubuntu 24.04 in the CI
  • Loading branch information
antoyo authored Jan 24, 2025
2 parents 0ada67f + e78ed08 commit 319e957
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# TODO: Run cargo clippy.
# TODO: Switch to stable Rust.
# TODO: Switch to stable Rust when we don't use nightly features anymore.

name: CI

Expand All @@ -9,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down
24 changes: 12 additions & 12 deletions tiger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ const WORD_SIZE: usize = 8;
}*/

#[no_mangle]
extern fn ord(string: *const c_char) -> i64 {
extern "C" fn ord(string: *const c_char) -> i64 {
let cstring = unsafe { CStr::from_ptr(string_offset(string)) };
cstring.to_str().expect("cstr to_str").chars().next().expect("ord string is empty") as i64
}

#[no_mangle]
extern fn chr(num: i64) -> *const c_char {
extern "C" fn chr(num: i64) -> *const c_char {
let char = num as u8;
let ptr = GARBAGE_COLLECTOR.with(|collector| {
collector.borrow_mut().allocate(Layout::String(1))
Expand All @@ -74,7 +74,7 @@ extern fn chr(num: i64) -> *const c_char {
}

#[no_mangle]
extern fn getchar() -> *const c_char {
extern "C" fn getchar() -> *const c_char {
let stdin = stdin();
let char = stdin.bytes().next().expect("next char").expect("read stdin") as char;

Expand All @@ -92,7 +92,7 @@ extern fn getchar() -> *const c_char {
}

#[no_mangle]
extern fn getcharP(continuation: *const c_void) {
extern "C" fn getcharP(continuation: *const c_void) {
let char = getchar();
unsafe {
let function: fn(*const c_char) = mem::transmute(get_function_pointer(continuation));
Expand All @@ -101,7 +101,7 @@ extern fn getcharP(continuation: *const c_void) {
}

#[no_mangle]
extern fn concat(string1: *const c_char, string2: *const c_char) -> *const c_char {
extern "C" fn concat(string1: *const c_char, string2: *const c_char) -> *const c_char {
let cstring1 = unsafe { CStr::from_ptr(string_offset(string1)) };
let cstring2 = unsafe { CStr::from_ptr(string_offset(string2)) };
let mut string1 = cstring1.to_str().expect("to_str").to_string();
Expand All @@ -125,35 +125,35 @@ extern fn concat(string1: *const c_char, string2: *const c_char) -> *const c_cha
}

#[no_mangle]
extern fn stringEqual(string1: *const c_char, string2: *const c_char) -> i64 {
extern "C" fn stringEqual(string1: *const c_char, string2: *const c_char) -> i64 {
let cstring1 = unsafe { CStr::from_ptr(string_offset(string1)) };
let cstring2 = unsafe { CStr::from_ptr(string_offset(string2)) };
(cstring1 == cstring2) as i64
}

#[no_mangle]
extern fn allocClass(data_layout: *const c_char) -> i64 {
extern "C" fn allocClass(data_layout: *const c_char) -> i64 {
GARBAGE_COLLECTOR.with(|collector| {
collector.borrow_mut().allocate(Layout::Class(data_layout))
})
}

#[no_mangle]
extern fn allocRecord(data_layout: *const c_char) -> i64 {
extern "C" fn allocRecord(data_layout: *const c_char) -> i64 {
GARBAGE_COLLECTOR.with(|collector| {
collector.borrow_mut().allocate(Layout::Record(data_layout))
})
}

#[no_mangle]
extern fn initArray(length: usize, is_pointer: i64) -> i64 {
extern "C" fn initArray(length: usize, is_pointer: i64) -> i64 {
GARBAGE_COLLECTOR.with(|collector| {
collector.borrow_mut().allocate(Layout::Array(length, is_pointer != 0))
})
}

#[no_mangle]
extern fn print(string: *const c_char) {
extern "C" fn print(string: *const c_char) {
let cstring = unsafe { CStr::from_ptr(string_offset(string)) };
if let Ok(string) = cstring.to_str() {
print!("{}", string);
Expand All @@ -162,14 +162,14 @@ extern fn print(string: *const c_char) {
}

#[no_mangle]
extern fn printP(string: *const c_char, continuation: *const c_void) {
extern "C" fn printP(string: *const c_char, continuation: *const c_void) {
print(string);
let function = get_function_pointer(continuation);
function();
}

#[no_mangle]
extern fn printi(num: i32) {
extern "C" fn printi(num: i32) {
println!("{}", num);
}

Expand Down
2 changes: 2 additions & 0 deletions tiger/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ fn test_execution() {
if output != expected_output {
success = false;
println!(" FAIL");
println!("Expected: {}", expected_output);
println!("Actual: {}\n====================", output);
failure_count += 1;
}
else {
Expand Down

0 comments on commit 319e957

Please sign in to comment.