Island/Windows: Where is memcmp?

I am trying to find memcmp , but it seems not existing with Island RTL.

Instead, I found RtlCompareMemory, it seems to be a substitute for memcmp. But the return value of RtlCompareMemory doesn’t seem to be right - if two blocks of memory are the same, I would expect RtlCompareMemory returns 0 (just like memcmp does), but it will return the size of the memory. For example:
var a: Int64 := 1000;
var b: Int64 := 1000;

RtlCompareMemory(@a, @b, 8) will return 8, instead of 0. Is this intended? It is definitely not compatible with memcmp, which begs for another question: where is memcmp?

Should be in the rtf namespace?

U meant RTL namespace? If so, it doesn’t have RTL.memcmp

Ah, I misread, memcpy vs. memcmp. Is that a standard Win32 API? Where is it defined? if it is, this sounds like it might be an SDK import issue…

Thanks, logged as bugs://84575

Yes. It is part of C Runtime Library. https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/memcmp-wmemcmp?view=vs-2019

1 Like

The problem is that the Windows doesn’t have a C runtime. VC has one, but it’s not distributed with Windows by default. I’ll be implementing this one in the rtl.

Grab latest IslandRTL to fix (or wait for the build).

bugs://84575 got closed with status fixed.

@ck Thank u

But what is RtlCompareMemoy for?

Can Island’s memcmp optimize for 16-byte size comparison like other memcmp does?

RtlCompareMemory is a kernel32 function (which ends up doing the same and probably is more optimized than our default implementation)

That said, yes, our function can be optimized of course, what I wanted to go for is correct code first. I’ll log an issue for that separately.