1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __BIND_PROG_H__
3 #define __BIND_PROG_H__
4 
5 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
6 #define load_byte(src, b, s) \
7 	(((volatile __u8 *)&(src))[b] << 8 * b)
8 #define load_word(src, w, s) \
9 	(((volatile __u16 *)&(src))[w] << 16 * w)
10 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
11 #define load_byte(src, b, s) \
12 	(((volatile __u8 *)&(src))[(b) + (sizeof(src) - (s))] << 8 * ((s) - (b) - 1))
13 #define load_word(src, w, s) \
14 	(((volatile __u16 *)&(src))[w] << 16 * (((s) / 2) - (w) - 1))
15 #else
16 # error "Fix your compiler's __BYTE_ORDER__?!"
17 #endif
18 
19 #endif
20