fpbits.h 2.1 KB

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