diff src/lisp.h @ 665:fdefd0186b75

[xemacs-hg @ 2001-09-20 06:28:42 by ben] The great integral types renaming. The purpose of this is to rationalize the names used for various integral types, so that they match their intended uses and follow consist conventions, and eliminate types that were not semantically different from each other. The conventions are: -- All integral types that measure quantities of anything are signed. Some people disagree vociferously with this, but their arguments are mostly theoretical, and are vastly outweighed by the practical headaches of mixing signed and unsigned values, and more importantly by the far increased likelihood of inadvertent bugs: Because of the broken "viral" nature of unsigned quantities in C (operations involving mixed signed/unsigned are done unsigned, when exactly the opposite is nearly always wanted), even a single error in declaring a quantity unsigned that should be signed, or even the even more subtle error of comparing signed and unsigned values and forgetting the necessary cast, can be catastrophic, as comparisons will yield wrong results. -Wsign-compare is turned on specifically to catch this, but this tends to result in a great number of warnings when mixing signed and unsigned, and the casts are annoying. More has been written on this elsewhere. -- All such quantity types just mentioned boil down to EMACS_INT, which is 32 bits on 32-bit machines and 64 bits on 64-bit machines. This is guaranteed to be the same size as Lisp objects of type `int', and (as far as I can tell) of size_t (unsigned!) and ssize_t. The only type below that is not an EMACS_INT is Hashcode, which is an unsigned value of the same size as EMACS_INT. -- Type names should be relatively short (no more than 10 characters or so), with the first letter capitalized and no underscores if they can at all be avoided. -- "count" == a zero-based measurement of some quantity. Includes sizes, offsets, and indexes. -- "bpos" == a one-based measurement of a position in a buffer. "Charbpos" and "Bytebpos" count text in the buffer, rather than bytes in memory; thus Bytebpos does not directly correspond to the memory representation. Use "Membpos" for this. -- "Char" refers to internal-format characters, not to the C type "char", which is really a byte. -- For the actual name changes, see the script below. I ran the following script to do the conversion. (NOTE: This script is idempotent. You can safely run it multiple times and it will not screw up previous results -- in fact, it will do nothing if nothing has changed. Thus, it can be run repeatedly as necessary to handle patches coming in from old workspaces, or old branches.) There are two tags, just before and just after the change: `pre-integral-type-rename' and `post-integral-type-rename'. When merging code from the main trunk into a branch, the best thing to do is first merge up to `pre-integral-type-rename', then apply the script and associated changes, then merge from `post-integral-type-change' to the present. (Alternatively, just do the merging in one operation; but you may then have a lot of conflicts needing to be resolved by hand.) Script `fixtypes.sh' follows: ----------------------------------- cut ------------------------------------ files="*.[ch] s/*.h m/*.h config.h.in ../configure.in Makefile.in.in ../lib-src/*.[ch] ../lwlib/*.[ch]" gr Memory_Count Bytecount $files gr Lstream_Data_Count Bytecount $files gr Element_Count Elemcount $files gr Hash_Code Hashcode $files gr extcount bytecount $files gr bufpos charbpos $files gr bytind bytebpos $files gr memind membpos $files gr bufbyte intbyte $files gr Extcount Bytecount $files gr Bufpos Charbpos $files gr Bytind Bytebpos $files gr Memind Membpos $files gr Bufbyte Intbyte $files gr EXTCOUNT BYTECOUNT $files gr BUFPOS CHARBPOS $files gr BYTIND BYTEBPOS $files gr MEMIND MEMBPOS $files gr BUFBYTE INTBYTE $files gr MEMORY_COUNT BYTECOUNT $files gr LSTREAM_DATA_COUNT BYTECOUNT $files gr ELEMENT_COUNT ELEMCOUNT $files gr HASH_CODE HASHCODE $files ----------------------------------- cut ------------------------------------ `fixtypes.sh' is a Bourne-shell script; it uses 'gr': ----------------------------------- cut ------------------------------------ #!/bin/sh # Usage is like this: # gr FROM TO FILES ... # globally replace FROM with TO in FILES. FROM and TO are regular expressions. # backup files are stored in the `backup' directory. from="$1" to="$2" shift 2 echo ${1+"$@"} | xargs global-replace "s/$from/$to/g" ----------------------------------- cut ------------------------------------ `gr' in turn uses a Perl script to do its real work, `global-replace', which follows: ----------------------------------- cut ------------------------------------ : #-*- Perl -*- ### global-modify --- modify the contents of a file by a Perl expression ## Copyright (C) 1999 Martin Buchholz. ## Copyright (C) 2001 Ben Wing. ## Authors: Martin Buchholz <martin@xemacs.org>, Ben Wing <ben@xemacs.org> ## Maintainer: Ben Wing <ben@xemacs.org> ## Current Version: 1.0, May 5, 2001 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XEmacs; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. eval 'exec perl -w -S $0 ${1+"$@"}' if 0; use strict; use FileHandle; use Carp; use Getopt::Long; use File::Basename; (my $myName = $0) =~ s@.*/@@; my $usage=" Usage: $myName [--help] [--backup-dir=DIR] [--line-mode] [--hunk-mode] PERLEXPR FILE ... Globally modify a file, either line by line or in one big hunk. Typical usage is like this: [with GNU print, GNU xargs: guaranteed to handle spaces, quotes, etc. in file names] find . -name '*.[ch]' -print0 | xargs -0 $0 's/\bCONST\b/const/g'\n [with non-GNU print, xargs] find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n The file is read in, either line by line (with --line-mode specified) or in one big hunk (with --hunk-mode specified; it's the default), and the Perl expression is then evalled with \$_ set to the line or hunk of text, including the terminating newline if there is one. It should destructively modify the value there, storing the changed result in \$_. Files in which any modifications are made are backed up to the directory specified using --backup-dir, or to `backup' by default. To disable this, use --backup-dir= with no argument. Hunk mode is the default because it is MUCH MUCH faster than line-by-line. Use line-by-line only when it matters, e.g. you want to do a replacement only once per line (the default without the `g' argument). Conversely, when using hunk mode, *ALWAYS* use `g'; otherwise, you will only make one replacement in the entire file! "; my %options = (); $Getopt::Long::ignorecase = 0; &GetOptions ( \%options, 'help', 'backup-dir=s', 'line-mode', 'hunk-mode', ); die $usage if $options{"help"} or @ARGV <= 1; my $code = shift; die $usage if grep (-d || ! -w, @ARGV); sub SafeOpen { open ((my $fh = new FileHandle), $_[0]); confess "Can't open $_[0]: $!" if ! defined $fh; return $fh; } sub SafeClose { close $_[0] or confess "Can't close $_[0]: $!"; } sub FileContents { my $fh = SafeOpen ("< $_[0]"); my $olddollarslash = $/; local $/ = undef; my $contents = <$fh>; $/ = $olddollarslash; return $contents; } sub WriteStringToFile { my $fh = SafeOpen ("> $_[0]"); binmode $fh; print $fh $_[1] or confess "$_[0]: $!\n"; SafeClose $fh; } foreach my $file (@ARGV) { my $changed_p = 0; my $new_contents = ""; if ($options{"line-mode"}) { my $fh = SafeOpen $file; while (<$fh>) { my $save_line = $_; eval $code; $changed_p = 1 if $save_line ne $_; $new_contents .= $_; } } else { my $orig_contents = $_ = FileContents $file; eval $code; if ($_ ne $orig_contents) { $changed_p = 1; $new_contents = $_; } } if ($changed_p) { my $backdir = $options{"backup-dir"}; $backdir = "backup" if !defined ($backdir); if ($backdir) { my ($name, $path, $suffix) = fileparse ($file, ""); my $backfulldir = $path . $backdir; my $backfile = "$backfulldir/$name"; mkdir $backfulldir, 0755 unless -d $backfulldir; print "modifying $file (original saved in $backfile)\n"; rename $file, $backfile; } WriteStringToFile ($file, $new_contents); } } ----------------------------------- cut ------------------------------------ In addition to those programs, I needed to fix up a few other things, particularly relating to the duplicate definitions of types, now that some types merged with others. Specifically: 1. in lisp.h, removed duplicate declarations of Bytecount. The changed code should now look like this: (In each code snippet below, the first and last lines are the same as the original, as are all lines outside of those lines. That allows you to locate the section to be replaced, and replace the stuff in that section, verifying that there isn't anything new added that would need to be kept.) --------------------------------- snip ------------------------------------- /* Counts of bytes or chars */ typedef EMACS_INT Bytecount; typedef EMACS_INT Charcount; /* Counts of elements */ typedef EMACS_INT Elemcount; /* Hash codes */ typedef unsigned long Hashcode; /* ------------------------ dynamic arrays ------------------- */ --------------------------------- snip ------------------------------------- 2. in lstream.h, removed duplicate declaration of Bytecount. Rewrote the comment about this type. The changed code should now look like this: --------------------------------- snip ------------------------------------- #endif /* The have been some arguments over the what the type should be that specifies a count of bytes in a data block to be written out or read in, using Lstream_read(), Lstream_write(), and related functions. Originally it was long, which worked fine; Martin "corrected" these to size_t and ssize_t on the grounds that this is theoretically cleaner and is in keeping with the C standards. Unfortunately, this practice is horribly error-prone due to design flaws in the way that mixed signed/unsigned arithmetic happens. In fact, by doing this change, Martin introduced a subtle but fatal error that caused the operation of sending large mail messages to the SMTP server under Windows to fail. By putting all values back to be signed, avoiding any signed/unsigned mixing, the bug immediately went away. The type then in use was Lstream_Data_Count, so that it be reverted cleanly if a vote came to that. Now it is Bytecount. Some earlier comments about why the type must be signed: This MUST BE SIGNED, since it also is used in functions that return the number of bytes actually read to or written from in an operation, and these functions can return -1 to signal error. Note that the standard Unix read() and write() functions define the count going in as a size_t, which is UNSIGNED, and the count going out as an ssize_t, which is SIGNED. This is a horrible design flaw. Not only is it highly likely to lead to logic errors when a -1 gets interpreted as a large positive number, but operations are bound to fail in all sorts of horrible ways when a number in the upper-half of the size_t range is passed in -- this number is unrepresentable as an ssize_t, so code that checks to see how many bytes are actually written (which is mandatory if you are dealing with certain types of devices) will get completely screwed up. --ben */ typedef enum lstream_buffering --------------------------------- snip ------------------------------------- 3. in dumper.c, there are four places, all inside of switch() statements, where XD_BYTECOUNT appears twice as a case tag. In each case, the two case blocks contain identical code, and you should *REMOVE THE SECOND* and leave the first.
author ben
date Thu, 20 Sep 2001 06:31:11 +0000
parents b39c14581166
children a307f9a2021d
line wrap: on
line diff
--- a/src/lisp.h	Tue Sep 18 05:06:57 2001 +0000
+++ b/src/lisp.h	Thu Sep 20 06:31:11 2001 +0000
@@ -96,20 +96,20 @@
    functions declared as such. */
 
 /* The data representing the text in a buffer is logically a set
-   of Bufbytes, declared as follows. */
-
-typedef unsigned char Bufbyte;
+   of Intbytes, declared as follows. */
+
+typedef unsigned char Intbyte;
 
 /* The following should be used when you are working with internal data
    but for whatever reason need to have it declared a "char *".  Examples
    are function arguments whose values are most commonly literal strings,
    or where you have to apply a stdlib string function to internal data.
 
-   In general, you should avoid this where possible and use Bufbyte instead,
+   In general, you should avoid this where possible and use Intbyte instead,
    for consistency.  For example, the new Mule workspace contains
-   Bufbyte versions of the stdlib string functions. */
-
-typedef char CBufbyte;
+   Intbyte versions of the stdlib string functions. */
+
+typedef char CIntbyte;
 
 /* The data representing a string in "external" format (binary or any
    external encoding) is logically a set of Extbytes, declared as
@@ -132,9 +132,9 @@
 
 
 /* To the user, a buffer is made up of characters, declared as follows.
-   In the non-Mule world, characters and Bufbytes are equivalent.
+   In the non-Mule world, characters and Intbytes are equivalent.
    In the Mule world, a character requires (typically) 1 to 4
-   Bufbytes for its representation in a buffer. */
+   Intbytes for its representation in a buffer. */
 
 typedef int Emchar;
 
@@ -145,23 +145,19 @@
    buffer.h (where they rightfully belong) to avoid syntax errors
    in function prototypes. */
 
-typedef EMACS_INT Bufpos;
-typedef EMACS_INT Bytind;
-typedef EMACS_INT Memind;
+typedef EMACS_INT Charbpos;
+typedef EMACS_INT Bytebpos;
+typedef EMACS_INT Membpos;
 
 /* Counts of bytes or chars */
-
 typedef EMACS_INT Bytecount;
 typedef EMACS_INT Charcount;
 
-/* Length in bytes of a string in external format */
-typedef EMACS_INT Extcount;
-
-/* General counts of bytes or elements */
-typedef EMACS_INT Memory_Count;
-typedef EMACS_INT Element_Count;
-
-typedef unsigned long Hash_Code;
+/* Counts of elements */
+typedef EMACS_INT Elemcount;
+
+/* Hash codes */
+typedef unsigned long Hashcode;
 
 /* ------------------------ dynamic arrays ------------------- */
 
@@ -216,7 +212,7 @@
 
 #ifdef MEMORY_USAGE_STATS
 struct overhead_stats;
-Memory_Count Dynarr_memory_usage (void *d, struct overhead_stats *stats);
+Bytecount Dynarr_memory_usage (void *d, struct overhead_stats *stats);
 #endif
 
 /* Also define min() and max(). (Some compilers put them in strange
@@ -232,9 +228,9 @@
 
 /* Memory allocation */
 void malloc_warning (const char *);
-void *xmalloc (Memory_Count size);
-void *xmalloc_and_zero (Memory_Count size);
-void *xrealloc (void *, Memory_Count size);
+void *xmalloc (Bytecount size);
+void *xmalloc_and_zero (Bytecount size);
+void *xrealloc (void *, Bytecount size);
 char *xstrdup (const char *);
 /* generally useful */
 #define countof(x) ((int) (sizeof(x)/sizeof((x)[0])))
@@ -254,7 +250,7 @@
    least NEEDED_SIZE objects.  The reallocing is done by doubling,
    which ensures constant amortized time per element. */
 #define DO_REALLOC(basevar, sizevar, needed_size, type)	do {	\
-  Memory_Count do_realloc_needed_size = (needed_size);		\
+  Bytecount do_realloc_needed_size = (needed_size);		\
   if ((sizevar) < do_realloc_needed_size)			\
     {								\
       if ((sizevar) < 32)					\
@@ -443,8 +439,8 @@
 
 typedef struct
 {
-  Dynarr_declare (Bufbyte);
-} Bufbyte_dynarr;
+  Dynarr_declare (Intbyte);
+} Intbyte_dynarr;
 
 typedef struct
 {
@@ -480,13 +476,13 @@
 
 typedef struct
 {
-  Dynarr_declare (Bufpos);
-} Bufpos_dynarr;
+  Dynarr_declare (Charbpos);
+} Charbpos_dynarr;
 
 typedef struct
 {
-  Dynarr_declare (Bytind);
-} Bytind_dynarr;
+  Dynarr_declare (Bytebpos);
+} Bytebpos_dynarr;
 
 typedef struct
 {
@@ -673,7 +669,7 @@
 {
   Lisp_Object car, cdr;
   struct buffer *buffer;
-  int bufpos;
+  int charbpos;
 };
 #endif
 
@@ -1160,7 +1156,7 @@
 {
   struct lrecord_header lheader;
   Bytecount size;
-  Bufbyte *data;
+  Intbyte *data;
   Lisp_Object plist;
 };
 typedef struct Lisp_String Lisp_String;
@@ -1175,8 +1171,8 @@
 
 #ifdef MULE
 
-Charcount bytecount_to_charcount (const Bufbyte *ptr, Bytecount len);
-Bytecount charcount_to_bytecount (const Bufbyte *ptr, Charcount len);
+Charcount bytecount_to_charcount (const Intbyte *ptr, Bytecount len);
+Bytecount charcount_to_bytecount (const Intbyte *ptr, Charcount len);
 
 #else /* not MULE */
 
@@ -1217,7 +1213,7 @@
 # define string_char_length(s) string_length (s)
 # define string_char(s, i) ((Emchar) string_byte (s, i))
 # define string_char_addr(s, i) string_byte_addr (s, i)
-# define set_string_char(s, i, c) set_string_byte (s, i, (Bufbyte)c)
+# define set_string_char(s, i, c) set_string_byte (s, i, (Intbyte)c)
 
 #endif /* not MULE */
 
@@ -1291,7 +1287,7 @@
 {
   struct lrecord_header lheader;
   Lisp_Object next;
-  Element_Count size;
+  Elemcount size;
   unsigned long bits[1];
 };
 typedef struct Lisp_Bit_Vector Lisp_Bit_Vector;
@@ -1319,17 +1315,17 @@
 #define bit_vector_length(v) ((v)->size)
 #define bit_vector_next(v) ((v)->next)
 
-INLINE_HEADER int bit_vector_bit (Lisp_Bit_Vector *v, Element_Count n);
+INLINE_HEADER int bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n);
 INLINE_HEADER int
-bit_vector_bit (Lisp_Bit_Vector *v, Element_Count n)
+bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n)
 {
   return ((v->bits[n >> LONGBITS_LOG2] >> (n & (LONGBITS_POWER_OF_2 - 1)))
 	  & 1);
 }
 
-INLINE_HEADER void set_bit_vector_bit (Lisp_Bit_Vector *v, Element_Count n, int value);
+INLINE_HEADER void set_bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n, int value);
 INLINE_HEADER void
-set_bit_vector_bit (Lisp_Bit_Vector *v, Element_Count n, int value)
+set_bit_vector_bit (Lisp_Bit_Vector *v, Elemcount n, int value)
 {
   if (value)
     v->bits[n >> LONGBITS_LOG2] |= (1UL << (n & (LONGBITS_POWER_OF_2 - 1)));
@@ -1415,7 +1411,7 @@
   Lisp_Marker *next;
   Lisp_Marker *prev;
   struct buffer *buffer;
-  Memind memind;
+  Membpos membpos;
   char insertion_type;
 };
 
@@ -1695,7 +1691,7 @@
 {
   struct lcrecord_header header;
   Lisp_Object free;
-  Element_Count size;
+  Elemcount size;
   const struct lrecord_implementation *implementation;
 };
 
@@ -1708,7 +1704,7 @@
    Lcrecord lists should never escape to the Lisp level, so
    functions should not be doing this. */
 
-Lisp_Object make_lcrecord_list (Element_Count size,
+Lisp_Object make_lcrecord_list (Elemcount size,
 				const struct lrecord_implementation
 				*implementation);
 Lisp_Object allocate_managed_lcrecord (Lisp_Object lcrecord_list);
@@ -1889,7 +1885,7 @@
 
 #define LISP_HASH(obj) ((unsigned long) LISP_TO_VOID (obj))
 unsigned long string_hash (const char *xv);
-unsigned long memory_hash (const void *xv, Memory_Count size);
+unsigned long memory_hash (const void *xv, Bytecount size);
 unsigned long internal_hash (Lisp_Object obj, int depth);
 unsigned long internal_array_hash (Lisp_Object *arr, int size, int depth);
 
@@ -2190,7 +2186,7 @@
 
 /* dump_add_opaque (&var, size) dumps the opaque static structure `var'. */
 #ifdef PDUMP
-void dump_add_opaque (const void *, Memory_Count);
+void dump_add_opaque (const void *, Bytecount);
 #else
 #define dump_add_opaque(varaddr,size) DO_NOTHING
 #endif
@@ -2258,10 +2254,10 @@
 
 struct overhead_stats
 {
-  Memory_Count was_requested;
-  Memory_Count malloc_overhead;
-  Memory_Count dynarr_overhead;
-  Memory_Count gap_overhead;
+  Bytecount was_requested;
+  Bytecount malloc_overhead;
+  Bytecount dynarr_overhead;
+  Bytecount gap_overhead;
 };
 
 #endif /* MEMORY_USAGE_STATS */
@@ -2323,12 +2319,12 @@
 /* Defined in alloc.c */
 void release_breathing_space (void);
 Lisp_Object noseeum_cons (Lisp_Object, Lisp_Object);
-Lisp_Object make_vector (Element_Count, Lisp_Object);
+Lisp_Object make_vector (Elemcount, Lisp_Object);
 Lisp_Object vector1 (Lisp_Object);
 Lisp_Object vector2 (Lisp_Object, Lisp_Object);
 Lisp_Object vector3 (Lisp_Object, Lisp_Object, Lisp_Object);
-Lisp_Object make_bit_vector (Element_Count, Lisp_Object);
-Lisp_Object make_bit_vector_from_byte_vector (unsigned char *, Element_Count);
+Lisp_Object make_bit_vector (Elemcount, Lisp_Object);
+Lisp_Object make_bit_vector_from_byte_vector (unsigned char *, Elemcount);
 Lisp_Object noseeum_make_marker (void);
 void garbage_collect_1 (void);
 Lisp_Object acons (Lisp_Object, Lisp_Object, Lisp_Object);
@@ -2349,14 +2345,14 @@
 extern EMACS_INT gc_generation_number[1];
 int c_readonly (Lisp_Object);
 int lisp_readonly (Lisp_Object);
-Lisp_Object build_string (const CBufbyte *);
+Lisp_Object build_string (const CIntbyte *);
 Lisp_Object build_ext_string (const Extbyte *, Lisp_Object);
-Lisp_Object build_translated_string (const CBufbyte *);
-Lisp_Object make_string (const Bufbyte *, Bytecount);
+Lisp_Object build_translated_string (const CIntbyte *);
+Lisp_Object make_string (const Intbyte *, Bytecount);
 Lisp_Object make_ext_string (const Extbyte *, EMACS_INT, Lisp_Object);
 Lisp_Object make_uninit_string (Bytecount);
 Lisp_Object make_float (double);
-Lisp_Object make_string_nocopy (const Bufbyte *, Bytecount);
+Lisp_Object make_string_nocopy (const Intbyte *, Bytecount);
 void free_cons (Lisp_Cons *);
 void free_list (Lisp_Object);
 void free_alist (Lisp_Object);
@@ -2367,8 +2363,8 @@
 int marked_p (Lisp_Object obj);
 
 #ifdef MEMORY_USAGE_STATS
-Memory_Count malloced_storage_size (void *, Memory_Count, struct overhead_stats *);
-Memory_Count fixed_type_block_overhead (Memory_Count);
+Bytecount malloced_storage_size (void *, Bytecount, struct overhead_stats *);
+Bytecount fixed_type_block_overhead (Bytecount);
 #endif
 #ifdef PDUMP
 void pdump (void);
@@ -2389,7 +2385,7 @@
 
 /* Defined in bytecode.c */
 DECLARE_DOESNT_RETURN (invalid_byte_code
-		       (const CBufbyte *reason, Lisp_Object frob));
+		       (const CIntbyte *reason, Lisp_Object frob));
 
 /* Defined in callproc.c */
 char *egetenv (const char *);
@@ -2432,32 +2428,32 @@
 Lisp_Object read_doc_string (Lisp_Object);
 
 /* Defined in doprnt.c */
-Bytecount emacs_doprnt_c (Lisp_Object, const Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_c (Lisp_Object, const Intbyte *, Lisp_Object,
 			  Bytecount, ...);
-Bytecount emacs_doprnt_va (Lisp_Object, const Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_va (Lisp_Object, const Intbyte *, Lisp_Object,
 			   Bytecount, va_list);
-Bytecount emacs_doprnt_lisp (Lisp_Object, const Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_lisp (Lisp_Object, const Intbyte *, Lisp_Object,
 			     Bytecount, int, const Lisp_Object *);
-Bytecount emacs_doprnt_lisp_2 (Lisp_Object, const Bufbyte *, Lisp_Object,
+Bytecount emacs_doprnt_lisp_2 (Lisp_Object, const Intbyte *, Lisp_Object,
 			       Bytecount, int, ...);
-Lisp_Object emacs_doprnt_string_c (const Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_c (const Intbyte *, Lisp_Object,
 				   Bytecount, ...);
-Lisp_Object emacs_doprnt_string_va (const Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_va (const Intbyte *, Lisp_Object,
 				    Bytecount, va_list);
-Lisp_Object emacs_doprnt_string_lisp (const Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_lisp (const Intbyte *, Lisp_Object,
 				      Bytecount, int, const Lisp_Object *);
-Lisp_Object emacs_doprnt_string_lisp_2 (const Bufbyte *, Lisp_Object,
+Lisp_Object emacs_doprnt_string_lisp_2 (const Intbyte *, Lisp_Object,
 					Bytecount, int, ...);
 
 /* Defined in editfns.c */
 void uncache_home_directory (void);
 Extbyte *get_home_directory (void);
 char *user_login_name (uid_t *);
-Bufpos bufpos_clip_to_bounds (Bufpos, Bufpos, Bufpos);
-Bytind bytind_clip_to_bounds (Bytind, Bytind, Bytind);
+Charbpos charbpos_clip_to_bounds (Charbpos, Charbpos, Charbpos);
+Bytebpos bytebpos_clip_to_bounds (Bytebpos, Bytebpos, Bytebpos);
 void buffer_insert1 (struct buffer *, Lisp_Object);
-Lisp_Object make_string_from_buffer (struct buffer *, Bufpos, Charcount);
-Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Bufpos, Charcount);
+Lisp_Object make_string_from_buffer (struct buffer *, Charbpos, Charcount);
+Lisp_Object make_string_from_buffer_no_extents (struct buffer *, Charbpos, Charcount);
 Lisp_Object save_excursion_save (void);
 Lisp_Object save_restriction_save (void);
 Lisp_Object save_excursion_restore (Lisp_Object);
@@ -2493,50 +2489,50 @@
 					      Lisp_Object, Error_Behavior);
 DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (signal_ferror
 						  (Lisp_Object,
-						   const CBufbyte *,
+						   const CIntbyte *,
 						   ...), 2, 3);
 void maybe_signal_ferror (Lisp_Object, Lisp_Object, Error_Behavior,
-			  const CBufbyte *, ...) PRINTF_ARGS (4, 5);
-Lisp_Object signal_continuable_ferror (Lisp_Object, const CBufbyte *, ...)
+			  const CIntbyte *, ...) PRINTF_ARGS (4, 5);
+Lisp_Object signal_continuable_ferror (Lisp_Object, const CIntbyte *, ...)
      PRINTF_ARGS (2, 3);
 Lisp_Object maybe_signal_continuable_ferror (Lisp_Object, Lisp_Object,
 					     Error_Behavior,
-					     const CBufbyte *, ...)
+					     const CIntbyte *, ...)
      PRINTF_ARGS (4, 5);
 
-Lisp_Object build_error_data (const CBufbyte *reason, Lisp_Object frob);
-DECLARE_DOESNT_RETURN (signal_error (Lisp_Object, const CBufbyte *,
+Lisp_Object build_error_data (const CIntbyte *reason, Lisp_Object frob);
+DECLARE_DOESNT_RETURN (signal_error (Lisp_Object, const CIntbyte *,
 				     Lisp_Object));
-void maybe_signal_error (Lisp_Object, const CBufbyte *, Lisp_Object,
+void maybe_signal_error (Lisp_Object, const CIntbyte *, Lisp_Object,
 			 Lisp_Object, Error_Behavior);
-Lisp_Object signal_continuable_error (Lisp_Object, const CBufbyte *,
+Lisp_Object signal_continuable_error (Lisp_Object, const CIntbyte *,
 				      Lisp_Object);
-Lisp_Object maybe_signal_continuable_error (Lisp_Object, const CBufbyte *,
+Lisp_Object maybe_signal_continuable_error (Lisp_Object, const CIntbyte *,
 					    Lisp_Object,
 					    Lisp_Object, Error_Behavior);
 DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (signal_ferror_with_frob
 						  (Lisp_Object, Lisp_Object,
-						   const CBufbyte *,
+						   const CIntbyte *,
 						   ...), 3, 4);
 void maybe_signal_ferror_with_frob (Lisp_Object, Lisp_Object, Lisp_Object,
 				    Error_Behavior,
-				    const CBufbyte *, ...) PRINTF_ARGS (5, 6);
+				    const CIntbyte *, ...) PRINTF_ARGS (5, 6);
 Lisp_Object signal_continuable_ferror_with_frob (Lisp_Object, Lisp_Object,
-						 const CBufbyte *,
+						 const CIntbyte *,
 						 ...) PRINTF_ARGS (3, 4);
 Lisp_Object maybe_signal_continuable_ferror_with_frob (Lisp_Object,
 						       Lisp_Object,
 						       Lisp_Object,
 						       Error_Behavior,
-						       const CBufbyte *, ...)
+						       const CIntbyte *, ...)
      PRINTF_ARGS (5, 6);
-DECLARE_DOESNT_RETURN (signal_error_2 (Lisp_Object, const CBufbyte *,
+DECLARE_DOESNT_RETURN (signal_error_2 (Lisp_Object, const CIntbyte *,
 				       Lisp_Object, Lisp_Object));
-void maybe_signal_error_2 (Lisp_Object, const CBufbyte *, Lisp_Object,
+void maybe_signal_error_2 (Lisp_Object, const CIntbyte *, Lisp_Object,
 			   Lisp_Object, Lisp_Object, Error_Behavior);
-Lisp_Object signal_continuable_error_2 (Lisp_Object, const CBufbyte *,
+Lisp_Object signal_continuable_error_2 (Lisp_Object, const CIntbyte *,
 					Lisp_Object, Lisp_Object);
-Lisp_Object maybe_signal_continuable_error_2 (Lisp_Object, const CBufbyte *,
+Lisp_Object maybe_signal_continuable_error_2 (Lisp_Object, const CIntbyte *,
 					      Lisp_Object, Lisp_Object,
 					      Lisp_Object,
 					      Error_Behavior);
@@ -2547,60 +2543,60 @@
 DECLARE_DOESNT_RETURN (signal_circular_list_error (Lisp_Object));
 DECLARE_DOESNT_RETURN (signal_circular_property_list_error (Lisp_Object));
 
-DECLARE_DOESNT_RETURN (syntax_error (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (syntax_error (const CIntbyte *reason,
 				     Lisp_Object frob));
-DECLARE_DOESNT_RETURN (syntax_error_2 (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (syntax_error_2 (const CIntbyte *reason,
 				       Lisp_Object frob1,
 				       Lisp_Object frob2));
-void maybe_syntax_error (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_syntax_error (const CIntbyte *, Lisp_Object, Lisp_Object,
 			 Error_Behavior);
-DECLARE_DOESNT_RETURN (sferror (const CBufbyte *reason, Lisp_Object frob));
-DECLARE_DOESNT_RETURN (sferror_2 (const CBufbyte *reason, Lisp_Object frob1,
+DECLARE_DOESNT_RETURN (sferror (const CIntbyte *reason, Lisp_Object frob));
+DECLARE_DOESNT_RETURN (sferror_2 (const CIntbyte *reason, Lisp_Object frob1,
 				  Lisp_Object frob2));
-void maybe_sferror (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_sferror (const CIntbyte *, Lisp_Object, Lisp_Object,
 		    Error_Behavior);
-DECLARE_DOESNT_RETURN (invalid_argument (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_argument (const CIntbyte *reason,
 					 Lisp_Object frob));
-DECLARE_DOESNT_RETURN (invalid_argument_2 (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_argument_2 (const CIntbyte *reason,
 					   Lisp_Object frob1,
 					   Lisp_Object frob2));
-void maybe_invalid_argument (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_invalid_argument (const CIntbyte *, Lisp_Object, Lisp_Object,
 			     Error_Behavior);
-DECLARE_DOESNT_RETURN (invalid_operation (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_operation (const CIntbyte *reason,
 					 Lisp_Object frob));
-DECLARE_DOESNT_RETURN (invalid_operation_2 (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_operation_2 (const CIntbyte *reason,
 					   Lisp_Object frob1,
 					   Lisp_Object frob2));
-void maybe_invalid_operation (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_invalid_operation (const CIntbyte *, Lisp_Object, Lisp_Object,
 			     Error_Behavior);
-DECLARE_DOESNT_RETURN (invalid_state (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_state (const CIntbyte *reason,
 					 Lisp_Object frob));
-DECLARE_DOESNT_RETURN (invalid_state_2 (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_state_2 (const CIntbyte *reason,
 					   Lisp_Object frob1,
 					   Lisp_Object frob2));
-void maybe_invalid_state (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_invalid_state (const CIntbyte *, Lisp_Object, Lisp_Object,
 			  Error_Behavior);
-DECLARE_DOESNT_RETURN (invalid_change (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_change (const CIntbyte *reason,
 					 Lisp_Object frob));
-DECLARE_DOESNT_RETURN (invalid_change_2 (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_change_2 (const CIntbyte *reason,
 					   Lisp_Object frob1,
 					   Lisp_Object frob2));
-void maybe_invalid_change (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_invalid_change (const CIntbyte *, Lisp_Object, Lisp_Object,
 			   Error_Behavior);
-DECLARE_DOESNT_RETURN (invalid_constant (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_constant (const CIntbyte *reason,
 					 Lisp_Object frob));
-DECLARE_DOESNT_RETURN (invalid_constant_2 (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (invalid_constant_2 (const CIntbyte *reason,
 					   Lisp_Object frob1,
 					   Lisp_Object frob2));
-void maybe_invalid_constant (const CBufbyte *, Lisp_Object, Lisp_Object,
+void maybe_invalid_constant (const CIntbyte *, Lisp_Object, Lisp_Object,
 			     Error_Behavior);
-DECLARE_DOESNT_RETURN (wtaerror (const CBufbyte *reason, Lisp_Object frob));
-DECLARE_DOESNT_RETURN (out_of_memory (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (wtaerror (const CIntbyte *reason, Lisp_Object frob));
+DECLARE_DOESNT_RETURN (out_of_memory (const CIntbyte *reason,
 				      Lisp_Object frob));
-DECLARE_DOESNT_RETURN (stack_overflow (const CBufbyte *reason,
+DECLARE_DOESNT_RETURN (stack_overflow (const CIntbyte *reason,
 				       Lisp_Object frob));
 DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS (printing_unreadable_object
-						  (const CBufbyte *,
+						  (const CIntbyte *,
 						   ...), 1, 2);
 
 Lisp_Object signal_void_function_error (Lisp_Object);
@@ -2646,13 +2642,13 @@
 Lisp_Object eval_in_buffer (struct buffer *, Lisp_Object);
 Lisp_Object call0_with_handler (Lisp_Object, Lisp_Object);
 Lisp_Object call1_with_handler (Lisp_Object, Lisp_Object, Lisp_Object);
-Lisp_Object eval_in_buffer_trapping_errors (const CBufbyte *, struct buffer *,
+Lisp_Object eval_in_buffer_trapping_errors (const CIntbyte *, struct buffer *,
 					    Lisp_Object);
-Lisp_Object run_hook_trapping_errors (const CBufbyte *, Lisp_Object);
-Lisp_Object safe_run_hook_trapping_errors (const CBufbyte *, Lisp_Object, int);
-Lisp_Object call0_trapping_errors (const CBufbyte *, Lisp_Object);
-Lisp_Object call1_trapping_errors (const CBufbyte *, Lisp_Object, Lisp_Object);
-Lisp_Object call2_trapping_errors (const CBufbyte *,
+Lisp_Object run_hook_trapping_errors (const CIntbyte *, Lisp_Object);
+Lisp_Object safe_run_hook_trapping_errors (const CIntbyte *, Lisp_Object, int);
+Lisp_Object call0_trapping_errors (const CIntbyte *, Lisp_Object);
+Lisp_Object call1_trapping_errors (const CIntbyte *, Lisp_Object, Lisp_Object);
+Lisp_Object call2_trapping_errors (const CIntbyte *,
 				   Lisp_Object, Lisp_Object, Lisp_Object);
 Lisp_Object call_with_suspended_errors (lisp_fn_t, volatile Lisp_Object, Lisp_Object,
 					Error_Behavior, int, ...);
@@ -2671,7 +2667,7 @@
 void do_autoload (Lisp_Object, Lisp_Object);
 Lisp_Object un_autoload (Lisp_Object);
 void warn_when_safe_lispobj (Lisp_Object, Lisp_Object, Lisp_Object);
-void warn_when_safe (Lisp_Object, Lisp_Object, const CBufbyte *,
+void warn_when_safe (Lisp_Object, Lisp_Object, const CIntbyte *,
 		     ...) PRINTF_ARGS (3, 4);
 
 
@@ -2697,18 +2693,18 @@
 void record_auto_save (void);
 void force_auto_save_soon (void);
 DECLARE_DOESNT_RETURN (report_error_with_errno (Lisp_Object errtype,
-						const CBufbyte *string,
+						const CIntbyte *string,
 						Lisp_Object data));
 DECLARE_DOESNT_RETURN (report_file_type_error (Lisp_Object errtype,
 					       Lisp_Object oserrmess,
-					       const CBufbyte *string,
+					       const CIntbyte *string,
 					       Lisp_Object data));
-DECLARE_DOESNT_RETURN (report_file_error (const CBufbyte *, Lisp_Object));
+DECLARE_DOESNT_RETURN (report_file_error (const CIntbyte *, Lisp_Object));
 Lisp_Object lisp_strerror (int);
 Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
-Memory_Count read_allowing_quit (int fildes, void *buf, Memory_Count size);
-Memory_Count write_allowing_quit (int fildes, const void *buf,
-				  Memory_Count size);
+Bytecount read_allowing_quit (int fildes, void *buf, Bytecount size);
+Bytecount write_allowing_quit (int fildes, const void *buf,
+				  Bytecount size);
 int internal_delete_file (Lisp_Object);
 
 /* Defined in filelock.c */
@@ -2775,13 +2771,13 @@
 DECLARE_DOESNT_RETURN (gui_error_2 (const char *reason,
 				    Lisp_Object frob0, Lisp_Object frob1));
 /* Defined in indent.c */
-int bi_spaces_at_point (struct buffer *, Bytind);
-int column_at_point (struct buffer *, Bufpos, int);
-int string_column_at_point (Lisp_String *, Bufpos, int);
+int bi_spaces_at_point (struct buffer *, Bytebpos);
+int column_at_point (struct buffer *, Charbpos, int);
+int string_column_at_point (Lisp_String *, Charbpos, int);
 int current_column (struct buffer *);
 void invalidate_current_column (void);
-Bufpos vmotion (struct window *, Bufpos, int, int *);
-Bufpos vmotion_pixels (Lisp_Object, Bufpos, int, int, int *);
+Charbpos vmotion (struct window *, Charbpos, int, int *);
+Charbpos vmotion_pixels (Lisp_Object, Charbpos, int, int, int *);
 
 /* Defined in keymap.c */
 void where_is_to_char (Lisp_Object, char *);
@@ -2810,10 +2806,10 @@
 #endif /*! LOADHIST */
 
 /* Defined in marker.c */
-Bytind bi_marker_position (Lisp_Object);
-Bufpos marker_position (Lisp_Object);
-void set_bi_marker_position (Lisp_Object, Bytind);
-void set_marker_position (Lisp_Object, Bufpos);
+Bytebpos bi_marker_position (Lisp_Object);
+Charbpos marker_position (Lisp_Object);
+void set_bi_marker_position (Lisp_Object, Bytebpos);
+void set_marker_position (Lisp_Object, Charbpos);
 void unchain_marker (Lisp_Object);
 Lisp_Object noseeum_copy_marker (Lisp_Object, Lisp_Object);
 Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object);
@@ -2828,22 +2824,22 @@
 
 /* Defined in minibuf.c */
 extern int minibuf_level;
-Charcount scmp_1 (const Bufbyte *, const Bufbyte *, Charcount, int);
+Charcount scmp_1 (const Intbyte *, const Intbyte *, Charcount, int);
 #define scmp(s1, s2, len) scmp_1 (s1, s2, len, completion_ignore_case)
 extern int completion_ignore_case;
-int regexp_ignore_completion_p (const Bufbyte *, Lisp_Object,
+int regexp_ignore_completion_p (const Intbyte *, Lisp_Object,
 				Bytecount, Bytecount);
 Lisp_Object clear_echo_area (struct frame *, Lisp_Object, int);
 Lisp_Object clear_echo_area_from_print (struct frame *, Lisp_Object, int);
-void echo_area_append (struct frame *, const Bufbyte *, Lisp_Object,
+void echo_area_append (struct frame *, const Intbyte *, Lisp_Object,
 		       Bytecount, Bytecount, Lisp_Object);
-void echo_area_message (struct frame *, const Bufbyte *, Lisp_Object,
+void echo_area_message (struct frame *, const Intbyte *, Lisp_Object,
 			Bytecount, Bytecount, Lisp_Object);
 Lisp_Object echo_area_status (struct frame *);
 int echo_area_active (struct frame *);
 Lisp_Object echo_area_contents (struct frame *);
-void message_internal (const Bufbyte *, Lisp_Object, Bytecount, Bytecount);
-void message_append_internal (const Bufbyte *, Lisp_Object,
+void message_internal (const Intbyte *, Lisp_Object, Bytecount, Bytecount);
+void message_append_internal (const Intbyte *, Lisp_Object,
 			      Bytecount, Bytecount);
 void message (const char *, ...) PRINTF_ARGS (1, 2);
 void message_append (const char *, ...) PRINTF_ARGS (1, 2);
@@ -2852,7 +2848,7 @@
 
 /* Defined in print.c */
 void write_string_to_stdio_stream (FILE *, struct console *,
-				   const Bufbyte *, Bytecount, Bytecount,
+				   const Intbyte *, Bytecount, Bytecount,
 				   Lisp_Object, int);
 void debug_print (Lisp_Object);
 void debug_short_backtrace (int);
@@ -2863,7 +2859,7 @@
  *  (eg Qnil means stdout, not Vstandard_output, etc) */
 void write_c_string (const char *, Lisp_Object);
 /* Same goes for this function. */
-void write_string_1 (const Bufbyte *, Bytecount, Lisp_Object);
+void write_string_1 (const Intbyte *, Bytecount, Lisp_Object);
 void print_cons (Lisp_Object, Lisp_Object, int);
 void print_vector (Lisp_Object, Lisp_Object, int);
 void print_string (Lisp_Object, Lisp_Object, int);
@@ -2914,15 +2910,15 @@
 /* Defined in search.c */
 struct re_pattern_buffer;
 struct re_registers;
-Bufpos scan_buffer (struct buffer *, Emchar, Bufpos, Bufpos, EMACS_INT, EMACS_INT *, int);
-Bufpos find_next_newline (struct buffer *, Bufpos, int);
-Bufpos find_next_newline_no_quit (struct buffer *, Bufpos, int);
-Bytind bi_find_next_newline_no_quit (struct buffer *, Bytind, int);
-Bytind bi_find_next_emchar_in_string (Lisp_String*, Emchar, Bytind, EMACS_INT);
-Bufpos find_before_next_newline (struct buffer *, Bufpos, Bufpos, int);
+Charbpos scan_buffer (struct buffer *, Emchar, Charbpos, Charbpos, EMACS_INT, EMACS_INT *, int);
+Charbpos find_next_newline (struct buffer *, Charbpos, int);
+Charbpos find_next_newline_no_quit (struct buffer *, Charbpos, int);
+Bytebpos bi_find_next_newline_no_quit (struct buffer *, Bytebpos, int);
+Bytebpos bi_find_next_emchar_in_string (Lisp_String*, Emchar, Bytebpos, EMACS_INT);
+Charbpos find_before_next_newline (struct buffer *, Charbpos, Charbpos, int);
 struct re_pattern_buffer *compile_pattern (Lisp_Object, struct re_registers *,
 					   Lisp_Object, int, Error_Behavior);
-Bytecount fast_string_match (Lisp_Object,  const Bufbyte *,
+Bytecount fast_string_match (Lisp_Object,  const Intbyte *,
 			     Lisp_Object, Bytecount,
 			     Bytecount, int, Error_Behavior, int);
 Bytecount fast_lisp_string_match (Lisp_Object, Lisp_Object);
@@ -2947,9 +2943,9 @@
 					Error_Behavior, int, Lisp_Object);
 
 /* Defined in symbols.c */
-unsigned int hash_string (const Bufbyte *, Bytecount);
+unsigned int hash_string (const Intbyte *, Bytecount);
 Lisp_Object intern (const char *);
-Lisp_Object oblookup (Lisp_Object, const Bufbyte *, Bytecount);
+Lisp_Object oblookup (Lisp_Object, const Intbyte *, Bytecount);
 void map_obarray (Lisp_Object, int (*) (Lisp_Object, void *), void *);
 Lisp_Object indirect_function (Lisp_Object, int);
 Lisp_Object symbol_value_in_buffer (Lisp_Object, Lisp_Object);
@@ -2963,14 +2959,14 @@
 			      Lisp_Object follow_past_lisp_magic);
 
 /* Defined in syntax.c */
-Bufpos scan_words (struct buffer *, Bufpos, int);
+Charbpos scan_words (struct buffer *, Charbpos, int);
 
 /* Defined in undo.c */
 Lisp_Object truncate_undo_list (Lisp_Object, int, int);
 void record_extent (Lisp_Object, int);
-void record_insert (struct buffer *, Bufpos, Charcount);
-void record_delete (struct buffer *, Bufpos, Charcount);
-void record_change (struct buffer *, Bufpos, Charcount);
+void record_insert (struct buffer *, Charbpos, Charcount);
+void record_delete (struct buffer *, Charbpos, Charcount);
+void record_change (struct buffer *, Charbpos, Charcount);
 
 /* Defined in unex*.c */
 int unexec (char *, char *, uintptr_t, uintptr_t, uintptr_t);