1 /*
2 Copyright (C) 2000, 2002 Andreas Gruenbacher <agruen@suse.de>
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifdef WORDS_BIGENDIAN
19 # define cpu_to_le16(w16) le16_to_cpu(w16)
20 # define le16_to_cpu(w16) ((u_int16_t)((u_int16_t)(w16) >> 8) | \
21 (u_int16_t)((u_int16_t)(w16) << 8))
22 # define cpu_to_le32(w32) le32_to_cpu(w32)
23 # define le32_to_cpu(w32) ((u_int32_t)( (u_int32_t)(w32) >>24) | \
24 (u_int32_t)(((u_int32_t)(w32) >> 8) & 0xFF00) | \
25 (u_int32_t)(((u_int32_t)(w32) << 8) & 0xFF0000) | \
26 (u_int32_t)( (u_int32_t)(w32) <<24))
27 #else
28 # define cpu_to_le16(w16) ((u_int16_t)(w16))
29 # define le16_to_cpu(w16) ((u_int16_t)(w16))
30 # define cpu_to_le32(w32) ((u_int32_t)(w32))
31 # define le32_to_cpu(w32) ((u_int32_t)(w32))
32 #endif
33