2fe8fb192f
There is important information about booting non-ack images in docs/UPDATING. ack/aout-format images can't be built any more, and booting clang/ELF-format ones is a little different. Updating to the new boot monitor is recommended. Changes in this commit: . drop boot monitor -> allowing dropping ack support . facility to copy ELF boot files to /boot so that old boot monitor can still boot fairly easily, see UPDATING . no more ack-format libraries -> single-case libraries . some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases . drop several ack toolchain commands, but not all support commands (e.g. aal is gone but acksize is not yet). . a few libc files moved to netbsd libc dir . new /bin/date as minix date used code in libc/ . test compile fix . harmonize includes . /usr/lib is no longer special: without ack, /usr/lib plays no kind of special bootstrapping role any more and bootstrapping is done exclusively through packages, so releases depend even less on the state of the machine making them now. . rename nbsd_lib* to lib* . reduce mtree
79 lines
2.2 KiB
C
79 lines
2.2 KiB
C
/* $NetBSD: bswap.h,v 1.16 2009/08/08 21:23:15 christos Exp $ */
|
|
|
|
/* Written by Manuel Bouyer. Public domain */
|
|
|
|
#ifndef _SYS_BSWAP_H_
|
|
#define _SYS_BSWAP_H_
|
|
|
|
#ifndef _LOCORE
|
|
#include <sys/cdefs.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <machine/bswap.h>
|
|
|
|
__BEGIN_DECLS
|
|
/* Always declare the functions in case their address is taken (etc) */
|
|
#if defined(_KERNEL) || defined(_STANDALONE) || !defined(__BSWAP_RENAME)
|
|
uint16_t bswap16(uint16_t) __constfunc;
|
|
uint32_t bswap32(uint32_t) __constfunc;
|
|
#else
|
|
uint16_t bswap16(uint16_t) __RENAME(__bswap16) __constfunc;
|
|
uint32_t bswap32(uint32_t) __RENAME(__bswap32) __constfunc;
|
|
#endif
|
|
uint64_t bswap64(uint64_t) __constfunc;
|
|
__END_DECLS
|
|
|
|
#if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__lint__)
|
|
|
|
/* machine/byte_swap.h might have defined inline versions */
|
|
#ifndef __BYTE_SWAP_U64_VARIABLE
|
|
#define __BYTE_SWAP_U64_VARIABLE bswap64
|
|
#endif
|
|
|
|
#ifndef __BYTE_SWAP_U32_VARIABLE
|
|
#define __BYTE_SWAP_U32_VARIABLE bswap32
|
|
#endif
|
|
|
|
#ifndef __BYTE_SWAP_U16_VARIABLE
|
|
#define __BYTE_SWAP_U16_VARIABLE bswap16
|
|
#endif
|
|
|
|
#define __byte_swap_u64_constant(x) \
|
|
(__CAST(uint64_t, \
|
|
((((x) & 0xff00000000000000ull) >> 56) | \
|
|
(((x) & 0x00ff000000000000ull) >> 40) | \
|
|
(((x) & 0x0000ff0000000000ull) >> 24) | \
|
|
(((x) & 0x000000ff00000000ull) >> 8) | \
|
|
(((x) & 0x00000000ff000000ull) << 8) | \
|
|
(((x) & 0x0000000000ff0000ull) << 24) | \
|
|
(((x) & 0x000000000000ff00ull) << 40) | \
|
|
(((x) & 0x00000000000000ffull) << 56))))
|
|
|
|
#define __byte_swap_u32_constant(x) \
|
|
(__CAST(uint32_t, \
|
|
((((x) & 0xff000000) >> 24) | \
|
|
(((x) & 0x00ff0000) >> 8) | \
|
|
(((x) & 0x0000ff00) << 8) | \
|
|
(((x) & 0x000000ff) << 24))))
|
|
|
|
#define __byte_swap_u16_constant(x) \
|
|
(__CAST(uint16_t, \
|
|
((((x) & 0xff00) >> 8) | \
|
|
(((x) & 0x00ff) << 8))))
|
|
|
|
#define bswap64(x) \
|
|
(__builtin_constant_p((x)) ? \
|
|
__byte_swap_u64_constant(x) : __BYTE_SWAP_U64_VARIABLE(x))
|
|
|
|
#define bswap32(x) \
|
|
(__builtin_constant_p((x)) ? \
|
|
__byte_swap_u32_constant(x) : __BYTE_SWAP_U32_VARIABLE(x))
|
|
|
|
#define bswap16(x) \
|
|
(__builtin_constant_p((x)) ? \
|
|
__byte_swap_u16_constant(x) : __BYTE_SWAP_U16_VARIABLE(x))
|
|
|
|
#endif /* __GNUC__ && __OPTIMIZE__ */
|
|
#endif /* !_LOCORE */
|
|
|
|
#endif /* !_SYS_BSWAP_H_ */
|