Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
3.2 KiB

  1. /***
  2. *divhelp.c - Div/Rem helpers for IA64
  3. *
  4. * Copyright (c) 2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Define a number of IA64 compiler support functions used to implement
  8. * integral divide and remainder in code compiled -Os.
  9. *
  10. *Revision History:
  11. * 11-30-01 EVN Created.
  12. *
  13. *******************************************************************************/
  14. /*
  15. ** First, turn on global optimizations and optimize for speed,
  16. ** so that compiler generates division/reminder inline.
  17. */
  18. #pragma optimize ("gt", on)
  19. /*
  20. ** Now proper helper functions.
  21. */
  22. unsigned char __udiv8 (unsigned char i, unsigned char j)
  23. {
  24. return i / j;
  25. }
  26. unsigned char __urem8 (unsigned char i, unsigned char j)
  27. {
  28. return i % j;
  29. }
  30. signed char __div8 (signed char i, signed char j)
  31. {
  32. return i / j;
  33. }
  34. signed char __rem8 (signed char i, signed char j)
  35. {
  36. return i % j;
  37. }
  38. unsigned short __udiv16 (unsigned short i, unsigned short j)
  39. {
  40. return i / j;
  41. }
  42. unsigned short __urem16 (unsigned short i, unsigned short j)
  43. {
  44. return i % j;
  45. }
  46. signed short __div16 (signed short i, signed short j)
  47. {
  48. return i / j;
  49. }
  50. signed short __rem16 (signed short i, signed short j)
  51. {
  52. return i % j;
  53. }
  54. unsigned int __udiv32 (unsigned int i, unsigned int j)
  55. {
  56. return i / j;
  57. }
  58. unsigned int __urem32 (unsigned int i, unsigned int j)
  59. {
  60. return i % j;
  61. }
  62. signed int __div32 (signed int i, signed int j)
  63. {
  64. return i / j;
  65. }
  66. signed int __rem32 (signed int i, signed int j)
  67. {
  68. return i % j;
  69. }
  70. unsigned __int64 __udiv64 (unsigned __int64 i, unsigned __int64 j)
  71. {
  72. return i / j;
  73. }
  74. unsigned __int64 __urem64 (unsigned __int64 i, unsigned __int64 j)
  75. {
  76. return i % j;
  77. }
  78. signed __int64 __div64 (signed __int64 i, signed __int64 j)
  79. {
  80. return i / j;
  81. }
  82. signed __int64 __rem64 (signed __int64 i, signed __int64 j)
  83. {
  84. return i % j;
  85. }
  86. struct udivrem {
  87. unsigned __int64 div;
  88. unsigned __int64 rem;
  89. };
  90. struct divrem {
  91. signed __int64 div;
  92. signed __int64 rem;
  93. };
  94. struct udivrem __udivrem8 (unsigned char i, unsigned char j)
  95. {
  96. struct udivrem s;
  97. s.div = i / j;
  98. s.rem = i % j;
  99. return s;
  100. }
  101. struct divrem __divrem8 (signed char i, signed char j)
  102. {
  103. struct divrem s;
  104. s.div = i / j;
  105. s.rem = i % j;
  106. return s;
  107. }
  108. struct udivrem __udivrem16 (unsigned short i, unsigned short j)
  109. {
  110. struct udivrem s;
  111. s.div = i / j;
  112. s.rem = i % j;
  113. return s;
  114. }
  115. struct divrem __divrem16 (signed short i, signed short j)
  116. {
  117. struct divrem s;
  118. s.div = i / j;
  119. s.rem = i % j;
  120. return s;
  121. }
  122. struct udivrem __udivrem32 (unsigned int i, unsigned int j)
  123. {
  124. struct udivrem s;
  125. s.div = i / j;
  126. s.rem = i % j;
  127. return s;
  128. }
  129. struct divrem __divrem32 (signed int i, signed int j)
  130. {
  131. struct divrem s;
  132. s.div = i / j;
  133. s.rem = i % j;
  134. return s;
  135. }
  136. struct udivrem __udivrem64 (unsigned __int64 i, unsigned __int64 j)
  137. {
  138. struct udivrem s;
  139. s.div = i / j;
  140. s.rem = i % j;
  141. return s;
  142. }
  143. struct divrem __divrem64 (signed __int64 i, signed __int64 j)
  144. {
  145. struct divrem s;
  146. s.div = i / j;
  147. s.rem = i % j;
  148. return s;
  149. }