ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/byteswap.c
Revision: 3.2
Committed: Fri Jan 15 18:31:38 2021 UTC (3 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, HEAD
Changes since 3.1: +10 -10 lines
Log Message:
More 64-bit addressing fixes

File Contents

# User Rev Content
1 greg 3.1 #ifndef lint
2 greg 3.2 static const char RCSid[] = "$Id: byteswap.c,v 3.1 2006/12/23 17:27:45 greg Exp $";
3 greg 3.1 #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 greg 3.2 char *wp,
16     size_t n
17 greg 3.1 )
18     {
19 greg 3.2 int t;
20 greg 3.1
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 greg 3.2 char *wp,
31     size_t n
32 greg 3.1 )
33     {
34 greg 3.2 int t;
35 greg 3.1
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 greg 3.2 char *wp,
47     size_t n
48 greg 3.1 )
49     {
50 greg 3.2 int t;
51 greg 3.1
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