libopenraw
endianutils.hpp
1 /*
2  * libopenraw - endiantutils.h
3  *
4  * Copyright (C) 2006 Hubert Figuiere
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef OR_INTERNALS_ENDIANUTILS_H_
22 #define OR_INTERNALS_ENDIANUTILS_H_
23 
24 #define EL16(b) \
25  ((b)[0] | ((b)[1] << 8))
26 
27 #define BE16(b) \
28  ((b)[1] | ((b)[0] << 8))
29 
30 #define EL32(b) \
31  ((b)[0] | ((b)[1] << 8) | ((b)[2] << 16) | ((b)[3] << 24))
32 
33 #define BE32(b) \
34  ((b)[3] | ((b)[2] << 8) | ((b)[1] << 16) | ((b)[0] << 24))
35 
36 
37 #endif
38