Mercurial > hg > xemacs-beta
annotate src/mem-limits.h @ 5776:65d65b52d608
Pass character count from coding systems to buffer insertion code.
src/ChangeLog addition:
2014-01-16 Aidan Kehoe <kehoea@parhasard.net>
Pass character count information from the no-conversion and
unicode coding systems to the buffer insertion code, making
#'find-file on large buffers a little snappier (if
ERROR_CHECK_TEXT is not defined).
* file-coding.c:
* file-coding.c (coding_character_tell): New.
* file-coding.c (conversion_coding_stream_description): New.
* file-coding.c (no_conversion_convert):
Update characters_seen when decoding.
* file-coding.c (no_conversion_character_tell): New.
* file-coding.c (lstream_type_create_file_coding): Create the
no_conversion type with data.
* file-coding.c (coding_system_type_create):
Make the character_tell method available here.
* file-coding.h:
* file-coding.h (struct coding_system_methods):
Add a new character_tell() method, passing charcount information
from the coding systems to the buffer code, avoiding duplicate
bytecount-to-charcount work especially with large buffers.
* fileio.c (Finsert_file_contents_internal):
Update this to pass charcount information to
buffer_insert_string_1(), if that is available from the lstream code.
* insdel.c:
* insdel.c (buffer_insert_string_1):
Add a new CCLEN argument, giving the character count of the string
to insert. It can be -1 to indicate that te function should work
it out itself using bytecount_to_charcount(), as it used to.
* insdel.c (buffer_insert_raw_string_1):
* insdel.c (buffer_insert_lisp_string_1):
* insdel.c (buffer_insert_ascstring_1):
* insdel.c (buffer_insert_emacs_char_1):
* insdel.c (buffer_insert_from_buffer_1):
* insdel.c (buffer_replace_char):
Update these functions to use the new calling convention.
* insdel.h:
* insdel.h (buffer_insert_string):
Update this header to reflect the new buffer_insert_string_1()
argument.
* lstream.c (Lstream_character_tell): New.
Return the number of characters *read* and seen by the consumer so
far, taking into account the unget buffer, and buffered reading.
* lstream.c (Lstream_unread):
Update unget_character_count here as appropriate.
* lstream.c (Lstream_rewind):
Reset unget_character_count here too.
* lstream.h:
* lstream.h (struct lstream):
Provide the character_tell method, add a new field,
unget_character_count, giving the number of characters ever passed
to Lstream_unread().
Declare Lstream_character_tell().
Make Lstream_ungetc(), which happens to be unused, an inline
function rather than a macro, in the course of updating it to
modify unget_character_count.
* print.c (output_string):
Use the new argument to buffer_insert_string_1().
* tests.c:
* tests.c (Ftest_character_tell):
New test function.
* tests.c (syms_of_tests):
Make it available.
* unicode.c:
* unicode.c (struct unicode_coding_stream):
* unicode.c (unicode_character_tell):
New method.
* unicode.c (unicode_convert):
Update the character counter as appropriate.
* unicode.c (coding_system_type_create_unicode):
Make the character_tell method available.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 16 Jan 2014 16:27:52 +0000 |
parents | 308d34e9f07d |
children | e2fae7783046 |
rev | line source |
---|---|
428 | 1 /* Includes for memory limit warnings. |
2 Copyright (C) 1990, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | |
3 | |
4 This file is part of XEmacs. | |
5 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
428 | 7 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
9 option) any later version. |
428 | 10 |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 18 |
19 /* Synched up with: FSF 19.30. */ | |
20 | |
2263 | 21 /* Subsequently cleaned up and reorganised, made to use configure. */ |
428 | 22 |
440 | 23 #ifndef INCLUDED_mem_limits_h_ |
24 #define INCLUDED_mem_limits_h_ | |
428 | 25 |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
30 #ifdef HAVE_ULIMIT_H | |
31 #include <ulimit.h> | |
32 #endif | |
33 | |
2263 | 34 #ifdef HAVE_SYS_RESOURCE_H |
35 /* Some systems need either sys/types.h or sys/time.h before <sys/resource.h>. */ | |
428 | 36 #include <sys/types.h> |
2263 | 37 #include <sys/time.h> |
38 #include <sys/resource.h> | |
39 #endif | |
40 | |
41 #ifdef HAVE_SYS_VLIMIT_H | |
42 #include <sys/vlimit.h> | |
43 #endif | |
428 | 44 |
45 #ifdef _LIBC | |
46 | |
47 /* Old Linux startup code won't define __data_start. */ | |
48 extern int etext, __data_start; weak_symbol (__data_start) | |
49 #define start_of_data() (&__data_start ?: &etext) | |
50 | |
51 #else /* not GNU libc */ | |
52 | |
53 #ifdef emacs | |
54 typedef void *POINTER; | |
55 | |
442 | 56 #ifndef CYGWIN |
428 | 57 typedef unsigned long SIZE; |
58 #endif | |
59 | |
60 extern POINTER start_of_data (void); | |
61 #define EXCEEDS_LISP_PTR(ptr) 0 | |
62 | |
63 #ifdef BSD | |
64 extern int etext; | |
65 #define start_of_data() &etext | |
66 #endif | |
67 | |
68 #else /* not emacs */ | |
69 extern char etext; | |
70 #define start_of_data() &etext | |
71 #endif /* not emacs */ | |
72 | |
73 #endif /* not _LIBC */ | |
74 | |
75 | |
76 | |
77 /* start of data space; can be changed by calling malloc_init */ | |
78 static POINTER data_space_start; | |
79 | |
80 /* Number of bytes of writable memory we can expect to be able to get */ | |
2132 | 81 extern unsigned long lim_data; |
428 | 82 |
2263 | 83 /* The implementation of get_lim_data() is very machine dependent. */ |
84 | |
442 | 85 #if defined (HEAP_IN_DATA) && !defined(PDUMP) |
428 | 86 extern unsigned long static_heap_size; |
1632 | 87 extern MODULE_API int initialized; |
2263 | 88 |
428 | 89 static void |
90 get_lim_data (void) | |
91 { | |
92 if (!initialized) | |
93 { | |
2132 | 94 lim_data = (unsigned long) -1; /* static_heap_size; */ |
428 | 95 } |
96 else | |
97 { | |
2132 | 98 lim_data = (unsigned long) -1; |
428 | 99 } |
100 } | |
2263 | 101 |
102 #elif defined(NO_LIM_DATA) | |
103 | |
428 | 104 static void |
105 get_lim_data (void) | |
106 { | |
2132 | 107 lim_data = (unsigned long) -1; |
428 | 108 } |
2263 | 109 |
110 #elif defined(HAVE_GETRLIMIT) | |
111 | |
112 static void | |
113 get_lim_data (void) | |
114 { | |
115 struct rlimit XXrlimit; | |
428 | 116 |
2263 | 117 getrlimit (RLIMIT_DATA, &XXrlimit); |
118 #ifdef RLIM_INFINITY | |
119 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ | |
120 #else | |
121 lim_data = XXrlimit.rlim_cur; /* soft limit */ | |
122 #endif | |
123 } | |
124 | |
125 #elif defined(HAVE_ULIMIT) | |
428 | 126 |
127 static void | |
128 get_lim_data (void) | |
129 { | |
2132 | 130 lim_data = (unsigned long) -1; |
428 | 131 |
132 /* Use the ulimit call, if we seem to have it. */ | |
2132 | 133 #if !defined (ULIMIT_BREAK_VALUE) |
428 | 134 lim_data = ulimit (3, 0); |
135 #endif | |
136 | |
137 /* If that didn't work, just use the macro's value. */ | |
138 #ifdef ULIMIT_BREAK_VALUE | |
2132 | 139 if (lim_data == (unsigned long) -1) |
428 | 140 lim_data = ULIMIT_BREAK_VALUE; |
141 #endif | |
142 | |
143 lim_data -= (long) data_space_start; | |
144 } | |
145 | |
2263 | 146 #elif defined(WIN32_NATIVE) |
428 | 147 |
148 static void | |
149 get_lim_data (void) | |
150 { | |
151 extern unsigned long data_region_size; | |
152 lim_data = data_region_size; | |
153 } | |
154 | |
2263 | 155 #elif defined(HAVE_VLIMIT) |
428 | 156 |
157 static void | |
158 get_lim_data (void) | |
159 { | |
160 lim_data = vlimit (LIM_DATA, -1); | |
161 } | |
162 | |
163 #else | |
2263 | 164 #error Cannot determine an implementation of get_lim_data(). |
165 #endif /* not HAVE_VLIMIT */ | |
428 | 166 |
440 | 167 #endif /* INCLUDED_mem_limits_h_ */ |