ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/byteswap.c
Revision: 3.1
Committed: Sat Dec 23 17:27:45 2006 UTC (17 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R0, rad3R9, rad4R2P1, rad5R3
Log Message:
Added byte-swapping i/o options to rcalc

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * Byte swapping routines
6 *
7 * External symbols declared in rtio.h
8 */
9
10 #include "copyright.h"
11 #include "rtio.h"
12
13 void
14 swap16( /* swap n 16-bit words */
15 register char *wp,
16 int n
17 )
18 {
19 register int t;
20
21 while (n-- > 0) {
22 t = wp[0]; wp[0] = wp[1]; wp[1] = t;
23 wp += 2;
24 }
25 }
26
27
28 void
29 swap32( /* swap n 32-bit words */
30 register char *wp,
31 int n
32 )
33 {
34 register int t;
35
36 while (n-- > 0) {
37 t = wp[0]; wp[0] = wp[3]; wp[3] = t;
38 t = wp[1]; wp[1] = wp[2]; wp[2] = t;
39 wp += 4;
40 }
41 }
42
43
44 void
45 swap64( /* swap n 64-bit words */
46 register char *wp,
47 int n
48 )
49 {
50 register int t;
51
52 while (n-- > 0) {
53 t = wp[0]; wp[0] = wp[7]; wp[7] = t;
54 t = wp[1]; wp[1] = wp[6]; wp[6] = t;
55 t = wp[2]; wp[2] = wp[5]; wp[5] = t;
56 t = wp[3]; wp[3] = wp[4]; wp[4] = t;
57 wp += 8;
58 }
59 }
60