zig/lib/libc/mingw/misc/winbs_ulong.c
Andrew Kelley 49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00

21 lines
599 B
C

unsigned long __cdecl _byteswap_ulong (unsigned long _Long);
unsigned long __cdecl _byteswap_ulong (unsigned long _Long)
{
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
unsigned long retval;
__asm__ __volatile__ ("bswapl %[retval]" : [retval] "=rm" (retval) : "[retval]" (_Long));
return retval;
#else
unsigned char *b = (void*)&_Long;
unsigned char tmp;
tmp = b[0];
b[0] = b[3];
b[3] = tmp;
tmp = b[1];
b[1] = b[2];
b[2] = tmp;
return _Long;
#endif /* defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) */
}