mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
add actual folly implementation of memcpy
This commit is contained in:
parent
77624f627b
commit
0e2c3e4723
4 changed files with 460 additions and 3 deletions
|
@ -2,6 +2,7 @@ const std = @import("std");
|
|||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const musl = @import("libc/musl.zig");
|
||||
const folly = @import("libc/folly.zig");
|
||||
const cpuid = @import("libc/cpuid.zig");
|
||||
|
||||
comptime {
|
||||
|
@ -12,7 +13,7 @@ comptime {
|
|||
const Memcpy = fn (noalias [*]u8, noalias [*]const u8, len: usize) callconv(.C) [*]u8;
|
||||
|
||||
pub var memcpy_target: Memcpy = switch (arch) {
|
||||
// TODO(): Switch to dispatch_memcpy once the surgical linker can support it.
|
||||
// TODO: Switch to dispatch_memcpy once the surgical linker can support it.
|
||||
// .x86_64 => dispatch_memcpy,
|
||||
.x86_64 => musl.memcpy,
|
||||
else => unreachable,
|
||||
|
@ -48,9 +49,9 @@ fn dispatch_memcpy(noalias dest: [*]u8, noalias src: [*]const u8, len: usize) ca
|
|||
.x86_64 => {
|
||||
if (cpuid.supports_avx2()) {
|
||||
if (cpuid.supports_prefetchw()) {
|
||||
memcpy_target = musl.memcpy;
|
||||
memcpy_target = folly.memcpy_prefetchw;
|
||||
} else {
|
||||
memcpy_target = musl.memcpy;
|
||||
memcpy_target = folly.memcpy_prefetcht0;
|
||||
}
|
||||
} else {
|
||||
memcpy_target = musl.memcpy;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue