remove all definitions of roc_memcpy

This commit is contained in:
Brendan Hansknecht 2023-06-01 23:04:38 -07:00
parent ebc6bd3f45
commit 75a035e12d
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
53 changed files with 32 additions and 284 deletions

View file

@ -48,10 +48,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(16, @ptrCast([*]u8, c_ptr))); free(@alignCast(16, @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -47,10 +47,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(16, @ptrCast([*]u8, c_ptr))); free(@alignCast(16, @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -48,10 +48,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(16, @ptrCast([*]u8, c_ptr))); free(@alignCast(16, @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -73,10 +73,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -72,10 +72,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -77,10 +77,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -67,10 +67,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -49,7 +49,6 @@ comptime {
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong }); @export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong }); @export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong }); @export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
@export(testing_roc_memcpy, .{ .name = "roc_memcpy", .linkage = .Strong });
if (builtin.os.tag == .macos or builtin.os.tag == .linux) { if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
@export(testing_roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong }); @export(testing_roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
@ -83,14 +82,6 @@ fn testing_roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
@panic("Roc panicked"); @panic("Roc panicked");
} }
fn testing_roc_memcpy(dest: *anyopaque, src: *anyopaque, bytes: usize) callconv(.C) ?*anyopaque {
const zig_dest = @ptrCast([*]u8, dest);
const zig_src = @ptrCast([*]u8, src);
@memcpy(zig_dest, zig_src, bytes);
return dest;
}
pub fn alloc(size: usize, alignment: u32) ?[*]u8 { pub fn alloc(size: usize, alignment: u32) ?[*]u8 {
return @ptrCast(?[*]u8, roc_alloc(size, alignment)); return @ptrCast(?[*]u8, roc_alloc(size, alignment));
} }
@ -103,10 +94,6 @@ pub fn dealloc(c_ptr: [*]u8, alignment: u32) void {
return roc_dealloc(c_ptr, alignment); return roc_dealloc(c_ptr, alignment);
} }
pub fn memcpy(dst: [*]u8, src: [*]u8, size: usize) void {
roc_memcpy(dst, src, size);
}
// indirection because otherwise zig creates an alias to the panic function which our LLVM code // indirection because otherwise zig creates an alias to the panic function which our LLVM code
// does not know how to deal with // does not know how to deal with
pub fn test_panic(c_ptr: *anyopaque, crash_tag: u32) callconv(.C) void { pub fn test_panic(c_ptr: *anyopaque, crash_tag: u32) callconv(.C) void {

View file

@ -289,11 +289,6 @@ mod dummy_platform_functions {
unimplemented!("It is not valid to call roc panic from within the compiler. Please use the \"platform\" feature if this is a platform.") unimplemented!("It is not valid to call roc panic from within the compiler. Please use the \"platform\" feature if this is a platform.")
} }
#[no_mangle]
pub fn roc_memcpy(_dst: *mut c_void, _src: *mut c_void, _n: usize) -> *mut c_void {
unimplemented!("It is not valid to call roc memcpy from within the compiler. Please use the \"platform\" feature if this is a platform.")
}
#[no_mangle] #[no_mangle]
pub fn roc_memset(_dst: *mut c_void, _c: i32, _n: usize) -> *mut c_void { pub fn roc_memset(_dst: *mut c_void, _c: i32, _n: usize) -> *mut c_void {
unimplemented!("It is not valid to call roc memset from within the compiler. Please use the \"platform\" feature if this is a platform.") unimplemented!("It is not valid to call roc memset from within the compiler. Please use the \"platform\" feature if this is a platform.")

View file

@ -7,13 +7,6 @@ pub unsafe fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void {
libc::malloc(size) libc::malloc(size)
} }
/// # Safety
/// The Roc application needs this.
#[no_mangle]
pub unsafe fn roc_memcpy(dest: *mut c_void, src: *const c_void, bytes: usize) -> *mut c_void {
libc::memcpy(dest, src, bytes)
}
/// # Safety /// # Safety
/// The Roc application needs this. /// The Roc application needs this.
#[no_mangle] #[no_mangle]

View file

@ -134,13 +134,6 @@ void roc_panic(void* msg, unsigned int tag_id)
//-------------------------- //--------------------------
void roc_memcpy(void *dest, const void *src, size_t n)
{
memcpy(dest, src, n);
}
//--------------------------
void *roc_memset(void *str, int c, size_t n) void *roc_memset(void *str, int c, size_t n)
{ {
return memset(str, c, n); return memset(str, c, n);

View file

@ -78,11 +78,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -49,11 +49,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -71,11 +71,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -13,7 +13,7 @@ pub extern "C" fn rust_main() -> i32 {
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::hash_set::HashSet; use std::collections::hash_set::HashSet;
let tag_union = test_glue::mainForHost(()); let tag_union = test_glue::mainForHost(());
// Verify that it has all the expected traits. // Verify that it has all the expected traits.
@ -89,11 +89,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -75,11 +75,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -88,11 +88,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -76,11 +76,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -73,11 +73,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -91,11 +91,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -87,11 +87,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -102,11 +102,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -51,11 +51,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -51,11 +51,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -51,11 +51,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -77,11 +77,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -82,11 +82,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -79,11 +79,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -64,13 +64,6 @@ void roc_panic(void *ptr, unsigned int alignment)
//-------------------------- //--------------------------
void *roc_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
//--------------------------
void *roc_memset(void *str, int c, size_t n) void *roc_memset(void *str, int c, size_t n)
{ {
return memset(str, c, n); return memset(str, c, n);

View file

@ -36,7 +36,6 @@ extern "C" {
) -> *mut c_void; ) -> *mut c_void;
pub fn roc_dealloc(ptr: *mut c_void, alignment: u32); pub fn roc_dealloc(ptr: *mut c_void, alignment: u32);
pub fn roc_panic(c_ptr: *mut c_void, tag_id: u32); pub fn roc_panic(c_ptr: *mut c_void, tag_id: u32);
pub fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void;
pub fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void; pub fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void;
} }

View file

@ -45,12 +45,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[cfg(test)]
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[cfg(test)] #[cfg(test)]
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {

View file

@ -67,10 +67,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -9,7 +9,7 @@ use core::mem::MaybeUninit;
use glue::Metadata; use glue::Metadata;
use roc_std::{RocDict, RocList, RocResult, RocStr}; use roc_std::{RocDict, RocList, RocResult, RocStr};
use std::borrow::{Borrow, Cow}; use std::borrow::{Borrow, Cow};
use std::ffi::{ OsStr}; use std::ffi::OsStr;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
@ -199,11 +199,6 @@ fn display_roc_fn(module_name: &str, fn_name: &str) -> String {
format!("\u{001B}[36m{module_name}\u{001B}[39m.{fn_name}") format!("\u{001B}[36m{module_name}\u{001B}[39m.{fn_name}")
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -81,10 +81,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -61,11 +61,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -136,10 +136,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -44,11 +44,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -196,11 +196,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -38,11 +38,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -42,11 +42,6 @@ void roc_dealloc(void *ptr, unsigned int alignment)
free(ptr); free(ptr);
} }
void *roc_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
void *roc_memset(void *str, int c, size_t n) void *roc_memset(void *str, int c, size_t n)
{ {
return memset(str, c, n); return memset(str, c, n);

View file

@ -27,11 +27,6 @@ void roc_panic(void *ptr, unsigned int alignment)
napi_throw_error(napi_global_env, NULL, (char *)ptr); napi_throw_error(napi_global_env, NULL, (char *)ptr);
} }
void *roc_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); } void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); }
// Reference counting // Reference counting

View file

@ -33,10 +33,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr))); free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dest: *anyopaque, src: *anyopaque, count: usize) callconv(.C) void {
_ = memcpy(dest, src, count);
}
// NOTE roc_panic is provided in the JS file, so it can throw an exception // NOTE roc_panic is provided in the JS file, so it can throw an exception
extern fn roc__mainForHost_1_exposed(*RocStr) void; extern fn roc__mainForHost_1_exposed(*RocStr) void;

View file

@ -30,10 +30,6 @@ void roc_panic(void* ptr, unsigned int alignment) {
exit(0); exit(0);
} }
void* roc_memcpy(void* dest, const void* src, size_t n) {
return memcpy(dest, src, n);
}
void* roc_memset(void* str, int c, size_t n) { return memset(str, c, n); } void* roc_memset(void* str, int c, size_t n) { return memset(str, c, n); }
int roc_shm_open(char* name, int oflag, int mode) { int roc_shm_open(char* name, int oflag, int mode) {

View file

@ -44,11 +44,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
libc::memcpy(dst, src, n)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)

View file

@ -33,10 +33,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr))); free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dest: *anyopaque, src: *anyopaque, count: usize) callconv(.C) void {
_ = memcpy(dest, src, count);
}
// NOTE roc_panic is provided in the JS file, so it can throw an exception // NOTE roc_panic is provided in the JS file, so it can throw an exception
extern fn roc__mainForHost_1_exposed(*RocStr) void; extern fn roc__mainForHost_1_exposed(*RocStr) void;

View file

@ -67,10 +67,6 @@ export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
std.process.exit(0); std.process.exit(0);
} }
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void { export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size); return memset(dst, value, size);
} }

View file

@ -27,11 +27,6 @@ __attribute__((noreturn)) void roc_panic(void *ptr, unsigned int alignment)
PyErr_SetString(PyExc_RuntimeError, (char *)ptr); PyErr_SetString(PyExc_RuntimeError, (char *)ptr);
} }
void *roc_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); } void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); }
// Reference counting // Reference counting

View file

@ -24,10 +24,6 @@ void roc_panic(void* ptr, unsigned int alignment) {
exit(0); exit(0);
} }
void* roc_memcpy(void* dest, const void* src, size_t n) {
return memcpy(dest, src, n);
}
void* roc_memset(void* str, int c, size_t n) { return memset(str, c, n); } void* roc_memset(void* str, int c, size_t n) { return memset(str, c, n); }
int roc_shm_open(char* name, int oflag, int mode) { int roc_shm_open(char* name, int oflag, int mode) {

View file

@ -23,11 +23,6 @@ __attribute__((noreturn)) void roc_panic(void *ptr, unsigned int alignment)
rb_raise(rb_eException, "%s", (char *)ptr); rb_raise(rb_eException, "%s", (char *)ptr);
} }
void *roc_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); } void *roc_memset(void *str, int c, size_t n) { return memset(str, c, n); }
// Reference counting // Reference counting

View file

@ -24,10 +24,6 @@ void roc_panic(void* ptr, unsigned int alignment) {
exit(0); exit(0);
} }
void* roc_memcpy(void* dest, const void* src, size_t n) {
return memcpy(dest, src, n);
}
void* roc_memmove(void* dest, const void* src, size_t n){ void* roc_memmove(void* dest, const void* src, size_t n){
return memmove(dest, src, n); return memmove(dest, src, n);
} }

View file

@ -9,10 +9,10 @@ use std::os::raw::c_char;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use syntect::easy::HighlightLines; use syntect::easy::HighlightLines;
use syntect::highlighting::{Style, ThemeSet};
use syntect::html::{ClassStyle, ClassedHTMLGenerator};
use syntect::parsing::SyntaxSet; use syntect::parsing::SyntaxSet;
use syntect::highlighting::{ThemeSet, Style}; use syntect::util::LinesWithEndings;
use syntect::util::{LinesWithEndings};
use syntect::html::{ClassedHTMLGenerator, ClassStyle};
extern "C" { extern "C" {
#[link_name = "roc__transformFileContentForHost_1_exposed"] #[link_name = "roc__transformFileContentForHost_1_exposed"]
@ -98,15 +98,6 @@ pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
} }
} }
#[no_mangle]
pub unsafe extern "C" fn roc_memcpy(
dest: *mut c_void,
src: *const c_void,
bytes: usize,
) -> *mut c_void {
libc::memcpy(dest, src, bytes)
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void { pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
libc::memset(dst, c, n) libc::memset(dst, c, n)
@ -216,9 +207,9 @@ fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Resul
// And track a little bit of state // And track a little bit of state
let mut in_code_block = false; let mut in_code_block = false;
let mut is_roc_code = false; let mut is_roc_code = false;
let syntax_set : syntect::parsing::SyntaxSet = SyntaxSet::load_defaults_newlines(); let syntax_set: syntect::parsing::SyntaxSet = SyntaxSet::load_defaults_newlines();
let theme_set : syntect::highlighting::ThemeSet = ThemeSet::load_defaults(); let theme_set: syntect::highlighting::ThemeSet = ThemeSet::load_defaults();
for event in parser { for event in parser {
match event { match event {
pulldown_cmark::Event::Code(code_str) => { pulldown_cmark::Event::Code(code_str) => {
@ -227,23 +218,25 @@ fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Resul
.strip_prefix("roc!") .strip_prefix("roc!")
.expect("expected leading 'roc!'"); .expect("expected leading 'roc!'");
let highlighted_html = roc_highlight::highlight_roc_code_inline(stripped.to_string().as_str()); let highlighted_html =
roc_highlight::highlight_roc_code_inline(stripped.to_string().as_str());
parser_with_highlighting.push(pulldown_cmark::Event::Html( parser_with_highlighting.push(pulldown_cmark::Event::Html(
pulldown_cmark::CowStr::from(highlighted_html), pulldown_cmark::CowStr::from(highlighted_html),
)); ));
} else { } else {
let inline_code = pulldown_cmark::CowStr::from(format!("<code>{}</code>", code_str)); let inline_code =
parser_with_highlighting.push( pulldown_cmark::CowStr::from(format!("<code>{}</code>", code_str));
pulldown_cmark::Event::Html(inline_code) parser_with_highlighting.push(pulldown_cmark::Event::Html(inline_code));
);
} }
} }
pulldown_cmark::Event::Start(pulldown_cmark::Tag::CodeBlock(cbk)) => { pulldown_cmark::Event::Start(pulldown_cmark::Tag::CodeBlock(cbk)) => {
in_code_block = true; in_code_block = true;
is_roc_code = is_roc_code_block(&cbk); is_roc_code = is_roc_code_block(&cbk);
} }
pulldown_cmark::Event::End(pulldown_cmark::Tag::CodeBlock(pulldown_cmark::CodeBlockKind::Fenced(extention_str))) => { pulldown_cmark::Event::End(pulldown_cmark::Tag::CodeBlock(
pulldown_cmark::CodeBlockKind::Fenced(extention_str),
)) => {
if in_code_block { if in_code_block {
match replace_code_with_static_file(&code_to_highlight, input_file) { match replace_code_with_static_file(&code_to_highlight, input_file) {
None => {} None => {}
@ -263,13 +256,19 @@ fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Resul
if is_roc_code { if is_roc_code {
highlighted_html = roc_highlight::highlight_roc_code(&code_to_highlight) highlighted_html = roc_highlight::highlight_roc_code(&code_to_highlight)
} else if let Some(syntax) = syntax_set.find_syntax_by_token(&extention_str) { } else if let Some(syntax) = syntax_set.find_syntax_by_token(&extention_str) {
let mut h = HighlightLines::new(syntax, &theme_set.themes["base16-ocean.dark"]); let mut h =
HighlightLines::new(syntax, &theme_set.themes["base16-ocean.dark"]);
let mut html_generator = ClassedHTMLGenerator::new_with_class_style(syntax, &syntax_set, ClassStyle::Spaced); let mut html_generator = ClassedHTMLGenerator::new_with_class_style(
syntax,
&syntax_set,
ClassStyle::Spaced,
);
for line in LinesWithEndings::from(&code_to_highlight) { for line in LinesWithEndings::from(&code_to_highlight) {
html_generator.parse_html_for_line_which_includes_newline(line); html_generator.parse_html_for_line_which_includes_newline(line);
} }
highlighted_html = format!("<pre><samp>{}</pre></samp>", html_generator.finalize()) highlighted_html =
format!("<pre><samp>{}</pre></samp>", html_generator.finalize())
} else { } else {
highlighted_html = format!("<pre><samp>{}</pre></samp>", &code_to_highlight) highlighted_html = format!("<pre><samp>{}</pre></samp>", &code_to_highlight)
} }
@ -362,12 +361,11 @@ fn is_roc_code_block(cbk: &pulldown_cmark::CodeBlockKind) -> bool {
fn replace_code_with_static_file(code: &str, input_file: &Path) -> Option<String> { fn replace_code_with_static_file(code: &str, input_file: &Path) -> Option<String> {
let input_dir = input_file.parent()?; let input_dir = input_file.parent()?;
let trimmed_code = code.trim(); let trimmed_code = code.trim();
// Confirm the code block starts with a `file:` tag // Confirm the code block starts with a `file:` tag
match trimmed_code.strip_prefix("file:") { match trimmed_code.strip_prefix("file:") {
None => None, None => None,
Some(path) => { Some(path) => {
// File must be located in input folder or sub-directory // File must be located in input folder or sub-directory
if path.contains("../") { if path.contains("../") {
panic!("ERROR File must be located within the input diretory!"); panic!("ERROR File must be located within the input diretory!");
@ -378,7 +376,10 @@ fn replace_code_with_static_file(code: &str, input_file: &Path) -> Option<String
// Check file exists before opening // Check file exists before opening
match file_path.try_exists() { match file_path.try_exists() {
Err(_) | Ok(false) => { Err(_) | Ok(false) => {
panic!("ERROR File does not exist: \"{}\"", file_path.to_str().unwrap()); panic!(
"ERROR File does not exist: \"{}\"",
file_path.to_str().unwrap()
);
} }
Ok(true) => { Ok(true) => {
let vec_u8 = fs::read(file_path).ok()?; let vec_u8 = fs::read(file_path).ok()?;
@ -388,4 +389,4 @@ fn replace_code_with_static_file(code: &str, input_file: &Path) -> Option<String
} }
} }
} }
} }

View file

@ -28,10 +28,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr))); free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dest: *anyopaque, src: *anyopaque, count: usize) callconv(.C) void {
_ = memcpy(dest, src, count);
}
export fn roc_panic(message: RocStr, tag_id: u32) callconv(.C) void { export fn roc_panic(message: RocStr, tag_id: u32) callconv(.C) void {
_ = tag_id; _ = tag_id;
const msg = @ptrCast([*:0]const u8, c_ptr); const msg = @ptrCast([*:0]const u8, c_ptr);

View file

@ -28,10 +28,6 @@ export fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void {
free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr))); free(@alignCast(@alignOf(Align), @ptrCast([*]u8, c_ptr)));
} }
export fn roc_memcpy(dest: *anyopaque, src: *anyopaque, count: usize) callconv(.C) void {
_ = memcpy(dest, src, count);
}
export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void { export fn roc_panic(c_ptr: *anyopaque, tag_id: u32) callconv(.C) void {
_ = tag_id; _ = tag_id;
const msg = @ptrCast([*:0]const u8, c_ptr); const msg = @ptrCast([*:0]const u8, c_ptr);