u.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 char u8;
  11. typedef signed char i8;
  12. typedef unsigned short u16;
  13. typedef signed short i16;
  14. typedef unsigned int u32;
  15. typedef signed int i32;
  16. typedef unsigned long long u64;
  17. typedef signed long long i64;
  18. typedef u64 usize;
  19. typedef i64 isize;
  20. typedef unsigned char uint8_t;
  21. typedef signed char int8_t;
  22. typedef unsigned short uint16_t;
  23. typedef signed short int16_t;
  24. typedef unsigned int uint32_t;
  25. typedef unsigned int uint;
  26. typedef signed int int32_t;
  27. typedef long ssize_t;
  28. typedef unsigned long long uint64_t;
  29. typedef long long int64_t;
  30. typedef uint64_t uintptr;
  31. typedef uint64_t uintptr_t;
  32. typedef int64_t intptr_t;
  33. typedef unsigned long size_t;
  34. typedef u32 Rune;
  35. typedef union FPdbleword FPdbleword;
  36. typedef uint64_t jmp_buf[10]; // for registers.
  37. #define alignas _Alignas
  38. #define static_assert _Static_assert
  39. #define JMPBUFSP 6
  40. #define JMPBUFPC 7
  41. #define JMPBUFARG1 8
  42. #define JMPBUFARG2 9
  43. #define JMPBUFDPC 0
  44. typedef unsigned int mpdigit; /* for /sys/include/mp.h */
  45. /* MXCSR */
  46. /* fcr */
  47. #define FPFTZ (1<<15) /* amd64 */
  48. #define FPINEX (1<<12)
  49. #define FPUNFL (1<<11)
  50. #define FPOVFL (1<<10)
  51. #define FPZDIV (1<<9)
  52. #define FPDNRM (1<<8) /* amd64 */
  53. #define FPINVAL (1<<7)
  54. #define FPDAZ (1<<6) /* amd64 */
  55. #define FPRNR (0<<13)
  56. #define FPRZ (3<<13)
  57. #define FPRPINF (2<<13)
  58. #define FPRNINF (1<<13)
  59. #define FPRMASK (3<<13)
  60. #define FPPEXT 0
  61. #define FPPSGL 0
  62. #define FPPDBL 0
  63. #define FPPMASK 0
  64. /* fsr */
  65. #define FPAINEX (1<<5)
  66. #define FPAUNFL (1<<4)
  67. #define FPAOVFL (1<<3)
  68. #define FPAZDIV (1<<2)
  69. #define FPADNRM (1<<1) /* not in plan 9 */
  70. #define FPAINVAL (1<<0)
  71. union FPdbleword
  72. {
  73. double x;
  74. struct { /* little endian */
  75. uint lo;
  76. uint hi;
  77. };
  78. };
  79. /*
  80. #if 0
  81. typedef char* va_list;
  82. #define va_start(list, start) list =\
  83. (sizeof(start) < 8?\
  84. (char*)((int64_t*)&(start)+1):\
  85. (char*)(&(start)+1))
  86. #define va_end(list)\
  87. USED(list)
  88. #define va_arg(list, mode)\
  89. ((sizeof(mode) == 1)?\
  90. ((list += 8), (mode*)list)[-8]:\
  91. (sizeof(mode) == 2)?\
  92. ((list += 8), (mode*)list)[-4]:\
  93. (sizeof(mode) == 4)?\
  94. ((list += 8), (mode*)list)[-2]:\
  95. ((list += sizeof(mode)), (mode*)list)[-1])
  96. #endif
  97. */
  98. typedef __builtin_va_list va_list;
  99. #define va_start(v,l) __builtin_va_start(v,l)
  100. #define va_end(v) __builtin_va_end(v)
  101. #define va_arg(v,l) __builtin_va_arg(v,l)
  102. #define va_copy(v,l) __builtin_va_copy(v,l)
  103. #define getcallerpc() ((uintptr_t)__builtin_return_address(0))