summaryrefslogtreecommitdiff
path: root/src/floatfns.c
Commit message (Collapse)AuthorAgeFilesLines
* Help GCC compute modiff_incrPaul Eggert2023-05-141-11/+1
| | | | | | | | | | | * src/floatfns.c: Don’t include count-leading-zeros.h, since we no longer use it directly. (ecount_leading_zeros): Remove. (Flogb): Use elogb instead of doing it by hand. * src/lisp.h: Include count-leading-zeros.h. (elogb): New macro. (modiff_incr): Use it so that on typical platforms we use a hardware instruction instead of a loop.
* Update some commentary for C23Paul Eggert2023-02-041-2/+5
|
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
|
* * src/floatfns.c: Update comment.Paul Eggert2022-05-101-8/+14
|
* Merge from origin/emacs-28Eli Zaretskii2022-01-011-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year. 86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year ebe8772f65 ; Minor fixes related to copyright years 23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye... 8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t. 19dcb237b5 ; Add 2022 to copyright years. # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex # lib/cdefs.h # lisp/erc/erc-dcc.el # lisp/erc/erc-imenu.el # lisp/erc/erc-replace.el # lisp/image-dired.el # lisp/progmodes/xref.el # m4/alloca.m4 # m4/byteswap.m4 # m4/errno_h.m4 # m4/getopt.m4 # m4/gnulib-common.m4 # m4/inttypes.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/sys_socket_h.m4
| * ; Add 2022 to copyright years.Eli Zaretskii2022-01-011-1/+1
| |
* | Add support for the Haiku operating system and its window systemPo Lu2021-11-201-0/+15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .gitignore: Add binaries specific to Haiku. * Makefie.in (HAVE_BE_APP): New variable. (install-arch-dep): Install Emacs and Emacs.pdmp when using Haiku. * configure.ac: Detect and configure for Haiku and various related configurations. (be-app, be-freetype, be-cairo): New options. (HAVE_BE_APP, HAIKU_OBJ, HAIKU_CXX_OBJ) (HAIKU_LIBS, HAIKU_CFLAGS): New variables. (HAIKU, HAVE_TINY_SPEED_T): New define. (emacs_config_features): Add BE_APP. * doc/emacs/Makefile.in (EMACSSOURCES): Add Haiku appendix. * doc/emacs/emacs.texi: Add Haiku appendix to menus and include it. * doc/emacs/haiku.texi: New Haiku appendix. * doc/lispref/display.texi (Defining Faces, Window Systems): Explain meaning of `haiku' as a window system identifier. (haiku-use-system-tooltips): Explain meaning of system tooltips on Haiku. * doc/lispref/frames.texi (Multiple Terminals): Explain meaning of haiku as a display type. (Frame Layout): Clarify section for Haiku frames. (Size Parameters): Explain limitations of fullwidth and fullheight on Haiku. (Management Parameters): Explain limitations of inhibiting double buffering on builds with Cairo, and the inability of frames with no-accept-focus to receive keyboard input on Haiku. (Font and Color Parameters): Explain the different font backends available on Haiku. (Raising and Lowering): Explain that lowering and restacking frames doesn't work on Haiku. (Child Frames): Explain oddities of child frame visibility on Haiku. * doc/lispref/os.texi (System Environment): Explain meaning of haiku. * etc/MACHINES: Add appropriate notices for Haiku. * etc/NEWS: Document changes. * etc/PROBLEMS: Document font spacing bug on Haiku. * lib-src/Makefile.in: Build be-resources binary on Haiku. (CXX, CXXFLAGS, NON_CXX_FLAGS, ALL_CXXFLAGS) (HAVE_BE_APP, HAIKU_LIBS, HAIKU_CFLAGS): New variables. (DONT_INSTALL): Add be-resources binary if on Haiku. (be-resources): New target. * lib-src/be_resources: Add helper binary for setting resources on the Emacs application. * lib-src/emacsclient.c (decode_options): Set alt_display to "be" on Haiku. * lisp/cus-edit.el (custom-button, custom-button-mouse) (custom-button-unraised, custom-button-pressed): Update face definitions for Haiku. * lisp/cus-start.el: Add haiku-debug-on-fatal-error and haiku-use-system-tooltips. * lisp/faces.el (face-valid-attribute-values): Clarify attribute comment for Haiku. (tool-bar): Add appropriate toolbar color for Haiku. * lisp/frame.el (haiku-frame-geometry) (haiku-mouse-absolute-pixel-position) (haiku-set-mouse-absolute-pixel-position) (haiku-frame-edges) (haiku-frame-list-z-order): New function declarations. (frame-geometry, frame-edges) (mouse-absolute-pixel-position) (set-mouse-absolute-pixel-position) (frame-list-z-order): Call appropriate window system functions on Haiku. (display-mouse-p, display-graphic-p) (display-images-p, display-pixel-height) (display-pixel-width, display-mm-height) (display-mm-width, display-backing-store) (display-save-under, display-planes) (display-color-cells, display-visual-class): Update type tests for Haiku. * lisp/international/mule-cmds.el (set-coding-system-map): Also prevent set-terminal-coding-system from appearing in the menu bar on Haiku. * lisp/loadup.el: Load Haiku-specific files when built with Haiku, and don't rename newly built Emacs on Haiku as BFS doesn't support hard links. * lisp/menu-bar.el (menu-bar-open): Add for Haiku. * lisp/mwheel.el (mouse-wheel-down-event): Expect wheel-up on Haiku. (mouse-wheel-up-event): Expect wheel-down on Haiku. (mouse-wheel-left-event): Expect wheel-left on Haiku. (mouse-wheel-right-event): Expect wheel-right on Haiku. * lisp/net/browse-url.el (browse-url--browser-defcustom-type): Add option for WebPositive. (browse-url-webpositive-program): New variable. (browse-url-default-program): Search for WebPositive. (browse-url-webpositive): New function. * lisp/net/eww.el (eww-form-submit, eww-form-file) (eww-form-checkbox, eww-form-select): Define faces appropriately for Haiku. * lisp/term/haiku-win.el: New file. * lisp/tooltip.el (menu-or-popup-active-p): New function declaration. (tooltip-show-help): Don't use tooltips on Haiku when a menu is active. * lisp/version.el (haiku-get-version-string): New function declaration. (emacs-version): Add Haiku version string if appropriate. * src/Makefile.in: Also produce binary named "Emacs" with Haiku resources set. (CXX, HAIKU_OBJ, HAIKU_CXX_OBJ, HAIKU_LIBS) (HAIKU_CFLAGS, HAVE_BE_APP, NON_CXX_FLAGS) (ALL_CXX_FLAGS): New variables. (.SUFFIXES): Add .cc. (.cc.o): New target. (base_obj): Add Haiku C objects. (doc_obj, obj): Split objects that should scanned for documentation into doc_obj. (SOME_MACHINE_OBJECTS): Add appropriate Haiku C objects. (all): Depend on Emacs and Emacs.pdmp on Haiku. (LIBES): Add Haiku libraries. (gl-stamp) ($(etc)/DOC): Scan doc_obj instead of obj (temacs$(EXEEXT): Use C++ linker on Haiku. (ctagsfiles3): New variable. (TAGS): Scan C++ files. * src/alloc.c (garbage_collect): Mark Haiku display. * src/dispextern.h (HAVE_NATIVE_TRANSFORMS): Also enable on Haiku. (struct image): Add fields for Haiku transforms. (RGB_PIXEL_COLOR): Define to unsigned long on Haiku as well. (sit_for): Also check USABLE_SIGPOLL. (init_display_interactive): Set initial window system to Haiku on Haiku builds. * src/emacs.c (main): Define Haiku syms and init haiku clipboard. (shut_down_emacs): Quit BApplication on Haiku and trigger debug on aborts if haiku_debug_on_fatal_error. (Vsystem_type): Update docstring. * src/fileio.c (next-read-file-uses-dialog-p): Enable on Haiku. * src/filelock.c (WTMP_FILE): Only define if BOOT_TIME is also defined. * src/floatfns.c (double_integer_scale): Work around Haiku libroot brain damage. * src/font.c (syms_of_font): Define appropriate font driver symbols for Haiku builds with various options. * src/font.h: Also enable ftcrfont on Haiku builds with Cairo. (font_data_structures_may_be_ill_formed): Also enable on Haiku builds that have Cairo. * src/frame.c (Fframep): Update doc-string for Haiku builds and return haiku if appropriate. (syms_of_frame): New symbol `haiku'. * src/frame.h (struct frame): Add output data for Haiku. (FRAME_HAIKU_P): New macro. (FRAME_WINDOW_P): Test for Haiku frames as well. * src/ftcrfont.c (RED_FROM_ULONG, GREEN_FROM_ULONG) (BLUE_FROM_ULONG): New macros. (ftcrfont_draw): Add haiku specific code for Haiku builds with Cairo. * src/ftfont.c (ftfont_open): Set face. (ftfont_has_char, ftfont_text_extents): Work around crash. (syms_of_ftfont): New symbol `mono'. * src/ftfont.h (struct font_info): Enable Cairo-specific fields for Cairo builds on Haiku. * src/haiku_draw_support.cc: * src/haiku_font_support.cc: * src/haiku_io.c: * src/haiku_select.cc: * src/haiku_support.cc: * src/haiku_support.h: * src/haikufns.c: * src/haikufont.c: * src/haikugui.h: * src/haikuimage.c: * src/haikumenu.c: * src/haikuselect.c: * src/haikuselect.h: * src/haikuterm.c: * src/haikuterm.h: Add new files for Haiku windowing support. * src/haiku.c: Add new files for Haiku operating system support. * src/image.c: Implement image transforms and native XPM support on Haiku. (GET_PIXEL, PUT_PIXEL, NO_PIXMAP) (PIX_MASK_RETAIN, PIX_MASK_DRAW) (RGB_TO_ULONG, RED_FROM_ULONG, GREEN_FROM_ULONG) (BLUE_FROM_ULONG, RED16_FROM_ULONG, GREEN16_FROM_ULONG) (BLUE16_FROM_ULONG): Define to appropriate values on Haiku. (image_create_bitmap_from_data): Add Haiku support. (image_create_bitmap_from_file): Add TODO on Haiku. (free_bitmap_record): Free bitmap on Haiku. (image_size_in_bytes): Implement for Haiku bitmaps. (image_set_transform): Implement on Haiku. (image_create_x_image_and_pixmap_1): Implement on Haiku, 24-bit or 1-bit only. (image_destroy_x_image, image_get_x_image): Use correct img and pixmap values on Haiku. (lookup_rgb_color): Use correct macro on Haiku. (image_to_emacs_colors): Implement on Haiku. (image_disable_image): Disable on Haiku. (image_can_use_native_api): Test for translator presence on Haiku. (native_image_load): Use translator on Haiku. (imagemagick_load_image): Add Haiku-specific quirks. (Fimage_transforms_p): Allow rotate90 on Haiku. (image_types): Enable native XPM support on Haiku. (syms_of_image): Enable XPM images on Haiku. * src/keyboard.c (kbd_buffer_get_event) (handle_async_input, handle_input_available_signal) (handle_user_signal, Fset_input_interrupt_mode) (init_keyboard): Check for USABLE_SIGPOLL along with USABLE_SIGIO. * src/lisp.h (pD): Work around broken Haiku headers. (HAVE_EXT_MENU_BAR): Define on Haiku. (handle_input_available_signal): Enable if we just have SIGPOLL as well. * src/menu.c (have_boxes): Return true on Haiku. (single_menu_item): Enable toolkit menus on Haiku. (find_and_call_menu_selection): Also enable on Haiku. * src/process.c (keyboard_bit_set): Enable with only usable SIGPOLL. (wait_reading_process_output): Test for SIGPOLL as well as SIGIO availability. * src/sound.c (sound_perror, vox_open) (vox_configure, vox_close): Enable for usable SIGPOLL as well. * src/sysdep.c (sys_subshell): Enable for usable SIGPOLL. (reset_sigio): Make conditional on F_SETOWN. (request_sigio, unrequest_sigio) (emacs_sigaction_init): Also handle SIGPOLLs. (init_sys_modes): Disable TCXONC usage on Haiku, as it doesn't have any ttys other than pseudo ttys, which don't support C-s/C-q flow control, and causes compiler warnings. (speeds): Disable high speeds if HAVE_TINY_SPEED_T. * src/termhooks.h (enum output_method): Add output_haiku. (struct terminal): Add Haiku display info. (TERMINAL_FONT_CACHE): Enable for Haiku. * src/terminal.c (Fterminal_live_p): Return `haiku' if appropriate. * src/verbose.mk.in (AM_V_CXX, AM_V_CXXLD): New logging variables. * src/xdisp.c (redisplay_internal) (note_mouse_highlight): Return on Haiku if a popup is activated. (display_menu_bar): Return on Haiku if frame is a Haiku frame. * src/xfaces.c (GCGraphicsExposures): Enable correctly on Haiku. (x_create_gc): Enable dummy GC code on Haiku. * src/xfns.c (x-server-version, x-file-dialog): Add Haiku specifics to doc strings. * src/xterm.c (syms_of_xterm): Add Haiku information to doc string.
* Update copyright year to 2021Paul Eggert2021-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Port new float-scaling code to SolarisPaul Eggert2019-11-151-4/+1
| | | | | | * src/floatfns.c (double_integer_scale): Simplify, so that the function works when (FP_ILOGBNAN == INT_MAX && FP_ILOGB0 == INT_MIN), as on Solaris.
* Handle weird cases like (ceil 0 0.0)Paul Eggert2019-11-141-9/+20
| | | | | | | | | | | * src/floatfns.c (double_integer_scale): Distinguish Inf from NaN. (rounding_driver): Handle (ceil 0 0.0) and (ceil 0 1.0e+INF). * test/src/floatfns-tests.el (special-round): Add tests for weird cases like this. Avoid crash with (floor 0 0.0) * src/floatfns.c (rounding_driver): Signal an arithmetic error if divisor is 0.0 or -0.0, instead of crashing.
* Fix double-rounding bug in ceiling etc.Paul Eggert2019-11-131-65/+50
| | | | | | | | | | | | This is doable now that we have bignums. * src/floatfns.c (integer_value): Remove; no longer used. (rescale_for_division): New function. (rounding_driver): Use it to divide properly (by using bignums) even when arguments are float, fixing a double-rounding FIXME. * src/lisp.h (LOG2_FLT_RADIX): Move here ... * src/timefns.c (frac_to_double): ... from here. * test/src/floatfns-tests.el (big-round): Add a test to catch the double-rounding bug.
* Refactor double integer scalingPaul Eggert2019-11-131-0/+23
| | | | | | | This doesn’t alter behavior, and simplifies a future commit. * src/floatfns.c (double_integer_scale): New function, with body adapted from the old timefns.c. * src/timefns.c (decode_float_time): Use it.
* lisp/*.el, src/*.c: Fix typos in docstringsJuanma Barranquero2019-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/apropos.el (apropos-do-all): * lisp/auth-source-pass.el (auth-source-pass--select-from-entries): * lisp/auth-source.el (auth-source-user-or-password): * lisp/calc/calc-forms.el (math-tzone-names): * lisp/calendar/diary-lib.el (diary-face-attrs) (diary-mark-entries-1): * lisp/cedet/cedet-files.el (cedet-files-list-recursively): * lisp/cedet/ede.el (ede-constructing, ede-deep-rescan): * lisp/cedet/ede/cpp-root.el (ede-cpp-root-header-file-p): * lisp/cedet/ede/proj.el (ede-proj-target-makefile): * lisp/cedet/inversion.el (inversion-check-version) (inversion-test): * lisp/cedet/mode-local.el (mode-local-map-file-buffers): * lisp/cedet/semantic/complete.el (semantic-displayer-ghost): * lisp/cedet/semantic/db-find.el (semanticdb-find-translate-path-default): * lisp/cedet/semantic/db.el (semanticdb-table) (semanticdb-search-system-databases): * lisp/cedet/semantic/imenu.el (semantic-imenu-index-directory): * lisp/cedet/semantic/java.el (semantic-java-doc-keywords-map): * lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-use-headers-flag): * lisp/cedet/semantic/lex.el (semantic-lex-make-keyword-table) (semantic-lex-make-type-table, semantic-lex-debug-analyzers): * lisp/cedet/semantic/tag-ls.el (semantic-tag-abstract-p) (semantic-tag-leaf-p, semantic-tag-static-p) (semantic-tag-prototype-p): * lisp/dnd.el (dnd-open-remote-file-function, dnd-open-local-file): * lisp/emacs-lisp/eieio-opt.el (eieio-build-class-alist) (eieio-read-class, eieio-read-subclass): * lisp/emacs-lisp/generator.el (cps--replace-variable-references) (cps--handle-loop-for): * lisp/erc/erc-dcc.el (erc-dcc-list, erc-dcc-member, erc-dcc-server) (erc-dcc-auto-mask-p, erc-dcc-get-file, erc-dcc-chat-accept): * lisp/eshell/em-pred.el (eshell-pred-file-type): * lisp/faces.el (defined-colors-with-face-attributes): * lisp/font-core.el (font-lock-mode): * lisp/frame.el (frame-restack): * lisp/net/shr.el (shr-image-animate): * lisp/org/org-agenda.el (org-agenda-change-all-lines) (org-agenda-today-p): * lisp/org/org-id.el (org-id-get): * lisp/org/org.el (org-highlight-latex-and-related) (org--valid-property-p): * lisp/org/ox-beamer.el (org-beamer--get-label): * lisp/org/ox-latex.el (org-latex--caption-above-p): * lisp/org/ox-odt.el (org-odt--copy-image-file) (org-odt--copy-formula-file): * lisp/org/ox.el (org-export-with-timestamps): * lisp/progmodes/verilog-mode.el (verilog-indent-declaration-macros): * lisp/ses.el (ses-file-format-extend-parameter-list): * lisp/term.el (ansi-term): * lisp/textmodes/bibtex.el (bibtex-no-opt-remove-re) (bibtex-beginning-of-first-entry, bibtex-autokey-get-title) (bibtex-read-key, bibtex-initialize): * lisp/textmodes/flyspell.el (flyspell-word): * lisp/view.el (view-mode-exit): * src/composite.c: * src/floatfns.c (Fisnan): Fix typos in docstrings.
* ; * src/floatfns.c: Don't use non-ASCII characters in comments.Eli Zaretskii2019-08-311-1/+1
|
* * src/floatfns.c: Check against __FINITE_MATH_ONLY__ (bug#37140)Mattias Engdegård2019-08-301-0/+8
|
* Be more careful about pointers to bignum valsPaul Eggert2019-08-211-3/+3
| | | | | | | | | | | | | | | This uses ‘const’ to be better at catching bugs that mistakenly attempt to modify a bignum value. Lisp bignums are supposed to be immutable. * src/alloc.c (make_pure_bignum): * src/fns.c (sxhash_bignum): Accept Lisp_Object instead of struct Lisp_Bignum *, as that’s simpler now. Caller changed. * src/bignum.h (bignum_val, xbignum_val): New inline functions. Prefer them to &i->value and XBIGNUM (i)->value, since they apply ‘const’ to the result. * src/timefns.c (lisp_to_timespec): Use mpz_t const * to point to a bignum value.
* Fix logb on zero, infinite, NaN argsPaul Eggert2019-01-061-16/+11
| | | | | | | | | Change logb to return -infinity, +infinity, and NaN respectively. Formerly logb returned an extreme fixnum to represent infinity, but this is no longer the right thing to do now that we have bignums and there is no extreme integer. * doc/lispref/numbers.texi (Float Basics), etc/NEWS: Document. * src/floatfns.c (Flogb): Implement this.
* Merge from origin/emacs-26Paul Eggert2018-12-311-1/+1
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* | Fix (floor 54043195528445955 3.0) bugPaul Eggert2018-09-131-1/+19
| | | | | | | | | | | | | | * src/floatfns.c (rounding_driver): Fix rounding error that can occur when both args have values exactly representable as integers but at least one arg is a float. * test/src/floatfns-tests.el (big-round): New test.
* | Minor rounding_driver simplificationPaul Eggert2018-09-111-8/+5
| | | | | | | | | | | | | | * src/floatfns.c (rounding_driver): Omit last arg, which is now unused. All callers changed. Signal overflow-error for bignum overflow
* | Fix misleading name ‘double_to_bignum’Paul Eggert2018-09-101-1/+1
| | | | | | | | | | * src/bignum.c (double_to_integer): Rename from double_to_bignum, since the result is not necessarily a bignum. All uses changed.
* | Improve (round FIXNUM FIXNUM) performancePaul Eggert2018-09-051-22/+52
| | | | | | | | | | | | | | | | * src/floatfns.c (rounding_driver): New arg fixnum_divide. All callers changed. (ceiling2, floor2, truncate2, round2): New functions. Not that new, actually; these are essentially taken from Emacs 26. (Fceiling, Ffloor, Fround, Ftruncate): Use them.
* | Fix (round FLOAT BIGNUM) bugPaul Eggert2018-09-041-2/+5
| | | | | | | | | | | | * src/floatfns.c (rounding_driver): Fix bug when one argument is a float and the other is a bignum. * test/src/floatfns-tests.el (bignum-round): Test for the bug.
* | Speed up (+ 2 2) by a factor of 10Paul Eggert2018-09-031-31/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve arithmetic performance by avoiding bignums until needed. Also, simplify bignum memory management, fixing some unlikely leaks. This patch improved the performance of (+ 2 2) by a factor of ten on a simple microbenchmark computing (+ x 2), byte-compiled, with x a local variable initialized to 2 via means the byte compiler could not predict: performance improved from 135 to 13 ns. The platform was Fedora 28 x86-64, AMD Phenom II X4 910e. Performance also improved 0.6% on ‘make compile-always’. * src/bignum.c (init_bignum_once): New function. * src/emacs.c (main): Use it. * src/bignum.c (mpz): New global var. (make_integer_mpz): Rename from make_integer. All uses changed. * src/bignum.c (double_to_bignum, make_bignum_bits) (make_bignum, make_bigint, make_biguint, make_integer_mpz): * src/data.c (bignum_arith_driver, Frem, Flogcount, Fash) (expt_integer, Fadd1, Fsub1, Flognot): * src/floatfns.c (Fabs, rounding_driver, rounddiv_q): * src/fns.c (Fnthcdr): Use mpz rather than mpz_initting and mpz_clearing private temporaries. * src/bignum.h (bignum_integer): New function. * src/data.c (Frem, Fmod, Fash, expt_integer): * src/floatfns.c (rounding_driver): Use it to simplify code. * src/data.c (FIXNUMS_FIT_IN_LONG, free_mpz_value): Remove. All uses removed. (floating_point_op): New function. (floatop_arith_driver): New function, with much of the guts of the old float_arith_driver. (float_arith_driver): Use it. (floatop_arith_driver, arith_driver): Simplify by assuming NARGS is at least 2. All callers changed. (float_arith_driver): New arg, containing the partly converted value of the next arg. Reorder args for consistency. All uses changed. (bignum_arith_driver): New function. (arith_driver): Use it. Do fixnum-only integer calculations in intmax_t instead of mpz_t, when they fit. Break out mpz_t calculations into bignum_arith_driver. (Fquo): Use floatop_arith_driver instead of float_arith_driver, since the op is known to be valid. (Flogcount, Fash): Simplify by coalescing bignum and fixnum code. (Fadd1, Fsub1): Simplify by using make_int.
* | Fix Fnatnump typosPaul Eggert2018-08-281-1/+1
| | | | | | | | | | | | | | | | Problem reported by Glenn Morris in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00946.html * src/floatfns.c (Fexpt): * src/xselect.c (cons_to_x_long): Don't assume Lisp_Object values are scalars.
* | Modularize bignums betterPaul Eggert2018-08-271-35/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/bignum.c, src/bignum.h: New files. Only modules that need to know how bignums are implemented should include bignum.h. Currently these are alloc.c, bignum.c (of course), data.c, emacs.c, emacs-module.c, floatfns.c, fns.c, print.c. * src/Makefile.in (base_obj): Add bignum.o. * src/alloc.c (make_bignum_str): Move to bignum.c. (make_number): Remove; replaced by bignum.c’s make_integer. All callers changed. * src/conf_post.h (ARG_NONNULL): New macro. * src/json.c (json_to_lisp): Use it. * src/data.c (Fnatnump): Move NATNUMP’s implementation here from lisp.h. * src/data.c (Fnumber_to_string): * src/editfns.c (styled_format): Move conversion of string to bignum to bignum_to_string, and call it here. * src/emacs-module.c (module_make_integer): * src/floatfns.c (Fabs): Simplify by using make_int. * src/emacs.c: Include bignum.h, to expand its inline fns. * src/floatfns.c (Ffloat): Simplify by using XFLOATINT. (rounding_driver): Simplify by using double_to_bignum. (rounddiv_q): Clarify use of temporaries. * src/lisp.h: Move decls that need to know bignum internals to bignum.h. Do not include gmp.h or mini-gmp.h; that is now bignum.h’s job. (GMP_NUM_BITS, struct Lisp_Bignum, XBIGNUM, mpz_set_intmax): Move to bignum.h. (make_int): New function. (NATNUMP): Remove; all callers changed to use Fnatnump. (XFLOATINT): If arg is a bignum, use bignum_to_double, so that bignum internals are not exposed here. * src/print.c (print_vectorlike): Use SAFE_ALLOCA to avoid the need for a record_unwind_protect_ptr.
* | Fix bugs when rounding to bignumsPaul Eggert2018-08-221-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, since Emacs historically reported a range error when rounding operations overflowed, do that consistently for all bignum overflows. * doc/lispref/errors.texi (Standard Errors): * doc/lispref/numbers.texi (Integer Basics): Document range errors. * src/alloc.c (range_error): Rename from integer_overflow. All uses changed. * src/floatfns.c (rounding_driver): When the result of a floating point rounding operation does not fit into a fixnum, put it into a bignum instead of always signaling an range error. * test/src/floatfns-tests.el (divide-extreme-sign): These tests now return the mathematically-correct answer instead of signaling an error. (bignum-round): Check that integers round to themselves.
* | Add bignum support to floor, ceiling, etc.Paul Eggert2018-08-211-40/+55
| | | | | | | | | | | | | | | | | | | | | | Problem reported by Andy Moreton (Bug#32463#35 (d)). * src/floatfns.c (rounding_driver): Change the signature of the integer rounder to use mpz_t rather than EMACS_INT. All uses changed. Support bignums. (ceiling2, floor2, truncate2, round2): Remove. All uses changed to rounddiv_q or to a GMP library function. (rounddiv_q): New function. * test/src/floatfns-tests.el (bignum-round): New test.
* | Avoid libgmp aborts by imposing limitsPaul Eggert2018-08-211-23/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libgmp calls ‘abort’ when given numbers too big for its internal data structures. The numeric limit is large and platform-dependent; with 64-bit GMP 6.1.2 it is around 2**2**37. Work around the problem by refusing to call libgmp functions with arguments that would cause an abort. With luck libgmp will have a better way to do this in the future. Also, introduce a variable integer-width that lets the user control how large bignums can be. This currently defaults to 2**16, i.e., it allows bignums up to 2**2**16. This should be enough for ordinary computation, and should help Emacs to avoid thrashing or hanging. Problem noted by Pip Cet (Bug#32463#71). * doc/lispref/numbers.texi, etc/NEWS: Document recent bignum changes, including this one. Improve documentation for bitwise operations, in the light of bignums. * src/alloc.c (make_number): Enforce integer-width. (integer_overflow): New function. (xrealloc_for_gmp, xfree_for_gmp): Move here from emacs.c, as it's memory allocation. (init_alloc): Initialize GMP here, rather than in emacs.c. (integer_width): New var. * src/data.c (GMP_NLIMBS_MAX, NLIMBS_LIMIT): New constants. (emacs_mpz_size, emacs_mpz_mul) (emacs_mpz_mul_2exp, emacs_mpz_pow_ui): New functions. (arith_driver, Fash, expt_integer): Use them. (expt_integer): New function, containing integer code that was out of place in floatfns.c. (check_bignum_size, xmalloc_for_gmp): Remove. * src/emacs.c (main): Do not initialize GMP here. * src/floatfns.c (Fexpt): Use expt_integer, which now contains integer code moved from here. * src/lisp.h (GMP_NUMB_BITS): Define if gmp.h doesn’t.
* | Fix expt signedness bug --without-wide-intPaul Eggert2018-08-191-1/+1
| | | | | | | | | | | | | | | | Problem reported by Federico in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00619.html * src/floatfns.c (Fexpt): Use TYPE_RANGED_FIXNUMP, not RANGED_FIXNUMP, to fix bug with unsigned comparison on platforms built --without-wide-int.
* | Add bignum support to exptPaul Eggert2018-08-191-20/+27
| | | | | | | | | | | | | | | | | | | | Problem and initial solution reported by Andy Moreton in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00503.html * doc/lispref/numbers.texi (Math Functions): expt integer overflow no longer causes truncation; it now signals an error since bignum overflow is a big deal. * src/floatfns.c (Fexpt): Support bignum arguments. * test/src/floatfns-tests.el (bignum-expt): New test.
* | Fix bug with ‘mod’ and float+bignumPaul Eggert2018-08-181-4/+2
| | | | | | | | | | | | | | Problem reported by Andy Moreton in: https://lists.gnu.org/r/emacs-devel/2018-08/msg00442.html * src/floatfns.c (fmod_float): Work even if an arg is a bignum. * test/src/floatfns-tests.el (bignum-mod): New test.
* | Improve ‘abs’ performancePaul Eggert2018-08-171-17/+30
| | | | | | | | | | | | * src/floatfns.c (Fabs): Improve performance by not copying the argument if it would eql the result. As a minor detail, don't assume fixnums are two’s complement.
* | Merge remote-tracking branch 'origin/master' into feature/bignumTom Tromey2018-08-091-7/+0
|\ \
| * | Simplify by assuming C99 math.h isnan etc.Paul Eggert2018-07-311-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | These should be portable nowadays. * src/data.c (isnan): Remove. * src/floatfns.c (isfinite, isnan): Remove. * src/print.c: Include math.h, for isinf and isnan. (float_to_string): Simplify by using them.
* | | More macro renamings for bignumTom Tromey2018-08-071-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c, src/bidi.c, src/buffer.c, src/buffer.h, src/bytecode.c, src/callint.c, src/callproc.c, src/casefiddle.c, src/casetab.c, src/category.c, src/ccl.c, src/character.c, src/character.h, src/charset.c, src/charset.h, src/chartab.c, src/cmds.c, src/coding.c, src/composite.c, src/composite.h, src/data.c, src/dbusbind.c, src/decompress.c, src/dired.c, src/dispextern.h, src/dispnew.c, src/disptab.h, src/doc.c, src/dosfns.c, src/editfns.c, src/emacs-module.c, src/emacs.c, src/eval.c, src/fileio.c, src/floatfns.c, src/fns.c, src/font.c, src/font.h, src/fontset.c, src/frame.c, src/frame.h, src/fringe.c, src/ftcrfont.c, src/ftfont.c, src/gfilenotify.c, src/gnutls.c, src/gtkutil.c, src/image.c, src/indent.c, src/insdel.c, src/intervals.c, src/json.c, src/keyboard.c, src/keymap.c, src/kqueue.c, src/lcms.c, src/lisp.h, src/lread.c, src/macros.c, src/marker.c, src/menu.c, src/minibuf.c, src/msdos.c, src/print.c, src/process.c, src/profiler.c, src/search.c, src/sound.c, src/syntax.c, src/syntax.h, src/sysdep.c, src/term.c, src/termhooks.h, src/textprop.c, src/undo.c, src/w32.c, src/w32console.c, src/w32fns.c, src/w32font.c, src/w32inevt.c, src/w32proc.c, src/w32select.c, src/w32term.c, src/w32term.h, src/w32uniscribe.c, src/window.c, src/xdisp.c, src/xfaces.c, src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c, src/xml.c, src/xrdb.c, src/xselect.c, src/xsettings.c, src/xterm.c, src/xwidget.c Rename XINT->XFIXNUM, XFASTINT->XFIXNAT, XUINT->XUFIXNUM.
* | | Fix bignum creation when EMACS_INT is wider than longfeature/bignumTom Tromey2018-07-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (mpz_set_intmax_slow, mpz_set_uintmax_slow): New functions. * src/data.c (arith_driver, Frem, Fmod, ash_lsh_impl, Fadd1) (Fsub1): Use mpz_set_intmax, mpz_set_uintmax. * src/emacs-module.c (module_make_integer): Use mpz_set_intmax. * src/floatfns.c (Fabs): Use mpz_set_intmax. * src/lisp.h (mpz_set_intmax, mpz_set_uintmax): New inline functions. (mpz_set_uintmax_slow, mpz_set_intmax_slow): Declare.
* | | Make logb handle bignumsTom Tromey2018-07-121-1/+4
| | | | | | | | | | | | | | | * src/floatfns.c (Flogb): Handle bignums. * test/src/floatfns-tests.el (bignum-logb): New test.
* | | Make abs handle bignumsTom Tromey2018-07-121-2/+17
| | | | | | | | | | | | | | | * src/floatfns.c (Fabs): Handle bignums. * test/src/floatfns-tests.el (bignum-abs): New test.
* | | Allow conversion of bignums to floatsTom Tromey2018-07-121-2/+4
| | | | | | | | | | | | | | | | | | * src/floatfns.c (extract_float, Ffloat): Handle bignums. * src/lisp.h (XFLOATINT): Handle bignums. * test/src/floatfns-tests.el (bignum-to-float): New test.
* | | Rename integerp->fixnum, etc, in preparation for bignumsTom Tromey2018-07-121-16/+16
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/json.c, src/keyboard.c, src/keyboard.h, src/keymap.c, src/kqueue.c, src/lcms.c, src/lisp.h, src/lread.c, src/macros.c, src/marker.c, src/menu.c, src/minibuf.c, src/msdos.c, src/print.c, src/process.c, src/profiler.c, src/search.c, src/sound.c, src/syntax.c, src/sysdep.c, src/term.c, src/terminal.c, src/textprop.c, src/undo.c, src/w16select.c, src/w32.c, src/w32console.c, src/w32cygwinx.c, src/w32fns.c, src/w32font.c, src/w32inevt.c, src/w32proc.c, src/w32select.c, src/w32term.c, src/w32uniscribe.c, src/widget.c, src/window.c, src/xdisp.c, src/xfaces.c, src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c, src/xrdb.c, src/xselect.c, src/xterm.c, src/xwidget.c: Rename INTEGERP->FIXNUM, make_number->make_fixnum, CHECK_NUMBER->CHECK_FIXNUM, make_natnum->make_fixed_natum, NUMBERP->FIXED_OR_FLOATP, NATNUMP->FIXNATP, CHECK_NATNUM->CHECK_FIXNAT.
* | (format "%d" F) now truncates floating FPaul Eggert2018-06-251-8/+5
|/ | | | | | | | | | | | | Problem reported by Paul Pogonyshev (Bug#31938). * src/editfns.c: Include math.h, for trunc. (styled_format): For %d, truncate floating-point numbers and convert -0 to 0, going back to how Emacs 26 did things. * doc/lispref/strings.texi (Formatting Strings): Document behavior of %o, %d, %x, %X on floating-point numbers. * src/floatfns.c (trunc) [!HAVE_TRUNC]: Rename from emacs_trunc and make it an extern function, so that editfns.c can use it. All callers changed. * test/src/editfns-tests.el (format-%d-float): New test.
* Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | Run admin/update-copyright.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-1/+1
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Remove isnan hack for Solaris 10 gcc 3.4.3Paul Eggert2017-03-071-7/+6
| | | | | | | This seems to have been a false alarm (Bug#26018). * src/data.c (isnan): * src/floatfns.c (isfinite, isnan): Use standard implementation if available.
* Define copysign on all platformsPaul Eggert2017-03-071-5/+9
| | | | | | | * configure.ac (copysign): Remove test. * src/floatfns.c (signbit): New macro, if not already defined. (Fcopysign): Use it instead of copysign. (Fcopysign, syms_of_floatfns): Define the function on all platforms.
* ffloor etc. now accept only floatsPaul Eggert2017-03-051-6/+10
| | | | | | | * etc/NEWS: Say why. * src/floatfns.c (Ffceiling, Fffloor, Ffround, Fftruncate): Require arg to be float. * test/src/floatfns-tests.el (fround-fixnum): Check this.
* * src/floatfns.c (Fftruncate): Simplify via emacs_trunc.Paul Eggert2017-03-041-4/+1
|