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