home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GERLIB_DEV08B.LHA / gerlib / gnulib / normal / gnulib1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-12  |  10.5 KB  |  618 lines

  1. /* Subroutines needed by GCC output code on some machines.  */
  2. /* Compile this file with the Unix C compiler!  */
  3. /* Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  4.  
  5. This file is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any
  8. later version.
  9.  
  10. In addition to the permissions in the GNU General Public License, the
  11. Free Software Foundation gives you unlimited permission to link the
  12. compiled version of this file with other programs, and to distribute
  13. those programs without any restriction coming from the use of this
  14. file.  (The General Public License restrictions do apply in other
  15. respects; for example, they cover modification of the file, and
  16. distribution when not linked into another program.)
  17.  
  18. This file is distributed in the hope that it will be useful, but
  19. WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  21. General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  26.  
  27. #include "config.h"
  28.  
  29. /* Don't use `fancy_abort' here even if config.h says to use it.  */
  30. #ifdef abort
  31. #undef abort
  32. #endif
  33.  
  34. /* On some machines, cc is really GCC.  For these machines, we can't
  35.    expect these functions to be properly compiled unless GCC open codes
  36.    the operation (which is precisely when the function won't be used).
  37.    So allow tm-*.h to specify ways of accomplishing the operations
  38.    by defining the macros perform_*.
  39.  
  40.    On a machine where cc is some other compiler, there is usually no
  41.    reason to define perform_*.  The other compiler normally has other ways
  42.    of implementing all of these operations.
  43.  
  44.    In some cases a certain machine may come with GCC installed as cc
  45.    or may have some other compiler.  Then it may make sense for tm-*.h
  46.    to define perform_* only if __GNUC__ is defined.  */
  47.  
  48. #ifndef perform_mulsi3
  49. #define perform_mulsi3(a, b) return a * b
  50. #endif
  51.  
  52. #ifndef perform_divsi3
  53. #define perform_divsi3(a, b) return a / b
  54. #endif
  55.  
  56. #ifndef perform_udivsi3
  57. #define perform_udivsi3(a, b) return a / b
  58. #endif
  59.  
  60. #ifndef perform_modsi3
  61. #define perform_modsi3(a, b) return a % b
  62. #endif
  63.  
  64. #ifndef perform_umodsi3
  65. #define perform_umodsi3(a, b) return a % b
  66. #endif
  67.  
  68. #ifndef perform_lshrsi3
  69. #define perform_lshrsi3(a, b) return a >> b
  70. #endif
  71.  
  72. #ifndef perform_lshlsi3
  73. #define perform_lshlsi3(a, b) return a << b
  74. #endif
  75.  
  76. #ifndef perform_ashrsi3
  77. #define perform_ashrsi3(a, b) return a >> b
  78. #endif
  79.  
  80. #ifndef perform_ashlsi3
  81. #define perform_ashlsi3(a, b) return a << b
  82. #endif
  83.  
  84. #ifndef perform_adddf3
  85. #define perform_adddf3(a, b) return a + b
  86. #endif
  87.  
  88. #ifndef perform_subdf3
  89. #define perform_subdf3(a, b) return a - b
  90. #endif
  91.  
  92. #ifndef perform_muldf3
  93. #define perform_muldf3(a, b) return a * b
  94. #endif
  95.  
  96. #ifndef perform_divdf3
  97. #define perform_divdf3(a, b) return a / b
  98. #endif
  99.  
  100. #ifndef perform_addsf3
  101. #define perform_addsf3(a, b) return INTIFY (a + b)
  102. #endif
  103.  
  104. #ifndef perform_subsf3
  105. #define perform_subsf3(a, b) return INTIFY (a - b)
  106. #endif
  107.  
  108. #ifndef perform_mulsf3
  109. #define perform_mulsf3(a, b) return INTIFY (a * b)
  110. #endif
  111.  
  112. #ifndef perform_divsf3
  113. #define perform_divsf3(a, b) return INTIFY (a / b)
  114. #endif
  115.  
  116. #ifndef perform_negdf2
  117. #define perform_negdf2(a) return -a
  118. #endif
  119.  
  120. #ifndef perform_negsf2
  121. #define perform_negsf2(a) return INTIFY (-a)
  122. #endif
  123.  
  124. #ifndef perform_fixsfsi
  125. #define perform_fixsfsi(a) return (SItype) a
  126. #endif
  127.  
  128. #ifndef perform_floatsidf
  129. #define perform_floatsidf(a) return (double) a
  130. #endif
  131.  
  132. #ifndef perform_floatsisf
  133. #define perform_floatsisf(a)  return INTIFY ((float) a)
  134. #endif
  135.  
  136. #ifndef perform_extendsfdf2
  137. #define perform_extendsfdf2(a)  return a
  138. #endif
  139.  
  140. #ifndef perform_truncdfsf2
  141. #define perform_truncdfsf2(a)  return INTIFY (a)
  142. #endif
  143.  
  144. #ifndef perform_eqdf2
  145. #define perform_eqdf2(a, b) return !(a == b)
  146. #endif
  147.  
  148. #ifndef perform_nedf2
  149. #define perform_nedf2(a, b) return a != b
  150. #endif
  151.  
  152. #ifndef perform_gtdf2
  153. #define perform_gtdf2(a, b) return a > b
  154. #endif
  155.  
  156. #ifndef perform_gedf2
  157. #define perform_gedf2(a, b) return (a >= b) - 1
  158. #endif
  159.  
  160. #ifndef perform_ltdf2
  161. #define perform_ltdf2(a, b) return -(a < b)
  162. #endif
  163.  
  164. #ifndef perform_ledf2
  165. #define perform_ledf2(a, b) return 1 - (a <= b)
  166. #endif
  167.  
  168. #ifndef perform_eqsf2
  169. #define perform_eqsf2(a, b) return !(a == b)
  170. #endif
  171.  
  172. #ifndef perform_nesf2
  173. #define perform_nesf2(a, b) return a != b
  174. #endif
  175.  
  176. #ifndef perform_gtsf2
  177. #define perform_gtsf2(a, b) return a > b
  178. #endif
  179.  
  180. #ifndef perform_gesf2
  181. #define perform_gesf2(a, b) return (a >= b) - 1
  182. #endif
  183.  
  184. #ifndef perform_ltsf2
  185. #define perform_ltsf2(a, b) return -(a < b)
  186. #endif
  187.  
  188. #ifndef perform_lesf2
  189. #define perform_lesf2(a, b) return 1 - (a >= b);
  190. #endif
  191.  
  192. /* Define the C data type to use for an SImode value.  */
  193.  
  194. #ifndef SItype
  195. #define SItype long int
  196. #endif
  197.  
  198. /* Define the type to be used for returning an SF mode value
  199.    and the method for turning a float into that type.
  200.    These definitions work for machines where an SF value is
  201.    returned in the same register as an int.  */
  202.  
  203. #ifndef FLOAT_VALUE_TYPE  
  204. #define FLOAT_VALUE_TYPE int
  205. #endif
  206.  
  207. #ifndef INTIFY
  208. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  209. #endif
  210.  
  211. #ifndef FLOATIFY
  212. #define FLOATIFY(INTVAL)  ((INTVAL).f)
  213. #endif
  214.  
  215. #ifndef FLOAT_ARG_TYPE
  216. #define FLOAT_ARG_TYPE union flt_or_int
  217. #endif
  218.  
  219. union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
  220.  
  221. union flt_or_int { int i; float f; };
  222.  
  223.  
  224. #ifdef L_mulsi3
  225. SItype
  226. __mulsi3 (a, b)
  227.      SItype a, b;
  228. {
  229.   perform_mulsi3 (a, b);
  230. }
  231. #endif
  232.  
  233. #ifdef L_udivsi3
  234. SItype
  235. __udivsi3 (a, b)
  236.      unsigned SItype a, b;
  237. {
  238.   perform_udivsi3 (a, b);
  239. }
  240. #endif
  241.  
  242. #ifdef L_divsi3
  243. SItype
  244. __divsi3 (a, b)
  245.      SItype a, b;
  246. {
  247.   perform_divsi3 (a, b);
  248. }
  249. #endif
  250.  
  251. #ifdef L_umodsi3
  252. SItype
  253. __umodsi3 (a, b)
  254.      unsigned SItype a, b;
  255. {
  256.   perform_umodsi3 (a, b);
  257. }
  258. #endif
  259.  
  260. #ifdef L_modsi3
  261. SItype
  262. __modsi3 (a, b)
  263.      SItype a, b;
  264. {
  265.   perform_modsi3 (a, b);
  266. }
  267. #endif
  268.  
  269. #ifdef L_lshrsi3
  270. SItype
  271. __lshrsi3 (a, b)
  272.      unsigned SItype a, b;
  273. {
  274.   perform_lshrsi3 (a, b);
  275. }
  276. #endif
  277.  
  278. #ifdef L_lshlsi3
  279. SItype
  280. __lshlsi3 (a, b)
  281.      unsigned SItype a, b;
  282. {
  283.   perform_lshlsi3 (a, b);
  284. }
  285. #endif
  286.  
  287. #ifdef L_ashrsi3
  288. SItype
  289. __ashrsi3 (a, b)
  290.      SItype a, b;
  291. {
  292.   perform_ashrsi3 (a, b);
  293. }
  294. #endif
  295.  
  296. #ifdef L_ashlsi3
  297. SItype
  298. __ashlsi3 (a, b)
  299.      SItype a, b;
  300. {
  301.   perform_ashlsi3 (a, b);
  302. }
  303. #endif
  304.  
  305. #ifdef L_divdf3
  306. double
  307. __divdf3 (a, b)
  308.      double a, b;
  309. {
  310.   perform_divdf3 (a, b);
  311. }
  312. #endif
  313.  
  314. #ifdef L_muldf3
  315. double
  316. __muldf3 (a, b)
  317.      double a, b;
  318. {
  319.   perform_muldf3 (a, b);
  320. }
  321. #endif
  322.  
  323. #ifdef L_negdf2
  324. double
  325. __negdf2 (a)
  326.      double a;
  327. {
  328.   perform_negdf2 (a);
  329. }
  330. #endif
  331.  
  332. #ifdef L_adddf3
  333. double
  334. __adddf3 (a, b)
  335.      double a, b;
  336. {
  337.   perform_adddf3 (a, b);
  338. }
  339. #endif
  340.  
  341. #ifdef L_subdf3
  342. double
  343. __subdf3 (a, b)
  344.      double a, b;
  345. {
  346.   perform_subdf3 (a, b);
  347. }
  348. #endif
  349.  
  350. #ifdef L_cmpdf2
  351. SItype
  352. __cmpdf2 (a, b)
  353.      double a, b;
  354. {
  355. #ifdef perform_cmpdf2
  356.   perform_cmpdf2 (a, b);
  357. #else
  358.   if (a > b)
  359.     return 1;
  360.   else if (a < b)
  361.     return -1;
  362.   return 0;
  363. #endif
  364. }
  365. #endif
  366.  
  367. #ifdef L_eqdf2
  368. SItype
  369. __eqdf2 (a, b)
  370.      double a, b;
  371. {
  372.   /* Value == 0 iff a == b.  */
  373.   perform_eqdf2 (a, b);
  374. }
  375. #endif
  376.  
  377. #ifdef L_nedf2
  378. SItype
  379. __nedf2 (a, b)
  380.      double a, b;
  381. {
  382.   /* Value != 0 iff a != b.  */
  383.   perform_nedf2 (a, b);
  384. }
  385. #endif
  386.  
  387. #ifdef L_gtdf2
  388. SItype
  389. __gtdf2 (a, b)
  390.      double a, b;
  391. {
  392.   /* Value > 0 iff a > b.  */
  393.   perform_gtdf2 (a, b);
  394. }
  395. #endif
  396.  
  397. #ifdef L_gedf2
  398. SItype
  399. __gedf2 (a, b)
  400.      double a, b;
  401. {
  402.   /* Value >= 0 iff a >= b.  */
  403.   perform_gedf2 (a, b);
  404. }
  405. #endif
  406.  
  407. #ifdef L_ltdf2
  408. SItype
  409. __ltdf2 (a, b)
  410.      double a, b;
  411. {
  412.   /* Value < 0 iff a < b.  */
  413.   perform_ltdf2 (a, b);
  414. }
  415. #endif
  416.  
  417. #ifdef L_ledf2
  418. SItype
  419. __ledf2 (a, b)
  420.      double a, b;
  421. {
  422.   /* Value <= 0 iff a <= b.  */
  423.   perform_ledf2 (a, b);
  424. }
  425. #endif
  426.  
  427. #ifdef L_fixdfsi
  428. SItype
  429. __fixdfsi (a)
  430.      double a;
  431. {
  432.   return (SItype) a;
  433. }
  434. #endif
  435.  
  436. #ifdef L_fixsfsi
  437. SItype
  438. __fixsfsi (a)
  439.      FLOAT_ARG_TYPE a;
  440. {
  441.   union flt_or_value intify;
  442.   perform_fixsfsi (FLOATIFY (a));
  443. }
  444. #endif
  445.  
  446. #ifdef L_floatsidf
  447. double
  448. __floatsidf (a)
  449.      SItype a;
  450. {
  451.   perform_floatsidf (a);
  452. }
  453. #endif
  454.  
  455. #ifdef L_floatsisf
  456. FLOAT_VALUE_TYPE
  457. __floatsisf (a)
  458.      SItype a;
  459. {
  460.   union flt_or_value intify;
  461.   perform_floatsisf (a);
  462. }
  463. #endif
  464.  
  465. #ifdef L_addsf3
  466. FLOAT_VALUE_TYPE
  467. __addsf3 (a, b)
  468.      FLOAT_ARG_TYPE a, b;
  469. {
  470.   union flt_or_value intify;
  471.   perform_addsf3 (FLOATIFY (a), FLOATIFY (b));
  472. }
  473. #endif
  474.  
  475. #ifdef L_negsf2
  476. FLOAT_VALUE_TYPE
  477. __negsf2 (a)
  478.      FLOAT_ARG_TYPE a;
  479. {
  480.   union flt_or_value intify;
  481.   perform_negsf2 (FLOATIFY (a));
  482. }
  483. #endif
  484.  
  485. #ifdef L_subsf3
  486. FLOAT_VALUE_TYPE
  487. __subsf3 (a, b)
  488.      FLOAT_ARG_TYPE a, b;
  489. {
  490.   union flt_or_value intify;
  491.   perform_subsf3 (FLOATIFY (a), FLOATIFY (b));
  492. }
  493. #endif
  494.  
  495. #ifdef L_cmpsf2
  496. SItype
  497. __cmpsf2 (a, b)
  498.      FLOAT_ARG_TYPE a, b;
  499. {
  500.   union flt_or_value intify;
  501. #ifdef perform_cmpsf2
  502.   perform_cmpsf2 (FLOATIFY (a), FLOATIFY (b));
  503. #else
  504.   if (FLOATIFY (a) > FLOATIFY (b))
  505.     return 1;
  506.   else if (FLOATIFY (a) < FLOATIFY (b))
  507.     return -1;
  508.   return 0;
  509. #endif
  510. }
  511. #endif
  512.  
  513. #ifdef L_eqsf2
  514. SItype
  515. __eqsf2 (a, b)
  516.      FLOAT_ARG_TYPE a, b;
  517. {
  518.   union flt_or_int intify;
  519.   /* Value == 0 iff a == b.  */
  520.   perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
  521. }
  522. #endif
  523.  
  524. #ifdef L_nesf2
  525. SItype
  526. __nesf2 (a, b)
  527.      FLOAT_ARG_TYPE a, b;
  528. {
  529.   union flt_or_int intify;
  530.   /* Value != 0 iff a != b.  */
  531.   perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
  532. }
  533. #endif
  534.  
  535. #ifdef L_gtsf2
  536. SItype
  537. __gtsf2 (a, b)
  538.      FLOAT_ARG_TYPE a, b;
  539. {
  540.   union flt_or_int intify;
  541.   /* Value > 0 iff a > b.  */
  542.   perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
  543. }
  544. #endif
  545.  
  546. #ifdef L_gesf2
  547. SItype
  548. __gesf2 (a, b)
  549.      FLOAT_ARG_TYPE a, b;
  550. {
  551.   union flt_or_int intify;
  552.   /* Value >= 0 iff a >= b.  */
  553.   perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
  554. }
  555. #endif
  556.  
  557. #ifdef L_ltsf2
  558. SItype
  559. __ltsf2 (a, b)
  560.      FLOAT_ARG_TYPE a, b;
  561. {
  562.   union flt_or_int intify;
  563.   /* Value < 0 iff a < b.  */
  564.   perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
  565. }
  566. #endif
  567.  
  568. #ifdef L_lesf2
  569. SItype
  570. __lesf2 (a, b)
  571.      FLOAT_ARG_TYPE a, b;
  572. {
  573.   union flt_or_int intify;
  574.   /* Value <= 0 iff a <= b.  */
  575.   perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
  576. }
  577. #endif
  578.  
  579. #ifdef L_mulsf3
  580. FLOAT_VALUE_TYPE
  581. __mulsf3 (a, b)
  582.      FLOAT_ARG_TYPE a, b;
  583. {
  584.   union flt_or_value intify;
  585.   perform_mulsf3 (FLOATIFY (a), FLOATIFY (b));
  586. }
  587. #endif
  588.  
  589. #ifdef L_divsf3
  590. FLOAT_VALUE_TYPE
  591. __divsf3 (a, b)
  592.      FLOAT_ARG_TYPE a, b;
  593. {
  594.   union flt_or_value intify;
  595.   perform_divsf3 (FLOATIFY (a), FLOATIFY (b));
  596. }
  597. #endif
  598.  
  599. #ifdef L_truncdfsf2
  600. FLOAT_VALUE_TYPE
  601. __truncdfsf2 (a)
  602.      double a;
  603. {
  604.   union flt_or_value intify;
  605.   perform_truncdfsf2 (a);
  606. }
  607. #endif
  608.  
  609. #ifdef L_extendsfdf2
  610. double
  611. __extendsfdf2 (a)
  612.      FLOAT_ARG_TYPE a;
  613. {
  614.   union flt_or_value intify;
  615.   perform_extendsfdf2 (FLOATIFY (a));
  616. }
  617. #endif
  618.