home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / src / basic / _fix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  1.2 KB  |  59 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  _fix.c
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16. /* For compatibility with gcc */
  17.  
  18. #ifndef __GNUG__
  19.  
  20. #define BITS_PER_WORD 32
  21. #define HIGH_BIT_INT_COEFF  (1 << (BITS_PER_WORD - 1))
  22. #define HIGH_BIT_COEFF  (2 * (double) (1 << (BITS_PER_WORD - 2)))
  23.  
  24. long __fixunsdfsi (a)
  25. double a;
  26. {
  27.   if (a < HIGH_BIT_COEFF)
  28.     return (long)a;
  29.   /* Convert large positive numbers to smaller ones,
  30.      then increase again after you have a fixed point number.  */
  31.   else
  32.     return ((long) (a - HIGH_BIT_COEFF)) + HIGH_BIT_INT_COEFF;
  33. }
  34.  
  35.  
  36. #ifdef sparc 
  37.  
  38. asm (".global _save_registers");
  39. asm ("_save_registers:");
  40. asm ("st %i0,[%fp+68]");
  41. asm ("st %i1,[%fp+72]");
  42. asm ("st %i2,[%fp+76]");
  43. asm ("st %i3,[%fp+80]");
  44. asm ("st %i4,[%fp+84]");
  45. asm ("retl");
  46. asm ("st %i5,[%fp+88]");
  47.  
  48. #else
  49. void save_registers() {};
  50.  
  51. #endif
  52.  
  53. #else
  54. void save_registers() {};
  55.  
  56. #endif
  57.  
  58.