18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Linux/PA-RISC Project (http://www.parisc-linux.org/)
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Floating-point emulation code
68c2ecf20Sopenharmony_ci *  Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifdef __NO_PA_HDRS
108c2ecf20Sopenharmony_ci    PA header file -- do not include this header file for non-PA builds.
118c2ecf20Sopenharmony_ci#endif
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/*
158c2ecf20Sopenharmony_ci *  These macros are designed to be portable to all machines that have
168c2ecf20Sopenharmony_ci *  a wordsize greater than or equal to 32 bits that support the portable
178c2ecf20Sopenharmony_ci *  C compiler and the standard C preprocessor.  Wordsize (default 32)
188c2ecf20Sopenharmony_ci *  and bitfield assignment (default left-to-right,  unlike VAX, PDP-11)
198c2ecf20Sopenharmony_ci *  should be predefined using the constants HOSTWDSZ and BITFRL and
208c2ecf20Sopenharmony_ci *  the C compiler "-D" flag (e.g., -DHOSTWDSZ=36 -DBITFLR for the DEC-20).
218c2ecf20Sopenharmony_ci *  Note that the macro arguments assume that the integer being referenced
228c2ecf20Sopenharmony_ci *  is a 32-bit integer (right-justified on the 20) and that bit 0 is the
238c2ecf20Sopenharmony_ci *  most significant bit.
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#ifndef HOSTWDSZ
278c2ecf20Sopenharmony_ci#define	HOSTWDSZ	32
288c2ecf20Sopenharmony_ci#endif
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/*###########################  Macros  ######################################*/
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*-------------------------------------------------------------------------
348c2ecf20Sopenharmony_ci * NewDeclareBitField_Reference - Declare a structure similar to the simulator
358c2ecf20Sopenharmony_ci * function "DeclBitfR" except its use is restricted to occur within a larger
368c2ecf20Sopenharmony_ci * enclosing structure or union definition.  This declaration is an unnamed
378c2ecf20Sopenharmony_ci * structure with the argument, name, as the member name and the argument,
388c2ecf20Sopenharmony_ci * uname, as the element name.
398c2ecf20Sopenharmony_ci *----------------------------------------------------------------------- */
408c2ecf20Sopenharmony_ci#define Bitfield_extract(start, length, object) 	\
418c2ecf20Sopenharmony_ci    ((object) >> (HOSTWDSZ - (start) - (length)) & 	\
428c2ecf20Sopenharmony_ci    ((unsigned)-1 >> (HOSTWDSZ - (length))))
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define Bitfield_signed_extract(start, length, object) \
458c2ecf20Sopenharmony_ci    ((int)((object) << start) >> (HOSTWDSZ - (length)))
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define Bitfield_mask(start, len, object)		\
488c2ecf20Sopenharmony_ci    ((object) & (((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len)))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define Bitfield_deposit(value,start,len,object)  object = \
518c2ecf20Sopenharmony_ci    ((object) & ~(((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len))) | \
528c2ecf20Sopenharmony_ci    (((value) & ((unsigned)-1 >> (HOSTWDSZ-len))) << (HOSTWDSZ-start-len))
53