1999-02-05 19:34:13 +03:00
|
|
|
/* $NetBSD: bswap64.c,v 1.3 1999/02/05 16:34:13 bouyer Exp $ */
|
1997-10-09 19:42:19 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Written by Manuel Bouyer <bouyer@netbsd.org>.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
1999-01-15 16:31:15 +03:00
|
|
|
#include <sys/cdefs.h>
|
1997-10-09 19:42:19 +04:00
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
1999-02-05 19:34:13 +03:00
|
|
|
__RCSID("$NetBSD: bswap64.c,v 1.3 1999/02/05 16:34:13 bouyer Exp $");
|
1999-01-15 16:31:15 +03:00
|
|
|
#endif /* LIBC_SCCS and not lint */
|
1997-10-09 19:42:19 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
1999-01-15 16:31:15 +03:00
|
|
|
#include <machine/bswap.h>
|
1997-10-09 19:42:19 +04:00
|
|
|
|
|
|
|
#undef bswap64
|
|
|
|
|
|
|
|
u_int64_t
|
|
|
|
bswap64(x)
|
1999-01-15 16:31:15 +03:00
|
|
|
u_int64_t x;
|
|
|
|
{
|
1999-02-05 19:34:13 +03:00
|
|
|
u_int32_t *p = (u_int32_t*)(void *)&x;
|
1997-10-09 19:42:19 +04:00
|
|
|
u_int32_t t;
|
|
|
|
t = bswap32(p[0]);
|
|
|
|
p[0] = bswap32(p[1]);
|
|
|
|
p[1] = t;
|
|
|
|
return x;
|
1999-01-15 16:31:15 +03:00
|
|
|
}
|