diff options
| author | Paul Eggert | 2012-05-25 11:19:24 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-05-25 11:19:24 -0700 |
| commit | 42b2a986d9d4b7040fb20c90ec0efeffb78e761a (patch) | |
| tree | d38e7bf5307837f2f38982757f088100de18a64e /src | |
| parent | e4d81efc58695c19154d5f6733d91172b4c3e5b7 (diff) | |
| parent | a8d3cbf75d219d7a249fc0623219511179e959da (diff) | |
| download | emacs-42b2a986d9d4b7040fb20c90ec0efeffb78e761a.tar.gz emacs-42b2a986d9d4b7040fb20c90ec0efeffb78e761a.zip | |
Merge from trunk.
Diffstat (limited to 'src')
80 files changed, 2269 insertions, 3057 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index 7cd828733b1..8f8508f291f 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -54,7 +54,7 @@ end | |||
| 54 | 54 | ||
| 55 | define xgetint | 55 | define xgetint |
| 56 | set $bugfix = $arg0 | 56 | set $bugfix = $arg0 |
| 57 | set $int = gdb_use_union ? $bugfix.s.val : (gdb_use_lsb ? $bugfix : $bugfix << gdb_gctypebits) >> gdb_gctypebits | 57 | set $int = gdb_use_union ? $bugfix.s.val : (gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << gdb_gctypebits) >> gdb_gctypebits |
| 58 | end | 58 | end |
| 59 | 59 | ||
| 60 | define xgettype | 60 | define xgettype |
| @@ -703,60 +703,6 @@ Print $ as a misc free-cell pointer. | |||
| 703 | This command assumes that $ is an Emacs Lisp Misc value. | 703 | This command assumes that $ is an Emacs Lisp Misc value. |
| 704 | end | 704 | end |
| 705 | 705 | ||
| 706 | define xintfwd | ||
| 707 | xgetptr $ | ||
| 708 | print (struct Lisp_Intfwd *) $ptr | ||
| 709 | end | ||
| 710 | document xintfwd | ||
| 711 | Print $ as an integer forwarding pointer. | ||
| 712 | This command assumes that $ is an Emacs Lisp Misc value. | ||
| 713 | end | ||
| 714 | |||
| 715 | define xboolfwd | ||
| 716 | xgetptr $ | ||
| 717 | print (struct Lisp_Boolfwd *) $ptr | ||
| 718 | end | ||
| 719 | document xboolfwd | ||
| 720 | Print $ as a boolean forwarding pointer. | ||
| 721 | This command assumes that $ is an Emacs Lisp Misc value. | ||
| 722 | end | ||
| 723 | |||
| 724 | define xobjfwd | ||
| 725 | xgetptr $ | ||
| 726 | print (struct Lisp_Objfwd *) $ptr | ||
| 727 | end | ||
| 728 | document xobjfwd | ||
| 729 | Print $ as an object forwarding pointer. | ||
| 730 | This command assumes that $ is an Emacs Lisp Misc value. | ||
| 731 | end | ||
| 732 | |||
| 733 | define xbufobjfwd | ||
| 734 | xgetptr $ | ||
| 735 | print (struct Lisp_Buffer_Objfwd *) $ptr | ||
| 736 | end | ||
| 737 | document xbufobjfwd | ||
| 738 | Print $ as a buffer-local object forwarding pointer. | ||
| 739 | This command assumes that $ is an Emacs Lisp Misc value. | ||
| 740 | end | ||
| 741 | |||
| 742 | define xkbobjfwd | ||
| 743 | xgetptr $ | ||
| 744 | print (struct Lisp_Kboard_Objfwd *) $ptr | ||
| 745 | end | ||
| 746 | document xkbobjfwd | ||
| 747 | Print $ as a kboard-local object forwarding pointer. | ||
| 748 | This command assumes that $ is an Emacs Lisp Misc value. | ||
| 749 | end | ||
| 750 | |||
| 751 | define xbuflocal | ||
| 752 | xgetptr $ | ||
| 753 | print (struct Lisp_Buffer_Local_Value *) $ptr | ||
| 754 | end | ||
| 755 | document xbuflocal | ||
| 756 | Print $ as a buffer-local-value pointer. | ||
| 757 | This command assumes that $ is an Emacs Lisp Misc value. | ||
| 758 | end | ||
| 759 | |||
| 760 | define xsymbol | 706 | define xsymbol |
| 761 | set $sym = $ | 707 | set $sym = $ |
| 762 | xgetptr $sym | 708 | xgetptr $sym |
| @@ -1003,8 +949,15 @@ end | |||
| 1003 | 949 | ||
| 1004 | define xpr | 950 | define xpr |
| 1005 | xtype | 951 | xtype |
| 1006 | if $type == Lisp_Int | 952 | if gdb_use_union |
| 1007 | xint | 953 | if $type == Lisp_Int |
| 954 | xint | ||
| 955 | end | ||
| 956 | end | ||
| 957 | if !gdb_use_union | ||
| 958 | if $type == Lisp_Int0 || $type == Lisp_Int1 | ||
| 959 | xint | ||
| 960 | end | ||
| 1008 | end | 961 | end |
| 1009 | if $type == Lisp_Symbol | 962 | if $type == Lisp_Symbol |
| 1010 | xsymbol | 963 | xsymbol |
| @@ -1023,36 +976,12 @@ define xpr | |||
| 1023 | if $misc == Lisp_Misc_Free | 976 | if $misc == Lisp_Misc_Free |
| 1024 | xmiscfree | 977 | xmiscfree |
| 1025 | end | 978 | end |
| 1026 | if $misc == Lisp_Misc_Boolfwd | ||
| 1027 | xboolfwd | ||
| 1028 | end | ||
| 1029 | if $misc == Lisp_Misc_Marker | 979 | if $misc == Lisp_Misc_Marker |
| 1030 | xmarker | 980 | xmarker |
| 1031 | end | 981 | end |
| 1032 | if $misc == Lisp_Misc_Intfwd | ||
| 1033 | xintfwd | ||
| 1034 | end | ||
| 1035 | if $misc == Lisp_Misc_Boolfwd | ||
| 1036 | xboolfwd | ||
| 1037 | end | ||
| 1038 | if $misc == Lisp_Misc_Objfwd | ||
| 1039 | xobjfwd | ||
| 1040 | end | ||
| 1041 | if $misc == Lisp_Misc_Buffer_Objfwd | ||
| 1042 | xbufobjfwd | ||
| 1043 | end | ||
| 1044 | if $misc == Lisp_Misc_Buffer_Local_Value | ||
| 1045 | xbuflocal | ||
| 1046 | end | ||
| 1047 | # if $misc == Lisp_Misc_Some_Buffer_Local_Value | ||
| 1048 | # xvalue | ||
| 1049 | # end | ||
| 1050 | if $misc == Lisp_Misc_Overlay | 982 | if $misc == Lisp_Misc_Overlay |
| 1051 | xoverlay | 983 | xoverlay |
| 1052 | end | 984 | end |
| 1053 | if $misc == Lisp_Misc_Kboard_Objfwd | ||
| 1054 | xkbobjfwd | ||
| 1055 | end | ||
| 1056 | # if $misc == Lisp_Misc_Save_Value | 985 | # if $misc == Lisp_Misc_Save_Value |
| 1057 | # xsavevalue | 986 | # xsavevalue |
| 1058 | # end | 987 | # end |
diff --git a/src/ChangeLog b/src/ChangeLog index bdc70f54f29..6217560409d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,9 +1,8 @@ | |||
| 1 | 2012-04-22 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-05-25 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Fix integer width and related bugs (Bug#9874). | ||
| 3 | * process.h (struct Lisp_Process): Members tick and update_tick | 4 | * process.h (struct Lisp_Process): Members tick and update_tick |
| 4 | are now of type EMACS_INT, not int. | 5 | are now of type EMACS_INT, not int. |
| 5 | |||
| 6 | Fix integer width and related bugs (Bug#9874). | ||
| 7 | * alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp): | 6 | * alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp): |
| 8 | (allocate_vectorlike, buffer_memory_full, struct sdata, SDATA_SIZE) | 7 | (allocate_vectorlike, buffer_memory_full, struct sdata, SDATA_SIZE) |
| 9 | (string_bytes, check_sblock, allocate_string_data): | 8 | (string_bytes, check_sblock, allocate_string_data): |
| @@ -47,12 +46,6 @@ | |||
| 47 | (Foverlays_at, Fnext_overlay_change, Fprevious_overlay_change): | 46 | (Foverlays_at, Fnext_overlay_change, Fprevious_overlay_change): |
| 48 | Omit pointer cast, which isn't needed anyway, and doesn't work | 47 | Omit pointer cast, which isn't needed anyway, and doesn't work |
| 49 | after the EMACS_INT -> ptrdiff_t change. | 48 | after the EMACS_INT -> ptrdiff_t change. |
| 50 | (Fmove_overlay): Delete an evaporating overlay | ||
| 51 | if it becomes empty after its bounds are adjusted to fit within | ||
| 52 | its buffer. Without this fix, in a nonempty buffer (let ((o | ||
| 53 | (make-overlay 1 2))) (overlay-put o 'evaporate t) (move-overlay o 0 1)) | ||
| 54 | yields an empty overlay that has the evaporate property, which is | ||
| 55 | not supposed to happen. (Bug#9642) | ||
| 56 | * buffer.h: Adjust decls to match defn changes elsewhere. | 49 | * buffer.h: Adjust decls to match defn changes elsewhere. |
| 57 | (struct buffer_text, struct buffer): | 50 | (struct buffer_text, struct buffer): |
| 58 | Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. | 51 | Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. |
| @@ -218,6 +211,7 @@ | |||
| 218 | (Frem): Don't assume arg is nonnegative. | 211 | (Frem): Don't assume arg is nonnegative. |
| 219 | * dbusbind.c (xd_append_arg): Check for integers out of range. | 212 | * dbusbind.c (xd_append_arg): Check for integers out of range. |
| 220 | (Fdbus_call_method): Don't overflow the timeout int. | 213 | (Fdbus_call_method): Don't overflow the timeout int. |
| 214 | (extract_signed, extract_unsigned): New functions. | ||
| 221 | * dired.c (directory_files_internal, file_name_completion, scmp) | 215 | * dired.c (directory_files_internal, file_name_completion, scmp) |
| 222 | (file_name_completion_stat): | 216 | (file_name_completion_stat): |
| 223 | Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. | 217 | Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. |
| @@ -796,6 +790,539 @@ | |||
| 796 | rather than rolling our own approximation. | 790 | rather than rolling our own approximation. |
| 797 | (SCROLL_BAR_VEC_SIZE): Remove; not used. | 791 | (SCROLL_BAR_VEC_SIZE): Remove; not used. |
| 798 | 792 | ||
| 793 | 2012-05-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 794 | |||
| 795 | * fileio.c, character.h: Minor style tweaks. | ||
| 796 | |||
| 797 | 2012-05-24 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 798 | |||
| 799 | * window.h (clip_changed): Remove useless declaration. | ||
| 800 | |||
| 801 | 2012-05-22 Juanma Barranquero <lekktu@gmail.com> | ||
| 802 | |||
| 803 | * makefile.w32-in: Follow-up to 2012-05-22T16:20:27Z!eggert@cs.ucla.edu. | ||
| 804 | (TAGS, TAGS-gmake, CONFIG_H): Remove further references to m/intel386.h. | ||
| 805 | |||
| 806 | 2012-05-22 Paul Eggert <eggert@cs.ucla.edu> | ||
| 807 | |||
| 808 | Remove src/m/*. | ||
| 809 | This directory predates autoconf and is no longer needed nowadays. | ||
| 810 | Move its few remaining bits of functionality to where they're needed. | ||
| 811 | * m/README, m/alpha.h, m/amdx86-64.h, m/ia64.h, m/ibmrs6000.h: | ||
| 812 | * m/ibms390x.h, m/intel386.h, m/m68k.h, m/macppc.h, m/sparc.h: | ||
| 813 | * m/template.h: Remove. | ||
| 814 | * Makefile.in (M_FILE): Remove. All uses removed. | ||
| 815 | * alloc.c (POINTERS_MIGHT_HIDE_IN_OBJECTS): | ||
| 816 | * lisp.h (USE_LSB_TAG): | ||
| 817 | * mem-limits.h (EXCEEDS_LISP_PTR): | ||
| 818 | Use VAL_MAX, not VALBITS, in #if. | ||
| 819 | * lisp.h (EMACS_INT_MAX): New macro, useful in #if. | ||
| 820 | (EMACS_UINT): Define unconditionally now. | ||
| 821 | (BITS_PER_CHAR, BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG) | ||
| 822 | (BITS_PER_EMACS_INT): New constants, replacing | ||
| 823 | what used to be in config.h, but not useful in #if. | ||
| 824 | (GCTYPEBITS, VALBITS): Define unconditionally, since m/* files don't | ||
| 825 | define them any more. | ||
| 826 | (VAL_MAX): New macro. | ||
| 827 | (VALMASK): Use it. | ||
| 828 | * puresize.h (PURESIZE_RATIO): Use EMACS_INT_MAX, not | ||
| 829 | BITS_PER_EMACS_INT, in #if. | ||
| 830 | * s/aix4-2.h (BROKEN_FIONREAD, BROKEN_SIGAIO, BROKEN_SIGPTY) | ||
| 831 | (BROKEN_SIGPOLL): Move here from m/ibmrs6000.h, which was removed. | ||
| 832 | * s/gnu-linux.h (ULIMIT_BREAK_VALUE) [__i386__]: | ||
| 833 | * s/ms-w32.h (DATA_START): | ||
| 834 | Move here from removed file m/intel386.h. | ||
| 835 | * s/gnu.h (NLIST_STRUCT): Remove undef; 'configure' does this. | ||
| 836 | * s/irix6-5.h (_LP64): Remove; lisp.h no longer needs this. | ||
| 837 | |||
| 838 | 2012-05-21 Paul Eggert <eggert@cs.ucla.edu> | ||
| 839 | |||
| 840 | Assume C89 or later. | ||
| 841 | * alloc.c, buffer.c, lisp.h: Replace POINTER_TYPE with void. | ||
| 842 | * alloc.c (overrun_check_malloc, overrun_check_realloc, xmalloc) | ||
| 843 | (xrealloc): | ||
| 844 | * buffer.c (mmap_free_1, mmap_enlarge): Omit needless casts. | ||
| 845 | * editfns.c, fns.c, gmalloc.c, insdel.c, sysdep.c, termcap.c (NULL): | ||
| 846 | * textprop.c, tparam.c (NULL): Remove. | ||
| 847 | * ralloc.c, vm-limit.c (POINTER): Assume void * works. | ||
| 848 | * regex.c (SIGN_EXTEND_CHAR): Assume signed char works. | ||
| 849 | * regex.h (_RE_ARGS): Remove. All uses rewritten to use prototypes. | ||
| 850 | * unexelf.c (ElfBitsW): Assume c89 preprocessor or better. | ||
| 851 | * xterm.c (input_signal_count): Assume volatile works. | ||
| 852 | |||
| 853 | 2012-05-21 Ken Brown <kbrown@cornell.edu> | ||
| 854 | |||
| 855 | * xgselect.c (xg_select): Fix first argument in call to 'select' | ||
| 856 | (bug#11508). | ||
| 857 | |||
| 858 | 2012-05-20 Ken Brown <kbrown@cornell.edu> | ||
| 859 | |||
| 860 | * gmalloc.c (_free_internal_nolock, _realloc_internal_nolock) | ||
| 861 | [CYGWIN]: Cast ptr to (char *) before comparing to _heapbase. | ||
| 862 | |||
| 863 | 2012-05-19 Ken Brown <kbrown@cornell.edu> | ||
| 864 | |||
| 865 | * xfns.c (x_in_use): Remove `static' qualifier. | ||
| 866 | * xterm.h (x_in_use): Declare. | ||
| 867 | * xgselect.c: Include xterm.h. | ||
| 868 | (xg_select): Test `x_in_use' instead of `inhibit_window_system' | ||
| 869 | and `display_arg' (bug#9754). | ||
| 870 | |||
| 871 | 2012-05-19 Paul Eggert <eggert@cs.ucla.edu> | ||
| 872 | |||
| 873 | * s/ms-w32.h (HAVE_GETDOMAINNAME): Remove; not needed. | ||
| 874 | |||
| 875 | * m/vax.h: Remove; no longer needed since HAVE_FTIME is being removed. | ||
| 876 | * s/ms-w32.h (HAVE_FTIME): Remove; not needed. | ||
| 877 | |||
| 878 | 2012-05-18 Eli Zaretskii <eliz@gnu.org> | ||
| 879 | |||
| 880 | Fix compilation with -DGLYPH_DEBUG=1 on MS-Windows. | ||
| 881 | |||
| 882 | * w32term.c [GLYPH_DEBUG]: Add prototype for x_check_font. | ||
| 883 | (x_check_font) [GLYPH_DEBUG]: New function, copied from xterm.c | ||
| 884 | |||
| 885 | * w32fns.c (unwind_create_frame) [GLYPH_DEBUG]: Fix broken | ||
| 886 | reference to image_cache->refcount. | ||
| 887 | (x_create_tip_frame): Fix broken use of FRAME_IMAGE_CACHE. | ||
| 888 | |||
| 889 | 2012-05-17 Juri Linkov <juri@jurta.org> | ||
| 890 | |||
| 891 | * search.c (Fword_search_regexp, Fword_search_backward) | ||
| 892 | (Fword_search_forward, Fword_search_backward_lax) | ||
| 893 | (Fword_search_forward_lax): Move functions to isearch.el | ||
| 894 | (bug#10145, bug#11381). | ||
| 895 | |||
| 896 | 2012-05-16 Paul Eggert <eggert@cs.ucla.edu> | ||
| 897 | |||
| 898 | * xgselect.c (xg_select): Just invoke 'select' if -nw (Bug#9754). | ||
| 899 | |||
| 900 | 2012-05-15 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 901 | |||
| 902 | * lread.c (init_obarray): Declare Qt and Qnil as special. | ||
| 903 | |||
| 904 | 2012-05-14 Glenn Morris <rgm@gnu.org> | ||
| 905 | |||
| 906 | * nsterm.m (ns_init_paths): Fix typo ("libexec" not "lib-exec"). | ||
| 907 | Put "libexec" before "bin", for the sake of init_callproc_1. | ||
| 908 | |||
| 909 | 2012-05-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 910 | |||
| 911 | * keyboard.c (kbd_buffer_get_event) [!HAVE_DBUS]: Omit unused local. | ||
| 912 | |||
| 913 | * unexaix.c: Port to more-recent AIX compilers. | ||
| 914 | (report_error, report_error_1, make_hdr, copy_sym) | ||
| 915 | (mark_x, adjust_lnnoptrs, unrelocate_symbols): | ||
| 916 | Make arguments const char *, not char *, to avoid violations of C | ||
| 917 | standard and to fix some AIX warnings reported by Gilles Pion. | ||
| 918 | |||
| 919 | 2012-05-14 Eli Zaretskii <eliz@gnu.org> | ||
| 920 | |||
| 921 | * xdisp.c (handle_stop): Don't call get_overlay_strings_1 if we | ||
| 922 | already have overlays loaded. | ||
| 923 | (handle_single_display_spec): Before returning without displaying | ||
| 924 | fringe bitmap, synchronize the bidi iterator with the main display | ||
| 925 | iterator, by calling iterate_out_of_display_property. | ||
| 926 | (iterate_out_of_display_property): Detect buffer iteration by | ||
| 927 | testing that it->string is a Lisp string. | ||
| 928 | (get_next_display_element): When the current object is exhausted, | ||
| 929 | and there's something on it->stack, call set_iterator_to_next to | ||
| 930 | proceed with what's on the stack, instead of returning zero. | ||
| 931 | (set_iterator_to_next): If called at the end of a Lisp string, | ||
| 932 | proceed to consider_string_end without incrementing string | ||
| 933 | position. Don't increment display vector index past the end of | ||
| 934 | the display vector. (Bug#11417) | ||
| 935 | (pos_visible_p): Don't report a position visible when move_it_to | ||
| 936 | stopped at the last line of window, which happens to be scanned | ||
| 937 | backwards by the bidi iteration. (Bug#11464) | ||
| 938 | |||
| 939 | 2012-05-14 Eli Zaretskii <eliz@gnu.org> | ||
| 940 | |||
| 941 | * xdisp.c (handle_single_display_spec): Return 1 for left-margin | ||
| 942 | and right-margin display specs even if the spec is invalid or we | ||
| 943 | are on a TTY, and thus unable to display on the fringes. That's | ||
| 944 | because the text with the property will not be displayed anyway, | ||
| 945 | so we need to signal to the caller that this is a "replacing" | ||
| 946 | display spec. This fixes display when the spec is invalid or we | ||
| 947 | are on a TTY. | ||
| 948 | |||
| 949 | 2012-05-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 950 | |||
| 951 | * unexaix.c (make_hdr): Fix typo in prototype. | ||
| 952 | This bug broke the build on AIX. Problem reported by Gilles Pion. | ||
| 953 | |||
| 954 | 2012-05-14 Michael Albinus <michael.albinus@gmx.de> | ||
| 955 | |||
| 956 | * keyboard.c (kbd_buffer_get_event): Read special events also in | ||
| 957 | batch mode. (Bug#11415) | ||
| 958 | |||
| 959 | 2012-05-12 Glenn Morris <rgm@gnu.org> | ||
| 960 | |||
| 961 | * ns.mk: Update for ns_appbindir no longer having trailing "/". | ||
| 962 | |||
| 963 | 2012-05-12 Eli Zaretskii <eliz@gnu.org> | ||
| 964 | |||
| 965 | * lisp.mk (lisp): Add newcomment.elc. | ||
| 966 | |||
| 967 | 2012-05-12 Glenn Morris <rgm@gnu.org> | ||
| 968 | |||
| 969 | * Makefile.in (MKDIR_P): New, set by configure. | ||
| 970 | * ns.mk (${ns_appdir}, ${ns_appbindir}Emacs): Use $MKDIR_P. | ||
| 971 | |||
| 972 | 2012-05-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 973 | |||
| 974 | Remove unused function hourglass_started. | ||
| 975 | * dispextern.h (hourglass_started): | ||
| 976 | * w32fns.c (hourglass_started): | ||
| 977 | * xdisp.c (hourglass_started): Remove. | ||
| 978 | |||
| 979 | 2012-05-10 Juanma Barranquero <lekktu@gmail.com> | ||
| 980 | |||
| 981 | * makefile.w32-in ($(BLD)/gmalloc.$(O), $(BLD)/w32menu.$(O)): | ||
| 982 | Update dependencies. | ||
| 983 | |||
| 984 | 2012-05-10 Paul Eggert <eggert@cs.ucla.edu> | ||
| 985 | |||
| 986 | * xgselect.c (xg_select): Put maxfds+1 into a var. | ||
| 987 | This is slightly clearer, and pacifies Ubuntu 12.04 gcc. | ||
| 988 | |||
| 989 | * sound.c (DEFAULT_ALSA_SOUND_DEVICE): Define only if HAVE_ALSA. | ||
| 990 | |||
| 991 | 2012-05-10 Dave Abrahams <dave@boostpro.com> | ||
| 992 | |||
| 993 | * filelock.c (syms_of_filelock): New boolean create-lockfiles. | ||
| 994 | (lock_file): If create_lockfiles is 0, do nothing. (Bug#11227) | ||
| 995 | |||
| 996 | 2012-05-09 Michael Albinus <michael.albinus@gmx.de> | ||
| 997 | |||
| 998 | * dbusbind.c (xd_registered_buses): New internal Lisp object. | ||
| 999 | Rename all occurences of Vdbus_registered_buses to xd_registered_buses. | ||
| 1000 | (syms_of_dbusbind): Remove declaration of Vdbus_registered_buses. | ||
| 1001 | Initialize xd_registered_buses. | ||
| 1002 | |||
| 1003 | 2012-05-09 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1004 | |||
| 1005 | Untag more efficiently if USE_LSB_TAG. | ||
| 1006 | This is based on a proposal by YAMAMOTO Mitsuharu in | ||
| 1007 | <http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg01876.html>. | ||
| 1008 | For an admittedly artificial (nth 8000 longlist) benchmark on | ||
| 1009 | Fedora 15 x86-64, this yields a 25% CPU speedup. Also, it shrinks | ||
| 1010 | Emacs's overall text size by 1%. | ||
| 1011 | * lisp.h (XUNTAG): New macro. | ||
| 1012 | (XCONS, XVECTOR, XSTRING, XSYMBOL, XFLOAT, XMISC, XPROCESS, XWINDOW) | ||
| 1013 | (XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE, XSUB_CHAR_TABLE, XBOOL_VECTOR) | ||
| 1014 | (XSETTYPED_PSEUDOVECTOR, XHASH_TABLE, TYPED_PSEUDOVECTORP): Use it. | ||
| 1015 | * eval.c (Fautoload): | ||
| 1016 | * font.h (XFONT_SPEC, XFONT_ENTITY, XFONT_OBJECT): | ||
| 1017 | * frame.h (XFRAME): Use XUNTAG. | ||
| 1018 | |||
| 1019 | Port recent dbusbind.c changes to 32-bit --with-wide-int. | ||
| 1020 | * dbusbind.c (xd_append_arg, xd_retrieve_arg, Fdbus_message_internal): | ||
| 1021 | Remove unportable assumptions about print widths of types like | ||
| 1022 | dbus_uint32_t. | ||
| 1023 | (xd_get_connection_address, Fdbus_init_bus): Cast Emacs integer to | ||
| 1024 | intptr_t when converting between pointer and integer, to avoid GCC | ||
| 1025 | warnings about wrong width. | ||
| 1026 | |||
| 1027 | 2012-05-09 Eli Zaretskii <eliz@gnu.org> | ||
| 1028 | |||
| 1029 | * w32proc.c (new_child): Force Windows to reserve only 64KB of | ||
| 1030 | stack for each reader_thread, instead of defaulting to 8MB | ||
| 1031 | determined by the linker. This avoids failures in creating | ||
| 1032 | subprocesses on Windows 7, see the discussion in this thread: | ||
| 1033 | http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00119.html. | ||
| 1034 | |||
| 1035 | 2012-05-07 Jérémy Compostella <jeremy.compostella@gmail.com> | ||
| 1036 | |||
| 1037 | Fix up display of the *Minibuf-0* buffer in the mini window. | ||
| 1038 | * keyboard.c (read_char): Don't clear the echo area if there's no | ||
| 1039 | message to clear. | ||
| 1040 | * xdisp.c (redisplay_internal): Redisplay the mini window (with the | ||
| 1041 | contents of *Minibuf-0*) if there's no message displayed in its stead. | ||
| 1042 | |||
| 1043 | 2012-05-07 Michael Albinus <michael.albinus@gmx.de> | ||
| 1044 | |||
| 1045 | * dbusbind.c (XD_DEBUG_MESSAGE): Don't print message twice in | ||
| 1046 | batch mode. | ||
| 1047 | |||
| 1048 | 2012-05-06 Chong Yidong <cyd@gnu.org> | ||
| 1049 | |||
| 1050 | * lisp.mk (lisp): Update. | ||
| 1051 | |||
| 1052 | 2012-05-05 Jim Meyering <meyering@redhat.com> | ||
| 1053 | |||
| 1054 | * w32font.c (fill_in_logfont): NUL-terminate a string (Bug#11372). | ||
| 1055 | |||
| 1056 | 2012-05-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 1057 | |||
| 1058 | * data.c (PUT_ERROR): New macro. | ||
| 1059 | (syms_of_data): Use it. Add new error type `user-error'. | ||
| 1060 | * undo.c (user_error): New function. | ||
| 1061 | (Fprimitive_undo): Use it. | ||
| 1062 | * print.c (print_error_message): Adjust print style for `user-error'. | ||
| 1063 | * keyboard.c (user_error): New function. | ||
| 1064 | (Fexit_recursive_edit, Fabort_recursive_edit): Use it. | ||
| 1065 | |||
| 1066 | 2012-05-03 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1067 | |||
| 1068 | Do not limit current-time-string to years 1000..9999. | ||
| 1069 | * editfns.c (TM_YEAR_IN_ASCTIME_RANGE): Remove. | ||
| 1070 | (Fcurrent_time_string): Support any year that is supported by the | ||
| 1071 | underlying localtime representation. Don't use asctime, as it | ||
| 1072 | has undefined behavior for years outside the range -999..9999. | ||
| 1073 | |||
| 1074 | 2012-05-02 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1075 | |||
| 1076 | Fix race conditions involving setenv, gmtime, localtime, asctime. | ||
| 1077 | Without this fix, interrupts could mess up code that uses these | ||
| 1078 | nonreentrant functions, since setting TZ invalidates existing | ||
| 1079 | tm_zone or tzname values, and since most of these functions return | ||
| 1080 | pointers to static storage. | ||
| 1081 | * editfns.c (format_time_string, Fdecode_time, Fencode_time) | ||
| 1082 | (Fcurrent_time_string, Fcurrent_time_zone, Fset_time_zone_rule): | ||
| 1083 | Grow the critical sections to include not just invoking | ||
| 1084 | localtime/gmtime, but also accessing these functions' results | ||
| 1085 | including their tm_zone values if any, and any related TZ setting. | ||
| 1086 | (format_time_string): Last arg is now struct tm *, not struct tm **, | ||
| 1087 | so that the struct tm is saved in the critical section. | ||
| 1088 | All callers changed. Simplify allocation of initial buffer, partly | ||
| 1089 | motivated by the fact that memory allocation needs to be outside | ||
| 1090 | the critical section. | ||
| 1091 | |||
| 1092 | 2012-05-02 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 1093 | |||
| 1094 | * intervals.c (adjust_intervals_for_insertion): Initialize `newi' | ||
| 1095 | with RESET_INTERVAL. | ||
| 1096 | |||
| 1097 | * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): | ||
| 1098 | Remove duplicated buffer name initialization. | ||
| 1099 | |||
| 1100 | 2012-05-02 Jim Meyering <jim@meyering.net> | ||
| 1101 | |||
| 1102 | * xterm.c (x_term_init): Use memcpy instead of strncpy (Bug#11373). | ||
| 1103 | |||
| 1104 | * xfns.c (x_window): Use xstrdup (Bug#11375). | ||
| 1105 | |||
| 1106 | 2012-05-02 Eli Zaretskii <eliz@gnu.org> | ||
| 1107 | |||
| 1108 | * xdisp.c (pos_visible_p): If already at a newline from the | ||
| 1109 | display string before the 'while' loop, don't walk back the glyphs | ||
| 1110 | from it3.glyph_row. Solves assertion violation when the display | ||
| 1111 | string begins with a newline (egg.el). (Bug#11367) | ||
| 1112 | |||
| 1113 | 2012-05-01 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 1114 | |||
| 1115 | * keyboard.c (Fexecute_extended_command, Vsuggest_key_bindings): | ||
| 1116 | Move to simple.el. | ||
| 1117 | |||
| 1118 | 2012-05-01 Glenn Morris <rgm@gnu.org> | ||
| 1119 | |||
| 1120 | * syssignal.h: Remove reference to BROKEN_SIGINFO (last used in | ||
| 1121 | s/ptx4.h), BROKEN_SIGTSTP (last used in m/ustation.h, m/dpx2.h), | ||
| 1122 | and BROKEN_SIGURG (was in s/gnu-linux.h prior to 2008-02-10). | ||
| 1123 | All were removed before 23.1. | ||
| 1124 | |||
| 1125 | * dispnew.c: Remove HAVE_LIBNCURSES test; | ||
| 1126 | it is always true on relevant platforms. | ||
| 1127 | |||
| 1128 | * Makefile.in (LD_SWITCH_X_SITE_RPATH): | ||
| 1129 | Rename from LD_SWITCH_X_SITE_AUX_RPATH. | ||
| 1130 | |||
| 1131 | * Makefile.in (LD_SWITCH_X_SITE_AUX): Remove; no longer used. | ||
| 1132 | |||
| 1133 | 2012-04-30 Andreas Schwab <schwab@linux-m68k.org> | ||
| 1134 | |||
| 1135 | * .gdbinit (xpr): Remove checks for no longer existing misc types. | ||
| 1136 | (xintfwd, xboolfwd, xobjfwd, xbufobjfwd, xkbobjfwd, xbuflocal): | ||
| 1137 | Remove. | ||
| 1138 | |||
| 1139 | 2012-04-28 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1140 | |||
| 1141 | Do not avoid creating empty evaporating overlays (Bug#9642). | ||
| 1142 | * buffer.c (Fmove_overlay): Revert the change of 2012-04-23. | ||
| 1143 | That is, do not delete an evaporating overlay if it becomes | ||
| 1144 | empty after its bounds are adjusted to fit within its buffer. | ||
| 1145 | This fix caused other problems, and I'm reverting it until we get | ||
| 1146 | to the bottom of them. | ||
| 1147 | |||
| 1148 | 2012-04-27 Chong Yidong <cyd@gnu.org> | ||
| 1149 | |||
| 1150 | * xselect.c (x_convert_selection): Initialize a pointer (Bug#11315). | ||
| 1151 | |||
| 1152 | 2012-04-27 Eli Zaretskii <eliz@gnu.org> | ||
| 1153 | |||
| 1154 | * xdisp.c (pos_visible_p): If the window start position is beyond | ||
| 1155 | ZV, start the display from buffer beginning. Prevents assertion | ||
| 1156 | violation in init_iterator when the minibuffer window is scrolled | ||
| 1157 | via the scroll bar. | ||
| 1158 | |||
| 1159 | * window.c (window_scroll_pixel_based): Likewise. | ||
| 1160 | |||
| 1161 | 2012-04-27 Chong Yidong <cyd@gnu.org> | ||
| 1162 | |||
| 1163 | * keymap.c (where_is_internal): Doc fix (Bug#10872). | ||
| 1164 | |||
| 1165 | 2012-04-27 Glenn Morris <rgm@gnu.org> | ||
| 1166 | |||
| 1167 | * fileio.c (Fcopy_file, Fset_file_selinux_context): | ||
| 1168 | Ignore ENOTSUP failures from setfilecon functions. (Bug#11245) | ||
| 1169 | |||
| 1170 | 2012-04-27 Eli Zaretskii <eliz@gnu.org> | ||
| 1171 | |||
| 1172 | * dispnew.c (swap_glyph_pointers, copy_row_except_pointers): | ||
| 1173 | Don't overrun array limits of glyph row's used[] array. (Bug#11288) | ||
| 1174 | |||
| 1175 | 2012-04-26 Eli Zaretskii <eliz@gnu.org> | ||
| 1176 | |||
| 1177 | * xdisp.c (IT_DISPLAYING_WHITESPACE): In addition to the loaded | ||
| 1178 | display element, check also the underlying string or buffer | ||
| 1179 | character. (Bug#11341) | ||
| 1180 | |||
| 1181 | * w32menu.c: Include w32heap.h. | ||
| 1182 | (add_menu_item): If the call to AppendMenuW (via | ||
| 1183 | unicode_append_menu) fails, disable Unicode menus only if we are | ||
| 1184 | running on Windows 9X/Me. | ||
| 1185 | |||
| 1186 | 2012-04-24 Andreas Schwab <schwab@linux-m68k.org> | ||
| 1187 | |||
| 1188 | * .gdbinit (xpr): Handle USE_2_TAGS_FOR_INTS. | ||
| 1189 | (xgetint): Add missing shift for LSB tags. | ||
| 1190 | |||
| 1191 | 2012-04-24 Martin Rudalics <rudalics@gmx.at> | ||
| 1192 | |||
| 1193 | * keyboard.c (read_char): Don't wipe echo area for select window | ||
| 1194 | events: These might get delayed via `mouse-autoselect-window' | ||
| 1195 | (Bug#11304). | ||
| 1196 | |||
| 1197 | 2012-04-24 Juanma Barranquero <lekktu@gmail.com> | ||
| 1198 | |||
| 1199 | * gnutls.c (init_gnutls_functions): Protect against (unlikely) | ||
| 1200 | manipulation of :loaded-from data. | ||
| 1201 | |||
| 1202 | 2012-04-23 Juanma Barranquero <lekktu@gmail.com> | ||
| 1203 | |||
| 1204 | * gnutls.c (init_gnutls_functions): The value of :loaded-from is | ||
| 1205 | now a cons (bug#11311). | ||
| 1206 | |||
| 1207 | 2012-04-23 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1208 | |||
| 1209 | Do not create empty overlays with the evaporate property (Bug#9642). | ||
| 1210 | * buffer.c (Fmove_overlay): Delete an evaporating overlay | ||
| 1211 | if it becomes empty after its bounds are adjusted to fit within | ||
| 1212 | its buffer. Without this fix, in a nonempty buffer (let ((o | ||
| 1213 | (make-overlay 1 2))) (overlay-put o 'evaporate t) (move-overlay o 0 1)) | ||
| 1214 | yields an empty overlay that has the evaporate property, which is | ||
| 1215 | not supposed to happen. | ||
| 1216 | |||
| 1217 | Fix minor GTK3 problems found by static checking. | ||
| 1218 | * emacsgtkfixed.c (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed) | ||
| 1219 | (EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed) | ||
| 1220 | (struct _EmacsFixedClass, emacs_fixed_get_type): | ||
| 1221 | Move decls here from emacsgtkfixed.h, since they needn't be public. | ||
| 1222 | (emacs_fixed_get_type): Now static. | ||
| 1223 | (emacs_fixed_class_init): Omit unused local. | ||
| 1224 | (emacs_fixed_child_type): Remove; unused. | ||
| 1225 | * emacsgtkfixed.h (EMACS_TYPE_FIXED, EMACS_FIXED, EmacsFixed) | ||
| 1226 | (EmacsFixedPrivate, EmacsFixedClass, struct _EmacsFixed) | ||
| 1227 | (struct _EmacsFixedClass): Move to emacsgtkfixed.c. | ||
| 1228 | (EMACS_FIXED_CLASS, EMACS_IS_FIXED, EMACS_IS_FIXED_CLASS) | ||
| 1229 | (EMACS_FIXED_GET_CLASS): Remove; unused. | ||
| 1230 | * gtkutil.c (xg_create_frame_widgets) [!HAVE_GTK3]: Omit unused local. | ||
| 1231 | |||
| 1232 | * keyboard.c (handle_async_input): Define only if SYNC_INPUT || SIGIO. | ||
| 1233 | Problem reported by Juanma Barranquero for Windows -Wunused-function. | ||
| 1234 | |||
| 1235 | 2012-04-22 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1236 | |||
| 1237 | Modernize and clean up gmalloc.c to assume C89 (Bug#9119). | ||
| 1238 | * gmalloc.c (_MALLOC_INTERNAL, _MALLOC_H, _PP, __ptr_t) | ||
| 1239 | (__malloc_size_t, __malloc_ptrdiff_t): | ||
| 1240 | Remove. All uses removed, replaced by the definiens if needed, | ||
| 1241 | since we can assume C89 or better now. | ||
| 1242 | Include <stdint.h>, for PTRDIFF_MAX, uintptr_t. | ||
| 1243 | (protect_malloc_state, align, get_contiguous_space) | ||
| 1244 | (malloc_atfork_handler_prepare, malloc_atfork_handler_parent) | ||
| 1245 | (malloc_atfork_handler_child, malloc_enable_thread) | ||
| 1246 | (malloc_initialize_1, __malloc_initialize, morecore_nolock) | ||
| 1247 | (_malloc_internal_nolock, _malloc_internal, malloc, _malloc) | ||
| 1248 | (_free, _realloc, _free_internal_nolock, _free_internal, free, cfree) | ||
| 1249 | (special_realloc, _realloc_internal_nolock, _realloc_internal) | ||
| 1250 | (realloc, calloc, __default_morecore, memalign, valloc, checkhdr) | ||
| 1251 | (freehook, mallochook, reallochook, mabort, mcheck, mprobe): | ||
| 1252 | Define using prototypes, not old style. | ||
| 1253 | (align, _malloc_internal_nolock, _free_internal_nolock, memalign): | ||
| 1254 | Don't assume ptrdiff_t and uintptr_t are no wider than unsigned long. | ||
| 1255 | (align): Don't assume that signed integer overflow wraps around. | ||
| 1256 | Omit unused local var. | ||
| 1257 | (malloc_initialize_1, morecore_nolock, _malloc_internal_nolock) | ||
| 1258 | (_free_internal_nolock, memalign, mallochook, reallochook): | ||
| 1259 | Omit no-longer-needed casts. | ||
| 1260 | (valloc): Use getpagesize, not __getpagesize. | ||
| 1261 | (MAGICWORD, MAGICFREE): Now randomish size_t values, not 32-bit. | ||
| 1262 | (struct hdr): The 'magic' member is now size_t, not unsigned long. | ||
| 1263 | |||
| 1264 | * dbusbind.c (XD_DBUS_VALIDATE_OBJECT): Define only if needed. | ||
| 1265 | |||
| 1266 | 2012-04-22 Michael Albinus <michael.albinus@gmx.de> | ||
| 1267 | |||
| 1268 | Move functions from C to Lisp. Make non-blocking method calls | ||
| 1269 | the default. Implement further D-Bus standard interfaces. | ||
| 1270 | |||
| 1271 | * dbusbind.c (DBUS_NUM_MESSAGE_TYPES): Declare. | ||
| 1272 | (QCdbus_request_name_allow_replacement) | ||
| 1273 | (QCdbus_request_name_replace_existing) | ||
| 1274 | (QCdbus_request_name_do_not_queue) | ||
| 1275 | (QCdbus_request_name_reply_primary_owner) | ||
| 1276 | (QCdbus_request_name_reply_in_queue) | ||
| 1277 | (QCdbus_request_name_reply_exists) | ||
| 1278 | (QCdbus_request_name_reply_already_owner): Move to dbus.el. | ||
| 1279 | (QCdbus_registered_serial, QCdbus_registered_method) | ||
| 1280 | (QCdbus_registered_signal): New Lisp objects. | ||
| 1281 | (XD_DEBUG_MESSAGE): Use sizeof. | ||
| 1282 | (XD_MESSAGE_TYPE_TO_STRING, XD_OBJECT_TO_STRING) | ||
| 1283 | (XD_DBUS_VALIDATE_BUS_ADDRESS, XD_DBUS_VALIDATE_OBJECT) | ||
| 1284 | (XD_DBUS_VALIDATE_BUS_NAME, XD_DBUS_VALIDATE_PATH) | ||
| 1285 | (XD_DBUS_VALIDATE_INTERFACE, XD_DBUS_VALIDATE_MEMBER): New macros. | ||
| 1286 | (XD_CHECK_DBUS_SERIAL): Rename from CHECK_DBUS_SERIAL_GET_SERIAL. | ||
| 1287 | (xd_signature, xd_append_arg): Allow float for integer types. | ||
| 1288 | (xd_get_connection_references): New function. | ||
| 1289 | (xd_get_connection_address): Rename from xd_initialize. | ||
| 1290 | Return cached address. | ||
| 1291 | (xd_remove_watch): Do not unset $DBUS_SESSION_BUS_ADDRESS. | ||
| 1292 | (xd_close_bus): Rename from Fdbus_close_bus. Not needed on Lisp | ||
| 1293 | level. | ||
| 1294 | (Fdbus_init_bus): New optional arg PRIVATE. Cache address. | ||
| 1295 | Return number of refcounts. | ||
| 1296 | (Fdbus_get_unique_name): Make stronger parameter check. | ||
| 1297 | (Fdbus_message_internal): New defun. | ||
| 1298 | (Fdbus_call_method, Fdbus_call_method_asynchronously) | ||
| 1299 | (Fdbus_method_return_internal, Fdbus_method_error_internal) | ||
| 1300 | (Fdbus_send_signal, Fdbus_register_service) | ||
| 1301 | (Fdbus_register_signal, Fdbus_register_method): Move to dbus.el. | ||
| 1302 | (xd_read_message_1): Obey new structure of Vdbus_registered_objects. | ||
| 1303 | (xd_read_queued_messages): Obey new structure of Vdbus_registered_buses. | ||
| 1304 | (Vdbus_compiled_version, Vdbus_runtime_version) | ||
| 1305 | (Vdbus_message_type_invalid, Vdbus_message_type_method_call) | ||
| 1306 | (Vdbus_message_type_method_return, Vdbus_message_type_error) | ||
| 1307 | (Vdbus_message_type_signal): New defvars. | ||
| 1308 | (Vdbus_registered_buses, Vdbus_registered_objects_table): | ||
| 1309 | Adapt docstring. | ||
| 1310 | |||
| 1311 | 2012-04-22 Paul Eggert <eggert@cs.ucla.edu> | ||
| 1312 | |||
| 1313 | Fix GC_MALLOC_CHECK debugging output on 64-bit hosts. | ||
| 1314 | * alloc.c (emacs_blocked_malloc) [GC_MALLOC_CHECK]: | ||
| 1315 | Do not assume ptrdiff_t is the same width as 'int'. | ||
| 1316 | |||
| 1317 | * alloc.c: Handle unusual debugging option combinations. | ||
| 1318 | (GC_CHECK_MARKED_OBJECTS): Undef if ! GC_MARK_STACK, | ||
| 1319 | since the two debugging options are incompatible. | ||
| 1320 | (GC_MALLOC_CHECK): Similarly, undef if GC_CHECK_MARKED_OBJECTS | ||
| 1321 | is defined. | ||
| 1322 | (mem_init, mem_insert, mem_insert_fixup): | ||
| 1323 | Define if GC_MARK_STACK || GC_MALLOC_CHECK. | ||
| 1324 | (NEED_MEM_INSERT): Remove; no longer needed. | ||
| 1325 | |||
| 799 | 2012-04-22 Leo Liu <sdl.web@gmail.com> | 1326 | 2012-04-22 Leo Liu <sdl.web@gmail.com> |
| 800 | 1327 | ||
| 801 | * sysdep.c (list_system_processes): Support Darwin (Bug#5725). | 1328 | * sysdep.c (list_system_processes): Support Darwin (Bug#5725). |
| @@ -809,8 +1336,8 @@ | |||
| 809 | 1336 | ||
| 810 | 2012-04-21 Eduard Wiebe <usenet@pusto.de> | 1337 | 2012-04-21 Eduard Wiebe <usenet@pusto.de> |
| 811 | 1338 | ||
| 812 | * sysdep.c (list_system_processes, system_process_attributes): Add | 1339 | * sysdep.c (list_system_processes, system_process_attributes): |
| 813 | implementation for FreeBSD (Bug#5243). | 1340 | Add implementation for FreeBSD (Bug#5243). |
| 814 | 1341 | ||
| 815 | 2012-04-21 Andreas Schwab <schwab@linux-m68k.org> | 1342 | 2012-04-21 Andreas Schwab <schwab@linux-m68k.org> |
| 816 | 1343 | ||
diff --git a/src/Makefile.in b/src/Makefile.in index 37480f8269d..27199578fc0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -40,6 +40,7 @@ version = @version@ | |||
| 40 | # Substitute an assignment for the MAKE variable, because | 40 | # Substitute an assignment for the MAKE variable, because |
| 41 | # BSD doesn't have it as a default. | 41 | # BSD doesn't have it as a default. |
| 42 | @SET_MAKE@ | 42 | @SET_MAKE@ |
| 43 | MKDIR_P = @MKDIR_P@ | ||
| 43 | # Don't use LIBS. configure puts stuff in it that either shouldn't be | 44 | # Don't use LIBS. configure puts stuff in it that either shouldn't be |
| 44 | # linked with Emacs or is duplicated by the other stuff below. | 45 | # linked with Emacs or is duplicated by the other stuff below. |
| 45 | # LIBS = @LIBS@ | 46 | # LIBS = @LIBS@ |
| @@ -55,9 +56,8 @@ lwlibdir = ../lwlib | |||
| 55 | lispdir = ../lisp | 56 | lispdir = ../lisp |
| 56 | 57 | ||
| 57 | # Configuration files for .o files to depend on. | 58 | # Configuration files for .o files to depend on. |
| 58 | M_FILE = @M_FILE@ | ||
| 59 | S_FILE = @S_FILE@ | 59 | S_FILE = @S_FILE@ |
| 60 | config_h = config.h $(M_FILE) $(S_FILE) | 60 | config_h = config.h $(S_FILE) |
| 61 | 61 | ||
| 62 | bootstrap_exe = $(abs_builddir)/bootstrap-emacs$(EXEEXT) | 62 | bootstrap_exe = $(abs_builddir)/bootstrap-emacs$(EXEEXT) |
| 63 | 63 | ||
| @@ -94,11 +94,9 @@ C_SWITCH_X_SITE=@C_SWITCH_X_SITE@ | |||
| 94 | ## substituted in this or any other Makefile. Cf C_SWITCH_X_SITE. | 94 | ## substituted in this or any other Makefile. Cf C_SWITCH_X_SITE. |
| 95 | LD_SWITCH_X_SITE= | 95 | LD_SWITCH_X_SITE= |
| 96 | 96 | ||
| 97 | ## Next two must come before LD_SWITCH_SYSTEM. | 97 | ## This must come before LD_SWITCH_SYSTEM. |
| 98 | ## If needed, a -R option that says where to find X windows at run time. | 98 | ## If needed, a -rpath option that says where to find X windows at run time. |
| 99 | LD_SWITCH_X_SITE_AUX=@LD_SWITCH_X_SITE_AUX@ | 99 | LD_SWITCH_X_SITE_RPATH=@LD_SWITCH_X_SITE_RPATH@ |
| 100 | ## As above, but using -rpath instead. | ||
| 101 | LD_SWITCH_X_SITE_AUX_RPATH=@LD_SWITCH_X_SITE_AUX_RPATH@ | ||
| 102 | 100 | ||
| 103 | ## System-specific LDFLAGS. | 101 | ## System-specific LDFLAGS. |
| 104 | LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@ | 102 | LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@ |
| @@ -286,7 +284,7 @@ CANNOT_DUMP=@CANNOT_DUMP@ | |||
| 286 | DEPDIR=deps | 284 | DEPDIR=deps |
| 287 | ## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty. | 285 | ## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty. |
| 288 | DEPFLAGS=@DEPFLAGS@ | 286 | DEPFLAGS=@DEPFLAGS@ |
| 289 | ## test -d $(DEPDIR) || mkdir $(DEPDIR) (if AUTO_DEPEND); else ':'. | 287 | ## ${MKDIR_P} ${DEPDIR} (if AUTO_DEPEND); else ':'. |
| 290 | MKDEPDIR=@MKDEPDIR@ | 288 | MKDEPDIR=@MKDEPDIR@ |
| 291 | 289 | ||
| 292 | ## DO NOT use -R. There is a special hack described in lastfile.c | 290 | ## DO NOT use -R. There is a special hack described in lastfile.c |
| @@ -535,10 +533,10 @@ extraclean: distclean | |||
| 535 | ctagsfiles1 = [xyzXYZ]*.[hcm] | 533 | ctagsfiles1 = [xyzXYZ]*.[hcm] |
| 536 | ctagsfiles2 = [a-wA-W]*.[hcm] | 534 | ctagsfiles2 = [a-wA-W]*.[hcm] |
| 537 | 535 | ||
| 538 | TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(M_FILE) $(S_FILE) | 536 | TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(S_FILE) |
| 539 | ../lib-src/etags --include=TAGS-LISP --include=$(lwlibdir)/TAGS \ | 537 | ../lib-src/etags --include=TAGS-LISP --include=$(lwlibdir)/TAGS \ |
| 540 | --regex='/[ ]*DEFVAR_[A-Z_ (]+"\([^"]+\)"/' \ | 538 | --regex='/[ ]*DEFVAR_[A-Z_ (]+"\([^"]+\)"/' \ |
| 541 | $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(M_FILE) $(S_FILE) | 539 | $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(S_FILE) |
| 542 | frc: | 540 | frc: |
| 543 | TAGS-LISP: frc | 541 | TAGS-LISP: frc |
| 544 | $(MAKE) -f $(lispdir)/Makefile TAGS-LISP ETAGS=../lib-src/etags | 542 | $(MAKE) -f $(lispdir)/Makefile TAGS-LISP ETAGS=../lib-src/etags |
diff --git a/src/alloc.c b/src/alloc.c index c07d5c929f9..05d2db274da 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -49,16 +49,24 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 49 | #include <setjmp.h> | 49 | #include <setjmp.h> |
| 50 | #include <verify.h> | 50 | #include <verify.h> |
| 51 | 51 | ||
| 52 | /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. | ||
| 53 | Doable only if GC_MARK_STACK. */ | ||
| 54 | #if ! GC_MARK_STACK | ||
| 55 | # undef GC_CHECK_MARKED_OBJECTS | ||
| 56 | #endif | ||
| 57 | |||
| 52 | /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd | 58 | /* GC_MALLOC_CHECK defined means perform validity checks of malloc'd |
| 53 | memory. Can do this only if using gmalloc.c. */ | 59 | memory. Can do this only if using gmalloc.c and if not checking |
| 60 | marked objects. */ | ||
| 54 | 61 | ||
| 55 | #if defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC | 62 | #if (defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC \ |
| 63 | || defined GC_CHECK_MARKED_OBJECTS) | ||
| 56 | #undef GC_MALLOC_CHECK | 64 | #undef GC_MALLOC_CHECK |
| 57 | #endif | 65 | #endif |
| 58 | 66 | ||
| 59 | #include <unistd.h> | 67 | #include <unistd.h> |
| 60 | #ifndef HAVE_UNISTD_H | 68 | #ifndef HAVE_UNISTD_H |
| 61 | extern POINTER_TYPE *sbrk (); | 69 | extern void *sbrk (); |
| 62 | #endif | 70 | #endif |
| 63 | 71 | ||
| 64 | #include <fcntl.h> | 72 | #include <fcntl.h> |
| @@ -298,7 +306,7 @@ enum mem_type | |||
| 298 | MEM_TYPE_VECTORLIKE | 306 | MEM_TYPE_VECTORLIKE |
| 299 | }; | 307 | }; |
| 300 | 308 | ||
| 301 | static POINTER_TYPE *lisp_malloc (size_t, enum mem_type); | 309 | static void *lisp_malloc (size_t, enum mem_type); |
| 302 | 310 | ||
| 303 | 311 | ||
| 304 | #if GC_MARK_STACK || defined GC_MALLOC_CHECK | 312 | #if GC_MARK_STACK || defined GC_MALLOC_CHECK |
| @@ -380,7 +388,7 @@ static struct mem_node mem_z; | |||
| 380 | #define MEM_NIL &mem_z | 388 | #define MEM_NIL &mem_z |
| 381 | 389 | ||
| 382 | static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t); | 390 | static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t); |
| 383 | static void lisp_free (POINTER_TYPE *); | 391 | static void lisp_free (void *); |
| 384 | static void mark_stack (void); | 392 | static void mark_stack (void); |
| 385 | static int live_vector_p (struct mem_node *, void *); | 393 | static int live_vector_p (struct mem_node *, void *); |
| 386 | static int live_buffer_p (struct mem_node *, void *); | 394 | static int live_buffer_p (struct mem_node *, void *); |
| @@ -391,11 +399,8 @@ static int live_float_p (struct mem_node *, void *); | |||
| 391 | static int live_misc_p (struct mem_node *, void *); | 399 | static int live_misc_p (struct mem_node *, void *); |
| 392 | static void mark_maybe_object (Lisp_Object); | 400 | static void mark_maybe_object (Lisp_Object); |
| 393 | static void mark_memory (void *, void *); | 401 | static void mark_memory (void *, void *); |
| 402 | #if GC_MARK_STACK || defined GC_MALLOC_CHECK | ||
| 394 | static void mem_init (void); | 403 | static void mem_init (void); |
| 395 | #if (defined GC_MALLOC_CHECK \ | ||
| 396 | ? !defined SYSTEM_MALLOC && !defined SYNC_INPUT \ | ||
| 397 | : GC_MARK_STACK) | ||
| 398 | # define NEED_MEM_INSERT | ||
| 399 | static struct mem_node *mem_insert (void *, void *, enum mem_type); | 404 | static struct mem_node *mem_insert (void *, void *, enum mem_type); |
| 400 | static void mem_insert_fixup (struct mem_node *); | 405 | static void mem_insert_fixup (struct mem_node *); |
| 401 | #endif | 406 | #endif |
| @@ -430,15 +435,15 @@ static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; | |||
| 430 | 435 | ||
| 431 | static int staticidx = 0; | 436 | static int staticidx = 0; |
| 432 | 437 | ||
| 433 | static POINTER_TYPE *pure_alloc (size_t, int); | 438 | static void *pure_alloc (size_t, int); |
| 434 | 439 | ||
| 435 | 440 | ||
| 436 | /* Value is SZ rounded up to the next multiple of ALIGNMENT. | 441 | /* Value is SZ rounded up to the next multiple of ALIGNMENT. |
| 437 | ALIGNMENT must be a power of 2. */ | 442 | ALIGNMENT must be a power of 2. */ |
| 438 | 443 | ||
| 439 | #define ALIGN(ptr, ALIGNMENT) \ | 444 | #define ALIGN(ptr, ALIGNMENT) \ |
| 440 | ((POINTER_TYPE *) ((((uintptr_t) (ptr)) + (ALIGNMENT) - 1) \ | 445 | ((void *) (((uintptr_t) (ptr) + (ALIGNMENT) - 1) \ |
| 441 | & ~((ALIGNMENT) - 1))) | 446 | & ~ ((ALIGNMENT) - 1))) |
| 442 | 447 | ||
| 443 | 448 | ||
| 444 | 449 | ||
| @@ -599,7 +604,7 @@ static ptrdiff_t check_depth; | |||
| 599 | 604 | ||
| 600 | /* Like malloc, but wraps allocated block with header and trailer. */ | 605 | /* Like malloc, but wraps allocated block with header and trailer. */ |
| 601 | 606 | ||
| 602 | static POINTER_TYPE * | 607 | static void * |
| 603 | overrun_check_malloc (size_t size) | 608 | overrun_check_malloc (size_t size) |
| 604 | { | 609 | { |
| 605 | register unsigned char *val; | 610 | register unsigned char *val; |
| @@ -617,15 +622,15 @@ overrun_check_malloc (size_t size) | |||
| 617 | XMALLOC_OVERRUN_CHECK_SIZE); | 622 | XMALLOC_OVERRUN_CHECK_SIZE); |
| 618 | } | 623 | } |
| 619 | --check_depth; | 624 | --check_depth; |
| 620 | return (POINTER_TYPE *)val; | 625 | return val; |
| 621 | } | 626 | } |
| 622 | 627 | ||
| 623 | 628 | ||
| 624 | /* Like realloc, but checks old block for overrun, and wraps new block | 629 | /* Like realloc, but checks old block for overrun, and wraps new block |
| 625 | with header and trailer. */ | 630 | with header and trailer. */ |
| 626 | 631 | ||
| 627 | static POINTER_TYPE * | 632 | static void * |
| 628 | overrun_check_realloc (POINTER_TYPE *block, size_t size) | 633 | overrun_check_realloc (void *block, size_t size) |
| 629 | { | 634 | { |
| 630 | register unsigned char *val = (unsigned char *) block; | 635 | register unsigned char *val = (unsigned char *) block; |
| 631 | int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; | 636 | int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; |
| @@ -647,7 +652,7 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size) | |||
| 647 | memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); | 652 | memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); |
| 648 | } | 653 | } |
| 649 | 654 | ||
| 650 | val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead); | 655 | val = realloc (val, size + overhead); |
| 651 | 656 | ||
| 652 | if (val && check_depth == 1) | 657 | if (val && check_depth == 1) |
| 653 | { | 658 | { |
| @@ -658,13 +663,13 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size) | |||
| 658 | XMALLOC_OVERRUN_CHECK_SIZE); | 663 | XMALLOC_OVERRUN_CHECK_SIZE); |
| 659 | } | 664 | } |
| 660 | --check_depth; | 665 | --check_depth; |
| 661 | return (POINTER_TYPE *)val; | 666 | return val; |
| 662 | } | 667 | } |
| 663 | 668 | ||
| 664 | /* Like free, but checks block for overrun. */ | 669 | /* Like free, but checks block for overrun. */ |
| 665 | 670 | ||
| 666 | static void | 671 | static void |
| 667 | overrun_check_free (POINTER_TYPE *block) | 672 | overrun_check_free (void *block) |
| 668 | { | 673 | { |
| 669 | unsigned char *val = (unsigned char *) block; | 674 | unsigned char *val = (unsigned char *) block; |
| 670 | 675 | ||
| @@ -713,13 +718,13 @@ overrun_check_free (POINTER_TYPE *block) | |||
| 713 | 718 | ||
| 714 | /* Like malloc but check for no memory and block interrupt input.. */ | 719 | /* Like malloc but check for no memory and block interrupt input.. */ |
| 715 | 720 | ||
| 716 | POINTER_TYPE * | 721 | void * |
| 717 | xmalloc (size_t size) | 722 | xmalloc (size_t size) |
| 718 | { | 723 | { |
| 719 | register POINTER_TYPE *val; | 724 | void *val; |
| 720 | 725 | ||
| 721 | MALLOC_BLOCK_INPUT; | 726 | MALLOC_BLOCK_INPUT; |
| 722 | val = (POINTER_TYPE *) malloc (size); | 727 | val = malloc (size); |
| 723 | MALLOC_UNBLOCK_INPUT; | 728 | MALLOC_UNBLOCK_INPUT; |
| 724 | 729 | ||
| 725 | if (!val && size) | 730 | if (!val && size) |
| @@ -730,18 +735,18 @@ xmalloc (size_t size) | |||
| 730 | 735 | ||
| 731 | /* Like realloc but check for no memory and block interrupt input.. */ | 736 | /* Like realloc but check for no memory and block interrupt input.. */ |
| 732 | 737 | ||
| 733 | POINTER_TYPE * | 738 | void * |
| 734 | xrealloc (POINTER_TYPE *block, size_t size) | 739 | xrealloc (void *block, size_t size) |
| 735 | { | 740 | { |
| 736 | register POINTER_TYPE *val; | 741 | void *val; |
| 737 | 742 | ||
| 738 | MALLOC_BLOCK_INPUT; | 743 | MALLOC_BLOCK_INPUT; |
| 739 | /* We must call malloc explicitly when BLOCK is 0, since some | 744 | /* We must call malloc explicitly when BLOCK is 0, since some |
| 740 | reallocs don't do this. */ | 745 | reallocs don't do this. */ |
| 741 | if (! block) | 746 | if (! block) |
| 742 | val = (POINTER_TYPE *) malloc (size); | 747 | val = malloc (size); |
| 743 | else | 748 | else |
| 744 | val = (POINTER_TYPE *) realloc (block, size); | 749 | val = realloc (block, size); |
| 745 | MALLOC_UNBLOCK_INPUT; | 750 | MALLOC_UNBLOCK_INPUT; |
| 746 | 751 | ||
| 747 | if (!val && size) | 752 | if (!val && size) |
| @@ -753,7 +758,7 @@ xrealloc (POINTER_TYPE *block, size_t size) | |||
| 753 | /* Like free but block interrupt input. */ | 758 | /* Like free but block interrupt input. */ |
| 754 | 759 | ||
| 755 | void | 760 | void |
| 756 | xfree (POINTER_TYPE *block) | 761 | xfree (void *block) |
| 757 | { | 762 | { |
| 758 | if (!block) | 763 | if (!block) |
| 759 | return; | 764 | return; |
| @@ -888,7 +893,7 @@ safe_alloca_unwind (Lisp_Object arg) | |||
| 888 | static void *lisp_malloc_loser; | 893 | static void *lisp_malloc_loser; |
| 889 | #endif | 894 | #endif |
| 890 | 895 | ||
| 891 | static POINTER_TYPE * | 896 | static void * |
| 892 | lisp_malloc (size_t nbytes, enum mem_type type) | 897 | lisp_malloc (size_t nbytes, enum mem_type type) |
| 893 | { | 898 | { |
| 894 | register void *val; | 899 | register void *val; |
| @@ -933,7 +938,7 @@ lisp_malloc (size_t nbytes, enum mem_type type) | |||
| 933 | call to lisp_malloc. */ | 938 | call to lisp_malloc. */ |
| 934 | 939 | ||
| 935 | static void | 940 | static void |
| 936 | lisp_free (POINTER_TYPE *block) | 941 | lisp_free (void *block) |
| 937 | { | 942 | { |
| 938 | MALLOC_BLOCK_INPUT; | 943 | MALLOC_BLOCK_INPUT; |
| 939 | free (block); | 944 | free (block); |
| @@ -1029,7 +1034,7 @@ static struct ablock *free_ablock; | |||
| 1029 | /* Allocate an aligned block of nbytes. | 1034 | /* Allocate an aligned block of nbytes. |
| 1030 | Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be | 1035 | Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be |
| 1031 | smaller or equal to BLOCK_BYTES. */ | 1036 | smaller or equal to BLOCK_BYTES. */ |
| 1032 | static POINTER_TYPE * | 1037 | static void * |
| 1033 | lisp_align_malloc (size_t nbytes, enum mem_type type) | 1038 | lisp_align_malloc (size_t nbytes, enum mem_type type) |
| 1034 | { | 1039 | { |
| 1035 | void *base, *val; | 1040 | void *base, *val; |
| @@ -1136,7 +1141,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 1136 | } | 1141 | } |
| 1137 | 1142 | ||
| 1138 | static void | 1143 | static void |
| 1139 | lisp_align_free (POINTER_TYPE *block) | 1144 | lisp_align_free (void *block) |
| 1140 | { | 1145 | { |
| 1141 | struct ablock *ablock = block; | 1146 | struct ablock *ablock = block; |
| 1142 | struct ablocks *abase = ABLOCK_ABASE (ablock); | 1147 | struct ablocks *abase = ABLOCK_ABASE (ablock); |
| @@ -1309,7 +1314,7 @@ emacs_blocked_malloc (size_t size, const void *ptr) | |||
| 1309 | { | 1314 | { |
| 1310 | fprintf (stderr, "Malloc returned %p which is already in use\n", | 1315 | fprintf (stderr, "Malloc returned %p which is already in use\n", |
| 1311 | value); | 1316 | value); |
| 1312 | fprintf (stderr, "Region in use is %p...%p, %u bytes, type %d\n", | 1317 | fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n", |
| 1313 | m->start, m->end, (char *) m->end - (char *) m->start, | 1318 | m->start, m->end, (char *) m->end - (char *) m->start, |
| 1314 | m->type); | 1319 | m->type); |
| 1315 | abort (); | 1320 | abort (); |
| @@ -3579,8 +3584,6 @@ mem_find (void *start) | |||
| 3579 | } | 3584 | } |
| 3580 | 3585 | ||
| 3581 | 3586 | ||
| 3582 | #ifdef NEED_MEM_INSERT | ||
| 3583 | |||
| 3584 | /* Insert a new node into the tree for a block of memory with start | 3587 | /* Insert a new node into the tree for a block of memory with start |
| 3585 | address START, end address END, and type TYPE. Value is a | 3588 | address START, end address END, and type TYPE. Value is a |
| 3586 | pointer to the node that was inserted. */ | 3589 | pointer to the node that was inserted. */ |
| @@ -3728,8 +3731,6 @@ mem_insert_fixup (struct mem_node *x) | |||
| 3728 | mem_root->color = MEM_BLACK; | 3731 | mem_root->color = MEM_BLACK; |
| 3729 | } | 3732 | } |
| 3730 | 3733 | ||
| 3731 | #endif /* NEED_MEM_INSERT */ | ||
| 3732 | |||
| 3733 | 3734 | ||
| 3734 | /* (x) (y) | 3735 | /* (x) (y) |
| 3735 | / \ / \ | 3736 | / \ / \ |
| @@ -4297,8 +4298,8 @@ mark_maybe_pointer (void *p) | |||
| 4297 | wider than a pointer might allocate a Lisp_Object in non-adjacent halves. | 4298 | wider than a pointer might allocate a Lisp_Object in non-adjacent halves. |
| 4298 | If USE_LSB_TAG, the bottom half is not a valid pointer, but it should | 4299 | If USE_LSB_TAG, the bottom half is not a valid pointer, but it should |
| 4299 | suffice to widen it to to a Lisp_Object and check it that way. */ | 4300 | suffice to widen it to to a Lisp_Object and check it that way. */ |
| 4300 | #if defined USE_LSB_TAG || UINTPTR_MAX >> VALBITS != 0 | 4301 | #if defined USE_LSB_TAG || VAL_MAX < UINTPTR_MAX |
| 4301 | # if !defined USE_LSB_TAG && UINTPTR_MAX >> VALBITS >> GCTYPEBITS != 0 | 4302 | # if !defined USE_LSB_TAG && VAL_MAX < UINTPTR_MAX >> GCTYPEBITS |
| 4302 | /* If tag bits straddle pointer-word boundaries, neither mark_maybe_pointer | 4303 | /* If tag bits straddle pointer-word boundaries, neither mark_maybe_pointer |
| 4303 | nor mark_maybe_object can follow the pointers. This should not occur on | 4304 | nor mark_maybe_object can follow the pointers. This should not occur on |
| 4304 | any practical porting target. */ | 4305 | any practical porting target. */ |
| @@ -4722,10 +4723,10 @@ valid_lisp_object_p (Lisp_Object obj) | |||
| 4722 | pointer to it. TYPE is the Lisp type for which the memory is | 4723 | pointer to it. TYPE is the Lisp type for which the memory is |
| 4723 | allocated. TYPE < 0 means it's not used for a Lisp object. */ | 4724 | allocated. TYPE < 0 means it's not used for a Lisp object. */ |
| 4724 | 4725 | ||
| 4725 | static POINTER_TYPE * | 4726 | static void * |
| 4726 | pure_alloc (size_t size, int type) | 4727 | pure_alloc (size_t size, int type) |
| 4727 | { | 4728 | { |
| 4728 | POINTER_TYPE *result; | 4729 | void *result; |
| 4729 | #ifdef USE_LSB_TAG | 4730 | #ifdef USE_LSB_TAG |
| 4730 | size_t alignment = (1 << GCTYPEBITS); | 4731 | size_t alignment = (1 << GCTYPEBITS); |
| 4731 | #else | 4732 | #else |
| @@ -5838,7 +5839,7 @@ mark_buffer (Lisp_Object buf) | |||
| 5838 | } | 5839 | } |
| 5839 | 5840 | ||
| 5840 | /* Mark the Lisp pointers in the terminal objects. | 5841 | /* Mark the Lisp pointers in the terminal objects. |
| 5841 | Called by the Fgarbage_collector. */ | 5842 | Called by Fgarbage_collect. */ |
| 5842 | 5843 | ||
| 5843 | static void | 5844 | static void |
| 5844 | mark_terminals (void) | 5845 | mark_terminals (void) |
diff --git a/src/buffer.c b/src/buffer.c index d3d5bd268a2..dbaa9f0cc82 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -392,7 +392,6 @@ even if it is dead. The return value is never nil. */) | |||
| 392 | 392 | ||
| 393 | BVAR (b, mark) = Fmake_marker (); | 393 | BVAR (b, mark) = Fmake_marker (); |
| 394 | BUF_MARKERS (b) = NULL; | 394 | BUF_MARKERS (b) = NULL; |
| 395 | BVAR (b, name) = name; | ||
| 396 | 395 | ||
| 397 | /* Put this in the alist of all live buffers. */ | 396 | /* Put this in the alist of all live buffers. */ |
| 398 | XSETBUFFER (buffer, b); | 397 | XSETBUFFER (buffer, b); |
| @@ -612,7 +611,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 612 | Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); | 611 | Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); |
| 613 | 612 | ||
| 614 | BVAR (b, mark) = Fmake_marker (); | 613 | BVAR (b, mark) = Fmake_marker (); |
| 615 | BVAR (b, name) = name; | ||
| 616 | 614 | ||
| 617 | /* The multibyte status belongs to the base buffer. */ | 615 | /* The multibyte status belongs to the base buffer. */ |
| 618 | BVAR (b, enable_multibyte_characters) = BVAR (b->base_buffer, enable_multibyte_characters); | 616 | BVAR (b, enable_multibyte_characters) = BVAR (b->base_buffer, enable_multibyte_characters); |
| @@ -2052,10 +2050,10 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2052 | eassert (current_buffer->text == ¤t_buffer->own_text); | 2050 | eassert (current_buffer->text == ¤t_buffer->own_text); |
| 2053 | eassert (other_buffer->text == &other_buffer->own_text); | 2051 | eassert (other_buffer->text == &other_buffer->own_text); |
| 2054 | #ifdef REL_ALLOC | 2052 | #ifdef REL_ALLOC |
| 2055 | r_alloc_reset_variable ((POINTER_TYPE **) ¤t_buffer->own_text.beg, | 2053 | r_alloc_reset_variable ((void **) ¤t_buffer->own_text.beg, |
| 2056 | (POINTER_TYPE **) &other_buffer->own_text.beg); | 2054 | (void **) &other_buffer->own_text.beg); |
| 2057 | r_alloc_reset_variable ((POINTER_TYPE **) &other_buffer->own_text.beg, | 2055 | r_alloc_reset_variable ((void **) &other_buffer->own_text.beg, |
| 2058 | (POINTER_TYPE **) ¤t_buffer->own_text.beg); | 2056 | (void **) ¤t_buffer->own_text.beg); |
| 2059 | #endif /* REL_ALLOC */ | 2057 | #endif /* REL_ALLOC */ |
| 2060 | 2058 | ||
| 2061 | swapfield (pt, ptrdiff_t); | 2059 | swapfield (pt, ptrdiff_t); |
| @@ -4384,7 +4382,7 @@ struct mmap_region | |||
| 4384 | /* Pointer to the location holding the address of the memory | 4382 | /* Pointer to the location holding the address of the memory |
| 4385 | allocated with the mmap'd block. The variable actually points | 4383 | allocated with the mmap'd block. The variable actually points |
| 4386 | after this structure. */ | 4384 | after this structure. */ |
| 4387 | POINTER_TYPE **var; | 4385 | void **var; |
| 4388 | 4386 | ||
| 4389 | /* Next and previous in list of all mmap'd regions. */ | 4387 | /* Next and previous in list of all mmap'd regions. */ |
| 4390 | struct mmap_region *next, *prev; | 4388 | struct mmap_region *next, *prev; |
| @@ -4431,7 +4429,7 @@ static int mmap_initialized_p; | |||
| 4431 | to the start of the user-visible part of the region. */ | 4429 | to the start of the user-visible part of the region. */ |
| 4432 | 4430 | ||
| 4433 | #define MMAP_USER_AREA(P) \ | 4431 | #define MMAP_USER_AREA(P) \ |
| 4434 | ((POINTER_TYPE *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE)) | 4432 | ((void *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE)) |
| 4435 | 4433 | ||
| 4436 | #define MEM_ALIGN sizeof (double) | 4434 | #define MEM_ALIGN sizeof (double) |
| 4437 | 4435 | ||
| @@ -4480,7 +4478,7 @@ mmap_init (void) | |||
| 4480 | is at END - 1. */ | 4478 | is at END - 1. */ |
| 4481 | 4479 | ||
| 4482 | static struct mmap_region * | 4480 | static struct mmap_region * |
| 4483 | mmap_find (POINTER_TYPE *start, POINTER_TYPE *end) | 4481 | mmap_find (void *start, void *end) |
| 4484 | { | 4482 | { |
| 4485 | struct mmap_region *r; | 4483 | struct mmap_region *r; |
| 4486 | char *s = (char *) start, *e = (char *) end; | 4484 | char *s = (char *) start, *e = (char *) end; |
| @@ -4518,7 +4516,7 @@ mmap_free_1 (struct mmap_region *r) | |||
| 4518 | else | 4516 | else |
| 4519 | mmap_regions = r->next; | 4517 | mmap_regions = r->next; |
| 4520 | 4518 | ||
| 4521 | if (munmap ((POINTER_TYPE *) r, r->nbytes_mapped) == -1) | 4519 | if (munmap (r, r->nbytes_mapped) == -1) |
| 4522 | { | 4520 | { |
| 4523 | fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); | 4521 | fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); |
| 4524 | return 0; | 4522 | return 0; |
| @@ -4560,13 +4558,13 @@ mmap_enlarge (struct mmap_region *r, int npages) | |||
| 4560 | I'm not sure this is worth doing, let's see. */ | 4558 | I'm not sure this is worth doing, let's see. */ |
| 4561 | if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes)) | 4559 | if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes)) |
| 4562 | { | 4560 | { |
| 4563 | POINTER_TYPE *p; | 4561 | void *p; |
| 4564 | 4562 | ||
| 4565 | p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, | 4563 | p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, |
| 4566 | MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); | 4564 | MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); |
| 4567 | if (p == MAP_FAILED) | 4565 | if (p == MAP_FAILED) |
| 4568 | ; /* fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); */ | 4566 | ; /* fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); */ |
| 4569 | else if (p != (POINTER_TYPE *) region_end) | 4567 | else if (p != region_end) |
| 4570 | { | 4568 | { |
| 4571 | /* Kernels are free to choose a different address. In | 4569 | /* Kernels are free to choose a different address. In |
| 4572 | that case, unmap what we've mapped above; we have | 4570 | that case, unmap what we've mapped above; we have |
| @@ -4628,8 +4626,8 @@ mmap_set_vars (int restore_p) | |||
| 4628 | If we can't allocate the necessary memory, set *VAR to null, and | 4626 | If we can't allocate the necessary memory, set *VAR to null, and |
| 4629 | return null. */ | 4627 | return null. */ |
| 4630 | 4628 | ||
| 4631 | static POINTER_TYPE * | 4629 | static void * |
| 4632 | mmap_alloc (POINTER_TYPE **var, size_t nbytes) | 4630 | mmap_alloc (void **var, size_t nbytes) |
| 4633 | { | 4631 | { |
| 4634 | void *p; | 4632 | void *p; |
| 4635 | size_t map; | 4633 | size_t map; |
| @@ -4670,7 +4668,7 @@ mmap_alloc (POINTER_TYPE **var, size_t nbytes) | |||
| 4670 | PTR. Store 0 in *PTR to show there's no block allocated. */ | 4668 | PTR. Store 0 in *PTR to show there's no block allocated. */ |
| 4671 | 4669 | ||
| 4672 | static void | 4670 | static void |
| 4673 | mmap_free (POINTER_TYPE **var) | 4671 | mmap_free (void **var) |
| 4674 | { | 4672 | { |
| 4675 | mmap_init (); | 4673 | mmap_init (); |
| 4676 | 4674 | ||
| @@ -4687,10 +4685,10 @@ mmap_free (POINTER_TYPE **var) | |||
| 4687 | and return this value. If more memory cannot be allocated, then | 4685 | and return this value. If more memory cannot be allocated, then |
| 4688 | leave *VAR unchanged, and return null. */ | 4686 | leave *VAR unchanged, and return null. */ |
| 4689 | 4687 | ||
| 4690 | static POINTER_TYPE * | 4688 | static void * |
| 4691 | mmap_realloc (POINTER_TYPE **var, size_t nbytes) | 4689 | mmap_realloc (void **var, size_t nbytes) |
| 4692 | { | 4690 | { |
| 4693 | POINTER_TYPE *result; | 4691 | void *result; |
| 4694 | 4692 | ||
| 4695 | mmap_init (); | 4693 | mmap_init (); |
| 4696 | 4694 | ||
| @@ -4709,7 +4707,7 @@ mmap_realloc (POINTER_TYPE **var, size_t nbytes) | |||
| 4709 | if (room < nbytes) | 4707 | if (room < nbytes) |
| 4710 | { | 4708 | { |
| 4711 | /* Must enlarge. */ | 4709 | /* Must enlarge. */ |
| 4712 | POINTER_TYPE *old_ptr = *var; | 4710 | void *old_ptr = *var; |
| 4713 | 4711 | ||
| 4714 | /* Try to map additional pages at the end of the region. | 4712 | /* Try to map additional pages at the end of the region. |
| 4715 | If that fails, allocate a new region, copy data | 4713 | If that fails, allocate a new region, copy data |
| @@ -4771,13 +4769,13 @@ mmap_realloc (POINTER_TYPE **var, size_t nbytes) | |||
| 4771 | static void | 4769 | static void |
| 4772 | alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) | 4770 | alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) |
| 4773 | { | 4771 | { |
| 4774 | POINTER_TYPE *p; | 4772 | void *p; |
| 4775 | 4773 | ||
| 4776 | BLOCK_INPUT; | 4774 | BLOCK_INPUT; |
| 4777 | #if defined USE_MMAP_FOR_BUFFERS | 4775 | #if defined USE_MMAP_FOR_BUFFERS |
| 4778 | p = mmap_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); | 4776 | p = mmap_alloc ((void **) &b->text->beg, nbytes); |
| 4779 | #elif defined REL_ALLOC | 4777 | #elif defined REL_ALLOC |
| 4780 | p = r_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); | 4778 | p = r_alloc ((void **) &b->text->beg, nbytes); |
| 4781 | #else | 4779 | #else |
| 4782 | p = xmalloc (nbytes); | 4780 | p = xmalloc (nbytes); |
| 4783 | #endif | 4781 | #endif |
| @@ -4798,14 +4796,14 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) | |||
| 4798 | void | 4796 | void |
| 4799 | enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) | 4797 | enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) |
| 4800 | { | 4798 | { |
| 4801 | POINTER_TYPE *p; | 4799 | void *p; |
| 4802 | ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 | 4800 | ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 |
| 4803 | + delta); | 4801 | + delta); |
| 4804 | BLOCK_INPUT; | 4802 | BLOCK_INPUT; |
| 4805 | #if defined USE_MMAP_FOR_BUFFERS | 4803 | #if defined USE_MMAP_FOR_BUFFERS |
| 4806 | p = mmap_realloc ((POINTER_TYPE **) &b->text->beg, nbytes); | 4804 | p = mmap_realloc ((void **) &b->text->beg, nbytes); |
| 4807 | #elif defined REL_ALLOC | 4805 | #elif defined REL_ALLOC |
| 4808 | p = r_re_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); | 4806 | p = r_re_alloc ((void **) &b->text->beg, nbytes); |
| 4809 | #else | 4807 | #else |
| 4810 | p = xrealloc (b->text->beg, nbytes); | 4808 | p = xrealloc (b->text->beg, nbytes); |
| 4811 | #endif | 4809 | #endif |
| @@ -4829,9 +4827,9 @@ free_buffer_text (struct buffer *b) | |||
| 4829 | BLOCK_INPUT; | 4827 | BLOCK_INPUT; |
| 4830 | 4828 | ||
| 4831 | #if defined USE_MMAP_FOR_BUFFERS | 4829 | #if defined USE_MMAP_FOR_BUFFERS |
| 4832 | mmap_free ((POINTER_TYPE **) &b->text->beg); | 4830 | mmap_free ((void **) &b->text->beg); |
| 4833 | #elif defined REL_ALLOC | 4831 | #elif defined REL_ALLOC |
| 4834 | r_alloc_free ((POINTER_TYPE **) &b->text->beg); | 4832 | r_alloc_free ((void **) &b->text->beg); |
| 4835 | #else | 4833 | #else |
| 4836 | xfree (b->text->beg); | 4834 | xfree (b->text->beg); |
| 4837 | #endif | 4835 | #endif |
diff --git a/src/character.h b/src/character.h index 8a0f2d4c3f6..a64b48d896c 100644 --- a/src/character.h +++ b/src/character.h | |||
| @@ -434,7 +434,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 434 | unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ | 434 | unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ |
| 435 | int chlen; \ | 435 | int chlen; \ |
| 436 | \ | 436 | \ |
| 437 | OUTPUT= STRING_CHAR_AND_LENGTH (chp, chlen); \ | 437 | OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \ |
| 438 | BYTEIDX += chlen; \ | 438 | BYTEIDX += chlen; \ |
| 439 | } \ | 439 | } \ |
| 440 | else \ | 440 | else \ |
diff --git a/src/data.c b/src/data.c index 7c0d1830344..11660a2483d 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -51,7 +51,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 51 | Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; | 51 | Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; |
| 52 | static Lisp_Object Qsubr; | 52 | static Lisp_Object Qsubr; |
| 53 | Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; | 53 | Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; |
| 54 | Lisp_Object Qerror, Qquit, Qargs_out_of_range; | 54 | Lisp_Object Qerror, Quser_error, Qquit, Qargs_out_of_range; |
| 55 | static Lisp_Object Qwrong_type_argument; | 55 | static Lisp_Object Qwrong_type_argument; |
| 56 | Lisp_Object Qvoid_variable, Qvoid_function; | 56 | Lisp_Object Qvoid_variable, Qvoid_function; |
| 57 | static Lisp_Object Qcyclic_function_indirection; | 57 | static Lisp_Object Qcyclic_function_indirection; |
| @@ -2938,6 +2938,7 @@ syms_of_data (void) | |||
| 2938 | DEFSYM (Qtop_level, "top-level"); | 2938 | DEFSYM (Qtop_level, "top-level"); |
| 2939 | 2939 | ||
| 2940 | DEFSYM (Qerror, "error"); | 2940 | DEFSYM (Qerror, "error"); |
| 2941 | DEFSYM (Quser_error, "user-error"); | ||
| 2941 | DEFSYM (Qquit, "quit"); | 2942 | DEFSYM (Qquit, "quit"); |
| 2942 | DEFSYM (Qwrong_type_argument, "wrong-type-argument"); | 2943 | DEFSYM (Qwrong_type_argument, "wrong-type-argument"); |
| 2943 | DEFSYM (Qargs_out_of_range, "args-out-of-range"); | 2944 | DEFSYM (Qargs_out_of_range, "args-out-of-range"); |
| @@ -3005,102 +3006,42 @@ syms_of_data (void) | |||
| 3005 | Fput (Qerror, Qerror_message, | 3006 | Fput (Qerror, Qerror_message, |
| 3006 | make_pure_c_string ("error")); | 3007 | make_pure_c_string ("error")); |
| 3007 | 3008 | ||
| 3008 | Fput (Qquit, Qerror_conditions, | 3009 | #define PUT_ERROR(sym, tail, msg) \ |
| 3009 | pure_cons (Qquit, Qnil)); | 3010 | Fput (sym, Qerror_conditions, pure_cons (sym, tail)); \ |
| 3010 | Fput (Qquit, Qerror_message, | 3011 | Fput (sym, Qerror_message, make_pure_c_string (msg)) |
| 3011 | make_pure_c_string ("Quit")); | 3012 | |
| 3012 | 3013 | PUT_ERROR (Qquit, Qnil, "Quit"); | |
| 3013 | Fput (Qwrong_type_argument, Qerror_conditions, | 3014 | |
| 3014 | pure_cons (Qwrong_type_argument, error_tail)); | 3015 | PUT_ERROR (Quser_error, error_tail, ""); |
| 3015 | Fput (Qwrong_type_argument, Qerror_message, | 3016 | PUT_ERROR (Qwrong_type_argument, error_tail, "Wrong type argument"); |
| 3016 | make_pure_c_string ("Wrong type argument")); | 3017 | PUT_ERROR (Qargs_out_of_range, error_tail, "Args out of range"); |
| 3017 | 3018 | PUT_ERROR (Qvoid_function, error_tail, | |
| 3018 | Fput (Qargs_out_of_range, Qerror_conditions, | 3019 | "Symbol's function definition is void"); |
| 3019 | pure_cons (Qargs_out_of_range, error_tail)); | 3020 | PUT_ERROR (Qcyclic_function_indirection, error_tail, |
| 3020 | Fput (Qargs_out_of_range, Qerror_message, | 3021 | "Symbol's chain of function indirections contains a loop"); |
| 3021 | make_pure_c_string ("Args out of range")); | 3022 | PUT_ERROR (Qcyclic_variable_indirection, error_tail, |
| 3022 | 3023 | "Symbol's chain of variable indirections contains a loop"); | |
| 3023 | Fput (Qvoid_function, Qerror_conditions, | ||
| 3024 | pure_cons (Qvoid_function, error_tail)); | ||
| 3025 | Fput (Qvoid_function, Qerror_message, | ||
| 3026 | make_pure_c_string ("Symbol's function definition is void")); | ||
| 3027 | |||
| 3028 | Fput (Qcyclic_function_indirection, Qerror_conditions, | ||
| 3029 | pure_cons (Qcyclic_function_indirection, error_tail)); | ||
| 3030 | Fput (Qcyclic_function_indirection, Qerror_message, | ||
| 3031 | make_pure_c_string ("Symbol's chain of function indirections contains a loop")); | ||
| 3032 | |||
| 3033 | Fput (Qcyclic_variable_indirection, Qerror_conditions, | ||
| 3034 | pure_cons (Qcyclic_variable_indirection, error_tail)); | ||
| 3035 | Fput (Qcyclic_variable_indirection, Qerror_message, | ||
| 3036 | make_pure_c_string ("Symbol's chain of variable indirections contains a loop")); | ||
| 3037 | |||
| 3038 | DEFSYM (Qcircular_list, "circular-list"); | 3024 | DEFSYM (Qcircular_list, "circular-list"); |
| 3039 | Fput (Qcircular_list, Qerror_conditions, | 3025 | PUT_ERROR (Qcircular_list, error_tail, "List contains a loop"); |
| 3040 | pure_cons (Qcircular_list, error_tail)); | 3026 | PUT_ERROR (Qvoid_variable, error_tail, "Symbol's value as variable is void"); |
| 3041 | Fput (Qcircular_list, Qerror_message, | 3027 | PUT_ERROR (Qsetting_constant, error_tail, |
| 3042 | make_pure_c_string ("List contains a loop")); | 3028 | "Attempt to set a constant symbol"); |
| 3043 | 3029 | PUT_ERROR (Qinvalid_read_syntax, error_tail, "Invalid read syntax"); | |
| 3044 | Fput (Qvoid_variable, Qerror_conditions, | 3030 | PUT_ERROR (Qinvalid_function, error_tail, "Invalid function"); |
| 3045 | pure_cons (Qvoid_variable, error_tail)); | 3031 | PUT_ERROR (Qwrong_number_of_arguments, error_tail, |
| 3046 | Fput (Qvoid_variable, Qerror_message, | 3032 | "Wrong number of arguments"); |
| 3047 | make_pure_c_string ("Symbol's value as variable is void")); | 3033 | PUT_ERROR (Qno_catch, error_tail, "No catch for tag"); |
| 3048 | 3034 | PUT_ERROR (Qend_of_file, error_tail, "End of file during parsing"); | |
| 3049 | Fput (Qsetting_constant, Qerror_conditions, | ||
| 3050 | pure_cons (Qsetting_constant, error_tail)); | ||
| 3051 | Fput (Qsetting_constant, Qerror_message, | ||
| 3052 | make_pure_c_string ("Attempt to set a constant symbol")); | ||
| 3053 | |||
| 3054 | Fput (Qinvalid_read_syntax, Qerror_conditions, | ||
| 3055 | pure_cons (Qinvalid_read_syntax, error_tail)); | ||
| 3056 | Fput (Qinvalid_read_syntax, Qerror_message, | ||
| 3057 | make_pure_c_string ("Invalid read syntax")); | ||
| 3058 | |||
| 3059 | Fput (Qinvalid_function, Qerror_conditions, | ||
| 3060 | pure_cons (Qinvalid_function, error_tail)); | ||
| 3061 | Fput (Qinvalid_function, Qerror_message, | ||
| 3062 | make_pure_c_string ("Invalid function")); | ||
| 3063 | |||
| 3064 | Fput (Qwrong_number_of_arguments, Qerror_conditions, | ||
| 3065 | pure_cons (Qwrong_number_of_arguments, error_tail)); | ||
| 3066 | Fput (Qwrong_number_of_arguments, Qerror_message, | ||
| 3067 | make_pure_c_string ("Wrong number of arguments")); | ||
| 3068 | |||
| 3069 | Fput (Qno_catch, Qerror_conditions, | ||
| 3070 | pure_cons (Qno_catch, error_tail)); | ||
| 3071 | Fput (Qno_catch, Qerror_message, | ||
| 3072 | make_pure_c_string ("No catch for tag")); | ||
| 3073 | |||
| 3074 | Fput (Qend_of_file, Qerror_conditions, | ||
| 3075 | pure_cons (Qend_of_file, error_tail)); | ||
| 3076 | Fput (Qend_of_file, Qerror_message, | ||
| 3077 | make_pure_c_string ("End of file during parsing")); | ||
| 3078 | 3035 | ||
| 3079 | arith_tail = pure_cons (Qarith_error, error_tail); | 3036 | arith_tail = pure_cons (Qarith_error, error_tail); |
| 3080 | Fput (Qarith_error, Qerror_conditions, | 3037 | Fput (Qarith_error, Qerror_conditions, arith_tail); |
| 3081 | arith_tail); | 3038 | Fput (Qarith_error, Qerror_message, make_pure_c_string ("Arithmetic error")); |
| 3082 | Fput (Qarith_error, Qerror_message, | 3039 | |
| 3083 | make_pure_c_string ("Arithmetic error")); | 3040 | PUT_ERROR (Qbeginning_of_buffer, error_tail, "Beginning of buffer"); |
| 3084 | 3041 | PUT_ERROR (Qend_of_buffer, error_tail, "End of buffer"); | |
| 3085 | Fput (Qbeginning_of_buffer, Qerror_conditions, | 3042 | PUT_ERROR (Qbuffer_read_only, error_tail, "Buffer is read-only"); |
| 3086 | pure_cons (Qbeginning_of_buffer, error_tail)); | 3043 | PUT_ERROR (Qtext_read_only, pure_cons (Qbuffer_read_only, error_tail), |
| 3087 | Fput (Qbeginning_of_buffer, Qerror_message, | 3044 | "Text is read-only"); |
| 3088 | make_pure_c_string ("Beginning of buffer")); | ||
| 3089 | |||
| 3090 | Fput (Qend_of_buffer, Qerror_conditions, | ||
| 3091 | pure_cons (Qend_of_buffer, error_tail)); | ||
| 3092 | Fput (Qend_of_buffer, Qerror_message, | ||
| 3093 | make_pure_c_string ("End of buffer")); | ||
| 3094 | |||
| 3095 | Fput (Qbuffer_read_only, Qerror_conditions, | ||
| 3096 | pure_cons (Qbuffer_read_only, error_tail)); | ||
| 3097 | Fput (Qbuffer_read_only, Qerror_message, | ||
| 3098 | make_pure_c_string ("Buffer is read-only")); | ||
| 3099 | |||
| 3100 | Fput (Qtext_read_only, Qerror_conditions, | ||
| 3101 | pure_cons (Qtext_read_only, error_tail)); | ||
| 3102 | Fput (Qtext_read_only, Qerror_message, | ||
| 3103 | make_pure_c_string ("Text is read-only")); | ||
| 3104 | 3045 | ||
| 3105 | DEFSYM (Qrange_error, "range-error"); | 3046 | DEFSYM (Qrange_error, "range-error"); |
| 3106 | DEFSYM (Qdomain_error, "domain-error"); | 3047 | DEFSYM (Qdomain_error, "domain-error"); |
| @@ -3108,30 +3049,17 @@ syms_of_data (void) | |||
| 3108 | DEFSYM (Qoverflow_error, "overflow-error"); | 3049 | DEFSYM (Qoverflow_error, "overflow-error"); |
| 3109 | DEFSYM (Qunderflow_error, "underflow-error"); | 3050 | DEFSYM (Qunderflow_error, "underflow-error"); |
| 3110 | 3051 | ||
| 3111 | Fput (Qdomain_error, Qerror_conditions, | 3052 | PUT_ERROR (Qdomain_error, arith_tail, "Arithmetic domain error"); |
| 3112 | pure_cons (Qdomain_error, arith_tail)); | 3053 | |
| 3113 | Fput (Qdomain_error, Qerror_message, | 3054 | PUT_ERROR (Qrange_error, arith_tail, "Arithmetic range error"); |
| 3114 | make_pure_c_string ("Arithmetic domain error")); | 3055 | |
| 3115 | 3056 | PUT_ERROR (Qsingularity_error, Fcons (Qdomain_error, arith_tail), | |
| 3116 | Fput (Qrange_error, Qerror_conditions, | 3057 | "Arithmetic singularity error"); |
| 3117 | pure_cons (Qrange_error, arith_tail)); | 3058 | |
| 3118 | Fput (Qrange_error, Qerror_message, | 3059 | PUT_ERROR (Qoverflow_error, Fcons (Qdomain_error, arith_tail), |
| 3119 | make_pure_c_string ("Arithmetic range error")); | 3060 | "Arithmetic overflow error"); |
| 3120 | 3061 | PUT_ERROR (Qunderflow_error, Fcons (Qdomain_error, arith_tail), | |
| 3121 | Fput (Qsingularity_error, Qerror_conditions, | 3062 | "Arithmetic underflow error"); |
| 3122 | pure_cons (Qsingularity_error, Fcons (Qdomain_error, arith_tail))); | ||
| 3123 | Fput (Qsingularity_error, Qerror_message, | ||
| 3124 | make_pure_c_string ("Arithmetic singularity error")); | ||
| 3125 | |||
| 3126 | Fput (Qoverflow_error, Qerror_conditions, | ||
| 3127 | pure_cons (Qoverflow_error, Fcons (Qdomain_error, arith_tail))); | ||
| 3128 | Fput (Qoverflow_error, Qerror_message, | ||
| 3129 | make_pure_c_string ("Arithmetic overflow error")); | ||
| 3130 | |||
| 3131 | Fput (Qunderflow_error, Qerror_conditions, | ||
| 3132 | pure_cons (Qunderflow_error, Fcons (Qdomain_error, arith_tail))); | ||
| 3133 | Fput (Qunderflow_error, Qerror_message, | ||
| 3134 | make_pure_c_string ("Arithmetic underflow error")); | ||
| 3135 | 3063 | ||
| 3136 | staticpro (&Qnil); | 3064 | staticpro (&Qnil); |
| 3137 | staticpro (&Qt); | 3065 | staticpro (&Qt); |
diff --git a/src/dbusbind.c b/src/dbusbind.c index c4e57dad98a..2ed7369c9dc 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -28,19 +28,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 28 | #include "keyboard.h" | 28 | #include "keyboard.h" |
| 29 | #include "process.h" | 29 | #include "process.h" |
| 30 | 30 | ||
| 31 | #ifndef DBUS_NUM_MESSAGE_TYPES | ||
| 32 | #define DBUS_NUM_MESSAGE_TYPES 5 | ||
| 33 | #endif | ||
| 34 | |||
| 31 | 35 | ||
| 32 | /* Subroutines. */ | 36 | /* Subroutines. */ |
| 33 | static Lisp_Object Qdbus_init_bus; | 37 | static Lisp_Object Qdbus_init_bus; |
| 34 | static Lisp_Object Qdbus_close_bus; | ||
| 35 | static Lisp_Object Qdbus_get_unique_name; | 38 | static Lisp_Object Qdbus_get_unique_name; |
| 36 | static Lisp_Object Qdbus_call_method; | 39 | static Lisp_Object Qdbus_message_internal; |
| 37 | static Lisp_Object Qdbus_call_method_asynchronously; | ||
| 38 | static Lisp_Object Qdbus_method_return_internal; | ||
| 39 | static Lisp_Object Qdbus_method_error_internal; | ||
| 40 | static Lisp_Object Qdbus_send_signal; | ||
| 41 | static Lisp_Object Qdbus_register_service; | ||
| 42 | static Lisp_Object Qdbus_register_signal; | ||
| 43 | static Lisp_Object Qdbus_register_method; | ||
| 44 | 40 | ||
| 45 | /* D-Bus error symbol. */ | 41 | /* D-Bus error symbol. */ |
| 46 | static Lisp_Object Qdbus_error; | 42 | static Lisp_Object Qdbus_error; |
| @@ -51,17 +47,6 @@ static Lisp_Object QCdbus_system_bus, QCdbus_session_bus; | |||
| 51 | /* Lisp symbol for method call timeout. */ | 47 | /* Lisp symbol for method call timeout. */ |
| 52 | static Lisp_Object QCdbus_timeout; | 48 | static Lisp_Object QCdbus_timeout; |
| 53 | 49 | ||
| 54 | /* Lisp symbols for name request flags. */ | ||
| 55 | static Lisp_Object QCdbus_request_name_allow_replacement; | ||
| 56 | static Lisp_Object QCdbus_request_name_replace_existing; | ||
| 57 | static Lisp_Object QCdbus_request_name_do_not_queue; | ||
| 58 | |||
| 59 | /* Lisp symbols for name request replies. */ | ||
| 60 | static Lisp_Object QCdbus_request_name_reply_primary_owner; | ||
| 61 | static Lisp_Object QCdbus_request_name_reply_in_queue; | ||
| 62 | static Lisp_Object QCdbus_request_name_reply_exists; | ||
| 63 | static Lisp_Object QCdbus_request_name_reply_already_owner; | ||
| 64 | |||
| 65 | /* Lisp symbols of D-Bus types. */ | 50 | /* Lisp symbols of D-Bus types. */ |
| 66 | static Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; | 51 | static Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; |
| 67 | static Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; | 52 | static Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; |
| @@ -75,6 +60,15 @@ static Lisp_Object QCdbus_type_unix_fd; | |||
| 75 | static Lisp_Object QCdbus_type_array, QCdbus_type_variant; | 60 | static Lisp_Object QCdbus_type_array, QCdbus_type_variant; |
| 76 | static Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; | 61 | static Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; |
| 77 | 62 | ||
| 63 | /* Lisp symbols of objects in `dbus-registered-objects-table'. */ | ||
| 64 | static Lisp_Object QCdbus_registered_serial, QCdbus_registered_method; | ||
| 65 | static Lisp_Object QCdbus_registered_signal; | ||
| 66 | |||
| 67 | /* Alist of D-Bus buses we are polling for messages. | ||
| 68 | The key is the symbol or string of the bus, and the value is the | ||
| 69 | connection address. */ | ||
| 70 | static Lisp_Object xd_registered_buses; | ||
| 71 | |||
| 78 | /* Whether we are reading a D-Bus event. */ | 72 | /* Whether we are reading a D-Bus event. */ |
| 79 | static int xd_in_read_queued_messages = 0; | 73 | static int xd_in_read_queued_messages = 0; |
| 80 | 74 | ||
| @@ -120,14 +114,15 @@ static int xd_in_read_queued_messages = 0; | |||
| 120 | } while (0) | 114 | } while (0) |
| 121 | 115 | ||
| 122 | /* Macros for debugging. In order to enable them, build with | 116 | /* Macros for debugging. In order to enable them, build with |
| 123 | "MYCPPFLAGS='-DDBUS_DEBUG -Wall' make". */ | 117 | "env MYCPPFLAGS='-DDBUS_DEBUG -Wall' make". */ |
| 124 | #ifdef DBUS_DEBUG | 118 | #ifdef DBUS_DEBUG |
| 125 | #define XD_DEBUG_MESSAGE(...) \ | 119 | #define XD_DEBUG_MESSAGE(...) \ |
| 126 | do { \ | 120 | do { \ |
| 127 | char s[1024]; \ | 121 | char s[1024]; \ |
| 128 | snprintf (s, sizeof s, __VA_ARGS__); \ | 122 | snprintf (s, sizeof s, __VA_ARGS__); \ |
| 129 | printf ("%s: %s\n", __func__, s); \ | 123 | if (!noninteractive) \ |
| 130 | message ("%s: %s", __func__, s); \ | 124 | printf ("%s: %s\n", __func__, s); \ |
| 125 | message ("%s: %s", __func__, s); \ | ||
| 131 | } while (0) | 126 | } while (0) |
| 132 | #define XD_DEBUG_VALID_LISP_OBJECT_P(object) \ | 127 | #define XD_DEBUG_VALID_LISP_OBJECT_P(object) \ |
| 133 | do { \ | 128 | do { \ |
| @@ -144,7 +139,7 @@ static int xd_in_read_queued_messages = 0; | |||
| 144 | if (!NILP (Vdbus_debug)) \ | 139 | if (!NILP (Vdbus_debug)) \ |
| 145 | { \ | 140 | { \ |
| 146 | char s[1024]; \ | 141 | char s[1024]; \ |
| 147 | snprintf (s, 1023, __VA_ARGS__); \ | 142 | snprintf (s, sizeof s, __VA_ARGS__); \ |
| 148 | message ("%s: %s", __func__, s); \ | 143 | message ("%s: %s", __func__, s); \ |
| 149 | } \ | 144 | } \ |
| 150 | } while (0) | 145 | } while (0) |
| @@ -241,23 +236,115 @@ xd_symbol_to_dbus_type (Lisp_Object object) | |||
| 241 | #define XD_NEXT_VALUE(object) \ | 236 | #define XD_NEXT_VALUE(object) \ |
| 242 | ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object) | 237 | ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object) |
| 243 | 238 | ||
| 239 | /* Transform the message type to its string representation for debug | ||
| 240 | messages. */ | ||
| 241 | #define XD_MESSAGE_TYPE_TO_STRING(mtype) \ | ||
| 242 | ((mtype == DBUS_MESSAGE_TYPE_INVALID) \ | ||
| 243 | ? "DBUS_MESSAGE_TYPE_INVALID" \ | ||
| 244 | : (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) \ | ||
| 245 | ? "DBUS_MESSAGE_TYPE_METHOD_CALL" \ | ||
| 246 | : (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) \ | ||
| 247 | ? "DBUS_MESSAGE_TYPE_METHOD_RETURN" \ | ||
| 248 | : (mtype == DBUS_MESSAGE_TYPE_ERROR) \ | ||
| 249 | ? "DBUS_MESSAGE_TYPE_ERROR" \ | ||
| 250 | : "DBUS_MESSAGE_TYPE_SIGNAL") | ||
| 251 | |||
| 252 | /* Transform the object to its string representation for debug | ||
| 253 | messages. */ | ||
| 254 | #define XD_OBJECT_TO_STRING(object) \ | ||
| 255 | SDATA (format2 ("%s", object, Qnil)) | ||
| 256 | |||
| 244 | /* Check whether X is a valid dbus serial number. If valid, set | 257 | /* Check whether X is a valid dbus serial number. If valid, set |
| 245 | SERIAL to its value. Otherwise, signal an error. */ | 258 | SERIAL to its value. Otherwise, signal an error. */ |
| 246 | #define CHECK_DBUS_SERIAL_GET_SERIAL(x, serial) \ | 259 | #define XD_CHECK_DBUS_SERIAL(x, serial) \ |
| 247 | do \ | 260 | do { \ |
| 248 | { \ | 261 | dbus_uint32_t DBUS_SERIAL_MAX = -1; \ |
| 249 | dbus_uint32_t DBUS_SERIAL_MAX = -1; \ | 262 | if (NATNUMP (x) && XINT (x) <= DBUS_SERIAL_MAX) \ |
| 250 | if (NATNUMP (x) && XINT (x) <= DBUS_SERIAL_MAX) \ | 263 | serial = XINT (x); \ |
| 251 | serial = XINT (x); \ | 264 | else if (MOST_POSITIVE_FIXNUM < DBUS_SERIAL_MAX \ |
| 252 | else if (MOST_POSITIVE_FIXNUM < DBUS_SERIAL_MAX \ | 265 | && FLOATP (x) \ |
| 253 | && FLOATP (x) \ | 266 | && 0 <= XFLOAT_DATA (x) \ |
| 254 | && 0 <= XFLOAT_DATA (x) \ | 267 | && XFLOAT_DATA (x) <= DBUS_SERIAL_MAX) \ |
| 255 | && XFLOAT_DATA (x) <= DBUS_SERIAL_MAX) \ | 268 | serial = XFLOAT_DATA (x); \ |
| 256 | serial = XFLOAT_DATA (x); \ | 269 | else \ |
| 257 | else \ | 270 | XD_SIGNAL2 (build_string ("Invalid dbus serial"), x); \ |
| 258 | XD_SIGNAL2 (build_string ("Invalid dbus serial"), x); \ | 271 | } while (0) |
| 259 | } \ | 272 | |
| 260 | while (0) | 273 | #define XD_DBUS_VALIDATE_BUS_ADDRESS(bus) \ |
| 274 | do { \ | ||
| 275 | if (STRINGP (bus)) \ | ||
| 276 | { \ | ||
| 277 | DBusAddressEntry **entries; \ | ||
| 278 | int len; \ | ||
| 279 | DBusError derror; \ | ||
| 280 | dbus_error_init (&derror); \ | ||
| 281 | if (!dbus_parse_address (SSDATA (bus), &entries, &len, &derror)) \ | ||
| 282 | XD_ERROR (derror); \ | ||
| 283 | /* Cleanup. */ \ | ||
| 284 | dbus_error_free (&derror); \ | ||
| 285 | dbus_address_entries_free (entries); \ | ||
| 286 | } \ | ||
| 287 | \ | ||
| 288 | else \ | ||
| 289 | { \ | ||
| 290 | CHECK_SYMBOL (bus); \ | ||
| 291 | if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus))) \ | ||
| 292 | XD_SIGNAL2 (build_string ("Wrong bus name"), bus); \ | ||
| 293 | /* We do not want to have an autolaunch for the session bus. */ \ | ||
| 294 | if (EQ (bus, QCdbus_session_bus) \ | ||
| 295 | && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL) \ | ||
| 296 | XD_SIGNAL2 (build_string ("No connection to bus"), bus); \ | ||
| 297 | } \ | ||
| 298 | } while (0) | ||
| 299 | |||
| 300 | #if (HAVE_DBUS_VALIDATE_BUS_NAME || HAVE_DBUS_VALIDATE_PATH \ | ||
| 301 | || XD_DBUS_VALIDATE_OBJECT || HAVE_DBUS_VALIDATE_MEMBER) | ||
| 302 | #define XD_DBUS_VALIDATE_OBJECT(object, func) \ | ||
| 303 | do { \ | ||
| 304 | if (!NILP (object)) \ | ||
| 305 | { \ | ||
| 306 | DBusError derror; \ | ||
| 307 | CHECK_STRING (object); \ | ||
| 308 | dbus_error_init (&derror); \ | ||
| 309 | if (!func (SSDATA (object), &derror)) \ | ||
| 310 | XD_ERROR (derror); \ | ||
| 311 | /* Cleanup. */ \ | ||
| 312 | dbus_error_free (&derror); \ | ||
| 313 | } \ | ||
| 314 | } while (0) | ||
| 315 | #endif | ||
| 316 | |||
| 317 | #if HAVE_DBUS_VALIDATE_BUS_NAME | ||
| 318 | #define XD_DBUS_VALIDATE_BUS_NAME(bus_name) \ | ||
| 319 | XD_DBUS_VALIDATE_OBJECT(bus_name, dbus_validate_bus_name); | ||
| 320 | #else | ||
| 321 | #define XD_DBUS_VALIDATE_BUS_NAME(bus_name) \ | ||
| 322 | if (!NILP (bus_name)) CHECK_STRING (bus_name); | ||
| 323 | #endif | ||
| 324 | |||
| 325 | #if HAVE_DBUS_VALIDATE_PATH | ||
| 326 | #define XD_DBUS_VALIDATE_PATH(path) \ | ||
| 327 | XD_DBUS_VALIDATE_OBJECT(path, dbus_validate_path); | ||
| 328 | #else | ||
| 329 | #define XD_DBUS_VALIDATE_PATH(path) \ | ||
| 330 | if (!NILP (path)) CHECK_STRING (path); | ||
| 331 | #endif | ||
| 332 | |||
| 333 | #if HAVE_DBUS_VALIDATE_INTERFACE | ||
| 334 | #define XD_DBUS_VALIDATE_INTERFACE(interface) \ | ||
| 335 | XD_DBUS_VALIDATE_OBJECT(interface, dbus_validate_interface); | ||
| 336 | #else | ||
| 337 | #define XD_DBUS_VALIDATE_INTERFACE(interface) \ | ||
| 338 | if (!NILP (interface)) CHECK_STRING (interface); | ||
| 339 | #endif | ||
| 340 | |||
| 341 | #if HAVE_DBUS_VALIDATE_MEMBER | ||
| 342 | #define XD_DBUS_VALIDATE_MEMBER(member) \ | ||
| 343 | XD_DBUS_VALIDATE_OBJECT(member, dbus_validate_member); | ||
| 344 | #else | ||
| 345 | #define XD_DBUS_VALIDATE_MEMBER(member) \ | ||
| 346 | if (!NILP (member)) CHECK_STRING (member); | ||
| 347 | #endif | ||
| 261 | 348 | ||
| 262 | /* Append to SIGNATURE a copy of X, making sure SIGNATURE does | 349 | /* Append to SIGNATURE a copy of X, making sure SIGNATURE does |
| 263 | not become too long. */ | 350 | not become too long. */ |
| @@ -293,11 +380,6 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 293 | { | 380 | { |
| 294 | case DBUS_TYPE_BYTE: | 381 | case DBUS_TYPE_BYTE: |
| 295 | case DBUS_TYPE_UINT16: | 382 | case DBUS_TYPE_UINT16: |
| 296 | case DBUS_TYPE_UINT32: | ||
| 297 | case DBUS_TYPE_UINT64: | ||
| 298 | #ifdef DBUS_TYPE_UNIX_FD | ||
| 299 | case DBUS_TYPE_UNIX_FD: | ||
| 300 | #endif | ||
| 301 | CHECK_NATNUM (object); | 383 | CHECK_NATNUM (object); |
| 302 | sprintf (signature, "%c", dtype); | 384 | sprintf (signature, "%c", dtype); |
| 303 | break; | 385 | break; |
| @@ -309,14 +391,19 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 309 | break; | 391 | break; |
| 310 | 392 | ||
| 311 | case DBUS_TYPE_INT16: | 393 | case DBUS_TYPE_INT16: |
| 312 | case DBUS_TYPE_INT32: | ||
| 313 | case DBUS_TYPE_INT64: | ||
| 314 | CHECK_NUMBER (object); | 394 | CHECK_NUMBER (object); |
| 315 | sprintf (signature, "%c", dtype); | 395 | sprintf (signature, "%c", dtype); |
| 316 | break; | 396 | break; |
| 317 | 397 | ||
| 398 | case DBUS_TYPE_UINT32: | ||
| 399 | case DBUS_TYPE_UINT64: | ||
| 400 | #ifdef DBUS_TYPE_UNIX_FD | ||
| 401 | case DBUS_TYPE_UNIX_FD: | ||
| 402 | #endif | ||
| 403 | case DBUS_TYPE_INT32: | ||
| 404 | case DBUS_TYPE_INT64: | ||
| 318 | case DBUS_TYPE_DOUBLE: | 405 | case DBUS_TYPE_DOUBLE: |
| 319 | CHECK_FLOAT (object); | 406 | CHECK_NUMBER_OR_FLOAT (object); |
| 320 | sprintf (signature, "%c", dtype); | 407 | sprintf (signature, "%c", dtype); |
| 321 | break; | 408 | break; |
| 322 | 409 | ||
| @@ -352,8 +439,8 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 352 | } | 439 | } |
| 353 | 440 | ||
| 354 | /* If the element type is DBUS_TYPE_SIGNATURE, and this is the | 441 | /* If the element type is DBUS_TYPE_SIGNATURE, and this is the |
| 355 | only element, the value of this element is used as he array's | 442 | only element, the value of this element is used as the |
| 356 | element signature. */ | 443 | array's element signature. */ |
| 357 | if ((subtype == DBUS_TYPE_SIGNATURE) | 444 | if ((subtype == DBUS_TYPE_SIGNATURE) |
| 358 | && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt))) | 445 | && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt))) |
| 359 | && NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) | 446 | && NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) |
| @@ -451,6 +538,54 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 451 | XD_DEBUG_MESSAGE ("%s", signature); | 538 | XD_DEBUG_MESSAGE ("%s", signature); |
| 452 | } | 539 | } |
| 453 | 540 | ||
| 541 | /* Convert X to a signed integer with bounds LO and HI. */ | ||
| 542 | static intmax_t | ||
| 543 | extract_signed (Lisp_Object x, intmax_t lo, intmax_t hi) | ||
| 544 | { | ||
| 545 | CHECK_NUMBER_OR_FLOAT (x); | ||
| 546 | if (INTEGERP (x)) | ||
| 547 | { | ||
| 548 | if (lo <= XINT (x) && XINT (x) <= hi) | ||
| 549 | return XINT (x); | ||
| 550 | } | ||
| 551 | else | ||
| 552 | { | ||
| 553 | double d = XFLOAT_DATA (x); | ||
| 554 | if (lo <= d && d <= hi) | ||
| 555 | { | ||
| 556 | intmax_t n = d; | ||
| 557 | if (n == d) | ||
| 558 | return n; | ||
| 559 | } | ||
| 560 | } | ||
| 561 | args_out_of_range_3 (x, | ||
| 562 | make_fixnum_or_float (lo), | ||
| 563 | make_fixnum_or_float (hi)); | ||
| 564 | } | ||
| 565 | |||
| 566 | /* Convert X to an unsigned integer with bounds 0 and HI. */ | ||
| 567 | static uintmax_t | ||
| 568 | extract_unsigned (Lisp_Object x, uintmax_t hi) | ||
| 569 | { | ||
| 570 | CHECK_NUMBER_OR_FLOAT (x); | ||
| 571 | if (INTEGERP (x)) | ||
| 572 | { | ||
| 573 | if (0 <= XINT (x) && XINT (x) <= hi) | ||
| 574 | return XINT (x); | ||
| 575 | } | ||
| 576 | else | ||
| 577 | { | ||
| 578 | double d = XFLOAT_DATA (x); | ||
| 579 | if (0 <= d && d <= hi) | ||
| 580 | { | ||
| 581 | uintmax_t n = d; | ||
| 582 | if (n == d) | ||
| 583 | return n; | ||
| 584 | } | ||
| 585 | } | ||
| 586 | args_out_of_range_2 (x, make_fixnum_or_float (hi)); | ||
| 587 | } | ||
| 588 | |||
| 454 | /* Append C value, extracted from Lisp OBJECT, to iteration ITER. | 589 | /* Append C value, extracted from Lisp OBJECT, to iteration ITER. |
| 455 | DTYPE must be a valid DBusType. It is used to convert Lisp | 590 | DTYPE must be a valid DBusType. It is used to convert Lisp |
| 456 | objects, being arguments of `dbus-call-method' or | 591 | objects, being arguments of `dbus-call-method' or |
| @@ -469,7 +604,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 469 | CHECK_NATNUM (object); | 604 | CHECK_NATNUM (object); |
| 470 | { | 605 | { |
| 471 | unsigned char val = XFASTINT (object) & 0xFF; | 606 | unsigned char val = XFASTINT (object) & 0xFF; |
| 472 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 607 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); |
| 473 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 608 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 474 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 609 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 475 | return; | 610 | return; |
| @@ -488,7 +623,8 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 488 | CHECK_TYPE_RANGED_INTEGER (dbus_int16_t, object); | 623 | CHECK_TYPE_RANGED_INTEGER (dbus_int16_t, object); |
| 489 | { | 624 | { |
| 490 | dbus_int16_t val = XINT (object); | 625 | dbus_int16_t val = XINT (object); |
| 491 | XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val); | 626 | int pval = val; |
| 627 | XD_DEBUG_MESSAGE ("%c %d", dtype, pval); | ||
| 492 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 628 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 493 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 629 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 494 | return; | 630 | return; |
| @@ -498,17 +634,20 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 498 | CHECK_TYPE_RANGED_INTEGER (dbus_uint16_t, object); | 634 | CHECK_TYPE_RANGED_INTEGER (dbus_uint16_t, object); |
| 499 | { | 635 | { |
| 500 | dbus_uint16_t val = XFASTINT (object); | 636 | dbus_uint16_t val = XFASTINT (object); |
| 501 | XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); | 637 | unsigned int pval = val; |
| 638 | XD_DEBUG_MESSAGE ("%c %u", dtype, pval); | ||
| 502 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 639 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 503 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 640 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 504 | return; | 641 | return; |
| 505 | } | 642 | } |
| 506 | 643 | ||
| 507 | case DBUS_TYPE_INT32: | 644 | case DBUS_TYPE_INT32: |
| 508 | CHECK_TYPE_RANGED_INTEGER (dbus_int32_t, object); | ||
| 509 | { | 645 | { |
| 510 | dbus_int32_t val = XINT (object); | 646 | dbus_int32_t val = extract_signed (object, |
| 511 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 647 | TYPE_MINIMUM (dbus_int32_t), |
| 648 | TYPE_MAXIMUM (dbus_int32_t)); | ||
| 649 | int pval = val; | ||
| 650 | XD_DEBUG_MESSAGE ("%c %d", dtype, pval); | ||
| 512 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 651 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 513 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 652 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 514 | return; | 653 | return; |
| @@ -518,39 +657,43 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 518 | #ifdef DBUS_TYPE_UNIX_FD | 657 | #ifdef DBUS_TYPE_UNIX_FD |
| 519 | case DBUS_TYPE_UNIX_FD: | 658 | case DBUS_TYPE_UNIX_FD: |
| 520 | #endif | 659 | #endif |
| 521 | CHECK_TYPE_RANGED_INTEGER (dbus_uint32_t, object); | ||
| 522 | { | 660 | { |
| 523 | dbus_uint32_t val = XFASTINT (object); | 661 | dbus_uint32_t val = extract_unsigned (object, |
| 524 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); | 662 | TYPE_MAXIMUM (dbus_uint32_t)); |
| 663 | unsigned int pval = val; | ||
| 664 | XD_DEBUG_MESSAGE ("%c %u", dtype, pval); | ||
| 525 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 665 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 526 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 666 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 527 | return; | 667 | return; |
| 528 | } | 668 | } |
| 529 | 669 | ||
| 530 | case DBUS_TYPE_INT64: | 670 | case DBUS_TYPE_INT64: |
| 531 | CHECK_NUMBER (object); | 671 | CHECK_TYPE_RANGED_INTEGER_OR_FLOAT (dbus_int64_t, object); |
| 532 | { | 672 | { |
| 533 | dbus_int64_t val = XINT (object); | 673 | dbus_int64_t val = extract_signed (object, |
| 534 | XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val); | 674 | TYPE_MINIMUM (dbus_int64_t), |
| 675 | TYPE_MAXIMUM (dbus_int64_t)); | ||
| 676 | printmax_t pval = val; | ||
| 677 | XD_DEBUG_MESSAGE ("%c %"pMd, dtype, pval); | ||
| 535 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 678 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 536 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 679 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 537 | return; | 680 | return; |
| 538 | } | 681 | } |
| 539 | 682 | ||
| 540 | case DBUS_TYPE_UINT64: | 683 | case DBUS_TYPE_UINT64: |
| 541 | CHECK_TYPE_RANGED_INTEGER (dbus_uint64_t, object); | ||
| 542 | { | 684 | { |
| 543 | dbus_uint64_t val = XFASTINT (object); | 685 | dbus_uint64_t val = extract_unsigned (object, |
| 544 | XD_DEBUG_MESSAGE ("%c %"pI"d", dtype, XFASTINT (object)); | 686 | TYPE_MAXIMUM (dbus_uint64_t)); |
| 687 | uprintmax_t pval = val; | ||
| 688 | XD_DEBUG_MESSAGE ("%c %"pMu, dtype, pval); | ||
| 545 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 689 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 546 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 690 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 547 | return; | 691 | return; |
| 548 | } | 692 | } |
| 549 | 693 | ||
| 550 | case DBUS_TYPE_DOUBLE: | 694 | case DBUS_TYPE_DOUBLE: |
| 551 | CHECK_FLOAT (object); | ||
| 552 | { | 695 | { |
| 553 | double val = XFLOAT_DATA (object); | 696 | double val = extract_float (object); |
| 554 | XD_DEBUG_MESSAGE ("%c %f", dtype, val); | 697 | XD_DEBUG_MESSAGE ("%c %f", dtype, val); |
| 555 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 698 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 556 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 699 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -614,7 +757,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 614 | dtype, CAR_SAFE (XD_NEXT_VALUE (object))); | 757 | dtype, CAR_SAFE (XD_NEXT_VALUE (object))); |
| 615 | 758 | ||
| 616 | XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, | 759 | XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, |
| 617 | SDATA (format2 ("%s", object, Qnil))); | 760 | XD_OBJECT_TO_STRING (object)); |
| 618 | if (!dbus_message_iter_open_container (iter, dtype, | 761 | if (!dbus_message_iter_open_container (iter, dtype, |
| 619 | signature, &subiter)) | 762 | signature, &subiter)) |
| 620 | XD_SIGNAL3 (build_string ("Cannot open container"), | 763 | XD_SIGNAL3 (build_string ("Cannot open container"), |
| @@ -627,7 +770,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 627 | dtype, CAR_SAFE (XD_NEXT_VALUE (object))); | 770 | dtype, CAR_SAFE (XD_NEXT_VALUE (object))); |
| 628 | 771 | ||
| 629 | XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, | 772 | XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, |
| 630 | SDATA (format2 ("%s", object, Qnil))); | 773 | XD_OBJECT_TO_STRING (object)); |
| 631 | if (!dbus_message_iter_open_container (iter, dtype, | 774 | if (!dbus_message_iter_open_container (iter, dtype, |
| 632 | signature, &subiter)) | 775 | signature, &subiter)) |
| 633 | XD_SIGNAL3 (build_string ("Cannot open container"), | 776 | XD_SIGNAL3 (build_string ("Cannot open container"), |
| @@ -637,8 +780,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 637 | case DBUS_TYPE_STRUCT: | 780 | case DBUS_TYPE_STRUCT: |
| 638 | case DBUS_TYPE_DICT_ENTRY: | 781 | case DBUS_TYPE_DICT_ENTRY: |
| 639 | /* These containers do not require a signature. */ | 782 | /* These containers do not require a signature. */ |
| 640 | XD_DEBUG_MESSAGE ("%c %s", dtype, | 783 | XD_DEBUG_MESSAGE ("%c %s", dtype, XD_OBJECT_TO_STRING (object)); |
| 641 | SDATA (format2 ("%s", object, Qnil))); | ||
| 642 | if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter)) | 784 | if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter)) |
| 643 | XD_SIGNAL2 (build_string ("Cannot open container"), | 785 | XD_SIGNAL2 (build_string ("Cannot open container"), |
| 644 | make_number (dtype)); | 786 | make_number (dtype)); |
| @@ -678,7 +820,7 @@ xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter) | |||
| 678 | unsigned int val; | 820 | unsigned int val; |
| 679 | dbus_message_iter_get_basic (iter, &val); | 821 | dbus_message_iter_get_basic (iter, &val); |
| 680 | val = val & 0xFF; | 822 | val = val & 0xFF; |
| 681 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 823 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); |
| 682 | return make_number (val); | 824 | return make_number (val); |
| 683 | } | 825 | } |
| 684 | 826 | ||
| @@ -693,24 +835,30 @@ xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter) | |||
| 693 | case DBUS_TYPE_INT16: | 835 | case DBUS_TYPE_INT16: |
| 694 | { | 836 | { |
| 695 | dbus_int16_t val; | 837 | dbus_int16_t val; |
| 838 | int pval; | ||
| 696 | dbus_message_iter_get_basic (iter, &val); | 839 | dbus_message_iter_get_basic (iter, &val); |
| 697 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 840 | pval = val; |
| 841 | XD_DEBUG_MESSAGE ("%c %d", dtype, pval); | ||
| 698 | return make_number (val); | 842 | return make_number (val); |
| 699 | } | 843 | } |
| 700 | 844 | ||
| 701 | case DBUS_TYPE_UINT16: | 845 | case DBUS_TYPE_UINT16: |
| 702 | { | 846 | { |
| 703 | dbus_uint16_t val; | 847 | dbus_uint16_t val; |
| 848 | int pval; | ||
| 704 | dbus_message_iter_get_basic (iter, &val); | 849 | dbus_message_iter_get_basic (iter, &val); |
| 705 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 850 | pval = val; |
| 851 | XD_DEBUG_MESSAGE ("%c %d", dtype, pval); | ||
| 706 | return make_number (val); | 852 | return make_number (val); |
| 707 | } | 853 | } |
| 708 | 854 | ||
| 709 | case DBUS_TYPE_INT32: | 855 | case DBUS_TYPE_INT32: |
| 710 | { | 856 | { |
| 711 | dbus_int32_t val; | 857 | dbus_int32_t val; |
| 858 | int pval; | ||
| 712 | dbus_message_iter_get_basic (iter, &val); | 859 | dbus_message_iter_get_basic (iter, &val); |
| 713 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 860 | pval = val; |
| 861 | XD_DEBUG_MESSAGE ("%c %d", dtype, pval); | ||
| 714 | return make_fixnum_or_float (val); | 862 | return make_fixnum_or_float (val); |
| 715 | } | 863 | } |
| 716 | 864 | ||
| @@ -720,24 +868,30 @@ xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter) | |||
| 720 | #endif | 868 | #endif |
| 721 | { | 869 | { |
| 722 | dbus_uint32_t val; | 870 | dbus_uint32_t val; |
| 871 | unsigned int pval = val; | ||
| 723 | dbus_message_iter_get_basic (iter, &val); | 872 | dbus_message_iter_get_basic (iter, &val); |
| 724 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 873 | pval = val; |
| 874 | XD_DEBUG_MESSAGE ("%c %u", dtype, pval); | ||
| 725 | return make_fixnum_or_float (val); | 875 | return make_fixnum_or_float (val); |
| 726 | } | 876 | } |
| 727 | 877 | ||
| 728 | case DBUS_TYPE_INT64: | 878 | case DBUS_TYPE_INT64: |
| 729 | { | 879 | { |
| 730 | dbus_int64_t val; | 880 | dbus_int64_t val; |
| 881 | printmax_t pval; | ||
| 731 | dbus_message_iter_get_basic (iter, &val); | 882 | dbus_message_iter_get_basic (iter, &val); |
| 732 | XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val); | 883 | pval = val; |
| 884 | XD_DEBUG_MESSAGE ("%c %"pMd, dtype, pval); | ||
| 733 | return make_fixnum_or_float (val); | 885 | return make_fixnum_or_float (val); |
| 734 | } | 886 | } |
| 735 | 887 | ||
| 736 | case DBUS_TYPE_UINT64: | 888 | case DBUS_TYPE_UINT64: |
| 737 | { | 889 | { |
| 738 | dbus_uint64_t val; | 890 | dbus_uint64_t val; |
| 891 | uprintmax_t pval; | ||
| 739 | dbus_message_iter_get_basic (iter, &val); | 892 | dbus_message_iter_get_basic (iter, &val); |
| 740 | XD_DEBUG_MESSAGE ("%c %d", dtype, (int) val); | 893 | pval = val; |
| 894 | XD_DEBUG_MESSAGE ("%c %"pMd, dtype, pval); | ||
| 741 | return make_fixnum_or_float (val); | 895 | return make_fixnum_or_float (val); |
| 742 | } | 896 | } |
| 743 | 897 | ||
| @@ -777,7 +931,7 @@ xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter) | |||
| 777 | result = Fcons (xd_retrieve_arg (subtype, &subiter), result); | 931 | result = Fcons (xd_retrieve_arg (subtype, &subiter), result); |
| 778 | dbus_message_iter_next (&subiter); | 932 | dbus_message_iter_next (&subiter); |
| 779 | } | 933 | } |
| 780 | XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", result, Qnil))); | 934 | XD_DEBUG_MESSAGE ("%c %s", dtype, XD_OBJECT_TO_STRING (result)); |
| 781 | RETURN_UNGCPRO (Fnreverse (result)); | 935 | RETURN_UNGCPRO (Fnreverse (result)); |
| 782 | } | 936 | } |
| 783 | 937 | ||
| @@ -787,85 +941,37 @@ xd_retrieve_arg (unsigned int dtype, DBusMessageIter *iter) | |||
| 787 | } | 941 | } |
| 788 | } | 942 | } |
| 789 | 943 | ||
| 790 | /* Initialize D-Bus connection. BUS is either a Lisp symbol, :system | 944 | /* Return the number of references of the shared CONNECTION. */ |
| 791 | or :session, or a string denoting the bus address. It tells which | 945 | static int |
| 792 | D-Bus to initialize. If RAISE_ERROR is non-zero, signal an error | 946 | xd_get_connection_references (DBusConnection *connection) |
| 793 | when the connection cannot be initialized. */ | 947 | { |
| 948 | ptrdiff_t *refcount; | ||
| 949 | |||
| 950 | /* We cannot access the DBusConnection structure, it is not public. | ||
| 951 | But we know, that the reference counter is the first field in | ||
| 952 | that structure. */ | ||
| 953 | refcount = (void *) &connection; | ||
| 954 | refcount = (void *) *refcount; | ||
| 955 | return *refcount; | ||
| 956 | } | ||
| 957 | |||
| 958 | /* Return D-Bus connection address. BUS is either a Lisp symbol, | ||
| 959 | :system or :session, or a string denoting the bus address. */ | ||
| 794 | static DBusConnection * | 960 | static DBusConnection * |
| 795 | xd_initialize (Lisp_Object bus, int raise_error) | 961 | xd_get_connection_address (Lisp_Object bus) |
| 796 | { | 962 | { |
| 797 | DBusConnection *connection; | 963 | DBusConnection *connection; |
| 798 | DBusError derror; | 964 | Lisp_Object val; |
| 799 | |||
| 800 | /* Parameter check. */ | ||
| 801 | if (!STRINGP (bus)) | ||
| 802 | { | ||
| 803 | CHECK_SYMBOL (bus); | ||
| 804 | if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus))) | ||
| 805 | { | ||
| 806 | if (raise_error) | ||
| 807 | XD_SIGNAL2 (build_string ("Wrong bus name"), bus); | ||
| 808 | else | ||
| 809 | return NULL; | ||
| 810 | } | ||
| 811 | 965 | ||
| 812 | /* We do not want to have an autolaunch for the session bus. */ | 966 | val = CDR_SAFE (Fassoc (bus, xd_registered_buses)); |
| 813 | if (EQ (bus, QCdbus_session_bus) | 967 | if (NILP (val)) |
| 814 | && getenv ("DBUS_SESSION_BUS_ADDRESS") == NULL) | 968 | XD_SIGNAL2 (build_string ("No connection to bus"), bus); |
| 815 | { | ||
| 816 | if (raise_error) | ||
| 817 | XD_SIGNAL2 (build_string ("No connection to bus"), bus); | ||
| 818 | else | ||
| 819 | return NULL; | ||
| 820 | } | ||
| 821 | } | ||
| 822 | |||
| 823 | /* Open a connection to the bus. */ | ||
| 824 | dbus_error_init (&derror); | ||
| 825 | |||
| 826 | if (STRINGP (bus)) | ||
| 827 | connection = dbus_connection_open (SSDATA (bus), &derror); | ||
| 828 | else | 969 | else |
| 829 | if (EQ (bus, QCdbus_system_bus)) | 970 | connection = (DBusConnection *) (intptr_t) XFASTINT (val); |
| 830 | connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); | ||
| 831 | else | ||
| 832 | connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); | ||
| 833 | |||
| 834 | if (dbus_error_is_set (&derror)) | ||
| 835 | { | ||
| 836 | if (raise_error) | ||
| 837 | XD_ERROR (derror); | ||
| 838 | else | ||
| 839 | connection = NULL; | ||
| 840 | } | ||
| 841 | 971 | ||
| 842 | /* If it is not the system or session bus, we must register | 972 | if (!dbus_connection_get_is_connected (connection)) |
| 843 | ourselves. Otherwise, we have called dbus_bus_get, which has | ||
| 844 | configured us to exit if the connection closes - we undo this | ||
| 845 | setting. */ | ||
| 846 | if (connection != NULL) | ||
| 847 | { | ||
| 848 | if (STRINGP (bus)) | ||
| 849 | dbus_bus_register (connection, &derror); | ||
| 850 | else | ||
| 851 | dbus_connection_set_exit_on_disconnect (connection, FALSE); | ||
| 852 | } | ||
| 853 | |||
| 854 | if (dbus_error_is_set (&derror)) | ||
| 855 | { | ||
| 856 | if (raise_error) | ||
| 857 | XD_ERROR (derror); | ||
| 858 | else | ||
| 859 | connection = NULL; | ||
| 860 | } | ||
| 861 | |||
| 862 | if (connection == NULL && raise_error) | ||
| 863 | XD_SIGNAL2 (build_string ("No connection to bus"), bus); | 973 | XD_SIGNAL2 (build_string ("No connection to bus"), bus); |
| 864 | 974 | ||
| 865 | /* Cleanup. */ | ||
| 866 | dbus_error_free (&derror); | ||
| 867 | |||
| 868 | /* Return the result. */ | ||
| 869 | return connection; | 975 | return connection; |
| 870 | } | 976 | } |
| 871 | 977 | ||
| @@ -896,8 +1002,8 @@ xd_add_watch (DBusWatch *watch, void *data) | |||
| 896 | int fd = xd_find_watch_fd (watch); | 1002 | int fd = xd_find_watch_fd (watch); |
| 897 | 1003 | ||
| 898 | XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d", | 1004 | XD_DEBUG_MESSAGE ("fd %d, write %d, enabled %d", |
| 899 | fd, flags & DBUS_WATCH_WRITABLE, | 1005 | fd, flags & DBUS_WATCH_WRITABLE, |
| 900 | dbus_watch_get_enabled (watch)); | 1006 | dbus_watch_get_enabled (watch)); |
| 901 | 1007 | ||
| 902 | if (fd == -1) | 1008 | if (fd == -1) |
| 903 | return FALSE; | 1009 | return FALSE; |
| @@ -929,8 +1035,8 @@ xd_remove_watch (DBusWatch *watch, void *data) | |||
| 929 | /* Unset session environment. */ | 1035 | /* Unset session environment. */ |
| 930 | if (XSYMBOL (QCdbus_session_bus) == data) | 1036 | if (XSYMBOL (QCdbus_session_bus) == data) |
| 931 | { | 1037 | { |
| 932 | XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); | 1038 | // XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); |
| 933 | unsetenv ("DBUS_SESSION_BUS_ADDRESS"); | 1039 | // unsetenv ("DBUS_SESSION_BUS_ADDRESS"); |
| 934 | } | 1040 | } |
| 935 | 1041 | ||
| 936 | if (flags & DBUS_WATCH_WRITABLE) | 1042 | if (flags & DBUS_WATCH_WRITABLE) |
| @@ -949,23 +1055,111 @@ xd_toggle_watch (DBusWatch *watch, void *data) | |||
| 949 | xd_remove_watch (watch, data); | 1055 | xd_remove_watch (watch, data); |
| 950 | } | 1056 | } |
| 951 | 1057 | ||
| 952 | DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, | 1058 | /* Close connection to D-Bus BUS. */ |
| 953 | doc: /* Initialize connection to D-Bus BUS. */) | 1059 | static void |
| 954 | (Lisp_Object bus) | 1060 | xd_close_bus (Lisp_Object bus) |
| 1061 | { | ||
| 1062 | DBusConnection *connection; | ||
| 1063 | Lisp_Object val; | ||
| 1064 | |||
| 1065 | /* Check whether we are connected. */ | ||
| 1066 | val = Fassoc (bus, xd_registered_buses); | ||
| 1067 | if (NILP (val)) | ||
| 1068 | return; | ||
| 1069 | |||
| 1070 | /* Retrieve bus address. */ | ||
| 1071 | connection = xd_get_connection_address (bus); | ||
| 1072 | |||
| 1073 | /* Close connection, if there isn't another shared application. */ | ||
| 1074 | if (xd_get_connection_references (connection) == 1) | ||
| 1075 | { | ||
| 1076 | XD_DEBUG_MESSAGE ("Close connection to bus %s", | ||
| 1077 | XD_OBJECT_TO_STRING (bus)); | ||
| 1078 | dbus_connection_close (connection); | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | /* Decrement reference count. */ | ||
| 1082 | dbus_connection_unref (connection); | ||
| 1083 | |||
| 1084 | /* Remove bus from list of registered buses. */ | ||
| 1085 | xd_registered_buses = Fdelete (val, xd_registered_buses); | ||
| 1086 | |||
| 1087 | /* Return. */ | ||
| 1088 | return; | ||
| 1089 | } | ||
| 1090 | |||
| 1091 | DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 2, 0, | ||
| 1092 | doc: /* Establish the connection to D-Bus BUS. | ||
| 1093 | |||
| 1094 | BUS can be either the symbol `:system' or the symbol `:session', or it | ||
| 1095 | can be a string denoting the address of the corresponding bus. For | ||
| 1096 | the system and session buses, this function is called when loading | ||
| 1097 | `dbus.el', there is no need to call it again. | ||
| 1098 | |||
| 1099 | The function returns a number, which counts the connections this Emacs | ||
| 1100 | session has established to the BUS under the same unique name (see | ||
| 1101 | `dbus-get-unique-name'). It depends on the libraries Emacs is linked | ||
| 1102 | with, and on the environment Emacs is running. For example, if Emacs | ||
| 1103 | is linked with the gtk toolkit, and it runs in a GTK-aware environment | ||
| 1104 | like Gnome, another connection might already be established. | ||
| 1105 | |||
| 1106 | When PRIVATE is non-nil, a new connection is established instead of | ||
| 1107 | reusing an existing one. It results in a new unique name at the bus. | ||
| 1108 | This can be used, if it is necessary to distinguish from another | ||
| 1109 | connection used in the same Emacs process, like the one established by | ||
| 1110 | GTK+. It should be used with care for at least the `:system' and | ||
| 1111 | `:session' buses, because other Emacs Lisp packages might already use | ||
| 1112 | this connection to those buses. */) | ||
| 1113 | (Lisp_Object bus, Lisp_Object private) | ||
| 955 | { | 1114 | { |
| 956 | DBusConnection *connection; | 1115 | DBusConnection *connection; |
| 957 | void *busp; | 1116 | DBusError derror; |
| 1117 | Lisp_Object val; | ||
| 1118 | int refcount; | ||
| 958 | 1119 | ||
| 959 | /* Check parameter. */ | 1120 | /* Check parameter. */ |
| 960 | if (SYMBOLP (bus)) | 1121 | XD_DBUS_VALIDATE_BUS_ADDRESS (bus); |
| 961 | busp = XSYMBOL (bus); | 1122 | |
| 962 | else if (STRINGP (bus)) | 1123 | /* Close bus if it is already open. */ |
| 963 | busp = XSTRING (bus); | 1124 | xd_close_bus (bus); |
| 1125 | |||
| 1126 | /* Initialize. */ | ||
| 1127 | dbus_error_init (&derror); | ||
| 1128 | |||
| 1129 | /* Open the connection. */ | ||
| 1130 | if (STRINGP (bus)) | ||
| 1131 | if (NILP (private)) | ||
| 1132 | connection = dbus_connection_open (SSDATA (bus), &derror); | ||
| 1133 | else | ||
| 1134 | connection = dbus_connection_open_private (SSDATA (bus), &derror); | ||
| 1135 | |||
| 1136 | else | ||
| 1137 | if (NILP (private)) | ||
| 1138 | connection = dbus_bus_get (EQ (bus, QCdbus_system_bus) | ||
| 1139 | ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, | ||
| 1140 | &derror); | ||
| 1141 | else | ||
| 1142 | connection = dbus_bus_get_private (EQ (bus, QCdbus_system_bus) | ||
| 1143 | ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, | ||
| 1144 | &derror); | ||
| 1145 | |||
| 1146 | if (dbus_error_is_set (&derror)) | ||
| 1147 | XD_ERROR (derror); | ||
| 1148 | |||
| 1149 | if (connection == NULL) | ||
| 1150 | XD_SIGNAL2 (build_string ("No connection to bus"), bus); | ||
| 1151 | |||
| 1152 | /* If it is not the system or session bus, we must register | ||
| 1153 | ourselves. Otherwise, we have called dbus_bus_get, which has | ||
| 1154 | configured us to exit if the connection closes - we undo this | ||
| 1155 | setting. */ | ||
| 1156 | if (STRINGP (bus)) | ||
| 1157 | dbus_bus_register (connection, &derror); | ||
| 964 | else | 1158 | else |
| 965 | wrong_type_argument (intern ("D-Bus"), bus); | 1159 | dbus_connection_set_exit_on_disconnect (connection, FALSE); |
| 966 | 1160 | ||
| 967 | /* Open a connection to the bus. */ | 1161 | if (dbus_error_is_set (&derror)) |
| 968 | connection = xd_initialize (bus, TRUE); | 1162 | XD_ERROR (derror); |
| 969 | 1163 | ||
| 970 | /* Add the watch functions. We pass also the bus as data, in order | 1164 | /* Add the watch functions. We pass also the bus as data, in order |
| 971 | to distinguish between the buses in xd_remove_watch. */ | 1165 | to distinguish between the buses in xd_remove_watch. */ |
| @@ -973,36 +1167,27 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, | |||
| 973 | xd_add_watch, | 1167 | xd_add_watch, |
| 974 | xd_remove_watch, | 1168 | xd_remove_watch, |
| 975 | xd_toggle_watch, | 1169 | xd_toggle_watch, |
| 976 | busp, NULL)) | 1170 | SYMBOLP (bus) |
| 1171 | ? (void *) XSYMBOL (bus) | ||
| 1172 | : (void *) XSTRING (bus), | ||
| 1173 | NULL)) | ||
| 977 | XD_SIGNAL1 (build_string ("Cannot add watch functions")); | 1174 | XD_SIGNAL1 (build_string ("Cannot add watch functions")); |
| 978 | 1175 | ||
| 979 | /* Add bus to list of registered buses. */ | 1176 | /* Add bus to list of registered buses. */ |
| 980 | Vdbus_registered_buses = Fcons (bus, Vdbus_registered_buses); | 1177 | XSETFASTINT (val, (intptr_t) connection); |
| 1178 | xd_registered_buses = Fcons (Fcons (bus, val), xd_registered_buses); | ||
| 981 | 1179 | ||
| 982 | /* We do not want to abort. */ | 1180 | /* We do not want to abort. */ |
| 983 | putenv ((char *) "DBUS_FATAL_WARNINGS=0"); | 1181 | putenv ((char *) "DBUS_FATAL_WARNINGS=0"); |
| 984 | 1182 | ||
| 985 | /* Return. */ | 1183 | /* Cleanup. */ |
| 986 | return Qnil; | 1184 | dbus_error_free (&derror); |
| 987 | } | ||
| 988 | |||
| 989 | DEFUN ("dbus-close-bus", Fdbus_close_bus, Sdbus_close_bus, 1, 1, 0, | ||
| 990 | doc: /* Close connection to D-Bus BUS. */) | ||
| 991 | (Lisp_Object bus) | ||
| 992 | { | ||
| 993 | DBusConnection *connection; | ||
| 994 | |||
| 995 | /* Open a connection to the bus. */ | ||
| 996 | connection = xd_initialize (bus, TRUE); | ||
| 997 | |||
| 998 | /* Decrement reference count to the bus. */ | ||
| 999 | dbus_connection_unref (connection); | ||
| 1000 | |||
| 1001 | /* Remove bus from list of registered buses. */ | ||
| 1002 | Vdbus_registered_buses = Fdelete (bus, Vdbus_registered_buses); | ||
| 1003 | 1185 | ||
| 1004 | /* Return. */ | 1186 | /* Return reference counter. */ |
| 1005 | return Qnil; | 1187 | refcount = xd_get_connection_references (connection); |
| 1188 | XD_DEBUG_MESSAGE ("Bus %s, Reference counter %d", | ||
| 1189 | XD_OBJECT_TO_STRING (bus), refcount); | ||
| 1190 | return make_number (refcount); | ||
| 1006 | } | 1191 | } |
| 1007 | 1192 | ||
| 1008 | DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, | 1193 | DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, |
| @@ -1013,8 +1198,11 @@ DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, | |||
| 1013 | DBusConnection *connection; | 1198 | DBusConnection *connection; |
| 1014 | const char *name; | 1199 | const char *name; |
| 1015 | 1200 | ||
| 1016 | /* Open a connection to the bus. */ | 1201 | /* Check parameter. */ |
| 1017 | connection = xd_initialize (bus, TRUE); | 1202 | XD_DBUS_VALIDATE_BUS_ADDRESS (bus); |
| 1203 | |||
| 1204 | /* Retrieve bus address. */ | ||
| 1205 | connection = xd_get_connection_address (bus); | ||
| 1018 | 1206 | ||
| 1019 | /* Request the name. */ | 1207 | /* Request the name. */ |
| 1020 | name = dbus_bus_get_unique_name (connection); | 1208 | name = dbus_bus_get_unique_name (connection); |
| @@ -1025,341 +1213,243 @@ DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, | |||
| 1025 | return build_string (name); | 1213 | return build_string (name); |
| 1026 | } | 1214 | } |
| 1027 | 1215 | ||
| 1028 | DEFUN ("dbus-call-method", Fdbus_call_method, Sdbus_call_method, 5, MANY, 0, | 1216 | DEFUN ("dbus-message-internal", Fdbus_message_internal, Sdbus_message_internal, |
| 1029 | doc: /* Call METHOD on the D-Bus BUS. | 1217 | 4, MANY, 0, |
| 1030 | 1218 | doc: /* Send a D-Bus message. | |
| 1031 | BUS is either a Lisp symbol, `:system' or `:session', or a string | 1219 | This is an internal function, it shall not be used outside dbus.el. |
| 1032 | denoting the bus address. | 1220 | |
| 1033 | 1221 | The following usages are expected: | |
| 1034 | SERVICE is the D-Bus service name to be used. PATH is the D-Bus | 1222 | |
| 1035 | object path SERVICE is registered at. INTERFACE is an interface | 1223 | `dbus-call-method', `dbus-call-method-asynchronously': |
| 1036 | offered by SERVICE. It must provide METHOD. | 1224 | \(dbus-message-internal |
| 1037 | 1225 | dbus-message-type-method-call BUS SERVICE PATH INTERFACE METHOD HANDLER | |
| 1038 | If the parameter `:timeout' is given, the following integer TIMEOUT | 1226 | &optional :timeout TIMEOUT &rest ARGS) |
| 1039 | specifies the maximum number of milliseconds the method call must | 1227 | |
| 1040 | return. The default value is 25,000. If the method call doesn't | 1228 | `dbus-send-signal': |
| 1041 | return in time, a D-Bus error is raised. | 1229 | \(dbus-message-internal |
| 1042 | 1230 | dbus-message-type-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) | |
| 1043 | All other arguments ARGS are passed to METHOD as arguments. They are | 1231 | |
| 1044 | converted into D-Bus types via the following rules: | 1232 | `dbus-method-return-internal': |
| 1045 | 1233 | \(dbus-message-internal | |
| 1046 | t and nil => DBUS_TYPE_BOOLEAN | 1234 | dbus-message-type-method-return BUS SERVICE SERIAL &rest ARGS) |
| 1047 | number => DBUS_TYPE_UINT32 | 1235 | |
| 1048 | integer => DBUS_TYPE_INT32 | 1236 | `dbus-method-error-internal': |
| 1049 | float => DBUS_TYPE_DOUBLE | 1237 | \(dbus-message-internal |
| 1050 | string => DBUS_TYPE_STRING | 1238 | dbus-message-type-error BUS SERVICE SERIAL &rest ARGS) |
| 1051 | list => DBUS_TYPE_ARRAY | 1239 | |
| 1052 | 1240 | usage: (dbus-message-internal &rest REST) */) | |
| 1053 | All arguments can be preceded by a type symbol. For details about | ||
| 1054 | type symbols, see Info node `(dbus)Type Conversion'. | ||
| 1055 | |||
| 1056 | `dbus-call-method' returns the resulting values of METHOD as a list of | ||
| 1057 | Lisp objects. The type conversion happens the other direction as for | ||
| 1058 | input arguments. It follows the mapping rules: | ||
| 1059 | |||
| 1060 | DBUS_TYPE_BOOLEAN => t or nil | ||
| 1061 | DBUS_TYPE_BYTE => number | ||
| 1062 | DBUS_TYPE_UINT16 => number | ||
| 1063 | DBUS_TYPE_INT16 => integer | ||
| 1064 | DBUS_TYPE_UINT32 => number or float | ||
| 1065 | DBUS_TYPE_UNIX_FD => number or float | ||
| 1066 | DBUS_TYPE_INT32 => integer or float | ||
| 1067 | DBUS_TYPE_UINT64 => number or float | ||
| 1068 | DBUS_TYPE_INT64 => integer or float | ||
| 1069 | DBUS_TYPE_DOUBLE => float | ||
| 1070 | DBUS_TYPE_STRING => string | ||
| 1071 | DBUS_TYPE_OBJECT_PATH => string | ||
| 1072 | DBUS_TYPE_SIGNATURE => string | ||
| 1073 | DBUS_TYPE_ARRAY => list | ||
| 1074 | DBUS_TYPE_VARIANT => list | ||
| 1075 | DBUS_TYPE_STRUCT => list | ||
| 1076 | DBUS_TYPE_DICT_ENTRY => list | ||
| 1077 | |||
| 1078 | Example: | ||
| 1079 | |||
| 1080 | \(dbus-call-method | ||
| 1081 | :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp" | ||
| 1082 | "org.gnome.seahorse.Keys" "GetKeyField" | ||
| 1083 | "openpgp:657984B8C7A966DD" "simple-name") | ||
| 1084 | |||
| 1085 | => (t ("Philip R. Zimmermann")) | ||
| 1086 | |||
| 1087 | If the result of the METHOD call is just one value, the converted Lisp | ||
| 1088 | object is returned instead of a list containing this single Lisp object. | ||
| 1089 | |||
| 1090 | \(dbus-call-method | ||
| 1091 | :system "org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer" | ||
| 1092 | "org.freedesktop.Hal.Device" "GetPropertyString" | ||
| 1093 | "system.kernel.machine") | ||
| 1094 | |||
| 1095 | => "i686" | ||
| 1096 | |||
| 1097 | usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS) */) | ||
| 1098 | (ptrdiff_t nargs, Lisp_Object *args) | 1241 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1099 | { | 1242 | { |
| 1100 | Lisp_Object bus, service, path, interface, method; | 1243 | Lisp_Object message_type, bus, service, handler; |
| 1244 | Lisp_Object path = Qnil; | ||
| 1245 | Lisp_Object interface = Qnil; | ||
| 1246 | Lisp_Object member = Qnil; | ||
| 1101 | Lisp_Object result; | 1247 | Lisp_Object result; |
| 1102 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 1248 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 1103 | DBusConnection *connection; | 1249 | DBusConnection *connection; |
| 1104 | DBusMessage *dmessage; | 1250 | DBusMessage *dmessage; |
| 1105 | DBusMessage *reply; | ||
| 1106 | DBusMessageIter iter; | 1251 | DBusMessageIter iter; |
| 1107 | DBusError derror; | ||
| 1108 | unsigned int dtype; | 1252 | unsigned int dtype; |
| 1253 | unsigned int mtype; | ||
| 1254 | dbus_uint32_t serial = 0; | ||
| 1255 | unsigned int ui_serial; | ||
| 1109 | int timeout = -1; | 1256 | int timeout = -1; |
| 1110 | ptrdiff_t i = 5; | 1257 | ptrdiff_t count; |
| 1111 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 1258 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 1112 | 1259 | ||
| 1260 | /* Initialize parameters. */ | ||
| 1261 | message_type = args[0]; | ||
| 1262 | bus = args[1]; | ||
| 1263 | service = args[2]; | ||
| 1264 | handler = Qnil; | ||
| 1265 | |||
| 1266 | CHECK_NATNUM (message_type); | ||
| 1267 | mtype = XFASTINT (message_type); | ||
| 1268 | if ((mtype <= DBUS_MESSAGE_TYPE_INVALID) || (mtype >= DBUS_NUM_MESSAGE_TYPES)) | ||
| 1269 | XD_SIGNAL2 (build_string ("Invalid message type"), message_type); | ||
| 1270 | |||
| 1271 | if ((mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) | ||
| 1272 | || (mtype == DBUS_MESSAGE_TYPE_SIGNAL)) | ||
| 1273 | { | ||
| 1274 | path = args[3]; | ||
| 1275 | interface = args[4]; | ||
| 1276 | member = args[5]; | ||
| 1277 | if (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) | ||
| 1278 | handler = args[6]; | ||
| 1279 | count = (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) ? 7 : 6; | ||
| 1280 | } | ||
| 1281 | else /* DBUS_MESSAGE_TYPE_METHOD_RETURN, DBUS_MESSAGE_TYPE_ERROR */ | ||
| 1282 | { | ||
| 1283 | XD_CHECK_DBUS_SERIAL (args[3], serial); | ||
| 1284 | count = 4; | ||
| 1285 | } | ||
| 1286 | |||
| 1113 | /* Check parameters. */ | 1287 | /* Check parameters. */ |
| 1114 | bus = args[0]; | 1288 | XD_DBUS_VALIDATE_BUS_ADDRESS (bus); |
| 1115 | service = args[1]; | 1289 | XD_DBUS_VALIDATE_BUS_NAME (service); |
| 1116 | path = args[2]; | 1290 | if (nargs < count) |
| 1117 | interface = args[3]; | 1291 | xsignal2 (Qwrong_number_of_arguments, |
| 1118 | method = args[4]; | 1292 | Qdbus_message_internal, |
| 1119 | 1293 | make_number (nargs)); | |
| 1120 | CHECK_STRING (service); | 1294 | |
| 1121 | CHECK_STRING (path); | 1295 | if ((mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) |
| 1122 | CHECK_STRING (interface); | 1296 | || (mtype == DBUS_MESSAGE_TYPE_SIGNAL)) |
| 1123 | CHECK_STRING (method); | 1297 | { |
| 1124 | GCPRO5 (bus, service, path, interface, method); | 1298 | XD_DBUS_VALIDATE_PATH (path); |
| 1125 | 1299 | XD_DBUS_VALIDATE_INTERFACE (interface); | |
| 1126 | XD_DEBUG_MESSAGE ("%s %s %s %s", | 1300 | XD_DBUS_VALIDATE_MEMBER (member); |
| 1127 | SDATA (service), | 1301 | if (!NILP (handler) && (!FUNCTIONP (handler))) |
| 1128 | SDATA (path), | 1302 | wrong_type_argument (Qinvalid_function, handler); |
| 1129 | SDATA (interface), | 1303 | } |
| 1130 | SDATA (method)); | ||
| 1131 | |||
| 1132 | /* Open a connection to the bus. */ | ||
| 1133 | connection = xd_initialize (bus, TRUE); | ||
| 1134 | |||
| 1135 | /* Create the message. */ | ||
| 1136 | dmessage = dbus_message_new_method_call (SSDATA (service), | ||
| 1137 | SSDATA (path), | ||
| 1138 | SSDATA (interface), | ||
| 1139 | SSDATA (method)); | ||
| 1140 | UNGCPRO; | ||
| 1141 | if (dmessage == NULL) | ||
| 1142 | XD_SIGNAL1 (build_string ("Unable to create a new message")); | ||
| 1143 | 1304 | ||
| 1144 | /* Check for timeout parameter. */ | 1305 | /* Protect Lisp variables. */ |
| 1145 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | 1306 | GCPRO6 (bus, service, path, interface, member, handler); |
| 1307 | |||
| 1308 | /* Trace parameters. */ | ||
| 1309 | switch (mtype) | ||
| 1146 | { | 1310 | { |
| 1147 | CHECK_NATNUM (args[i+1]); | 1311 | case DBUS_MESSAGE_TYPE_METHOD_CALL: |
| 1148 | timeout = min (XFASTINT (args[i+1]), INT_MAX); | 1312 | XD_DEBUG_MESSAGE ("%s %s %s %s %s %s %s", |
| 1149 | i = i+2; | 1313 | XD_MESSAGE_TYPE_TO_STRING (mtype), |
| 1314 | XD_OBJECT_TO_STRING (bus), | ||
| 1315 | XD_OBJECT_TO_STRING (service), | ||
| 1316 | XD_OBJECT_TO_STRING (path), | ||
| 1317 | XD_OBJECT_TO_STRING (interface), | ||
| 1318 | XD_OBJECT_TO_STRING (member), | ||
| 1319 | XD_OBJECT_TO_STRING (handler)); | ||
| 1320 | break; | ||
| 1321 | case DBUS_MESSAGE_TYPE_SIGNAL: | ||
| 1322 | XD_DEBUG_MESSAGE ("%s %s %s %s %s %s", | ||
| 1323 | XD_MESSAGE_TYPE_TO_STRING (mtype), | ||
| 1324 | XD_OBJECT_TO_STRING (bus), | ||
| 1325 | XD_OBJECT_TO_STRING (service), | ||
| 1326 | XD_OBJECT_TO_STRING (path), | ||
| 1327 | XD_OBJECT_TO_STRING (interface), | ||
| 1328 | XD_OBJECT_TO_STRING (member)); | ||
| 1329 | break; | ||
| 1330 | default: /* DBUS_MESSAGE_TYPE_METHOD_RETURN, DBUS_MESSAGE_TYPE_ERROR */ | ||
| 1331 | ui_serial = serial; | ||
| 1332 | XD_DEBUG_MESSAGE ("%s %s %s %u", | ||
| 1333 | XD_MESSAGE_TYPE_TO_STRING (mtype), | ||
| 1334 | XD_OBJECT_TO_STRING (bus), | ||
| 1335 | XD_OBJECT_TO_STRING (service), | ||
| 1336 | ui_serial); | ||
| 1150 | } | 1337 | } |
| 1151 | 1338 | ||
| 1152 | /* Initialize parameter list of message. */ | 1339 | /* Retrieve bus address. */ |
| 1153 | dbus_message_iter_init_append (dmessage, &iter); | 1340 | connection = xd_get_connection_address (bus); |
| 1154 | 1341 | ||
| 1155 | /* Append parameters to the message. */ | 1342 | /* Create the D-Bus message. */ |
| 1156 | for (; i < nargs; ++i) | 1343 | dmessage = dbus_message_new (mtype); |
| 1344 | if (dmessage == NULL) | ||
| 1157 | { | 1345 | { |
| 1158 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | 1346 | UNGCPRO; |
| 1159 | if (XD_DBUS_TYPE_P (args[i])) | 1347 | XD_SIGNAL1 (build_string ("Unable to create a new message")); |
| 1348 | } | ||
| 1349 | |||
| 1350 | if (STRINGP (service)) | ||
| 1351 | { | ||
| 1352 | if (mtype != DBUS_MESSAGE_TYPE_SIGNAL) | ||
| 1353 | /* Set destination. */ | ||
| 1160 | { | 1354 | { |
| 1161 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1355 | if (!dbus_message_set_destination (dmessage, SSDATA (service))) |
| 1162 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1356 | { |
| 1163 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, | 1357 | UNGCPRO; |
| 1164 | SDATA (format2 ("%s", args[i], Qnil)), | 1358 | XD_SIGNAL2 (build_string ("Unable to set the destination"), |
| 1165 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1359 | service); |
| 1166 | ++i; | 1360 | } |
| 1167 | } | 1361 | } |
| 1362 | |||
| 1168 | else | 1363 | else |
| 1364 | /* Set destination for unicast signals. */ | ||
| 1169 | { | 1365 | { |
| 1170 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1366 | Lisp_Object uname; |
| 1171 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, | ||
| 1172 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 1173 | } | ||
| 1174 | 1367 | ||
| 1175 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | 1368 | /* If it is the same unique name as we are registered at the |
| 1176 | indication that there is no parent type. */ | 1369 | bus or an unknown name, we regard it as broadcast message |
| 1177 | xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); | 1370 | due to backward compatibility. */ |
| 1371 | if (dbus_bus_name_has_owner (connection, SSDATA (service), NULL)) | ||
| 1372 | uname = call2 (intern ("dbus-get-name-owner"), bus, service); | ||
| 1373 | else | ||
| 1374 | uname = Qnil; | ||
| 1178 | 1375 | ||
| 1179 | xd_append_arg (dtype, args[i], &iter); | 1376 | if (STRINGP (uname) |
| 1377 | && (strcmp (dbus_bus_get_unique_name (connection), SSDATA (uname)) | ||
| 1378 | != 0) | ||
| 1379 | && (!dbus_message_set_destination (dmessage, SSDATA (service)))) | ||
| 1380 | { | ||
| 1381 | UNGCPRO; | ||
| 1382 | XD_SIGNAL2 (build_string ("Unable to set signal destination"), | ||
| 1383 | service); | ||
| 1384 | } | ||
| 1385 | } | ||
| 1180 | } | 1386 | } |
| 1181 | 1387 | ||
| 1182 | /* Send the message. */ | 1388 | /* Set message parameters. */ |
| 1183 | dbus_error_init (&derror); | 1389 | if ((mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) |
| 1184 | reply = dbus_connection_send_with_reply_and_block (connection, | 1390 | || (mtype == DBUS_MESSAGE_TYPE_SIGNAL)) |
| 1185 | dmessage, | ||
| 1186 | timeout, | ||
| 1187 | &derror); | ||
| 1188 | |||
| 1189 | if (dbus_error_is_set (&derror)) | ||
| 1190 | XD_ERROR (derror); | ||
| 1191 | |||
| 1192 | if (reply == NULL) | ||
| 1193 | XD_SIGNAL1 (build_string ("No reply")); | ||
| 1194 | |||
| 1195 | XD_DEBUG_MESSAGE ("Message sent"); | ||
| 1196 | |||
| 1197 | /* Collect the results. */ | ||
| 1198 | result = Qnil; | ||
| 1199 | GCPRO1 (result); | ||
| 1200 | |||
| 1201 | if (dbus_message_iter_init (reply, &iter)) | ||
| 1202 | { | 1391 | { |
| 1203 | /* Loop over the parameters of the D-Bus reply message. Construct a | 1392 | if ((!dbus_message_set_path (dmessage, SSDATA (path))) |
| 1204 | Lisp list, which is returned by `dbus-call-method'. */ | 1393 | || (!dbus_message_set_interface (dmessage, SSDATA (interface))) |
| 1205 | while ((dtype = dbus_message_iter_get_arg_type (&iter)) | 1394 | || (!dbus_message_set_member (dmessage, SSDATA (member)))) |
| 1206 | != DBUS_TYPE_INVALID) | ||
| 1207 | { | 1395 | { |
| 1208 | result = Fcons (xd_retrieve_arg (dtype, &iter), result); | 1396 | UNGCPRO; |
| 1209 | dbus_message_iter_next (&iter); | 1397 | XD_SIGNAL1 (build_string ("Unable to set the message parameter")); |
| 1210 | } | 1398 | } |
| 1211 | } | 1399 | } |
| 1212 | else | ||
| 1213 | { | ||
| 1214 | /* No arguments: just return nil. */ | ||
| 1215 | } | ||
| 1216 | |||
| 1217 | /* Cleanup. */ | ||
| 1218 | dbus_error_free (&derror); | ||
| 1219 | dbus_message_unref (dmessage); | ||
| 1220 | dbus_message_unref (reply); | ||
| 1221 | |||
| 1222 | /* Return the result. If there is only one single Lisp object, | ||
| 1223 | return it as-it-is, otherwise return the reversed list. */ | ||
| 1224 | if (XFASTINT (Flength (result)) == 1) | ||
| 1225 | RETURN_UNGCPRO (CAR_SAFE (result)); | ||
| 1226 | else | ||
| 1227 | RETURN_UNGCPRO (Fnreverse (result)); | ||
| 1228 | } | ||
| 1229 | |||
| 1230 | DEFUN ("dbus-call-method-asynchronously", Fdbus_call_method_asynchronously, | ||
| 1231 | Sdbus_call_method_asynchronously, 6, MANY, 0, | ||
| 1232 | doc: /* Call METHOD on the D-Bus BUS asynchronously. | ||
| 1233 | |||
| 1234 | BUS is either a Lisp symbol, `:system' or `:session', or a string | ||
| 1235 | denoting the bus address. | ||
| 1236 | |||
| 1237 | SERVICE is the D-Bus service name to be used. PATH is the D-Bus | ||
| 1238 | object path SERVICE is registered at. INTERFACE is an interface | ||
| 1239 | offered by SERVICE. It must provide METHOD. | ||
| 1240 | |||
| 1241 | HANDLER is a Lisp function, which is called when the corresponding | ||
| 1242 | return message has arrived. If HANDLER is nil, no return message will | ||
| 1243 | be expected. | ||
| 1244 | |||
| 1245 | If the parameter `:timeout' is given, the following integer TIMEOUT | ||
| 1246 | specifies the maximum number of milliseconds the method call must | ||
| 1247 | return. The default value is 25,000. If the method call doesn't | ||
| 1248 | return in time, a D-Bus error is raised. | ||
| 1249 | |||
| 1250 | All other arguments ARGS are passed to METHOD as arguments. They are | ||
| 1251 | converted into D-Bus types via the following rules: | ||
| 1252 | |||
| 1253 | t and nil => DBUS_TYPE_BOOLEAN | ||
| 1254 | number => DBUS_TYPE_UINT32 | ||
| 1255 | integer => DBUS_TYPE_INT32 | ||
| 1256 | float => DBUS_TYPE_DOUBLE | ||
| 1257 | string => DBUS_TYPE_STRING | ||
| 1258 | list => DBUS_TYPE_ARRAY | ||
| 1259 | |||
| 1260 | All arguments can be preceded by a type symbol. For details about | ||
| 1261 | type symbols, see Info node `(dbus)Type Conversion'. | ||
| 1262 | 1400 | ||
| 1263 | Unless HANDLER is nil, the function returns a key into the hash table | 1401 | else /* DBUS_MESSAGE_TYPE_METHOD_RETURN, DBUS_MESSAGE_TYPE_ERROR */ |
| 1264 | `dbus-registered-objects-table'. The corresponding entry in the hash | 1402 | { |
| 1265 | table is removed, when the return message has been arrived, and | 1403 | if (!dbus_message_set_reply_serial (dmessage, serial)) |
| 1266 | HANDLER is called. | 1404 | { |
| 1267 | 1405 | UNGCPRO; | |
| 1268 | Example: | 1406 | XD_SIGNAL1 (build_string ("Unable to create a return message")); |
| 1269 | 1407 | } | |
| 1270 | \(dbus-call-method-asynchronously | ||
| 1271 | :system "org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer" | ||
| 1272 | "org.freedesktop.Hal.Device" "GetPropertyString" 'message | ||
| 1273 | "system.kernel.machine") | ||
| 1274 | |||
| 1275 | => (:system 2) | ||
| 1276 | |||
| 1277 | -| i686 | ||
| 1278 | |||
| 1279 | usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS) */) | ||
| 1280 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 1281 | { | ||
| 1282 | Lisp_Object bus, service, path, interface, method, handler; | ||
| 1283 | Lisp_Object result; | ||
| 1284 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | ||
| 1285 | DBusConnection *connection; | ||
| 1286 | DBusMessage *dmessage; | ||
| 1287 | DBusMessageIter iter; | ||
| 1288 | unsigned int dtype; | ||
| 1289 | dbus_uint32_t serial; | ||
| 1290 | int timeout = -1; | ||
| 1291 | ptrdiff_t i = 6; | ||
| 1292 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | ||
| 1293 | 1408 | ||
| 1294 | /* Check parameters. */ | 1409 | if ((mtype == DBUS_MESSAGE_TYPE_ERROR) |
| 1295 | bus = args[0]; | 1410 | && (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED))) |
| 1296 | service = args[1]; | 1411 | { |
| 1297 | path = args[2]; | 1412 | UNGCPRO; |
| 1298 | interface = args[3]; | 1413 | XD_SIGNAL1 (build_string ("Unable to create a error message")); |
| 1299 | method = args[4]; | 1414 | } |
| 1300 | handler = args[5]; | 1415 | } |
| 1301 | |||
| 1302 | CHECK_STRING (service); | ||
| 1303 | CHECK_STRING (path); | ||
| 1304 | CHECK_STRING (interface); | ||
| 1305 | CHECK_STRING (method); | ||
| 1306 | if (!NILP (handler) && !FUNCTIONP (handler)) | ||
| 1307 | wrong_type_argument (Qinvalid_function, handler); | ||
| 1308 | GCPRO6 (bus, service, path, interface, method, handler); | ||
| 1309 | |||
| 1310 | XD_DEBUG_MESSAGE ("%s %s %s %s", | ||
| 1311 | SDATA (service), | ||
| 1312 | SDATA (path), | ||
| 1313 | SDATA (interface), | ||
| 1314 | SDATA (method)); | ||
| 1315 | |||
| 1316 | /* Open a connection to the bus. */ | ||
| 1317 | connection = xd_initialize (bus, TRUE); | ||
| 1318 | |||
| 1319 | /* Create the message. */ | ||
| 1320 | dmessage = dbus_message_new_method_call (SSDATA (service), | ||
| 1321 | SSDATA (path), | ||
| 1322 | SSDATA (interface), | ||
| 1323 | SSDATA (method)); | ||
| 1324 | if (dmessage == NULL) | ||
| 1325 | XD_SIGNAL1 (build_string ("Unable to create a new message")); | ||
| 1326 | 1416 | ||
| 1327 | /* Check for timeout parameter. */ | 1417 | /* Check for timeout parameter. */ |
| 1328 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | 1418 | if ((count+2 <= nargs) && (EQ ((args[count]), QCdbus_timeout))) |
| 1329 | { | 1419 | { |
| 1330 | CHECK_NATNUM (args[i+1]); | 1420 | CHECK_NATNUM (args[count+1]); |
| 1331 | timeout = min (XFASTINT (args[i+1]), INT_MAX); | 1421 | timeout = min (XFASTINT (args[count+1]), INT_MAX); |
| 1332 | i = i+2; | 1422 | count = count+2; |
| 1333 | } | 1423 | } |
| 1334 | 1424 | ||
| 1335 | /* Initialize parameter list of message. */ | 1425 | /* Initialize parameter list of message. */ |
| 1336 | dbus_message_iter_init_append (dmessage, &iter); | 1426 | dbus_message_iter_init_append (dmessage, &iter); |
| 1337 | 1427 | ||
| 1338 | /* Append parameters to the message. */ | 1428 | /* Append parameters to the message. */ |
| 1339 | for (; i < nargs; ++i) | 1429 | for (; count < nargs; ++count) |
| 1340 | { | 1430 | { |
| 1341 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | 1431 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[count]); |
| 1342 | if (XD_DBUS_TYPE_P (args[i])) | 1432 | if (XD_DBUS_TYPE_P (args[count])) |
| 1343 | { | 1433 | { |
| 1344 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1434 | XD_DEBUG_VALID_LISP_OBJECT_P (args[count]); |
| 1345 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1435 | XD_DEBUG_VALID_LISP_OBJECT_P (args[count+1]); |
| 1346 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, | 1436 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", count - 4, |
| 1347 | SDATA (format2 ("%s", args[i], Qnil)), | 1437 | XD_OBJECT_TO_STRING (args[count]), |
| 1348 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1438 | XD_OBJECT_TO_STRING (args[count+1])); |
| 1349 | ++i; | 1439 | ++count; |
| 1350 | } | 1440 | } |
| 1351 | else | 1441 | else |
| 1352 | { | 1442 | { |
| 1353 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1443 | XD_DEBUG_VALID_LISP_OBJECT_P (args[count]); |
| 1354 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, | 1444 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", count - 4, |
| 1355 | SDATA (format2 ("%s", args[i], Qnil))); | 1445 | XD_OBJECT_TO_STRING (args[count])); |
| 1356 | } | 1446 | } |
| 1357 | 1447 | ||
| 1358 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | 1448 | /* Check for valid signature. We use DBUS_TYPE_INVALID as |
| 1359 | indication that there is no parent type. */ | 1449 | indication that there is no parent type. */ |
| 1360 | xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); | 1450 | xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[count]); |
| 1361 | 1451 | ||
| 1362 | xd_append_arg (dtype, args[i], &iter); | 1452 | xd_append_arg (dtype, args[count], &iter); |
| 1363 | } | 1453 | } |
| 1364 | 1454 | ||
| 1365 | if (!NILP (handler)) | 1455 | if (!NILP (handler)) |
| @@ -1368,11 +1458,15 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1368 | message queue. */ | 1458 | message queue. */ |
| 1369 | if (!dbus_connection_send_with_reply (connection, dmessage, | 1459 | if (!dbus_connection_send_with_reply (connection, dmessage, |
| 1370 | NULL, timeout)) | 1460 | NULL, timeout)) |
| 1371 | XD_SIGNAL1 (build_string ("Cannot send message")); | 1461 | { |
| 1462 | UNGCPRO; | ||
| 1463 | XD_SIGNAL1 (build_string ("Cannot send message")); | ||
| 1464 | } | ||
| 1372 | 1465 | ||
| 1373 | /* The result is the key in Vdbus_registered_objects_table. */ | 1466 | /* The result is the key in Vdbus_registered_objects_table. */ |
| 1374 | serial = dbus_message_get_serial (dmessage); | 1467 | serial = dbus_message_get_serial (dmessage); |
| 1375 | result = list2 (bus, make_fixnum_or_float (serial)); | 1468 | result = list3 (QCdbus_registered_serial, |
| 1469 | bus, make_fixnum_or_float (serial)); | ||
| 1376 | 1470 | ||
| 1377 | /* Create a hash table entry. */ | 1471 | /* Create a hash table entry. */ |
| 1378 | Fputhash (result, handler, Vdbus_registered_objects_table); | 1472 | Fputhash (result, handler, Vdbus_registered_objects_table); |
| @@ -1382,12 +1476,15 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1382 | /* Send the message. The message is just added to the outgoing | 1476 | /* Send the message. The message is just added to the outgoing |
| 1383 | message queue. */ | 1477 | message queue. */ |
| 1384 | if (!dbus_connection_send (connection, dmessage, NULL)) | 1478 | if (!dbus_connection_send (connection, dmessage, NULL)) |
| 1385 | XD_SIGNAL1 (build_string ("Cannot send message")); | 1479 | { |
| 1480 | UNGCPRO; | ||
| 1481 | XD_SIGNAL1 (build_string ("Cannot send message")); | ||
| 1482 | } | ||
| 1386 | 1483 | ||
| 1387 | result = Qnil; | 1484 | result = Qnil; |
| 1388 | } | 1485 | } |
| 1389 | 1486 | ||
| 1390 | XD_DEBUG_MESSAGE ("Message sent"); | 1487 | XD_DEBUG_MESSAGE ("Message sent: %s", XD_OBJECT_TO_STRING (result)); |
| 1391 | 1488 | ||
| 1392 | /* Cleanup. */ | 1489 | /* Cleanup. */ |
| 1393 | dbus_message_unref (dmessage); | 1490 | dbus_message_unref (dmessage); |
| @@ -1396,300 +1493,6 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1396 | RETURN_UNGCPRO (result); | 1493 | RETURN_UNGCPRO (result); |
| 1397 | } | 1494 | } |
| 1398 | 1495 | ||
| 1399 | DEFUN ("dbus-method-return-internal", Fdbus_method_return_internal, | ||
| 1400 | Sdbus_method_return_internal, | ||
| 1401 | 3, MANY, 0, | ||
| 1402 | doc: /* Return for message SERIAL on the D-Bus BUS. | ||
| 1403 | This is an internal function, it shall not be used outside dbus.el. | ||
| 1404 | |||
| 1405 | usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | ||
| 1406 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 1407 | { | ||
| 1408 | Lisp_Object bus, service; | ||
| 1409 | struct gcpro gcpro1, gcpro2; | ||
| 1410 | DBusConnection *connection; | ||
| 1411 | DBusMessage *dmessage; | ||
| 1412 | DBusMessageIter iter; | ||
| 1413 | dbus_uint32_t serial; | ||
| 1414 | unsigned int ui_serial, dtype; | ||
| 1415 | ptrdiff_t i; | ||
| 1416 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | ||
| 1417 | |||
| 1418 | /* Check parameters. */ | ||
| 1419 | bus = args[0]; | ||
| 1420 | service = args[2]; | ||
| 1421 | |||
| 1422 | CHECK_DBUS_SERIAL_GET_SERIAL (args[1], serial); | ||
| 1423 | CHECK_STRING (service); | ||
| 1424 | GCPRO2 (bus, service); | ||
| 1425 | |||
| 1426 | ui_serial = serial; | ||
| 1427 | XD_DEBUG_MESSAGE ("%u %s ", ui_serial, SSDATA (service)); | ||
| 1428 | |||
| 1429 | /* Open a connection to the bus. */ | ||
| 1430 | connection = xd_initialize (bus, TRUE); | ||
| 1431 | |||
| 1432 | /* Create the message. */ | ||
| 1433 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); | ||
| 1434 | if ((dmessage == NULL) | ||
| 1435 | || (!dbus_message_set_reply_serial (dmessage, serial)) | ||
| 1436 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) | ||
| 1437 | { | ||
| 1438 | UNGCPRO; | ||
| 1439 | XD_SIGNAL1 (build_string ("Unable to create a return message")); | ||
| 1440 | } | ||
| 1441 | |||
| 1442 | UNGCPRO; | ||
| 1443 | |||
| 1444 | /* Initialize parameter list of message. */ | ||
| 1445 | dbus_message_iter_init_append (dmessage, &iter); | ||
| 1446 | |||
| 1447 | /* Append parameters to the message. */ | ||
| 1448 | for (i = 3; i < nargs; ++i) | ||
| 1449 | { | ||
| 1450 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | ||
| 1451 | if (XD_DBUS_TYPE_P (args[i])) | ||
| 1452 | { | ||
| 1453 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1454 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | ||
| 1455 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 2, | ||
| 1456 | SDATA (format2 ("%s", args[i], Qnil)), | ||
| 1457 | SDATA (format2 ("%s", args[i+1], Qnil))); | ||
| 1458 | ++i; | ||
| 1459 | } | ||
| 1460 | else | ||
| 1461 | { | ||
| 1462 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1463 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 2, | ||
| 1464 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 1465 | } | ||
| 1466 | |||
| 1467 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | ||
| 1468 | indication that there is no parent type. */ | ||
| 1469 | xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); | ||
| 1470 | |||
| 1471 | xd_append_arg (dtype, args[i], &iter); | ||
| 1472 | } | ||
| 1473 | |||
| 1474 | /* Send the message. The message is just added to the outgoing | ||
| 1475 | message queue. */ | ||
| 1476 | if (!dbus_connection_send (connection, dmessage, NULL)) | ||
| 1477 | XD_SIGNAL1 (build_string ("Cannot send message")); | ||
| 1478 | |||
| 1479 | XD_DEBUG_MESSAGE ("Message sent"); | ||
| 1480 | |||
| 1481 | /* Cleanup. */ | ||
| 1482 | dbus_message_unref (dmessage); | ||
| 1483 | |||
| 1484 | /* Return. */ | ||
| 1485 | return Qt; | ||
| 1486 | } | ||
| 1487 | |||
| 1488 | DEFUN ("dbus-method-error-internal", Fdbus_method_error_internal, | ||
| 1489 | Sdbus_method_error_internal, | ||
| 1490 | 3, MANY, 0, | ||
| 1491 | doc: /* Return error message for message SERIAL on the D-Bus BUS. | ||
| 1492 | This is an internal function, it shall not be used outside dbus.el. | ||
| 1493 | |||
| 1494 | usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | ||
| 1495 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 1496 | { | ||
| 1497 | Lisp_Object bus, service; | ||
| 1498 | struct gcpro gcpro1, gcpro2; | ||
| 1499 | DBusConnection *connection; | ||
| 1500 | DBusMessage *dmessage; | ||
| 1501 | DBusMessageIter iter; | ||
| 1502 | dbus_uint32_t serial; | ||
| 1503 | unsigned int ui_serial, dtype; | ||
| 1504 | ptrdiff_t i; | ||
| 1505 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | ||
| 1506 | |||
| 1507 | /* Check parameters. */ | ||
| 1508 | bus = args[0]; | ||
| 1509 | service = args[2]; | ||
| 1510 | |||
| 1511 | CHECK_DBUS_SERIAL_GET_SERIAL (args[1], serial); | ||
| 1512 | CHECK_STRING (service); | ||
| 1513 | GCPRO2 (bus, service); | ||
| 1514 | |||
| 1515 | ui_serial = serial; | ||
| 1516 | XD_DEBUG_MESSAGE ("%u %s ", ui_serial, SSDATA (service)); | ||
| 1517 | |||
| 1518 | /* Open a connection to the bus. */ | ||
| 1519 | connection = xd_initialize (bus, TRUE); | ||
| 1520 | |||
| 1521 | /* Create the message. */ | ||
| 1522 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); | ||
| 1523 | if ((dmessage == NULL) | ||
| 1524 | || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED)) | ||
| 1525 | || (!dbus_message_set_reply_serial (dmessage, serial)) | ||
| 1526 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) | ||
| 1527 | { | ||
| 1528 | UNGCPRO; | ||
| 1529 | XD_SIGNAL1 (build_string ("Unable to create a error message")); | ||
| 1530 | } | ||
| 1531 | |||
| 1532 | UNGCPRO; | ||
| 1533 | |||
| 1534 | /* Initialize parameter list of message. */ | ||
| 1535 | dbus_message_iter_init_append (dmessage, &iter); | ||
| 1536 | |||
| 1537 | /* Append parameters to the message. */ | ||
| 1538 | for (i = 3; i < nargs; ++i) | ||
| 1539 | { | ||
| 1540 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | ||
| 1541 | if (XD_DBUS_TYPE_P (args[i])) | ||
| 1542 | { | ||
| 1543 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1544 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | ||
| 1545 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 2, | ||
| 1546 | SDATA (format2 ("%s", args[i], Qnil)), | ||
| 1547 | SDATA (format2 ("%s", args[i+1], Qnil))); | ||
| 1548 | ++i; | ||
| 1549 | } | ||
| 1550 | else | ||
| 1551 | { | ||
| 1552 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1553 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 2, | ||
| 1554 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 1555 | } | ||
| 1556 | |||
| 1557 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | ||
| 1558 | indication that there is no parent type. */ | ||
| 1559 | xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); | ||
| 1560 | |||
| 1561 | xd_append_arg (dtype, args[i], &iter); | ||
| 1562 | } | ||
| 1563 | |||
| 1564 | /* Send the message. The message is just added to the outgoing | ||
| 1565 | message queue. */ | ||
| 1566 | if (!dbus_connection_send (connection, dmessage, NULL)) | ||
| 1567 | XD_SIGNAL1 (build_string ("Cannot send message")); | ||
| 1568 | |||
| 1569 | XD_DEBUG_MESSAGE ("Message sent"); | ||
| 1570 | |||
| 1571 | /* Cleanup. */ | ||
| 1572 | dbus_message_unref (dmessage); | ||
| 1573 | |||
| 1574 | /* Return. */ | ||
| 1575 | return Qt; | ||
| 1576 | } | ||
| 1577 | |||
| 1578 | DEFUN ("dbus-send-signal", Fdbus_send_signal, Sdbus_send_signal, 5, MANY, 0, | ||
| 1579 | doc: /* Send signal SIGNAL on the D-Bus BUS. | ||
| 1580 | |||
| 1581 | BUS is either a Lisp symbol, `:system' or `:session', or a string | ||
| 1582 | denoting the bus address. | ||
| 1583 | |||
| 1584 | SERVICE is the D-Bus service name SIGNAL is sent from. PATH is the | ||
| 1585 | D-Bus object path SERVICE is registered at. INTERFACE is an interface | ||
| 1586 | offered by SERVICE. It must provide signal SIGNAL. | ||
| 1587 | |||
| 1588 | All other arguments ARGS are passed to SIGNAL as arguments. They are | ||
| 1589 | converted into D-Bus types via the following rules: | ||
| 1590 | |||
| 1591 | t and nil => DBUS_TYPE_BOOLEAN | ||
| 1592 | number => DBUS_TYPE_UINT32 | ||
| 1593 | integer => DBUS_TYPE_INT32 | ||
| 1594 | float => DBUS_TYPE_DOUBLE | ||
| 1595 | string => DBUS_TYPE_STRING | ||
| 1596 | list => DBUS_TYPE_ARRAY | ||
| 1597 | |||
| 1598 | All arguments can be preceded by a type symbol. For details about | ||
| 1599 | type symbols, see Info node `(dbus)Type Conversion'. | ||
| 1600 | |||
| 1601 | Example: | ||
| 1602 | |||
| 1603 | \(dbus-send-signal | ||
| 1604 | :session "org.gnu.Emacs" "/org/gnu/Emacs" | ||
| 1605 | "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs") | ||
| 1606 | |||
| 1607 | usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | ||
| 1608 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 1609 | { | ||
| 1610 | Lisp_Object bus, service, path, interface, signal; | ||
| 1611 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | ||
| 1612 | DBusConnection *connection; | ||
| 1613 | DBusMessage *dmessage; | ||
| 1614 | DBusMessageIter iter; | ||
| 1615 | unsigned int dtype; | ||
| 1616 | ptrdiff_t i; | ||
| 1617 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | ||
| 1618 | |||
| 1619 | /* Check parameters. */ | ||
| 1620 | bus = args[0]; | ||
| 1621 | service = args[1]; | ||
| 1622 | path = args[2]; | ||
| 1623 | interface = args[3]; | ||
| 1624 | signal = args[4]; | ||
| 1625 | |||
| 1626 | CHECK_STRING (service); | ||
| 1627 | CHECK_STRING (path); | ||
| 1628 | CHECK_STRING (interface); | ||
| 1629 | CHECK_STRING (signal); | ||
| 1630 | GCPRO5 (bus, service, path, interface, signal); | ||
| 1631 | |||
| 1632 | XD_DEBUG_MESSAGE ("%s %s %s %s", | ||
| 1633 | SDATA (service), | ||
| 1634 | SDATA (path), | ||
| 1635 | SDATA (interface), | ||
| 1636 | SDATA (signal)); | ||
| 1637 | |||
| 1638 | /* Open a connection to the bus. */ | ||
| 1639 | connection = xd_initialize (bus, TRUE); | ||
| 1640 | |||
| 1641 | /* Create the message. */ | ||
| 1642 | dmessage = dbus_message_new_signal (SSDATA (path), | ||
| 1643 | SSDATA (interface), | ||
| 1644 | SSDATA (signal)); | ||
| 1645 | UNGCPRO; | ||
| 1646 | if (dmessage == NULL) | ||
| 1647 | XD_SIGNAL1 (build_string ("Unable to create a new message")); | ||
| 1648 | |||
| 1649 | /* Initialize parameter list of message. */ | ||
| 1650 | dbus_message_iter_init_append (dmessage, &iter); | ||
| 1651 | |||
| 1652 | /* Append parameters to the message. */ | ||
| 1653 | for (i = 5; i < nargs; ++i) | ||
| 1654 | { | ||
| 1655 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | ||
| 1656 | if (XD_DBUS_TYPE_P (args[i])) | ||
| 1657 | { | ||
| 1658 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1659 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | ||
| 1660 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, | ||
| 1661 | SDATA (format2 ("%s", args[i], Qnil)), | ||
| 1662 | SDATA (format2 ("%s", args[i+1], Qnil))); | ||
| 1663 | ++i; | ||
| 1664 | } | ||
| 1665 | else | ||
| 1666 | { | ||
| 1667 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1668 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, | ||
| 1669 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 1670 | } | ||
| 1671 | |||
| 1672 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | ||
| 1673 | indication that there is no parent type. */ | ||
| 1674 | xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); | ||
| 1675 | |||
| 1676 | xd_append_arg (dtype, args[i], &iter); | ||
| 1677 | } | ||
| 1678 | |||
| 1679 | /* Send the message. The message is just added to the outgoing | ||
| 1680 | message queue. */ | ||
| 1681 | if (!dbus_connection_send (connection, dmessage, NULL)) | ||
| 1682 | XD_SIGNAL1 (build_string ("Cannot send message")); | ||
| 1683 | |||
| 1684 | XD_DEBUG_MESSAGE ("Signal sent"); | ||
| 1685 | |||
| 1686 | /* Cleanup. */ | ||
| 1687 | dbus_message_unref (dmessage); | ||
| 1688 | |||
| 1689 | /* Return. */ | ||
| 1690 | return Qt; | ||
| 1691 | } | ||
| 1692 | |||
| 1693 | /* Read one queued incoming message of the D-Bus BUS. | 1496 | /* Read one queued incoming message of the D-Bus BUS. |
| 1694 | BUS is either a Lisp symbol, :system or :session, or a string denoting | 1497 | BUS is either a Lisp symbol, :system or :session, or a string denoting |
| 1695 | the bus address. */ | 1498 | the bus address. */ |
| @@ -1702,7 +1505,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1702 | DBusMessage *dmessage; | 1505 | DBusMessage *dmessage; |
| 1703 | DBusMessageIter iter; | 1506 | DBusMessageIter iter; |
| 1704 | unsigned int dtype; | 1507 | unsigned int dtype; |
| 1705 | int mtype; | 1508 | unsigned int mtype; |
| 1706 | dbus_uint32_t serial; | 1509 | dbus_uint32_t serial; |
| 1707 | unsigned int ui_serial; | 1510 | unsigned int ui_serial; |
| 1708 | const char *uname, *path, *interface, *member; | 1511 | const char *uname, *path, *interface, *member; |
| @@ -1744,23 +1547,19 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1744 | member = dbus_message_get_member (dmessage); | 1547 | member = dbus_message_get_member (dmessage); |
| 1745 | 1548 | ||
| 1746 | XD_DEBUG_MESSAGE ("Event received: %s %u %s %s %s %s %s", | 1549 | XD_DEBUG_MESSAGE ("Event received: %s %u %s %s %s %s %s", |
| 1747 | (mtype == DBUS_MESSAGE_TYPE_INVALID) | 1550 | XD_MESSAGE_TYPE_TO_STRING (mtype), |
| 1748 | ? "DBUS_MESSAGE_TYPE_INVALID" | ||
| 1749 | : (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) | ||
| 1750 | ? "DBUS_MESSAGE_TYPE_METHOD_CALL" | ||
| 1751 | : (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) | ||
| 1752 | ? "DBUS_MESSAGE_TYPE_METHOD_RETURN" | ||
| 1753 | : (mtype == DBUS_MESSAGE_TYPE_ERROR) | ||
| 1754 | ? "DBUS_MESSAGE_TYPE_ERROR" | ||
| 1755 | : "DBUS_MESSAGE_TYPE_SIGNAL", | ||
| 1756 | ui_serial, uname, path, interface, member, | 1551 | ui_serial, uname, path, interface, member, |
| 1757 | SDATA (format2 ("%s", args, Qnil))); | 1552 | XD_OBJECT_TO_STRING (args)); |
| 1553 | |||
| 1554 | if (mtype == DBUS_MESSAGE_TYPE_INVALID) | ||
| 1555 | goto cleanup; | ||
| 1758 | 1556 | ||
| 1759 | if ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) | 1557 | else if ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) |
| 1760 | || (mtype == DBUS_MESSAGE_TYPE_ERROR)) | 1558 | || (mtype == DBUS_MESSAGE_TYPE_ERROR)) |
| 1761 | { | 1559 | { |
| 1762 | /* Search for a registered function of the message. */ | 1560 | /* Search for a registered function of the message. */ |
| 1763 | key = list2 (bus, make_fixnum_or_float (serial)); | 1561 | key = list3 (QCdbus_registered_serial, bus, |
| 1562 | make_fixnum_or_float (serial)); | ||
| 1764 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); | 1563 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1765 | 1564 | ||
| 1766 | /* There shall be exactly one entry. Construct an event. */ | 1565 | /* There shall be exactly one entry. Construct an event. */ |
| @@ -1777,7 +1576,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1777 | event.arg = Fcons (value, args); | 1576 | event.arg = Fcons (value, args); |
| 1778 | } | 1577 | } |
| 1779 | 1578 | ||
| 1780 | else /* (mtype != DBUS_MESSAGE_TYPE_METHOD_RETURN) */ | 1579 | else /* DBUS_MESSAGE_TYPE_METHOD_CALL, DBUS_MESSAGE_TYPE_SIGNAL. */ |
| 1781 | { | 1580 | { |
| 1782 | /* Vdbus_registered_objects_table requires non-nil interface and | 1581 | /* Vdbus_registered_objects_table requires non-nil interface and |
| 1783 | member. */ | 1582 | member. */ |
| @@ -1785,7 +1584,10 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1785 | goto cleanup; | 1584 | goto cleanup; |
| 1786 | 1585 | ||
| 1787 | /* Search for a registered function of the message. */ | 1586 | /* Search for a registered function of the message. */ |
| 1788 | key = list3 (bus, build_string (interface), build_string (member)); | 1587 | key = list4 ((mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) |
| 1588 | ? QCdbus_registered_method | ||
| 1589 | : QCdbus_registered_signal, | ||
| 1590 | bus, build_string (interface), build_string (member)); | ||
| 1789 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); | 1591 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1790 | 1592 | ||
| 1791 | /* Loop over the registered functions. Construct an event. */ | 1593 | /* Loop over the registered functions. Construct an event. */ |
| @@ -1835,8 +1637,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1835 | /* Store it into the input event queue. */ | 1637 | /* Store it into the input event queue. */ |
| 1836 | kbd_buffer_store_event (&event); | 1638 | kbd_buffer_store_event (&event); |
| 1837 | 1639 | ||
| 1838 | XD_DEBUG_MESSAGE ("Event stored: %s", | 1640 | XD_DEBUG_MESSAGE ("Event stored: %s", XD_OBJECT_TO_STRING (event.arg)); |
| 1839 | SDATA (format2 ("%s", event.arg, Qnil))); | ||
| 1840 | 1641 | ||
| 1841 | /* Cleanup. */ | 1642 | /* Cleanup. */ |
| 1842 | cleanup: | 1643 | cleanup: |
| @@ -1851,8 +1652,8 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1851 | static Lisp_Object | 1652 | static Lisp_Object |
| 1852 | xd_read_message (Lisp_Object bus) | 1653 | xd_read_message (Lisp_Object bus) |
| 1853 | { | 1654 | { |
| 1854 | /* Open a connection to the bus. */ | 1655 | /* Retrieve bus address. */ |
| 1855 | DBusConnection *connection = xd_initialize (bus, TRUE); | 1656 | DBusConnection *connection = xd_get_connection_address (bus); |
| 1856 | 1657 | ||
| 1857 | /* Non blocking read of the next available message. */ | 1658 | /* Non blocking read of the next available message. */ |
| 1858 | dbus_connection_read_write (connection, 0); | 1659 | dbus_connection_read_write (connection, 0); |
| @@ -1867,16 +1668,18 @@ xd_read_message (Lisp_Object bus) | |||
| 1867 | static void | 1668 | static void |
| 1868 | xd_read_queued_messages (int fd, void *data, int for_read) | 1669 | xd_read_queued_messages (int fd, void *data, int for_read) |
| 1869 | { | 1670 | { |
| 1870 | Lisp_Object busp = Vdbus_registered_buses; | 1671 | Lisp_Object busp = xd_registered_buses; |
| 1871 | Lisp_Object bus = Qnil; | 1672 | Lisp_Object bus = Qnil; |
| 1673 | Lisp_Object key; | ||
| 1872 | 1674 | ||
| 1873 | /* Find bus related to fd. */ | 1675 | /* Find bus related to fd. */ |
| 1874 | if (data != NULL) | 1676 | if (data != NULL) |
| 1875 | while (!NILP (busp)) | 1677 | while (!NILP (busp)) |
| 1876 | { | 1678 | { |
| 1877 | if ((SYMBOLP (CAR_SAFE (busp)) && XSYMBOL (CAR_SAFE (busp)) == data) | 1679 | key = CAR_SAFE (CAR_SAFE (busp)); |
| 1878 | || (STRINGP (CAR_SAFE (busp)) && XSTRING (CAR_SAFE (busp)) == data)) | 1680 | if ((SYMBOLP (key) && XSYMBOL (key) == data) |
| 1879 | bus = CAR_SAFE (busp); | 1681 | || (STRINGP (key) && XSTRING (key) == data)) |
| 1682 | bus = key; | ||
| 1880 | busp = CDR_SAFE (busp); | 1683 | busp = CDR_SAFE (busp); |
| 1881 | } | 1684 | } |
| 1882 | 1685 | ||
| @@ -1889,327 +1692,6 @@ xd_read_queued_messages (int fd, void *data, int for_read) | |||
| 1889 | xd_in_read_queued_messages = 0; | 1692 | xd_in_read_queued_messages = 0; |
| 1890 | } | 1693 | } |
| 1891 | 1694 | ||
| 1892 | DEFUN ("dbus-register-service", Fdbus_register_service, Sdbus_register_service, | ||
| 1893 | 2, MANY, 0, | ||
| 1894 | doc: /* Register known name SERVICE on the D-Bus BUS. | ||
| 1895 | |||
| 1896 | BUS is either a Lisp symbol, `:system' or `:session', or a string | ||
| 1897 | denoting the bus address. | ||
| 1898 | |||
| 1899 | SERVICE is the D-Bus service name that should be registered. It must | ||
| 1900 | be a known name. | ||
| 1901 | |||
| 1902 | FLAGS are keywords, which control how the service name is registered. | ||
| 1903 | The following keywords are recognized: | ||
| 1904 | |||
| 1905 | `:allow-replacement': Allow another service to become the primary | ||
| 1906 | owner if requested. | ||
| 1907 | |||
| 1908 | `:replace-existing': Request to replace the current primary owner. | ||
| 1909 | |||
| 1910 | `:do-not-queue': If we can not become the primary owner do not place | ||
| 1911 | us in the queue. | ||
| 1912 | |||
| 1913 | The function returns a keyword, indicating the result of the | ||
| 1914 | operation. One of the following keywords is returned: | ||
| 1915 | |||
| 1916 | `:primary-owner': Service has become the primary owner of the | ||
| 1917 | requested name. | ||
| 1918 | |||
| 1919 | `:in-queue': Service could not become the primary owner and has been | ||
| 1920 | placed in the queue. | ||
| 1921 | |||
| 1922 | `:exists': Service is already in the queue. | ||
| 1923 | |||
| 1924 | `:already-owner': Service is already the primary owner. | ||
| 1925 | |||
| 1926 | Example: | ||
| 1927 | |||
| 1928 | \(dbus-register-service :session dbus-service-emacs) | ||
| 1929 | |||
| 1930 | => :primary-owner. | ||
| 1931 | |||
| 1932 | \(dbus-register-service | ||
| 1933 | :session "org.freedesktop.TextEditor" | ||
| 1934 | dbus-service-allow-replacement dbus-service-replace-existing) | ||
| 1935 | |||
| 1936 | => :already-owner. | ||
| 1937 | |||
| 1938 | usage: (dbus-register-service BUS SERVICE &rest FLAGS) */) | ||
| 1939 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 1940 | { | ||
| 1941 | Lisp_Object bus, service; | ||
| 1942 | DBusConnection *connection; | ||
| 1943 | ptrdiff_t i; | ||
| 1944 | unsigned int value; | ||
| 1945 | unsigned int flags = 0; | ||
| 1946 | int result; | ||
| 1947 | DBusError derror; | ||
| 1948 | |||
| 1949 | bus = args[0]; | ||
| 1950 | service = args[1]; | ||
| 1951 | |||
| 1952 | /* Check parameters. */ | ||
| 1953 | CHECK_STRING (service); | ||
| 1954 | |||
| 1955 | /* Process flags. */ | ||
| 1956 | for (i = 2; i < nargs; ++i) { | ||
| 1957 | value = ((EQ (args[i], QCdbus_request_name_replace_existing)) | ||
| 1958 | ? DBUS_NAME_FLAG_REPLACE_EXISTING | ||
| 1959 | : (EQ (args[i], QCdbus_request_name_allow_replacement)) | ||
| 1960 | ? DBUS_NAME_FLAG_ALLOW_REPLACEMENT | ||
| 1961 | : (EQ (args[i], QCdbus_request_name_do_not_queue)) | ||
| 1962 | ? DBUS_NAME_FLAG_DO_NOT_QUEUE | ||
| 1963 | : -1); | ||
| 1964 | if (value == -1) | ||
| 1965 | XD_SIGNAL2 (build_string ("Unrecognized name request flag"), args[i]); | ||
| 1966 | flags |= value; | ||
| 1967 | } | ||
| 1968 | |||
| 1969 | /* Open a connection to the bus. */ | ||
| 1970 | connection = xd_initialize (bus, TRUE); | ||
| 1971 | |||
| 1972 | /* Request the known name from the bus. */ | ||
| 1973 | dbus_error_init (&derror); | ||
| 1974 | result = dbus_bus_request_name (connection, SSDATA (service), flags, | ||
| 1975 | &derror); | ||
| 1976 | if (dbus_error_is_set (&derror)) | ||
| 1977 | XD_ERROR (derror); | ||
| 1978 | |||
| 1979 | /* Cleanup. */ | ||
| 1980 | dbus_error_free (&derror); | ||
| 1981 | |||
| 1982 | /* Return object. */ | ||
| 1983 | switch (result) | ||
| 1984 | { | ||
| 1985 | case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER: | ||
| 1986 | return QCdbus_request_name_reply_primary_owner; | ||
| 1987 | case DBUS_REQUEST_NAME_REPLY_IN_QUEUE: | ||
| 1988 | return QCdbus_request_name_reply_in_queue; | ||
| 1989 | case DBUS_REQUEST_NAME_REPLY_EXISTS: | ||
| 1990 | return QCdbus_request_name_reply_exists; | ||
| 1991 | case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: | ||
| 1992 | return QCdbus_request_name_reply_already_owner; | ||
| 1993 | default: | ||
| 1994 | /* This should not happen. */ | ||
| 1995 | XD_SIGNAL2 (build_string ("Could not register service"), service); | ||
| 1996 | } | ||
| 1997 | } | ||
| 1998 | |||
| 1999 | DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal, | ||
| 2000 | 6, MANY, 0, | ||
| 2001 | doc: /* Register for signal SIGNAL on the D-Bus BUS. | ||
| 2002 | |||
| 2003 | BUS is either a Lisp symbol, `:system' or `:session', or a string | ||
| 2004 | denoting the bus address. | ||
| 2005 | |||
| 2006 | SERVICE is the D-Bus service name used by the sending D-Bus object. | ||
| 2007 | It can be either a known name or the unique name of the D-Bus object | ||
| 2008 | sending the signal. When SERVICE is nil, related signals from all | ||
| 2009 | D-Bus objects shall be accepted. | ||
| 2010 | |||
| 2011 | PATH is the D-Bus object path SERVICE is registered. It can also be | ||
| 2012 | nil if the path name of incoming signals shall not be checked. | ||
| 2013 | |||
| 2014 | INTERFACE is an interface offered by SERVICE. It must provide SIGNAL. | ||
| 2015 | HANDLER is a Lisp function to be called when the signal is received. | ||
| 2016 | It must accept as arguments the values SIGNAL is sending. | ||
| 2017 | |||
| 2018 | All other arguments ARGS, if specified, must be strings. They stand | ||
| 2019 | for the respective arguments of the signal in their order, and are | ||
| 2020 | used for filtering as well. A nil argument might be used to preserve | ||
| 2021 | the order. | ||
| 2022 | |||
| 2023 | INTERFACE, SIGNAL and HANDLER must not be nil. Example: | ||
| 2024 | |||
| 2025 | \(defun my-signal-handler (device) | ||
| 2026 | (message "Device %s added" device)) | ||
| 2027 | |||
| 2028 | \(dbus-register-signal | ||
| 2029 | :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" | ||
| 2030 | "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler) | ||
| 2031 | |||
| 2032 | => ((:system "org.freedesktop.Hal.Manager" "DeviceAdded") | ||
| 2033 | ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler)) | ||
| 2034 | |||
| 2035 | `dbus-register-signal' returns an object, which can be used in | ||
| 2036 | `dbus-unregister-object' for removing the registration. | ||
| 2037 | |||
| 2038 | usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */) | ||
| 2039 | (ptrdiff_t nargs, Lisp_Object *args) | ||
| 2040 | { | ||
| 2041 | Lisp_Object bus, service, path, interface, signal, handler; | ||
| 2042 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | ||
| 2043 | Lisp_Object uname, key, key1, value; | ||
| 2044 | DBusConnection *connection; | ||
| 2045 | ptrdiff_t i; | ||
| 2046 | char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | ||
| 2047 | int rulelen; | ||
| 2048 | DBusError derror; | ||
| 2049 | |||
| 2050 | /* Check parameters. */ | ||
| 2051 | bus = args[0]; | ||
| 2052 | service = args[1]; | ||
| 2053 | path = args[2]; | ||
| 2054 | interface = args[3]; | ||
| 2055 | signal = args[4]; | ||
| 2056 | handler = args[5]; | ||
| 2057 | |||
| 2058 | if (!NILP (service)) CHECK_STRING (service); | ||
| 2059 | if (!NILP (path)) CHECK_STRING (path); | ||
| 2060 | CHECK_STRING (interface); | ||
| 2061 | CHECK_STRING (signal); | ||
| 2062 | if (!FUNCTIONP (handler)) | ||
| 2063 | wrong_type_argument (Qinvalid_function, handler); | ||
| 2064 | GCPRO6 (bus, service, path, interface, signal, handler); | ||
| 2065 | |||
| 2066 | /* Retrieve unique name of service. If service is a known name, we | ||
| 2067 | will register for the corresponding unique name, if any. Signals | ||
| 2068 | are sent always with the unique name as sender. Note: the unique | ||
| 2069 | name of "org.freedesktop.DBus" is that string itself. */ | ||
| 2070 | if ((STRINGP (service)) | ||
| 2071 | && (SBYTES (service) > 0) | ||
| 2072 | && (strcmp (SSDATA (service), DBUS_SERVICE_DBUS) != 0) | ||
| 2073 | && (strncmp (SSDATA (service), ":", 1) != 0)) | ||
| 2074 | uname = call2 (intern ("dbus-get-name-owner"), bus, service); | ||
| 2075 | else | ||
| 2076 | uname = service; | ||
| 2077 | |||
| 2078 | /* Create a matching rule if the unique name exists (when no | ||
| 2079 | wildcard). */ | ||
| 2080 | if (NILP (uname) || (SBYTES (uname) > 0)) | ||
| 2081 | { | ||
| 2082 | /* Open a connection to the bus. */ | ||
| 2083 | connection = xd_initialize (bus, TRUE); | ||
| 2084 | |||
| 2085 | /* Create a rule to receive related signals. */ | ||
| 2086 | rulelen = snprintf (rule, sizeof rule, | ||
| 2087 | "type='signal',interface='%s',member='%s'", | ||
| 2088 | SDATA (interface), | ||
| 2089 | SDATA (signal)); | ||
| 2090 | if (! (0 <= rulelen && rulelen < sizeof rule)) | ||
| 2091 | string_overflow (); | ||
| 2092 | |||
| 2093 | /* Add unique name and path to the rule if they are non-nil. */ | ||
| 2094 | if (!NILP (uname)) | ||
| 2095 | { | ||
| 2096 | int len = snprintf (rule + rulelen, sizeof rule - rulelen, | ||
| 2097 | ",sender='%s'", SDATA (uname)); | ||
| 2098 | if (! (0 <= len && len < sizeof rule - rulelen)) | ||
| 2099 | string_overflow (); | ||
| 2100 | rulelen += len; | ||
| 2101 | } | ||
| 2102 | |||
| 2103 | if (!NILP (path)) | ||
| 2104 | { | ||
| 2105 | int len = snprintf (rule + rulelen, sizeof rule - rulelen, | ||
| 2106 | ",path='%s'", SDATA (path)); | ||
| 2107 | if (! (0 <= len && len < sizeof rule - rulelen)) | ||
| 2108 | string_overflow (); | ||
| 2109 | rulelen += len; | ||
| 2110 | } | ||
| 2111 | |||
| 2112 | /* Add arguments to the rule if they are non-nil. */ | ||
| 2113 | for (i = 6; i < nargs; ++i) | ||
| 2114 | if (!NILP (args[i])) | ||
| 2115 | { | ||
| 2116 | int len; | ||
| 2117 | CHECK_STRING (args[i]); | ||
| 2118 | len = snprintf (rule + rulelen, sizeof rule - rulelen, | ||
| 2119 | ",arg%"pD"d='%s'", i - 6, SDATA (args[i])); | ||
| 2120 | if (! (0 <= len && len < sizeof rule - rulelen)) | ||
| 2121 | string_overflow (); | ||
| 2122 | rulelen += len; | ||
| 2123 | } | ||
| 2124 | |||
| 2125 | /* Add the rule to the bus. */ | ||
| 2126 | dbus_error_init (&derror); | ||
| 2127 | dbus_bus_add_match (connection, rule, &derror); | ||
| 2128 | if (dbus_error_is_set (&derror)) | ||
| 2129 | { | ||
| 2130 | UNGCPRO; | ||
| 2131 | XD_ERROR (derror); | ||
| 2132 | } | ||
| 2133 | |||
| 2134 | /* Cleanup. */ | ||
| 2135 | dbus_error_free (&derror); | ||
| 2136 | |||
| 2137 | XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); | ||
| 2138 | } | ||
| 2139 | |||
| 2140 | /* Create a hash table entry. */ | ||
| 2141 | key = list3 (bus, interface, signal); | ||
| 2142 | key1 = list5 (uname, service, path, handler, build_string (rule)); | ||
| 2143 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); | ||
| 2144 | |||
| 2145 | if (NILP (Fmember (key1, value))) | ||
| 2146 | Fputhash (key, Fcons (key1, value), Vdbus_registered_objects_table); | ||
| 2147 | |||
| 2148 | /* Return object. */ | ||
| 2149 | RETURN_UNGCPRO (list2 (key, list3 (service, path, handler))); | ||
| 2150 | } | ||
| 2151 | |||
| 2152 | DEFUN ("dbus-register-method", Fdbus_register_method, Sdbus_register_method, | ||
| 2153 | 6, 7, 0, | ||
| 2154 | doc: /* Register for method METHOD on the D-Bus BUS. | ||
| 2155 | |||
| 2156 | BUS is either a Lisp symbol, `:system' or `:session', or a string | ||
| 2157 | denoting the bus address. | ||
| 2158 | |||
| 2159 | SERVICE is the D-Bus service name of the D-Bus object METHOD is | ||
| 2160 | registered for. It must be a known name (See discussion of | ||
| 2161 | DONT-REGISTER-SERVICE below). | ||
| 2162 | |||
| 2163 | PATH is the D-Bus object path SERVICE is registered (See discussion of | ||
| 2164 | DONT-REGISTER-SERVICE below). INTERFACE is the interface offered by | ||
| 2165 | SERVICE. It must provide METHOD. | ||
| 2166 | |||
| 2167 | HANDLER is a Lisp function to be called when a method call is | ||
| 2168 | received. It must accept the input arguments of METHOD. The return | ||
| 2169 | value of HANDLER is used for composing the returning D-Bus message. | ||
| 2170 | In case HANDLER shall return a reply message with an empty argument | ||
| 2171 | list, HANDLER must return the symbol `:ignore'. | ||
| 2172 | |||
| 2173 | When DONT-REGISTER-SERVICE is non-nil, the known name SERVICE is not | ||
| 2174 | registered. This means that other D-Bus clients have no way of | ||
| 2175 | noticing the newly registered method. When interfaces are constructed | ||
| 2176 | incrementally by adding single methods or properties at a time, | ||
| 2177 | DONT-REGISTER-SERVICE can be used to prevent other clients from | ||
| 2178 | discovering the still incomplete interface.*/) | ||
| 2179 | (Lisp_Object bus, Lisp_Object service, Lisp_Object path, | ||
| 2180 | Lisp_Object interface, Lisp_Object method, Lisp_Object handler, | ||
| 2181 | Lisp_Object dont_register_service) | ||
| 2182 | { | ||
| 2183 | Lisp_Object key, key1, value; | ||
| 2184 | Lisp_Object args[2] = { bus, service }; | ||
| 2185 | |||
| 2186 | /* Check parameters. */ | ||
| 2187 | CHECK_STRING (service); | ||
| 2188 | CHECK_STRING (path); | ||
| 2189 | CHECK_STRING (interface); | ||
| 2190 | CHECK_STRING (method); | ||
| 2191 | if (!FUNCTIONP (handler)) | ||
| 2192 | wrong_type_argument (Qinvalid_function, handler); | ||
| 2193 | /* TODO: We must check for a valid service name, otherwise there is | ||
| 2194 | a segmentation fault. */ | ||
| 2195 | |||
| 2196 | /* Request the name. */ | ||
| 2197 | if (NILP (dont_register_service)) | ||
| 2198 | Fdbus_register_service (2, args); | ||
| 2199 | |||
| 2200 | /* Create a hash table entry. We use nil for the unique name, | ||
| 2201 | because the method might be called from anybody. */ | ||
| 2202 | key = list3 (bus, interface, method); | ||
| 2203 | key1 = list4 (Qnil, service, path, handler); | ||
| 2204 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); | ||
| 2205 | |||
| 2206 | if (NILP (Fmember (key1, value))) | ||
| 2207 | Fputhash (key, Fcons (key1, value), Vdbus_registered_objects_table); | ||
| 2208 | |||
| 2209 | /* Return object. */ | ||
| 2210 | return list2 (key, list3 (service, path, handler)); | ||
| 2211 | } | ||
| 2212 | |||
| 2213 | 1695 | ||
| 2214 | void | 1696 | void |
| 2215 | syms_of_dbusbind (void) | 1697 | syms_of_dbusbind (void) |
| @@ -2218,35 +1700,11 @@ syms_of_dbusbind (void) | |||
| 2218 | DEFSYM (Qdbus_init_bus, "dbus-init-bus"); | 1700 | DEFSYM (Qdbus_init_bus, "dbus-init-bus"); |
| 2219 | defsubr (&Sdbus_init_bus); | 1701 | defsubr (&Sdbus_init_bus); |
| 2220 | 1702 | ||
| 2221 | DEFSYM (Qdbus_close_bus, "dbus-close-bus"); | ||
| 2222 | defsubr (&Sdbus_close_bus); | ||
| 2223 | |||
| 2224 | DEFSYM (Qdbus_get_unique_name, "dbus-get-unique-name"); | 1703 | DEFSYM (Qdbus_get_unique_name, "dbus-get-unique-name"); |
| 2225 | defsubr (&Sdbus_get_unique_name); | 1704 | defsubr (&Sdbus_get_unique_name); |
| 2226 | 1705 | ||
| 2227 | DEFSYM (Qdbus_call_method, "dbus-call-method"); | 1706 | DEFSYM (Qdbus_message_internal, "dbus-message-internal"); |
| 2228 | defsubr (&Sdbus_call_method); | 1707 | defsubr (&Sdbus_message_internal); |
| 2229 | |||
| 2230 | DEFSYM (Qdbus_call_method_asynchronously, "dbus-call-method-asynchronously"); | ||
| 2231 | defsubr (&Sdbus_call_method_asynchronously); | ||
| 2232 | |||
| 2233 | DEFSYM (Qdbus_method_return_internal, "dbus-method-return-internal"); | ||
| 2234 | defsubr (&Sdbus_method_return_internal); | ||
| 2235 | |||
| 2236 | DEFSYM (Qdbus_method_error_internal, "dbus-method-error-internal"); | ||
| 2237 | defsubr (&Sdbus_method_error_internal); | ||
| 2238 | |||
| 2239 | DEFSYM (Qdbus_send_signal, "dbus-send-signal"); | ||
| 2240 | defsubr (&Sdbus_send_signal); | ||
| 2241 | |||
| 2242 | DEFSYM (Qdbus_register_service, "dbus-register-service"); | ||
| 2243 | defsubr (&Sdbus_register_service); | ||
| 2244 | |||
| 2245 | DEFSYM (Qdbus_register_signal, "dbus-register-signal"); | ||
| 2246 | defsubr (&Sdbus_register_signal); | ||
| 2247 | |||
| 2248 | DEFSYM (Qdbus_register_method, "dbus-register-method"); | ||
| 2249 | defsubr (&Sdbus_register_method); | ||
| 2250 | 1708 | ||
| 2251 | DEFSYM (Qdbus_error, "dbus-error"); | 1709 | DEFSYM (Qdbus_error, "dbus-error"); |
| 2252 | Fput (Qdbus_error, Qerror_conditions, | 1710 | Fput (Qdbus_error, Qerror_conditions, |
| @@ -2256,13 +1714,6 @@ syms_of_dbusbind (void) | |||
| 2256 | 1714 | ||
| 2257 | DEFSYM (QCdbus_system_bus, ":system"); | 1715 | DEFSYM (QCdbus_system_bus, ":system"); |
| 2258 | DEFSYM (QCdbus_session_bus, ":session"); | 1716 | DEFSYM (QCdbus_session_bus, ":session"); |
| 2259 | DEFSYM (QCdbus_request_name_allow_replacement, ":allow-replacement"); | ||
| 2260 | DEFSYM (QCdbus_request_name_replace_existing, ":replace-existing"); | ||
| 2261 | DEFSYM (QCdbus_request_name_do_not_queue, ":do-not-queue"); | ||
| 2262 | DEFSYM (QCdbus_request_name_reply_primary_owner, ":primary-owner"); | ||
| 2263 | DEFSYM (QCdbus_request_name_reply_exists, ":exists"); | ||
| 2264 | DEFSYM (QCdbus_request_name_reply_in_queue, ":in-queue"); | ||
| 2265 | DEFSYM (QCdbus_request_name_reply_already_owner, ":already-owner"); | ||
| 2266 | DEFSYM (QCdbus_timeout, ":timeout"); | 1717 | DEFSYM (QCdbus_timeout, ":timeout"); |
| 2267 | DEFSYM (QCdbus_type_byte, ":byte"); | 1718 | DEFSYM (QCdbus_type_byte, ":byte"); |
| 2268 | DEFSYM (QCdbus_type_boolean, ":boolean"); | 1719 | DEFSYM (QCdbus_type_boolean, ":boolean"); |
| @@ -2276,20 +1727,66 @@ syms_of_dbusbind (void) | |||
| 2276 | DEFSYM (QCdbus_type_string, ":string"); | 1727 | DEFSYM (QCdbus_type_string, ":string"); |
| 2277 | DEFSYM (QCdbus_type_object_path, ":object-path"); | 1728 | DEFSYM (QCdbus_type_object_path, ":object-path"); |
| 2278 | DEFSYM (QCdbus_type_signature, ":signature"); | 1729 | DEFSYM (QCdbus_type_signature, ":signature"); |
| 2279 | |||
| 2280 | #ifdef DBUS_TYPE_UNIX_FD | 1730 | #ifdef DBUS_TYPE_UNIX_FD |
| 2281 | DEFSYM (QCdbus_type_unix_fd, ":unix-fd"); | 1731 | DEFSYM (QCdbus_type_unix_fd, ":unix-fd"); |
| 2282 | #endif | 1732 | #endif |
| 2283 | |||
| 2284 | DEFSYM (QCdbus_type_array, ":array"); | 1733 | DEFSYM (QCdbus_type_array, ":array"); |
| 2285 | DEFSYM (QCdbus_type_variant, ":variant"); | 1734 | DEFSYM (QCdbus_type_variant, ":variant"); |
| 2286 | DEFSYM (QCdbus_type_struct, ":struct"); | 1735 | DEFSYM (QCdbus_type_struct, ":struct"); |
| 2287 | DEFSYM (QCdbus_type_dict_entry, ":dict-entry"); | 1736 | DEFSYM (QCdbus_type_dict_entry, ":dict-entry"); |
| 1737 | DEFSYM (QCdbus_registered_serial, ":serial"); | ||
| 1738 | DEFSYM (QCdbus_registered_method, ":method"); | ||
| 1739 | DEFSYM (QCdbus_registered_signal, ":signal"); | ||
| 1740 | |||
| 1741 | DEFVAR_LISP ("dbus-compiled-version", | ||
| 1742 | Vdbus_compiled_version, | ||
| 1743 | doc: /* The version of D-Bus Emacs is compiled against. */); | ||
| 1744 | #ifdef DBUS_VERSION_STRING | ||
| 1745 | Vdbus_compiled_version = make_pure_c_string (DBUS_VERSION_STRING); | ||
| 1746 | #else | ||
| 1747 | Vdbus_compiled_version = Qnil; | ||
| 1748 | #endif | ||
| 1749 | |||
| 1750 | DEFVAR_LISP ("dbus-runtime-version", | ||
| 1751 | Vdbus_runtime_version, | ||
| 1752 | doc: /* The version of D-Bus Emacs runs with. */); | ||
| 1753 | { | ||
| 1754 | #ifdef DBUS_VERSION | ||
| 1755 | int major, minor, micro; | ||
| 1756 | char s[1024]; | ||
| 1757 | dbus_get_version (&major, &minor, µ); | ||
| 1758 | snprintf (s, sizeof s, "%d.%d.%d", major, minor, micro); | ||
| 1759 | Vdbus_runtime_version = make_string (s, strlen (s)); | ||
| 1760 | #else | ||
| 1761 | Vdbus_runtime_version = Qnil; | ||
| 1762 | #endif | ||
| 1763 | } | ||
| 1764 | |||
| 1765 | DEFVAR_LISP ("dbus-message-type-invalid", | ||
| 1766 | Vdbus_message_type_invalid, | ||
| 1767 | doc: /* This value is never a valid message type. */); | ||
| 1768 | Vdbus_message_type_invalid = make_number (DBUS_MESSAGE_TYPE_INVALID); | ||
| 2288 | 1769 | ||
| 2289 | DEFVAR_LISP ("dbus-registered-buses", | 1770 | DEFVAR_LISP ("dbus-message-type-method-call", |
| 2290 | Vdbus_registered_buses, | 1771 | Vdbus_message_type_method_call, |
| 2291 | doc: /* List of D-Bus buses we are polling for messages. */); | 1772 | doc: /* Message type of a method call message. */); |
| 2292 | Vdbus_registered_buses = Qnil; | 1773 | Vdbus_message_type_method_call = make_number (DBUS_MESSAGE_TYPE_METHOD_CALL); |
| 1774 | |||
| 1775 | DEFVAR_LISP ("dbus-message-type-method-return", | ||
| 1776 | Vdbus_message_type_method_return, | ||
| 1777 | doc: /* Message type of a method return message. */); | ||
| 1778 | Vdbus_message_type_method_return | ||
| 1779 | = make_number (DBUS_MESSAGE_TYPE_METHOD_RETURN); | ||
| 1780 | |||
| 1781 | DEFVAR_LISP ("dbus-message-type-error", | ||
| 1782 | Vdbus_message_type_error, | ||
| 1783 | doc: /* Message type of an error reply message. */); | ||
| 1784 | Vdbus_message_type_error = make_number (DBUS_MESSAGE_TYPE_ERROR); | ||
| 1785 | |||
| 1786 | DEFVAR_LISP ("dbus-message-type-signal", | ||
| 1787 | Vdbus_message_type_signal, | ||
| 1788 | doc: /* Message type of a signal message. */); | ||
| 1789 | Vdbus_message_type_signal = make_number (DBUS_MESSAGE_TYPE_SIGNAL); | ||
| 2293 | 1790 | ||
| 2294 | DEFVAR_LISP ("dbus-registered-objects-table", | 1791 | DEFVAR_LISP ("dbus-registered-objects-table", |
| 2295 | Vdbus_registered_objects_table, | 1792 | Vdbus_registered_objects_table, |
| @@ -2299,27 +1796,28 @@ There are two different uses of the hash table: for accessing | |||
| 2299 | registered interfaces properties, targeted by signals or method calls, | 1796 | registered interfaces properties, targeted by signals or method calls, |
| 2300 | and for calling handlers in case of non-blocking method call returns. | 1797 | and for calling handlers in case of non-blocking method call returns. |
| 2301 | 1798 | ||
| 2302 | In the first case, the key in the hash table is the list (BUS | 1799 | In the first case, the key in the hash table is the list (TYPE BUS |
| 2303 | INTERFACE MEMBER). BUS is either a Lisp symbol, `:system' or | 1800 | INTERFACE MEMBER). TYPE is one of the Lisp symbols `:method', |
| 1801 | `:signal' or `:property'. BUS is either a Lisp symbol, `:system' or | ||
| 2304 | `:session', or a string denoting the bus address. INTERFACE is a | 1802 | `:session', or a string denoting the bus address. INTERFACE is a |
| 2305 | string which denotes a D-Bus interface, and MEMBER, also a string, is | 1803 | string which denotes a D-Bus interface, and MEMBER, also a string, is |
| 2306 | either a method, a signal or a property INTERFACE is offering. All | 1804 | either a method, a signal or a property INTERFACE is offering. All |
| 2307 | arguments but BUS must not be nil. | 1805 | arguments but BUS must not be nil. |
| 2308 | 1806 | ||
| 2309 | The value in the hash table is a list of quadruple lists | 1807 | The value in the hash table is a list of quadruple lists \((UNAME |
| 2310 | \((UNAME SERVICE PATH OBJECT) (UNAME SERVICE PATH OBJECT) ...). | 1808 | SERVICE PATH OBJECT [RULE]) ...). SERVICE is the service name as |
| 2311 | SERVICE is the service name as registered, UNAME is the corresponding | 1809 | registered, UNAME is the corresponding unique name. In case of |
| 2312 | unique name. In case of registered methods and properties, UNAME is | 1810 | registered methods and properties, UNAME is nil. PATH is the object |
| 2313 | nil. PATH is the object path of the sending object. All of them can | 1811 | path of the sending object. All of them can be nil, which means a |
| 2314 | be nil, which means a wildcard then. OBJECT is either the handler to | 1812 | wildcard then. OBJECT is either the handler to be called when a D-Bus |
| 2315 | be called when a D-Bus message, which matches the key criteria, | 1813 | message, which matches the key criteria, arrives (TYPE `:method' and |
| 2316 | arrives (methods and signals), or a cons cell containing the value of | 1814 | `:signal'), or a cons cell containing the value of the property (TYPE |
| 2317 | the property. | 1815 | `:property'). |
| 2318 | 1816 | ||
| 2319 | For signals, there is also a fifth element RULE, which keeps the match | 1817 | For entries of type `:signal', there is also a fifth element RULE, |
| 2320 | string the signal is registered with. | 1818 | which keeps the match string the signal is registered with. |
| 2321 | 1819 | ||
| 2322 | In the second case, the key in the hash table is the list (BUS | 1820 | In the second case, the key in the hash table is the list (:serial BUS |
| 2323 | SERIAL). BUS is either a Lisp symbol, `:system' or `:session', or a | 1821 | SERIAL). BUS is either a Lisp symbol, `:system' or `:session', or a |
| 2324 | string denoting the bus address. SERIAL is the serial number of the | 1822 | string denoting the bus address. SERIAL is the serial number of the |
| 2325 | non-blocking method call, a reply is expected. Both arguments must | 1823 | non-blocking method call, a reply is expected. Both arguments must |
| @@ -2343,6 +1841,10 @@ be called when the D-Bus reply message arrives. */); | |||
| 2343 | Vdbus_debug = Qnil; | 1841 | Vdbus_debug = Qnil; |
| 2344 | #endif | 1842 | #endif |
| 2345 | 1843 | ||
| 1844 | /* Initialize internal objects. */ | ||
| 1845 | xd_registered_buses = Qnil; | ||
| 1846 | staticpro (&xd_registered_buses); | ||
| 1847 | |||
| 2346 | Fprovide (intern_c_string ("dbusbind"), Qnil); | 1848 | Fprovide (intern_c_string ("dbusbind"), Qnil); |
| 2347 | 1849 | ||
| 2348 | } | 1850 | } |
diff --git a/src/dispextern.h b/src/dispextern.h index 93611403649..979ade70bfc 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3243,7 +3243,6 @@ extern Window tip_window; | |||
| 3243 | EXFUN (Fx_hide_tip, 0); | 3243 | EXFUN (Fx_hide_tip, 0); |
| 3244 | extern void start_hourglass (void); | 3244 | extern void start_hourglass (void); |
| 3245 | extern void cancel_hourglass (void); | 3245 | extern void cancel_hourglass (void); |
| 3246 | extern int hourglass_started (void); | ||
| 3247 | extern int hourglass_shown_p; | 3246 | extern int hourglass_shown_p; |
| 3248 | struct atimer; /* Defined in atimer.h. */ | 3247 | struct atimer; /* Defined in atimer.h. */ |
| 3249 | /* If non-null, an asynchronous timer that, when it expires, displays | 3248 | /* If non-null, an asynchronous timer that, when it expires, displays |
diff --git a/src/dispnew.c b/src/dispnew.c index 41e6e5b8df6..d8808de3caa 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* Updating of data structures for redisplay. | 1 | /* Updating of data structures for redisplay. |
| 2 | Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc. | 2 | |
| 3 | Copyright (C) 1985-1988, 1993-1995, 1997-2012 Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -87,7 +88,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 87 | #endif | 88 | #endif |
| 88 | #endif /* not __GNU_LIBRARY__ */ | 89 | #endif /* not __GNU_LIBRARY__ */ |
| 89 | 90 | ||
| 90 | #if defined (HAVE_TERM_H) && defined (GNU_LINUX) && defined (HAVE_LIBNCURSES) | 91 | #if defined (HAVE_TERM_H) && defined (GNU_LINUX) |
| 91 | #include <term.h> /* for tgetent */ | 92 | #include <term.h> /* for tgetent */ |
| 92 | #endif | 93 | #endif |
| 93 | 94 | ||
| @@ -1085,12 +1086,16 @@ swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b) | |||
| 1085 | for (i = 0; i < LAST_AREA + 1; ++i) | 1086 | for (i = 0; i < LAST_AREA + 1; ++i) |
| 1086 | { | 1087 | { |
| 1087 | struct glyph *temp = a->glyphs[i]; | 1088 | struct glyph *temp = a->glyphs[i]; |
| 1088 | short used_tem = a->used[i]; | ||
| 1089 | 1089 | ||
| 1090 | a->glyphs[i] = b->glyphs[i]; | 1090 | a->glyphs[i] = b->glyphs[i]; |
| 1091 | b->glyphs[i] = temp; | 1091 | b->glyphs[i] = temp; |
| 1092 | a->used[i] = b->used[i]; | 1092 | if (i < LAST_AREA) |
| 1093 | b->used[i] = used_tem; | 1093 | { |
| 1094 | short used_tem = a->used[i]; | ||
| 1095 | |||
| 1096 | a->used[i] = b->used[i]; | ||
| 1097 | b->used[i] = used_tem; | ||
| 1098 | } | ||
| 1094 | } | 1099 | } |
| 1095 | a->hash = b->hash; | 1100 | a->hash = b->hash; |
| 1096 | b->hash = hash_tem; | 1101 | b->hash = hash_tem; |
| @@ -1105,7 +1110,7 @@ static inline void | |||
| 1105 | copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from) | 1110 | copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from) |
| 1106 | { | 1111 | { |
| 1107 | struct glyph *pointers[1 + LAST_AREA]; | 1112 | struct glyph *pointers[1 + LAST_AREA]; |
| 1108 | short used[1 + LAST_AREA]; | 1113 | short used[LAST_AREA]; |
| 1109 | unsigned hashval; | 1114 | unsigned hashval; |
| 1110 | 1115 | ||
| 1111 | /* Save glyph pointers of TO. */ | 1116 | /* Save glyph pointers of TO. */ |
| @@ -6308,7 +6313,7 @@ init_display (void) | |||
| 6308 | #ifdef HAVE_X11 | 6313 | #ifdef HAVE_X11 |
| 6309 | Vwindow_system_version = make_number (11); | 6314 | Vwindow_system_version = make_number (11); |
| 6310 | #endif | 6315 | #endif |
| 6311 | #if defined (GNU_LINUX) && defined (HAVE_LIBNCURSES) | 6316 | #ifdef GNU_LINUX |
| 6312 | /* In some versions of ncurses, | 6317 | /* In some versions of ncurses, |
| 6313 | tputs crashes if we have not called tgetent. | 6318 | tputs crashes if we have not called tgetent. |
| 6314 | So call tgetent. */ | 6319 | So call tgetent. */ |
diff --git a/src/editfns.c b/src/editfns.c index 7e7f82c5992..6d59b89513c 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -59,10 +59,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 59 | #include "window.h" | 59 | #include "window.h" |
| 60 | #include "blockinput.h" | 60 | #include "blockinput.h" |
| 61 | 61 | ||
| 62 | #ifndef NULL | ||
| 63 | #define NULL 0 | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #ifndef USER_FULL_NAME | 62 | #ifndef USER_FULL_NAME |
| 67 | #define USER_FULL_NAME pw->pw_gecos | 63 | #define USER_FULL_NAME pw->pw_gecos |
| 68 | #endif | 64 | #endif |
| @@ -73,20 +69,13 @@ extern char **environ; | |||
| 73 | 69 | ||
| 74 | #define TM_YEAR_BASE 1900 | 70 | #define TM_YEAR_BASE 1900 |
| 75 | 71 | ||
| 76 | /* Nonzero if TM_YEAR is a struct tm's tm_year value that causes | ||
| 77 | asctime to have well-defined behavior. */ | ||
| 78 | #ifndef TM_YEAR_IN_ASCTIME_RANGE | ||
| 79 | # define TM_YEAR_IN_ASCTIME_RANGE(tm_year) \ | ||
| 80 | (1000 - TM_YEAR_BASE <= (tm_year) && (tm_year) <= 9999 - TM_YEAR_BASE) | ||
| 81 | #endif | ||
| 82 | |||
| 83 | #ifdef WINDOWSNT | 72 | #ifdef WINDOWSNT |
| 84 | extern Lisp_Object w32_get_internal_run_time (void); | 73 | extern Lisp_Object w32_get_internal_run_time (void); |
| 85 | #endif | 74 | #endif |
| 86 | 75 | ||
| 87 | static void time_overflow (void) NO_RETURN; | 76 | static void time_overflow (void) NO_RETURN; |
| 88 | static Lisp_Object format_time_string (char const *, ptrdiff_t, Lisp_Object, | 77 | static Lisp_Object format_time_string (char const *, ptrdiff_t, Lisp_Object, |
| 89 | int, time_t *, struct tm **); | 78 | int, time_t *, struct tm *); |
| 90 | static int tm_diff (struct tm *, struct tm *); | 79 | static int tm_diff (struct tm *, struct tm *); |
| 91 | static void update_buffer_properties (ptrdiff_t, ptrdiff_t); | 80 | static void update_buffer_properties (ptrdiff_t, ptrdiff_t); |
| 92 | 81 | ||
| @@ -1691,7 +1680,7 @@ usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) | |||
| 1691 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) | 1680 | (Lisp_Object format_string, Lisp_Object timeval, Lisp_Object universal) |
| 1692 | { | 1681 | { |
| 1693 | time_t t; | 1682 | time_t t; |
| 1694 | struct tm *tm; | 1683 | struct tm tm; |
| 1695 | 1684 | ||
| 1696 | CHECK_STRING (format_string); | 1685 | CHECK_STRING (format_string); |
| 1697 | format_string = code_convert_string_norecord (format_string, | 1686 | format_string = code_convert_string_norecord (format_string, |
| @@ -1702,53 +1691,54 @@ usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */) | |||
| 1702 | 1691 | ||
| 1703 | static Lisp_Object | 1692 | static Lisp_Object |
| 1704 | format_time_string (char const *format, ptrdiff_t formatlen, | 1693 | format_time_string (char const *format, ptrdiff_t formatlen, |
| 1705 | Lisp_Object timeval, int ut, time_t *tval, struct tm **tmp) | 1694 | Lisp_Object timeval, int ut, time_t *tval, struct tm *tmp) |
| 1706 | { | 1695 | { |
| 1707 | ptrdiff_t size; | 1696 | char buffer[4000]; |
| 1697 | char *buf = buffer; | ||
| 1698 | size_t size = sizeof buffer; | ||
| 1699 | size_t len; | ||
| 1700 | Lisp_Object bufstring; | ||
| 1708 | int usec; | 1701 | int usec; |
| 1709 | int ns; | 1702 | int ns; |
| 1710 | struct tm *tm; | 1703 | struct tm *tm; |
| 1704 | USE_SAFE_ALLOCA; | ||
| 1711 | 1705 | ||
| 1712 | if (! lisp_time_argument (timeval, tval, &usec)) | 1706 | if (! lisp_time_argument (timeval, tval, &usec)) |
| 1713 | error ("Invalid time specification"); | 1707 | error ("Invalid time specification"); |
| 1714 | ns = usec * 1000; | 1708 | ns = usec * 1000; |
| 1715 | 1709 | ||
| 1716 | /* This is probably enough. */ | ||
| 1717 | size = formatlen; | ||
| 1718 | if (size <= (STRING_BYTES_BOUND - 50) / 6) | ||
| 1719 | size = size * 6 + 50; | ||
| 1720 | |||
| 1721 | BLOCK_INPUT; | ||
| 1722 | tm = ut ? gmtime (tval) : localtime (tval); | ||
| 1723 | UNBLOCK_INPUT; | ||
| 1724 | if (! tm) | ||
| 1725 | time_overflow (); | ||
| 1726 | *tmp = tm; | ||
| 1727 | |||
| 1728 | synchronize_system_time_locale (); | ||
| 1729 | |||
| 1730 | while (1) | 1710 | while (1) |
| 1731 | { | 1711 | { |
| 1732 | char *buf = (char *) alloca (size + 1); | 1712 | BLOCK_INPUT; |
| 1733 | size_t result; | 1713 | |
| 1714 | synchronize_system_time_locale (); | ||
| 1715 | |||
| 1716 | tm = ut ? gmtime (tval) : localtime (tval); | ||
| 1717 | if (! tm) | ||
| 1718 | { | ||
| 1719 | UNBLOCK_INPUT; | ||
| 1720 | time_overflow (); | ||
| 1721 | } | ||
| 1722 | *tmp = *tm; | ||
| 1734 | 1723 | ||
| 1735 | buf[0] = '\1'; | 1724 | buf[0] = '\1'; |
| 1736 | BLOCK_INPUT; | 1725 | len = emacs_nmemftime (buf, size, format, formatlen, tm, ut, ns); |
| 1737 | result = emacs_nmemftime (buf, size, format, formatlen, tm, ut, ns); | 1726 | if ((0 < len && len < size) || (len == 0 && buf[0] == '\0')) |
| 1738 | UNBLOCK_INPUT; | 1727 | break; |
| 1739 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) | ||
| 1740 | return code_convert_string_norecord (make_unibyte_string (buf, result), | ||
| 1741 | Vlocale_coding_system, 0); | ||
| 1742 | 1728 | ||
| 1743 | /* If buffer was too small, make it bigger and try again. */ | 1729 | /* Buffer was too small, so make it bigger and try again. */ |
| 1744 | BLOCK_INPUT; | 1730 | len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tm, ut, ns); |
| 1745 | result = emacs_nmemftime (NULL, (size_t) -1, format, formatlen, | ||
| 1746 | tm, ut, ns); | ||
| 1747 | UNBLOCK_INPUT; | 1731 | UNBLOCK_INPUT; |
| 1748 | if (STRING_BYTES_BOUND <= result) | 1732 | if (STRING_BYTES_BOUND <= len) |
| 1749 | string_overflow (); | 1733 | string_overflow (); |
| 1750 | size = result + 1; | 1734 | size = len + 1; |
| 1735 | SAFE_ALLOCA (buf, char *, size); | ||
| 1751 | } | 1736 | } |
| 1737 | |||
| 1738 | UNBLOCK_INPUT; | ||
| 1739 | bufstring = make_unibyte_string (buf, len); | ||
| 1740 | SAFE_FREE (); | ||
| 1741 | return code_convert_string_norecord (bufstring, Vlocale_coding_system, 0); | ||
| 1752 | } | 1742 | } |
| 1753 | 1743 | ||
| 1754 | DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0, | 1744 | DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 1, 0, |
| @@ -1778,31 +1768,32 @@ DOW and ZONE.) */) | |||
| 1778 | 1768 | ||
| 1779 | BLOCK_INPUT; | 1769 | BLOCK_INPUT; |
| 1780 | decoded_time = localtime (&time_spec); | 1770 | decoded_time = localtime (&time_spec); |
| 1771 | /* Make a copy, in case a signal handler modifies TZ or the struct. */ | ||
| 1772 | if (decoded_time) | ||
| 1773 | save_tm = *decoded_time; | ||
| 1781 | UNBLOCK_INPUT; | 1774 | UNBLOCK_INPUT; |
| 1782 | if (! (decoded_time | 1775 | if (! (decoded_time |
| 1783 | && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= decoded_time->tm_year | 1776 | && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= save_tm.tm_year |
| 1784 | && decoded_time->tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE)) | 1777 | && save_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE)) |
| 1785 | time_overflow (); | 1778 | time_overflow (); |
| 1786 | XSETFASTINT (list_args[0], decoded_time->tm_sec); | 1779 | XSETFASTINT (list_args[0], save_tm.tm_sec); |
| 1787 | XSETFASTINT (list_args[1], decoded_time->tm_min); | 1780 | XSETFASTINT (list_args[1], save_tm.tm_min); |
| 1788 | XSETFASTINT (list_args[2], decoded_time->tm_hour); | 1781 | XSETFASTINT (list_args[2], save_tm.tm_hour); |
| 1789 | XSETFASTINT (list_args[3], decoded_time->tm_mday); | 1782 | XSETFASTINT (list_args[3], save_tm.tm_mday); |
| 1790 | XSETFASTINT (list_args[4], decoded_time->tm_mon + 1); | 1783 | XSETFASTINT (list_args[4], save_tm.tm_mon + 1); |
| 1791 | /* On 64-bit machines an int is narrower than EMACS_INT, thus the | 1784 | /* On 64-bit machines an int is narrower than EMACS_INT, thus the |
| 1792 | cast below avoids overflow in int arithmetics. */ | 1785 | cast below avoids overflow in int arithmetics. */ |
| 1793 | XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) decoded_time->tm_year); | 1786 | XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) save_tm.tm_year); |
| 1794 | XSETFASTINT (list_args[6], decoded_time->tm_wday); | 1787 | XSETFASTINT (list_args[6], save_tm.tm_wday); |
| 1795 | list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; | 1788 | list_args[7] = save_tm.tm_isdst ? Qt : Qnil; |
| 1796 | 1789 | ||
| 1797 | /* Make a copy, in case gmtime modifies the struct. */ | ||
| 1798 | save_tm = *decoded_time; | ||
| 1799 | BLOCK_INPUT; | 1790 | BLOCK_INPUT; |
| 1800 | decoded_time = gmtime (&time_spec); | 1791 | decoded_time = gmtime (&time_spec); |
| 1801 | UNBLOCK_INPUT; | ||
| 1802 | if (decoded_time == 0) | 1792 | if (decoded_time == 0) |
| 1803 | list_args[8] = Qnil; | 1793 | list_args[8] = Qnil; |
| 1804 | else | 1794 | else |
| 1805 | XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); | 1795 | XSETINT (list_args[8], tm_diff (&save_tm, decoded_time)); |
| 1796 | UNBLOCK_INPUT; | ||
| 1806 | return Flist (9, list_args); | 1797 | return Flist (9, list_args); |
| 1807 | } | 1798 | } |
| 1808 | 1799 | ||
| @@ -1887,21 +1878,23 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1887 | else | 1878 | else |
| 1888 | error ("Invalid time zone specification"); | 1879 | error ("Invalid time zone specification"); |
| 1889 | 1880 | ||
| 1881 | BLOCK_INPUT; | ||
| 1882 | |||
| 1890 | /* Set TZ before calling mktime; merely adjusting mktime's returned | 1883 | /* Set TZ before calling mktime; merely adjusting mktime's returned |
| 1891 | value doesn't suffice, since that would mishandle leap seconds. */ | 1884 | value doesn't suffice, since that would mishandle leap seconds. */ |
| 1892 | set_time_zone_rule (tzstring); | 1885 | set_time_zone_rule (tzstring); |
| 1893 | 1886 | ||
| 1894 | BLOCK_INPUT; | ||
| 1895 | value = mktime (&tm); | 1887 | value = mktime (&tm); |
| 1896 | UNBLOCK_INPUT; | ||
| 1897 | 1888 | ||
| 1898 | /* Restore TZ to previous value. */ | 1889 | /* Restore TZ to previous value. */ |
| 1899 | newenv = environ; | 1890 | newenv = environ; |
| 1900 | environ = oldenv; | 1891 | environ = oldenv; |
| 1901 | xfree (newenv); | ||
| 1902 | #ifdef LOCALTIME_CACHE | 1892 | #ifdef LOCALTIME_CACHE |
| 1903 | tzset (); | 1893 | tzset (); |
| 1904 | #endif | 1894 | #endif |
| 1895 | UNBLOCK_INPUT; | ||
| 1896 | |||
| 1897 | xfree (newenv); | ||
| 1905 | } | 1898 | } |
| 1906 | 1899 | ||
| 1907 | if (value == (time_t) -1) | 1900 | if (value == (time_t) -1) |
| @@ -1928,24 +1921,37 @@ but this is considered obsolete. */) | |||
| 1928 | { | 1921 | { |
| 1929 | time_t value; | 1922 | time_t value; |
| 1930 | struct tm *tm; | 1923 | struct tm *tm; |
| 1931 | register char *tem; | 1924 | char buf[sizeof "Mon Apr 30 12:49:17 " + INT_STRLEN_BOUND (int) + 1]; |
| 1925 | int len IF_LINT (= 0); | ||
| 1932 | 1926 | ||
| 1933 | if (! lisp_time_argument (specified_time, &value, NULL)) | 1927 | if (! lisp_time_argument (specified_time, &value, NULL)) |
| 1934 | error ("Invalid time specification"); | 1928 | error ("Invalid time specification"); |
| 1935 | 1929 | ||
| 1936 | /* Convert to a string, checking for out-of-range time stamps. | 1930 | /* Convert to a string in ctime format, except without the trailing |
| 1937 | Don't use 'ctime', as that might dump core if VALUE is out of | 1931 | newline, and without the 4-digit year limit. Don't use asctime |
| 1938 | range. */ | 1932 | or ctime, as they might dump core if the year is outside the |
| 1933 | range -999 .. 9999. */ | ||
| 1939 | BLOCK_INPUT; | 1934 | BLOCK_INPUT; |
| 1940 | tm = localtime (&value); | 1935 | tm = localtime (&value); |
| 1936 | if (tm) | ||
| 1937 | { | ||
| 1938 | static char const wday_name[][4] = | ||
| 1939 | { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; | ||
| 1940 | static char const mon_name[][4] = | ||
| 1941 | { "Jan", "Feb", "Mar", "Apr", "May", "Jun", | ||
| 1942 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; | ||
| 1943 | printmax_t year_base = TM_YEAR_BASE; | ||
| 1944 | |||
| 1945 | len = sprintf (buf, "%s %s%3d %02d:%02d:%02d %"pMd, | ||
| 1946 | wday_name[tm->tm_wday], mon_name[tm->tm_mon], tm->tm_mday, | ||
| 1947 | tm->tm_hour, tm->tm_min, tm->tm_sec, | ||
| 1948 | tm->tm_year + year_base); | ||
| 1949 | } | ||
| 1941 | UNBLOCK_INPUT; | 1950 | UNBLOCK_INPUT; |
| 1942 | if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) && (tem = asctime (tm)))) | 1951 | if (! tm) |
| 1943 | time_overflow (); | 1952 | time_overflow (); |
| 1944 | 1953 | ||
| 1945 | /* Remove the trailing newline. */ | 1954 | return make_unibyte_string (buf, len); |
| 1946 | tem[strlen (tem) - 1] = '\0'; | ||
| 1947 | |||
| 1948 | return build_string (tem); | ||
| 1949 | } | 1955 | } |
| 1950 | 1956 | ||
| 1951 | /* Yield A - B, measured in seconds. | 1957 | /* Yield A - B, measured in seconds. |
| @@ -1989,22 +1995,22 @@ the data it can't find. */) | |||
| 1989 | (Lisp_Object specified_time) | 1995 | (Lisp_Object specified_time) |
| 1990 | { | 1996 | { |
| 1991 | time_t value; | 1997 | time_t value; |
| 1998 | int offset; | ||
| 1992 | struct tm *t; | 1999 | struct tm *t; |
| 1993 | struct tm localtm; | 2000 | struct tm localtm; |
| 1994 | struct tm *localt; | ||
| 1995 | Lisp_Object zone_offset, zone_name; | 2001 | Lisp_Object zone_offset, zone_name; |
| 1996 | 2002 | ||
| 1997 | zone_offset = Qnil; | 2003 | zone_offset = Qnil; |
| 1998 | zone_name = format_time_string ("%Z", sizeof "%Z" - 1, specified_time, | 2004 | zone_name = format_time_string ("%Z", sizeof "%Z" - 1, specified_time, |
| 1999 | 0, &value, &localt); | 2005 | 0, &value, &localtm); |
| 2000 | localtm = *localt; | ||
| 2001 | BLOCK_INPUT; | 2006 | BLOCK_INPUT; |
| 2002 | t = gmtime (&value); | 2007 | t = gmtime (&value); |
| 2008 | if (t) | ||
| 2009 | offset = tm_diff (&localtm, t); | ||
| 2003 | UNBLOCK_INPUT; | 2010 | UNBLOCK_INPUT; |
| 2004 | 2011 | ||
| 2005 | if (t) | 2012 | if (t) |
| 2006 | { | 2013 | { |
| 2007 | int offset = tm_diff (&localtm, t); | ||
| 2008 | zone_offset = make_number (offset); | 2014 | zone_offset = make_number (offset); |
| 2009 | if (SCHARS (zone_name) == 0) | 2015 | if (SCHARS (zone_name) == 0) |
| 2010 | { | 2016 | { |
| @@ -2042,9 +2048,16 @@ only the former. */) | |||
| 2042 | (Lisp_Object tz) | 2048 | (Lisp_Object tz) |
| 2043 | { | 2049 | { |
| 2044 | const char *tzstring; | 2050 | const char *tzstring; |
| 2051 | char **old_environbuf; | ||
| 2052 | |||
| 2053 | if (! (NILP (tz) || EQ (tz, Qt))) | ||
| 2054 | CHECK_STRING (tz); | ||
| 2055 | |||
| 2056 | BLOCK_INPUT; | ||
| 2045 | 2057 | ||
| 2046 | /* When called for the first time, save the original TZ. */ | 2058 | /* When called for the first time, save the original TZ. */ |
| 2047 | if (!environbuf) | 2059 | old_environbuf = environbuf; |
| 2060 | if (!old_environbuf) | ||
| 2048 | initial_tz = (char *) getenv ("TZ"); | 2061 | initial_tz = (char *) getenv ("TZ"); |
| 2049 | 2062 | ||
| 2050 | if (NILP (tz)) | 2063 | if (NILP (tz)) |
| @@ -2052,15 +2065,14 @@ only the former. */) | |||
| 2052 | else if (EQ (tz, Qt)) | 2065 | else if (EQ (tz, Qt)) |
| 2053 | tzstring = "UTC0"; | 2066 | tzstring = "UTC0"; |
| 2054 | else | 2067 | else |
| 2055 | { | 2068 | tzstring = SSDATA (tz); |
| 2056 | CHECK_STRING (tz); | ||
| 2057 | tzstring = SSDATA (tz); | ||
| 2058 | } | ||
| 2059 | 2069 | ||
| 2060 | set_time_zone_rule (tzstring); | 2070 | set_time_zone_rule (tzstring); |
| 2061 | xfree (environbuf); | ||
| 2062 | environbuf = environ; | 2071 | environbuf = environ; |
| 2063 | 2072 | ||
| 2073 | UNBLOCK_INPUT; | ||
| 2074 | |||
| 2075 | xfree (old_environbuf); | ||
| 2064 | return Qnil; | 2076 | return Qnil; |
| 2065 | } | 2077 | } |
| 2066 | 2078 | ||
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c index fba672ff74d..1a62b59b7af 100644 --- a/src/emacsgtkfixed.c +++ b/src/emacsgtkfixed.c | |||
| @@ -28,6 +28,27 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 28 | #include "frame.h" | 28 | #include "frame.h" |
| 29 | #include "xterm.h" | 29 | #include "xterm.h" |
| 30 | 30 | ||
| 31 | #define EMACS_TYPE_FIXED emacs_fixed_get_type () | ||
| 32 | #define EMACS_FIXED(obj) \ | ||
| 33 | G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed) | ||
| 34 | |||
| 35 | typedef struct _EmacsFixed EmacsFixed; | ||
| 36 | typedef struct _EmacsFixedPrivate EmacsFixedPrivate; | ||
| 37 | typedef struct _EmacsFixedClass EmacsFixedClass; | ||
| 38 | |||
| 39 | struct _EmacsFixed | ||
| 40 | { | ||
| 41 | GtkFixed container; | ||
| 42 | |||
| 43 | /*< private >*/ | ||
| 44 | EmacsFixedPrivate *priv; | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct _EmacsFixedClass | ||
| 48 | { | ||
| 49 | GtkFixedClass parent_class; | ||
| 50 | }; | ||
| 51 | |||
| 31 | struct _EmacsFixedPrivate | 52 | struct _EmacsFixedPrivate |
| 32 | { | 53 | { |
| 33 | struct frame *f; | 54 | struct frame *f; |
| @@ -40,28 +61,21 @@ static void emacs_fixed_get_preferred_width (GtkWidget *widget, | |||
| 40 | static void emacs_fixed_get_preferred_height (GtkWidget *widget, | 61 | static void emacs_fixed_get_preferred_height (GtkWidget *widget, |
| 41 | gint *minimum, | 62 | gint *minimum, |
| 42 | gint *natural); | 63 | gint *natural); |
| 64 | static GType emacs_fixed_get_type (void); | ||
| 43 | G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) | 65 | G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) |
| 44 | 66 | ||
| 45 | static void | 67 | static void |
| 46 | emacs_fixed_class_init (EmacsFixedClass *klass) | 68 | emacs_fixed_class_init (EmacsFixedClass *klass) |
| 47 | { | 69 | { |
| 48 | GtkWidgetClass *widget_class; | 70 | GtkWidgetClass *widget_class; |
| 49 | GtkFixedClass *fixed_class; | ||
| 50 | 71 | ||
| 51 | widget_class = (GtkWidgetClass*) klass; | 72 | widget_class = (GtkWidgetClass*) klass; |
| 52 | fixed_class = (GtkFixedClass*) klass; | ||
| 53 | 73 | ||
| 54 | widget_class->get_preferred_width = emacs_fixed_get_preferred_width; | 74 | widget_class->get_preferred_width = emacs_fixed_get_preferred_width; |
| 55 | widget_class->get_preferred_height = emacs_fixed_get_preferred_height; | 75 | widget_class->get_preferred_height = emacs_fixed_get_preferred_height; |
| 56 | g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); | 76 | g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); |
| 57 | } | 77 | } |
| 58 | 78 | ||
| 59 | static GType | ||
| 60 | emacs_fixed_child_type (GtkFixed *container) | ||
| 61 | { | ||
| 62 | return GTK_TYPE_WIDGET; | ||
| 63 | } | ||
| 64 | |||
| 65 | static void | 79 | static void |
| 66 | emacs_fixed_init (EmacsFixed *fixed) | 80 | emacs_fixed_init (EmacsFixed *fixed) |
| 67 | { | 81 | { |
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h index 90fb37e521b..3fa294aa41e 100644 --- a/src/emacsgtkfixed.h +++ b/src/emacsgtkfixed.h | |||
| @@ -27,33 +27,7 @@ G_BEGIN_DECLS | |||
| 27 | 27 | ||
| 28 | struct frame; | 28 | struct frame; |
| 29 | 29 | ||
| 30 | #define EMACS_TYPE_FIXED (emacs_fixed_get_type ()) | ||
| 31 | #define EMACS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMACS_TYPE_FIXED, EmacsFixed)) | ||
| 32 | #define EMACS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMACS_TYPE_FIXED, EmacsFixedClass)) | ||
| 33 | #define EMACS_IS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMACS_TYPE_FIXED)) | ||
| 34 | #define EMACS_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMACS_TYPE_FIXED)) | ||
| 35 | #define EMACS_FIXED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMACS_TYPE_FIXED, EmacsFixedClass)) | ||
| 36 | |||
| 37 | typedef struct _EmacsFixed EmacsFixed; | ||
| 38 | typedef struct _EmacsFixedPrivate EmacsFixedPrivate; | ||
| 39 | typedef struct _EmacsFixedClass EmacsFixedClass; | ||
| 40 | |||
| 41 | struct _EmacsFixed | ||
| 42 | { | ||
| 43 | GtkFixed container; | ||
| 44 | |||
| 45 | /*< private >*/ | ||
| 46 | EmacsFixedPrivate *priv; | ||
| 47 | }; | ||
| 48 | |||
| 49 | |||
| 50 | struct _EmacsFixedClass | ||
| 51 | { | ||
| 52 | GtkFixedClass parent_class; | ||
| 53 | }; | ||
| 54 | |||
| 55 | extern GtkWidget *emacs_fixed_new (struct frame *f); | 30 | extern GtkWidget *emacs_fixed_new (struct frame *f); |
| 56 | extern GType emacs_fixed_get_type (void); | ||
| 57 | 31 | ||
| 58 | G_END_DECLS | 32 | G_END_DECLS |
| 59 | 33 | ||
diff --git a/src/eval.c b/src/eval.c index d266d995c4b..e44b7e32915 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -2020,7 +2020,7 @@ this does nothing and returns nil. */) | |||
| 2020 | We used to use 0 here, but that leads to accidental sharing in | 2020 | We used to use 0 here, but that leads to accidental sharing in |
| 2021 | purecopy's hash-consing, so we use a (hopefully) unique integer | 2021 | purecopy's hash-consing, so we use a (hopefully) unique integer |
| 2022 | instead. */ | 2022 | instead. */ |
| 2023 | docstring = make_number (XPNTR (function)); | 2023 | docstring = make_number (XUNTAG (function, Lisp_Symbol)); |
| 2024 | return Ffset (function, | 2024 | return Ffset (function, |
| 2025 | Fpurecopy (list5 (Qautoload, file, docstring, | 2025 | Fpurecopy (list5 (Qautoload, file, docstring, |
| 2026 | interactive, type))); | 2026 | interactive, type))); |
diff --git a/src/fileio.c b/src/fileio.c index c5442d560fd..c6e2eea5089 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* File IO for GNU Emacs. | 1 | /* File IO for GNU Emacs. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1988, 1993-2012 Free Software Foundation, Inc. | 3 | Copyright (C) 1985-1988, 1993-2012 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 6 | 6 | ||
| @@ -87,17 +87,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 87 | #define FILE_SYSTEM_CASE(filename) (filename) | 87 | #define FILE_SYSTEM_CASE(filename) (filename) |
| 88 | #endif | 88 | #endif |
| 89 | 89 | ||
| 90 | /* Nonzero during writing of auto-save files */ | 90 | /* Nonzero during writing of auto-save files. */ |
| 91 | static int auto_saving; | 91 | static int auto_saving; |
| 92 | 92 | ||
| 93 | /* Nonzero umask during creation of auto-save directories */ | 93 | /* Nonzero umask during creation of auto-save directories. */ |
| 94 | static int auto_saving_dir_umask; | 94 | static int auto_saving_dir_umask; |
| 95 | 95 | ||
| 96 | /* Set by auto_save_1 to mode of original file so Fwrite_region will create | 96 | /* Set by auto_save_1 to mode of original file so Fwrite_region will create |
| 97 | a new file with the same mode as the original */ | 97 | a new file with the same mode as the original. */ |
| 98 | static int auto_save_mode_bits; | 98 | static int auto_save_mode_bits; |
| 99 | 99 | ||
| 100 | /* Set by auto_save_1 if an error occurred during the last auto-save. */ | 100 | /* Set by auto_save_1 if an error occurred during the last auto-save. */ |
| 101 | static int auto_save_error_occurred; | 101 | static int auto_save_error_occurred; |
| 102 | 102 | ||
| 103 | /* The symbol bound to coding-system-for-read when | 103 | /* The symbol bound to coding-system-for-read when |
| @@ -111,7 +111,7 @@ static Lisp_Object Qauto_save_coding; | |||
| 111 | which gives a list of operations it handles.. */ | 111 | which gives a list of operations it handles.. */ |
| 112 | static Lisp_Object Qoperations; | 112 | static Lisp_Object Qoperations; |
| 113 | 113 | ||
| 114 | /* Lisp functions for translating file formats */ | 114 | /* Lisp functions for translating file formats. */ |
| 115 | static Lisp_Object Qformat_decode, Qformat_annotate_function; | 115 | static Lisp_Object Qformat_decode, Qformat_annotate_function; |
| 116 | 116 | ||
| 117 | /* Lisp function for setting buffer-file-coding-system and the | 117 | /* Lisp function for setting buffer-file-coding-system and the |
| @@ -877,7 +877,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 877 | } | 877 | } |
| 878 | } | 878 | } |
| 879 | 879 | ||
| 880 | /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ | 880 | /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ |
| 881 | nm = (char *) alloca (SBYTES (name) + 1); | 881 | nm = (char *) alloca (SBYTES (name) + 1); |
| 882 | memcpy (nm, SSDATA (name), SBYTES (name) + 1); | 882 | memcpy (nm, SSDATA (name), SBYTES (name) + 1); |
| 883 | 883 | ||
| @@ -905,7 +905,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 905 | if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) | 905 | if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) |
| 906 | nm++; | 906 | nm++; |
| 907 | 907 | ||
| 908 | /* Discard any previous drive specifier if nm is now in UNC format. */ | 908 | /* Discard any previous drive specifier if nm is now in UNC format. */ |
| 909 | if (IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) | 909 | if (IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) |
| 910 | { | 910 | { |
| 911 | drive = 0; | 911 | drive = 0; |
| @@ -970,7 +970,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 970 | } | 970 | } |
| 971 | else | 971 | else |
| 972 | #endif | 972 | #endif |
| 973 | /* drive must be set, so this is okay */ | 973 | /* Drive must be set, so this is okay. */ |
| 974 | if (strcmp (nm - 2, SSDATA (name)) != 0) | 974 | if (strcmp (nm - 2, SSDATA (name)) != 0) |
| 975 | { | 975 | { |
| 976 | char temp[] = " :"; | 976 | char temp[] = " :"; |
| @@ -1016,7 +1016,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1016 | if (!(newdir = egetenv ("HOME"))) | 1016 | if (!(newdir = egetenv ("HOME"))) |
| 1017 | newdir = ""; | 1017 | newdir = ""; |
| 1018 | nm++; | 1018 | nm++; |
| 1019 | /* egetenv may return a unibyte string, which will bite us since | 1019 | /* `egetenv' may return a unibyte string, which will bite us since |
| 1020 | we expect the directory to be multibyte. */ | 1020 | we expect the directory to be multibyte. */ |
| 1021 | tem = build_string (newdir); | 1021 | tem = build_string (newdir); |
| 1022 | if (!STRING_MULTIBYTE (tem)) | 1022 | if (!STRING_MULTIBYTE (tem)) |
| @@ -1058,7 +1058,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1058 | use the drive's current directory as the prefix if needed. */ | 1058 | use the drive's current directory as the prefix if needed. */ |
| 1059 | if (!newdir && drive) | 1059 | if (!newdir && drive) |
| 1060 | { | 1060 | { |
| 1061 | /* Get default directory if needed to make nm absolute. */ | 1061 | /* Get default directory if needed to make nm absolute. */ |
| 1062 | char *adir = NULL; | 1062 | char *adir = NULL; |
| 1063 | if (!IS_DIRECTORY_SEP (nm[0])) | 1063 | if (!IS_DIRECTORY_SEP (nm[0])) |
| 1064 | { | 1064 | { |
| @@ -1068,7 +1068,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1068 | } | 1068 | } |
| 1069 | if (!adir) | 1069 | if (!adir) |
| 1070 | { | 1070 | { |
| 1071 | /* Either nm starts with /, or drive isn't mounted. */ | 1071 | /* Either nm starts with /, or drive isn't mounted. */ |
| 1072 | adir = alloca (4); | 1072 | adir = alloca (4); |
| 1073 | adir[0] = DRIVE_LETTER (drive); | 1073 | adir[0] = DRIVE_LETTER (drive); |
| 1074 | adir[1] = ':'; | 1074 | adir[1] = ':'; |
| @@ -1080,11 +1080,11 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1080 | #endif /* DOS_NT */ | 1080 | #endif /* DOS_NT */ |
| 1081 | 1081 | ||
| 1082 | /* Finally, if no prefix has been specified and nm is not absolute, | 1082 | /* Finally, if no prefix has been specified and nm is not absolute, |
| 1083 | then it must be expanded relative to default_directory. */ | 1083 | then it must be expanded relative to default_directory. */ |
| 1084 | 1084 | ||
| 1085 | if (1 | 1085 | if (1 |
| 1086 | #ifndef DOS_NT | 1086 | #ifndef DOS_NT |
| 1087 | /* /... alone is not absolute on DOS and Windows. */ | 1087 | /* /... alone is not absolute on DOS and Windows. */ |
| 1088 | && !IS_DIRECTORY_SEP (nm[0]) | 1088 | && !IS_DIRECTORY_SEP (nm[0]) |
| 1089 | #endif | 1089 | #endif |
| 1090 | #ifdef WINDOWSNT | 1090 | #ifdef WINDOWSNT |
| @@ -1106,7 +1106,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1106 | #ifdef DOS_NT | 1106 | #ifdef DOS_NT |
| 1107 | if (newdir) | 1107 | if (newdir) |
| 1108 | { | 1108 | { |
| 1109 | /* First ensure newdir is an absolute name. */ | 1109 | /* First ensure newdir is an absolute name. */ |
| 1110 | if ( | 1110 | if ( |
| 1111 | /* Detect MSDOS file names with drive specifiers. */ | 1111 | /* Detect MSDOS file names with drive specifiers. */ |
| 1112 | ! (IS_DRIVE (newdir[0]) | 1112 | ! (IS_DRIVE (newdir[0]) |
| @@ -1121,7 +1121,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1121 | Because of the admonition against calling expand-file-name | 1121 | Because of the admonition against calling expand-file-name |
| 1122 | when we have pointers into lisp strings, we accomplish this | 1122 | when we have pointers into lisp strings, we accomplish this |
| 1123 | indirectly by prepending newdir to nm if necessary, and using | 1123 | indirectly by prepending newdir to nm if necessary, and using |
| 1124 | cwd (or the wd of newdir's drive) as the new newdir. */ | 1124 | cwd (or the wd of newdir's drive) as the new newdir. */ |
| 1125 | char *adir; | 1125 | char *adir; |
| 1126 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) | 1126 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) |
| 1127 | { | 1127 | { |
| @@ -1146,7 +1146,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1146 | newdir = adir; | 1146 | newdir = adir; |
| 1147 | } | 1147 | } |
| 1148 | 1148 | ||
| 1149 | /* Strip off drive name from prefix, if present. */ | 1149 | /* Strip off drive name from prefix, if present. */ |
| 1150 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) | 1150 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) |
| 1151 | { | 1151 | { |
| 1152 | drive = newdir[0]; | 1152 | drive = newdir[0]; |
| @@ -1196,7 +1196,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1196 | else | 1196 | else |
| 1197 | tlen = 0; | 1197 | tlen = 0; |
| 1198 | 1198 | ||
| 1199 | /* Now concatenate the directory and name to new space in the stack frame */ | 1199 | /* Now concatenate the directory and name to new space in the stack frame. */ |
| 1200 | tlen += strlen (nm) + 1; | 1200 | tlen += strlen (nm) + 1; |
| 1201 | #ifdef DOS_NT | 1201 | #ifdef DOS_NT |
| 1202 | /* Reserve space for drive specifier and escape prefix, since either | 1202 | /* Reserve space for drive specifier and escape prefix, since either |
| @@ -1292,7 +1292,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1292 | } | 1292 | } |
| 1293 | 1293 | ||
| 1294 | #ifdef DOS_NT | 1294 | #ifdef DOS_NT |
| 1295 | /* At last, set drive name. */ | 1295 | /* At last, set drive name. */ |
| 1296 | #ifdef WINDOWSNT | 1296 | #ifdef WINDOWSNT |
| 1297 | /* Except for network file name. */ | 1297 | /* Except for network file name. */ |
| 1298 | if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) | 1298 | if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) |
| @@ -1320,7 +1320,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1320 | and perhaps call the corresponding file handler. This is needed | 1320 | and perhaps call the corresponding file handler. This is needed |
| 1321 | for filenames such as "/foo/../user@host:/bar/../baz". Expanding | 1321 | for filenames such as "/foo/../user@host:/bar/../baz". Expanding |
| 1322 | the ".." component gives us "/user@host:/bar/../baz" which needs | 1322 | the ".." component gives us "/user@host:/bar/../baz" which needs |
| 1323 | to be expanded again. */ | 1323 | to be expanded again. */ |
| 1324 | handler = Ffind_file_name_handler (result, Qexpand_file_name); | 1324 | handler = Ffind_file_name_handler (result, Qexpand_file_name); |
| 1325 | if (!NILP (handler)) | 1325 | if (!NILP (handler)) |
| 1326 | { | 1326 | { |
| @@ -1396,7 +1396,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1396 | } | 1396 | } |
| 1397 | } | 1397 | } |
| 1398 | 1398 | ||
| 1399 | /* Now determine directory to start with and put it in NEWDIR */ | 1399 | /* Now determine directory to start with and put it in NEWDIR. */ |
| 1400 | 1400 | ||
| 1401 | newdir = 0; | 1401 | newdir = 0; |
| 1402 | 1402 | ||
| @@ -1409,17 +1409,17 @@ See also the function `substitute-in-file-name'.") | |||
| 1409 | } | 1409 | } |
| 1410 | else /* ~user/filename */ | 1410 | else /* ~user/filename */ |
| 1411 | { | 1411 | { |
| 1412 | /* Get past ~ to user */ | 1412 | /* Get past ~ to user. */ |
| 1413 | unsigned char *user = nm + 1; | 1413 | unsigned char *user = nm + 1; |
| 1414 | /* Find end of name. */ | 1414 | /* Find end of name. */ |
| 1415 | unsigned char *ptr = (unsigned char *) strchr (user, '/'); | 1415 | unsigned char *ptr = (unsigned char *) strchr (user, '/'); |
| 1416 | ptrdiff_t len = ptr ? ptr - user : strlen (user); | 1416 | ptrdiff_t len = ptr ? ptr - user : strlen (user); |
| 1417 | /* Copy the user name into temp storage. */ | 1417 | /* Copy the user name into temp storage. */ |
| 1418 | o = (unsigned char *) alloca (len + 1); | 1418 | o = (unsigned char *) alloca (len + 1); |
| 1419 | memcpy (o, user, len); | 1419 | memcpy (o, user, len); |
| 1420 | o[len] = 0; | 1420 | o[len] = 0; |
| 1421 | 1421 | ||
| 1422 | /* Look up the user name. */ | 1422 | /* Look up the user name. */ |
| 1423 | BLOCK_INPUT; | 1423 | BLOCK_INPUT; |
| 1424 | pw = (struct passwd *) getpwnam (o + 1); | 1424 | pw = (struct passwd *) getpwnam (o + 1); |
| 1425 | UNBLOCK_INPUT; | 1425 | UNBLOCK_INPUT; |
| @@ -1440,7 +1440,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1440 | newdir = SDATA (defalt); | 1440 | newdir = SDATA (defalt); |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | /* Now concatenate the directory and name to new space in the stack frame */ | 1443 | /* Now concatenate the directory and name to new space in the stack frame. */ |
| 1444 | 1444 | ||
| 1445 | tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; | 1445 | tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; |
| 1446 | target = (unsigned char *) alloca (tlen); | 1446 | target = (unsigned char *) alloca (tlen); |
| @@ -1456,7 +1456,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1456 | 1456 | ||
| 1457 | strcat (target, nm); | 1457 | strcat (target, nm); |
| 1458 | 1458 | ||
| 1459 | /* Now canonicalize by removing /. and /foo/.. if they appear */ | 1459 | /* Now canonicalize by removing /. and /foo/.. if they appear. */ |
| 1460 | 1460 | ||
| 1461 | p = target; | 1461 | p = target; |
| 1462 | o = target; | 1462 | o = target; |
| @@ -1528,7 +1528,7 @@ search_embedded_absfilename (char *nm, char *endp) | |||
| 1528 | ) | 1528 | ) |
| 1529 | { | 1529 | { |
| 1530 | for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++); | 1530 | for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++); |
| 1531 | if (p[0] == '~' && s > p + 1) /* we've got "/~something/" */ | 1531 | if (p[0] == '~' && s > p + 1) /* We've got "/~something/". */ |
| 1532 | { | 1532 | { |
| 1533 | char *o = alloca (s - p + 1); | 1533 | char *o = alloca (s - p + 1); |
| 1534 | struct passwd *pw; | 1534 | struct passwd *pw; |
| @@ -1612,7 +1612,7 @@ those `/' is discarded. */) | |||
| 1612 | (make_specified_string (p, -1, endp - p, multibyte)); | 1612 | (make_specified_string (p, -1, endp - p, multibyte)); |
| 1613 | 1613 | ||
| 1614 | /* See if any variables are substituted into the string | 1614 | /* See if any variables are substituted into the string |
| 1615 | and find the total length of their values in `total' */ | 1615 | and find the total length of their values in `total'. */ |
| 1616 | 1616 | ||
| 1617 | for (p = nm; p != endp;) | 1617 | for (p = nm; p != endp;) |
| 1618 | if (*p != '$') | 1618 | if (*p != '$') |
| @@ -1624,7 +1624,7 @@ those `/' is discarded. */) | |||
| 1624 | goto badsubst; | 1624 | goto badsubst; |
| 1625 | else if (*p == '$') | 1625 | else if (*p == '$') |
| 1626 | { | 1626 | { |
| 1627 | /* "$$" means a single "$" */ | 1627 | /* "$$" means a single "$". */ |
| 1628 | p++; | 1628 | p++; |
| 1629 | total -= 1; | 1629 | total -= 1; |
| 1630 | substituted = 1; | 1630 | substituted = 1; |
| @@ -1644,7 +1644,7 @@ those `/' is discarded. */) | |||
| 1644 | s = p; | 1644 | s = p; |
| 1645 | } | 1645 | } |
| 1646 | 1646 | ||
| 1647 | /* Copy out the variable name */ | 1647 | /* Copy out the variable name. */ |
| 1648 | target = (char *) alloca (s - o + 1); | 1648 | target = (char *) alloca (s - o + 1); |
| 1649 | strncpy (target, o, s - o); | 1649 | strncpy (target, o, s - o); |
| 1650 | target[s - o] = 0; | 1650 | target[s - o] = 0; |
| @@ -1652,7 +1652,7 @@ those `/' is discarded. */) | |||
| 1652 | strupr (target); /* $home == $HOME etc. */ | 1652 | strupr (target); /* $home == $HOME etc. */ |
| 1653 | #endif /* DOS_NT */ | 1653 | #endif /* DOS_NT */ |
| 1654 | 1654 | ||
| 1655 | /* Get variable value */ | 1655 | /* Get variable value. */ |
| 1656 | o = egetenv (target); | 1656 | o = egetenv (target); |
| 1657 | if (o) | 1657 | if (o) |
| 1658 | { | 1658 | { |
| @@ -1674,12 +1674,12 @@ those `/' is discarded. */) | |||
| 1674 | if (!substituted) | 1674 | if (!substituted) |
| 1675 | return filename; | 1675 | return filename; |
| 1676 | 1676 | ||
| 1677 | /* If substitution required, recopy the string and do it */ | 1677 | /* If substitution required, recopy the string and do it. */ |
| 1678 | /* Make space in stack frame for the new copy */ | 1678 | /* Make space in stack frame for the new copy. */ |
| 1679 | xnm = (char *) alloca (SBYTES (filename) + total + 1); | 1679 | xnm = (char *) alloca (SBYTES (filename) + total + 1); |
| 1680 | x = xnm; | 1680 | x = xnm; |
| 1681 | 1681 | ||
| 1682 | /* Copy the rest of the name through, replacing $ constructs with values */ | 1682 | /* Copy the rest of the name through, replacing $ constructs with values. */ |
| 1683 | for (p = nm; *p;) | 1683 | for (p = nm; *p;) |
| 1684 | if (*p != '$') | 1684 | if (*p != '$') |
| 1685 | *x++ = *p++; | 1685 | *x++ = *p++; |
| @@ -1707,7 +1707,7 @@ those `/' is discarded. */) | |||
| 1707 | s = p; | 1707 | s = p; |
| 1708 | } | 1708 | } |
| 1709 | 1709 | ||
| 1710 | /* Copy out the variable name */ | 1710 | /* Copy out the variable name. */ |
| 1711 | target = (char *) alloca (s - o + 1); | 1711 | target = (char *) alloca (s - o + 1); |
| 1712 | strncpy (target, o, s - o); | 1712 | strncpy (target, o, s - o); |
| 1713 | target[s - o] = 0; | 1713 | target[s - o] = 0; |
| @@ -1715,7 +1715,7 @@ those `/' is discarded. */) | |||
| 1715 | strupr (target); /* $home == $HOME etc. */ | 1715 | strupr (target); /* $home == $HOME etc. */ |
| 1716 | #endif /* DOS_NT */ | 1716 | #endif /* DOS_NT */ |
| 1717 | 1717 | ||
| 1718 | /* Get variable value */ | 1718 | /* Get variable value. */ |
| 1719 | o = egetenv (target); | 1719 | o = egetenv (target); |
| 1720 | if (!o) | 1720 | if (!o) |
| 1721 | { | 1721 | { |
| @@ -1777,7 +1777,7 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir) | |||
| 1777 | stat behaves differently depending! */ | 1777 | stat behaves differently depending! */ |
| 1778 | if (SCHARS (absname) > 1 | 1778 | if (SCHARS (absname) > 1 |
| 1779 | && IS_DIRECTORY_SEP (SREF (absname, SBYTES (absname) - 1)) | 1779 | && IS_DIRECTORY_SEP (SREF (absname, SBYTES (absname) - 1)) |
| 1780 | && !IS_DEVICE_SEP (SREF (absname, SBYTES (absname)-2))) | 1780 | && !IS_DEVICE_SEP (SREF (absname, SBYTES (absname) - 2))) |
| 1781 | /* We cannot take shortcuts; they might be wrong for magic file names. */ | 1781 | /* We cannot take shortcuts; they might be wrong for magic file names. */ |
| 1782 | absname = Fdirectory_file_name (absname); | 1782 | absname = Fdirectory_file_name (absname); |
| 1783 | return absname; | 1783 | return absname; |
| @@ -1805,7 +1805,7 @@ barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring, | |||
| 1805 | 1805 | ||
| 1806 | encoded_filename = ENCODE_FILE (absname); | 1806 | encoded_filename = ENCODE_FILE (absname); |
| 1807 | 1807 | ||
| 1808 | /* stat is a good way to tell whether the file exists, | 1808 | /* `stat' is a good way to tell whether the file exists, |
| 1809 | regardless of what access permissions it has. */ | 1809 | regardless of what access permissions it has. */ |
| 1810 | if (lstat (SSDATA (encoded_filename), &statbuf) >= 0) | 1810 | if (lstat (SSDATA (encoded_filename), &statbuf) >= 0) |
| 1811 | { | 1811 | { |
| @@ -2044,9 +2044,10 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) | |||
| 2044 | #if HAVE_LIBSELINUX | 2044 | #if HAVE_LIBSELINUX |
| 2045 | if (conlength > 0) | 2045 | if (conlength > 0) |
| 2046 | { | 2046 | { |
| 2047 | /* Set the modified context back to the file. */ | 2047 | /* Set the modified context back to the file. */ |
| 2048 | fail = fsetfilecon (ofd, con); | 2048 | fail = fsetfilecon (ofd, con); |
| 2049 | if (fail) | 2049 | /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ |
| 2050 | if (fail && errno != ENOTSUP) | ||
| 2050 | report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil)); | 2051 | report_file_error ("Doing fsetfilecon", Fcons (newname, Qnil)); |
| 2051 | 2052 | ||
| 2052 | freecon (con); | 2053 | freecon (con); |
| @@ -2917,10 +2918,11 @@ compiled with SELinux support. */) | |||
| 2917 | error ("Doing context_range_set"); | 2918 | error ("Doing context_range_set"); |
| 2918 | } | 2919 | } |
| 2919 | 2920 | ||
| 2920 | /* Set the modified context back to the file. */ | 2921 | /* Set the modified context back to the file. */ |
| 2921 | fail = lsetfilecon (SSDATA (encoded_absname), | 2922 | fail = lsetfilecon (SSDATA (encoded_absname), |
| 2922 | context_str (parsed_con)); | 2923 | context_str (parsed_con)); |
| 2923 | if (fail) | 2924 | /* See http://debbugs.gnu.org/11245 for ENOTSUP. */ |
| 2925 | if (fail && errno != ENOTSUP) | ||
| 2924 | report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil)); | 2926 | report_file_error ("Doing lsetfilecon", Fcons (absname, Qnil)); |
| 2925 | 2927 | ||
| 2926 | context_free (parsed_con); | 2928 | context_free (parsed_con); |
diff --git a/src/filelock.c b/src/filelock.c index 2613eec4aca..d8914c73328 100644 --- a/src/filelock.c +++ b/src/filelock.c | |||
| @@ -550,6 +550,10 @@ lock_file (Lisp_Object fn) | |||
| 550 | struct gcpro gcpro1; | 550 | struct gcpro gcpro1; |
| 551 | USE_SAFE_ALLOCA; | 551 | USE_SAFE_ALLOCA; |
| 552 | 552 | ||
| 553 | /* Don't do locking if the user has opted out. */ | ||
| 554 | if (! create_lockfiles) | ||
| 555 | return; | ||
| 556 | |||
| 553 | /* Don't do locking while dumping Emacs. | 557 | /* Don't do locking while dumping Emacs. |
| 554 | Uncompressing wtmp files uses call-process, which does not work | 558 | Uncompressing wtmp files uses call-process, which does not work |
| 555 | in an uninitialized Emacs. */ | 559 | in an uninitialized Emacs. */ |
| @@ -722,6 +726,10 @@ syms_of_filelock (void) | |||
| 722 | doc: /* The directory for writing temporary files. */); | 726 | doc: /* The directory for writing temporary files. */); |
| 723 | Vtemporary_file_directory = Qnil; | 727 | Vtemporary_file_directory = Qnil; |
| 724 | 728 | ||
| 729 | DEFVAR_BOOL ("create-lockfiles", create_lockfiles, | ||
| 730 | doc: /* Non-nil means use lockfiles to avoid editing collisions. */); | ||
| 731 | create_lockfiles = 1; | ||
| 732 | |||
| 725 | #ifdef CLASH_DETECTION | 733 | #ifdef CLASH_DETECTION |
| 726 | defsubr (&Sunlock_buffer); | 734 | defsubr (&Sunlock_buffer); |
| 727 | defsubr (&Slock_buffer); | 735 | defsubr (&Slock_buffer); |
| @@ -42,10 +42,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 42 | #endif | 42 | #endif |
| 43 | #endif /* HAVE_MENUS */ | 43 | #endif /* HAVE_MENUS */ |
| 44 | 44 | ||
| 45 | #ifndef NULL | ||
| 46 | #define NULL ((POINTER_TYPE *)0) | ||
| 47 | #endif | ||
| 48 | |||
| 49 | Lisp_Object Qstring_lessp; | 45 | Lisp_Object Qstring_lessp; |
| 50 | static Lisp_Object Qprovide, Qrequire; | 46 | static Lisp_Object Qprovide, Qrequire; |
| 51 | static Lisp_Object Qyes_or_no_p_history; | 47 | static Lisp_Object Qyes_or_no_p_history; |
diff --git a/src/font.h b/src/font.h index 89f6b29ca9d..b058be67aa3 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -469,11 +469,12 @@ struct font_bitmap | |||
| 469 | } while (0) | 469 | } while (0) |
| 470 | 470 | ||
| 471 | #define XFONT_SPEC(p) \ | 471 | #define XFONT_SPEC(p) \ |
| 472 | (eassert (FONT_SPEC_P(p)), (struct font_spec *) XPNTR (p)) | 472 | (eassert (FONT_SPEC_P (p)), (struct font_spec *) XUNTAG (p, Lisp_Vectorlike)) |
| 473 | #define XFONT_ENTITY(p) \ | 473 | #define XFONT_ENTITY(p) \ |
| 474 | (eassert (FONT_ENTITY_P(p)), (struct font_entity *) XPNTR (p)) | 474 | (eassert (FONT_ENTITY_P (p)), \ |
| 475 | (struct font_entity *) XUNTAG (p, Lisp_Vectorlike)) | ||
| 475 | #define XFONT_OBJECT(p) \ | 476 | #define XFONT_OBJECT(p) \ |
| 476 | (eassert (FONT_OBJECT_P(p)), (struct font *) XPNTR (p)) | 477 | (eassert (FONT_OBJECT_P (p)), (struct font *) XUNTAG (p, Lisp_Vectorlike)) |
| 477 | #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT)) | 478 | #define XSETFONT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FONT)) |
| 478 | 479 | ||
| 479 | /* Number of pt per inch (from the TeXbook). */ | 480 | /* Number of pt per inch (from the TeXbook). */ |
diff --git a/src/frame.h b/src/frame.h index e058a101462..1a8bff7c3e7 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -501,7 +501,8 @@ struct frame | |||
| 501 | 501 | ||
| 502 | typedef struct frame *FRAME_PTR; | 502 | typedef struct frame *FRAME_PTR; |
| 503 | 503 | ||
| 504 | #define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p)) | 504 | #define XFRAME(p) \ |
| 505 | (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike)) | ||
| 505 | #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME)) | 506 | #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME)) |
| 506 | 507 | ||
| 507 | /* Given a window, return its frame as a Lisp_Object. */ | 508 | /* Given a window, return its frame as a Lisp_Object. */ |
diff --git a/src/gmalloc.c b/src/gmalloc.c index 7b5e6df009b..0df050e127a 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c | |||
| @@ -1,9 +1,3 @@ | |||
| 1 | /* This file is no longer automatically generated from libc. */ | ||
| 2 | |||
| 3 | #define _MALLOC_INTERNAL | ||
| 4 | |||
| 5 | /* The malloc headers and source files from the C library follow here. */ | ||
| 6 | |||
| 7 | /* Declarations for `malloc' and friends. | 1 | /* Declarations for `malloc' and friends. |
| 8 | Copyright (C) 1990, 1991, 1992, 1993, 1995, 1996, 1999, 2002, 2003, 2004, | 2 | Copyright (C) 1990, 1991, 1992, 1993, 1995, 1996, 1999, 2002, 2003, 2004, |
| 9 | 2005, 2006, 2007 Free Software Foundation, Inc. | 3 | 2005, 2006, 2007 Free Software Foundation, Inc. |
| @@ -27,12 +21,6 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 27 | The author may be reached (Email) at the address mike@ai.mit.edu, | 21 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 28 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 22 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 29 | 23 | ||
| 30 | #ifndef _MALLOC_H | ||
| 31 | |||
| 32 | #define _MALLOC_H 1 | ||
| 33 | |||
| 34 | #ifdef _MALLOC_INTERNAL | ||
| 35 | |||
| 36 | #ifdef HAVE_CONFIG_H | 24 | #ifdef HAVE_CONFIG_H |
| 37 | #include <config.h> | 25 | #include <config.h> |
| 38 | #endif | 26 | #endif |
| @@ -41,62 +29,44 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 41 | #define USE_PTHREAD | 29 | #define USE_PTHREAD |
| 42 | #endif | 30 | #endif |
| 43 | 31 | ||
| 44 | #undef PP | ||
| 45 | #define PP(args) args | ||
| 46 | #undef __ptr_t | ||
| 47 | #define __ptr_t void * | ||
| 48 | |||
| 49 | #include <string.h> | 32 | #include <string.h> |
| 50 | #include <limits.h> | 33 | #include <limits.h> |
| 34 | #include <stdint.h> | ||
| 51 | #include <unistd.h> | 35 | #include <unistd.h> |
| 52 | 36 | ||
| 53 | #ifdef USE_PTHREAD | 37 | #ifdef USE_PTHREAD |
| 54 | #include <pthread.h> | 38 | #include <pthread.h> |
| 55 | #endif | 39 | #endif |
| 56 | 40 | ||
| 57 | #endif /* _MALLOC_INTERNAL. */ | ||
| 58 | |||
| 59 | |||
| 60 | #ifdef __cplusplus | 41 | #ifdef __cplusplus |
| 61 | extern "C" | 42 | extern "C" |
| 62 | { | 43 | { |
| 63 | #endif | 44 | #endif |
| 64 | 45 | ||
| 65 | #include <stddef.h> | 46 | #include <stddef.h> |
| 66 | #define __malloc_size_t size_t | ||
| 67 | #define __malloc_ptrdiff_t ptrdiff_t | ||
| 68 | 47 | ||
| 69 | 48 | ||
| 70 | /* Allocate SIZE bytes of memory. */ | 49 | /* Allocate SIZE bytes of memory. */ |
| 71 | extern __ptr_t malloc PP ((__malloc_size_t __size)); | 50 | extern void *malloc (size_t size); |
| 72 | /* Re-allocate the previously allocated block | 51 | /* Re-allocate the previously allocated block |
| 73 | in __ptr_t, making the new block SIZE bytes long. */ | 52 | in ptr, making the new block SIZE bytes long. */ |
| 74 | extern __ptr_t realloc PP ((__ptr_t __ptr, __malloc_size_t __size)); | 53 | extern void *realloc (void *ptr, size_t size); |
| 75 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ | 54 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ |
| 76 | extern __ptr_t calloc PP ((__malloc_size_t __nmemb, __malloc_size_t __size)); | 55 | extern void *calloc (size_t nmemb, size_t size); |
| 77 | /* Free a block allocated by `malloc', `realloc' or `calloc'. */ | 56 | /* Free a block allocated by `malloc', `realloc' or `calloc'. */ |
| 78 | extern void free PP ((__ptr_t __ptr)); | 57 | extern void free (void *ptr); |
| 79 | 58 | ||
| 80 | /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ | 59 | /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ |
| 81 | #if !defined (_MALLOC_INTERNAL) || defined (MSDOS) /* Avoid conflict. */ | 60 | #ifdef MSDOS |
| 82 | extern __ptr_t memalign PP ((__malloc_size_t __alignment, | 61 | extern void *memalign (size_t, size_t); |
| 83 | __malloc_size_t __size)); | 62 | extern int posix_memalign (void **, size_t, size_t); |
| 84 | extern int posix_memalign PP ((__ptr_t *, __malloc_size_t, | ||
| 85 | __malloc_size_t size)); | ||
| 86 | #endif | ||
| 87 | |||
| 88 | /* Allocate SIZE bytes on a page boundary. */ | ||
| 89 | #if ! (defined (_MALLOC_INTERNAL) && defined (GMALLOC_INHIBIT_VALLOC)) | ||
| 90 | extern __ptr_t valloc PP ((__malloc_size_t __size)); | ||
| 91 | #endif | 63 | #endif |
| 92 | 64 | ||
| 93 | #ifdef USE_PTHREAD | 65 | #ifdef USE_PTHREAD |
| 94 | /* Set up mutexes and make malloc etc. thread-safe. */ | 66 | /* Set up mutexes and make malloc etc. thread-safe. */ |
| 95 | extern void malloc_enable_thread PP ((void)); | 67 | extern void malloc_enable_thread (void); |
| 96 | #endif | 68 | #endif |
| 97 | 69 | ||
| 98 | #ifdef _MALLOC_INTERNAL | ||
| 99 | |||
| 100 | /* The allocator divides the heap into blocks of fixed size; large | 70 | /* The allocator divides the heap into blocks of fixed size; large |
| 101 | requests receive one or more whole blocks, and small requests | 71 | requests receive one or more whole blocks, and small requests |
| 102 | receive a fragment of a block. Fragment sizes are powers of two, | 72 | receive a fragment of a block. Fragment sizes are powers of two, |
| @@ -128,22 +98,22 @@ typedef union | |||
| 128 | { | 98 | { |
| 129 | struct | 99 | struct |
| 130 | { | 100 | { |
| 131 | __malloc_size_t nfree; /* Free frags in a fragmented block. */ | 101 | size_t nfree; /* Free frags in a fragmented block. */ |
| 132 | __malloc_size_t first; /* First free fragment of the block. */ | 102 | size_t first; /* First free fragment of the block. */ |
| 133 | } frag; | 103 | } frag; |
| 134 | /* For a large object, in its first block, this has the number | 104 | /* For a large object, in its first block, this has the number |
| 135 | of blocks in the object. In the other blocks, this has a | 105 | of blocks in the object. In the other blocks, this has a |
| 136 | negative number which says how far back the first block is. */ | 106 | negative number which says how far back the first block is. */ |
| 137 | __malloc_ptrdiff_t size; | 107 | ptrdiff_t size; |
| 138 | } info; | 108 | } info; |
| 139 | } busy; | 109 | } busy; |
| 140 | /* Heap information for a free block | 110 | /* Heap information for a free block |
| 141 | (that may be the first of a free cluster). */ | 111 | (that may be the first of a free cluster). */ |
| 142 | struct | 112 | struct |
| 143 | { | 113 | { |
| 144 | __malloc_size_t size; /* Size (in blocks) of a free cluster. */ | 114 | size_t size; /* Size (in blocks) of a free cluster. */ |
| 145 | __malloc_size_t next; /* Index of next free cluster. */ | 115 | size_t next; /* Index of next free cluster. */ |
| 146 | __malloc_size_t prev; /* Index of previous free cluster. */ | 116 | size_t prev; /* Index of previous free cluster. */ |
| 147 | } free; | 117 | } free; |
| 148 | } malloc_info; | 118 | } malloc_info; |
| 149 | 119 | ||
| @@ -155,13 +125,13 @@ extern malloc_info *_heapinfo; | |||
| 155 | 125 | ||
| 156 | /* Address to block number and vice versa. */ | 126 | /* Address to block number and vice versa. */ |
| 157 | #define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) | 127 | #define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) |
| 158 | #define ADDRESS(B) ((__ptr_t) (((B) - 1) * BLOCKSIZE + _heapbase)) | 128 | #define ADDRESS(B) ((void *) (((B) - 1) * BLOCKSIZE + _heapbase)) |
| 159 | 129 | ||
| 160 | /* Current search index for the heap table. */ | 130 | /* Current search index for the heap table. */ |
| 161 | extern __malloc_size_t _heapindex; | 131 | extern size_t _heapindex; |
| 162 | 132 | ||
| 163 | /* Limit of valid info table indices. */ | 133 | /* Limit of valid info table indices. */ |
| 164 | extern __malloc_size_t _heaplimit; | 134 | extern size_t _heaplimit; |
| 165 | 135 | ||
| 166 | /* Doubly linked lists of free fragments. */ | 136 | /* Doubly linked lists of free fragments. */ |
| 167 | struct list | 137 | struct list |
| @@ -177,26 +147,26 @@ extern struct list _fraghead[]; | |||
| 177 | struct alignlist | 147 | struct alignlist |
| 178 | { | 148 | { |
| 179 | struct alignlist *next; | 149 | struct alignlist *next; |
| 180 | __ptr_t aligned; /* The address that memaligned returned. */ | 150 | void *aligned; /* The address that memaligned returned. */ |
| 181 | __ptr_t exact; /* The address that malloc returned. */ | 151 | void *exact; /* The address that malloc returned. */ |
| 182 | }; | 152 | }; |
| 183 | extern struct alignlist *_aligned_blocks; | 153 | extern struct alignlist *_aligned_blocks; |
| 184 | 154 | ||
| 185 | /* Instrumentation. */ | 155 | /* Instrumentation. */ |
| 186 | extern __malloc_size_t _chunks_used; | 156 | extern size_t _chunks_used; |
| 187 | extern __malloc_size_t _bytes_used; | 157 | extern size_t _bytes_used; |
| 188 | extern __malloc_size_t _chunks_free; | 158 | extern size_t _chunks_free; |
| 189 | extern __malloc_size_t _bytes_free; | 159 | extern size_t _bytes_free; |
| 190 | 160 | ||
| 191 | /* Internal versions of `malloc', `realloc', and `free' | 161 | /* Internal versions of `malloc', `realloc', and `free' |
| 192 | used when these functions need to call each other. | 162 | used when these functions need to call each other. |
| 193 | They are the same but don't call the hooks. */ | 163 | They are the same but don't call the hooks. */ |
| 194 | extern __ptr_t _malloc_internal PP ((__malloc_size_t __size)); | 164 | extern void *_malloc_internal (size_t); |
| 195 | extern __ptr_t _realloc_internal PP ((__ptr_t __ptr, __malloc_size_t __size)); | 165 | extern void *_realloc_internal (void *, size_t); |
| 196 | extern void _free_internal PP ((__ptr_t __ptr)); | 166 | extern void _free_internal (void *); |
| 197 | extern __ptr_t _malloc_internal_nolock PP ((__malloc_size_t __size)); | 167 | extern void *_malloc_internal_nolock (size_t); |
| 198 | extern __ptr_t _realloc_internal_nolock PP ((__ptr_t __ptr, __malloc_size_t __size)); | 168 | extern void *_realloc_internal_nolock (void *, size_t); |
| 199 | extern void _free_internal_nolock PP ((__ptr_t __ptr)); | 169 | extern void _free_internal_nolock (void *); |
| 200 | 170 | ||
| 201 | #ifdef USE_PTHREAD | 171 | #ifdef USE_PTHREAD |
| 202 | extern pthread_mutex_t _malloc_mutex, _aligned_blocks_mutex; | 172 | extern pthread_mutex_t _malloc_mutex, _aligned_blocks_mutex; |
| @@ -228,39 +198,36 @@ extern int _malloc_thread_enabled_p; | |||
| 228 | #define UNLOCK_ALIGNED_BLOCKS() | 198 | #define UNLOCK_ALIGNED_BLOCKS() |
| 229 | #endif | 199 | #endif |
| 230 | 200 | ||
| 231 | #endif /* _MALLOC_INTERNAL. */ | ||
| 232 | |||
| 233 | /* Given an address in the middle of a malloc'd object, | 201 | /* Given an address in the middle of a malloc'd object, |
| 234 | return the address of the beginning of the object. */ | 202 | return the address of the beginning of the object. */ |
| 235 | extern __ptr_t malloc_find_object_address PP ((__ptr_t __ptr)); | 203 | extern void *malloc_find_object_address (void *ptr); |
| 236 | 204 | ||
| 237 | /* Underlying allocation function; successive calls should | 205 | /* Underlying allocation function; successive calls should |
| 238 | return contiguous pieces of memory. */ | 206 | return contiguous pieces of memory. */ |
| 239 | extern __ptr_t (*__morecore) PP ((__malloc_ptrdiff_t __size)); | 207 | extern void *(*__morecore) (ptrdiff_t size); |
| 240 | 208 | ||
| 241 | /* Default value of `__morecore'. */ | 209 | /* Default value of `__morecore'. */ |
| 242 | extern __ptr_t __default_morecore PP ((__malloc_ptrdiff_t __size)); | 210 | extern void *__default_morecore (ptrdiff_t size); |
| 243 | 211 | ||
| 244 | /* If not NULL, this function is called after each time | 212 | /* If not NULL, this function is called after each time |
| 245 | `__morecore' is called to increase the data size. */ | 213 | `__morecore' is called to increase the data size. */ |
| 246 | extern void (*__after_morecore_hook) PP ((void)); | 214 | extern void (*__after_morecore_hook) (void); |
| 247 | 215 | ||
| 248 | /* Number of extra blocks to get each time we ask for more core. | 216 | /* Number of extra blocks to get each time we ask for more core. |
| 249 | This reduces the frequency of calling `(*__morecore)'. */ | 217 | This reduces the frequency of calling `(*__morecore)'. */ |
| 250 | extern __malloc_size_t __malloc_extra_blocks; | 218 | extern size_t __malloc_extra_blocks; |
| 251 | 219 | ||
| 252 | /* Nonzero if `malloc' has been called and done its initialization. */ | 220 | /* Nonzero if `malloc' has been called and done its initialization. */ |
| 253 | extern int __malloc_initialized; | 221 | extern int __malloc_initialized; |
| 254 | /* Function called to initialize malloc data structures. */ | 222 | /* Function called to initialize malloc data structures. */ |
| 255 | extern int __malloc_initialize PP ((void)); | 223 | extern int __malloc_initialize (void); |
| 256 | 224 | ||
| 257 | /* Hooks for debugging versions. */ | 225 | /* Hooks for debugging versions. */ |
| 258 | extern void (*__malloc_initialize_hook) PP ((void)); | 226 | extern void (*__malloc_initialize_hook) (void); |
| 259 | extern void (*__free_hook) PP ((__ptr_t __ptr)); | 227 | extern void (*__free_hook) (void *ptr); |
| 260 | extern __ptr_t (*__malloc_hook) PP ((__malloc_size_t __size)); | 228 | extern void *(*__malloc_hook) (size_t size); |
| 261 | extern __ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size)); | 229 | extern void *(*__realloc_hook) (void *ptr, size_t size); |
| 262 | extern __ptr_t (*__memalign_hook) PP ((__malloc_size_t __size, | 230 | extern void *(*__memalign_hook) (size_t size, size_t alignment); |
| 263 | __malloc_size_t __alignment)); | ||
| 264 | 231 | ||
| 265 | /* Return values for `mprobe': these are the kinds of inconsistencies that | 232 | /* Return values for `mprobe': these are the kinds of inconsistencies that |
| 266 | `mcheck' enables detection of. */ | 233 | `mcheck' enables detection of. */ |
| @@ -277,52 +244,37 @@ enum mcheck_status | |||
| 277 | before `malloc' is ever called. ABORTFUNC is called with an error code | 244 | before `malloc' is ever called. ABORTFUNC is called with an error code |
| 278 | (see enum above) when an inconsistency is detected. If ABORTFUNC is | 245 | (see enum above) when an inconsistency is detected. If ABORTFUNC is |
| 279 | null, the standard function prints on stderr and then calls `abort'. */ | 246 | null, the standard function prints on stderr and then calls `abort'. */ |
| 280 | extern int mcheck PP ((void (*__abortfunc) PP ((enum mcheck_status)))); | 247 | extern int mcheck (void (*abortfunc) (enum mcheck_status)); |
| 281 | 248 | ||
| 282 | /* Check for aberrations in a particular malloc'd block. You must have | 249 | /* Check for aberrations in a particular malloc'd block. You must have |
| 283 | called `mcheck' already. These are the same checks that `mcheck' does | 250 | called `mcheck' already. These are the same checks that `mcheck' does |
| 284 | when you free or reallocate a block. */ | 251 | when you free or reallocate a block. */ |
| 285 | extern enum mcheck_status mprobe PP ((__ptr_t __ptr)); | 252 | extern enum mcheck_status mprobe (void *ptr); |
| 286 | 253 | ||
| 287 | /* Activate a standard collection of tracing hooks. */ | 254 | /* Activate a standard collection of tracing hooks. */ |
| 288 | extern void mtrace PP ((void)); | 255 | extern void mtrace (void); |
| 289 | extern void muntrace PP ((void)); | 256 | extern void muntrace (void); |
| 290 | 257 | ||
| 291 | /* Statistics available to the user. */ | 258 | /* Statistics available to the user. */ |
| 292 | struct mstats | 259 | struct mstats |
| 293 | { | 260 | { |
| 294 | __malloc_size_t bytes_total; /* Total size of the heap. */ | 261 | size_t bytes_total; /* Total size of the heap. */ |
| 295 | __malloc_size_t chunks_used; /* Chunks allocated by the user. */ | 262 | size_t chunks_used; /* Chunks allocated by the user. */ |
| 296 | __malloc_size_t bytes_used; /* Byte total of user-allocated chunks. */ | 263 | size_t bytes_used; /* Byte total of user-allocated chunks. */ |
| 297 | __malloc_size_t chunks_free; /* Chunks in the free list. */ | 264 | size_t chunks_free; /* Chunks in the free list. */ |
| 298 | __malloc_size_t bytes_free; /* Byte total of chunks in the free list. */ | 265 | size_t bytes_free; /* Byte total of chunks in the free list. */ |
| 299 | }; | 266 | }; |
| 300 | 267 | ||
| 301 | /* Pick up the current statistics. */ | 268 | /* Pick up the current statistics. */ |
| 302 | extern struct mstats mstats PP ((void)); | 269 | extern struct mstats mstats (void); |
| 303 | 270 | ||
| 304 | /* Call WARNFUN with a warning message when memory usage is high. */ | 271 | /* Call WARNFUN with a warning message when memory usage is high. */ |
| 305 | extern void memory_warnings PP ((__ptr_t __start, | 272 | extern void memory_warnings (void *start, void (*warnfun) (const char *)); |
| 306 | void (*__warnfun) PP ((const char *)))); | ||
| 307 | |||
| 308 | |||
| 309 | /* Relocating allocator. */ | ||
| 310 | |||
| 311 | /* Allocate SIZE bytes, and store the address in *HANDLEPTR. */ | ||
| 312 | extern __ptr_t r_alloc PP ((__ptr_t *__handleptr, __malloc_size_t __size)); | ||
| 313 | |||
| 314 | /* Free the storage allocated in HANDLEPTR. */ | ||
| 315 | extern void r_alloc_free PP ((__ptr_t *__handleptr)); | ||
| 316 | |||
| 317 | /* Adjust the block at HANDLEPTR to be SIZE bytes long. */ | ||
| 318 | extern __ptr_t r_re_alloc PP ((__ptr_t *__handleptr, __malloc_size_t __size)); | ||
| 319 | |||
| 320 | 273 | ||
| 321 | #ifdef __cplusplus | 274 | #ifdef __cplusplus |
| 322 | } | 275 | } |
| 323 | #endif | 276 | #endif |
| 324 | 277 | ||
| 325 | #endif /* malloc.h */ | ||
| 326 | /* Memory allocator `malloc'. | 278 | /* Memory allocator `malloc'. |
| 327 | Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | 279 | Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
| 328 | Written May 1989 by Mike Haertel. | 280 | Written May 1989 by Mike Haertel. |
| @@ -345,10 +297,6 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 345 | The author may be reached (Email) at the address mike@ai.mit.edu, | 297 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 346 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 298 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 347 | 299 | ||
| 348 | #ifndef _MALLOC_INTERNAL | ||
| 349 | #define _MALLOC_INTERNAL | ||
| 350 | #include <malloc.h> | ||
| 351 | #endif | ||
| 352 | #include <errno.h> | 300 | #include <errno.h> |
| 353 | 301 | ||
| 354 | /* On Cygwin there are two heaps. temacs uses the static heap | 302 | /* On Cygwin there are two heaps. temacs uses the static heap |
| @@ -362,15 +310,15 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 362 | this is changed in the future, we'll have to similarly deal with | 310 | this is changed in the future, we'll have to similarly deal with |
| 363 | reinitializing ralloc. */ | 311 | reinitializing ralloc. */ |
| 364 | #ifdef CYGWIN | 312 | #ifdef CYGWIN |
| 365 | extern __ptr_t bss_sbrk PP ((ptrdiff_t __size)); | 313 | extern void *bss_sbrk (ptrdiff_t size); |
| 366 | extern int bss_sbrk_did_unexec; | 314 | extern int bss_sbrk_did_unexec; |
| 367 | char *bss_sbrk_heapbase; /* _heapbase for static heap */ | 315 | char *bss_sbrk_heapbase; /* _heapbase for static heap */ |
| 368 | malloc_info *bss_sbrk_heapinfo; /* _heapinfo for static heap */ | 316 | malloc_info *bss_sbrk_heapinfo; /* _heapinfo for static heap */ |
| 369 | #endif | 317 | #endif |
| 370 | __ptr_t (*__morecore) PP ((__malloc_ptrdiff_t __size)) = __default_morecore; | 318 | void *(*__morecore) (ptrdiff_t size) = __default_morecore; |
| 371 | 319 | ||
| 372 | /* Debugging hook for `malloc'. */ | 320 | /* Debugging hook for `malloc'. */ |
| 373 | __ptr_t (*__malloc_hook) PP ((__malloc_size_t __size)); | 321 | void *(*__malloc_hook) (size_t size); |
| 374 | 322 | ||
| 375 | /* Pointer to the base of the first block. */ | 323 | /* Pointer to the base of the first block. */ |
| 376 | char *_heapbase; | 324 | char *_heapbase; |
| @@ -379,30 +327,30 @@ char *_heapbase; | |||
| 379 | malloc_info *_heapinfo; | 327 | malloc_info *_heapinfo; |
| 380 | 328 | ||
| 381 | /* Number of info entries. */ | 329 | /* Number of info entries. */ |
| 382 | static __malloc_size_t heapsize; | 330 | static size_t heapsize; |
| 383 | 331 | ||
| 384 | /* Search index in the info table. */ | 332 | /* Search index in the info table. */ |
| 385 | __malloc_size_t _heapindex; | 333 | size_t _heapindex; |
| 386 | 334 | ||
| 387 | /* Limit of valid info table indices. */ | 335 | /* Limit of valid info table indices. */ |
| 388 | __malloc_size_t _heaplimit; | 336 | size_t _heaplimit; |
| 389 | 337 | ||
| 390 | /* Free lists for each fragment size. */ | 338 | /* Free lists for each fragment size. */ |
| 391 | struct list _fraghead[BLOCKLOG]; | 339 | struct list _fraghead[BLOCKLOG]; |
| 392 | 340 | ||
| 393 | /* Instrumentation. */ | 341 | /* Instrumentation. */ |
| 394 | __malloc_size_t _chunks_used; | 342 | size_t _chunks_used; |
| 395 | __malloc_size_t _bytes_used; | 343 | size_t _bytes_used; |
| 396 | __malloc_size_t _chunks_free; | 344 | size_t _chunks_free; |
| 397 | __malloc_size_t _bytes_free; | 345 | size_t _bytes_free; |
| 398 | 346 | ||
| 399 | /* Are you experienced? */ | 347 | /* Are you experienced? */ |
| 400 | int __malloc_initialized; | 348 | int __malloc_initialized; |
| 401 | 349 | ||
| 402 | __malloc_size_t __malloc_extra_blocks; | 350 | size_t __malloc_extra_blocks; |
| 403 | 351 | ||
| 404 | void (*__malloc_initialize_hook) PP ((void)); | 352 | void (*__malloc_initialize_hook) (void); |
| 405 | void (*__after_morecore_hook) PP ((void)); | 353 | void (*__after_morecore_hook) (void); |
| 406 | 354 | ||
| 407 | #if defined GC_MALLOC_CHECK && defined GC_PROTECT_MALLOC_STATE | 355 | #if defined GC_MALLOC_CHECK && defined GC_PROTECT_MALLOC_STATE |
| 408 | 356 | ||
| @@ -419,12 +367,11 @@ void (*__after_morecore_hook) PP ((void)); | |||
| 419 | #include <sys/mman.h> | 367 | #include <sys/mman.h> |
| 420 | 368 | ||
| 421 | static int state_protected_p; | 369 | static int state_protected_p; |
| 422 | static __malloc_size_t last_state_size; | 370 | static size_t last_state_size; |
| 423 | static malloc_info *last_heapinfo; | 371 | static malloc_info *last_heapinfo; |
| 424 | 372 | ||
| 425 | void | 373 | void |
| 426 | protect_malloc_state (protect_p) | 374 | protect_malloc_state (int protect_p) |
| 427 | int protect_p; | ||
| 428 | { | 375 | { |
| 429 | /* If _heapinfo has been relocated, make sure its old location | 376 | /* If _heapinfo has been relocated, make sure its old location |
| 430 | isn't left read-only; it will be reused by malloc. */ | 377 | isn't left read-only; it will be reused by malloc. */ |
| @@ -453,29 +400,25 @@ protect_malloc_state (protect_p) | |||
| 453 | 400 | ||
| 454 | 401 | ||
| 455 | /* Aligned allocation. */ | 402 | /* Aligned allocation. */ |
| 456 | static __ptr_t align PP ((__malloc_size_t)); | 403 | static void * |
| 457 | static __ptr_t | 404 | align (size_t size) |
| 458 | align (size) | ||
| 459 | __malloc_size_t size; | ||
| 460 | { | 405 | { |
| 461 | __ptr_t result; | 406 | void *result; |
| 462 | unsigned long int adj; | 407 | ptrdiff_t adj; |
| 463 | 408 | ||
| 464 | /* align accepts an unsigned argument, but __morecore accepts a | 409 | /* align accepts an unsigned argument, but __morecore accepts a |
| 465 | signed one. This could lead to trouble if SIZE overflows a | 410 | signed one. This could lead to trouble if SIZE overflows the |
| 466 | signed int type accepted by __morecore. We just punt in that | 411 | ptrdiff_t type accepted by __morecore. We just punt in that |
| 467 | case, since they are requesting a ludicrous amount anyway. */ | 412 | case, since they are requesting a ludicrous amount anyway. */ |
| 468 | if ((__malloc_ptrdiff_t)size < 0) | 413 | if (PTRDIFF_MAX < size) |
| 469 | result = 0; | 414 | result = 0; |
| 470 | else | 415 | else |
| 471 | result = (*__morecore) (size); | 416 | result = (*__morecore) (size); |
| 472 | adj = (unsigned long int) ((unsigned long int) ((char *) result - | 417 | adj = (uintptr_t) result % BLOCKSIZE; |
| 473 | (char *) NULL)) % BLOCKSIZE; | ||
| 474 | if (adj != 0) | 418 | if (adj != 0) |
| 475 | { | 419 | { |
| 476 | __ptr_t new; | ||
| 477 | adj = BLOCKSIZE - adj; | 420 | adj = BLOCKSIZE - adj; |
| 478 | new = (*__morecore) (adj); | 421 | (*__morecore) (adj); |
| 479 | result = (char *) result + adj; | 422 | result = (char *) result + adj; |
| 480 | } | 423 | } |
| 481 | 424 | ||
| @@ -488,14 +431,11 @@ align (size) | |||
| 488 | /* Get SIZE bytes, if we can get them starting at END. | 431 | /* Get SIZE bytes, if we can get them starting at END. |
| 489 | Return the address of the space we got. | 432 | Return the address of the space we got. |
| 490 | If we cannot get space at END, fail and return 0. */ | 433 | If we cannot get space at END, fail and return 0. */ |
| 491 | static __ptr_t get_contiguous_space PP ((__malloc_ptrdiff_t, __ptr_t)); | 434 | static void * |
| 492 | static __ptr_t | 435 | get_contiguous_space (ptrdiff_t size, void *position) |
| 493 | get_contiguous_space (size, position) | ||
| 494 | __malloc_ptrdiff_t size; | ||
| 495 | __ptr_t position; | ||
| 496 | { | 436 | { |
| 497 | __ptr_t before; | 437 | void *before; |
| 498 | __ptr_t after; | 438 | void *after; |
| 499 | 439 | ||
| 500 | before = (*__morecore) (0); | 440 | before = (*__morecore) (0); |
| 501 | /* If we can tell in advance that the break is at the wrong place, | 441 | /* If we can tell in advance that the break is at the wrong place, |
| @@ -525,7 +465,7 @@ get_contiguous_space (size, position) | |||
| 525 | static inline void | 465 | static inline void |
| 526 | register_heapinfo (void) | 466 | register_heapinfo (void) |
| 527 | { | 467 | { |
| 528 | __malloc_size_t block, blocks; | 468 | size_t block, blocks; |
| 529 | 469 | ||
| 530 | block = BLOCK (_heapinfo); | 470 | block = BLOCK (_heapinfo); |
| 531 | blocks = BLOCKIFY (heapsize * sizeof (malloc_info)); | 471 | blocks = BLOCKIFY (heapsize * sizeof (malloc_info)); |
| @@ -548,21 +488,21 @@ pthread_mutex_t _aligned_blocks_mutex = PTHREAD_MUTEX_INITIALIZER; | |||
| 548 | int _malloc_thread_enabled_p; | 488 | int _malloc_thread_enabled_p; |
| 549 | 489 | ||
| 550 | static void | 490 | static void |
| 551 | malloc_atfork_handler_prepare () | 491 | malloc_atfork_handler_prepare (void) |
| 552 | { | 492 | { |
| 553 | LOCK (); | 493 | LOCK (); |
| 554 | LOCK_ALIGNED_BLOCKS (); | 494 | LOCK_ALIGNED_BLOCKS (); |
| 555 | } | 495 | } |
| 556 | 496 | ||
| 557 | static void | 497 | static void |
| 558 | malloc_atfork_handler_parent () | 498 | malloc_atfork_handler_parent (void) |
| 559 | { | 499 | { |
| 560 | UNLOCK_ALIGNED_BLOCKS (); | 500 | UNLOCK_ALIGNED_BLOCKS (); |
| 561 | UNLOCK (); | 501 | UNLOCK (); |
| 562 | } | 502 | } |
| 563 | 503 | ||
| 564 | static void | 504 | static void |
| 565 | malloc_atfork_handler_child () | 505 | malloc_atfork_handler_child (void) |
| 566 | { | 506 | { |
| 567 | UNLOCK_ALIGNED_BLOCKS (); | 507 | UNLOCK_ALIGNED_BLOCKS (); |
| 568 | UNLOCK (); | 508 | UNLOCK (); |
| @@ -570,7 +510,7 @@ malloc_atfork_handler_child () | |||
| 570 | 510 | ||
| 571 | /* Set up mutexes and make malloc etc. thread-safe. */ | 511 | /* Set up mutexes and make malloc etc. thread-safe. */ |
| 572 | void | 512 | void |
| 573 | malloc_enable_thread () | 513 | malloc_enable_thread (void) |
| 574 | { | 514 | { |
| 575 | if (_malloc_thread_enabled_p) | 515 | if (_malloc_thread_enabled_p) |
| 576 | return; | 516 | return; |
| @@ -589,7 +529,7 @@ malloc_enable_thread () | |||
| 589 | #endif | 529 | #endif |
| 590 | 530 | ||
| 591 | static void | 531 | static void |
| 592 | malloc_initialize_1 () | 532 | malloc_initialize_1 (void) |
| 593 | { | 533 | { |
| 594 | #ifdef GC_MCHECK | 534 | #ifdef GC_MCHECK |
| 595 | mcheck (NULL); | 535 | mcheck (NULL); |
| @@ -609,7 +549,7 @@ malloc_initialize_1 () | |||
| 609 | (*__malloc_initialize_hook) (); | 549 | (*__malloc_initialize_hook) (); |
| 610 | 550 | ||
| 611 | heapsize = HEAP / BLOCKSIZE; | 551 | heapsize = HEAP / BLOCKSIZE; |
| 612 | _heapinfo = (malloc_info *) align (heapsize * sizeof (malloc_info)); | 552 | _heapinfo = align (heapsize * sizeof (malloc_info)); |
| 613 | if (_heapinfo == NULL) | 553 | if (_heapinfo == NULL) |
| 614 | return; | 554 | return; |
| 615 | memset (_heapinfo, 0, heapsize * sizeof (malloc_info)); | 555 | memset (_heapinfo, 0, heapsize * sizeof (malloc_info)); |
| @@ -630,7 +570,7 @@ malloc_initialize_1 () | |||
| 630 | main will call malloc which calls this function. That is before any threads | 570 | main will call malloc which calls this function. That is before any threads |
| 631 | or signal handlers has been set up, so we don't need thread protection. */ | 571 | or signal handlers has been set up, so we don't need thread protection. */ |
| 632 | int | 572 | int |
| 633 | __malloc_initialize () | 573 | __malloc_initialize (void) |
| 634 | { | 574 | { |
| 635 | if (__malloc_initialized) | 575 | if (__malloc_initialized) |
| 636 | return 0; | 576 | return 0; |
| @@ -644,14 +584,12 @@ static int morecore_recursing; | |||
| 644 | 584 | ||
| 645 | /* Get neatly aligned memory, initializing or | 585 | /* Get neatly aligned memory, initializing or |
| 646 | growing the heap info table as necessary. */ | 586 | growing the heap info table as necessary. */ |
| 647 | static __ptr_t morecore_nolock PP ((__malloc_size_t)); | 587 | static void * |
| 648 | static __ptr_t | 588 | morecore_nolock (size_t size) |
| 649 | morecore_nolock (size) | ||
| 650 | __malloc_size_t size; | ||
| 651 | { | 589 | { |
| 652 | __ptr_t result; | 590 | void *result; |
| 653 | malloc_info *newinfo, *oldinfo; | 591 | malloc_info *newinfo, *oldinfo; |
| 654 | __malloc_size_t newsize; | 592 | size_t newsize; |
| 655 | 593 | ||
| 656 | if (morecore_recursing) | 594 | if (morecore_recursing) |
| 657 | /* Avoid recursion. The caller will know how to handle a null return. */ | 595 | /* Avoid recursion. The caller will know how to handle a null return. */ |
| @@ -664,7 +602,7 @@ morecore_nolock (size) | |||
| 664 | PROTECT_MALLOC_STATE (0); | 602 | PROTECT_MALLOC_STATE (0); |
| 665 | 603 | ||
| 666 | /* Check if we need to grow the info table. */ | 604 | /* Check if we need to grow the info table. */ |
| 667 | if ((__malloc_size_t) BLOCK ((char *) result + size) > heapsize) | 605 | if ((size_t) BLOCK ((char *) result + size) > heapsize) |
| 668 | { | 606 | { |
| 669 | /* Calculate the new _heapinfo table size. We do not account for the | 607 | /* Calculate the new _heapinfo table size. We do not account for the |
| 670 | added blocks in the table itself, as we hope to place them in | 608 | added blocks in the table itself, as we hope to place them in |
| @@ -673,7 +611,7 @@ morecore_nolock (size) | |||
| 673 | newsize = heapsize; | 611 | newsize = heapsize; |
| 674 | do | 612 | do |
| 675 | newsize *= 2; | 613 | newsize *= 2; |
| 676 | while ((__malloc_size_t) BLOCK ((char *) result + size) > newsize); | 614 | while ((size_t) BLOCK ((char *) result + size) > newsize); |
| 677 | 615 | ||
| 678 | /* We must not reuse existing core for the new info table when called | 616 | /* We must not reuse existing core for the new info table when called |
| 679 | from realloc in the case of growing a large block, because the | 617 | from realloc in the case of growing a large block, because the |
| @@ -689,8 +627,8 @@ morecore_nolock (size) | |||
| 689 | `morecore_recursing' flag and return null. */ | 627 | `morecore_recursing' flag and return null. */ |
| 690 | int save = errno; /* Don't want to clobber errno with ENOMEM. */ | 628 | int save = errno; /* Don't want to clobber errno with ENOMEM. */ |
| 691 | morecore_recursing = 1; | 629 | morecore_recursing = 1; |
| 692 | newinfo = (malloc_info *) _realloc_internal_nolock | 630 | newinfo = _realloc_internal_nolock (_heapinfo, |
| 693 | (_heapinfo, newsize * sizeof (malloc_info)); | 631 | newsize * sizeof (malloc_info)); |
| 694 | morecore_recursing = 0; | 632 | morecore_recursing = 0; |
| 695 | if (newinfo == NULL) | 633 | if (newinfo == NULL) |
| 696 | errno = save; | 634 | errno = save; |
| @@ -710,7 +648,7 @@ morecore_nolock (size) | |||
| 710 | /* Allocate new space for the malloc info table. */ | 648 | /* Allocate new space for the malloc info table. */ |
| 711 | while (1) | 649 | while (1) |
| 712 | { | 650 | { |
| 713 | newinfo = (malloc_info *) align (newsize * sizeof (malloc_info)); | 651 | newinfo = align (newsize * sizeof (malloc_info)); |
| 714 | 652 | ||
| 715 | /* Did it fail? */ | 653 | /* Did it fail? */ |
| 716 | if (newinfo == NULL) | 654 | if (newinfo == NULL) |
| @@ -721,8 +659,8 @@ morecore_nolock (size) | |||
| 721 | 659 | ||
| 722 | /* Is it big enough to record status for its own space? | 660 | /* Is it big enough to record status for its own space? |
| 723 | If so, we win. */ | 661 | If so, we win. */ |
| 724 | if ((__malloc_size_t) BLOCK ((char *) newinfo | 662 | if ((size_t) BLOCK ((char *) newinfo |
| 725 | + newsize * sizeof (malloc_info)) | 663 | + newsize * sizeof (malloc_info)) |
| 726 | < newsize) | 664 | < newsize) |
| 727 | break; | 665 | break; |
| 728 | 666 | ||
| @@ -759,13 +697,12 @@ morecore_nolock (size) | |||
| 759 | } | 697 | } |
| 760 | 698 | ||
| 761 | /* Allocate memory from the heap. */ | 699 | /* Allocate memory from the heap. */ |
| 762 | __ptr_t | 700 | void * |
| 763 | _malloc_internal_nolock (size) | 701 | _malloc_internal_nolock (size_t size) |
| 764 | __malloc_size_t size; | ||
| 765 | { | 702 | { |
| 766 | __ptr_t result; | 703 | void *result; |
| 767 | __malloc_size_t block, blocks, lastblocks, start; | 704 | size_t block, blocks, lastblocks, start; |
| 768 | register __malloc_size_t i; | 705 | register size_t i; |
| 769 | struct list *next; | 706 | struct list *next; |
| 770 | 707 | ||
| 771 | /* ANSI C allows `malloc (0)' to either return NULL, or to return a | 708 | /* ANSI C allows `malloc (0)' to either return NULL, or to return a |
| @@ -790,7 +727,7 @@ _malloc_internal_nolock (size) | |||
| 790 | { | 727 | { |
| 791 | /* Small allocation to receive a fragment of a block. | 728 | /* Small allocation to receive a fragment of a block. |
| 792 | Determine the logarithm to base two of the fragment size. */ | 729 | Determine the logarithm to base two of the fragment size. */ |
| 793 | register __malloc_size_t log = 1; | 730 | register size_t log = 1; |
| 794 | --size; | 731 | --size; |
| 795 | while ((size /= 2) != 0) | 732 | while ((size /= 2) != 0) |
| 796 | ++log; | 733 | ++log; |
| @@ -803,15 +740,14 @@ _malloc_internal_nolock (size) | |||
| 803 | /* There are free fragments of this size. | 740 | /* There are free fragments of this size. |
| 804 | Pop a fragment out of the fragment list and return it. | 741 | Pop a fragment out of the fragment list and return it. |
| 805 | Update the block's nfree and first counters. */ | 742 | Update the block's nfree and first counters. */ |
| 806 | result = (__ptr_t) next; | 743 | result = next; |
| 807 | next->prev->next = next->next; | 744 | next->prev->next = next->next; |
| 808 | if (next->next != NULL) | 745 | if (next->next != NULL) |
| 809 | next->next->prev = next->prev; | 746 | next->next->prev = next->prev; |
| 810 | block = BLOCK (result); | 747 | block = BLOCK (result); |
| 811 | if (--_heapinfo[block].busy.info.frag.nfree != 0) | 748 | if (--_heapinfo[block].busy.info.frag.nfree != 0) |
| 812 | _heapinfo[block].busy.info.frag.first = (unsigned long int) | 749 | _heapinfo[block].busy.info.frag.first = |
| 813 | ((unsigned long int) ((char *) next->next - (char *) NULL) | 750 | (uintptr_t) next->next % BLOCKSIZE >> log; |
| 814 | % BLOCKSIZE) >> log; | ||
| 815 | 751 | ||
| 816 | /* Update the statistics. */ | 752 | /* Update the statistics. */ |
| 817 | ++_chunks_used; | 753 | ++_chunks_used; |
| @@ -843,7 +779,7 @@ _malloc_internal_nolock (size) | |||
| 843 | next->prev = &_fraghead[log]; | 779 | next->prev = &_fraghead[log]; |
| 844 | _fraghead[log].next = next; | 780 | _fraghead[log].next = next; |
| 845 | 781 | ||
| 846 | for (i = 2; i < (__malloc_size_t) (BLOCKSIZE >> log); ++i) | 782 | for (i = 2; i < (size_t) (BLOCKSIZE >> log); ++i) |
| 847 | { | 783 | { |
| 848 | next = (struct list *) ((char *) result + (i << log)); | 784 | next = (struct list *) ((char *) result + (i << log)); |
| 849 | next->next = _fraghead[log].next; | 785 | next->next = _fraghead[log].next; |
| @@ -877,7 +813,7 @@ _malloc_internal_nolock (size) | |||
| 877 | if (block == start) | 813 | if (block == start) |
| 878 | { | 814 | { |
| 879 | /* Need to get more from the system. Get a little extra. */ | 815 | /* Need to get more from the system. Get a little extra. */ |
| 880 | __malloc_size_t wantblocks = blocks + __malloc_extra_blocks; | 816 | size_t wantblocks = blocks + __malloc_extra_blocks; |
| 881 | block = _heapinfo[0].free.prev; | 817 | block = _heapinfo[0].free.prev; |
| 882 | lastblocks = _heapinfo[block].free.size; | 818 | lastblocks = _heapinfo[block].free.size; |
| 883 | /* Check to see if the new core will be contiguous with the | 819 | /* Check to see if the new core will be contiguous with the |
| @@ -959,11 +895,10 @@ _malloc_internal_nolock (size) | |||
| 959 | return result; | 895 | return result; |
| 960 | } | 896 | } |
| 961 | 897 | ||
| 962 | __ptr_t | 898 | void * |
| 963 | _malloc_internal (size) | 899 | _malloc_internal (size_t size) |
| 964 | __malloc_size_t size; | ||
| 965 | { | 900 | { |
| 966 | __ptr_t result; | 901 | void *result; |
| 967 | 902 | ||
| 968 | LOCK (); | 903 | LOCK (); |
| 969 | result = _malloc_internal_nolock (size); | 904 | result = _malloc_internal_nolock (size); |
| @@ -972,11 +907,10 @@ _malloc_internal (size) | |||
| 972 | return result; | 907 | return result; |
| 973 | } | 908 | } |
| 974 | 909 | ||
| 975 | __ptr_t | 910 | void * |
| 976 | malloc (size) | 911 | malloc (size_t size) |
| 977 | __malloc_size_t size; | ||
| 978 | { | 912 | { |
| 979 | __ptr_t (*hook) (__malloc_size_t); | 913 | void *(*hook) (size_t); |
| 980 | 914 | ||
| 981 | if (!__malloc_initialized && !__malloc_initialize ()) | 915 | if (!__malloc_initialized && !__malloc_initialize ()) |
| 982 | return NULL; | 916 | return NULL; |
| @@ -998,24 +932,24 @@ malloc (size) | |||
| 998 | /* On some ANSI C systems, some libc functions call _malloc, _free | 932 | /* On some ANSI C systems, some libc functions call _malloc, _free |
| 999 | and _realloc. Make them use the GNU functions. */ | 933 | and _realloc. Make them use the GNU functions. */ |
| 1000 | 934 | ||
| 1001 | __ptr_t | 935 | extern void *_malloc (size_t); |
| 1002 | _malloc (size) | 936 | extern void _free (void *); |
| 1003 | __malloc_size_t size; | 937 | extern void *_realloc (void *, size_t); |
| 938 | |||
| 939 | void * | ||
| 940 | _malloc (size_t size) | ||
| 1004 | { | 941 | { |
| 1005 | return malloc (size); | 942 | return malloc (size); |
| 1006 | } | 943 | } |
| 1007 | 944 | ||
| 1008 | void | 945 | void |
| 1009 | _free (ptr) | 946 | _free (void *ptr) |
| 1010 | __ptr_t ptr; | ||
| 1011 | { | 947 | { |
| 1012 | free (ptr); | 948 | free (ptr); |
| 1013 | } | 949 | } |
| 1014 | 950 | ||
| 1015 | __ptr_t | 951 | void * |
| 1016 | _realloc (ptr, size) | 952 | _realloc (void *ptr, size_t size) |
| 1017 | __ptr_t ptr; | ||
| 1018 | __malloc_size_t size; | ||
| 1019 | { | 953 | { |
| 1020 | return realloc (ptr, size); | 954 | return realloc (ptr, size); |
| 1021 | } | 955 | } |
| @@ -1043,14 +977,9 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 1043 | The author may be reached (Email) at the address mike@ai.mit.edu, | 977 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 1044 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 978 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 1045 | 979 | ||
| 1046 | #ifndef _MALLOC_INTERNAL | ||
| 1047 | #define _MALLOC_INTERNAL | ||
| 1048 | #include <malloc.h> | ||
| 1049 | #endif | ||
| 1050 | |||
| 1051 | 980 | ||
| 1052 | /* Debugging hook for free. */ | 981 | /* Debugging hook for free. */ |
| 1053 | void (*__free_hook) PP ((__ptr_t __ptr)); | 982 | void (*__free_hook) (void *__ptr); |
| 1054 | 983 | ||
| 1055 | /* List of blocks allocated by memalign. */ | 984 | /* List of blocks allocated by memalign. */ |
| 1056 | struct alignlist *_aligned_blocks = NULL; | 985 | struct alignlist *_aligned_blocks = NULL; |
| @@ -1058,15 +987,14 @@ struct alignlist *_aligned_blocks = NULL; | |||
| 1058 | /* Return memory to the heap. | 987 | /* Return memory to the heap. |
| 1059 | Like `_free_internal' but don't lock mutex. */ | 988 | Like `_free_internal' but don't lock mutex. */ |
| 1060 | void | 989 | void |
| 1061 | _free_internal_nolock (ptr) | 990 | _free_internal_nolock (void *ptr) |
| 1062 | __ptr_t ptr; | ||
| 1063 | { | 991 | { |
| 1064 | int type; | 992 | int type; |
| 1065 | __malloc_size_t block, blocks; | 993 | size_t block, blocks; |
| 1066 | register __malloc_size_t i; | 994 | register size_t i; |
| 1067 | struct list *prev, *next; | 995 | struct list *prev, *next; |
| 1068 | __ptr_t curbrk; | 996 | void *curbrk; |
| 1069 | const __malloc_size_t lesscore_threshold | 997 | const size_t lesscore_threshold |
| 1070 | /* Threshold of free space at which we will return some to the system. */ | 998 | /* Threshold of free space at which we will return some to the system. */ |
| 1071 | = FINAL_FREE_BLOCKS + 2 * __malloc_extra_blocks; | 999 | = FINAL_FREE_BLOCKS + 2 * __malloc_extra_blocks; |
| 1072 | 1000 | ||
| @@ -1076,7 +1004,7 @@ _free_internal_nolock (ptr) | |||
| 1076 | return; | 1004 | return; |
| 1077 | 1005 | ||
| 1078 | #ifdef CYGWIN | 1006 | #ifdef CYGWIN |
| 1079 | if (ptr < _heapbase) | 1007 | if ((char *) ptr < _heapbase) |
| 1080 | /* We're being asked to free something in the static heap. */ | 1008 | /* We're being asked to free something in the static heap. */ |
| 1081 | return; | 1009 | return; |
| 1082 | #endif | 1010 | #endif |
| @@ -1162,12 +1090,12 @@ _free_internal_nolock (ptr) | |||
| 1162 | It's possible that moving _heapinfo will allow us to | 1090 | It's possible that moving _heapinfo will allow us to |
| 1163 | return some space to the system. */ | 1091 | return some space to the system. */ |
| 1164 | 1092 | ||
| 1165 | __malloc_size_t info_block = BLOCK (_heapinfo); | 1093 | size_t info_block = BLOCK (_heapinfo); |
| 1166 | __malloc_size_t info_blocks = _heapinfo[info_block].busy.info.size; | 1094 | size_t info_blocks = _heapinfo[info_block].busy.info.size; |
| 1167 | __malloc_size_t prev_block = _heapinfo[block].free.prev; | 1095 | size_t prev_block = _heapinfo[block].free.prev; |
| 1168 | __malloc_size_t prev_blocks = _heapinfo[prev_block].free.size; | 1096 | size_t prev_blocks = _heapinfo[prev_block].free.size; |
| 1169 | __malloc_size_t next_block = _heapinfo[block].free.next; | 1097 | size_t next_block = _heapinfo[block].free.next; |
| 1170 | __malloc_size_t next_blocks = _heapinfo[next_block].free.size; | 1098 | size_t next_blocks = _heapinfo[next_block].free.size; |
| 1171 | 1099 | ||
| 1172 | if (/* Win if this block being freed is last in core, the info table | 1100 | if (/* Win if this block being freed is last in core, the info table |
| 1173 | is just before it, the previous free block is just before the | 1101 | is just before it, the previous free block is just before the |
| @@ -1190,7 +1118,7 @@ _free_internal_nolock (ptr) | |||
| 1190 | ) | 1118 | ) |
| 1191 | { | 1119 | { |
| 1192 | malloc_info *newinfo; | 1120 | malloc_info *newinfo; |
| 1193 | __malloc_size_t oldlimit = _heaplimit; | 1121 | size_t oldlimit = _heaplimit; |
| 1194 | 1122 | ||
| 1195 | /* Free the old info table, clearing _heaplimit to avoid | 1123 | /* Free the old info table, clearing _heaplimit to avoid |
| 1196 | recursion into this code. We don't want to return the | 1124 | recursion into this code. We don't want to return the |
| @@ -1205,8 +1133,7 @@ _free_internal_nolock (ptr) | |||
| 1205 | _heapindex = 0; | 1133 | _heapindex = 0; |
| 1206 | 1134 | ||
| 1207 | /* Allocate new space for the info table and move its data. */ | 1135 | /* Allocate new space for the info table and move its data. */ |
| 1208 | newinfo = (malloc_info *) _malloc_internal_nolock (info_blocks | 1136 | newinfo = _malloc_internal_nolock (info_blocks * BLOCKSIZE); |
| 1209 | * BLOCKSIZE); | ||
| 1210 | PROTECT_MALLOC_STATE (0); | 1137 | PROTECT_MALLOC_STATE (0); |
| 1211 | memmove (newinfo, _heapinfo, info_blocks * BLOCKSIZE); | 1138 | memmove (newinfo, _heapinfo, info_blocks * BLOCKSIZE); |
| 1212 | _heapinfo = newinfo; | 1139 | _heapinfo = newinfo; |
| @@ -1222,7 +1149,7 @@ _free_internal_nolock (ptr) | |||
| 1222 | /* Now see if we can return stuff to the system. */ | 1149 | /* Now see if we can return stuff to the system. */ |
| 1223 | if (block + blocks == _heaplimit && blocks >= lesscore_threshold) | 1150 | if (block + blocks == _heaplimit && blocks >= lesscore_threshold) |
| 1224 | { | 1151 | { |
| 1225 | register __malloc_size_t bytes = blocks * BLOCKSIZE; | 1152 | register size_t bytes = blocks * BLOCKSIZE; |
| 1226 | _heaplimit -= blocks; | 1153 | _heaplimit -= blocks; |
| 1227 | (*__morecore) (-bytes); | 1154 | (*__morecore) (-bytes); |
| 1228 | _heapinfo[_heapinfo[block].free.prev].free.next | 1155 | _heapinfo[_heapinfo[block].free.prev].free.next |
| @@ -1255,7 +1182,7 @@ _free_internal_nolock (ptr) | |||
| 1255 | /* If all fragments of this block are free, remove them | 1182 | /* If all fragments of this block are free, remove them |
| 1256 | from the fragment list and free the whole block. */ | 1183 | from the fragment list and free the whole block. */ |
| 1257 | next = prev; | 1184 | next = prev; |
| 1258 | for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> type); ++i) | 1185 | for (i = 1; i < (size_t) (BLOCKSIZE >> type); ++i) |
| 1259 | next = next->next; | 1186 | next = next->next; |
| 1260 | prev->prev->next = next; | 1187 | prev->prev->next = next; |
| 1261 | if (next != NULL) | 1188 | if (next != NULL) |
| @@ -1280,7 +1207,7 @@ _free_internal_nolock (ptr) | |||
| 1280 | /* If some fragments of this block are free, link this | 1207 | /* If some fragments of this block are free, link this |
| 1281 | fragment into the fragment list after the first free | 1208 | fragment into the fragment list after the first free |
| 1282 | fragment of this block. */ | 1209 | fragment of this block. */ |
| 1283 | next = (struct list *) ptr; | 1210 | next = ptr; |
| 1284 | next->next = prev->next; | 1211 | next->next = prev->next; |
| 1285 | next->prev = prev; | 1212 | next->prev = prev; |
| 1286 | prev->next = next; | 1213 | prev->next = next; |
| @@ -1293,11 +1220,10 @@ _free_internal_nolock (ptr) | |||
| 1293 | /* No fragments of this block are free, so link this | 1220 | /* No fragments of this block are free, so link this |
| 1294 | fragment into the fragment list and announce that | 1221 | fragment into the fragment list and announce that |
| 1295 | it is the first free fragment of this block. */ | 1222 | it is the first free fragment of this block. */ |
| 1296 | prev = (struct list *) ptr; | 1223 | prev = ptr; |
| 1297 | _heapinfo[block].busy.info.frag.nfree = 1; | 1224 | _heapinfo[block].busy.info.frag.nfree = 1; |
| 1298 | _heapinfo[block].busy.info.frag.first = (unsigned long int) | 1225 | _heapinfo[block].busy.info.frag.first = |
| 1299 | ((unsigned long int) ((char *) ptr - (char *) NULL) | 1226 | (uintptr_t) ptr % BLOCKSIZE >> type; |
| 1300 | % BLOCKSIZE >> type); | ||
| 1301 | prev->next = _fraghead[type].next; | 1227 | prev->next = _fraghead[type].next; |
| 1302 | prev->prev = &_fraghead[type]; | 1228 | prev->prev = &_fraghead[type]; |
| 1303 | prev->prev->next = prev; | 1229 | prev->prev->next = prev; |
| @@ -1313,8 +1239,7 @@ _free_internal_nolock (ptr) | |||
| 1313 | /* Return memory to the heap. | 1239 | /* Return memory to the heap. |
| 1314 | Like `free' but don't call a __free_hook if there is one. */ | 1240 | Like `free' but don't call a __free_hook if there is one. */ |
| 1315 | void | 1241 | void |
| 1316 | _free_internal (ptr) | 1242 | _free_internal (void *ptr) |
| 1317 | __ptr_t ptr; | ||
| 1318 | { | 1243 | { |
| 1319 | LOCK (); | 1244 | LOCK (); |
| 1320 | _free_internal_nolock (ptr); | 1245 | _free_internal_nolock (ptr); |
| @@ -1324,10 +1249,9 @@ _free_internal (ptr) | |||
| 1324 | /* Return memory to the heap. */ | 1249 | /* Return memory to the heap. */ |
| 1325 | 1250 | ||
| 1326 | void | 1251 | void |
| 1327 | free (ptr) | 1252 | free (void *ptr) |
| 1328 | __ptr_t ptr; | ||
| 1329 | { | 1253 | { |
| 1330 | void (*hook) (__ptr_t) = __free_hook; | 1254 | void (*hook) (void *) = __free_hook; |
| 1331 | 1255 | ||
| 1332 | if (hook != NULL) | 1256 | if (hook != NULL) |
| 1333 | (*hook) (ptr); | 1257 | (*hook) (ptr); |
| @@ -1340,8 +1264,7 @@ free (ptr) | |||
| 1340 | weak_alias (free, cfree) | 1264 | weak_alias (free, cfree) |
| 1341 | #else | 1265 | #else |
| 1342 | void | 1266 | void |
| 1343 | cfree (ptr) | 1267 | cfree (void *ptr) |
| 1344 | __ptr_t ptr; | ||
| 1345 | { | 1268 | { |
| 1346 | free (ptr); | 1269 | free (ptr); |
| 1347 | } | 1270 | } |
| @@ -1368,32 +1291,24 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 1368 | The author may be reached (Email) at the address mike@ai.mit.edu, | 1291 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 1369 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 1292 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 1370 | 1293 | ||
| 1371 | #ifndef _MALLOC_INTERNAL | ||
| 1372 | #define _MALLOC_INTERNAL | ||
| 1373 | #include <malloc.h> | ||
| 1374 | #endif | ||
| 1375 | |||
| 1376 | |||
| 1377 | #define min(A, B) ((A) < (B) ? (A) : (B)) | 1294 | #define min(A, B) ((A) < (B) ? (A) : (B)) |
| 1378 | 1295 | ||
| 1379 | /* On Cygwin the dumped emacs may try to realloc storage allocated in | 1296 | /* On Cygwin the dumped emacs may try to realloc storage allocated in |
| 1380 | the static heap. We just malloc space in the new heap and copy the | 1297 | the static heap. We just malloc space in the new heap and copy the |
| 1381 | data. */ | 1298 | data. */ |
| 1382 | #ifdef CYGWIN | 1299 | #ifdef CYGWIN |
| 1383 | __ptr_t | 1300 | void * |
| 1384 | special_realloc (ptr, size) | 1301 | special_realloc (void *ptr, size_t size) |
| 1385 | __ptr_t ptr; | ||
| 1386 | __malloc_size_t size; | ||
| 1387 | { | 1302 | { |
| 1388 | __ptr_t result; | 1303 | void *result; |
| 1389 | int type; | 1304 | int type; |
| 1390 | __malloc_size_t block, oldsize; | 1305 | size_t block, oldsize; |
| 1391 | 1306 | ||
| 1392 | block = ((char *) ptr - bss_sbrk_heapbase) / BLOCKSIZE + 1; | 1307 | block = ((char *) ptr - bss_sbrk_heapbase) / BLOCKSIZE + 1; |
| 1393 | type = bss_sbrk_heapinfo[block].busy.type; | 1308 | type = bss_sbrk_heapinfo[block].busy.type; |
| 1394 | oldsize = | 1309 | oldsize = |
| 1395 | type == 0 ? bss_sbrk_heapinfo[block].busy.info.size * BLOCKSIZE | 1310 | type == 0 ? bss_sbrk_heapinfo[block].busy.info.size * BLOCKSIZE |
| 1396 | : (__malloc_size_t) 1 << type; | 1311 | : (size_t) 1 << type; |
| 1397 | result = _malloc_internal_nolock (size); | 1312 | result = _malloc_internal_nolock (size); |
| 1398 | if (result != NULL) | 1313 | if (result != NULL) |
| 1399 | memcpy (result, ptr, min (oldsize, size)); | 1314 | memcpy (result, ptr, min (oldsize, size)); |
| @@ -1402,7 +1317,7 @@ special_realloc (ptr, size) | |||
| 1402 | #endif | 1317 | #endif |
| 1403 | 1318 | ||
| 1404 | /* Debugging hook for realloc. */ | 1319 | /* Debugging hook for realloc. */ |
| 1405 | __ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size)); | 1320 | void *(*__realloc_hook) (void *ptr, size_t size); |
| 1406 | 1321 | ||
| 1407 | /* Resize the given region to the new size, returning a pointer | 1322 | /* Resize the given region to the new size, returning a pointer |
| 1408 | to the (possibly moved) region. This is optimized for speed; | 1323 | to the (possibly moved) region. This is optimized for speed; |
| @@ -1410,14 +1325,12 @@ __ptr_t (*__realloc_hook) PP ((__ptr_t __ptr, __malloc_size_t __size)); | |||
| 1410 | achieved by unconditionally allocating and copying to a | 1325 | achieved by unconditionally allocating and copying to a |
| 1411 | new region. This module has incestuous knowledge of the | 1326 | new region. This module has incestuous knowledge of the |
| 1412 | internals of both free and malloc. */ | 1327 | internals of both free and malloc. */ |
| 1413 | __ptr_t | 1328 | void * |
| 1414 | _realloc_internal_nolock (ptr, size) | 1329 | _realloc_internal_nolock (void *ptr, size_t size) |
| 1415 | __ptr_t ptr; | ||
| 1416 | __malloc_size_t size; | ||
| 1417 | { | 1330 | { |
| 1418 | __ptr_t result; | 1331 | void *result; |
| 1419 | int type; | 1332 | int type; |
| 1420 | __malloc_size_t block, blocks, oldlimit; | 1333 | size_t block, blocks, oldlimit; |
| 1421 | 1334 | ||
| 1422 | if (size == 0) | 1335 | if (size == 0) |
| 1423 | { | 1336 | { |
| @@ -1428,7 +1341,7 @@ _realloc_internal_nolock (ptr, size) | |||
| 1428 | return _malloc_internal_nolock (size); | 1341 | return _malloc_internal_nolock (size); |
| 1429 | 1342 | ||
| 1430 | #ifdef CYGWIN | 1343 | #ifdef CYGWIN |
| 1431 | if (ptr < _heapbase) | 1344 | if ((char *) ptr < _heapbase) |
| 1432 | /* ptr points into the static heap */ | 1345 | /* ptr points into the static heap */ |
| 1433 | return special_realloc (ptr, size); | 1346 | return special_realloc (ptr, size); |
| 1434 | #endif | 1347 | #endif |
| @@ -1497,7 +1410,7 @@ _realloc_internal_nolock (ptr, size) | |||
| 1497 | (void) _malloc_internal_nolock (blocks * BLOCKSIZE); | 1410 | (void) _malloc_internal_nolock (blocks * BLOCKSIZE); |
| 1498 | else | 1411 | else |
| 1499 | { | 1412 | { |
| 1500 | __ptr_t previous | 1413 | void *previous |
| 1501 | = _malloc_internal_nolock ((block - _heapindex) * BLOCKSIZE); | 1414 | = _malloc_internal_nolock ((block - _heapindex) * BLOCKSIZE); |
| 1502 | (void) _malloc_internal_nolock (blocks * BLOCKSIZE); | 1415 | (void) _malloc_internal_nolock (blocks * BLOCKSIZE); |
| 1503 | _free_internal_nolock (previous); | 1416 | _free_internal_nolock (previous); |
| @@ -1512,8 +1425,8 @@ _realloc_internal_nolock (ptr, size) | |||
| 1512 | default: | 1425 | default: |
| 1513 | /* Old size is a fragment; type is logarithm | 1426 | /* Old size is a fragment; type is logarithm |
| 1514 | to base two of the fragment size. */ | 1427 | to base two of the fragment size. */ |
| 1515 | if (size > (__malloc_size_t) (1 << (type - 1)) && | 1428 | if (size > (size_t) (1 << (type - 1)) && |
| 1516 | size <= (__malloc_size_t) (1 << type)) | 1429 | size <= (size_t) (1 << type)) |
| 1517 | /* The new size is the same kind of fragment. */ | 1430 | /* The new size is the same kind of fragment. */ |
| 1518 | result = ptr; | 1431 | result = ptr; |
| 1519 | else | 1432 | else |
| @@ -1523,7 +1436,7 @@ _realloc_internal_nolock (ptr, size) | |||
| 1523 | result = _malloc_internal_nolock (size); | 1436 | result = _malloc_internal_nolock (size); |
| 1524 | if (result == NULL) | 1437 | if (result == NULL) |
| 1525 | goto out; | 1438 | goto out; |
| 1526 | memcpy (result, ptr, min (size, (__malloc_size_t) 1 << type)); | 1439 | memcpy (result, ptr, min (size, (size_t) 1 << type)); |
| 1527 | _free_internal_nolock (ptr); | 1440 | _free_internal_nolock (ptr); |
| 1528 | } | 1441 | } |
| 1529 | break; | 1442 | break; |
| @@ -1534,12 +1447,10 @@ _realloc_internal_nolock (ptr, size) | |||
| 1534 | return result; | 1447 | return result; |
| 1535 | } | 1448 | } |
| 1536 | 1449 | ||
| 1537 | __ptr_t | 1450 | void * |
| 1538 | _realloc_internal (ptr, size) | 1451 | _realloc_internal (void *ptr, size_t size) |
| 1539 | __ptr_t ptr; | ||
| 1540 | __malloc_size_t size; | ||
| 1541 | { | 1452 | { |
| 1542 | __ptr_t result; | 1453 | void *result; |
| 1543 | 1454 | ||
| 1544 | LOCK (); | 1455 | LOCK (); |
| 1545 | result = _realloc_internal_nolock (ptr, size); | 1456 | result = _realloc_internal_nolock (ptr, size); |
| @@ -1548,12 +1459,10 @@ _realloc_internal (ptr, size) | |||
| 1548 | return result; | 1459 | return result; |
| 1549 | } | 1460 | } |
| 1550 | 1461 | ||
| 1551 | __ptr_t | 1462 | void * |
| 1552 | realloc (ptr, size) | 1463 | realloc (void *ptr, size_t size) |
| 1553 | __ptr_t ptr; | ||
| 1554 | __malloc_size_t size; | ||
| 1555 | { | 1464 | { |
| 1556 | __ptr_t (*hook) (__ptr_t, __malloc_size_t); | 1465 | void *(*hook) (void *, size_t); |
| 1557 | 1466 | ||
| 1558 | if (!__malloc_initialized && !__malloc_initialize ()) | 1467 | if (!__malloc_initialized && !__malloc_initialize ()) |
| 1559 | return NULL; | 1468 | return NULL; |
| @@ -1581,19 +1490,12 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 1581 | The author may be reached (Email) at the address mike@ai.mit.edu, | 1490 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 1582 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 1491 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 1583 | 1492 | ||
| 1584 | #ifndef _MALLOC_INTERNAL | ||
| 1585 | #define _MALLOC_INTERNAL | ||
| 1586 | #include <malloc.h> | ||
| 1587 | #endif | ||
| 1588 | |||
| 1589 | /* Allocate an array of NMEMB elements each SIZE bytes long. | 1493 | /* Allocate an array of NMEMB elements each SIZE bytes long. |
| 1590 | The entire array is initialized to zeros. */ | 1494 | The entire array is initialized to zeros. */ |
| 1591 | __ptr_t | 1495 | void * |
| 1592 | calloc (nmemb, size) | 1496 | calloc (register size_t nmemb, register size_t size) |
| 1593 | register __malloc_size_t nmemb; | ||
| 1594 | register __malloc_size_t size; | ||
| 1595 | { | 1497 | { |
| 1596 | register __ptr_t result = malloc (nmemb * size); | 1498 | register void *result = malloc (nmemb * size); |
| 1597 | 1499 | ||
| 1598 | if (result != NULL) | 1500 | if (result != NULL) |
| 1599 | (void) memset (result, 0, nmemb * size); | 1501 | (void) memset (result, 0, nmemb * size); |
| @@ -1618,11 +1520,6 @@ along with the GNU C Library; see the file COPYING. If not, write to | |||
| 1618 | the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, | 1520 | the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, |
| 1619 | MA 02110-1301, USA. */ | 1521 | MA 02110-1301, USA. */ |
| 1620 | 1522 | ||
| 1621 | #ifndef _MALLOC_INTERNAL | ||
| 1622 | #define _MALLOC_INTERNAL | ||
| 1623 | #include <malloc.h> | ||
| 1624 | #endif | ||
| 1625 | |||
| 1626 | /* uClibc defines __GNU_LIBRARY__, but it is not completely | 1523 | /* uClibc defines __GNU_LIBRARY__, but it is not completely |
| 1627 | compatible. */ | 1524 | compatible. */ |
| 1628 | #if !defined (__GNU_LIBRARY__) || defined (__UCLIBC__) | 1525 | #if !defined (__GNU_LIBRARY__) || defined (__UCLIBC__) |
| @@ -1631,30 +1528,24 @@ MA 02110-1301, USA. */ | |||
| 1631 | /* It is best not to declare this and cast its result on foreign operating | 1528 | /* It is best not to declare this and cast its result on foreign operating |
| 1632 | systems with potentially hostile include files. */ | 1529 | systems with potentially hostile include files. */ |
| 1633 | 1530 | ||
| 1634 | #include <stddef.h> | 1531 | extern void *__sbrk (ptrdiff_t increment); |
| 1635 | extern __ptr_t __sbrk PP ((ptrdiff_t increment)); | ||
| 1636 | #endif /* __GNU_LIBRARY__ && ! defined (__UCLIBC__) */ | 1532 | #endif /* __GNU_LIBRARY__ && ! defined (__UCLIBC__) */ |
| 1637 | 1533 | ||
| 1638 | #ifndef NULL | ||
| 1639 | #define NULL 0 | ||
| 1640 | #endif | ||
| 1641 | |||
| 1642 | /* Allocate INCREMENT more bytes of data space, | 1534 | /* Allocate INCREMENT more bytes of data space, |
| 1643 | and return the start of data space, or NULL on errors. | 1535 | and return the start of data space, or NULL on errors. |
| 1644 | If INCREMENT is negative, shrink data space. */ | 1536 | If INCREMENT is negative, shrink data space. */ |
| 1645 | __ptr_t | 1537 | void * |
| 1646 | __default_morecore (increment) | 1538 | __default_morecore (ptrdiff_t increment) |
| 1647 | __malloc_ptrdiff_t increment; | ||
| 1648 | { | 1539 | { |
| 1649 | __ptr_t result; | 1540 | void *result; |
| 1650 | #if defined (CYGWIN) | 1541 | #if defined (CYGWIN) |
| 1651 | if (!bss_sbrk_did_unexec) | 1542 | if (!bss_sbrk_did_unexec) |
| 1652 | { | 1543 | { |
| 1653 | return bss_sbrk (increment); | 1544 | return bss_sbrk (increment); |
| 1654 | } | 1545 | } |
| 1655 | #endif | 1546 | #endif |
| 1656 | result = (__ptr_t) __sbrk (increment); | 1547 | result = (void *) __sbrk (increment); |
| 1657 | if (result == (__ptr_t) -1) | 1548 | if (result == (void *) -1) |
| 1658 | return NULL; | 1549 | return NULL; |
| 1659 | return result; | 1550 | return result; |
| 1660 | } | 1551 | } |
| @@ -1675,22 +1566,14 @@ License along with this library; see the file COPYING. If | |||
| 1675 | not, write to the Free Software Foundation, Inc., 51 Franklin Street, | 1566 | not, write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 1676 | Fifth Floor, Boston, MA 02110-1301, USA. */ | 1567 | Fifth Floor, Boston, MA 02110-1301, USA. */ |
| 1677 | 1568 | ||
| 1678 | #ifndef _MALLOC_INTERNAL | 1569 | void *(*__memalign_hook) (size_t size, size_t alignment); |
| 1679 | #define _MALLOC_INTERNAL | ||
| 1680 | #include <malloc.h> | ||
| 1681 | #endif | ||
| 1682 | |||
| 1683 | __ptr_t (*__memalign_hook) PP ((__malloc_size_t __size, | ||
| 1684 | __malloc_size_t __alignment)); | ||
| 1685 | 1570 | ||
| 1686 | __ptr_t | 1571 | void * |
| 1687 | memalign (alignment, size) | 1572 | memalign (size_t alignment, size_t size) |
| 1688 | __malloc_size_t alignment; | ||
| 1689 | __malloc_size_t size; | ||
| 1690 | { | 1573 | { |
| 1691 | __ptr_t result; | 1574 | void *result; |
| 1692 | unsigned long int adj, lastadj; | 1575 | size_t adj, lastadj; |
| 1693 | __ptr_t (*hook) (__malloc_size_t, __malloc_size_t) = __memalign_hook; | 1576 | void *(*hook) (size_t, size_t) = __memalign_hook; |
| 1694 | 1577 | ||
| 1695 | if (hook) | 1578 | if (hook) |
| 1696 | return (*hook) (alignment, size); | 1579 | return (*hook) (alignment, size); |
| @@ -1703,7 +1586,7 @@ memalign (alignment, size) | |||
| 1703 | 1586 | ||
| 1704 | /* Figure out how much we will need to pad this particular block | 1587 | /* Figure out how much we will need to pad this particular block |
| 1705 | to achieve the required alignment. */ | 1588 | to achieve the required alignment. */ |
| 1706 | adj = (unsigned long int) ((char *) result - (char *) NULL) % alignment; | 1589 | adj = (uintptr_t) result % alignment; |
| 1707 | 1590 | ||
| 1708 | do | 1591 | do |
| 1709 | { | 1592 | { |
| @@ -1714,7 +1597,7 @@ memalign (alignment, size) | |||
| 1714 | return NULL; | 1597 | return NULL; |
| 1715 | 1598 | ||
| 1716 | lastadj = adj; | 1599 | lastadj = adj; |
| 1717 | adj = (unsigned long int) ((char *) result - (char *) NULL) % alignment; | 1600 | adj = (uintptr_t) result % alignment; |
| 1718 | /* It's conceivable we might have been so unlucky as to get a | 1601 | /* It's conceivable we might have been so unlucky as to get a |
| 1719 | different block with weaker alignment. If so, this block is too | 1602 | different block with weaker alignment. If so, this block is too |
| 1720 | short to contain SIZE after alignment correction. So we must | 1603 | short to contain SIZE after alignment correction. So we must |
| @@ -1735,7 +1618,7 @@ memalign (alignment, size) | |||
| 1735 | break; | 1618 | break; |
| 1736 | if (l == NULL) | 1619 | if (l == NULL) |
| 1737 | { | 1620 | { |
| 1738 | l = (struct alignlist *) malloc (sizeof (struct alignlist)); | 1621 | l = malloc (sizeof (struct alignlist)); |
| 1739 | if (l != NULL) | 1622 | if (l != NULL) |
| 1740 | { | 1623 | { |
| 1741 | l->next = _aligned_blocks; | 1624 | l->next = _aligned_blocks; |
| @@ -1767,15 +1650,12 @@ memalign (alignment, size) | |||
| 1767 | #endif | 1650 | #endif |
| 1768 | 1651 | ||
| 1769 | int | 1652 | int |
| 1770 | posix_memalign (memptr, alignment, size) | 1653 | posix_memalign (void **memptr, size_t alignment, size_t size) |
| 1771 | __ptr_t *memptr; | ||
| 1772 | __malloc_size_t alignment; | ||
| 1773 | __malloc_size_t size; | ||
| 1774 | { | 1654 | { |
| 1775 | __ptr_t mem; | 1655 | void *mem; |
| 1776 | 1656 | ||
| 1777 | if (alignment == 0 | 1657 | if (alignment == 0 |
| 1778 | || alignment % sizeof (__ptr_t) != 0 | 1658 | || alignment % sizeof (void *) != 0 |
| 1779 | || (alignment & (alignment - 1)) != 0) | 1659 | || (alignment & (alignment - 1)) != 0) |
| 1780 | return EINVAL; | 1660 | return EINVAL; |
| 1781 | 1661 | ||
| @@ -1809,43 +1689,27 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 1809 | The author may be reached (Email) at the address mike@ai.mit.edu, | 1689 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 1810 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 1690 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 1811 | 1691 | ||
| 1812 | #if defined (_MALLOC_INTERNAL) && defined (GMALLOC_INHIBIT_VALLOC) | ||
| 1813 | |||
| 1814 | /* Emacs defines GMALLOC_INHIBIT_VALLOC to avoid this definition | 1692 | /* Emacs defines GMALLOC_INHIBIT_VALLOC to avoid this definition |
| 1815 | on MSDOS, where it conflicts with a system header file. */ | 1693 | on MSDOS, where it conflicts with a system header file. */ |
| 1816 | 1694 | ||
| 1817 | #define ELIDE_VALLOC | 1695 | #ifndef GMALLOC_INHIBIT_VALLOC |
| 1818 | 1696 | ||
| 1819 | #endif | 1697 | /* Allocate SIZE bytes on a page boundary. */ |
| 1820 | 1698 | extern void *valloc (size_t); | |
| 1821 | #ifndef ELIDE_VALLOC | ||
| 1822 | |||
| 1823 | #if defined (__GNU_LIBRARY__) || defined (_LIBC) | ||
| 1824 | #include <stddef.h> | ||
| 1825 | #include <sys/cdefs.h> | ||
| 1826 | #if defined (__GLIBC__) && __GLIBC__ >= 2 | ||
| 1827 | /* __getpagesize is already declared in <unistd.h> with return type int */ | ||
| 1828 | #else | ||
| 1829 | extern size_t __getpagesize PP ((void)); | ||
| 1830 | #endif | ||
| 1831 | #else | ||
| 1832 | #include "getpagesize.h" | ||
| 1833 | #define __getpagesize() getpagesize () | ||
| 1834 | #endif | ||
| 1835 | 1699 | ||
| 1836 | #ifndef _MALLOC_INTERNAL | 1700 | #if defined _SC_PAGESIZE || !defined HAVE_GETPAGESIZE |
| 1837 | #define _MALLOC_INTERNAL | 1701 | # include "getpagesize.h" |
| 1838 | #include <malloc.h> | 1702 | #elif !defined getpagesize |
| 1703 | extern int getpagesize (void); | ||
| 1839 | #endif | 1704 | #endif |
| 1840 | 1705 | ||
| 1841 | static __malloc_size_t pagesize; | 1706 | static size_t pagesize; |
| 1842 | 1707 | ||
| 1843 | __ptr_t | 1708 | void * |
| 1844 | valloc (size) | 1709 | valloc (size_t size) |
| 1845 | __malloc_size_t size; | ||
| 1846 | { | 1710 | { |
| 1847 | if (pagesize == 0) | 1711 | if (pagesize == 0) |
| 1848 | pagesize = __getpagesize (); | 1712 | pagesize = getpagesize (); |
| 1849 | 1713 | ||
| 1850 | return memalign (pagesize, size); | 1714 | return memalign (pagesize, size); |
| 1851 | } | 1715 | } |
| @@ -1876,41 +1740,31 @@ Fifth Floor, Boston, MA 02110-1301, USA. | |||
| 1876 | The author may be reached (Email) at the address mike@ai.mit.edu, | 1740 | The author may be reached (Email) at the address mike@ai.mit.edu, |
| 1877 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ | 1741 | or (US mail) as Mike Haertel c/o Free Software Foundation. */ |
| 1878 | 1742 | ||
| 1879 | #ifdef emacs | ||
| 1880 | #include <stdio.h> | ||
| 1881 | #else | ||
| 1882 | #ifndef _MALLOC_INTERNAL | ||
| 1883 | #define _MALLOC_INTERNAL | ||
| 1884 | #include <malloc.h> | ||
| 1885 | #include <stdio.h> | 1743 | #include <stdio.h> |
| 1886 | #endif | ||
| 1887 | #endif | ||
| 1888 | 1744 | ||
| 1889 | /* Old hook values. */ | 1745 | /* Old hook values. */ |
| 1890 | static void (*old_free_hook) (__ptr_t ptr); | 1746 | static void (*old_free_hook) (void *ptr); |
| 1891 | static __ptr_t (*old_malloc_hook) (__malloc_size_t size); | 1747 | static void *(*old_malloc_hook) (size_t size); |
| 1892 | static __ptr_t (*old_realloc_hook) (__ptr_t ptr, __malloc_size_t size); | 1748 | static void *(*old_realloc_hook) (void *ptr, size_t size); |
| 1893 | 1749 | ||
| 1894 | /* Function to call when something awful happens. */ | 1750 | /* Function to call when something awful happens. */ |
| 1895 | static void (*abortfunc) (enum mcheck_status); | 1751 | static void (*abortfunc) (enum mcheck_status); |
| 1896 | 1752 | ||
| 1897 | /* Arbitrary magical numbers. */ | 1753 | /* Arbitrary magical numbers. */ |
| 1898 | #define MAGICWORD 0xfedabeeb | 1754 | #define MAGICWORD (SIZE_MAX / 11 ^ SIZE_MAX / 13 << 3) |
| 1899 | #define MAGICFREE 0xd8675309 | 1755 | #define MAGICFREE (SIZE_MAX / 17 ^ SIZE_MAX / 19 << 4) |
| 1900 | #define MAGICBYTE ((char) 0xd7) | 1756 | #define MAGICBYTE ((char) 0xd7) |
| 1901 | #define MALLOCFLOOD ((char) 0x93) | 1757 | #define MALLOCFLOOD ((char) 0x93) |
| 1902 | #define FREEFLOOD ((char) 0x95) | 1758 | #define FREEFLOOD ((char) 0x95) |
| 1903 | 1759 | ||
| 1904 | struct hdr | 1760 | struct hdr |
| 1905 | { | 1761 | { |
| 1906 | __malloc_size_t size; /* Exact size requested by user. */ | 1762 | size_t size; /* Exact size requested by user. */ |
| 1907 | unsigned long int magic; /* Magic number to check header integrity. */ | 1763 | size_t magic; /* Magic number to check header integrity. */ |
| 1908 | }; | 1764 | }; |
| 1909 | 1765 | ||
| 1910 | static enum mcheck_status checkhdr (const struct hdr *); | ||
| 1911 | static enum mcheck_status | 1766 | static enum mcheck_status |
| 1912 | checkhdr (hdr) | 1767 | checkhdr (const struct hdr *hdr) |
| 1913 | const struct hdr *hdr; | ||
| 1914 | { | 1768 | { |
| 1915 | enum mcheck_status status; | 1769 | enum mcheck_status status; |
| 1916 | switch (hdr->magic) | 1770 | switch (hdr->magic) |
| @@ -1933,10 +1787,8 @@ checkhdr (hdr) | |||
| 1933 | return status; | 1787 | return status; |
| 1934 | } | 1788 | } |
| 1935 | 1789 | ||
| 1936 | static void freehook (__ptr_t); | ||
| 1937 | static void | 1790 | static void |
| 1938 | freehook (ptr) | 1791 | freehook (void *ptr) |
| 1939 | __ptr_t ptr; | ||
| 1940 | { | 1792 | { |
| 1941 | struct hdr *hdr; | 1793 | struct hdr *hdr; |
| 1942 | 1794 | ||
| @@ -1955,15 +1807,13 @@ freehook (ptr) | |||
| 1955 | __free_hook = freehook; | 1807 | __free_hook = freehook; |
| 1956 | } | 1808 | } |
| 1957 | 1809 | ||
| 1958 | static __ptr_t mallochook (__malloc_size_t); | 1810 | static void * |
| 1959 | static __ptr_t | 1811 | mallochook (size_t size) |
| 1960 | mallochook (size) | ||
| 1961 | __malloc_size_t size; | ||
| 1962 | { | 1812 | { |
| 1963 | struct hdr *hdr; | 1813 | struct hdr *hdr; |
| 1964 | 1814 | ||
| 1965 | __malloc_hook = old_malloc_hook; | 1815 | __malloc_hook = old_malloc_hook; |
| 1966 | hdr = (struct hdr *) malloc (sizeof (struct hdr) + size + 1); | 1816 | hdr = malloc (sizeof (struct hdr) + size + 1); |
| 1967 | __malloc_hook = mallochook; | 1817 | __malloc_hook = mallochook; |
| 1968 | if (hdr == NULL) | 1818 | if (hdr == NULL) |
| 1969 | return NULL; | 1819 | return NULL; |
| @@ -1971,18 +1821,15 @@ mallochook (size) | |||
| 1971 | hdr->size = size; | 1821 | hdr->size = size; |
| 1972 | hdr->magic = MAGICWORD; | 1822 | hdr->magic = MAGICWORD; |
| 1973 | ((char *) &hdr[1])[size] = MAGICBYTE; | 1823 | ((char *) &hdr[1])[size] = MAGICBYTE; |
| 1974 | memset ((__ptr_t) (hdr + 1), MALLOCFLOOD, size); | 1824 | memset (hdr + 1, MALLOCFLOOD, size); |
| 1975 | return (__ptr_t) (hdr + 1); | 1825 | return hdr + 1; |
| 1976 | } | 1826 | } |
| 1977 | 1827 | ||
| 1978 | static __ptr_t reallochook (__ptr_t, __malloc_size_t); | 1828 | static void * |
| 1979 | static __ptr_t | 1829 | reallochook (void *ptr, size_t size) |
| 1980 | reallochook (ptr, size) | ||
| 1981 | __ptr_t ptr; | ||
| 1982 | __malloc_size_t size; | ||
| 1983 | { | 1830 | { |
| 1984 | struct hdr *hdr = NULL; | 1831 | struct hdr *hdr = NULL; |
| 1985 | __malloc_size_t osize = 0; | 1832 | size_t osize = 0; |
| 1986 | 1833 | ||
| 1987 | if (ptr) | 1834 | if (ptr) |
| 1988 | { | 1835 | { |
| @@ -1997,7 +1844,7 @@ reallochook (ptr, size) | |||
| 1997 | __free_hook = old_free_hook; | 1844 | __free_hook = old_free_hook; |
| 1998 | __malloc_hook = old_malloc_hook; | 1845 | __malloc_hook = old_malloc_hook; |
| 1999 | __realloc_hook = old_realloc_hook; | 1846 | __realloc_hook = old_realloc_hook; |
| 2000 | hdr = (struct hdr *) realloc ((__ptr_t) hdr, sizeof (struct hdr) + size + 1); | 1847 | hdr = realloc (hdr, sizeof (struct hdr) + size + 1); |
| 2001 | __free_hook = freehook; | 1848 | __free_hook = freehook; |
| 2002 | __malloc_hook = mallochook; | 1849 | __malloc_hook = mallochook; |
| 2003 | __realloc_hook = reallochook; | 1850 | __realloc_hook = reallochook; |
| @@ -2009,12 +1856,11 @@ reallochook (ptr, size) | |||
| 2009 | ((char *) &hdr[1])[size] = MAGICBYTE; | 1856 | ((char *) &hdr[1])[size] = MAGICBYTE; |
| 2010 | if (size > osize) | 1857 | if (size > osize) |
| 2011 | memset ((char *) (hdr + 1) + osize, MALLOCFLOOD, size - osize); | 1858 | memset ((char *) (hdr + 1) + osize, MALLOCFLOOD, size - osize); |
| 2012 | return (__ptr_t) (hdr + 1); | 1859 | return hdr + 1; |
| 2013 | } | 1860 | } |
| 2014 | 1861 | ||
| 2015 | static void | 1862 | static void |
| 2016 | mabort (status) | 1863 | mabort (enum mcheck_status status) |
| 2017 | enum mcheck_status status; | ||
| 2018 | { | 1864 | { |
| 2019 | const char *msg; | 1865 | const char *msg; |
| 2020 | switch (status) | 1866 | switch (status) |
| @@ -2047,8 +1893,7 @@ mabort (status) | |||
| 2047 | static int mcheck_used = 0; | 1893 | static int mcheck_used = 0; |
| 2048 | 1894 | ||
| 2049 | int | 1895 | int |
| 2050 | mcheck (func) | 1896 | mcheck (void (*func) (enum mcheck_status)) |
| 2051 | void (*func) (enum mcheck_status); | ||
| 2052 | { | 1897 | { |
| 2053 | abortfunc = (func != NULL) ? func : &mabort; | 1898 | abortfunc = (func != NULL) ? func : &mabort; |
| 2054 | 1899 | ||
| @@ -2068,7 +1913,7 @@ mcheck (func) | |||
| 2068 | } | 1913 | } |
| 2069 | 1914 | ||
| 2070 | enum mcheck_status | 1915 | enum mcheck_status |
| 2071 | mprobe (__ptr_t ptr) | 1916 | mprobe (void *ptr) |
| 2072 | { | 1917 | { |
| 2073 | return mcheck_used ? checkhdr (ptr) : MCHECK_DISABLED; | 1918 | return mcheck_used ? checkhdr (ptr) : MCHECK_DISABLED; |
| 2074 | } | 1919 | } |
diff --git a/src/gnutls.c b/src/gnutls.c index 8dbf01cedc9..c5e21cc8777 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -200,8 +200,12 @@ init_gnutls_functions (Lisp_Object libraries) | |||
| 200 | 200 | ||
| 201 | max_log_level = global_gnutls_log_level; | 201 | max_log_level = global_gnutls_log_level; |
| 202 | 202 | ||
| 203 | GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:", | 203 | { |
| 204 | SDATA (Fget (Qgnutls_dll, QCloaded_from))); | 204 | Lisp_Object name = CAR_SAFE (Fget (Qgnutls_dll, QCloaded_from)); |
| 205 | GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:", | ||
| 206 | STRINGP (name) ? (const char *) SDATA (name) : "unknown"); | ||
| 207 | } | ||
| 208 | |||
| 205 | return 1; | 209 | return 1; |
| 206 | } | 210 | } |
| 207 | 211 | ||
| @@ -419,7 +423,7 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte) | |||
| 419 | { | 423 | { |
| 420 | proc->gnutls_handshakes_tried++; | 424 | proc->gnutls_handshakes_tried++; |
| 421 | emacs_gnutls_handshake (proc); | 425 | emacs_gnutls_handshake (proc); |
| 422 | GNUTLS_LOG2i (5, log_level, "Retried handshake", | 426 | GNUTLS_LOG2i (5, log_level, "Retried handshake", |
| 423 | proc->gnutls_handshakes_tried); | 427 | proc->gnutls_handshakes_tried); |
| 424 | return -1; | 428 | return -1; |
| 425 | } | 429 | } |
diff --git a/src/gtkutil.c b/src/gtkutil.c index d39a0eedf41..4cf421b6616 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1090,7 +1090,9 @@ xg_create_frame_widgets (FRAME_PTR f) | |||
| 1090 | GtkWidget *wtop; | 1090 | GtkWidget *wtop; |
| 1091 | GtkWidget *wvbox, *whbox; | 1091 | GtkWidget *wvbox, *whbox; |
| 1092 | GtkWidget *wfixed; | 1092 | GtkWidget *wfixed; |
| 1093 | #ifndef HAVE_GTK3 | ||
| 1093 | GtkRcStyle *style; | 1094 | GtkRcStyle *style; |
| 1095 | #endif | ||
| 1094 | char *title = 0; | 1096 | char *title = 0; |
| 1095 | 1097 | ||
| 1096 | BLOCK_INPUT; | 1098 | BLOCK_INPUT; |
diff --git a/src/insdel.c b/src/insdel.c index 748e2d54109..148ba221940 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -31,10 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 31 | #include "blockinput.h" | 31 | #include "blockinput.h" |
| 32 | #include "region-cache.h" | 32 | #include "region-cache.h" |
| 33 | 33 | ||
| 34 | #ifndef NULL | ||
| 35 | #define NULL 0 | ||
| 36 | #endif | ||
| 37 | |||
| 38 | static void insert_from_string_1 (Lisp_Object string, | 34 | static void insert_from_string_1 (Lisp_Object string, |
| 39 | ptrdiff_t pos, ptrdiff_t pos_byte, | 35 | ptrdiff_t pos, ptrdiff_t pos_byte, |
| 40 | ptrdiff_t nchars, ptrdiff_t nbytes, | 36 | ptrdiff_t nchars, ptrdiff_t nbytes, |
diff --git a/src/intervals.c b/src/intervals.c index e6c1b4d60d2..0b332caf897 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -1000,6 +1000,7 @@ adjust_intervals_for_insertion (INTERVAL tree, | |||
| 1000 | Lisp_Object pleft, pright; | 1000 | Lisp_Object pleft, pright; |
| 1001 | struct interval newi; | 1001 | struct interval newi; |
| 1002 | 1002 | ||
| 1003 | RESET_INTERVAL (&newi); | ||
| 1003 | pleft = NULL_INTERVAL_P (prev) ? Qnil : prev->plist; | 1004 | pleft = NULL_INTERVAL_P (prev) ? Qnil : prev->plist; |
| 1004 | pright = NULL_INTERVAL_P (i) ? Qnil : i->plist; | 1005 | pright = NULL_INTERVAL_P (i) ? Qnil : i->plist; |
| 1005 | newi.plist = merge_properties_sticky (pleft, pright); | 1006 | newi.plist = merge_properties_sticky (pleft, pright); |
diff --git a/src/keyboard.c b/src/keyboard.c index 79d9e7a18e8..339cf2a7e9e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1198,6 +1198,12 @@ This also exits all active minibuffers. */) | |||
| 1198 | Fthrow (Qtop_level, Qnil); | 1198 | Fthrow (Qtop_level, Qnil); |
| 1199 | } | 1199 | } |
| 1200 | 1200 | ||
| 1201 | static void user_error (const char*) NO_RETURN; | ||
| 1202 | static void user_error (const char *msg) | ||
| 1203 | { | ||
| 1204 | xsignal1 (Quser_error, build_string (msg)); | ||
| 1205 | } | ||
| 1206 | |||
| 1201 | static Lisp_Object Fexit_recursive_edit (void) NO_RETURN; | 1207 | static Lisp_Object Fexit_recursive_edit (void) NO_RETURN; |
| 1202 | DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "", | 1208 | DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "", |
| 1203 | doc: /* Exit from the innermost recursive edit or minibuffer. */) | 1209 | doc: /* Exit from the innermost recursive edit or minibuffer. */) |
| @@ -1206,7 +1212,7 @@ DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, | |||
| 1206 | if (command_loop_level > 0 || minibuf_level > 0) | 1212 | if (command_loop_level > 0 || minibuf_level > 0) |
| 1207 | Fthrow (Qexit, Qnil); | 1213 | Fthrow (Qexit, Qnil); |
| 1208 | 1214 | ||
| 1209 | error ("No recursive edit is in progress"); | 1215 | user_error ("No recursive edit is in progress"); |
| 1210 | } | 1216 | } |
| 1211 | 1217 | ||
| 1212 | static Lisp_Object Fabort_recursive_edit (void) NO_RETURN; | 1218 | static Lisp_Object Fabort_recursive_edit (void) NO_RETURN; |
| @@ -1217,7 +1223,7 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, | |||
| 1217 | if (command_loop_level > 0 || minibuf_level > 0) | 1223 | if (command_loop_level > 0 || minibuf_level > 0) |
| 1218 | Fthrow (Qexit, Qt); | 1224 | Fthrow (Qexit, Qt); |
| 1219 | 1225 | ||
| 1220 | error ("No recursive edit is in progress"); | 1226 | user_error ("No recursive edit is in progress"); |
| 1221 | } | 1227 | } |
| 1222 | 1228 | ||
| 1223 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) | 1229 | #if defined (HAVE_MOUSE) || defined (HAVE_GPM) |
| @@ -2983,11 +2989,16 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2983 | own stuff with the echo area. */ | 2989 | own stuff with the echo area. */ |
| 2984 | if (!CONSP (c) | 2990 | if (!CONSP (c) |
| 2985 | || (!(EQ (Qhelp_echo, XCAR (c))) | 2991 | || (!(EQ (Qhelp_echo, XCAR (c))) |
| 2986 | && !(EQ (Qswitch_frame, XCAR (c))))) | 2992 | && !(EQ (Qswitch_frame, XCAR (c))) |
| 2993 | /* Don't wipe echo area for select window events: These might | ||
| 2994 | get delayed via `mouse-autoselect-window' (Bug#11304). */ | ||
| 2995 | && !(EQ (Qselect_window, XCAR (c))))) | ||
| 2987 | { | 2996 | { |
| 2988 | if (!NILP (echo_area_buffer[0])) | 2997 | if (!NILP (echo_area_buffer[0])) |
| 2989 | safe_run_hooks (Qecho_area_clear_hook); | 2998 | { |
| 2990 | clear_message (1, 0); | 2999 | safe_run_hooks (Qecho_area_clear_hook); |
| 3000 | clear_message (1, 0); | ||
| 3001 | } | ||
| 2991 | } | 3002 | } |
| 2992 | 3003 | ||
| 2993 | reread_for_input_method: | 3004 | reread_for_input_method: |
| @@ -3775,7 +3786,6 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3775 | int *used_mouse_menu, | 3786 | int *used_mouse_menu, |
| 3776 | struct timeval *end_time) | 3787 | struct timeval *end_time) |
| 3777 | { | 3788 | { |
| 3778 | register int c; | ||
| 3779 | Lisp_Object obj; | 3789 | Lisp_Object obj; |
| 3780 | 3790 | ||
| 3781 | #ifdef subprocesses | 3791 | #ifdef subprocesses |
| @@ -3792,16 +3802,18 @@ kbd_buffer_get_event (KBOARD **kbp, | |||
| 3792 | } | 3802 | } |
| 3793 | #endif /* subprocesses */ | 3803 | #endif /* subprocesses */ |
| 3794 | 3804 | ||
| 3805 | #ifndef HAVE_DBUS /* We want to read D-Bus events in batch mode. */ | ||
| 3795 | if (noninteractive | 3806 | if (noninteractive |
| 3796 | /* In case we are running as a daemon, only do this before | 3807 | /* In case we are running as a daemon, only do this before |
| 3797 | detaching from the terminal. */ | 3808 | detaching from the terminal. */ |
| 3798 | || (IS_DAEMON && daemon_pipe[1] >= 0)) | 3809 | || (IS_DAEMON && daemon_pipe[1] >= 0)) |
| 3799 | { | 3810 | { |
| 3800 | c = getchar (); | 3811 | int c = getchar (); |
| 3801 | XSETINT (obj, c); | 3812 | XSETINT (obj, c); |
| 3802 | *kbp = current_kboard; | 3813 | *kbp = current_kboard; |
| 3803 | return obj; | 3814 | return obj; |
| 3804 | } | 3815 | } |
| 3816 | #endif /* ! HAVE_DBUS */ | ||
| 3805 | 3817 | ||
| 3806 | /* Wait until there is input available. */ | 3818 | /* Wait until there is input available. */ |
| 3807 | for (;;) | 3819 | for (;;) |
| @@ -7173,6 +7185,7 @@ tty_read_avail_input (struct terminal *terminal, | |||
| 7173 | return nread; | 7185 | return nread; |
| 7174 | } | 7186 | } |
| 7175 | 7187 | ||
| 7188 | #if defined SYNC_INPUT || defined SIGIO | ||
| 7176 | static void | 7189 | static void |
| 7177 | handle_async_input (void) | 7190 | handle_async_input (void) |
| 7178 | { | 7191 | { |
| @@ -7199,6 +7212,7 @@ handle_async_input (void) | |||
| 7199 | --handling_signal; | 7212 | --handling_signal; |
| 7200 | #endif | 7213 | #endif |
| 7201 | } | 7214 | } |
| 7215 | #endif /* SYNC_INPUT || SIGIO */ | ||
| 7202 | 7216 | ||
| 7203 | #ifdef SYNC_INPUT | 7217 | #ifdef SYNC_INPUT |
| 7204 | void | 7218 | void |
| @@ -10341,146 +10355,6 @@ a special event, so ignore the prefix argument and don't clear it. */) | |||
| 10341 | 10355 | ||
| 10342 | 10356 | ||
| 10343 | 10357 | ||
| 10344 | DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_command, | ||
| 10345 | 1, 1, "P", | ||
| 10346 | doc: /* Read function name, then read its arguments and call it. | ||
| 10347 | |||
| 10348 | To pass a numeric argument to the command you are invoking with, specify | ||
| 10349 | the numeric argument to this command. | ||
| 10350 | |||
| 10351 | Noninteractively, the argument PREFIXARG is the prefix argument to | ||
| 10352 | give to the command you invoke, if it asks for an argument. */) | ||
| 10353 | (Lisp_Object prefixarg) | ||
| 10354 | { | ||
| 10355 | Lisp_Object function; | ||
| 10356 | ptrdiff_t saved_last_point_position; | ||
| 10357 | Lisp_Object saved_keys, saved_last_point_position_buffer; | ||
| 10358 | Lisp_Object bindings, value; | ||
| 10359 | struct gcpro gcpro1, gcpro2, gcpro3; | ||
| 10360 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 10361 | /* The call to Fcompleting_read will start and cancel the hourglass, | ||
| 10362 | but if the hourglass was already scheduled, this means that no | ||
| 10363 | hourglass will be shown for the actual M-x command itself. | ||
| 10364 | So we restart it if it is already scheduled. Note that checking | ||
| 10365 | hourglass_shown_p is not enough, normally the hourglass is not shown, | ||
| 10366 | just scheduled to be shown. */ | ||
| 10367 | int hstarted = hourglass_started (); | ||
| 10368 | #endif | ||
| 10369 | |||
| 10370 | saved_keys = Fvector (this_command_key_count, | ||
| 10371 | XVECTOR (this_command_keys)->contents); | ||
| 10372 | saved_last_point_position_buffer = last_point_position_buffer; | ||
| 10373 | saved_last_point_position = last_point_position; | ||
| 10374 | GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer); | ||
| 10375 | |||
| 10376 | function = call0 (intern ("read-extended-command")); | ||
| 10377 | |||
| 10378 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 10379 | if (hstarted) start_hourglass (); | ||
| 10380 | #endif | ||
| 10381 | |||
| 10382 | if (STRINGP (function) && SCHARS (function) == 0) | ||
| 10383 | error ("No command name given"); | ||
| 10384 | |||
| 10385 | /* Set this_command_keys to the concatenation of saved_keys and | ||
| 10386 | function, followed by a RET. */ | ||
| 10387 | { | ||
| 10388 | Lisp_Object *keys; | ||
| 10389 | int i; | ||
| 10390 | |||
| 10391 | this_command_key_count = 0; | ||
| 10392 | this_command_key_count_reset = 0; | ||
| 10393 | this_single_command_key_start = 0; | ||
| 10394 | |||
| 10395 | keys = XVECTOR (saved_keys)->contents; | ||
| 10396 | for (i = 0; i < ASIZE (saved_keys); i++) | ||
| 10397 | add_command_key (keys[i]); | ||
| 10398 | |||
| 10399 | for (i = 0; i < SCHARS (function); i++) | ||
| 10400 | add_command_key (Faref (function, make_number (i))); | ||
| 10401 | |||
| 10402 | add_command_key (make_number ('\015')); | ||
| 10403 | } | ||
| 10404 | |||
| 10405 | last_point_position = saved_last_point_position; | ||
| 10406 | last_point_position_buffer = saved_last_point_position_buffer; | ||
| 10407 | |||
| 10408 | UNGCPRO; | ||
| 10409 | |||
| 10410 | function = Fintern (function, Qnil); | ||
| 10411 | KVAR (current_kboard, Vprefix_arg) = prefixarg; | ||
| 10412 | Vthis_command = function; | ||
| 10413 | real_this_command = function; | ||
| 10414 | |||
| 10415 | /* If enabled, show which key runs this command. */ | ||
| 10416 | if (!NILP (Vsuggest_key_bindings) | ||
| 10417 | && NILP (Vexecuting_kbd_macro) | ||
| 10418 | && SYMBOLP (function)) | ||
| 10419 | bindings = Fwhere_is_internal (function, Voverriding_local_map, | ||
| 10420 | Qt, Qnil, Qnil); | ||
| 10421 | else | ||
| 10422 | bindings = Qnil; | ||
| 10423 | |||
| 10424 | value = Qnil; | ||
| 10425 | GCPRO3 (bindings, value, function); | ||
| 10426 | value = Fcommand_execute (function, Qt, Qnil, Qnil); | ||
| 10427 | |||
| 10428 | /* If the command has a key binding, print it now. */ | ||
| 10429 | if (!NILP (bindings) | ||
| 10430 | && ! (VECTORP (bindings) && EQ (Faref (bindings, make_number (0)), | ||
| 10431 | Qmouse_movement))) | ||
| 10432 | { | ||
| 10433 | /* But first wait, and skip the message if there is input. */ | ||
| 10434 | Lisp_Object waited; | ||
| 10435 | |||
| 10436 | /* If this command displayed something in the echo area; | ||
| 10437 | wait a few seconds, then display our suggestion message. */ | ||
| 10438 | if (NILP (echo_area_buffer[0])) | ||
| 10439 | waited = sit_for (make_number (0), 0, 2); | ||
| 10440 | else if (NUMBERP (Vsuggest_key_bindings)) | ||
| 10441 | waited = sit_for (Vsuggest_key_bindings, 0, 2); | ||
| 10442 | else | ||
| 10443 | waited = sit_for (make_number (2), 0, 2); | ||
| 10444 | |||
| 10445 | if (!NILP (waited) && ! CONSP (Vunread_command_events)) | ||
| 10446 | { | ||
| 10447 | Lisp_Object binding; | ||
| 10448 | char *newmessage; | ||
| 10449 | int message_p = push_message (); | ||
| 10450 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 10451 | ptrdiff_t newmessage_len, newmessage_alloc; | ||
| 10452 | USE_SAFE_ALLOCA; | ||
| 10453 | |||
| 10454 | record_unwind_protect (pop_message_unwind, Qnil); | ||
| 10455 | binding = Fkey_description (bindings, Qnil); | ||
| 10456 | newmessage_alloc = | ||
| 10457 | (sizeof "You can run the command `' with " | ||
| 10458 | + SBYTES (SYMBOL_NAME (function)) + SBYTES (binding)); | ||
| 10459 | SAFE_ALLOCA (newmessage, char *, newmessage_alloc); | ||
| 10460 | newmessage_len = | ||
| 10461 | esprintf (newmessage, "You can run the command `%s' with %s", | ||
| 10462 | SDATA (SYMBOL_NAME (function)), | ||
| 10463 | SDATA (binding)); | ||
| 10464 | message2 (newmessage, | ||
| 10465 | newmessage_len, | ||
| 10466 | STRING_MULTIBYTE (binding)); | ||
| 10467 | if (NUMBERP (Vsuggest_key_bindings)) | ||
| 10468 | waited = sit_for (Vsuggest_key_bindings, 0, 2); | ||
| 10469 | else | ||
| 10470 | waited = sit_for (make_number (2), 0, 2); | ||
| 10471 | |||
| 10472 | if (!NILP (waited) && message_p) | ||
| 10473 | restore_message (); | ||
| 10474 | |||
| 10475 | SAFE_FREE (); | ||
| 10476 | unbind_to (count, Qnil); | ||
| 10477 | } | ||
| 10478 | } | ||
| 10479 | |||
| 10480 | RETURN_UNGCPRO (value); | ||
| 10481 | } | ||
| 10482 | |||
| 10483 | |||
| 10484 | /* Return nonzero if input events are pending. */ | 10358 | /* Return nonzero if input events are pending. */ |
| 10485 | 10359 | ||
| 10486 | int | 10360 | int |
| @@ -11791,7 +11665,6 @@ syms_of_keyboard (void) | |||
| 11791 | defsubr (&Sset_quit_char); | 11665 | defsubr (&Sset_quit_char); |
| 11792 | defsubr (&Sset_input_mode); | 11666 | defsubr (&Sset_input_mode); |
| 11793 | defsubr (&Scurrent_input_mode); | 11667 | defsubr (&Scurrent_input_mode); |
| 11794 | defsubr (&Sexecute_extended_command); | ||
| 11795 | defsubr (&Sposn_at_point); | 11668 | defsubr (&Sposn_at_point); |
| 11796 | defsubr (&Sposn_at_x_y); | 11669 | defsubr (&Sposn_at_x_y); |
| 11797 | 11670 | ||
| @@ -12195,12 +12068,6 @@ If this variable is non-nil, `delayed-warnings-hook' will be run | |||
| 12195 | immediately after running `post-command-hook'. */); | 12068 | immediately after running `post-command-hook'. */); |
| 12196 | Vdelayed_warnings_list = Qnil; | 12069 | Vdelayed_warnings_list = Qnil; |
| 12197 | 12070 | ||
| 12198 | DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings, | ||
| 12199 | doc: /* Non-nil means show the equivalent key-binding when M-x command has one. | ||
| 12200 | The value can be a length of time to show the message for. | ||
| 12201 | If the value is non-nil and not a number, we wait 2 seconds. */); | ||
| 12202 | Vsuggest_key_bindings = Qt; | ||
| 12203 | |||
| 12204 | DEFVAR_LISP ("timer-list", Vtimer_list, | 12071 | DEFVAR_LISP ("timer-list", Vtimer_list, |
| 12205 | doc: /* List of active absolute time timers in order of increasing time. */); | 12072 | doc: /* List of active absolute time timers in order of increasing time. */); |
| 12206 | Vtimer_list = Qnil; | 12073 | Vtimer_list = Qnil; |
| @@ -12396,7 +12263,7 @@ keys_of_keyboard (void) | |||
| 12396 | } | 12263 | } |
| 12397 | 12264 | ||
| 12398 | /* Mark the pointers in the kboard objects. | 12265 | /* Mark the pointers in the kboard objects. |
| 12399 | Called by the Fgarbage_collector. */ | 12266 | Called by Fgarbage_collect. */ |
| 12400 | void | 12267 | void |
| 12401 | mark_kboards (void) | 12268 | mark_kboards (void) |
| 12402 | { | 12269 | { |
diff --git a/src/keymap.c b/src/keymap.c index e8f2f88bb26..2a03dda5a5e 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2571,7 +2571,8 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps, | |||
| 2571 | DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, | 2571 | DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0, |
| 2572 | doc: /* Return list of keys that invoke DEFINITION. | 2572 | doc: /* Return list of keys that invoke DEFINITION. |
| 2573 | If KEYMAP is a keymap, search only KEYMAP and the global keymap. | 2573 | If KEYMAP is a keymap, search only KEYMAP and the global keymap. |
| 2574 | If KEYMAP is nil, search all the currently active keymaps. | 2574 | If KEYMAP is nil, search all the currently active keymaps, except |
| 2575 | for `overriding-local-map' (which is ignored). | ||
| 2575 | If KEYMAP is a list of keymaps, search only those keymaps. | 2576 | If KEYMAP is a list of keymaps, search only those keymaps. |
| 2576 | 2577 | ||
| 2577 | If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found, | 2578 | If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found, |
| @@ -2586,9 +2587,17 @@ If optional 4th arg NOINDIRECT is non-nil, don't follow indirections | |||
| 2586 | to other keymaps or slots. This makes it possible to search for an | 2587 | to other keymaps or slots. This makes it possible to search for an |
| 2587 | indirect definition itself. | 2588 | indirect definition itself. |
| 2588 | 2589 | ||
| 2589 | If optional 5th arg NO-REMAP is non-nil, don't search for key sequences | 2590 | The optional 5th arg NO-REMAP alters how command remapping is handled: |
| 2590 | that invoke a command which is remapped to DEFINITION, but include the | 2591 | |
| 2591 | remapped command in the returned list. */) | 2592 | - If another command OTHER-COMMAND is remapped to DEFINITION, normally |
| 2593 | search for the bindings of OTHER-COMMAND and include them in the | ||
| 2594 | returned list. But if NO-REMAP is non-nil, include the vector | ||
| 2595 | [remap OTHER-COMMAND] in the returned list instead, without | ||
| 2596 | searching for those other bindings. | ||
| 2597 | |||
| 2598 | - If DEFINITION is remapped to OTHER-COMMAND, normally return the | ||
| 2599 | bindings for OTHER-COMMAND. But if NO-REMAP is non-nil, return the | ||
| 2600 | bindings for DEFINITION instead, ignoring its remapping. */) | ||
| 2592 | (Lisp_Object definition, Lisp_Object keymap, Lisp_Object firstonly, Lisp_Object noindirect, Lisp_Object no_remap) | 2601 | (Lisp_Object definition, Lisp_Object keymap, Lisp_Object firstonly, Lisp_Object noindirect, Lisp_Object no_remap) |
| 2593 | { | 2602 | { |
| 2594 | /* The keymaps in which to search. */ | 2603 | /* The keymaps in which to search. */ |
diff --git a/src/lisp.h b/src/lisp.h index 66e449b0039..551c15473a7 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -41,25 +41,36 @@ extern void check_cons_list (void); | |||
| 41 | Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */ | 41 | Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */ |
| 42 | /* #undef WIDE_EMACS_INT */ | 42 | /* #undef WIDE_EMACS_INT */ |
| 43 | 43 | ||
| 44 | /* These are default choices for the types to use. */ | 44 | /* EMACS_INT - signed integer wide enough to hold an Emacs value |
| 45 | EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if | ||
| 46 | pI - printf length modifier for EMACS_INT | ||
| 47 | EMACS_UINT - unsigned variant of EMACS_INT */ | ||
| 45 | #ifndef EMACS_INT | 48 | #ifndef EMACS_INT |
| 46 | # if BITS_PER_LONG < BITS_PER_LONG_LONG && defined WIDE_EMACS_INT | 49 | # if LONG_MAX < LLONG_MAX && defined WIDE_EMACS_INT |
| 47 | # define EMACS_INT long long | 50 | # define EMACS_INT long long |
| 48 | # define BITS_PER_EMACS_INT BITS_PER_LONG_LONG | 51 | # define EMACS_INT_MAX LLONG_MAX |
| 49 | # define pI "ll" | 52 | # define pI "ll" |
| 50 | # elif BITS_PER_INT < BITS_PER_LONG | 53 | # elif INT_MAX < LONG_MAX |
| 51 | # define EMACS_INT long | 54 | # define EMACS_INT long |
| 52 | # define BITS_PER_EMACS_INT BITS_PER_LONG | 55 | # define EMACS_INT_MAX LONG_MAX |
| 53 | # define pI "l" | 56 | # define pI "l" |
| 54 | # else | 57 | # else |
| 55 | # define EMACS_INT int | 58 | # define EMACS_INT int |
| 56 | # define BITS_PER_EMACS_INT BITS_PER_INT | 59 | # define EMACS_INT_MAX INT_MAX |
| 57 | # define pI "" | 60 | # define pI "" |
| 58 | # endif | 61 | # endif |
| 59 | #endif | 62 | #endif |
| 60 | #ifndef EMACS_UINT | 63 | #define EMACS_UINT unsigned EMACS_INT |
| 61 | # define EMACS_UINT unsigned EMACS_INT | 64 | |
| 62 | #endif | 65 | /* Number of bits in some machine integer types. */ |
| 66 | enum | ||
| 67 | { | ||
| 68 | BITS_PER_CHAR = CHAR_BIT, | ||
| 69 | BITS_PER_SHORT = CHAR_BIT * sizeof (short), | ||
| 70 | BITS_PER_INT = CHAR_BIT * sizeof (int), | ||
| 71 | BITS_PER_LONG = CHAR_BIT * sizeof (long int), | ||
| 72 | BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT) | ||
| 73 | }; | ||
| 63 | 74 | ||
| 64 | /* printmax_t and uprintmax_t are types for printing large integers. | 75 | /* printmax_t and uprintmax_t are types for printing large integers. |
| 65 | These are the widest integers that are supported for printing. | 76 | These are the widest integers that are supported for printing. |
| @@ -164,13 +175,13 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 164 | variable VAR of type TYPE with the added requirement that it be | 175 | variable VAR of type TYPE with the added requirement that it be |
| 165 | TYPEBITS-aligned. */ | 176 | TYPEBITS-aligned. */ |
| 166 | 177 | ||
| 167 | #ifndef GCTYPEBITS | ||
| 168 | #define GCTYPEBITS 3 | 178 | #define GCTYPEBITS 3 |
| 169 | #endif | ||
| 170 | |||
| 171 | #ifndef VALBITS | ||
| 172 | #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS) | 179 | #define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS) |
| 173 | #endif | 180 | |
| 181 | /* The maximum value that can be stored in a EMACS_INT, assuming all | ||
| 182 | bits other than the type bits contribute to a nonnegative signed value. | ||
| 183 | This can be used in #if, e.g., '#if VAL_MAX < UINTPTR_MAX' below. */ | ||
| 184 | #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1)) | ||
| 174 | 185 | ||
| 175 | #ifndef NO_DECL_ALIGN | 186 | #ifndef NO_DECL_ALIGN |
| 176 | # ifndef DECL_ALIGN | 187 | # ifndef DECL_ALIGN |
| @@ -195,12 +206,12 @@ extern int suppress_checking EXTERNALLY_VISIBLE; | |||
| 195 | || defined DARWIN_OS || defined __sun) | 206 | || defined DARWIN_OS || defined __sun) |
| 196 | /* We also need to be able to specify mult-of-8 alignment on static vars. */ | 207 | /* We also need to be able to specify mult-of-8 alignment on static vars. */ |
| 197 | # if defined DECL_ALIGN | 208 | # if defined DECL_ALIGN |
| 198 | /* On hosts where VALBITS is greater than the pointer width in bits, | 209 | /* On hosts where pointers-as-ints do not exceed VAL_MAX, |
| 199 | USE_LSB_TAG is: | 210 | USE_LSB_TAG is: |
| 200 | a. unnecessary, because the top bits of an EMACS_INT are unused, and | 211 | a. unnecessary, because the top bits of an EMACS_INT are unused, and |
| 201 | b. slower, because it typically requires extra masking. | 212 | b. slower, because it typically requires extra masking. |
| 202 | So, define USE_LSB_TAG only on hosts where it might be useful. */ | 213 | So, define USE_LSB_TAG only on hosts where it might be useful. */ |
| 203 | # if UINTPTR_MAX >> VALBITS != 0 | 214 | # if VAL_MAX < UINTPTR_MAX |
| 204 | # define USE_LSB_TAG | 215 | # define USE_LSB_TAG |
| 205 | # endif | 216 | # endif |
| 206 | # endif | 217 | # endif |
| @@ -474,10 +485,11 @@ enum pvec_type | |||
| 474 | (var) = (type) | (intptr_t) (ptr)) | 485 | (var) = (type) | (intptr_t) (ptr)) |
| 475 | 486 | ||
| 476 | #define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK)) | 487 | #define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK)) |
| 488 | #define XUNTAG(a, type) ((intptr_t) ((a) - (type))) | ||
| 477 | 489 | ||
| 478 | #else /* not USE_LSB_TAG */ | 490 | #else /* not USE_LSB_TAG */ |
| 479 | 491 | ||
| 480 | #define VALMASK ((((EMACS_INT) 1) << VALBITS) - 1) | 492 | #define VALMASK VAL_MAX |
| 481 | 493 | ||
| 482 | /* One need to override this if there must be high bits set in data space | 494 | /* One need to override this if there must be high bits set in data space |
| 483 | (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work | 495 | (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work |
| @@ -580,6 +592,13 @@ extern Lisp_Object make_number (EMACS_INT); | |||
| 580 | # define XSETFASTINT(a, b) (XSETINT (a, b)) | 592 | # define XSETFASTINT(a, b) (XSETINT (a, b)) |
| 581 | #endif | 593 | #endif |
| 582 | 594 | ||
| 595 | /* Extract the pointer value of the Lisp object A, under the | ||
| 596 | assumption that A's type is TYPE. This is a fallback | ||
| 597 | implementation if nothing faster is available. */ | ||
| 598 | #ifndef XUNTAG | ||
| 599 | # define XUNTAG(a, type) XPNTR (a) | ||
| 600 | #endif | ||
| 601 | |||
| 583 | #define EQ(x, y) (XHASH (x) == XHASH (y)) | 602 | #define EQ(x, y) (XHASH (x) == XHASH (y)) |
| 584 | 603 | ||
| 585 | /* Number of bits in a fixnum, including the sign bit. */ | 604 | /* Number of bits in a fixnum, including the sign bit. */ |
| @@ -612,15 +631,20 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 612 | 631 | ||
| 613 | /* Extract a value or address from a Lisp_Object. */ | 632 | /* Extract a value or address from a Lisp_Object. */ |
| 614 | 633 | ||
| 615 | #define XCONS(a) (eassert (CONSP (a)), (struct Lisp_Cons *) XPNTR (a)) | 634 | #define XCONS(a) (eassert (CONSP (a)), \ |
| 616 | #define XVECTOR(a) (eassert (VECTORLIKEP (a)), (struct Lisp_Vector *) XPNTR (a)) | 635 | (struct Lisp_Cons *) XUNTAG (a, Lisp_Cons)) |
| 617 | #define XSTRING(a) (eassert (STRINGP (a)), (struct Lisp_String *) XPNTR (a)) | 636 | #define XVECTOR(a) (eassert (VECTORLIKEP (a)), \ |
| 618 | #define XSYMBOL(a) (eassert (SYMBOLP (a)), (struct Lisp_Symbol *) XPNTR (a)) | 637 | (struct Lisp_Vector *) XUNTAG (a, Lisp_Vectorlike)) |
| 619 | #define XFLOAT(a) (eassert (FLOATP (a)), (struct Lisp_Float *) XPNTR (a)) | 638 | #define XSTRING(a) (eassert (STRINGP (a)), \ |
| 639 | (struct Lisp_String *) XUNTAG (a, Lisp_String)) | ||
| 640 | #define XSYMBOL(a) (eassert (SYMBOLP (a)), \ | ||
| 641 | (struct Lisp_Symbol *) XUNTAG (a, Lisp_Symbol)) | ||
| 642 | #define XFLOAT(a) (eassert (FLOATP (a)), \ | ||
| 643 | (struct Lisp_Float *) XUNTAG (a, Lisp_Float)) | ||
| 620 | 644 | ||
| 621 | /* Misc types. */ | 645 | /* Misc types. */ |
| 622 | 646 | ||
| 623 | #define XMISC(a) ((union Lisp_Misc *) XPNTR (a)) | 647 | #define XMISC(a) ((union Lisp_Misc *) XUNTAG (a, Lisp_Misc)) |
| 624 | #define XMISCANY(a) (eassert (MISCP (a)), &(XMISC (a)->u_any)) | 648 | #define XMISCANY(a) (eassert (MISCP (a)), &(XMISC (a)->u_any)) |
| 625 | #define XMISCTYPE(a) (XMISCANY (a)->type) | 649 | #define XMISCTYPE(a) (XMISCANY (a)->type) |
| 626 | #define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker)) | 650 | #define XMARKER(a) (eassert (MARKERP (a)), &(XMISC (a)->u_marker)) |
| @@ -640,14 +664,24 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 640 | 664 | ||
| 641 | /* Pseudovector types. */ | 665 | /* Pseudovector types. */ |
| 642 | 666 | ||
| 643 | #define XPROCESS(a) (eassert (PROCESSP (a)), (struct Lisp_Process *) XPNTR (a)) | 667 | #define XPROCESS(a) (eassert (PROCESSP (a)), \ |
| 644 | #define XWINDOW(a) (eassert (WINDOWP (a)), (struct window *) XPNTR (a)) | 668 | (struct Lisp_Process *) XUNTAG (a, Lisp_Vectorlike)) |
| 645 | #define XTERMINAL(a) (eassert (TERMINALP (a)), (struct terminal *) XPNTR (a)) | 669 | #define XWINDOW(a) (eassert (WINDOWP (a)), \ |
| 646 | #define XSUBR(a) (eassert (SUBRP (a)), (struct Lisp_Subr *) XPNTR (a)) | 670 | (struct window *) XUNTAG (a, Lisp_Vectorlike)) |
| 647 | #define XBUFFER(a) (eassert (BUFFERP (a)), (struct buffer *) XPNTR (a)) | 671 | #define XTERMINAL(a) (eassert (TERMINALP (a)), \ |
| 648 | #define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), (struct Lisp_Char_Table *) XPNTR (a)) | 672 | (struct terminal *) XUNTAG (a, Lisp_Vectorlike)) |
| 649 | #define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), (struct Lisp_Sub_Char_Table *) XPNTR (a)) | 673 | #define XSUBR(a) (eassert (SUBRP (a)), \ |
| 650 | #define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), (struct Lisp_Bool_Vector *) XPNTR (a)) | 674 | (struct Lisp_Subr *) XUNTAG (a, Lisp_Vectorlike)) |
| 675 | #define XBUFFER(a) (eassert (BUFFERP (a)), \ | ||
| 676 | (struct buffer *) XUNTAG (a, Lisp_Vectorlike)) | ||
| 677 | #define XCHAR_TABLE(a) (eassert (CHAR_TABLE_P (a)), \ | ||
| 678 | (struct Lisp_Char_Table *) XUNTAG (a, Lisp_Vectorlike)) | ||
| 679 | #define XSUB_CHAR_TABLE(a) (eassert (SUB_CHAR_TABLE_P (a)), \ | ||
| 680 | ((struct Lisp_Sub_Char_Table *) \ | ||
| 681 | XUNTAG (a, Lisp_Vectorlike))) | ||
| 682 | #define XBOOL_VECTOR(a) (eassert (BOOL_VECTOR_P (a)), \ | ||
| 683 | ((struct Lisp_Bool_Vector *) \ | ||
| 684 | XUNTAG (a, Lisp_Vectorlike))) | ||
| 651 | 685 | ||
| 652 | /* Construct a Lisp_Object from a value or address. */ | 686 | /* Construct a Lisp_Object from a value or address. */ |
| 653 | 687 | ||
| @@ -674,7 +708,9 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | |||
| 674 | /* The cast to struct vectorlike_header * avoids aliasing issues. */ | 708 | /* The cast to struct vectorlike_header * avoids aliasing issues. */ |
| 675 | #define XSETPSEUDOVECTOR(a, b, code) \ | 709 | #define XSETPSEUDOVECTOR(a, b, code) \ |
| 676 | XSETTYPED_PSEUDOVECTOR(a, b, \ | 710 | XSETTYPED_PSEUDOVECTOR(a, b, \ |
| 677 | ((struct vectorlike_header *) XPNTR (a))->size, \ | 711 | (((struct vectorlike_header *) \ |
| 712 | XUNTAG (a, Lisp_Vectorlike)) \ | ||
| 713 | ->size), \ | ||
| 678 | code) | 714 | code) |
| 679 | #define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \ | 715 | #define XSETTYPED_PSEUDOVECTOR(a, b, size, code) \ |
| 680 | (XSETVECTOR (a, b), \ | 716 | (XSETVECTOR (a, b), \ |
| @@ -1282,7 +1318,7 @@ struct Lisp_Hash_Table | |||
| 1282 | 1318 | ||
| 1283 | 1319 | ||
| 1284 | #define XHASH_TABLE(OBJ) \ | 1320 | #define XHASH_TABLE(OBJ) \ |
| 1285 | ((struct Lisp_Hash_Table *) XPNTR (OBJ)) | 1321 | ((struct Lisp_Hash_Table *) XUNTAG (OBJ, Lisp_Vectorlike)) |
| 1286 | 1322 | ||
| 1287 | #define XSET_HASH_TABLE(VAR, PTR) \ | 1323 | #define XSET_HASH_TABLE(VAR, PTR) \ |
| 1288 | (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE)) | 1324 | (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE)) |
| @@ -1748,7 +1784,7 @@ typedef struct { | |||
| 1748 | code is CODE. */ | 1784 | code is CODE. */ |
| 1749 | #define TYPED_PSEUDOVECTORP(x, t, code) \ | 1785 | #define TYPED_PSEUDOVECTORP(x, t, code) \ |
| 1750 | (VECTORLIKEP (x) \ | 1786 | (VECTORLIKEP (x) \ |
| 1751 | && (((((struct t *) XPNTR (x))->size \ | 1787 | && (((((struct t *) XUNTAG (x, Lisp_Vectorlike))->size \ |
| 1752 | & (PSEUDOVECTOR_FLAG | (code)))) \ | 1788 | & (PSEUDOVECTOR_FLAG | (code)))) \ |
| 1753 | == (PSEUDOVECTOR_FLAG | (code)))) | 1789 | == (PSEUDOVECTOR_FLAG | (code)))) |
| 1754 | 1790 | ||
| @@ -2409,7 +2445,7 @@ extern Lisp_Object Qerror, Qquit, Qargs_out_of_range; | |||
| 2409 | extern Lisp_Object Qvoid_variable, Qvoid_function; | 2445 | extern Lisp_Object Qvoid_variable, Qvoid_function; |
| 2410 | extern Lisp_Object Qinvalid_read_syntax; | 2446 | extern Lisp_Object Qinvalid_read_syntax; |
| 2411 | extern Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; | 2447 | extern Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; |
| 2412 | extern Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive; | 2448 | extern Lisp_Object Quser_error, Qend_of_file, Qarith_error, Qmark_inactive; |
| 2413 | extern Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; | 2449 | extern Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; |
| 2414 | extern Lisp_Object Qtext_read_only; | 2450 | extern Lisp_Object Qtext_read_only; |
| 2415 | extern Lisp_Object Qinteractive_form; | 2451 | extern Lisp_Object Qinteractive_form; |
| @@ -2788,7 +2824,7 @@ extern int pos_visible_p (struct window *, ptrdiff_t, int *, | |||
| 2788 | extern void syms_of_xsettings (void); | 2824 | extern void syms_of_xsettings (void); |
| 2789 | 2825 | ||
| 2790 | /* Defined in vm-limit.c. */ | 2826 | /* Defined in vm-limit.c. */ |
| 2791 | extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (const char *)); | 2827 | extern void memory_warnings (void *, void (*warnfun) (const char *)); |
| 2792 | 2828 | ||
| 2793 | /* Defined in alloc.c */ | 2829 | /* Defined in alloc.c */ |
| 2794 | extern void check_pure_size (void); | 2830 | extern void check_pure_size (void); |
| @@ -3604,9 +3640,9 @@ extern int initialized; | |||
| 3604 | 3640 | ||
| 3605 | extern int immediate_quit; /* Nonzero means ^G can quit instantly */ | 3641 | extern int immediate_quit; /* Nonzero means ^G can quit instantly */ |
| 3606 | 3642 | ||
| 3607 | extern POINTER_TYPE *xmalloc (size_t); | 3643 | extern void *xmalloc (size_t); |
| 3608 | extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); | 3644 | extern void *xrealloc (void *, size_t); |
| 3609 | extern void xfree (POINTER_TYPE *); | 3645 | extern void xfree (void *); |
| 3610 | extern void *xnmalloc (ptrdiff_t, ptrdiff_t); | 3646 | extern void *xnmalloc (ptrdiff_t, ptrdiff_t); |
| 3611 | extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t); | 3647 | extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t); |
| 3612 | extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); | 3648 | extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); |
diff --git a/src/lisp.mk b/src/lisp.mk index 4895ca40959..4608cc3f687 100644 --- a/src/lisp.mk +++ b/src/lisp.mk | |||
| @@ -128,7 +128,9 @@ lisp = \ | |||
| 128 | $(lispsource)/emacs-lisp/lisp-mode.elc \ | 128 | $(lispsource)/emacs-lisp/lisp-mode.elc \ |
| 129 | $(lispsource)/textmodes/text-mode.elc \ | 129 | $(lispsource)/textmodes/text-mode.elc \ |
| 130 | $(lispsource)/textmodes/fill.elc \ | 130 | $(lispsource)/textmodes/fill.elc \ |
| 131 | $(lispsource)/newcomment.elc \ | ||
| 131 | $(lispsource)/replace.elc \ | 132 | $(lispsource)/replace.elc \ |
| 133 | $(lispsource)/emacs-lisp/tabulated-list.elc \ | ||
| 132 | $(lispsource)/buff-menu.elc \ | 134 | $(lispsource)/buff-menu.elc \ |
| 133 | $(lispsource)/fringe.elc \ | 135 | $(lispsource)/fringe.elc \ |
| 134 | $(lispsource)/emacs-lisp/regexp-opt.elc \ | 136 | $(lispsource)/emacs-lisp/regexp-opt.elc \ |
diff --git a/src/lread.c b/src/lread.c index a2a18921bdc..a7ceec3bb4a 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -24,7 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
| 25 | #include <sys/file.h> | 25 | #include <sys/file.h> |
| 26 | #include <errno.h> | 26 | #include <errno.h> |
| 27 | #include <limits.h> /* for CHAR_BIT */ | 27 | #include <limits.h> /* For CHAR_BIT. */ |
| 28 | #include <setjmp.h> | 28 | #include <setjmp.h> |
| 29 | #include "lisp.h" | 29 | #include "lisp.h" |
| 30 | #include "intervals.h" | 30 | #include "intervals.h" |
| @@ -3996,10 +3996,12 @@ init_obarray (void) | |||
| 3996 | /* XSYMBOL (Qnil)->function = Qunbound; */ | 3996 | /* XSYMBOL (Qnil)->function = Qunbound; */ |
| 3997 | SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil); | 3997 | SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil); |
| 3998 | XSYMBOL (Qnil)->constant = 1; | 3998 | XSYMBOL (Qnil)->constant = 1; |
| 3999 | XSYMBOL (Qnil)->declared_special = 1; | ||
| 3999 | XSYMBOL (Qnil)->plist = Qnil; | 4000 | XSYMBOL (Qnil)->plist = Qnil; |
| 4000 | 4001 | ||
| 4001 | Qt = intern_c_string ("t"); | 4002 | Qt = intern_c_string ("t"); |
| 4002 | SET_SYMBOL_VAL (XSYMBOL (Qt), Qt); | 4003 | SET_SYMBOL_VAL (XSYMBOL (Qt), Qt); |
| 4004 | XSYMBOL (Qnil)->declared_special = 1; | ||
| 4003 | XSYMBOL (Qt)->constant = 1; | 4005 | XSYMBOL (Qt)->constant = 1; |
| 4004 | 4006 | ||
| 4005 | /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */ | 4007 | /* Qt is correct even if CANNOT_DUMP. loadup.el will set to nil at end. */ |
diff --git a/src/m/README b/src/m/README deleted file mode 100644 index ad91167648e..00000000000 --- a/src/m/README +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | This directory contains C header files containing machine-specific | ||
| 2 | definitions. Each file describes a particular machine. The emacs | ||
| 3 | configuration script edits ../config.h to include the appropriate one of | ||
| 4 | these files, and then each emacs source file includes config.h. | ||
| 5 | |||
| 6 | template.h is a generic template for machine descriptions; it | ||
| 7 | describes the parameters a machine file can specify. | ||
diff --git a/src/m/alpha.h b/src/m/alpha.h deleted file mode 100644 index 2a97a3d5b0c..00000000000 --- a/src/m/alpha.h +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 1 | /* Machine description file for the alpha chip. | ||
| 2 | |||
| 3 | Copyright (C) 1994, 1997, 1999, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | Author: Rainer Schoepf | ||
| 6 | (according to authors.el) | ||
| 7 | |||
| 8 | This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | it under the terms of the GNU General Public License as published by | ||
| 12 | the Free Software Foundation, either version 3 of the License, or | ||
| 13 | (at your option) any later version. | ||
| 14 | |||
| 15 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | GNU General Public License for more details. | ||
| 19 | |||
| 20 | You should have received a copy of the GNU General Public License | ||
| 21 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 22 | |||
| 23 | #ifndef _LP64 | ||
| 24 | #define _LP64 /* This doesn't appear to be necessary on OSF 4/5 -- fx. */ | ||
| 25 | #endif | ||
| 26 | |||
| 27 | /* Now define a symbol for the cpu type, if your compiler | ||
| 28 | does not define it automatically. */ | ||
| 29 | /* __alpha defined automatically */ | ||
| 30 | |||
| 31 | |||
| 32 | #ifdef __ELF__ | ||
| 33 | |||
| 34 | #if !defined (GNU_LINUX) && !defined (__NetBSD__) | ||
| 35 | #define DATA_START 0x140000000 | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #else /* not __ELF__ */ | ||
| 39 | |||
| 40 | /* Describe layout of the address space in an executing process. */ | ||
| 41 | #define DATA_START 0x140000000 | ||
| 42 | |||
| 43 | #endif /* __ELF__ */ | ||
| 44 | |||
| 45 | /* On the Alpha it's best to avoid including TERMIO since struct | ||
| 46 | termio and struct termios are mutually incompatible. */ | ||
| 47 | #define NO_TERMIO | ||
| 48 | |||
| 49 | /* Many Alpha implementations (e.g. gas 2.8) can't handle DBL_MIN: | ||
| 50 | they generate code that uses a signaling NaN instead of DBL_MIN. | ||
| 51 | Define DBL_MIN_REPLACEMENT to be the next value larger than DBL_MIN: | ||
| 52 | this avoids the assembler bug. */ | ||
| 53 | #define DBL_MIN_REPLACEMENT 2.2250738585072019e-308 | ||
diff --git a/src/m/amdx86-64.h b/src/m/amdx86-64.h deleted file mode 100644 index f0482c733f9..00000000000 --- a/src/m/amdx86-64.h +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | /* machine description file for AMD x86-64. | ||
| 2 | |||
| 3 | Copyright (C) 2002-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #define BITS_PER_LONG 64 | ||
| 21 | #define BITS_PER_EMACS_INT 64 | ||
| 22 | |||
| 23 | /* Now define a symbol for the cpu type, if your compiler | ||
| 24 | does not define it automatically: | ||
| 25 | Ones defined so far include vax, m68000, ns16000, pyramid, | ||
| 26 | orion, tahoe, APOLLO and many others */ | ||
| 27 | /* __x86_64 defined automatically. */ | ||
| 28 | |||
| 29 | /* Define the type to use. */ | ||
| 30 | #define EMACS_INT long | ||
| 31 | #define pI "l" | ||
| 32 | #define EMACS_UINT unsigned long | ||
| 33 | |||
| 34 | /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ | ||
| 35 | #undef DATA_SEG_BITS | ||
diff --git a/src/m/ia64.h b/src/m/ia64.h deleted file mode 100644 index 47df94cedd0..00000000000 --- a/src/m/ia64.h +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | /* machine description file for the IA-64 architecture. | ||
| 2 | |||
| 3 | Copyright (C) 2000-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | Contributed by David Mosberger <davidm@hpl.hp.com> | ||
| 6 | |||
| 7 | This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | it under the terms of the GNU General Public License as published by | ||
| 11 | the Free Software Foundation, either version 3 of the License, or | ||
| 12 | (at your option) any later version. | ||
| 13 | |||
| 14 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | GNU General Public License for more details. | ||
| 18 | |||
| 19 | You should have received a copy of the GNU General Public License | ||
| 20 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 21 | |||
| 22 | #define BITS_PER_LONG 64 | ||
| 23 | #define BITS_PER_EMACS_INT 64 | ||
| 24 | |||
| 25 | /* Now define a symbol for the cpu type, if your compiler | ||
| 26 | does not define it automatically. */ | ||
| 27 | /* __ia64__ defined automatically */ | ||
| 28 | |||
| 29 | /* Define the type to use. */ | ||
| 30 | #define EMACS_INT long | ||
| 31 | #define pI "l" | ||
| 32 | #define EMACS_UINT unsigned long | ||
diff --git a/src/m/ibmrs6000.h b/src/m/ibmrs6000.h deleted file mode 100644 index 9798ad2d3d7..00000000000 --- a/src/m/ibmrs6000.h +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | /* R2 AIX machine/system dependent defines | ||
| 2 | |||
| 3 | Copyright (C) 1988, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | |||
| 21 | /* The data segment in this machine always starts at address 0x20000000. | ||
| 22 | An address of data cannot be stored correctly in a Lisp object; | ||
| 23 | we always lose the high bits. We must tell XPNTR to add them back. */ | ||
| 24 | #define DATA_START 0x20000000 | ||
| 25 | #define DATA_SEG_BITS 0x20000000 | ||
| 26 | |||
| 27 | #ifndef NLIST_STRUCT | ||
| 28 | /* AIX supposedly doesn't use this interface, but on the RS/6000 | ||
| 29 | it apparently does. */ | ||
| 30 | #define NLIST_STRUCT | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #undef ADDR_CORRECT | ||
| 34 | #define ADDR_CORRECT(x) ((int)(x)) | ||
| 35 | |||
| 36 | /*** BUILD 9008 - FIONREAD problem still exists in X-Windows. ***/ | ||
| 37 | #define BROKEN_FIONREAD | ||
| 38 | /* As we define BROKEN_FIONREAD, SIGIO will be undefined in systty.h. | ||
| 39 | But, on AIX, SIGAIO, SIGPTY, and SIGPOLL are defined as SIGIO, | ||
| 40 | which causes compilation error at init_signals in sysdep.c. So, we | ||
| 41 | define these macros so that syssignal.h detects them and undefine | ||
| 42 | SIGAIO, SIGPTY and SIGPOLL. */ | ||
| 43 | #define BROKEN_SIGAIO | ||
| 44 | #define BROKEN_SIGPTY | ||
| 45 | #define BROKEN_SIGPOLL | ||
| 46 | |||
diff --git a/src/m/ibms390x.h b/src/m/ibms390x.h deleted file mode 100644 index aa652a8206a..00000000000 --- a/src/m/ibms390x.h +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | /* Machine description file for IBM S390 in 64-bit mode | ||
| 2 | |||
| 3 | Copyright (C) 2002-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #define BITS_PER_LONG 64 | ||
| 21 | #define BITS_PER_EMACS_INT 64 | ||
| 22 | |||
| 23 | /* Define the type to use. */ | ||
| 24 | #define EMACS_INT long | ||
| 25 | #define pI "l" | ||
| 26 | #define EMACS_UINT unsigned long | ||
| 27 | |||
| 28 | /* On the 64 bit architecture, we can use 60 bits for addresses */ | ||
| 29 | #define VALBITS 60 | ||
| 30 | |||
| 31 | /* Define XPNTR to avoid or'ing with DATA_SEG_BITS */ | ||
| 32 | #define XPNTR(a) XUINT (a) | ||
diff --git a/src/m/intel386.h b/src/m/intel386.h deleted file mode 100644 index 78a43e92c21..00000000000 --- a/src/m/intel386.h +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | /* Machine description file for intel 386. | ||
| 2 | |||
| 3 | Copyright (C) 1987, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | |||
| 21 | #ifdef WINDOWSNT | ||
| 22 | #define DATA_START get_data_start () | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #ifdef GNU_LINUX | ||
| 26 | /* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */ | ||
| 27 | /* we cannot get the maximum address for brk */ | ||
| 28 | #define ULIMIT_BREAK_VALUE (32*1024*1024) | ||
| 29 | #endif | ||
diff --git a/src/m/m68k.h b/src/m/m68k.h deleted file mode 100644 index 120a2bad293..00000000000 --- a/src/m/m68k.h +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | /* Machine description file for generic Motorola 68k. | ||
| 2 | |||
| 3 | Copyright (C) 1985, 1995, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* Now define a symbol for the cpu type, if your compiler | ||
| 21 | does not define it automatically. */ | ||
| 22 | #ifndef m68k | ||
| 23 | #define m68k | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #ifdef GNU_LINUX | ||
| 27 | #ifdef __ELF__ | ||
| 28 | #define DATA_SEG_BITS 0x80000000 | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #endif | ||
| 32 | |||
diff --git a/src/m/macppc.h b/src/m/macppc.h deleted file mode 100644 index 0303ead25d6..00000000000 --- a/src/m/macppc.h +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | /* machine description file For the powerpc Macintosh. | ||
| 2 | |||
| 3 | Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #ifdef _ARCH_PPC64 | ||
| 21 | #ifndef _LP64 | ||
| 22 | #define _LP64 | ||
| 23 | #endif | ||
| 24 | #endif | ||
diff --git a/src/m/sparc.h b/src/m/sparc.h deleted file mode 100644 index 27b6070ba87..00000000000 --- a/src/m/sparc.h +++ /dev/null | |||
| @@ -1,30 +0,0 @@ | |||
| 1 | /* machine description file for Sun 4 SPARC. | ||
| 2 | |||
| 3 | Copyright (C) 1987, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* __sparc__ is defined by the compiler by default. */ | ||
| 21 | |||
| 22 | #ifdef __arch64__ /* GCC, 64-bit ABI. */ | ||
| 23 | |||
| 24 | #define BITS_PER_LONG 64 | ||
| 25 | |||
| 26 | #ifndef _LP64 | ||
| 27 | #define _LP64 /* Done on Alpha -- not sure if it should be here. -- fx */ | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #endif /* __arch64__ */ | ||
diff --git a/src/m/template.h b/src/m/template.h deleted file mode 100644 index 5f1a46c86e1..00000000000 --- a/src/m/template.h +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | /* machine description file template. | ||
| 2 | |||
| 3 | Copyright (C) 1985-1986, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | /* Now define a symbol for the cpu type, if your compiler | ||
| 21 | does not define it automatically. | ||
| 22 | Ones defined so far include m68k and many others */ | ||
| 23 | |||
| 24 | /* After adding support for a new machine, modify the large case | ||
| 25 | statement in configure.in to recognize reasonable | ||
| 26 | configuration names, and add a description of the system to | ||
| 27 | `etc/MACHINES'. | ||
| 28 | |||
| 29 | Check for any tests of $machine in configure.in, and add an entry | ||
| 30 | for the new machine if needed. | ||
| 31 | |||
| 32 | If you've just fixed a problem in an existing configuration file, | ||
| 33 | you should also check `etc/MACHINES' to make sure its descriptions | ||
| 34 | of known problems in that configuration should be updated. */ | ||
diff --git a/src/m/vax.h b/src/m/vax.h deleted file mode 100644 index e4bed4090b9..00000000000 --- a/src/m/vax.h +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | /* machine description file for vax. | ||
| 2 | |||
| 3 | Copyright (C) 1985-1986, 2001-2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs 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 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs 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 Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | |||
| 21 | /* #define vax -- appears to be done automatically */ | ||
| 22 | |||
| 23 | #define HAVE_FTIME | ||
diff --git a/src/makefile.w32-in b/src/makefile.w32-in index 303445bc2d6..99b1241eab0 100644 --- a/src/makefile.w32-in +++ b/src/makefile.w32-in | |||
| @@ -343,7 +343,7 @@ cleanall: clean | |||
| 343 | ## | 343 | ## |
| 344 | ## This works only with GNU Make. | 344 | ## This works only with GNU Make. |
| 345 | 345 | ||
| 346 | TAGS: $(OBJ0) $(OBJ1) $(OBJ2) $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h | 346 | TAGS: $(OBJ0) $(OBJ1) $(OBJ2) $(CURDIR)/s/ms-w32.h |
| 347 | $(MAKE) $(MFLAGS) TAGS-$(MAKETYPE) | 347 | $(MAKE) $(MFLAGS) TAGS-$(MAKETYPE) |
| 348 | 348 | ||
| 349 | TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2) | 349 | TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2) |
| @@ -357,7 +357,7 @@ TAGS-gmake: | |||
| 357 | $(OBJ1_c) | 357 | $(OBJ1_c) |
| 358 | ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ | 358 | ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ |
| 359 | $(OBJ2_c) \ | 359 | $(OBJ2_c) \ |
| 360 | $(CURDIR)/*.h $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h | 360 | $(CURDIR)/*.h $(CURDIR)/s/ms-w32.h |
| 361 | 361 | ||
| 362 | TAGS-nmake: | 362 | TAGS-nmake: |
| 363 | echo This target is not supported with NMake | 363 | echo This target is not supported with NMake |
| @@ -407,7 +407,6 @@ CODING_H = $(SRC)/coding.h \ | |||
| 407 | MS_W32_H = $(SRC)/s/ms-w32.h \ | 407 | MS_W32_H = $(SRC)/s/ms-w32.h \ |
| 408 | $(NT_INC)/sys/stat.h | 408 | $(NT_INC)/sys/stat.h |
| 409 | CONFIG_H = $(SRC)/config.h \ | 409 | CONFIG_H = $(SRC)/config.h \ |
| 410 | $(SRC)/m/intel386.h \ | ||
| 411 | $(MS_W32_H) | 410 | $(MS_W32_H) |
| 412 | DIR_H = $(NT_INC)/sys/dir.h \ | 411 | DIR_H = $(NT_INC)/sys/dir.h \ |
| 413 | $(SRC)/ndir.h | 412 | $(SRC)/ndir.h |
| @@ -930,7 +929,7 @@ $(BLD)/fringe.$(O) : \ | |||
| 930 | 929 | ||
| 931 | $(BLD)/gmalloc.$(O) : \ | 930 | $(BLD)/gmalloc.$(O) : \ |
| 932 | $(SRC)/gmalloc.c \ | 931 | $(SRC)/gmalloc.c \ |
| 933 | $(SRC)/getpagesize.h \ | 932 | $(NT_INC)/stdint.h \ |
| 934 | $(NT_INC)/unistd.h \ | 933 | $(NT_INC)/unistd.h \ |
| 935 | $(CONFIG_H) | 934 | $(CONFIG_H) |
| 936 | 935 | ||
| @@ -1514,6 +1513,7 @@ $(BLD)/w32menu.$(O) : \ | |||
| 1514 | $(SRC)/w32menu.c \ | 1513 | $(SRC)/w32menu.c \ |
| 1515 | $(SRC)/buffer.h \ | 1514 | $(SRC)/buffer.h \ |
| 1516 | $(SRC)/keymap.h \ | 1515 | $(SRC)/keymap.h \ |
| 1516 | $(SRC)/w32heap.h \ | ||
| 1517 | $(BLOCKINPUT_H) \ | 1517 | $(BLOCKINPUT_H) \ |
| 1518 | $(CHARSET_H) \ | 1518 | $(CHARSET_H) \ |
| 1519 | $(CODING_H) \ | 1519 | $(CODING_H) \ |
diff --git a/src/mem-limits.h b/src/mem-limits.h index 244592a9768..1fd53b472f3 100644 --- a/src/mem-limits.h +++ b/src/mem-limits.h | |||
| @@ -34,7 +34,7 @@ extern int etext; | |||
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | extern char *start_of_data (void); | 36 | extern char *start_of_data (void); |
| 37 | #if defined USE_LSB_TAG || UINTPTR_MAX >> VALBITS == 0 | 37 | #if defined USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX |
| 38 | #define EXCEEDS_LISP_PTR(ptr) 0 | 38 | #define EXCEEDS_LISP_PTR(ptr) 0 |
| 39 | #elif defined DATA_SEG_BITS | 39 | #elif defined DATA_SEG_BITS |
| 40 | #define EXCEEDS_LISP_PTR(ptr) \ | 40 | #define EXCEEDS_LISP_PTR(ptr) \ |
| @@ -1,6 +1,6 @@ | |||
| 1 | ### autodeps.mk --- src/Makefile fragment for GNU Emacs | 1 | ### autodeps.mk --- src/Makefile fragment for GNU Emacs |
| 2 | 2 | ||
| 3 | ## Copyright (C) 2008-2012 Free Software Foundation, Inc. | 3 | ## Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ## This file is part of GNU Emacs. | 5 | ## This file is part of GNU Emacs. |
| 6 | 6 | ||
| @@ -27,13 +27,13 @@ | |||
| 27 | 27 | ||
| 28 | ${ns_appdir}: ${ns_appsrc} | 28 | ${ns_appdir}: ${ns_appsrc} |
| 29 | rm -fr ${ns_appdir} | 29 | rm -fr ${ns_appdir} |
| 30 | mkdir -p ${ns_appdir} | 30 | ${MKDIR_P} ${ns_appdir} |
| 31 | ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - ) | 31 | ( cd ${ns_appsrc} ; tar cfh - . ) | ( cd ${ns_appdir} ; umask 022; tar xf - ) |
| 32 | 32 | ||
| 33 | ${ns_appbindir}Emacs: emacs${EXEEXT} | 33 | ${ns_appbindir}/Emacs: emacs${EXEEXT} |
| 34 | mkdir -p ${ns_appbindir} | 34 | ${MKDIR_P} ${ns_appbindir} |
| 35 | cp -f emacs${EXEEXT} ${ns_appbindir}Emacs | 35 | cp -f emacs${EXEEXT} ${ns_appbindir}/Emacs |
| 36 | 36 | ||
| 37 | ns-app: ${ns_appdir} ${ns_appbindir}Emacs | 37 | ns-app: ${ns_appdir} ${ns_appbindir}/Emacs |
| 38 | 38 | ||
| 39 | ### ns.mk ends here | 39 | ### ns.mk ends here |
diff --git a/src/nsterm.m b/src/nsterm.m index 7cbaf991311..4b8b2bb4820 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -338,11 +338,18 @@ ns_init_paths (void) | |||
| 338 | /*NSLog (@"loadPath: '%@'\n", resourcePaths); */ | 338 | /*NSLog (@"loadPath: '%@'\n", resourcePaths); */ |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | /* Normally, Emacs does not add its own bin/ directory to the PATH. | ||
| 342 | However, a self-contained NS build has a different layout, with | ||
| 343 | bin/ and libexec/ subdirectories in the directory that contains | ||
| 344 | Emacs.app itself. | ||
| 345 | We put libexec first, because init_callproc_1 uses the first | ||
| 346 | element to initialize exec-directory. An alternative would be | ||
| 347 | for init_callproc to check for invocation-directory/libexec. */ | ||
| 341 | if (!getenv ("EMACSPATH")) | 348 | if (!getenv ("EMACSPATH")) |
| 342 | { | 349 | { |
| 343 | NSArray *paths = [binDir stringsByAppendingPaths: | 350 | NSArray *paths = [binDir stringsByAppendingPaths: |
| 344 | [NSArray arrayWithObjects: @"bin", | 351 | [NSArray arrayWithObjects: @"libexec", |
| 345 | @"lib-exec", nil]]; | 352 | @"bin", nil]]; |
| 346 | NSEnumerator *pathEnum = [paths objectEnumerator]; | 353 | NSEnumerator *pathEnum = [paths objectEnumerator]; |
| 347 | resourcePaths = @""; | 354 | resourcePaths = @""; |
| 348 | while (resourcePath = [pathEnum nextObject]) | 355 | while (resourcePath = [pathEnum nextObject]) |
diff --git a/src/print.c b/src/print.c index bfe3287b92c..2912396bd33 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -854,7 +854,6 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 854 | { | 854 | { |
| 855 | Lisp_Object errname, errmsg, file_error, tail; | 855 | Lisp_Object errname, errmsg, file_error, tail; |
| 856 | struct gcpro gcpro1; | 856 | struct gcpro gcpro1; |
| 857 | int i; | ||
| 858 | 857 | ||
| 859 | if (context != 0) | 858 | if (context != 0) |
| 860 | write_string_1 (context, -1, stream); | 859 | write_string_1 (context, -1, stream); |
| @@ -885,9 +884,8 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 885 | } | 884 | } |
| 886 | else | 885 | else |
| 887 | { | 886 | { |
| 888 | Lisp_Object error_conditions; | 887 | Lisp_Object error_conditions = Fget (errname, Qerror_conditions); |
| 889 | errmsg = Fget (errname, Qerror_message); | 888 | errmsg = Fget (errname, Qerror_message); |
| 890 | error_conditions = Fget (errname, Qerror_conditions); | ||
| 891 | file_error = Fmemq (Qfile_error, error_conditions); | 889 | file_error = Fmemq (Qfile_error, error_conditions); |
| 892 | } | 890 | } |
| 893 | 891 | ||
| @@ -901,22 +899,30 @@ print_error_message (Lisp_Object data, Lisp_Object stream, const char *context, | |||
| 901 | if (!NILP (file_error) && CONSP (tail)) | 899 | if (!NILP (file_error) && CONSP (tail)) |
| 902 | errmsg = XCAR (tail), tail = XCDR (tail); | 900 | errmsg = XCAR (tail), tail = XCDR (tail); |
| 903 | 901 | ||
| 904 | if (STRINGP (errmsg)) | 902 | { |
| 905 | Fprinc (errmsg, stream); | 903 | const char *sep = ": "; |
| 906 | else | ||
| 907 | write_string_1 ("peculiar error", -1, stream); | ||
| 908 | 904 | ||
| 909 | for (i = 0; CONSP (tail); tail = XCDR (tail), i = 1) | 905 | if (!STRINGP (errmsg)) |
| 910 | { | 906 | write_string_1 ("peculiar error", -1, stream); |
| 911 | Lisp_Object obj; | 907 | else if (SCHARS (errmsg)) |
| 908 | Fprinc (errmsg, stream); | ||
| 909 | else | ||
| 910 | sep = NULL; | ||
| 912 | 911 | ||
| 913 | write_string_1 (i ? ", " : ": ", 2, stream); | 912 | for (; CONSP (tail); tail = XCDR (tail), sep = ", ") |
| 914 | obj = XCAR (tail); | 913 | { |
| 915 | if (!NILP (file_error) || EQ (errname, Qend_of_file)) | 914 | Lisp_Object obj; |
| 916 | Fprinc (obj, stream); | 915 | |
| 917 | else | 916 | if (sep) |
| 918 | Fprin1 (obj, stream); | 917 | write_string_1 (sep, 2, stream); |
| 919 | } | 918 | obj = XCAR (tail); |
| 919 | if (!NILP (file_error) | ||
| 920 | || EQ (errname, Qend_of_file) || EQ (errname, Quser_error)) | ||
| 921 | Fprinc (obj, stream); | ||
| 922 | else | ||
| 923 | Fprin1 (obj, stream); | ||
| 924 | } | ||
| 925 | } | ||
| 920 | 926 | ||
| 921 | UNGCPRO; | 927 | UNGCPRO; |
| 922 | } | 928 | } |
diff --git a/src/puresize.h b/src/puresize.h index bca36b2a562..bee82d1e783 100644 --- a/src/puresize.h +++ b/src/puresize.h | |||
| @@ -45,7 +45,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 45 | 45 | ||
| 46 | /* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ | 46 | /* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ |
| 47 | #ifndef PURESIZE_RATIO | 47 | #ifndef PURESIZE_RATIO |
| 48 | #if BITS_PER_EMACS_INT > 32 | 48 | #if EMACS_INT_MAX >> 31 != 0 |
| 49 | #if PTRDIFF_MAX >> 31 != 0 | 49 | #if PTRDIFF_MAX >> 31 != 0 |
| 50 | #define PURESIZE_RATIO 10/6 /* Don't surround with `()'. */ | 50 | #define PURESIZE_RATIO 10/6 /* Don't surround with `()'. */ |
| 51 | #else | 51 | #else |
diff --git a/src/ralloc.c b/src/ralloc.c index 4bb2f240438..d736e279520 100644 --- a/src/ralloc.c +++ b/src/ralloc.c | |||
| @@ -31,9 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 31 | 31 | ||
| 32 | #include <unistd.h> | 32 | #include <unistd.h> |
| 33 | 33 | ||
| 34 | typedef POINTER_TYPE *POINTER; | ||
| 35 | typedef size_t SIZE; | ||
| 36 | |||
| 37 | #ifdef DOUG_LEA_MALLOC | 34 | #ifdef DOUG_LEA_MALLOC |
| 38 | #define M_TOP_PAD -2 | 35 | #define M_TOP_PAD -2 |
| 39 | extern int mallopt (int, int); | 36 | extern int mallopt (int, int); |
| @@ -47,9 +44,6 @@ extern size_t __malloc_extra_blocks; | |||
| 47 | 44 | ||
| 48 | #include <stddef.h> | 45 | #include <stddef.h> |
| 49 | 46 | ||
| 50 | typedef size_t SIZE; | ||
| 51 | typedef void *POINTER; | ||
| 52 | |||
| 53 | #include <unistd.h> | 47 | #include <unistd.h> |
| 54 | #include <malloc.h> | 48 | #include <malloc.h> |
| 55 | 49 | ||
| @@ -58,6 +52,8 @@ typedef void *POINTER; | |||
| 58 | 52 | ||
| 59 | #include "getpagesize.h" | 53 | #include "getpagesize.h" |
| 60 | 54 | ||
| 55 | typedef size_t SIZE; | ||
| 56 | typedef void *POINTER; | ||
| 61 | #define NIL ((POINTER) 0) | 57 | #define NIL ((POINTER) 0) |
| 62 | 58 | ||
| 63 | /* A flag to indicate whether we have initialized ralloc yet. For | 59 | /* A flag to indicate whether we have initialized ralloc yet. For |
diff --git a/src/regex.c b/src/regex.c index d16a5148054..f9a12a3c2dc 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -434,17 +434,7 @@ init_syntax_once (void) | |||
| 434 | 434 | ||
| 435 | #endif /* not emacs */ | 435 | #endif /* not emacs */ |
| 436 | 436 | ||
| 437 | /* We remove any previous definition of `SIGN_EXTEND_CHAR', | 437 | #define SIGN_EXTEND_CHAR(c) ((signed char) (c)) |
| 438 | since ours (we hope) works properly with all combinations of | ||
| 439 | machines, compilers, `char' and `unsigned char' argument types. | ||
| 440 | (Per Bothner suggested the basic approach.) */ | ||
| 441 | #undef SIGN_EXTEND_CHAR | ||
| 442 | #if __STDC__ | ||
| 443 | # define SIGN_EXTEND_CHAR(c) ((signed char) (c)) | ||
| 444 | #else /* not __STDC__ */ | ||
| 445 | /* As in Harbison and Steele. */ | ||
| 446 | # define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) | ||
| 447 | #endif | ||
| 448 | 438 | ||
| 449 | /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we | 439 | /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we |
| 450 | use `alloca' instead of `malloc'. This is because using malloc in | 440 | use `alloca' instead of `malloc'. This is because using malloc in |
| @@ -553,12 +543,12 @@ typedef char boolean; | |||
| 553 | #define false 0 | 543 | #define false 0 |
| 554 | #define true 1 | 544 | #define true 1 |
| 555 | 545 | ||
| 556 | static regoff_t re_match_2_internal _RE_ARGS ((struct re_pattern_buffer *bufp, | 546 | static regoff_t re_match_2_internal (struct re_pattern_buffer *bufp, |
| 557 | re_char *string1, size_t size1, | 547 | re_char *string1, size_t size1, |
| 558 | re_char *string2, size_t size2, | 548 | re_char *string2, size_t size2, |
| 559 | ssize_t pos, | 549 | ssize_t pos, |
| 560 | struct re_registers *regs, | 550 | struct re_registers *regs, |
| 561 | ssize_t stop)); | 551 | ssize_t stop); |
| 562 | 552 | ||
| 563 | /* These are the command codes that appear in compiled regular | 553 | /* These are the command codes that appear in compiled regular |
| 564 | expressions. Some opcodes are followed by argument bytes. A | 554 | expressions. Some opcodes are followed by argument bytes. A |
| @@ -735,11 +725,8 @@ typedef enum | |||
| 735 | } while (0) | 725 | } while (0) |
| 736 | 726 | ||
| 737 | #ifdef DEBUG | 727 | #ifdef DEBUG |
| 738 | static void extract_number _RE_ARGS ((int *dest, re_char *source)); | ||
| 739 | static void | 728 | static void |
| 740 | extract_number (dest, source) | 729 | extract_number (int *dest, re_char *source) |
| 741 | int *dest; | ||
| 742 | re_char *source; | ||
| 743 | { | 730 | { |
| 744 | int temp = SIGN_EXTEND_CHAR (*(source + 1)); | 731 | int temp = SIGN_EXTEND_CHAR (*(source + 1)); |
| 745 | *dest = *source & 0377; | 732 | *dest = *source & 0377; |
| @@ -763,12 +750,8 @@ extract_number (dest, source) | |||
| 763 | } while (0) | 750 | } while (0) |
| 764 | 751 | ||
| 765 | #ifdef DEBUG | 752 | #ifdef DEBUG |
| 766 | static void extract_number_and_incr _RE_ARGS ((int *destination, | ||
| 767 | re_char **source)); | ||
| 768 | static void | 753 | static void |
| 769 | extract_number_and_incr (destination, source) | 754 | extract_number_and_incr (int *destination, re_char **source) |
| 770 | int *destination; | ||
| 771 | re_char **source; | ||
| 772 | { | 755 | { |
| 773 | extract_number (destination, *source); | 756 | extract_number (destination, *source); |
| 774 | *source += 2; | 757 | *source += 2; |
| @@ -1672,25 +1655,22 @@ do { \ | |||
| 1672 | 1655 | ||
| 1673 | /* Subroutine declarations and macros for regex_compile. */ | 1656 | /* Subroutine declarations and macros for regex_compile. */ |
| 1674 | 1657 | ||
| 1675 | static reg_errcode_t regex_compile _RE_ARGS ((re_char *pattern, size_t size, | 1658 | static reg_errcode_t regex_compile (re_char *pattern, size_t size, |
| 1676 | reg_syntax_t syntax, | 1659 | reg_syntax_t syntax, |
| 1677 | struct re_pattern_buffer *bufp)); | 1660 | struct re_pattern_buffer *bufp); |
| 1678 | static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg)); | 1661 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); |
| 1679 | static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, | 1662 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); |
| 1680 | int arg1, int arg2)); | 1663 | static void insert_op1 (re_opcode_t op, unsigned char *loc, |
| 1681 | static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, | 1664 | int arg, unsigned char *end); |
| 1682 | int arg, unsigned char *end)); | 1665 | static void insert_op2 (re_opcode_t op, unsigned char *loc, |
| 1683 | static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, | 1666 | int arg1, int arg2, unsigned char *end); |
| 1684 | int arg1, int arg2, unsigned char *end)); | 1667 | static boolean at_begline_loc_p (re_char *pattern, re_char *p, |
| 1685 | static boolean at_begline_loc_p _RE_ARGS ((re_char *pattern, | 1668 | reg_syntax_t syntax); |
| 1686 | re_char *p, | 1669 | static boolean at_endline_loc_p (re_char *p, re_char *pend, |
| 1687 | reg_syntax_t syntax)); | 1670 | reg_syntax_t syntax); |
| 1688 | static boolean at_endline_loc_p _RE_ARGS ((re_char *p, | 1671 | static re_char *skip_one_char (re_char *p); |
| 1689 | re_char *pend, | 1672 | static int analyse_first (re_char *p, re_char *pend, |
| 1690 | reg_syntax_t syntax)); | 1673 | char *fastmap, const int multibyte); |
| 1691 | static re_char *skip_one_char _RE_ARGS ((re_char *p)); | ||
| 1692 | static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, | ||
| 1693 | char *fastmap, const int multibyte)); | ||
| 1694 | 1674 | ||
| 1695 | /* Fetch the next character in the uncompiled pattern, with no | 1675 | /* Fetch the next character in the uncompiled pattern, with no |
| 1696 | translation. */ | 1676 | translation. */ |
| @@ -2442,9 +2422,8 @@ regex_grow_registers (int num_regs) | |||
| 2442 | 2422 | ||
| 2443 | #endif /* not MATCH_MAY_ALLOCATE */ | 2423 | #endif /* not MATCH_MAY_ALLOCATE */ |
| 2444 | 2424 | ||
| 2445 | static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type | 2425 | static boolean group_in_compile_stack (compile_stack_type compile_stack, |
| 2446 | compile_stack, | 2426 | regnum_t regnum); |
| 2447 | regnum_t regnum)); | ||
| 2448 | 2427 | ||
| 2449 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | 2428 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. |
| 2450 | Returns one of error codes defined in `regex.h', or zero for success. | 2429 | Returns one of error codes defined in `regex.h', or zero for success. |
| @@ -4554,10 +4533,10 @@ WEAK_ALIAS (__re_search_2, re_search_2) | |||
| 4554 | 4533 | ||
| 4555 | /* Declarations and macros for re_match_2. */ | 4534 | /* Declarations and macros for re_match_2. */ |
| 4556 | 4535 | ||
| 4557 | static int bcmp_translate _RE_ARGS ((re_char *s1, re_char *s2, | 4536 | static int bcmp_translate (re_char *s1, re_char *s2, |
| 4558 | register ssize_t len, | 4537 | register ssize_t len, |
| 4559 | RE_TRANSLATE_TYPE translate, | 4538 | RE_TRANSLATE_TYPE translate, |
| 4560 | const int multibyte)); | 4539 | const int multibyte); |
| 4561 | 4540 | ||
| 4562 | /* This converts PTR, a pointer into one of the search strings `string1' | 4541 | /* This converts PTR, a pointer into one of the search strings `string1' |
| 4563 | and `string2' into an offset from the beginning of that string. */ | 4542 | and `string2' into an offset from the beginning of that string. */ |
diff --git a/src/regex.h b/src/regex.h index 643d0b7b5ab..e0ede012b20 100644 --- a/src/regex.h +++ b/src/regex.h | |||
| @@ -451,38 +451,21 @@ typedef struct | |||
| 451 | 451 | ||
| 452 | /* Declarations for routines. */ | 452 | /* Declarations for routines. */ |
| 453 | 453 | ||
| 454 | /* To avoid duplicating every routine declaration -- once with a | ||
| 455 | prototype (if we are ANSI), and once without (if we aren't) -- we | ||
| 456 | use the following macro to declare argument types. This | ||
| 457 | unfortunately clutters up the declarations a bit, but I think it's | ||
| 458 | worth it. */ | ||
| 459 | |||
| 460 | #if defined __STDC__ || defined PROTOTYPES | ||
| 461 | |||
| 462 | # define _RE_ARGS(args) args | ||
| 463 | |||
| 464 | #else /* not __STDC__ || PROTOTYPES */ | ||
| 465 | |||
| 466 | # define _RE_ARGS(args) () | ||
| 467 | |||
| 468 | #endif /* not __STDC__ || PROTOTYPES */ | ||
| 469 | |||
| 470 | /* Sets the current default syntax to SYNTAX, and return the old syntax. | 454 | /* Sets the current default syntax to SYNTAX, and return the old syntax. |
| 471 | You can also simply assign to the `re_syntax_options' variable. */ | 455 | You can also simply assign to the `re_syntax_options' variable. */ |
| 472 | extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); | 456 | extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); |
| 473 | 457 | ||
| 474 | /* Compile the regular expression PATTERN, with length LENGTH | 458 | /* Compile the regular expression PATTERN, with length LENGTH |
| 475 | and syntax given by the global `re_syntax_options', into the buffer | 459 | and syntax given by the global `re_syntax_options', into the buffer |
| 476 | BUFFER. Return NULL if successful, and an error string if not. */ | 460 | BUFFER. Return NULL if successful, and an error string if not. */ |
| 477 | extern const char *re_compile_pattern | 461 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, |
| 478 | _RE_ARGS ((const char *pattern, size_t length, | 462 | struct re_pattern_buffer *__buffer); |
| 479 | struct re_pattern_buffer *buffer)); | ||
| 480 | 463 | ||
| 481 | 464 | ||
| 482 | /* Compile a fastmap for the compiled pattern in BUFFER; used to | 465 | /* Compile a fastmap for the compiled pattern in BUFFER; used to |
| 483 | accelerate searches. Return 0 if successful and -2 if was an | 466 | accelerate searches. Return 0 if successful and -2 if was an |
| 484 | internal error. */ | 467 | internal error. */ |
| 485 | extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); | 468 | extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); |
| 486 | 469 | ||
| 487 | 470 | ||
| 488 | /* Search in the string STRING (with length LENGTH) for the pattern | 471 | /* Search in the string STRING (with length LENGTH) for the pattern |
| @@ -490,33 +473,35 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); | |||
| 490 | characters. Return the starting position of the match, -1 for no | 473 | characters. Return the starting position of the match, -1 for no |
| 491 | match, or -2 for an internal error. Also return register | 474 | match, or -2 for an internal error. Also return register |
| 492 | information in REGS (if REGS and BUFFER->no_sub are nonzero). */ | 475 | information in REGS (if REGS and BUFFER->no_sub are nonzero). */ |
| 493 | extern regoff_t re_search | 476 | extern regoff_t re_search (struct re_pattern_buffer *__buffer, |
| 494 | _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, | 477 | const char *__string, size_t __length, |
| 495 | size_t length, ssize_t start, ssize_t range, | 478 | ssize_t __start, ssize_t __range, |
| 496 | struct re_registers *regs)); | 479 | struct re_registers *__regs); |
| 497 | 480 | ||
| 498 | 481 | ||
| 499 | /* Like `re_search', but search in the concatenation of STRING1 and | 482 | /* Like `re_search', but search in the concatenation of STRING1 and |
| 500 | STRING2. Also, stop searching at index START + STOP. */ | 483 | STRING2. Also, stop searching at index START + STOP. */ |
| 501 | extern regoff_t re_search_2 | 484 | extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, |
| 502 | _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, | 485 | const char *__string1, size_t __length1, |
| 503 | size_t length1, const char *string2, size_t length2, | 486 | const char *__string2, size_t __length2, |
| 504 | ssize_t start, ssize_t range, struct re_registers *regs, | 487 | ssize_t __start, ssize_t __range, |
| 505 | ssize_t stop)); | 488 | struct re_registers *__regs, |
| 489 | ssize_t __stop); | ||
| 506 | 490 | ||
| 507 | 491 | ||
| 508 | /* Like `re_search', but return how many characters in STRING the regexp | 492 | /* Like `re_search', but return how many characters in STRING the regexp |
| 509 | in BUFFER matched, starting at position START. */ | 493 | in BUFFER matched, starting at position START. */ |
| 510 | extern regoff_t re_match | 494 | extern regoff_t re_match (struct re_pattern_buffer *__buffer, |
| 511 | _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, | 495 | const char *__string, size_t __length, |
| 512 | size_t length, ssize_t start, struct re_registers *regs)); | 496 | ssize_t __start, struct re_registers *__regs); |
| 513 | 497 | ||
| 514 | 498 | ||
| 515 | /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ | 499 | /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ |
| 516 | extern regoff_t re_match_2 | 500 | extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, |
| 517 | _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, | 501 | const char *__string1, size_t __length1, |
| 518 | size_t length1, const char *string2, size_t length2, | 502 | const char *__string2, size_t __length2, |
| 519 | ssize_t start, struct re_registers *regs, ssize_t stop)); | 503 | ssize_t __start, struct re_registers *__regs, |
| 504 | ssize_t __stop); | ||
| 520 | 505 | ||
| 521 | 506 | ||
| 522 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | 507 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and |
| @@ -531,15 +516,16 @@ extern regoff_t re_match_2 | |||
| 531 | Unless this function is called, the first search or match using | 516 | Unless this function is called, the first search or match using |
| 532 | PATTERN_BUFFER will allocate its own register data, without | 517 | PATTERN_BUFFER will allocate its own register data, without |
| 533 | freeing the old data. */ | 518 | freeing the old data. */ |
| 534 | extern void re_set_registers | 519 | extern void re_set_registers (struct re_pattern_buffer *__buffer, |
| 535 | _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, | 520 | struct re_registers *__regs, |
| 536 | unsigned num_regs, regoff_t *starts, regoff_t *ends)); | 521 | unsigned __num_regs, |
| 522 | regoff_t *__starts, regoff_t *__ends); | ||
| 537 | 523 | ||
| 538 | #if defined _REGEX_RE_COMP || defined _LIBC | 524 | #if defined _REGEX_RE_COMP || defined _LIBC |
| 539 | # ifndef _CRAY | 525 | # ifndef _CRAY |
| 540 | /* 4.2 bsd compatibility. */ | 526 | /* 4.2 bsd compatibility. */ |
| 541 | extern char *re_comp _RE_ARGS ((const char *)); | 527 | extern char *re_comp (const char *); |
| 542 | extern int re_exec _RE_ARGS ((const char *)); | 528 | extern int re_exec (const char *); |
| 543 | # endif | 529 | # endif |
| 544 | #endif | 530 | #endif |
| 545 | 531 | ||
| @@ -562,20 +548,19 @@ extern int re_exec _RE_ARGS ((const char *)); | |||
| 562 | #endif | 548 | #endif |
| 563 | 549 | ||
| 564 | /* POSIX compatibility. */ | 550 | /* POSIX compatibility. */ |
| 565 | extern reg_errcode_t regcomp _RE_ARGS ((regex_t *__restrict __preg, | 551 | extern reg_errcode_t regcomp (regex_t *__restrict __preg, |
| 566 | const char *__restrict __pattern, | 552 | const char *__restrict __pattern, |
| 567 | int __cflags)); | 553 | int __cflags); |
| 568 | 554 | ||
| 569 | extern reg_errcode_t regexec _RE_ARGS ((const regex_t *__restrict __preg, | 555 | extern reg_errcode_t regexec (const regex_t *__restrict __preg, |
| 570 | const char *__restrict __string, | 556 | const char *__restrict __string, size_t __nmatch, |
| 571 | size_t __nmatch, | 557 | regmatch_t __pmatch[__restrict_arr], |
| 572 | regmatch_t __pmatch[__restrict_arr], | 558 | int __eflags); |
| 573 | int __eflags)); | ||
| 574 | 559 | ||
| 575 | extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, | 560 | extern size_t regerror (int __errcode, const regex_t * __preg, |
| 576 | char *__errbuf, size_t __errbuf_size)); | 561 | char *__errbuf, size_t __errbuf_size); |
| 577 | 562 | ||
| 578 | extern void regfree _RE_ARGS ((regex_t *__preg)); | 563 | extern void regfree (regex_t *__preg); |
| 579 | 564 | ||
| 580 | 565 | ||
| 581 | #ifdef __cplusplus | 566 | #ifdef __cplusplus |
diff --git a/src/s/aix4-2.h b/src/s/aix4-2.h index 354ffda0988..cacfdc7ed63 100644 --- a/src/s/aix4-2.h +++ b/src/s/aix4-2.h | |||
| @@ -76,6 +76,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 76 | to avoid a crash just use the Emacs implementation for that function. */ | 76 | to avoid a crash just use the Emacs implementation for that function. */ |
| 77 | #define BROKEN_GET_CURRENT_DIR_NAME 1 | 77 | #define BROKEN_GET_CURRENT_DIR_NAME 1 |
| 78 | 78 | ||
| 79 | /*** BUILD 9008 - FIONREAD problem still exists in X-Windows. ***/ | ||
| 80 | #define BROKEN_FIONREAD | ||
| 81 | /* As we define BROKEN_FIONREAD, SIGIO will be undefined in systty.h. | ||
| 82 | But, on AIX, SIGAIO, SIGPTY, and SIGPOLL are defined as SIGIO, | ||
| 83 | which causes compilation error at init_signals in sysdep.c. So, we | ||
| 84 | define these macros so that syssignal.h detects them and undefine | ||
| 85 | SIGAIO, SIGPTY and SIGPOLL. */ | ||
| 86 | #define BROKEN_SIGAIO | ||
| 87 | #define BROKEN_SIGPTY | ||
| 88 | #define BROKEN_SIGPOLL | ||
| 89 | |||
| 79 | /* Conservative garbage collection has not been tested, so for now | 90 | /* Conservative garbage collection has not been tested, so for now |
| 80 | play it safe and stick with the old-fashioned way of marking. */ | 91 | play it safe and stick with the old-fashioned way of marking. */ |
| 81 | #define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE | 92 | #define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE |
diff --git a/src/s/gnu-linux.h b/src/s/gnu-linux.h index d04ea33068a..409d0205520 100644 --- a/src/s/gnu-linux.h +++ b/src/s/gnu-linux.h | |||
| @@ -157,3 +157,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 157 | #else | 157 | #else |
| 158 | #define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE | 158 | #define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE |
| 159 | #endif | 159 | #endif |
| 160 | |||
| 161 | #ifdef __i386__ | ||
| 162 | /* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */ | ||
| 163 | /* we cannot get the maximum address for brk */ | ||
| 164 | # define ULIMIT_BREAK_VALUE (32*1024*1024) | ||
| 165 | #endif | ||
diff --git a/src/s/gnu.h b/src/s/gnu.h index a09e0e824c9..cd72164a520 100644 --- a/src/s/gnu.h +++ b/src/s/gnu.h | |||
| @@ -24,8 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 24 | #undef SYSTEM_TYPE | 24 | #undef SYSTEM_TYPE |
| 25 | #define SYSTEM_TYPE "gnu" | 25 | #define SYSTEM_TYPE "gnu" |
| 26 | 26 | ||
| 27 | #undef NLIST_STRUCT | ||
| 28 | |||
| 29 | #define SIGNALS_VIA_CHARACTERS | 27 | #define SIGNALS_VIA_CHARACTERS |
| 30 | 28 | ||
| 31 | /* libc defines data_start. */ | 29 | /* libc defines data_start. */ |
diff --git a/src/s/irix6-5.h b/src/s/irix6-5.h index e5d90c1bd5d..e5479c3b8d3 100644 --- a/src/s/irix6-5.h +++ b/src/s/irix6-5.h | |||
| @@ -85,10 +85,6 @@ char *_getpty(); | |||
| 85 | 85 | ||
| 86 | #define NARROWPROTO 1 | 86 | #define NARROWPROTO 1 |
| 87 | 87 | ||
| 88 | #if _MIPS_SZLONG == 64 /* -mabi=64 (gcc) or -64 (MIPSpro) */ | ||
| 89 | #define _LP64 /* lisp.h takes care of the rest */ | ||
| 90 | #endif /* _MIPS_SZLONG */ | ||
| 91 | |||
| 92 | #undef SA_RESTART | 88 | #undef SA_RESTART |
| 93 | 89 | ||
| 94 | #undef TIOCSIGSEND /* defined in usg5-4-common.h */ | 90 | #undef TIOCSIGSEND /* defined in usg5-4-common.h */ |
diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h index e89ecb05931..f88128b27aa 100644 --- a/src/s/ms-w32.h +++ b/src/s/ms-w32.h | |||
| @@ -122,7 +122,6 @@ struct sigaction { | |||
| 122 | 122 | ||
| 123 | #define HAVE_GETTIMEOFDAY 1 | 123 | #define HAVE_GETTIMEOFDAY 1 |
| 124 | #define HAVE_GETHOSTNAME 1 | 124 | #define HAVE_GETHOSTNAME 1 |
| 125 | #undef HAVE_GETDOMAINNAME | ||
| 126 | #define HAVE_DUP2 1 | 125 | #define HAVE_DUP2 1 |
| 127 | #define HAVE_RENAME 1 | 126 | #define HAVE_RENAME 1 |
| 128 | #define HAVE_CLOSEDIR 1 | 127 | #define HAVE_CLOSEDIR 1 |
| @@ -147,7 +146,6 @@ struct sigaction { | |||
| 147 | #define HAVE_FMOD 1 | 146 | #define HAVE_FMOD 1 |
| 148 | #undef HAVE_RINT | 147 | #undef HAVE_RINT |
| 149 | #undef HAVE_CBRT | 148 | #undef HAVE_CBRT |
| 150 | #define HAVE_FTIME 1 | ||
| 151 | #undef HAVE_RES_INIT /* For -lresolv on Suns. */ | 149 | #undef HAVE_RES_INIT /* For -lresolv on Suns. */ |
| 152 | #undef HAVE_SETSID | 150 | #undef HAVE_SETSID |
| 153 | #undef HAVE_FPATHCONF | 151 | #undef HAVE_FPATHCONF |
| @@ -383,6 +381,8 @@ extern int getloadavg (double *, int); | |||
| 383 | /* We need a little extra space, see ../../lisp/loadup.el. */ | 381 | /* We need a little extra space, see ../../lisp/loadup.el. */ |
| 384 | #define SYSTEM_PURESIZE_EXTRA 50000 | 382 | #define SYSTEM_PURESIZE_EXTRA 50000 |
| 385 | 383 | ||
| 384 | #define DATA_START get_data_start () | ||
| 385 | |||
| 386 | /* For unexec to work on Alpha systems, we need to put Emacs' | 386 | /* For unexec to work on Alpha systems, we need to put Emacs' |
| 387 | initialized data into a separate section from the CRT initialized | 387 | initialized data into a separate section from the CRT initialized |
| 388 | data (because the Alpha linker freely reorders data variables, even | 388 | data (because the Alpha linker freely reorders data variables, even |
diff --git a/src/search.c b/src/search.c index 503720b70ab..a9542a2ed97 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -2079,112 +2079,6 @@ set_search_regs (ptrdiff_t beg_byte, ptrdiff_t nbytes) | |||
| 2079 | XSETBUFFER (last_thing_searched, current_buffer); | 2079 | XSETBUFFER (last_thing_searched, current_buffer); |
| 2080 | } | 2080 | } |
| 2081 | 2081 | ||
| 2082 | DEFUN ("word-search-regexp", Fword_search_regexp, Sword_search_regexp, 1, 2, 0, | ||
| 2083 | doc: /* Return a regexp which matches words, ignoring punctuation. | ||
| 2084 | Given STRING, a string of words separated by word delimiters, | ||
| 2085 | compute a regexp that matches those exact words separated by | ||
| 2086 | arbitrary punctuation. If LAX is non-nil, the end of the string | ||
| 2087 | need not match a word boundary unless it ends in whitespace. | ||
| 2088 | |||
| 2089 | Used in `word-search-forward', `word-search-backward', | ||
| 2090 | `word-search-forward-lax', `word-search-backward-lax'. */) | ||
| 2091 | (Lisp_Object string, Lisp_Object lax) | ||
| 2092 | { | ||
| 2093 | register unsigned char *o; | ||
| 2094 | register ptrdiff_t i, i_byte, len, punct_count = 0, word_count = 0; | ||
| 2095 | Lisp_Object val; | ||
| 2096 | int prev_c = 0; | ||
| 2097 | EMACS_INT adjust; | ||
| 2098 | int whitespace_at_end; | ||
| 2099 | |||
| 2100 | CHECK_STRING (string); | ||
| 2101 | len = SCHARS (string); | ||
| 2102 | |||
| 2103 | for (i = 0, i_byte = 0; i < len; ) | ||
| 2104 | { | ||
| 2105 | int c; | ||
| 2106 | |||
| 2107 | FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte); | ||
| 2108 | |||
| 2109 | if (SYNTAX (c) != Sword) | ||
| 2110 | { | ||
| 2111 | punct_count++; | ||
| 2112 | if (SYNTAX (prev_c) == Sword) | ||
| 2113 | word_count++; | ||
| 2114 | } | ||
| 2115 | |||
| 2116 | prev_c = c; | ||
| 2117 | } | ||
| 2118 | |||
| 2119 | if (SYNTAX (prev_c) == Sword) | ||
| 2120 | { | ||
| 2121 | word_count++; | ||
| 2122 | whitespace_at_end = 0; | ||
| 2123 | } | ||
| 2124 | else | ||
| 2125 | { | ||
| 2126 | whitespace_at_end = 1; | ||
| 2127 | if (!word_count) | ||
| 2128 | return empty_unibyte_string; | ||
| 2129 | } | ||
| 2130 | |||
| 2131 | adjust = word_count - 1; | ||
| 2132 | if (TYPE_MAXIMUM (EMACS_INT) / 5 < adjust) | ||
| 2133 | memory_full (SIZE_MAX); | ||
| 2134 | adjust = - punct_count + 5 * adjust | ||
| 2135 | + ((!NILP (lax) && !whitespace_at_end) ? 2 : 4); | ||
| 2136 | if (STRING_MULTIBYTE (string)) | ||
| 2137 | { | ||
| 2138 | if (INT_ADD_OVERFLOW (SBYTES (string), adjust)) | ||
| 2139 | memory_full (SIZE_MAX); | ||
| 2140 | val = make_uninit_multibyte_string (len + adjust, | ||
| 2141 | SBYTES (string) + adjust); | ||
| 2142 | } | ||
| 2143 | else | ||
| 2144 | { | ||
| 2145 | if (INT_ADD_OVERFLOW (len, adjust)) | ||
| 2146 | memory_full (SIZE_MAX); | ||
| 2147 | val = make_uninit_string (len + adjust); | ||
| 2148 | } | ||
| 2149 | |||
| 2150 | o = SDATA (val); | ||
| 2151 | *o++ = '\\'; | ||
| 2152 | *o++ = 'b'; | ||
| 2153 | prev_c = 0; | ||
| 2154 | |||
| 2155 | for (i = 0, i_byte = 0; i < len; ) | ||
| 2156 | { | ||
| 2157 | int c; | ||
| 2158 | ptrdiff_t i_byte_orig = i_byte; | ||
| 2159 | |||
| 2160 | FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte); | ||
| 2161 | |||
| 2162 | if (SYNTAX (c) == Sword) | ||
| 2163 | { | ||
| 2164 | memcpy (o, SDATA (string) + i_byte_orig, i_byte - i_byte_orig); | ||
| 2165 | o += i_byte - i_byte_orig; | ||
| 2166 | } | ||
| 2167 | else if (SYNTAX (prev_c) == Sword && --word_count) | ||
| 2168 | { | ||
| 2169 | *o++ = '\\'; | ||
| 2170 | *o++ = 'W'; | ||
| 2171 | *o++ = '\\'; | ||
| 2172 | *o++ = 'W'; | ||
| 2173 | *o++ = '*'; | ||
| 2174 | } | ||
| 2175 | |||
| 2176 | prev_c = c; | ||
| 2177 | } | ||
| 2178 | |||
| 2179 | if (NILP (lax) || whitespace_at_end) | ||
| 2180 | { | ||
| 2181 | *o++ = '\\'; | ||
| 2182 | *o++ = 'b'; | ||
| 2183 | } | ||
| 2184 | |||
| 2185 | return val; | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4, | 2082 | DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4, |
| 2189 | "MSearch backward: ", | 2083 | "MSearch backward: ", |
| 2190 | doc: /* Search backward from point for STRING. | 2084 | doc: /* Search backward from point for STRING. |
| @@ -2227,86 +2121,6 @@ See also the functions `match-beginning', `match-end' and `replace-match'. */) | |||
| 2227 | return search_command (string, bound, noerror, count, 1, 0, 0); | 2121 | return search_command (string, bound, noerror, count, 1, 0, 0); |
| 2228 | } | 2122 | } |
| 2229 | 2123 | ||
| 2230 | DEFUN ("word-search-backward", Fword_search_backward, Sword_search_backward, 1, 4, | ||
| 2231 | "sWord search backward: ", | ||
| 2232 | doc: /* Search backward from point for STRING, ignoring differences in punctuation. | ||
| 2233 | Set point to the beginning of the occurrence found, and return point. | ||
| 2234 | An optional second argument bounds the search; it is a buffer position. | ||
| 2235 | The match found must not extend before that position. | ||
| 2236 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 2237 | If not nil and not t, move to limit of search and return nil. | ||
| 2238 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 2239 | |||
| 2240 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 2241 | of words in STRING to a regexp used to search words without regard | ||
| 2242 | to punctuation. */) | ||
| 2243 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | ||
| 2244 | { | ||
| 2245 | return search_command (Fword_search_regexp (string, Qnil), bound, noerror, count, -1, 1, 0); | ||
| 2246 | } | ||
| 2247 | |||
| 2248 | DEFUN ("word-search-forward", Fword_search_forward, Sword_search_forward, 1, 4, | ||
| 2249 | "sWord search: ", | ||
| 2250 | doc: /* Search forward from point for STRING, ignoring differences in punctuation. | ||
| 2251 | Set point to the end of the occurrence found, and return point. | ||
| 2252 | An optional second argument bounds the search; it is a buffer position. | ||
| 2253 | The match found must not extend after that position. | ||
| 2254 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 2255 | If not nil and not t, move to limit of search and return nil. | ||
| 2256 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 2257 | |||
| 2258 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 2259 | of words in STRING to a regexp used to search words without regard | ||
| 2260 | to punctuation. */) | ||
| 2261 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | ||
| 2262 | { | ||
| 2263 | return search_command (Fword_search_regexp (string, Qnil), bound, noerror, count, 1, 1, 0); | ||
| 2264 | } | ||
| 2265 | |||
| 2266 | DEFUN ("word-search-backward-lax", Fword_search_backward_lax, Sword_search_backward_lax, 1, 4, | ||
| 2267 | "sWord search backward: ", | ||
| 2268 | doc: /* Search backward from point for STRING, ignoring differences in punctuation. | ||
| 2269 | Set point to the beginning of the occurrence found, and return point. | ||
| 2270 | |||
| 2271 | Unlike `word-search-backward', the end of STRING need not match a word | ||
| 2272 | boundary, unless STRING ends in whitespace. | ||
| 2273 | |||
| 2274 | An optional second argument bounds the search; it is a buffer position. | ||
| 2275 | The match found must not extend before that position. | ||
| 2276 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 2277 | If not nil and not t, move to limit of search and return nil. | ||
| 2278 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 2279 | |||
| 2280 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 2281 | of words in STRING to a regexp used to search words without regard | ||
| 2282 | to punctuation. */) | ||
| 2283 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | ||
| 2284 | { | ||
| 2285 | return search_command (Fword_search_regexp (string, Qt), bound, noerror, count, -1, 1, 0); | ||
| 2286 | } | ||
| 2287 | |||
| 2288 | DEFUN ("word-search-forward-lax", Fword_search_forward_lax, Sword_search_forward_lax, 1, 4, | ||
| 2289 | "sWord search: ", | ||
| 2290 | doc: /* Search forward from point for STRING, ignoring differences in punctuation. | ||
| 2291 | Set point to the end of the occurrence found, and return point. | ||
| 2292 | |||
| 2293 | Unlike `word-search-forward', the end of STRING need not match a word | ||
| 2294 | boundary, unless STRING ends in whitespace. | ||
| 2295 | |||
| 2296 | An optional second argument bounds the search; it is a buffer position. | ||
| 2297 | The match found must not extend after that position. | ||
| 2298 | Optional third argument, if t, means if fail just return nil (no error). | ||
| 2299 | If not nil and not t, move to limit of search and return nil. | ||
| 2300 | Optional fourth argument is repeat count--search for successive occurrences. | ||
| 2301 | |||
| 2302 | Relies on the function `word-search-regexp' to convert a sequence | ||
| 2303 | of words in STRING to a regexp used to search words without regard | ||
| 2304 | to punctuation. */) | ||
| 2305 | (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) | ||
| 2306 | { | ||
| 2307 | return search_command (Fword_search_regexp (string, Qt), bound, noerror, count, 1, 1, 0); | ||
| 2308 | } | ||
| 2309 | |||
| 2310 | DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, | 2124 | DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, |
| 2311 | "sRE search backward: ", | 2125 | "sRE search backward: ", |
| 2312 | doc: /* Search backward from point for match for regular expression REGEXP. | 2126 | doc: /* Search backward from point for match for regular expression REGEXP. |
| @@ -3277,11 +3091,6 @@ is to bind it with `let' around a small expression. */); | |||
| 3277 | defsubr (&Sposix_string_match); | 3091 | defsubr (&Sposix_string_match); |
| 3278 | defsubr (&Ssearch_forward); | 3092 | defsubr (&Ssearch_forward); |
| 3279 | defsubr (&Ssearch_backward); | 3093 | defsubr (&Ssearch_backward); |
| 3280 | defsubr (&Sword_search_regexp); | ||
| 3281 | defsubr (&Sword_search_forward); | ||
| 3282 | defsubr (&Sword_search_backward); | ||
| 3283 | defsubr (&Sword_search_forward_lax); | ||
| 3284 | defsubr (&Sword_search_backward_lax); | ||
| 3285 | defsubr (&Sre_search_forward); | 3094 | defsubr (&Sre_search_forward); |
| 3286 | defsubr (&Sre_search_backward); | 3095 | defsubr (&Sre_search_backward); |
| 3287 | defsubr (&Sposix_search_forward); | 3096 | defsubr (&Sposix_search_forward); |
diff --git a/src/sound.c b/src/sound.c index bd34628767b..143653e48e4 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -124,9 +124,6 @@ static int parse_sound (Lisp_Object, Lisp_Object *); | |||
| 124 | #ifndef DEFAULT_SOUND_DEVICE | 124 | #ifndef DEFAULT_SOUND_DEVICE |
| 125 | #define DEFAULT_SOUND_DEVICE "/dev/dsp" | 125 | #define DEFAULT_SOUND_DEVICE "/dev/dsp" |
| 126 | #endif | 126 | #endif |
| 127 | #ifndef DEFAULT_ALSA_SOUND_DEVICE | ||
| 128 | #define DEFAULT_ALSA_SOUND_DEVICE "default" | ||
| 129 | #endif | ||
| 130 | 127 | ||
| 131 | 128 | ||
| 132 | /* Structure forward declarations. */ | 129 | /* Structure forward declarations. */ |
| @@ -908,6 +905,10 @@ vox_write (struct sound_device *sd, const char *buffer, ptrdiff_t nbytes) | |||
| 908 | 905 | ||
| 909 | /* This driver is available on GNU/Linux. */ | 906 | /* This driver is available on GNU/Linux. */ |
| 910 | 907 | ||
| 908 | #ifndef DEFAULT_ALSA_SOUND_DEVICE | ||
| 909 | #define DEFAULT_ALSA_SOUND_DEVICE "default" | ||
| 910 | #endif | ||
| 911 | |||
| 911 | static void | 912 | static void |
| 912 | alsa_sound_perror (const char *msg, int err) | 913 | alsa_sound_perror (const char *msg, int err) |
| 913 | { | 914 | { |
diff --git a/src/sysdep.c b/src/sysdep.c index 9d09d1d2c67..a82f802a785 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -52,9 +52,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | #define read sys_read | 52 | #define read sys_read |
| 53 | #define write sys_write | 53 | #define write sys_write |
| 54 | #include <windows.h> | 54 | #include <windows.h> |
| 55 | #ifndef NULL | ||
| 56 | #define NULL 0 | ||
| 57 | #endif | ||
| 58 | #endif /* not WINDOWSNT */ | 55 | #endif /* not WINDOWSNT */ |
| 59 | 56 | ||
| 60 | #include <sys/types.h> | 57 | #include <sys/types.h> |
diff --git a/src/syssignal.h b/src/syssignal.h index 86135d71215..a2522f24429 100644 --- a/src/syssignal.h +++ b/src/syssignal.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* syssignal.h - System-dependent definitions for signals. | 1 | /* syssignal.h - System-dependent definitions for signals. |
| 2 | Copyright (C) 1993, 1999, 2001-2012 Free Software Foundation, Inc. | 2 | |
| 3 | Copyright (C) 1993, 1999, 2001-2012 Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -82,24 +83,18 @@ void croak (char *) NO_RETURN; | |||
| 82 | 83 | ||
| 83 | #define sigfree() sigsetmask (SIGEMPTYMASK) | 84 | #define sigfree() sigsetmask (SIGEMPTYMASK) |
| 84 | 85 | ||
| 85 | #if defined (SIGINFO) && defined (BROKEN_SIGINFO) | ||
| 86 | #undef SIGINFO | ||
| 87 | #endif | ||
| 88 | #if defined (SIGIO) && defined (BROKEN_SIGIO) | 86 | #if defined (SIGIO) && defined (BROKEN_SIGIO) |
| 89 | # undef SIGIO | 87 | # undef SIGIO |
| 90 | #endif | 88 | #endif |
| 89 | /* Last user: m/ibmrs6000.h */ | ||
| 91 | #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) | 90 | #if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) |
| 92 | #undef SIGPOLL | 91 | #undef SIGPOLL |
| 93 | #endif | 92 | #endif |
| 94 | #if defined (SIGTSTP) && defined (BROKEN_SIGTSTP) | 93 | /* Last user: m/ibmrs6000.h */ |
| 95 | #undef SIGTSTP | ||
| 96 | #endif | ||
| 97 | #if defined (SIGURG) && defined (BROKEN_SIGURG) | ||
| 98 | #undef SIGURG | ||
| 99 | #endif | ||
| 100 | #if defined (SIGAIO) && defined (BROKEN_SIGAIO) | 94 | #if defined (SIGAIO) && defined (BROKEN_SIGAIO) |
| 101 | #undef SIGAIO | 95 | #undef SIGAIO |
| 102 | #endif | 96 | #endif |
| 97 | /* Last user: m/ibmrs6000.h */ | ||
| 103 | #if defined (SIGPTY) && defined (BROKEN_SIGPTY) | 98 | #if defined (SIGPTY) && defined (BROKEN_SIGPTY) |
| 104 | #undef SIGPTY | 99 | #undef SIGPTY |
| 105 | #endif | 100 | #endif |
diff --git a/src/term.c b/src/term.c index 09888bc6dda..3d7a677374c 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -3599,7 +3599,7 @@ delete_tty (struct terminal *terminal) | |||
| 3599 | 3599 | ||
| 3600 | 3600 | ||
| 3601 | /* Mark the pointers in the tty_display_info objects. | 3601 | /* Mark the pointers in the tty_display_info objects. |
| 3602 | Called by the Fgarbage_collector. */ | 3602 | Called by Fgarbage_collect. */ |
| 3603 | 3603 | ||
| 3604 | void | 3604 | void |
| 3605 | mark_ttys (void) | 3605 | mark_ttys (void) |
diff --git a/src/termcap.c b/src/termcap.c index 10c195eebe2..61f9d9a31ea 100644 --- a/src/termcap.c +++ b/src/termcap.c | |||
| @@ -30,10 +30,6 @@ Boston, MA 02110-1301, USA. */ | |||
| 30 | #include "msdos.h" | 30 | #include "msdos.h" |
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | #ifndef NULL | ||
| 34 | #define NULL (char *) 0 | ||
| 35 | #endif | ||
| 36 | |||
| 37 | /* BUFSIZE is the initial size allocated for the buffer | 33 | /* BUFSIZE is the initial size allocated for the buffer |
| 38 | for reading the termcap file. | 34 | for reading the termcap file. |
| 39 | It is not a limit. | 35 | It is not a limit. |
| @@ -661,10 +657,6 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) | |||
| 661 | 657 | ||
| 662 | #ifdef TEST | 658 | #ifdef TEST |
| 663 | 659 | ||
| 664 | #ifdef NULL | ||
| 665 | #undef NULL | ||
| 666 | #endif | ||
| 667 | |||
| 668 | #include <stdio.h> | 660 | #include <stdio.h> |
| 669 | 661 | ||
| 670 | static void | 662 | static void |
diff --git a/src/textprop.c b/src/textprop.c index f9339c66893..83d07c56f28 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -23,10 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 23 | #include "buffer.h" | 23 | #include "buffer.h" |
| 24 | #include "window.h" | 24 | #include "window.h" |
| 25 | 25 | ||
| 26 | #ifndef NULL | ||
| 27 | #define NULL (void *)0 | ||
| 28 | #endif | ||
| 29 | |||
| 30 | /* Test for membership, allowing for t (actually any non-cons) to mean the | 26 | /* Test for membership, allowing for t (actually any non-cons) to mean the |
| 31 | universal set. */ | 27 | universal set. */ |
| 32 | 28 | ||
diff --git a/src/tparam.c b/src/tparam.c index ac21667d65b..4d26ef524fb 100644 --- a/src/tparam.c +++ b/src/tparam.c | |||
| @@ -22,10 +22,6 @@ Boston, MA 02110-1301, USA. */ | |||
| 22 | #include <setjmp.h> | 22 | #include <setjmp.h> |
| 23 | #include "lisp.h" /* for xmalloc */ | 23 | #include "lisp.h" /* for xmalloc */ |
| 24 | #include "tparam.h" | 24 | #include "tparam.h" |
| 25 | |||
| 26 | #ifndef NULL | ||
| 27 | #define NULL (char *) 0 | ||
| 28 | #endif | ||
| 29 | 25 | ||
| 30 | /* Assuming STRING is the value of a termcap string entry | 26 | /* Assuming STRING is the value of a termcap string entry |
| 31 | containing `%' constructs to expand parameters, | 27 | containing `%' constructs to expand parameters, |
diff --git a/src/undo.c b/src/undo.c index 929955ffcf5..9b763984d7f 100644 --- a/src/undo.c +++ b/src/undo.c | |||
| @@ -436,6 +436,13 @@ truncate_undo_list (struct buffer *b) | |||
| 436 | 436 | ||
| 437 | unbind_to (count, Qnil); | 437 | unbind_to (count, Qnil); |
| 438 | } | 438 | } |
| 439 | |||
| 440 | static void user_error (const char*) NO_RETURN; | ||
| 441 | static void user_error (const char *msg) | ||
| 442 | { | ||
| 443 | xsignal1 (Quser_error, build_string (msg)); | ||
| 444 | } | ||
| 445 | |||
| 439 | 446 | ||
| 440 | DEFUN ("primitive-undo", Fprimitive_undo, Sprimitive_undo, 2, 2, 0, | 447 | DEFUN ("primitive-undo", Fprimitive_undo, Sprimitive_undo, 2, 2, 0, |
| 441 | doc: /* Undo N records from the front of the list LIST. | 448 | doc: /* Undo N records from the front of the list LIST. |
| @@ -528,7 +535,7 @@ Return what remains of the list. */) | |||
| 528 | end = Fcdr (cdr); | 535 | end = Fcdr (cdr); |
| 529 | 536 | ||
| 530 | if (XINT (beg) < BEGV || XINT (end) > ZV) | 537 | if (XINT (beg) < BEGV || XINT (end) > ZV) |
| 531 | error ("Changes to be undone are outside visible portion of buffer"); | 538 | user_error ("Changes to be undone are outside visible portion of buffer"); |
| 532 | Fput_text_property (beg, end, prop, val, Qnil); | 539 | Fput_text_property (beg, end, prop, val, Qnil); |
| 533 | } | 540 | } |
| 534 | else if (INTEGERP (car) && INTEGERP (cdr)) | 541 | else if (INTEGERP (car) && INTEGERP (cdr)) |
| @@ -537,7 +544,7 @@ Return what remains of the list. */) | |||
| 537 | 544 | ||
| 538 | if (XINT (car) < BEGV | 545 | if (XINT (car) < BEGV |
| 539 | || XINT (cdr) > ZV) | 546 | || XINT (cdr) > ZV) |
| 540 | error ("Changes to be undone are outside visible portion of buffer"); | 547 | user_error ("Changes to be undone are outside visible portion of buffer"); |
| 541 | /* Set point first thing, so that undoing this undo | 548 | /* Set point first thing, so that undoing this undo |
| 542 | does not send point back to where it is now. */ | 549 | does not send point back to where it is now. */ |
| 543 | Fgoto_char (car); | 550 | Fgoto_char (car); |
| @@ -588,14 +595,14 @@ Return what remains of the list. */) | |||
| 588 | if (pos < 0) | 595 | if (pos < 0) |
| 589 | { | 596 | { |
| 590 | if (-pos < BEGV || -pos > ZV) | 597 | if (-pos < BEGV || -pos > ZV) |
| 591 | error ("Changes to be undone are outside visible portion of buffer"); | 598 | user_error ("Changes to be undone are outside visible portion of buffer"); |
| 592 | SET_PT (-pos); | 599 | SET_PT (-pos); |
| 593 | Finsert (1, &membuf); | 600 | Finsert (1, &membuf); |
| 594 | } | 601 | } |
| 595 | else | 602 | else |
| 596 | { | 603 | { |
| 597 | if (pos < BEGV || pos > ZV) | 604 | if (pos < BEGV || pos > ZV) |
| 598 | error ("Changes to be undone are outside visible portion of buffer"); | 605 | user_error ("Changes to be undone are outside visible portion of buffer"); |
| 599 | SET_PT (pos); | 606 | SET_PT (pos); |
| 600 | 607 | ||
| 601 | /* Now that we record marker adjustments | 608 | /* Now that we record marker adjustments |
diff --git a/src/unexaix.c b/src/unexaix.c index 1bf65b68518..29fa0fd6287 100644 --- a/src/unexaix.c +++ b/src/unexaix.c | |||
| @@ -78,13 +78,13 @@ static long data_scnptr; | |||
| 78 | static long load_scnptr; | 78 | static long load_scnptr; |
| 79 | static long orig_load_scnptr; | 79 | static long orig_load_scnptr; |
| 80 | static long orig_data_scnptr; | 80 | static long orig_data_scnptr; |
| 81 | static int unrelocate_symbols (int, int, char *, char *); | 81 | static int unrelocate_symbols (int, int, const char *, const char *); |
| 82 | 82 | ||
| 83 | #ifndef MAX_SECTIONS | 83 | #ifndef MAX_SECTIONS |
| 84 | #define MAX_SECTIONS 10 | 84 | #define MAX_SECTIONS 10 |
| 85 | #endif | 85 | #endif |
| 86 | 86 | ||
| 87 | static int adjust_lnnoptrs (int, int, char *); | 87 | static int adjust_lnnoptrs (int, int, const char *); |
| 88 | 88 | ||
| 89 | static int pagemask; | 89 | static int pagemask; |
| 90 | 90 | ||
| @@ -92,7 +92,7 @@ static int pagemask; | |||
| 92 | #include "lisp.h" | 92 | #include "lisp.h" |
| 93 | 93 | ||
| 94 | static void | 94 | static void |
| 95 | report_error (char *file, int fd) | 95 | report_error (const char *file, int fd) |
| 96 | { | 96 | { |
| 97 | if (fd) | 97 | if (fd) |
| 98 | close (fd); | 98 | close (fd); |
| @@ -104,16 +104,16 @@ report_error (char *file, int fd) | |||
| 104 | #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 | 104 | #define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 |
| 105 | 105 | ||
| 106 | static void | 106 | static void |
| 107 | report_error_1 (int fd, char *msg, int a1, int a2) | 107 | report_error_1 (int fd, const char *msg, int a1, int a2) |
| 108 | { | 108 | { |
| 109 | close (fd); | 109 | close (fd); |
| 110 | error (msg, a1, a2); | 110 | error (msg, a1, a2); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | static int make_hdr (int, int, unsigned, unsigned, unsigned, char *, char *); | 113 | static int make_hdr (int, int, const char *, const char *); |
| 114 | static void mark_x (char *); | 114 | static void mark_x (const char *); |
| 115 | static int copy_text_and_data (int); | 115 | static int copy_text_and_data (int); |
| 116 | static int copy_sym (int, int, char *, char *); | 116 | static int copy_sym (int, int, const char *, const char *); |
| 117 | static void write_segment (int, char *, char *); | 117 | static void write_segment (int, char *, char *); |
| 118 | 118 | ||
| 119 | /* **************************************************************** | 119 | /* **************************************************************** |
| @@ -159,7 +159,7 @@ unexec (const char *new_name, const char *a_name) | |||
| 159 | */ | 159 | */ |
| 160 | static int | 160 | static int |
| 161 | make_hdr (int new, int a_out, | 161 | make_hdr (int new, int a_out, |
| 162 | char *a_name, char *new_name) | 162 | const char *a_name, const char *new_name) |
| 163 | { | 163 | { |
| 164 | int scns; | 164 | int scns; |
| 165 | unsigned int bss_start; | 165 | unsigned int bss_start; |
| @@ -429,7 +429,7 @@ write_segment (int new, char *ptr, char *end) | |||
| 429 | * Copy the relocation information and symbol table from the a.out to the new | 429 | * Copy the relocation information and symbol table from the a.out to the new |
| 430 | */ | 430 | */ |
| 431 | static int | 431 | static int |
| 432 | copy_sym (int new, int a_out, char *a_name, char *new_name) | 432 | copy_sym (int new, int a_out, const char *a_name, const char *new_name) |
| 433 | { | 433 | { |
| 434 | char page[UnexBlockSz]; | 434 | char page[UnexBlockSz]; |
| 435 | int n; | 435 | int n; |
| @@ -465,7 +465,7 @@ copy_sym (int new, int a_out, char *a_name, char *new_name) | |||
| 465 | * After successfully building the new a.out, mark it executable | 465 | * After successfully building the new a.out, mark it executable |
| 466 | */ | 466 | */ |
| 467 | static void | 467 | static void |
| 468 | mark_x (char *name) | 468 | mark_x (const char *name) |
| 469 | { | 469 | { |
| 470 | struct stat sbuf; | 470 | struct stat sbuf; |
| 471 | int um; | 471 | int um; |
| @@ -483,7 +483,7 @@ mark_x (char *name) | |||
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | static int | 485 | static int |
| 486 | adjust_lnnoptrs (int writedesc, int readdesc, char *new_name) | 486 | adjust_lnnoptrs (int writedesc, int readdesc, const char *new_name) |
| 487 | { | 487 | { |
| 488 | int nsyms; | 488 | int nsyms; |
| 489 | int naux; | 489 | int naux; |
| @@ -530,7 +530,8 @@ adjust_lnnoptrs (int writedesc, int readdesc, char *new_name) | |||
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | static int | 532 | static int |
| 533 | unrelocate_symbols (int new, int a_out, char *a_name, char *new_name) | 533 | unrelocate_symbols (int new, int a_out, |
| 534 | const char *a_name, const char *new_name) | ||
| 534 | { | 535 | { |
| 535 | int i; | 536 | int i; |
| 536 | LDHDR ldhdr; | 537 | LDHDR ldhdr; |
diff --git a/src/unexelf.c b/src/unexelf.c index ac9c9e75764..f35b53aeab3 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -506,11 +506,7 @@ typedef struct { | |||
| 506 | #endif | 506 | #endif |
| 507 | 507 | ||
| 508 | #ifndef ElfW | 508 | #ifndef ElfW |
| 509 | # ifdef __STDC__ | 509 | # define ElfBitsW(bits, type) Elf##bits##_##type |
| 510 | # define ElfBitsW(bits, type) Elf##bits##_##type | ||
| 511 | # else | ||
| 512 | # define ElfBitsW(bits, type) Elf/**/bits/**/_/**/type | ||
| 513 | # endif | ||
| 514 | # ifdef _LP64 | 510 | # ifdef _LP64 |
| 515 | # define ELFSIZE 64 | 511 | # define ELFSIZE 64 |
| 516 | # else | 512 | # else |
diff --git a/src/vm-limit.c b/src/vm-limit.c index 94725044048..c313a900f2c 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c | |||
| @@ -31,7 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 31 | enum warnlevel { not_warned, warned_75, warned_85, warned_95 }; | 31 | enum warnlevel { not_warned, warned_75, warned_85, warned_95 }; |
| 32 | static enum warnlevel warnlevel; | 32 | static enum warnlevel warnlevel; |
| 33 | 33 | ||
| 34 | typedef POINTER_TYPE *POINTER; | 34 | typedef void *POINTER; |
| 35 | 35 | ||
| 36 | /* Function to call to issue a warning; | 36 | /* Function to call to issue a warning; |
| 37 | 0 means don't issue them. */ | 37 | 0 means don't issue them. */ |
diff --git a/src/w32fns.c b/src/w32fns.c index 3a6929844de..d7114f19b90 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -4003,7 +4003,7 @@ unwind_create_frame (Lisp_Object frame) | |||
| 4003 | #if GLYPH_DEBUG | 4003 | #if GLYPH_DEBUG |
| 4004 | /* Check that reference counts are indeed correct. */ | 4004 | /* Check that reference counts are indeed correct. */ |
| 4005 | xassert (dpyinfo->reference_count == dpyinfo_refcount); | 4005 | xassert (dpyinfo->reference_count == dpyinfo_refcount); |
| 4006 | xassert (dpyinfo->image_cache->refcount == image_cache_refcount); | 4006 | xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount); |
| 4007 | #endif | 4007 | #endif |
| 4008 | return Qt; | 4008 | return Qt; |
| 4009 | } | 4009 | } |
| @@ -5016,16 +5016,6 @@ no value of TYPE (always string in the MS Windows case). */) | |||
| 5016 | cursor. Duplicated from xdisp.c, but cannot use the version there | 5016 | cursor. Duplicated from xdisp.c, but cannot use the version there |
| 5017 | due to lack of atimers on w32. */ | 5017 | due to lack of atimers on w32. */ |
| 5018 | #define DEFAULT_HOURGLASS_DELAY 1 | 5018 | #define DEFAULT_HOURGLASS_DELAY 1 |
| 5019 | /* Return non-zero if hourglass timer has been started or hourglass is | ||
| 5020 | shown. */ | ||
| 5021 | /* PENDING: if W32 can use atimers (atimer.[hc]) then the common impl in | ||
| 5022 | xdisp.c could be used. */ | ||
| 5023 | |||
| 5024 | int | ||
| 5025 | hourglass_started (void) | ||
| 5026 | { | ||
| 5027 | return hourglass_shown_p || hourglass_timer; | ||
| 5028 | } | ||
| 5029 | 5019 | ||
| 5030 | /* Cancel a currently active hourglass timer, and start a new one. */ | 5020 | /* Cancel a currently active hourglass timer, and start a new one. */ |
| 5031 | 5021 | ||
| @@ -5246,7 +5236,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, | |||
| 5246 | 5236 | ||
| 5247 | #if GLYPH_DEBUG | 5237 | #if GLYPH_DEBUG |
| 5248 | image_cache_refcount = | 5238 | image_cache_refcount = |
| 5249 | FRAME_IMAGE_CACHE ? FRAME_IMAGE_CACHE (f)->refcount : 0; | 5239 | FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; |
| 5250 | dpyinfo_refcount = dpyinfo->reference_count; | 5240 | dpyinfo_refcount = dpyinfo->reference_count; |
| 5251 | #endif /* GLYPH_DEBUG */ | 5241 | #endif /* GLYPH_DEBUG */ |
| 5252 | FRAME_KBOARD (f) = kb; | 5242 | FRAME_KBOARD (f) = kb; |
diff --git a/src/w32font.c b/src/w32font.c index dab9f4c61b4..8badace9635 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -2045,8 +2045,11 @@ fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec) | |||
| 2045 | /* Font families are interned, but allow for strings also in case of | 2045 | /* Font families are interned, but allow for strings also in case of |
| 2046 | user input. */ | 2046 | user input. */ |
| 2047 | else if (SYMBOLP (tmp)) | 2047 | else if (SYMBOLP (tmp)) |
| 2048 | strncpy (logfont->lfFaceName, | 2048 | { |
| 2049 | SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE); | 2049 | strncpy (logfont->lfFaceName, |
| 2050 | SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE); | ||
| 2051 | logfont->lfFaceName[LF_FACESIZE-1] = '\0'; | ||
| 2052 | } | ||
| 2050 | } | 2053 | } |
| 2051 | 2054 | ||
| 2052 | tmp = AREF (font_spec, FONT_ADSTYLE_INDEX); | 2055 | tmp = AREF (font_spec, FONT_ADSTYLE_INDEX); |
diff --git a/src/w32menu.c b/src/w32menu.c index dd741a01b5b..2bc4c208956 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -48,6 +48,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 48 | 48 | ||
| 49 | #include "dispextern.h" | 49 | #include "dispextern.h" |
| 50 | 50 | ||
| 51 | #include "w32heap.h" /* for osinfo_cache */ | ||
| 52 | |||
| 51 | #undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ | 53 | #undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ |
| 52 | 54 | ||
| 53 | #ifndef TRUE | 55 | #ifndef TRUE |
| @@ -1498,8 +1500,11 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 1498 | AppendMenu (menu, fuFlags, | 1500 | AppendMenu (menu, fuFlags, |
| 1499 | item != NULL ? (UINT) item: (UINT) wv->call_data, | 1501 | item != NULL ? (UINT) item: (UINT) wv->call_data, |
| 1500 | out_string); | 1502 | out_string); |
| 1501 | /* Don't use Unicode menus in future. */ | 1503 | /* Don't use Unicode menus in future, unless this is Windows |
| 1502 | unicode_append_menu = NULL; | 1504 | NT or later, where a failure of AppendMenuW does NOT mean |
| 1505 | Unicode menus are unsupported. */ | ||
| 1506 | if (osinfo_cache.dwPlatformId != VER_PLATFORM_WIN32_NT) | ||
| 1507 | unicode_append_menu = NULL; | ||
| 1503 | } | 1508 | } |
| 1504 | 1509 | ||
| 1505 | if (unicode_append_menu && (fuFlags & MF_OWNERDRAW)) | 1510 | if (unicode_append_menu && (fuFlags & MF_OWNERDRAW)) |
diff --git a/src/w32proc.c b/src/w32proc.c index 28591f90128..5bdeba25958 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -141,7 +141,25 @@ new_child (void) | |||
| 141 | cp->char_consumed = CreateEvent (NULL, FALSE, FALSE, NULL); | 141 | cp->char_consumed = CreateEvent (NULL, FALSE, FALSE, NULL); |
| 142 | if (cp->char_consumed) | 142 | if (cp->char_consumed) |
| 143 | { | 143 | { |
| 144 | cp->thrd = CreateThread (NULL, 1024, reader_thread, cp, 0, &id); | 144 | /* The 0x00010000 flag is STACK_SIZE_PARAM_IS_A_RESERVATION. |
| 145 | It means that the 64K stack we are requesting in the 2nd | ||
| 146 | argument is how much memory should be reserved for the | ||
| 147 | stack. If we don't use this flag, the memory requested | ||
| 148 | by the 2nd argument is the amount actually _committed_, | ||
| 149 | but Windows reserves 8MB of memory for each thread's | ||
| 150 | stack. (The 8MB figure comes from the -stack | ||
| 151 | command-line argument we pass to the linker when building | ||
| 152 | Emacs, but that's because we need a large stack for | ||
| 153 | Emacs's main thread.) Since we request 2GB of reserved | ||
| 154 | memory at startup (see w32heap.c), which is close to the | ||
| 155 | maximum memory available for a 32-bit process on Windows, | ||
| 156 | the 8MB reservation for each thread causes failures in | ||
| 157 | starting subprocesses, because we create a thread running | ||
| 158 | reader_thread for each subprocess. As 8MB of stack is | ||
| 159 | way too much for reader_thread, forcing Windows to | ||
| 160 | reserve less wins the day. */ | ||
| 161 | cp->thrd = CreateThread (NULL, 64 * 1024, reader_thread, cp, | ||
| 162 | 0x00010000, &id); | ||
| 145 | if (cp->thrd) | 163 | if (cp->thrd) |
| 146 | return cp; | 164 | return cp; |
| 147 | } | 165 | } |
diff --git a/src/w32term.c b/src/w32term.c index 18a3753f9e9..2ccd7574332 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -231,6 +231,10 @@ static void my_set_focus (struct frame *, HWND); | |||
| 231 | static void my_set_foreground_window (HWND); | 231 | static void my_set_foreground_window (HWND); |
| 232 | static void my_destroy_window (struct frame *, HWND); | 232 | static void my_destroy_window (struct frame *, HWND); |
| 233 | 233 | ||
| 234 | #if GLYPH_DEBUG | ||
| 235 | static void x_check_font (struct frame *, struct font *); | ||
| 236 | #endif | ||
| 237 | |||
| 234 | static Lisp_Object Qvendor_specific_keysyms; | 238 | static Lisp_Object Qvendor_specific_keysyms; |
| 235 | 239 | ||
| 236 | 240 | ||
| @@ -5906,6 +5910,27 @@ x_wm_set_icon_position (struct frame *f, int icon_x, int icon_y) | |||
| 5906 | 5910 | ||
| 5907 | 5911 | ||
| 5908 | /*********************************************************************** | 5912 | /*********************************************************************** |
| 5913 | Fonts | ||
| 5914 | ***********************************************************************/ | ||
| 5915 | |||
| 5916 | #if GLYPH_DEBUG | ||
| 5917 | |||
| 5918 | /* Check that FONT is valid on frame F. It is if it can be found in F's | ||
| 5919 | font table. */ | ||
| 5920 | |||
| 5921 | static void | ||
| 5922 | x_check_font (struct frame *f, struct font *font) | ||
| 5923 | { | ||
| 5924 | xassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX])); | ||
| 5925 | if (font->driver->check) | ||
| 5926 | xassert (font->driver->check (f, font) == 0); | ||
| 5927 | } | ||
| 5928 | |||
| 5929 | #endif /* GLYPH_DEBUG != 0 */ | ||
| 5930 | |||
| 5931 | |||
| 5932 | |||
| 5933 | /*********************************************************************** | ||
| 5909 | Initialization | 5934 | Initialization |
| 5910 | ***********************************************************************/ | 5935 | ***********************************************************************/ |
| 5911 | 5936 | ||
diff --git a/src/window.c b/src/window.c index 19f27ec5320..37bcf64181a 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -4223,6 +4223,11 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4223 | void *itdata = NULL; | 4223 | void *itdata = NULL; |
| 4224 | 4224 | ||
| 4225 | SET_TEXT_POS_FROM_MARKER (start, w->start); | 4225 | SET_TEXT_POS_FROM_MARKER (start, w->start); |
| 4226 | /* Scrolling a minibuffer window via scroll bar when the echo area | ||
| 4227 | shows long text sometimes resets the minibuffer contents behind | ||
| 4228 | our backs. */ | ||
| 4229 | if (CHARPOS (start) > ZV) | ||
| 4230 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); | ||
| 4226 | 4231 | ||
| 4227 | /* If PT is not visible in WINDOW, move back one half of | 4232 | /* If PT is not visible in WINDOW, move back one half of |
| 4228 | the screen. Allow PT to be partially visible, otherwise | 4233 | the screen. Allow PT to be partially visible, otherwise |
diff --git a/src/window.h b/src/window.h index ea127ca95a8..1524805579f 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -852,11 +852,6 @@ extern EMACS_INT minibuf_level; | |||
| 852 | 852 | ||
| 853 | extern int update_mode_lines; | 853 | extern int update_mode_lines; |
| 854 | 854 | ||
| 855 | /* Nonzero if BEGV - BEG or Z - ZV of current buffer has changed since | ||
| 856 | last redisplay that finished. */ | ||
| 857 | |||
| 858 | extern int clip_changed; | ||
| 859 | |||
| 860 | /* Nonzero if window sizes or contents have changed since last | 855 | /* Nonzero if window sizes or contents have changed since last |
| 861 | redisplay that finished */ | 856 | redisplay that finished */ |
| 862 | 857 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index 43b92bcf536..0a25eab1cbc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -383,11 +383,21 @@ static Lisp_Object Qline_height; | |||
| 383 | #define IT_OVERFLOW_NEWLINE_INTO_FRINGE(it) 0 | 383 | #define IT_OVERFLOW_NEWLINE_INTO_FRINGE(it) 0 |
| 384 | #endif /* HAVE_WINDOW_SYSTEM */ | 384 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 385 | 385 | ||
| 386 | /* Test if the display element loaded in IT is a space or tab | 386 | /* Test if the display element loaded in IT, or the underlying buffer |
| 387 | character. This is used to determine word wrapping. */ | 387 | or string character, is a space or a TAB character. This is used |
| 388 | 388 | to determine where word wrapping can occur. */ | |
| 389 | #define IT_DISPLAYING_WHITESPACE(it) \ | 389 | |
| 390 | (it->what == IT_CHARACTER && (it->c == ' ' || it->c == '\t')) | 390 | #define IT_DISPLAYING_WHITESPACE(it) \ |
| 391 | ((it->what == IT_CHARACTER && (it->c == ' ' || it->c == '\t')) \ | ||
| 392 | || ((STRINGP (it->string) \ | ||
| 393 | && (SREF (it->string, IT_STRING_BYTEPOS (*it)) == ' ' \ | ||
| 394 | || SREF (it->string, IT_STRING_BYTEPOS (*it)) == '\t')) \ | ||
| 395 | || (it->s \ | ||
| 396 | && (it->s[IT_BYTEPOS (*it)] == ' ' \ | ||
| 397 | || it->s[IT_BYTEPOS (*it)] == '\t')) \ | ||
| 398 | || (IT_BYTEPOS (*it) < ZV_BYTE \ | ||
| 399 | && (*BYTE_POS_ADDR (IT_BYTEPOS (*it)) == ' ' \ | ||
| 400 | || *BYTE_POS_ADDR (IT_BYTEPOS (*it)) == '\t')))) \ | ||
| 391 | 401 | ||
| 392 | /* Name of the face used to highlight trailing whitespace. */ | 402 | /* Name of the face used to highlight trailing whitespace. */ |
| 393 | 403 | ||
| @@ -839,6 +849,7 @@ static int try_cursor_movement (Lisp_Object, struct text_pos, int *); | |||
| 839 | static int trailing_whitespace_p (ptrdiff_t); | 849 | static int trailing_whitespace_p (ptrdiff_t); |
| 840 | static intmax_t message_log_check_duplicate (ptrdiff_t, ptrdiff_t); | 850 | static intmax_t message_log_check_duplicate (ptrdiff_t, ptrdiff_t); |
| 841 | static void push_it (struct it *, struct text_pos *); | 851 | static void push_it (struct it *, struct text_pos *); |
| 852 | static void iterate_out_of_display_property (struct it *); | ||
| 842 | static void pop_it (struct it *); | 853 | static void pop_it (struct it *); |
| 843 | static void sync_frame_with_window_matrix_rows (struct window *); | 854 | static void sync_frame_with_window_matrix_rows (struct window *); |
| 844 | static void select_frame_for_redisplay (Lisp_Object); | 855 | static void select_frame_for_redisplay (Lisp_Object); |
| @@ -1265,6 +1276,11 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1265 | } | 1276 | } |
| 1266 | 1277 | ||
| 1267 | SET_TEXT_POS_FROM_MARKER (top, w->start); | 1278 | SET_TEXT_POS_FROM_MARKER (top, w->start); |
| 1279 | /* Scrolling a minibuffer window via scroll bar when the echo area | ||
| 1280 | shows long text sometimes resets the minibuffer contents behind | ||
| 1281 | our backs. */ | ||
| 1282 | if (CHARPOS (top) > ZV) | ||
| 1283 | SET_TEXT_POS (top, BEGV, BEGV_BYTE); | ||
| 1268 | 1284 | ||
| 1269 | /* Compute exact mode line heights. */ | 1285 | /* Compute exact mode line heights. */ |
| 1270 | if (WINDOW_WANTS_MODELINE_P (w)) | 1286 | if (WINDOW_WANTS_MODELINE_P (w)) |
| @@ -1298,8 +1314,8 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1298 | glyph. */ | 1314 | glyph. */ |
| 1299 | int top_x = it.current_x; | 1315 | int top_x = it.current_x; |
| 1300 | int top_y = it.current_y; | 1316 | int top_y = it.current_y; |
| 1301 | enum it_method it_method = it.method; | ||
| 1302 | /* Calling line_bottom_y may change it.method, it.position, etc. */ | 1317 | /* Calling line_bottom_y may change it.method, it.position, etc. */ |
| 1318 | enum it_method it_method = it.method; | ||
| 1303 | int bottom_y = (last_height = 0, line_bottom_y (&it)); | 1319 | int bottom_y = (last_height = 0, line_bottom_y (&it)); |
| 1304 | int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w); | 1320 | int window_top_y = WINDOW_HEADER_LINE_HEIGHT (w); |
| 1305 | 1321 | ||
| @@ -1307,6 +1323,31 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1307 | visible_p = bottom_y > window_top_y; | 1323 | visible_p = bottom_y > window_top_y; |
| 1308 | else if (top_y < it.last_visible_y) | 1324 | else if (top_y < it.last_visible_y) |
| 1309 | visible_p = 1; | 1325 | visible_p = 1; |
| 1326 | if (bottom_y >= it.last_visible_y | ||
| 1327 | && it.bidi_p && it.bidi_it.scan_dir == -1 | ||
| 1328 | && IT_CHARPOS (it) < charpos) | ||
| 1329 | { | ||
| 1330 | /* When the last line of the window is scanned backwards | ||
| 1331 | under bidi iteration, we could be duped into thinking | ||
| 1332 | that we have passed CHARPOS, when in fact move_it_to | ||
| 1333 | simply stopped short of CHARPOS because it reached | ||
| 1334 | last_visible_y. To see if that's what happened, we call | ||
| 1335 | move_it_to again with a slightly larger vertical limit, | ||
| 1336 | and see if it actually moved vertically; if it did, we | ||
| 1337 | didn't really reach CHARPOS, which is beyond window end. */ | ||
| 1338 | struct it save_it = it; | ||
| 1339 | /* Why 10? because we don't know how many canonical lines | ||
| 1340 | will the height of the next line(s) be. So we guess. */ | ||
| 1341 | int ten_more_lines = | ||
| 1342 | 10 * FRAME_LINE_HEIGHT (XFRAME (WINDOW_FRAME (w))); | ||
| 1343 | |||
| 1344 | move_it_to (&it, charpos, -1, bottom_y + ten_more_lines, -1, | ||
| 1345 | MOVE_TO_POS | MOVE_TO_Y); | ||
| 1346 | if (it.current_y > top_y) | ||
| 1347 | visible_p = 0; | ||
| 1348 | |||
| 1349 | it = save_it; | ||
| 1350 | } | ||
| 1310 | if (visible_p) | 1351 | if (visible_p) |
| 1311 | { | 1352 | { |
| 1312 | if (it_method == GET_FROM_DISPLAY_VECTOR) | 1353 | if (it_method == GET_FROM_DISPLAY_VECTOR) |
| @@ -1370,6 +1411,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1370 | Lisp_Object startpos, endpos; | 1411 | Lisp_Object startpos, endpos; |
| 1371 | EMACS_INT start, end; | 1412 | EMACS_INT start, end; |
| 1372 | struct it it3; | 1413 | struct it it3; |
| 1414 | int it3_moved; | ||
| 1373 | 1415 | ||
| 1374 | /* Find the first and the last buffer positions | 1416 | /* Find the first and the last buffer positions |
| 1375 | covered by the display string. */ | 1417 | covered by the display string. */ |
| @@ -1426,6 +1468,15 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1426 | begins. */ | 1468 | begins. */ |
| 1427 | start_display (&it3, w, top); | 1469 | start_display (&it3, w, top); |
| 1428 | move_it_to (&it3, -1, 0, top_y, -1, MOVE_TO_X | MOVE_TO_Y); | 1470 | move_it_to (&it3, -1, 0, top_y, -1, MOVE_TO_X | MOVE_TO_Y); |
| 1471 | /* If it3_moved stays zero after the 'while' loop | ||
| 1472 | below, that means we already were at a newline | ||
| 1473 | before the loop (e.g., the display string begins | ||
| 1474 | with a newline), so we don't need to (and cannot) | ||
| 1475 | inspect the glyphs of it3.glyph_row, because | ||
| 1476 | PRODUCE_GLYPHS will not produce anything for a | ||
| 1477 | newline, and thus it3.glyph_row stays at its | ||
| 1478 | stale content it got at top of the window. */ | ||
| 1479 | it3_moved = 0; | ||
| 1429 | /* Finally, advance the iterator until we hit the | 1480 | /* Finally, advance the iterator until we hit the |
| 1430 | first display element whose character position is | 1481 | first display element whose character position is |
| 1431 | CHARPOS, or until the first newline from the | 1482 | CHARPOS, or until the first newline from the |
| @@ -1437,6 +1488,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1437 | if (IT_CHARPOS (it3) == charpos | 1488 | if (IT_CHARPOS (it3) == charpos |
| 1438 | || ITERATOR_AT_END_OF_LINE_P (&it3)) | 1489 | || ITERATOR_AT_END_OF_LINE_P (&it3)) |
| 1439 | break; | 1490 | break; |
| 1491 | it3_moved = 1; | ||
| 1440 | set_iterator_to_next (&it3, 0); | 1492 | set_iterator_to_next (&it3, 0); |
| 1441 | } | 1493 | } |
| 1442 | top_x = it3.current_x - it3.pixel_width; | 1494 | top_x = it3.current_x - it3.pixel_width; |
| @@ -1447,7 +1499,8 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1447 | display string, move back over the glyphs | 1499 | display string, move back over the glyphs |
| 1448 | produced from the string, until we find the | 1500 | produced from the string, until we find the |
| 1449 | rightmost glyph not from the string. */ | 1501 | rightmost glyph not from the string. */ |
| 1450 | if (IT_CHARPOS (it3) != charpos && EQ (it3.object, string)) | 1502 | if (it3_moved |
| 1503 | && IT_CHARPOS (it3) != charpos && EQ (it3.object, string)) | ||
| 1451 | { | 1504 | { |
| 1452 | struct glyph *g = it3.glyph_row->glyphs[TEXT_AREA] | 1505 | struct glyph *g = it3.glyph_row->glyphs[TEXT_AREA] |
| 1453 | + it3.glyph_row->used[TEXT_AREA]; | 1506 | + it3.glyph_row->used[TEXT_AREA]; |
| @@ -3111,7 +3164,15 @@ handle_stop (struct it *it) | |||
| 3111 | overlays even if the actual buffer text is replaced. */ | 3164 | overlays even if the actual buffer text is replaced. */ |
| 3112 | if (!handle_overlay_change_p | 3165 | if (!handle_overlay_change_p |
| 3113 | || it->sp > 1 | 3166 | || it->sp > 1 |
| 3114 | || !get_overlay_strings_1 (it, 0, 0)) | 3167 | /* Don't call get_overlay_strings_1 if we already |
| 3168 | have overlay strings loaded, because doing so | ||
| 3169 | will load them again and push the iterator state | ||
| 3170 | onto the stack one more time, which is not | ||
| 3171 | expected by the rest of the code that processes | ||
| 3172 | overlay strings. */ | ||
| 3173 | || (it->n_overlay_strings <= 0 | ||
| 3174 | ? !get_overlay_strings_1 (it, 0, 0) | ||
| 3175 | : 0)) | ||
| 3115 | { | 3176 | { |
| 3116 | if (it->ellipsis_p) | 3177 | if (it->ellipsis_p) |
| 3117 | setup_for_ellipsis (it, 0); | 3178 | setup_for_ellipsis (it, 0); |
| @@ -4667,10 +4728,22 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4667 | if (!FRAME_WINDOW_P (it->f)) | 4728 | if (!FRAME_WINDOW_P (it->f)) |
| 4668 | /* If we return here, POSITION has been advanced | 4729 | /* If we return here, POSITION has been advanced |
| 4669 | across the text with this property. */ | 4730 | across the text with this property. */ |
| 4670 | return 0; | 4731 | { |
| 4732 | /* Synchronize the bidi iterator with POSITION. This is | ||
| 4733 | needed because we are not going to push the iterator | ||
| 4734 | on behalf of this display property, so there will be | ||
| 4735 | no pop_it call to do this synchronization for us. */ | ||
| 4736 | if (it->bidi_p) | ||
| 4737 | { | ||
| 4738 | it->position = *position; | ||
| 4739 | iterate_out_of_display_property (it); | ||
| 4740 | *position = it->position; | ||
| 4741 | } | ||
| 4742 | return 1; | ||
| 4743 | } | ||
| 4671 | } | 4744 | } |
| 4672 | else if (!frame_window_p) | 4745 | else if (!frame_window_p) |
| 4673 | return 0; | 4746 | return 1; |
| 4674 | 4747 | ||
| 4675 | #ifdef HAVE_WINDOW_SYSTEM | 4748 | #ifdef HAVE_WINDOW_SYSTEM |
| 4676 | value = XCAR (XCDR (spec)); | 4749 | value = XCAR (XCDR (spec)); |
| @@ -4678,7 +4751,15 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, | |||
| 4678 | || !(fringe_bitmap = lookup_fringe_bitmap (value))) | 4751 | || !(fringe_bitmap = lookup_fringe_bitmap (value))) |
| 4679 | /* If we return here, POSITION has been advanced | 4752 | /* If we return here, POSITION has been advanced |
| 4680 | across the text with this property. */ | 4753 | across the text with this property. */ |
| 4681 | return 0; | 4754 | { |
| 4755 | if (it && it->bidi_p) | ||
| 4756 | { | ||
| 4757 | it->position = *position; | ||
| 4758 | iterate_out_of_display_property (it); | ||
| 4759 | *position = it->position; | ||
| 4760 | } | ||
| 4761 | return 1; | ||
| 4762 | } | ||
| 4682 | 4763 | ||
| 4683 | if (it) | 4764 | if (it) |
| 4684 | { | 4765 | { |
| @@ -5602,7 +5683,7 @@ push_it (struct it *it, struct text_pos *position) | |||
| 5602 | static void | 5683 | static void |
| 5603 | iterate_out_of_display_property (struct it *it) | 5684 | iterate_out_of_display_property (struct it *it) |
| 5604 | { | 5685 | { |
| 5605 | int buffer_p = BUFFERP (it->object); | 5686 | int buffer_p = !STRINGP (it->string); |
| 5606 | ptrdiff_t eob = (buffer_p ? ZV : it->end_charpos); | 5687 | ptrdiff_t eob = (buffer_p ? ZV : it->end_charpos); |
| 5607 | ptrdiff_t bob = (buffer_p ? BEGV : 0); | 5688 | ptrdiff_t bob = (buffer_p ? BEGV : 0); |
| 5608 | 5689 | ||
| @@ -6769,6 +6850,16 @@ get_next_display_element (struct it *it) | |||
| 6769 | && FACE_FROM_ID (it->f, face_id)->box == FACE_NO_BOX); | 6850 | && FACE_FROM_ID (it->f, face_id)->box == FACE_NO_BOX); |
| 6770 | } | 6851 | } |
| 6771 | } | 6852 | } |
| 6853 | /* If we reached the end of the object we've been iterating (e.g., a | ||
| 6854 | display string or an overlay string), and there's something on | ||
| 6855 | IT->stack, proceed with what's on the stack. It doesn't make | ||
| 6856 | sense to return zero if there's unprocessed stuff on the stack, | ||
| 6857 | because otherwise that stuff will never be displayed. */ | ||
| 6858 | if (!success_p && it->sp > 0) | ||
| 6859 | { | ||
| 6860 | set_iterator_to_next (it, 0); | ||
| 6861 | success_p = get_next_display_element (it); | ||
| 6862 | } | ||
| 6772 | 6863 | ||
| 6773 | /* Value is 0 if end of buffer or string reached. */ | 6864 | /* Value is 0 if end of buffer or string reached. */ |
| 6774 | return success_p; | 6865 | return success_p; |
| @@ -6950,7 +7041,7 @@ set_iterator_to_next (struct it *it, int reseat_p) | |||
| 6950 | display vector entry (these entries may contain faces). */ | 7041 | display vector entry (these entries may contain faces). */ |
| 6951 | it->face_id = it->saved_face_id; | 7042 | it->face_id = it->saved_face_id; |
| 6952 | 7043 | ||
| 6953 | if (it->dpvec + it->current.dpvec_index == it->dpend) | 7044 | if (it->dpvec + it->current.dpvec_index >= it->dpend) |
| 6954 | { | 7045 | { |
| 6955 | int recheck_faces = it->ellipsis_p; | 7046 | int recheck_faces = it->ellipsis_p; |
| 6956 | 7047 | ||
| @@ -6988,6 +7079,26 @@ set_iterator_to_next (struct it *it, int reseat_p) | |||
| 6988 | case GET_FROM_STRING: | 7079 | case GET_FROM_STRING: |
| 6989 | /* Current display element is a character from a Lisp string. */ | 7080 | /* Current display element is a character from a Lisp string. */ |
| 6990 | xassert (it->s == NULL && STRINGP (it->string)); | 7081 | xassert (it->s == NULL && STRINGP (it->string)); |
| 7082 | /* Don't advance past string end. These conditions are true | ||
| 7083 | when set_iterator_to_next is called at the end of | ||
| 7084 | get_next_display_element, in which case the Lisp string is | ||
| 7085 | already exhausted, and all we want is pop the iterator | ||
| 7086 | stack. */ | ||
| 7087 | if (it->current.overlay_string_index >= 0) | ||
| 7088 | { | ||
| 7089 | /* This is an overlay string, so there's no padding with | ||
| 7090 | spaces, and the number of characters in the string is | ||
| 7091 | where the string ends. */ | ||
| 7092 | if (IT_STRING_CHARPOS (*it) >= SCHARS (it->string)) | ||
| 7093 | goto consider_string_end; | ||
| 7094 | } | ||
| 7095 | else | ||
| 7096 | { | ||
| 7097 | /* Not an overlay string. There could be padding, so test | ||
| 7098 | against it->end_charpos . */ | ||
| 7099 | if (IT_STRING_CHARPOS (*it) >= it->end_charpos) | ||
| 7100 | goto consider_string_end; | ||
| 7101 | } | ||
| 6991 | if (it->cmp_it.id >= 0) | 7102 | if (it->cmp_it.id >= 0) |
| 6992 | { | 7103 | { |
| 6993 | int i; | 7104 | int i; |
| @@ -12707,6 +12818,9 @@ redisplay_internal (void) | |||
| 12707 | frames. Zero means, only selected_window is considered. */ | 12818 | frames. Zero means, only selected_window is considered. */ |
| 12708 | int consider_all_windows_p; | 12819 | int consider_all_windows_p; |
| 12709 | 12820 | ||
| 12821 | /* Non-zero means redisplay has to redisplay the miniwindow */ | ||
| 12822 | int update_miniwindow_p = 0; | ||
| 12823 | |||
| 12710 | TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); | 12824 | TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); |
| 12711 | 12825 | ||
| 12712 | /* No redisplay if running in batch mode or frame is not yet fully | 12826 | /* No redisplay if running in batch mode or frame is not yet fully |
| @@ -12893,6 +13007,10 @@ redisplay_internal (void) | |||
| 12893 | && !MINI_WINDOW_P (XWINDOW (selected_window)))) | 13007 | && !MINI_WINDOW_P (XWINDOW (selected_window)))) |
| 12894 | { | 13008 | { |
| 12895 | int window_height_changed_p = echo_area_display (0); | 13009 | int window_height_changed_p = echo_area_display (0); |
| 13010 | |||
| 13011 | if (message_cleared_p) | ||
| 13012 | update_miniwindow_p = 1; | ||
| 13013 | |||
| 12896 | must_finish = 1; | 13014 | must_finish = 1; |
| 12897 | 13015 | ||
| 12898 | /* If we don't display the current message, don't clear the | 13016 | /* If we don't display the current message, don't clear the |
| @@ -12929,7 +13047,7 @@ redisplay_internal (void) | |||
| 12929 | /* FIXME: this causes all frames to be updated, which seems unnecessary | 13047 | /* FIXME: this causes all frames to be updated, which seems unnecessary |
| 12930 | since only the current frame needs to be considered. This function needs | 13048 | since only the current frame needs to be considered. This function needs |
| 12931 | to be rewritten with two variables, consider_all_windows and | 13049 | to be rewritten with two variables, consider_all_windows and |
| 12932 | consider_all_frames. */ | 13050 | consider_all_frames. */ |
| 12933 | consider_all_windows_p = 1; | 13051 | consider_all_windows_p = 1; |
| 12934 | ++windows_or_buffers_changed; | 13052 | ++windows_or_buffers_changed; |
| 12935 | ++update_mode_lines; | 13053 | ++update_mode_lines; |
| @@ -13115,7 +13233,8 @@ redisplay_internal (void) | |||
| 13115 | then we can't just move the cursor. */ | 13233 | then we can't just move the cursor. */ |
| 13116 | else if (! (!NILP (Vtransient_mark_mode) | 13234 | else if (! (!NILP (Vtransient_mark_mode) |
| 13117 | && !NILP (BVAR (current_buffer, mark_active))) | 13235 | && !NILP (BVAR (current_buffer, mark_active))) |
| 13118 | && (EQ (selected_window, BVAR (current_buffer, last_selected_window)) | 13236 | && (EQ (selected_window, |
| 13237 | BVAR (current_buffer, last_selected_window)) | ||
| 13119 | || highlight_nonselected_windows) | 13238 | || highlight_nonselected_windows) |
| 13120 | && NILP (w->region_showing) | 13239 | && NILP (w->region_showing) |
| 13121 | && NILP (Vshow_trailing_whitespace) | 13240 | && NILP (Vshow_trailing_whitespace) |
| @@ -13268,7 +13387,7 @@ redisplay_internal (void) | |||
| 13268 | } | 13387 | } |
| 13269 | else if (FRAME_VISIBLE_P (sf) && !FRAME_OBSCURED_P (sf)) | 13388 | else if (FRAME_VISIBLE_P (sf) && !FRAME_OBSCURED_P (sf)) |
| 13270 | { | 13389 | { |
| 13271 | Lisp_Object mini_window; | 13390 | Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf); |
| 13272 | struct frame *mini_frame; | 13391 | struct frame *mini_frame; |
| 13273 | 13392 | ||
| 13274 | displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer); | 13393 | displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer); |
| @@ -13277,6 +13396,10 @@ redisplay_internal (void) | |||
| 13277 | internal_condition_case_1 (redisplay_window_1, selected_window, | 13396 | internal_condition_case_1 (redisplay_window_1, selected_window, |
| 13278 | list_of_error, | 13397 | list_of_error, |
| 13279 | redisplay_window_error); | 13398 | redisplay_window_error); |
| 13399 | if (update_miniwindow_p) | ||
| 13400 | internal_condition_case_1 (redisplay_window_1, mini_window, | ||
| 13401 | list_of_error, | ||
| 13402 | redisplay_window_error); | ||
| 13280 | 13403 | ||
| 13281 | /* Compare desired and current matrices, perform output. */ | 13404 | /* Compare desired and current matrices, perform output. */ |
| 13282 | 13405 | ||
| @@ -28850,14 +28973,6 @@ init_xdisp (void) | |||
| 28850 | 28973 | ||
| 28851 | /* Platform-independent portion of hourglass implementation. */ | 28974 | /* Platform-independent portion of hourglass implementation. */ |
| 28852 | 28975 | ||
| 28853 | /* Return non-zero if hourglass timer has been started or hourglass is | ||
| 28854 | shown. */ | ||
| 28855 | int | ||
| 28856 | hourglass_started (void) | ||
| 28857 | { | ||
| 28858 | return hourglass_shown_p || hourglass_atimer != NULL; | ||
| 28859 | } | ||
| 28860 | |||
| 28861 | /* Cancel a currently active hourglass timer, and start a new one. */ | 28976 | /* Cancel a currently active hourglass timer, and start a new one. */ |
| 28862 | void | 28977 | void |
| 28863 | start_hourglass (void) | 28978 | start_hourglass (void) |
diff --git a/src/xfns.c b/src/xfns.c index 2d2ab46fb36..767507805fb 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -136,7 +136,7 @@ char *gray_bitmap_bits = gray_bits; | |||
| 136 | 136 | ||
| 137 | /* Nonzero if using X. */ | 137 | /* Nonzero if using X. */ |
| 138 | 138 | ||
| 139 | static int x_in_use; | 139 | int x_in_use; |
| 140 | 140 | ||
| 141 | static Lisp_Object Qnone; | 141 | static Lisp_Object Qnone; |
| 142 | static Lisp_Object Qsuppress_icon; | 142 | static Lisp_Object Qsuppress_icon; |
| @@ -2439,7 +2439,6 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) | |||
| 2439 | 2439 | ||
| 2440 | /* Do some needed geometry management. */ | 2440 | /* Do some needed geometry management. */ |
| 2441 | { | 2441 | { |
| 2442 | ptrdiff_t len; | ||
| 2443 | char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)]; | 2442 | char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)]; |
| 2444 | Arg gal[10]; | 2443 | Arg gal[10]; |
| 2445 | int gac = 0; | 2444 | int gac = 0; |
| @@ -2508,13 +2507,11 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only) | |||
| 2508 | } | 2507 | } |
| 2509 | } | 2508 | } |
| 2510 | 2509 | ||
| 2511 | len = strlen (shell_position) + 1; | ||
| 2512 | /* We don't free this because we don't know whether | 2510 | /* We don't free this because we don't know whether |
| 2513 | it is safe to free it while the frame exists. | 2511 | it is safe to free it while the frame exists. |
| 2514 | It isn't worth the trouble of arranging to free it | 2512 | It isn't worth the trouble of arranging to free it |
| 2515 | when the frame is deleted. */ | 2513 | when the frame is deleted. */ |
| 2516 | tem = (char *) xmalloc (len); | 2514 | tem = (char *) xstrdup (shell_position); |
| 2517 | strncpy (tem, shell_position, len); | ||
| 2518 | XtSetArg (gal[gac], XtNgeometry, tem); gac++; | 2515 | XtSetArg (gal[gac], XtNgeometry, tem); gac++; |
| 2519 | XtSetValues (shell_widget, gal, gac); | 2516 | XtSetValues (shell_widget, gal, gac); |
| 2520 | } | 2517 | } |
diff --git a/src/xgselect.c b/src/xgselect.c index 80dbfc32aee..9d6a3ba774a 100644 --- a/src/xgselect.c +++ b/src/xgselect.c | |||
| @@ -27,28 +27,33 @@ along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */ | |||
| 27 | #include <glib.h> | 27 | #include <glib.h> |
| 28 | #include <errno.h> | 28 | #include <errno.h> |
| 29 | #include <setjmp.h> | 29 | #include <setjmp.h> |
| 30 | #include "xterm.h" | ||
| 30 | 31 | ||
| 31 | static GPollFD *gfds; | 32 | static GPollFD *gfds; |
| 32 | static ptrdiff_t gfds_size; | 33 | static ptrdiff_t gfds_size; |
| 33 | 34 | ||
| 34 | int | 35 | int |
| 35 | xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | 36 | xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, |
| 36 | EMACS_TIME *timeout) | 37 | EMACS_TIME *timeout) |
| 37 | { | 38 | { |
| 38 | SELECT_TYPE all_rfds, all_wfds; | 39 | SELECT_TYPE all_rfds, all_wfds; |
| 39 | EMACS_TIME tmo, *tmop = timeout; | 40 | EMACS_TIME tmo, *tmop = timeout; |
| 40 | 41 | ||
| 41 | GMainContext *context = g_main_context_default (); | 42 | GMainContext *context; |
| 42 | int have_wfds = wfds != NULL; | 43 | int have_wfds = wfds != NULL; |
| 43 | int n_gfds = 0, our_tmo = 0, retval = 0, our_fds = 0; | 44 | int n_gfds = 0, our_tmo = 0, retval = 0, our_fds = 0, max_fds = fds_lim - 1; |
| 44 | int i, nfds, tmo_in_millisec; | 45 | int i, nfds, tmo_in_millisec; |
| 45 | 46 | ||
| 47 | if (!x_in_use) | ||
| 48 | return select (fds_lim, rfds, wfds, efds, timeout); | ||
| 49 | |||
| 46 | if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds)); | 50 | if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds)); |
| 47 | else FD_ZERO (&all_rfds); | 51 | else FD_ZERO (&all_rfds); |
| 48 | if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds)); | 52 | if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds)); |
| 49 | else FD_ZERO (&all_wfds); | 53 | else FD_ZERO (&all_wfds); |
| 50 | 54 | ||
| 51 | /* Update event sources in GLib. */ | 55 | /* Update event sources in GLib. */ |
| 56 | context = g_main_context_default (); | ||
| 52 | g_main_context_pending (context); | 57 | g_main_context_pending (context); |
| 53 | 58 | ||
| 54 | do { | 59 | do { |
| @@ -97,14 +102,14 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, | |||
| 97 | if (our_tmo) tmop = &tmo; | 102 | if (our_tmo) tmop = &tmo; |
| 98 | } | 103 | } |
| 99 | 104 | ||
| 100 | nfds = select (max_fds+1, &all_rfds, have_wfds ? &all_wfds : NULL, | 105 | fds_lim = max_fds + 1; |
| 101 | efds, tmop); | 106 | nfds = select (fds_lim, &all_rfds, have_wfds ? &all_wfds : NULL, efds, tmop); |
| 102 | 107 | ||
| 103 | if (nfds < 0) | 108 | if (nfds < 0) |
| 104 | retval = nfds; | 109 | retval = nfds; |
| 105 | else if (nfds > 0) | 110 | else if (nfds > 0) |
| 106 | { | 111 | { |
| 107 | for (i = 0; i < max_fds+1; ++i) | 112 | for (i = 0; i < fds_lim; ++i) |
| 108 | { | 113 | { |
| 109 | if (FD_ISSET (i, &all_rfds)) | 114 | if (FD_ISSET (i, &all_rfds)) |
| 110 | { | 115 | { |
diff --git a/src/xselect.c b/src/xselect.c index 290f4d7eb4d..48baeb32581 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -930,6 +930,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 930 | 930 | ||
| 931 | /* Otherwise, record the converted selection to binary. */ | 931 | /* Otherwise, record the converted selection to binary. */ |
| 932 | cs = xmalloc (sizeof (struct selection_data)); | 932 | cs = xmalloc (sizeof (struct selection_data)); |
| 933 | cs->data = NULL; | ||
| 933 | cs->nofree = 1; | 934 | cs->nofree = 1; |
| 934 | cs->property = property; | 935 | cs->property = property; |
| 935 | cs->wait_object = NULL; | 936 | cs->wait_object = NULL; |
diff --git a/src/xterm.c b/src/xterm.c index 1a5bc913f60..0ebaf87c252 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -256,11 +256,7 @@ static Time last_user_time; | |||
| 256 | /* Incremented by XTread_socket whenever it really tries to read | 256 | /* Incremented by XTread_socket whenever it really tries to read |
| 257 | events. */ | 257 | events. */ |
| 258 | 258 | ||
| 259 | #ifdef __STDC__ | ||
| 260 | static int volatile input_signal_count; | 259 | static int volatile input_signal_count; |
| 261 | #else | ||
| 262 | static int input_signal_count; | ||
| 263 | #endif | ||
| 264 | 260 | ||
| 265 | /* Used locally within XTread_socket. */ | 261 | /* Used locally within XTread_socket. */ |
| 266 | 262 | ||
| @@ -10146,7 +10142,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 10146 | 10142 | ||
| 10147 | /* Set the name of the terminal. */ | 10143 | /* Set the name of the terminal. */ |
| 10148 | terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); | 10144 | terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); |
| 10149 | strncpy (terminal->name, SSDATA (display_name), SBYTES (display_name)); | 10145 | memcpy (terminal->name, SSDATA (display_name), SBYTES (display_name)); |
| 10150 | terminal->name[SBYTES (display_name)] = 0; | 10146 | terminal->name[SBYTES (display_name)] = 0; |
| 10151 | 10147 | ||
| 10152 | #if 0 | 10148 | #if 0 |
diff --git a/src/xterm.h b/src/xterm.h index b498261a805..8919b648371 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1031,6 +1031,7 @@ extern void x_clipboard_manager_save_all (void); | |||
| 1031 | 1031 | ||
| 1032 | extern struct x_display_info * check_x_display_info (Lisp_Object); | 1032 | extern struct x_display_info * check_x_display_info (Lisp_Object); |
| 1033 | extern Lisp_Object x_get_focus_frame (struct frame *); | 1033 | extern Lisp_Object x_get_focus_frame (struct frame *); |
| 1034 | extern int x_in_use; | ||
| 1034 | 1035 | ||
| 1035 | #ifdef USE_GTK | 1036 | #ifdef USE_GTK |
| 1036 | extern int xg_set_icon (struct frame *, Lisp_Object); | 1037 | extern int xg_set_icon (struct frame *, Lisp_Object); |