1 1.3.44.1 martin /* $NetBSD: bswap32.c,v 1.3.44.2 2020/04/21 19:37:49 martin Exp $ */ 2 1.1 christos 3 1.1 christos /* 4 1.1 christos * Written by Manuel Bouyer <bouyer (at) NetBSD.org>. 5 1.1 christos * Public domain. 6 1.1 christos */ 7 1.1 christos 8 1.1 christos #include <sys/cdefs.h> 9 1.1 christos #if defined(LIBC_SCCS) && !defined(lint) 10 1.3.44.1 martin __RCSID("$NetBSD: bswap32.c,v 1.3.44.2 2020/04/21 19:37:49 martin Exp $"); 11 1.1 christos #endif /* LIBC_SCCS and not lint */ 12 1.1 christos 13 1.1 christos #include <sys/types.h> 14 1.1 christos #include <machine/bswap.h> 15 1.1 christos 16 1.1 christos #undef bswap32 17 1.1 christos 18 1.2 apb uint32_t 19 1.3 joerg bswap32(uint32_t x) 20 1.1 christos { 21 1.1 christos return ((x << 24) & 0xff000000 ) | 22 1.1 christos ((x << 8) & 0x00ff0000 ) | 23 1.1 christos ((x >> 8) & 0x0000ff00 ) | 24 1.1 christos ((x >> 24) & 0x000000ff ); 25 1.1 christos } 26