^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Linux/PA-RISC Project (http://www.parisc-linux.org/)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Floating-point emulation code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifdef __NO_PA_HDRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) PA header file -- do not include this header file for non-PA builds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * These macros are designed to be portable to all machines that have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * a wordsize greater than or equal to 32 bits that support the portable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * C compiler and the standard C preprocessor. Wordsize (default 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * and bitfield assignment (default left-to-right, unlike VAX, PDP-11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * should be predefined using the constants HOSTWDSZ and BITFRL and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * the C compiler "-D" flag (e.g., -DHOSTWDSZ=36 -DBITFLR for the DEC-20).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Note that the macro arguments assume that the integer being referenced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * is a 32-bit integer (right-justified on the 20) and that bit 0 is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * most significant bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #ifndef HOSTWDSZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define HOSTWDSZ 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*########################### Macros ######################################*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /*-------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * NewDeclareBitField_Reference - Declare a structure similar to the simulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * function "DeclBitfR" except its use is restricted to occur within a larger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * enclosing structure or union definition. This declaration is an unnamed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * structure with the argument, name, as the member name and the argument,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * uname, as the element name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) *----------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define Bitfield_extract(start, length, object) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ((object) >> (HOSTWDSZ - (start) - (length)) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) ((unsigned)-1 >> (HOSTWDSZ - (length))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define Bitfield_signed_extract(start, length, object) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ((int)((object) << start) >> (HOSTWDSZ - (length)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define Bitfield_mask(start, len, object) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ((object) & (((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define Bitfield_deposit(value,start,len,object) object = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ((object) & ~(((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len))) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) (((value) & ((unsigned)-1 >> (HOSTWDSZ-len))) << (HOSTWDSZ-start-len))