20 lines · c
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#else16# error "Fix your compiler's __BYTE_ORDER__?!"17#endif18 19#endif20