在 2019/1/23 9:27, Zebediah Figura 写道: > This provides memcmp() for x86 kernel-mode drivers, which for some reason is > not exported from ntoskrnl like other CRT functions. > > The implementation was copied and modified from wmemcmp.c in libmingwex. > > v3: fix types, restrict to i386 > ---
> +
> +int __cdecl memcmp(const void *_S1, const void *_S2, size_t _N)
> +{
> + const char *s1 = _S1, *s2 = _S2;
> +
I have requested you use `unsigned char *` here or you will get
erroneous results because `char` is signed by default on Windows.
> + if (_N == 0 || s1 == s2)
> + return 0; /* even for NULL pointers */
> +
> + if ((s1 != NULL) != (s2 != NULL))
> + return s2 == NULL ? 1 : -1; /* robust */
> +
> + for ( ; 0 < _N; ++s1, ++s2, --_N)
> + if (*s1 != *s2)
> + return (*s1 < *s2 ? -1 : +1);
> +
> + return 0;
> +}
> +
>
--
Best regards,
LH_Mouse
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
