diff --git a/core/runtime/procs.odin b/core/runtime/procs.odin index 782efa773..510abcbb9 100644 --- a/core/runtime/procs.odin +++ b/core/runtime/procs.odin @@ -6,7 +6,7 @@ when ODIN_NO_CRT && ODIN_OS == .Windows { @(private="file") @(default_calling_convention="stdcall") foreign lib { - RtlMoveMemory :: proc(dst, src: rawptr, length: int) --- + RtlMoveMemory :: proc(dst, s: rawptr, length: int) --- RtlFillMemory :: proc(dst: rawptr, length: int, fill: i32) --- } @@ -40,24 +40,34 @@ when ODIN_NO_CRT && ODIN_OS == .Windows { @(link_name="memmove", linkage="strong", require) memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr { - if dst != src { - d, s := ([^]byte)(dst), ([^]byte)(src) + d, s := ([^]byte)(dst), ([^]byte)(src) + if d == s || len == 0 { + return dst + } + if d > s && uintptr(d)-uintptr(s) < uintptr(len) { for i := len-1; i >= 0; i -= 1 { d[i] = s[i] } + return dst } - return dst - + + if s > d && uintptr(s)-uintptr(d) < uintptr(len) { + for i := 0; i < len; i += 1 { + d[i] = s[i] + } + return dst + } + return memcpy(dst, src, len) } @(link_name="memcpy", linkage="strong", require) memcpy :: proc "c" (dst, src: rawptr, len: int) -> rawptr { - if dst != src { - d, s := ([^]byte)(dst), ([^]byte)(src) - for i := len-1; i >= 0; i -= 1 { + d, s := ([^]byte)(dst), ([^]byte)(src) + if d != s { + for i := 0; i < len; i += 1 { d[i] = s[i] } } - return dst + return d } } else { diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 284936852..f055b6908 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -290,10 +290,10 @@ foreign kernel32 { InitializeSRWLock :: proc(SRWLock: ^SRWLOCK) --- AcquireSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) --- - TryAcquireSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) -> BOOL --- + TryAcquireSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) -> BOOLEAN --- ReleaseSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) --- AcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) --- - TryAcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) -> BOOL --- + TryAcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) -> BOOLEAN --- ReleaseSRWLockShared :: proc(SRWLock: ^SRWLOCK) --- InitializeConditionVariable :: proc(ConditionVariable: ^CONDITION_VARIABLE) --- diff --git a/src/gb/gb.h b/src/gb/gb.h index d09c7618b..90f2fd15a 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -90,7 +90,7 @@ extern "C" { #error This operating system is not supported #endif -#if defined(GB_SYSTEM_OPENBSD) +#if defined(GB_SYSTEM_UNIX) #include #endif