home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / patches / float-emacs.diff < prev    next >
Encoding:
Text File  |  1991-07-01  |  25.5 KB  |  820 lines

  1. This is a complete diff -c for making a version of gnuemacs18.52
  2. with lisp flonums. 
  3.  
  4. ***** start of diff (on Thu Apr 20 11:52:50 EST 1989) *****
  5.  
  6. *** src/FLONUM.orig    Thu Apr 20 11:51:11 1989
  7. --- src/FLONUM    Wed Apr 19 11:57:18 1989
  8. ***************
  9. *** 0 ****
  10. --- 1,263 ----
  11. + ###############################################################################
  12. + ##                                         ##
  13. + ##    File:     FLONUMS                             ##
  14. + ##    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 ##
  15. + ##    Created:  Tue Oct 27 15:58:53 EST 1987                     ##
  16. + ##    Contents: Documentation File for GnuEmacs with floats             ##
  17. + ##                                         ##
  18. + ##    Copyright (c) 1987 Wolfgang Rupprecht.                     ##
  19. + ##    All rights reserved.                             ##
  20. + ##                                         ##
  21. + ##    $Log$                                     ##
  22. + ###############################################################################
  23. + INTRO
  24. + I have added a true floating point data type (flonum in lisp jargon)
  25. + to the lisp interpreter of GnuEmacs.  This allows one to do emacs-lisp
  26. + calculations using floating point numbers as well as integers.  In
  27. + addition, GnuEmacs now has hooks to call all of the common
  28. + trigonometric functions from lisp.  One may now, for example, use the
  29. + *scratch* buffer as a real scientific calculator (programable even!!).
  30. + It is not that hard to write a super spreadsheet calculator in elisp,
  31. + using this package.
  32. + NEW FEATURES
  33. + The basic features features provided are:
  34. + *    a lisp float data type, that uses the C type "double" for it's
  35. +     basic storage
  36. + *    upgrading of the built-in math subroutines to allow manipulation
  37. +     of floats
  38. + *    conversion routines to convert to and from floats and ints
  39. + *    predicates for testing if a number is a float, float-or-int,
  40. +     or float-or-int-or-marker
  41. + *    trig math routines. (sin, cos, tan, exponentials, logs, bessels, etc.)
  42. + *    upgrading of int-to-string, string-to-int, and the basic printing
  43. +     and reading routines to allow float reading/printing.
  44. + *    changes to garbage-collect to also collect old floats.
  45. + The lisp reader will interpret strings of one of the following three
  46. + forms as a float:
  47. +      <number>.<number>
  48. +      <number>e<number>
  49. +      <number>.<number>e<number>
  50. + The mantissa and the exponent may both have a single + or - sign
  51. + prefixed.  All other strings are treated as symbols.  This is
  52. + intentional, and meant to prevent numbers and dotted pairs of 
  53. + ints from looking too much like one another. 
  54. +      legal numbers:
  55. +       (0 . 1)      a doted pair of integers 0 and 1
  56. +       (0.1)        a list of one float with value 1/10
  57. +       0.0        the floating pt. zero
  58. +       1.0        the floating point one
  59. +       1e0        also floating pt. one
  60. +       0e0        also floating pt. zero
  61. +          (0. 1)        a list of symbol "0\." and integer 0
  62. +      (0 .1)        a list of integer 0 and symbol "\.1"
  63. +           0.        symbol "0\."
  64. +       .1        symbol "\.1"
  65. + The built in math functions promote the type of the calculation from
  66. + integer to float at the first encounter with a float.
  67. +     (+ 1 2 3 4 5 6.0 7 8 9)
  68. + The above expression will be done in integer math for the addition of
  69. + 1, 2, 3, 4 and 5.  The rest of the calculation is done in floating
  70. + point math with the result being a float.  This allows an integer 
  71. + calculation to still return an integer.  To force a floating point
  72. + calculation, convert the first argument to a float.
  73. + Ints can be converted to floats by using the function "float".
  74. + Floats can be converted to ints by one of several functions, 
  75. + depending on the type of rounding desired.
  76. +        round        returns the closest integer
  77. +        ceiling        returns the largest integer that is not larger 
  78. +             than the arg (round towards -infinity)
  79. +        floor        returns the smallest integer that is not smaller
  80. +             than the arg (round towards +infinity)
  81. +        truncate        returns the integer corresponding to the mantissa
  82. +             of the float. (round towards zero)
  83. + On most machines that gnuemacs runs on, lisp integers are only 24 bits
  84. + long.  One must be careful when convering large floats to integers that
  85. + one doesn't exceed the storage capacity of integers.  Integers (of 24
  86. + bit size) can only have a range of slightly over +/- 8 million.  The
  87. + same caution applies when performing mathematical operations on
  88. + integers.  If you need to work with large numbers, it's safest to use 
  89. + floats.
  90. + The math trig functions sin/cos/tan all take their arguments in
  91. + radians.  Values can be converted to the desired radix with the
  92. + functions degrees-to-radians and radians-to-degrees.
  93. + Some of the new functions (or functions with new args/return values):
  94. + abs acosh asin asinh atan atanh ceiling cos cosh cube-root erf erfc
  95. + exp expm1 expt fceiling ffloor float floor fround ftruncate
  96. + garbage-collect int-to-string integer-or-float-or-marker-p
  97. + integer-or-floatp j0 j1 jn log log-gamma log10 log1p round sin sinh
  98. + sqrt tan tanh truncate y0 y1 yn
  99. + The full documentations for these functions is on-line under C-h f
  100. + <function-name> and at the end of this document. 
  101. + The lisp variable float-output-format controls the printed
  102. + representation of floats.  The available print formats are:
  103. +        <number>.<number>         with a 'd' specifier
  104. +        <number>.<number>e<number>    with an 'e' specifier
  105. +        (or data dependent switching 
  106. +         between the above two)         with no letter specifier
  107. + The field width may be contolled by an optional numeric field
  108. + preceeding the above format specifier. 
  109. + MAKING FLOAT-EMACS:
  110. + To make emacs with flonums (ie. lisp floats) define LISP_FLOAT_TYPE in
  111. + your conf.h file.  The resultant emacs will be less than 6% larger.
  112. + This has been tested on a Vax-750 running BSD 4.3.
  113. +     text    data    bss    dec    hex
  114. +     369664    180224    0    549888    86400    emacs-18.49
  115. +     391168    187392    0    578560    8d400    float-emacs-18.49
  116. + PORTING to other machines:
  117. + If you aren't running with a BSD/vax style printf, you may no be able
  118. + to use the optional runtime selectable floating point print-width stuff.
  119. + (I'll probably fix this soon.)
  120. + If you don't have some of the math-lib functions that emacs wants
  121. + linked in, don't worry.  These are all entirely optional.  Just #ifdef
  122. + the math routines out, stub them up, or find a copy of the 4.3 BSD
  123. + routines. (Check the 4.3 BSD math(3) man page for details on copying
  124. + the math-lib routines.)
  125. + Appendix A: floating pt. docstrings
  126. + abs
  127. +    Function: Return the absolute value of ARG.
  128. + acosh
  129. +    Function: Return the inverse hyperbolic cosine of ARG.
  130. + asin
  131. +    Function: Return the inverse sine of ARG.
  132. + asinh
  133. +    Function: Return the inverse hyperbolic sine of ARG.
  134. + atan
  135. +    Function: Return the inverse tangent of ARG.
  136. + atanh
  137. +    Function: Return the inverse hyperbolic tangent of ARG.
  138. + ceiling
  139. +    Function: Return the smallest integer no less than ARG. (round toward +inf)
  140. + cos
  141. +    Function: Return the cosine of ARG.
  142. + cosh
  143. +    Function: Return the hyperbolic cosine of ARG.
  144. + cube-root
  145. +    Function: Return the cube root of ARG.
  146. + erf
  147. +    Function: Return the mathematical error function of ARG.
  148. + erfc
  149. +    Function: Return the complementary error function of ARG.
  150. + exp
  151. +    Function: Return the exponential base e of ARG.
  152. + expm1
  153. +    Function: Return the exp(x)-1 of ARG.
  154. + expt
  155. +    Function: Return the exponential x ** y.
  156. + fceiling
  157. +    Function: Return the smallest integral floating pt. number no less than ARG.
  158. +    (round towards +inf)
  159. + ffloor
  160. +    Function: Return the largest floating pt number no greater than ARG.
  161. +    (round towards -inf)
  162. + float
  163. +    Function: Return the floating pt. number equal to ARG.
  164. + floatp
  165. +    Function: T if OBJECT is a floating pt. number.
  166. + float-output-format
  167. +    Variable: The format descriptor string (or nil) that lisp uses to print out
  168. +    floats.  Nil means use built-in defaults.
  169. +    The descriptor string consists of an optional field-width spec,
  170. +    followed by an optional output-style descriptor.
  171. +    
  172. +    Valid field-widths specs are:
  173. +    The empty string for default precision.
  174. +    0-20 for exponential notation, or 1-20 for decimal point notation.  A 0
  175. +    field spec causes the printing of the decimal point to be supressed.
  176. +    Using an out of bounds specs cause the closest valid spec to be used.
  177. +    
  178. +    Valid ouput-styles may be one of the following:
  179. +    The letter 'e' for exponential notation "<number>.<number>e<number>"
  180. +    The letter 'd' for decimal point notation "<number>.<number>".
  181. +    The empty string, for the defaulted output style.  This may print in
  182. +    either format in a data-dependent manner, choosing whatever produces
  183. +    the shortest string.
  184. +    
  185. + floor
  186. +    Function: Return the largest integer no greater than ARG. (round towards -inf)
  187. + fround
  188. +    Function: Return the nearest integral floating pt. number to ARG.
  189. + ftruncate
  190. +    Function: Truncate a floating point number, returns a float.
  191. +    (Truncates towards zero.) Will fail for floats > max integer.
  192. + garbage-collect
  193. +    Function: Reclaim storage for Lisp objects no longer needed.
  194. +    Returns info on amount of space in use:
  195. +     ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)
  196. +      (USED-MARKERS . FREE-MARKERS) (USED-FLOATS . FREE-FLOATS) 
  197. +      USED-STRING-CHARS USED-VECTOR-SLOTS)
  198. +    Garbage collection happens automatically if you cons more than
  199. +    gc-cons-threshold  bytes of Lisp data since previous garbage collection.
  200. + int-to-string
  201. +    Function: Convert INT to a string by printing it in decimal, with minus sign if negative.
  202. + integer-or-float-or-marker-p
  203. +    Function: T if OBJECT is a floating pointt, normal number, or marker.
  204. + integer-or-floatp
  205. +    Function: T if OBJECT is a floating pt. or normal number.
  206. + j0
  207. +    Function: Return the bessel function j0 of ARG.
  208. + j1
  209. +    Function: Return the bessel function j1 of ARG.
  210. + jn
  211. +    Function: Return the bessel function jN of ARG.
  212. + log
  213. +    Function: Return the natural logarithm of ARG.
  214. + log-gamma
  215. +    Function: Return the log gamma of ARG.
  216. + log10
  217. +    Function: Return the logarithm base 10 of ARG.
  218. + log1p
  219. +    Function: Return the log(1+x) of ARG.
  220. + round
  221. +    Function: Return the nearest integer to ARG.
  222. + sin
  223. +    Function: Return the sine of ARG.
  224. + sinh
  225. +    Function: Return the hyperbolic sine of ARG.
  226. + sqrt
  227. +    Function: Return the square root of ARG.
  228. + tan
  229. +    Function: Return the tangent of ARG.
  230. + tanh
  231. +    Function: Return the hyperbolic tangent of ARG.
  232. + truncate
  233. +    Function: Truncate a floating point number to an int.
  234. +    (Truncates toward zero.)
  235. + y0
  236. +    Function: Return the bessel function y0 of ARG.
  237. + y1
  238. +    Function: Return the bessel function y1 of ARG.
  239. + yn
  240. +    Function: Return the bessel function yN of ARG.
  241. *** src/alloc.c.orig    Thu Feb 11 02:09:48 1988
  242. --- src/alloc.c    Fri Sep  2 23:01:22 1988
  243. ***************
  244. *** 1,3 ****
  245. --- 1,15 ----
  246. + /******************************************************************************
  247. + *                                          *
  248. + *    File:     alloc.c                              *
  249. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  250. + *    Created:  Mon Nov  2 15:20:48 EST 1987                      *
  251. + *    Contents: GNU alloc.c with my float code                  *
  252. + *                                          *
  253. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  254. + *    All rights reserved.                              *
  255. + *                                          *
  256. + *    $Log$                                      *
  257. + ******************************************************************************/
  258.   /* Storage allocation and gc for GNU Emacs Lisp interpreter.
  259.      Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  260.   
  261. ***************
  262. *** 147,152 ****
  263. --- 159,239 ----
  264.     cons_free_list = ptr;
  265.   }
  266.   
  267. + #ifdef LISP_FLOAT_TYPE
  268. + /* Allocation of float cells, just like conses */
  269. + /* We store float cells inside of float_blocks, allocating a new
  270. +  float_block with malloc whenever necessary.  Float cells reclaimed by
  271. +  GC are put on a free list to be reallocated before allocating
  272. +  any new float cells from the latest float_block.
  273. +  Each float_block is just under 1020 bytes long,
  274. +  since malloc really allocates in units of powers of two
  275. +  and uses 4 bytes for its own overhead. */
  276. + #define FLOAT_BLOCK_SIZE \
  277. +   ((1020 - sizeof (struct float_block *)) / sizeof (struct Lisp_Float))
  278. + struct float_block
  279. +   {
  280. +     struct float_block *next;
  281. +     struct Lisp_Float floats[FLOAT_BLOCK_SIZE];
  282. +   };
  283. + struct float_block *float_block;
  284. + int float_block_index;
  285. + struct Lisp_Float *float_free_list;
  286. + void
  287. + init_float ()
  288. + {
  289. +   float_block = (struct float_block *) malloc (sizeof (struct float_block));
  290. +   float_block->next = 0;
  291. +   bzero (float_block->floats, sizeof float_block->floats);
  292. +   float_block_index = 0;
  293. +   float_free_list = 0;
  294. + }
  295. + /* Explicitly free a float cell.  */
  296. + free_float (ptr)
  297. +      struct Lisp_Float *ptr;
  298. + {
  299. +   XFASTINT (ptr->type) = (int) float_free_list;
  300. +   float_free_list = ptr;
  301. + }
  302. + Lisp_Object
  303. + make_float (float_value)
  304. +      double float_value;
  305. + {
  306. +   register Lisp_Object val;
  307. +   if (float_free_list)
  308. +     {
  309. +       XSET (val, Lisp_Float, float_free_list);
  310. +       float_free_list = (struct Lisp_Float *) XFASTINT (float_free_list->type);
  311. +     }
  312. +   else
  313. +     {
  314. +       if (float_block_index == FLOAT_BLOCK_SIZE)
  315. +     {
  316. +       register struct float_block *new = (struct float_block *) malloc (sizeof (struct float_block));
  317. +       if (!new) memory_full ();
  318. +       new->next = float_block;
  319. +       float_block = new;
  320. +       float_block_index = 0;
  321. +     }
  322. +       XSET (val, Lisp_Float, &float_block->floats[float_block_index++]);
  323. +     }
  324. +   XFLOAT (val)->data = float_value;
  325. +   XFLOAT (val)->type = 0;    /* bug chasing -wsr */
  326. +   consing_since_gc += sizeof (struct Lisp_Float);
  327. +   return val;
  328. + }
  329. + #endif LISP_FLOAT_TYPE
  330.   DEFUN ("cons", Fcons, Scons, 2, 2, 0,
  331.     "Create a new cons, give it CAR and CDR as components, and return it.")
  332.     (car, cdr)
  333. ***************
  334. *** 596,602 ****
  335. --- 683,707 ----
  336.     return new;
  337.   }
  338.   
  339. + #ifdef LISP_FLOAT_TYPE
  340.   Lisp_Object
  341. + pure_float (num)
  342. +      double num;
  343. + {
  344. +   register Lisp_Object new;
  345. +   if (pureptr + sizeof (struct Lisp_Float) > PURESIZE)
  346. +     error ("Pure Lisp storage exhausted");
  347. +   XSET (new, Lisp_Float, PUREBEG + pureptr);
  348. +   pureptr += sizeof (struct Lisp_Float);
  349. +   XFLOAT (new)->data = num;
  350. +   XFLOAT (new)->type = 0;    /* bug chasing -wsr */
  351. +   return new;
  352. + }
  353. + #endif LISP_FLOAT_TYPE
  354. + Lisp_Object
  355.   make_pure_vector (len)
  356.        int len;
  357.   {
  358. ***************
  359. *** 641,646 ****
  360. --- 746,756 ----
  361.       case Lisp_Cons:
  362.         return pure_cons (XCONS (obj)->car, XCONS (obj)->cdr);
  363.   
  364. + #ifdef LISP_FLOAT_TYPE
  365. +     case Lisp_Float:
  366. +       return pure_float (XFLOAT (obj)->data);
  367. + #endif LISP_FLOAT_TYPE
  368.       case Lisp_String:
  369.         return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size);
  370.   
  371. ***************
  372. *** 727,737 ****
  373. --- 837,852 ----
  374.   
  375.   int total_conses, total_markers, total_symbols, total_string_size, total_vector_size;
  376.   int total_free_conses, total_free_markers, total_free_symbols;
  377. + #ifdef LISP_FLOAT_TYPE
  378. + int total_free_floats, total_floats;
  379. + #endif LISP_FLOAT_TYPE
  380.   
  381.   static void mark_object (), mark_buffer ();
  382.   static void clear_marks (), gc_sweep ();
  383.   static void compact_strings ();
  384.   
  385. + #ifndef LISP_FLOAT_TYPE
  386.   DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
  387.     "Reclaim storage for Lisp objects no longer needed.\n\
  388.   Returns info on amount of space in use:\n\
  389. ***************
  390. *** 738,745 ****
  391.    ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
  392.     (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS)\n\
  393.   Garbage collection happens automatically if you cons more than\n\
  394. ! gc-cons-threshold  bytes of Lisp data since previous garbage collection.")
  395.     ()
  396.   {
  397.     register struct gcpro *tail;
  398.     register struct specbinding *bind;
  399. --- 853,873 ----
  400.    ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
  401.     (USED-MARKERS . FREE-MARKERS) USED-STRING-CHARS USED-VECTOR-SLOTS)\n\
  402.   Garbage collection happens automatically if you cons more than\n\
  403. ! gc-cons-threshold  bytes of Lisp data since previous garbage collection."
  404. !        )
  405.     ()
  406. + #else LISP_FLOAT_TYPE
  407. + DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",  "Reclaim storage for Lisp objects no longer needed.\n\
  408. + Returns info on amount of space in use:\n\
  409. +  ((USED-CONSES . FREE-CONSES) (USED-SYMS . FREE-SYMS)\n\
  410. +   (USED-MARKERS . FREE-MARKERS) (USED-FLOATS . FREE-FLOATS) \n\
  411. +   USED-STRING-CHARS USED-VECTOR-SLOTS)\n\
  412. + Garbage collection happens automatically if you cons more than\n\
  413. + gc-cons-threshold  bytes of Lisp data since previous garbage collection."
  414. +        )
  415. +   ()
  416. + #endif LISP_FLOAT_TYPE
  417.   {
  418.     register struct gcpro *tail;
  419.     register struct specbinding *bind;
  420. ***************
  421. *** 859,867 ****
  422. --- 987,1004 ----
  423.                     make_number (total_free_symbols)),
  424.                  Fcons (Fcons (make_number (total_markers),
  425.                        make_number (total_free_markers)),
  426. + #ifdef LISP_FLOAT_TYPE
  427. +                   Fcons (Fcons (make_number (total_floats),
  428. +                         make_number (total_free_floats)),
  429. +                      Fcons (make_number (total_string_size),
  430. +                         Fcons (make_number (total_vector_size),
  431. +                            Qnil))))));
  432. + #else not LISP_FLOAT_TYPE
  433.                     Fcons (make_number (total_string_size),
  434.                        Fcons (make_number (total_vector_size),
  435.                           Qnil)))));
  436. + #endif LISP_FLOAT_TYPE
  437.   }
  438.   
  439.   #if 0
  440. ***************
  441. *** 1053,1058 ****
  442. --- 1190,1201 ----
  443.       goto loop;
  444.         }
  445.   
  446. + #ifdef LISP_FLOAT_TYPE
  447. +  case Lisp_Float:
  448. +       XMARK (XFLOAT (obj)->type);
  449. +       break;
  450. + #endif LISP_FLOAT_TYPE
  451.       case Lisp_Buffer:
  452.         if (!XMARKBIT (XBUFFER (obj)->name))
  453.       mark_buffer (obj);
  454. ***************
  455. *** 1137,1143 ****
  456. --- 1280,1316 ----
  457.       total_conses = num_used;
  458.       total_free_conses = num_free;
  459.     }
  460. + #ifdef LISP_FLOAT_TYPE
  461. +   /* Put all unmarked floats on free list */
  462. +   {
  463. +     register struct float_block *fblk;
  464. +     register int lim = float_block_index;
  465. +     register int num_free = 0, num_used = 0;
  466.   
  467. +     float_free_list = 0;
  468. +   
  469. +     for (fblk = float_block; fblk; fblk = fblk->next)
  470. +       {
  471. +     register int i;
  472. +     for (i = 0; i < lim; i++)
  473. +       if (!XMARKBIT (fblk->floats[i].type))
  474. +         {
  475. +           XFASTINT (fblk->floats[i].type) = (int) float_free_list;
  476. +           num_free++;
  477. +           float_free_list = &fblk->floats[i];
  478. +         }
  479. +       else
  480. +         {
  481. +           num_used++;
  482. +           XUNMARK (fblk->floats[i].type);
  483. +         }
  484. +     lim = FLOAT_BLOCK_SIZE;
  485. +       }
  486. +     total_floats = num_used;
  487. +     total_free_floats = num_free;
  488. +   }
  489. + #endif LISP_FLOAT_TYPE
  490.     /* Put all unmarked symbols on free list */
  491.     {
  492.       register struct symbol_block *sblk;
  493. ***************
  494. *** 1412,1417 ****
  495. --- 1585,1593 ----
  496.     all_vectors = 0;
  497.     init_strings ();
  498.     init_cons ();
  499. + #ifdef LISP_FLOAT_TYPE
  500. +   init_float ();
  501. + #endif LISP_FLOAT_TYPE
  502.     init_symbol ();
  503.     init_marker ();
  504.     gcprolist = 0;
  505. *** src/callint.c.orig    Tue Jun 28 19:57:24 1988
  506. --- src/callint.c    Fri Sep  2 23:01:26 1988
  507. ***************
  508. *** 353,359 ****
  509. --- 353,364 ----
  510.       case 'n':        /* Read number from minibuffer.  */
  511.         do
  512.           args[i] = Fread_minibuffer (build_string (prompt), Qnil);
  513. + #ifdef LISP_FLOAT_TYPE
  514. +       while ((XTYPE (args[i]) != Lisp_Int) &&
  515. +          (XTYPE (args[i]) != Lisp_Float));
  516. + #else
  517.         while (XTYPE (args[i]) != Lisp_Int);
  518. + #endif
  519.         visargs[i] = last_minibuf_string;
  520.         break;
  521.   
  522. *** src/config.h-dist.orig    Thu Apr 21 03:18:33 1988
  523. --- src/config.h-dist    Fri Sep  2 23:01:27 1988
  524. ***************
  525. *** 18,24 ****
  526. --- 18,29 ----
  527.   file named COPYING.  Among other things, the copyright notice
  528.   and this notice must be preserved on all copies.  */
  529.   
  530. + /* This is a hack feature added by me.
  531. +  * It probably won't break anything too badly, but it may not do
  532. +  * much for you either. -Wolfgang Rupprecht 10/25/87
  533. +  */
  534.   
  535. + /* #define LISP_FLOAT_TYPE        /* define this for floating pt. numbers */
  536.   
  537.   /* Include here a s- file that describes the system type you are using.
  538.      See the file ../etc/MACHINES for a list of systems and
  539. ***************
  540. *** 100,110 ****
  541.      Note that s-vms.h and m-sun2.h may override this default.  */
  542.   
  543.   #ifndef PURESIZE
  544. ! #ifdef HAVE_X_WINDOWS
  545. ! #define PURESIZE 122000
  546. ! #else
  547. ! #define PURESIZE 118000
  548. ! #endif
  549.   #endif
  550.   
  551.   /* Define HIGHPRI as a negative number
  552. --- 105,119 ----
  553.      Note that s-vms.h and m-sun2.h may override this default.  */
  554.   
  555.   #ifndef PURESIZE
  556. ! # ifdef HAVE_X_WINDOWS
  557. ! #  define PURESIZE 122000
  558. ! # else
  559. ! #  ifdef LISP_FLOAT_TYPE        /* oink oink */
  560. ! #   define PURESIZE 122000
  561. ! #  else
  562. ! #   define PURESIZE 118000
  563. ! #  endif
  564. ! # endif
  565.   #endif
  566.   
  567.   /* Define HIGHPRI as a negative number
  568. *** src/crt0.c.orig    Wed Aug 31 02:48:46 1988
  569. --- src/crt0.c    Thu Apr 20 10:57:02 1989
  570. ***************
  571. *** 369,374 ****
  572. --- 369,379 ----
  573.   
  574.   _start ()
  575.   {
  576. + #ifdef LISP_FLOAT_TYPE
  577. + # ifdef sun3
  578. +   finitfp_();
  579. + # endif
  580. + #endif
  581.   /* On 68000, _start pushes a6 onto stack  */
  582.     start1 ();
  583.   }
  584. *** src/data.c.orig    Fri Aug 26 20:36:23 1988
  585. --- src/data.c    Fri Sep  2 23:01:39 1988
  586. ***************
  587. *** 1,3 ****
  588. --- 1,15 ----
  589. + /******************************************************************************
  590. + *                                          *
  591. + *    File:     data.c                              *
  592. + *    Author:   Wolfgang S. Rupprecht <wolfgang@wsrcc.com>                 *
  593. + *    Created:  Mon Nov  2 15:22:23 EST 1987                      *
  594. + *    Contents: GNU data.c with my float code                      *
  595. + *                                          *
  596. + *    Copyright (c) 1987 Wolfgang Rupprecht.                      *
  597. + *    All rights reserved.                              *
  598. + *                                          *
  599. + *    $Log$                                      *
  600. + ******************************************************************************/
  601.   /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter.
  602.      Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  603.   
  604. ***************
  605. *** 28,33 ****
  606. --- 40,49 ----
  607.   #include "buffer.h"
  608.   #endif
  609.   
  610. + #ifdef LISP_FLOAT_TYPE
  611. + #include <math.h>
  612. + #endif LISP_FLOAT_TYPE
  613.   Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound;
  614.   Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
  615.   Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range;
  616. ***************
  617. *** 41,47 ****
  618. --- 57,68 ----
  619.   Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp;
  620.   Lisp_Object Qboundp, Qfboundp;
  621.   Lisp_Object Qcdr;
  622. + #ifdef LISP_FLOAT_TYPE
  623. + Lisp_Object Qfloatp, Qinteger_or_floatp, Qinteger_or_float_or_marker_p;
  624. + #endif LISP_FLOAT_TYPE
  625.   
  626.   Lisp_Object
  627.   wrong_type_argument (predicate, value)
  628.        register Lisp_Object predicate, value;
  629. ***************
  630. *** 177,182 ****
  631. --- 198,238 ----
  632.     return Qnil;
  633.   }
  634.   
  635. + #ifdef LISP_FLOAT_TYPE
  636. + DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0,
  637. +        "T if OBJECT is a floating pt. number.")
  638. +   (obj)
  639. +      Lisp_Object obj;
  640. + {
  641. +   if (XTYPE (obj) == Lisp_Float)
  642. +     return Qt;
  643. +   return Qnil;
  644. + }
  645. + DEFUN ("integer-or-floatp", Finteger_or_floatp, Sinteger_or_floatp,
  646. +        1, 1, 0, "T if OBJECT is a floating pt. or normal number.")
  647. +   (obj)
  648. +      Lisp_Object obj;
  649. + {
  650. +   if ((XTYPE (obj) == Lisp_Float) || (XTYPE (obj) == Lisp_Int))
  651. +     return Qt;
  652. +   return Qnil;
  653. + }
  654. + DEFUN ("integer-or-float-or-marker-p", Finteger_or_float_or_marker_p,
  655. +        Sinteger_or_float_or_marker_p, 1, 1, 0,
  656. +        "T if OBJECT is a floating pointt, normal number, or marker.")
  657. +   (obj)
  658. +      Lisp_Object obj;
  659. + {
  660. +   if ((XTYPE (obj) == Lisp_Float) ||
  661. +       (XTYPE (obj) == Lisp_Int) ||
  662. +       (XTYPE (obj) == Lisp_Marker))
  663. +     return Qt;
  664. +   return Qnil;
  665. + }
  666. + #endif LISP_FLOAT_TYPE
  667.   DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, "T if OBJECT is a nonnegative number.")
  668.     (obj)
  669.        Lisp_Object obj;
  670. ***************
  671. *** 961,968 ****
  672. --- 1017,1041 ----
  673.     (num1, num2)
  674.        register Lisp_Object num1, num2;
  675.   {
  676. + #ifdef LISP_FLOAT_TYPE
  677. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  678. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  679. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  680. +     {
  681. +       double f1, f2;
  682. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  683. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  684. +       if (f1 == f2)
  685. +     return Qt;
  686. +       return Qnil;
  687. +     }
  688. + #else
  689.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  690.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  691. + #endif LISP_FLOAT_TYPE
  692.   
  693.     if (XINT (num1) == XINT (num2))
  694.       return Qt;
  695. ***************
  696. *** 974,981 ****
  697. --- 1047,1070 ----
  698.     (num1, num2)
  699.        register Lisp_Object num1, num2;
  700.   {
  701. + #ifdef LISP_FLOAT_TYPE
  702. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  703. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  704. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  705. +     {
  706. +       double f1, f2;
  707. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  708. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  709. +       if (f1 < f2)
  710. +     return Qt;
  711. +       return Qnil;
  712. +     }
  713. + #else
  714.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  715.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  716. + #endif LISP_FLOAT_TYPE
  717.   
  718.     if (XINT (num1) < XINT (num2))
  719.       return Qt;
  720. ***************
  721. *** 987,994 ****
  722. --- 1076,1099 ----
  723.     (num1, num2)
  724.        register Lisp_Object num1, num2;
  725.   {
  726. + #ifdef LISP_FLOAT_TYPE
  727. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  728. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
  729. +   if ((XTYPE(num1) == Lisp_Float) || (XTYPE(num2) == Lisp_Float))
  730. +     {
  731. +       double f1, f2;
  732. +       f1 = (XTYPE(num1) == Lisp_Float) ? XFLOAT(num1)->data : XINT(num1);
  733. +       f2 = (XTYPE(num2) == Lisp_Float) ? XFLOAT(num2)->data : XINT(num2);
  734. +       if (f1 > f2)
  735. +     return Qt;
  736. +       return Qnil;
  737. +     }
  738. + #else
  739.     CHECK_NUMBER_COERCE_MARKER (num1, 0);
  740.     CHECK_NUMBER_COERCE_MARKER (num2, 0);
  741. + #endif LISP_FLOAT_TYPE
  742.   
  743.     if (XINT (num1) > XINT (num2))
  744.       return Qt;
  745. ***************
  746. *** 1000,1007 ****
  747. --- 1105,1128 ----
  748.     (num1, num2)
  749.        register Lisp_Object num1, num2;
  750.   {
  751. + #ifdef LISP_FLOAT_TYPE
  752. +   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
  753. +   CHECK_NUMBER