u.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #define nil ((void*)0)
  10. typedef unsigned short ushort;
  11. typedef unsigned char uchar;
  12. typedef unsigned long ulong;
  13. typedef unsigned int uint;
  14. typedef signed char schar;
  15. typedef long long vlong;
  16. typedef unsigned long long uvlong;
  17. typedef unsigned long uintptr;
  18. typedef unsigned long usize;
  19. typedef uint Rune;
  20. typedef union FPdbleword FPdbleword;
  21. typedef long jmp_buf[2];
  22. #define JMPBUFSP 0
  23. #define JMPBUFPC 1
  24. #define JMPBUFDPC 0
  25. typedef unsigned int mpdigit; /* for /sys/include/mp.h */
  26. typedef unsigned char u8int;
  27. typedef unsigned short u16int;
  28. typedef unsigned int u32int;
  29. typedef unsigned long long u64int;
  30. /* FPSCR */
  31. #define FPSFX (1<<31) /* exception summary (sticky) */
  32. #define FPSEX (1<<30) /* enabled exception summary */
  33. #define FPSVX (1<<29) /* invalid operation exception summary */
  34. #define FPSOX (1<<28) /* overflow exception OX (sticky) */
  35. #define FPSUX (1<<27) /* underflow exception UX (sticky) */
  36. #define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
  37. #define FPSXX (1<<25) /* inexact exception XX (sticky) */
  38. #define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
  39. #define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
  40. #define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
  41. #define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
  42. #define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
  43. #define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
  44. #define FPSFR (1<<18) /* fraction rounded */
  45. #define FPSFI (1<<17) /* fraction inexact */
  46. #define FPSFPRF (1<<16) /* floating point result class */
  47. #define FPSFPCC (0xF<<12) /* <, >, =, unordered */
  48. #define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
  49. #define FPVE (1<<7) /* invalid operation exception enable */
  50. #define FPOVFL (1<<6) /* enable overflow exceptions */
  51. #define FPUNFL (1<<5) /* enable underflow */
  52. #define FPZDIV (1<<4) /* enable zero divide */
  53. #define FPINEX (1<<3) /* enable inexact exceptions */
  54. #define FPRMASK (3<<0) /* rounding mode */
  55. #define FPRNR (0<<0)
  56. #define FPRZ (1<<0)
  57. #define FPRPINF (2<<0)
  58. #define FPRNINF (3<<0)
  59. #define FPPEXT 0
  60. #define FPPSGL 0
  61. #define FPPDBL 0
  62. #define FPPMASK 0
  63. #define FPINVAL FPVE
  64. #define FPAOVFL FPSOX
  65. #define FPAINEX FPSXX
  66. #define FPAUNFL FPSUX
  67. #define FPAZDIV FPSZX
  68. #define FPAINVAL FPSVX
  69. union FPdbleword
  70. {
  71. double x;
  72. struct { /* big endian */
  73. uint32_t hi;
  74. uint32_t lo;
  75. };
  76. };
  77. typedef char* va_list;
  78. #define va_start(list, start) list =\
  79. (sizeof(start) < 4?\
  80. (char*)((int*)&(start)+1):\
  81. (char*)(&(start)+1))
  82. #define va_end(list)\
  83. USED(list)
  84. #define va_arg(list, mode)\
  85. ((sizeof(mode) <= 4)?\
  86. ((list += 4), (mode*)list)[-1]:\
  87. (signof(mode) != signof(double))?\
  88. ((list += sizeof(mode)), (mode*)list)[-1]:\
  89. ((list = (char*)((uintptr)(list+7) & ~7) + sizeof(mode)), (mode*)list)[-1])