#include <stdarg.h>
#include <stddef.h>
#include <inttypes.h>
+#include <limits.h>
#include <intprops.h>
# define EMACS_UINT unsigned EMACS_INT
#endif
+/* printmax_t and uprintmax_t are types for printing large integers.
+ These are the widest integers that are supported for printing.
+ pMd etc. are conversions for printing them.
+ On C99 hosts, there's no problem, as even the widest integers work.
+ Fall back on EMACS_INT on pre-C99 hosts. */
+#ifdef PRIdMAX
+typedef intmax_t printmax_t;
+typedef uintmax_t uprintmax_t;
+# define pMd PRIdMAX
+# define pMu PRIuMAX
+#else
+typedef EMACS_INT printmax_t;
+typedef EMACS_UINT uprintmax_t;
+# define pMd pI"d"
+# define pMu pI"u"
+#endif
+
/* Use pD to format ptrdiff_t values, which suffice for indexes into
buffers and strings. Emacs never allocates objects larger than
PTRDIFF_MAX bytes, as they cause problems with pointer subtraction.
{
/* Used for comparing two Lisp_Objects;
also, positive integers can be accessed fast this way. */
- EMACS_UINT i;
+ EMACS_INT i;
struct
{
{
/* Used for comparing two Lisp_Objects;
also, positive integers can be accessed fast this way. */
- EMACS_UINT i;
+ EMACS_INT i;
struct
{
#ifdef USE_LSB_TAG
# define XSET(var, vartype, ptr) \
- (eassert ((((EMACS_UINT) (ptr)) & ((1 << GCTYPEBITS) - 1)) == 0), \
- (var).u.val = ((EMACS_UINT) (ptr)) >> GCTYPEBITS, \
+ (eassert ((((uintptr_t) (ptr)) & ((1 << GCTYPEBITS) - 1)) == 0), \
+ (var).u.val = ((uintptr_t) (ptr)) >> GCTYPEBITS, \
(var).u.type = ((char) (vartype)))
/* Some versions of gcc seem to consider the bitfield width when issuing
# define XSETFASTINT(a, b) ((a).i = (b))
# define XSET(var, vartype, ptr) \
- (((var).s.val = ((EMACS_INT) (ptr))), ((var).s.type = ((char) (vartype))))
+ (((var).s.val = ((intptr_t) (ptr))), ((var).s.type = ((char) (vartype))))
#ifdef DATA_SEG_BITS
/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8546>. */
struct vectorlike_header
{
- EMACS_UINT size;
+ EMACS_INT size;
/* Pointer to the next vector-like object. It is generally a buffer or a
Lisp_Vector alias, so for convenience it is a union instead of a
just the subtype information. */
struct vectorlike_header header;
/* This is the size in bits. */
- EMACS_UINT size;
+ EMACS_INT size;
/* This contains the actual bits, packed into bytes. */
unsigned char data[1];
};
struct Lisp_Subr
{
- EMACS_UINT size;
+ EMACS_INT size;
union {
Lisp_Object (*a0) (void);
Lisp_Object (*a1) (Lisp_Object);
#define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant
+#define DEFSYM(sym, name) \
+ do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0)
+
\f
/***********************************************************************
Hash Tables
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
static DECL_ALIGN (struct Lisp_Subr, sname) = \
- { PVEC_SUBR | (sizeof (struct Lisp_Subr) / sizeof (EMACS_INT)), \
+ { PVEC_SUBR, \
{ .a ## maxargs = fnname }, \
minargs, maxargs, lname, intspec, 0}; \
Lisp_Object fnname
#define DEFVAR_KBOARD(lname, vname, doc) \
do { \
static struct Lisp_Kboard_Objfwd ko_fwd; \
- defvar_kboard (&ko_fwd, \
- lname, \
- (int)((char *)(¤t_kboard->vname ## _) \
- - (char *)current_kboard)); \
+ defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \
} while (0)
extern Lisp_Object Qcursor_in_echo_area;
extern Lisp_Object Qstring_lessp;
extern Lisp_Object QCsize, QCtest, QCweakness, Qequal, Qeq, Qeql;
+EMACS_UINT hash_string (char const *, ptrdiff_t);
EMACS_UINT sxhash (Lisp_Object, int);
Lisp_Object make_hash_table (Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object, Lisp_Object, Lisp_Object,
/* Defined in image.c */
extern Lisp_Object QCascent, QCmargin, QCrelief;
extern Lisp_Object QCconversion;
-extern int x_bitmap_mask (struct frame *, int);
+extern int x_bitmap_mask (struct frame *, ptrdiff_t);
extern void syms_of_image (void);
extern void init_image (void);
extern Lisp_Object Qinhibit_modification_hooks;
extern void move_gap (EMACS_INT);
extern void move_gap_both (EMACS_INT, EMACS_INT);
+extern void buffer_overflow (void) NO_RETURN;
extern void make_gap (EMACS_INT);
extern EMACS_INT copy_text (const unsigned char *, unsigned char *,
EMACS_INT, int, int);
Lisp_Object, Lisp_Object,
Lisp_Object, struct charset *,
unsigned, unsigned);
+extern Lisp_Object uniprop_table (Lisp_Object);
extern void syms_of_chartab (void);
/* Defined in print.c */
extern void syms_of_print (void);
/* Defined in doprnt.c */
-extern size_t doprnt (char *, size_t, const char *, const char *, va_list);
+extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *,
+ va_list);
/* Defined in lread.c. */
extern Lisp_Object Qvariable_documentation, Qstandard_input;
extern EMACS_INT emacs_write (int, const char *, EMACS_INT);
enum { READLINK_BUFSIZE = 1024 };
extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]);
-#ifndef HAVE_MEMSET
-extern void *memset (void *, int, size_t);
-#endif
-#ifndef HAVE_MEMCPY
-extern void *memcpy (void *, void *, size_t);
-#endif
-#ifndef HAVE_MEMMOVE
-extern void *memmove (void *, void *, size_t);
-#endif
-#ifndef HAVE_MEMCMP
-extern int memcmp (void *, void *, size_t);
-#endif
EXFUN (Funlock_buffer, 0);
extern void unlock_all_files (void);
#define SWITCH_ENUM_CAST(x) (x)
-/* Loop over Lisp list LIST. Signal an error if LIST is not a proper
- list, or if it contains circles.
-
- HARE and TORTOISE should be the names of Lisp_Object variables, and
- N should be the name of an EMACS_INT variable declared in the
- function where the macro is used. Each nested loop should use
- its own variables.
+/* Use this to suppress gcc's warnings. */
+#ifdef lint
- In the loop body, HARE is set to each cons of LIST, and N is the
- length of the list processed so far. */
+/* Use CODE only if lint checking is in effect. */
+# define IF_LINT(Code) Code
-#define LIST_END_P(list, obj) \
- (NILP (obj) \
- ? 1 \
- : (CONSP (obj) \
- ? 0 \
- : (wrong_type_argument (Qlistp, (list))), 1))
+/* Assume that the expression COND is true. This differs in intent
+ from 'assert', as it is a message from the programmer to the compiler. */
+# define lint_assume(cond) ((cond) ? (void) 0 : abort ())
-/* Use this to suppress gcc's `...may be used before initialized' warnings. */
-#ifdef lint
-# define IF_LINT(Code) Code
#else
# define IF_LINT(Code) /* empty */
+# define lint_assume(cond) ((void) (0 && (cond)))
#endif
/* The ubiquitous min and max macros. */
fixnum. */
#define make_fixnum_or_float(val) \
- (FIXNUM_OVERFLOW_P (val) \
- ? make_float (val) \
- : make_number ((EMACS_INT)(val)))
+ (FIXNUM_OVERFLOW_P (val) ? make_float (val) : make_number (val))
/* Checks the `cycle check' variable CHECK to see if it indicates that