Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / lib / libstand / bswap.c
1 /*
2  * Written by Manuel Bouyer <bouyer@netbsd.org>.
3  * Public domain.
4  *
5  * $NetBSD: bswap32.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $
6  * $NetBSD: bswap64.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $
7  */
8
9 #include <sys/types.h>
10
11 #undef bswap32
12 #undef bswap64
13
14 u_int32_t
15 bswap32(x)
16     u_int32_t x;
17 {
18         return  ((x << 24) & 0xff000000 ) |
19                         ((x <<  8) & 0x00ff0000 ) |
20                         ((x >>  8) & 0x0000ff00 ) |
21                         ((x >> 24) & 0x000000ff );
22 }
23
24 u_int64_t
25 bswap64(x)
26     u_int64_t x;
27 {  
28         u_int32_t *p = (u_int32_t*)&x;
29         u_int32_t t;
30         t = bswap32(p[0]);
31         p[0] = bswap32(p[1]);
32         p[1] = t;
33         return x;
34 }   
35