gnulib.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /* Subroutines needed by GCC output code on some machines. */
  2. /* Compile this file with the Unix C compiler! */
  3. #include "config.h"
  4. union double_di { double d; int i[2]; };
  5. union flt_or_int { int i; float f; };
  6. #ifdef WORDS_BIG_ENDIAN
  7. #define HIGH 0
  8. #define LOW 1
  9. #else
  10. #define HIGH 1
  11. #define LOW 0
  12. #endif
  13. #ifdef Lva_end
  14. /* This is here in case the user says #undef va_end, which ANSI C permits. */
  15. void
  16. va_end (ap)
  17. char **ap;
  18. {
  19. }
  20. #endif
  21. #ifdef L_eprintf
  22. #include <stdio.h>
  23. /* This is used by the `assert' macro. */
  24. void
  25. _eprintf (string, line)
  26. char *string;
  27. int line;
  28. {
  29. fprintf (stderr, string, line);
  30. }
  31. #endif
  32. #ifdef L_umulsi3
  33. _umulsi3 (a, b)
  34. unsigned a, b;
  35. {
  36. return a * b;
  37. }
  38. #endif
  39. #ifdef L_mulsi3
  40. _mulsi3 (a, b)
  41. int a, b;
  42. {
  43. return a * b;
  44. }
  45. #endif
  46. #ifdef L_udivsi3
  47. _udivsi3 (a, b)
  48. unsigned a, b;
  49. {
  50. return a / b;
  51. }
  52. #endif
  53. #ifdef L_divsi3
  54. _divsi3 (a, b)
  55. int a, b;
  56. {
  57. return a / b;
  58. }
  59. #endif
  60. #ifdef L_umodsi3
  61. _umodsi3 (a, b)
  62. unsigned a, b;
  63. {
  64. return a % b;
  65. }
  66. #endif
  67. #ifdef L_modsi3
  68. _modsi3 (a, b)
  69. int a, b;
  70. {
  71. return a % b;
  72. }
  73. #endif
  74. #ifdef L_lshrsi3
  75. _lshrsi3 (a, b)
  76. unsigned a, b;
  77. {
  78. return a >> b;
  79. }
  80. #endif
  81. #ifdef L_lshlsi3
  82. _lshlsi3 (a, b)
  83. unsigned a, b;
  84. {
  85. return a << b;
  86. }
  87. #endif
  88. #ifdef L_ashrsi3
  89. _ashrsi3 (a, b)
  90. int a, b;
  91. {
  92. return a >> b;
  93. }
  94. #endif
  95. #ifdef L_ashlsi3
  96. _ashlsi3 (a, b)
  97. int a, b;
  98. {
  99. return a << b;
  100. }
  101. #endif
  102. #ifdef L_divdf3
  103. double
  104. _divdf3 (a, b)
  105. double a, b;
  106. {
  107. return a / b;
  108. }
  109. #endif
  110. #ifdef L_muldf3
  111. double
  112. _muldf3 (a, b)
  113. double a, b;
  114. {
  115. return a * b;
  116. }
  117. #endif
  118. #ifdef L_negdf2
  119. double
  120. _negdf2 (a)
  121. double a;
  122. {
  123. return -a;
  124. }
  125. #endif
  126. #ifdef L_adddf3
  127. double
  128. _adddf3 (a, b)
  129. double a, b;
  130. {
  131. return a + b;
  132. }
  133. #endif
  134. #ifdef L_subdf3
  135. double
  136. _subdf3 (a, b)
  137. double a, b;
  138. {
  139. return a - b;
  140. }
  141. #endif
  142. #ifdef L_cmpdf2
  143. int
  144. _cmpdf2 (a, b)
  145. double a, b;
  146. {
  147. if (a > b)
  148. return 1;
  149. else if (a < b)
  150. return -1;
  151. return 0;
  152. }
  153. #endif
  154. #ifdef L_fixunsdfsi
  155. _fixunsdfsi (a)
  156. double a;
  157. {
  158. return (unsigned int) a;
  159. }
  160. #endif
  161. #ifdef L_fixunsdfdi
  162. double
  163. _fixunsdfdi (a)
  164. double a;
  165. {
  166. union double_di u;
  167. u.i[LOW] = (unsigned int) a;
  168. u.i[HIGH] = 0;
  169. return u.d;
  170. }
  171. #endif
  172. #ifdef L_fixdfsi
  173. _fixdfsi (a)
  174. double a;
  175. {
  176. return (int) a;
  177. }
  178. #endif
  179. #ifdef L_fixdfdi
  180. double
  181. _fixdfdi (a)
  182. double a;
  183. {
  184. union double_di u;
  185. u.i[LOW] = (int) a;
  186. u.i[HIGH] = (int) a < 0 ? -1 : 0;
  187. return u.d;
  188. }
  189. #endif
  190. #ifdef L_floatsidf
  191. double
  192. _floatsidf (a)
  193. int a;
  194. {
  195. return (double) a;
  196. }
  197. #endif
  198. #ifdef L_floatdidf
  199. double
  200. _floatdidf (u)
  201. union double_di u;
  202. {
  203. register double hi
  204. = ((double) u.i[HIGH]) * (double) 0x10000 * (double) 0x10000;
  205. register double low = (unsigned int) u.i[LOW];
  206. return hi + low;
  207. }
  208. #endif
  209. #define INTIFY(FLOATVAL) (intify.f = (FLOATVAL), intify.i)
  210. #ifdef L_addsf3
  211. int
  212. _addsf3 (a, b)
  213. union flt_or_int a, b;
  214. {
  215. union flt_or_int intify;
  216. return INTIFY (a.f + b.f);
  217. }
  218. #endif
  219. #ifdef L_negsf2
  220. int
  221. _negsf2 (a)
  222. union flt_or_int a;
  223. {
  224. union flt_or_int intify;
  225. return INTIFY (-a.f);
  226. }
  227. #endif
  228. #ifdef L_subsf3
  229. int
  230. _subsf3 (a, b)
  231. union flt_or_int a, b;
  232. {
  233. union flt_or_int intify;
  234. return INTIFY (a.f - b.f);
  235. }
  236. #endif
  237. #ifdef L_cmpsf2
  238. int
  239. _cmpsf2 (a, b)
  240. union flt_or_int a, b;
  241. {
  242. union flt_or_int intify;
  243. if (a.f > b.f)
  244. return 1;
  245. else if (a.f < b.f)
  246. return -1;
  247. return 0;
  248. }
  249. #endif
  250. #ifdef L_mulsf3
  251. int
  252. _mulsf3 (a, b)
  253. union flt_or_int a, b;
  254. {
  255. union flt_or_int intify;
  256. return INTIFY (a.f * b.f);
  257. }
  258. #endif
  259. #ifdef L_divsf3
  260. int
  261. _divsf3 (a, b)
  262. union flt_or_int a, b;
  263. {
  264. union flt_or_int intify;
  265. return INTIFY (a.f / b.f);
  266. }
  267. #endif
  268. #ifdef L_truncdfsf2
  269. int
  270. _truncdfsf2 (a)
  271. double a;
  272. {
  273. union flt_or_int intify;
  274. return INTIFY (a);
  275. }
  276. #endif
  277. #ifdef L_extendsfdf2
  278. double
  279. _extendsfdf2 (a)
  280. union flt_or_int a;
  281. {
  282. union flt_or_int intify;
  283. return a.f;
  284. }
  285. #endif