home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / gnulib1.c < prev    next >
C/C++ Source or Header  |  1991-06-03  |  11KB  |  616 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. /* 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 FLOAT_VALUE_TYPE  
  202. #define FLOAT_VALUE_TYPE int
  203. #endif
  204.  
  205. #ifndef INTIFY
  206. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  207. #endif
  208.  
  209. #ifndef FLOATIFY
  210. #define FLOATIFY(INTVAL)  ((INTVAL).f)
  211. #endif
  212.  
  213. #ifndef FLOAT_ARG_TYPE
  214. #define FLOAT_ARG_TYPE union flt_or_int
  215. #endif
  216.  
  217. union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
  218.  
  219. union flt_or_int { int i; float f; };
  220.  
  221.  
  222. #ifdef L_mulsi3
  223. SItype
  224. __mulsi3 (a, b)
  225.      SItype a, b;
  226. {
  227.   perform_mulsi3 (a, b);
  228. }
  229. #endif
  230.  
  231. #ifdef L_udivsi3
  232. SItype
  233. __udivsi3 (a, b)
  234.      unsigned SItype a, b;
  235. {
  236.   perform_udivsi3 (a, b);
  237. }
  238. #endif
  239.  
  240. #ifdef L_divsi3
  241. SItype
  242. __divsi3 (a, b)
  243.      SItype a, b;
  244. {
  245.   perform_divsi3 (a, b);
  246. }
  247. #endif
  248.  
  249. #ifdef L_umodsi3
  250. SItype
  251. __umodsi3 (a, b)
  252.      unsigned SItype a, b;
  253. {
  254.   perform_umodsi3 (a, b);
  255. }
  256. #endif
  257.  
  258. #ifdef L_modsi3
  259. SItype
  260. __modsi3 (a, b)
  261.      SItype a, b;
  262. {
  263.   perform_modsi3 (a, b);
  264. }
  265. #endif
  266.  
  267. #ifdef L_lshrsi3
  268. SItype
  269. __lshrsi3 (a, b)
  270.      unsigned SItype a, b;
  271. {
  272.   perform_lshrsi3 (a, b);
  273. }
  274. #endif
  275.  
  276. #ifdef L_lshlsi3
  277. SItype
  278. __lshlsi3 (a, b)
  279.      unsigned SItype a, b;
  280. {
  281.   perform_lshlsi3 (a, b);
  282. }
  283. #endif
  284.  
  285. #ifdef L_ashrsi3
  286. SItype
  287. __ashrsi3 (a, b)
  288.      SItype a, b;
  289. {
  290.   perform_ashrsi3 (a, b);
  291. }
  292. #endif
  293.  
  294. #ifdef L_ashlsi3
  295. SItype
  296. __ashlsi3 (a, b)
  297.      SItype a, b;
  298. {
  299.   perform_ashlsi3 (a, b);
  300. }
  301. #endif
  302.  
  303. #ifdef L_divdf3
  304. double
  305. __divdf3 (a, b)
  306.      double a, b;
  307. {
  308.   perform_divdf3 (a, b);
  309. }
  310. #endif
  311.  
  312. #ifdef L_muldf3
  313. double
  314. __muldf3 (a, b)
  315.      double a, b;
  316. {
  317.   perform_muldf3 (a, b);
  318. }
  319. #endif
  320.  
  321. #ifdef L_negdf2
  322. double
  323. __negdf2 (a)
  324.      double a;
  325. {
  326.   perform_negdf2 (a);
  327. }
  328. #endif
  329.  
  330. #ifdef L_adddf3
  331. double
  332. __adddf3 (a, b)
  333.      double a, b;
  334. {
  335.   perform_adddf3 (a, b);
  336. }
  337. #endif
  338.  
  339. #ifdef L_subdf3
  340. double
  341. __subdf3 (a, b)
  342.      double a, b;
  343. {
  344.   perform_subdf3 (a, b);
  345. }
  346. #endif
  347.  
  348. #ifdef L_cmpdf2
  349. SItype
  350. __cmpdf2 (a, b)
  351.      double a, b;
  352. {
  353. #ifdef perform_cmpdf2
  354.   perform_cmpdf2 (a, b);
  355. #else
  356.   if (a > b)
  357.     return 1;
  358.   else if (a < b)
  359.     return -1;
  360.   return 0;
  361. #endif
  362. }
  363. #endif
  364.  
  365. #ifdef L_eqdf2
  366. SItype
  367. __eqdf2 (a, b)
  368.      double a, b;
  369. {
  370.   /* Value == 0 iff a == b.  */
  371.   perform_eqdf2 (a, b);
  372. }
  373. #endif
  374.  
  375. #ifdef L_nedf2
  376. SItype
  377. __nedf2 (a, b)
  378.      double a, b;
  379. {
  380.   /* Value != 0 iff a != b.  */
  381.   perform_nedf2 (a, b);
  382. }
  383. #endif
  384.  
  385. #ifdef L_gtdf2
  386. SItype
  387. __gtdf2 (a, b)
  388.      double a, b;
  389. {
  390.   /* Value > 0 iff a > b.  */
  391.   perform_gtdf2 (a, b);
  392. }
  393. #endif
  394.  
  395. #ifdef L_gedf2
  396. SItype
  397. __gedf2 (a, b)
  398.      double a, b;
  399. {
  400.   /* Value >= 0 iff a >= b.  */
  401.   perform_gedf2 (a, b);
  402. }
  403. #endif
  404.  
  405. #ifdef L_ltdf2
  406. SItype
  407. __ltdf2 (a, b)
  408.      double a, b;
  409. {
  410.   /* Value < 0 iff a < b.  */
  411.   perform_ltdf2 (a, b);
  412. }
  413. #endif
  414.  
  415. #ifdef L_ledf2
  416. SItype
  417. __ledf2 (a, b)
  418.      double a, b;
  419. {
  420.   /* Value <= 0 iff a <= b.  */
  421.   perform_ledf2 (a, b);
  422. }
  423. #endif
  424.  
  425. #ifdef L_fixdfsi
  426. SItype
  427. __fixdfsi (a)
  428.      double a;
  429. {
  430.   return (SItype) a;
  431. }
  432. #endif
  433.  
  434. #ifdef L_fixsfsi
  435. SItype
  436. __fixsfsi (a)
  437.      FLOAT_ARG_TYPE a;
  438. {
  439.   union flt_or_value intify;
  440.   perform_fixsfsi (FLOATIFY (a));
  441. }
  442. #endif
  443.  
  444. #ifdef L_floatsidf
  445. double
  446. __floatsidf (a)
  447.      SItype a;
  448. {
  449.   perform_floatsidf (a);
  450. }
  451. #endif
  452.  
  453. #ifdef L_floatsisf
  454. FLOAT_VALUE_TYPE
  455. __floatsisf (a)
  456.      SItype a;
  457. {
  458.   union flt_or_value intify;
  459.   perform_floatsisf (a);
  460. }
  461. #endif
  462.  
  463. #ifdef L_addsf3
  464. FLOAT_VALUE_TYPE
  465. __addsf3 (a, b)
  466.      FLOAT_ARG_TYPE a, b;
  467. {
  468.   union flt_or_value intify;
  469.   perform_addsf3 (FLOATIFY (a), FLOATIFY (b));
  470. }
  471. #endif
  472.  
  473. #ifdef L_negsf2
  474. FLOAT_VALUE_TYPE
  475. __negsf2 (a)
  476.      FLOAT_ARG_TYPE a;
  477. {
  478.   union flt_or_value intify;
  479.   perform_negsf2 (FLOATIFY (a));
  480. }
  481. #endif
  482.  
  483. #ifdef L_subsf3
  484. FLOAT_VALUE_TYPE
  485. __subsf3 (a, b)
  486.      FLOAT_ARG_TYPE a, b;
  487. {
  488.   union flt_or_value intify;
  489.   perform_subsf3 (FLOATIFY (a), FLOATIFY (b));
  490. }
  491. #endif
  492.  
  493. #ifdef L_cmpsf2
  494. SItype
  495. __cmpsf2 (a, b)
  496.      FLOAT_ARG_TYPE a, b;
  497. {
  498.   union flt_or_value intify;
  499. #ifdef perform_cmpsf2
  500.   perform_cmpsf2 (FLOATIFY (a), FLOATIFY (b));
  501. #else
  502.   if (FLOATIFY (a) > FLOATIFY (b))
  503.     return 1;
  504.   else if (FLOATIFY (a) < FLOATIFY (b))
  505.     return -1;
  506.   return 0;
  507. #endif
  508. }
  509. #endif
  510.  
  511. #ifdef L_eqsf2
  512. SItype
  513. __eqsf2 (a, b)
  514.      FLOAT_ARG_TYPE a, b;
  515. {
  516.   union flt_or_int intify;
  517.   /* Value == 0 iff a == b.  */
  518.   perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
  519. }
  520. #endif
  521.  
  522. #ifdef L_nesf2
  523. SItype
  524. __nesf2 (a, b)
  525.      FLOAT_ARG_TYPE a, b;
  526. {
  527.   union flt_or_int intify;
  528.   /* Value != 0 iff a != b.  */
  529.   perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
  530. }
  531. #endif
  532.  
  533. #ifdef L_gtsf2
  534. SItype
  535. __gtsf2 (a, b)
  536.      FLOAT_ARG_TYPE a, b;
  537. {
  538.   union flt_or_int intify;
  539.   /* Value > 0 iff a > b.  */
  540.   perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
  541. }
  542. #endif
  543.  
  544. #ifdef L_gesf2
  545. SItype
  546. __gesf2 (a, b)
  547.      FLOAT_ARG_TYPE a, b;
  548. {
  549.   union flt_or_int intify;
  550.   /* Value >= 0 iff a >= b.  */
  551.   perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
  552. }
  553. #endif
  554.  
  555. #ifdef L_ltsf2
  556. SItype
  557. __ltsf2 (a, b)
  558.      FLOAT_ARG_TYPE a, b;
  559. {
  560.   union flt_or_int intify;
  561.   /* Value < 0 iff a < b.  */
  562.   perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
  563. }
  564. #endif
  565.  
  566. #ifdef L_lesf2
  567. SItype
  568. __lesf2 (a, b)
  569.      FLOAT_ARG_TYPE a, b;
  570. {
  571.   union flt_or_int intify;
  572.   /* Value <= 0 iff a <= b.  */
  573.   perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
  574. }
  575. #endif
  576.  
  577. #ifdef L_mulsf3
  578. FLOAT_VALUE_TYPE
  579. __mulsf3 (a, b)
  580.      FLOAT_ARG_TYPE a, b;
  581. {
  582.   union flt_or_value intify;
  583.   perform_mulsf3 (FLOATIFY (a), FLOATIFY (b));
  584. }
  585. #endif
  586.  
  587. #ifdef L_divsf3
  588. FLOAT_VALUE_TYPE
  589. __divsf3 (a, b)
  590.      FLOAT_ARG_TYPE a, b;
  591. {
  592.   union flt_or_value intify;
  593.   perform_divsf3 (FLOATIFY (a), FLOATIFY (b));
  594. }
  595. #endif
  596.  
  597. #ifdef L_truncdfsf2
  598. FLOAT_VALUE_TYPE
  599. __truncdfsf2 (a)
  600.      double a;
  601. {
  602.   union flt_or_value intify;
  603.   perform_truncdfsf2 (a);
  604. }
  605. #endif
  606.  
  607. #ifdef L_extendsfdf2
  608. double
  609. __extendsfdf2 (a)
  610.      FLOAT_ARG_TYPE a;
  611. {
  612.   union flt_or_value intify;
  613.   perform_extendsfdf2 (FLOATIFY (a));
  614. }
  615. #endif
  616.