Initialize the return object to Qnil
[sxemacs] / src / lisp.h
1 /* Fundamental definitions for SXEmacs Lisp interpreter.
2    Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc.
3    Copyright (C) 1993-1996 Richard Mlynarik.
4    Copyright (C) 1995, 1996, 2000 Ben Wing.
5    Copyright (C) 2004 Steve Youngs.
6
7 This file is part of SXEmacs
8
9 SXEmacs 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 SXEmacs 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 this program.  If not, see <http://www.gnu.org/licenses/>. */
21
22
23 /* Synched up with: FSF 19.30. */
24
25 #ifndef INCLUDED_lisp_h_
26 #define INCLUDED_lisp_h_
27
28 /************************************************************************/
29 /*                        general definitions                           */
30 /************************************************************************/
31
32 /* ------------------------ include files ------------------- */
33
34 /* We include the following generally useful header files so that you
35    don't have to worry about prototypes when using the standard C
36    library functions and macros.  These files shouldn't be excessively
37    large so they shouldn't cause that much of a slowdown. */
38
39 #include <stdlib.h>
40 #include <string.h>             /* primarily for memcpy, etc. */
41 #include <stdio.h>              /* NULL, etc. */
42 #include <ctype.h>
43 #include <stdarg.h>
44 #include <stddef.h>             /* offsetof */
45 #include <sys/types.h>
46 #include <limits.h>
47 #if defined HAVE_STDBOOL_H
48 # include <stdbool.h>
49 #endif
50
51 /* goodies */
52 #ifdef UNUSED
53 #elif defined(__GNUC__)
54 # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
55 #elif defined(__LCLINT__)
56 # define UNUSED(x) /*@unused@*/ x
57 #else
58 # define UNUSED(x) x
59 #endif
60
61 #ifdef WEAK_EXTERN
62 #elif defined(__GNUC__)
63 # define WEAK_EXTERN    extern __attribute__((weak))
64 #else
65 # error "Grrr, bloody 'ell, can't figure out how to create weak symbols"
66 #endif
67
68 #ifdef WEAK
69 #elif defined(__GNUC__)
70 # define WEAK           __attribute__((weak))
71 #else
72 # error "Grrr, bloody 'ell, can't figure out how to create weak symbols"
73 #endif
74
75
76 #ifdef LIKELY
77 #else
78 #define LIKELY(_x)      __builtin_expect(!!(_x), 1)
79 #endif
80 #ifdef UNLIKELY
81 #else
82 #define UNLIKELY(_x)    __builtin_expect(!!(_x), 0)
83 #endif
84
85 #if defined SXE_STATIC_EXTERN_INLINE
86 # define extern_inline  static inline
87 #elif !defined __GNUC_STDC_INLINE__ && !defined SXE_INLINE_NO_EXTERN
88 # define extern_inline  extern inline
89 #else
90 # define extern_inline  inline
91 #endif
92
93 #ifdef ALL_DEBUG_FLAGS
94 #undef SXE_DEBUG_FLAG
95 #define SXE_DEBUG_FLAG
96 #endif
97
98 #define __SXE_DEBUG__(args...)          fprintf(stderr, "SXE " args)
99 #ifndef SXE_DEBUG_FLAG
100 #define SXE_DEBUG(args...)
101 #else
102 #define SXE_DEBUG(args...)              __SXE_DEBUG__(args)
103 #endif
104 #define SXE_DEBUG_PT(args...)           SXE_DEBUG("[pthread]: " args)
105 #define SXE_CRITICAL(args...)           __SXE_DEBUG__("CRITICAL: " args)
106
107
108
109 /* We define assert iff USE_ASSERTIONS or DEBUG_SXEMACS is defined.
110    Otherwise we define it to be empty.  Quantify has shown that the
111    time the assert checks take is measurable so let's not include them
112    in production binaries. */
113
114 #ifdef USE_ASSERTIONS
115 /* Highly dubious kludge */
116 /*   (thanks, Jamie, I feel better now -- ben) */
117 void assert_failed(const char *, int, const char *);
118 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
119 # define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
120 #else
121 # ifdef DEBUG_SXEMACS
122 #  define assert(x) ((x) ? (void) 0 : (void) abort ())
123 # else
124 #  define assert(x)
125 # endif
126 #endif
127
128 /* from c.ac */
129 #ifndef BITS_PER_CHAR
130 #define BITS_PER_CHAR 8
131 #endif
132 #define SXE_SHORTBITS (SIZEOF_SHORT * BITS_PER_CHAR)
133 #define SXE_INTBITS (SIZEOF_INT * BITS_PER_CHAR)
134 #define SXE_LONGBITS (SIZEOF_LONG * BITS_PER_CHAR)
135 #define SXE_LONG_LONG_BITS (SIZEOF_LONG_LONG_INT * BITS_PER_CHAR)
136 #define SXE_VOID_P_BITS (SIZEOF_VOID_P * BITS_PER_CHAR)
137
138
139 /* ------------------------ dynamic arrays ------------------- */
140
141 #define Dynarr_declare(type)    \
142   type *base;                   \
143   int elsize;                   \
144   int cur;                      \
145   int largest;                  \
146   int max
147
148 typedef struct dynarr {
149         Dynarr_declare(void);
150 } Dynarr;
151
152 void *Dynarr_newf(int elsize);
153 void Dynarr_resize(void *dy, int size);
154 void Dynarr_insert_many(void *d, const void *el, int len, int start);
155 void Dynarr_delete_many(void *d, int start, int len);
156 void Dynarr_free(void *d);
157
158 #define Dynarr_new(type) ((type##_dynarr *) Dynarr_newf (sizeof (type)))
159 #define Dynarr_new2(dynarr_type, type) \
160   ((dynarr_type *) Dynarr_newf (sizeof (type)))
161 #define Dynarr_at(d, pos) ((d)->base[pos])
162 #define Dynarr_atp(d, pos) (&Dynarr_at (d, pos))
163 #define Dynarr_begin(d) Dynarr_atp (d, 0)
164 #define Dynarr_end(d) Dynarr_atp (d, Dynarr_length (d) - 1)
165 #define Dynarr_sizeof(d) ((d)->cur * (d)->elsize)
166 #define Dynarr_length(d) ((d)->cur)
167 #define Dynarr_largest(d) ((d)->largest)
168 #define Dynarr_reset(d) ((d)->cur = 0)
169 #define Dynarr_add_many(d, el, len) Dynarr_insert_many (d, el, len, (d)->cur)
170 #define Dynarr_insert_many_at_start(d, el, len) \
171   Dynarr_insert_many (d, el, len, 0)
172 #define Dynarr_add_literal_string(d, s) Dynarr_add_many (d, s, sizeof (s) - 1)
173 #define Dynarr_add_lisp_string(d, s) do {               \
174   Lisp_String *dyna_ls_s = XSTRING (s);                 \
175   Dynarr_add_many (d, (char *) string_data (dyna_ls_s), \
176                    string_length (dyna_ls_s));          \
177 } while (0)
178
179 #define Dynarr_add(d, el) (                                             \
180   (d)->cur >= (d)->max ? Dynarr_resize ((d), (d)->cur+1) : (void) 0,    \
181   ((d)->base)[(d)->cur++] = (el),                                       \
182   (d)->cur > (d)->largest ? (d)->largest = (d)->cur : (int) 0)
183
184 /* The following defines will get you into real trouble if you aren't
185    careful.  But they can save a lot of execution time when used wisely. */
186 #define Dynarr_increment(d) ((d)->cur++)
187 #define Dynarr_set_size(d, n) ((d)->cur = n)
188
189 #ifdef MEMORY_USAGE_STATS
190 struct overhead_stats;
191 size_t Dynarr_memory_usage(void *d, struct overhead_stats *stats);
192 #endif
193
194 /* Also define min() and max(). (Some compilers put them in strange
195    places that won't be referenced by the above include files, such
196    as 'macros.h' under Solaris.) */
197
198 #ifndef min
199 #define min(a,b) (((a) <= (b)) ? (a) : (b))
200 #endif
201 #ifndef max
202 #define max(a,b) (((a) > (b)) ? (a) : (b))
203 #endif
204
205 \f
206 /************************************************************************/
207 /*                                Memory                                */
208 /************************************************************************/
209
210 #ifdef ALL_DEBUG_FLAGS
211 #undef GC_DEBUG_FLAG
212 #define GC_DEBUG_FLAG
213 #endif
214
215 #if !defined GC_DEBUG_FLAG
216 # define SXE_DEBUG_GC(args...)
217 #else
218 # define SXE_DEBUG_GC(args...)          __SXE_DEBUG__("[gc] " args)
219 #endif
220 #define SXE_DEBUG_GC_PT(args...)        SXE_DEBUG_GC("[pthread]: " args)
221 #define SXE_CRITICAL_GC(args...)        __SXE_DEBUG__("[gc] CRITICAL: " args)
222
223 void malloc_warning(const char *);
224
225 #if defined HAVE_BDWGC && defined EF_USE_BDWGC
226 # if defined HAVE_THREADS
227 #  if !defined GC_PTHREADS
228 #   define GC_PTHREADS  1
229 #  endif  /* !GC_PTHREADS */
230 #  if !defined GC_THREADS
231 #   define GC_THREADS   1
232 #  endif  /* !GC_THREADS */
233 # endif  /* HAVE_THREADS */
234
235 # undef GC_DEBUG
236 # if defined GC_DEBUG_FLAG
237 #  define GC_DEBUG      1
238 # endif  /* GC_DEBUG_FLAG */
239 # if defined HAVE_GC_GC_H
240 #  include <gc/gc.h>
241 # elif defined HAVE_GC_H
242 #  include <gc.h>
243 # else
244 #  error "Take less of those pills!"
245 # endif
246
247 # if defined GC_DEBUG_FLAG
248 #  define zmalloc               GC_MALLOC_IGNORE_OFF_PAGE
249 #  define zcalloc(n, m) GC_MALLOC((n)*(m))
250 #  define zmalloc_atomic        GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE
251 #  define zmalloc_and_zero      GC_MALLOC
252 #  define zrealloc              GC_REALLOC
253 #  define zstrdup               GC_STRDUP
254 #  undef zfree
255 #  define zfree(x)              GC_FREE(x)
256 # else  /* !GC_DEBUG_FLAG */
257 #  define zmalloc               GC_malloc_ignore_off_page
258 #  define zcalloc(n, m)         GC_malloc((n)*(m))
259 #  define zmalloc_atomic        GC_malloc_atomic_ignore_off_page
260 #  define zmalloc_and_zero      GC_malloc
261 #  define zrealloc              GC_realloc
262 #  define zstrdup               GC_strdup
263 #  undef zfree
264 #  define zfree(x)
265 # endif /* GC_DEBUG_FLAG */
266
267 #else  /* !BDWGC */
268 #define zmalloc         F&^!
269 #define zcalloc         F&^!
270 #define zmalloc_atomic  F&^!
271 #define zmalloc_and_zero        F&^!
272 #define zrealloc        F&^!
273 #define zstrdrup        F&^!
274 #endif  /* BDWGC */
275
276 /* also define libc mem funs */
277 #define ymalloc         malloc
278 #define ycalloc(n, m)   calloc(n, m)
279 #define ymalloc_atomic(n)       ycalloc(1, n)
280 #define ymalloc_and_zero(x)     ycalloc(1, x)
281 #define yrealloc        realloc
282 #define ystrdup         strdup
283 #define yfree(x)        free(x)
284 /* and their convenience companions */
285 #define ynew(type)              ((type*)ymalloc(sizeof(type)))
286 #define ynew_array(type, len)   ((type*)ymalloc((len) * sizeof(type)))
287 #define ynew_and_zero(type)     ((type*)ymalloc_and_zero(sizeof(type)))
288 #define ynew_array_and_zero(type, len)                  \
289         ((type*)ymalloc_and_zero((len) * sizeof(type)))
290 #define YREALLOC_ARRAY(ptr, type, len)                                  \
291         ((void)(ptr = (type *)yrealloc(ptr, (len) * sizeof (type))))
292
293 #if defined HAVE_BDWGC && defined EF_USE_BDWGC
294 /* and now the x* series */
295 # define xmalloc                zmalloc
296 # define xcalloc                zcalloc
297 # define xmalloc_atomic         zmalloc_atomic
298 # define xmalloc_and_zero       zmalloc_and_zero
299 # define xrealloc               zrealloc
300 # define xstrdup                zstrdup
301 # if defined ERROR_CHECK_MALLOC
302 #  define xfree(args...)        zfree(args)
303 # else  /* !ERROR_CHECK_MALLOC */
304 #  define xfree(args...)
305 # endif  /* ERROR_CHECK_MALLOC */
306
307 #else  /* !BDWGC */
308 void *xmalloc(size_t size);
309 void *xmalloc_atomic(size_t size);
310 void *xmalloc_and_zero(size_t size);
311 void *xrealloc(void *, size_t size);
312 char *xstrdup(const char *);
313 # if defined ERROR_CHECK_MALLOC
314 #  if SIZEOF_VOID_P == 4
315 #   define xfree(lvalue)                                        \
316         do {                                                    \
317                 void *volatile *xfree_ptr =                     \
318                         (void *volatile*)                       \
319                         ((volatile void*)&(lvalue));            \
320                 assert(*xfree_ptr != (void*)0xB00BB4BE);        \
321                 yfree(*xfree_ptr);                              \
322                 *xfree_ptr = (void*)0xB00BB4BE;                 \
323         } while (0)
324 #  elif SIZEOF_VOID_P == 8
325 #   define xfree(lvalue)                                                        \
326         do {                                                            \
327                 void *volatile *xfree_ptr =                             \
328                         (void *volatile*)                               \
329                         ((volatile void*)&(lvalue));                    \
330                 assert(*xfree_ptr != (void*)0xCAFEBABEDEADBEEF);        \
331                 yfree(*xfree_ptr);                                      \
332                 *xfree_ptr = (void*)0xCAFEBABEDEADBEEF;                 \
333         } while (0)
334 #  else  /* huh? */
335 #   error "Strange-arse system detected.  Watch a movie, it\'s more fun!"
336 #  endif
337 # else  /* !ERROR_CHECK_MALLOC */
338 #  define xfree(args...)        yfree(args)
339 # endif  /* ERROR_CHECK_MALLOC */
340 #endif  /* BDWGC */
341
342 /* generally useful */
343 #define countof(x) ((int) (sizeof(x)/sizeof((x)[0])))
344 #define xnew(type) ((type *) xmalloc (sizeof (type)))
345 #define xnew_atomic(type) ((type *) xmalloc_atomic (sizeof (type)))
346 #define xnew_array(type, len) ((type *) xmalloc ((len) * sizeof (type)))
347 #define xnew_atomic_array(type, len)                    \
348         ((type*)xmalloc_atomic((len) * sizeof(type)))
349 #define xnew_and_zero(type) ((type *) xmalloc_and_zero (sizeof (type)))
350 #define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
351 #define xnew_array_and_zero(type, len)                          \
352         ((type*)xmalloc_and_zero ((len) * sizeof (type)))
353 #define xrealloc_array(ptr, type, len)                          \
354         ((void) (ptr = (type *) xrealloc (ptr, (len) * sizeof (type))))
355 #define XREALLOC_ARRAY          xrealloc_array
356 #define alloca_array(type, len) ((type *) alloca ((len) * sizeof (type)))
357
358 #if !defined HAVE_DECL_STRDUP
359 extern char *strdup(const char *s);
360 #endif  /* HAVE_DECL_STRDUP */
361
362 #ifndef PRINTF_ARGS
363 # if defined (__GNUC__) && (__GNUC__ >= 2)
364 #  define PRINTF_ARGS(string_index,first_to_check) \
365           __attribute__ ((format (printf, string_index, first_to_check)))
366 # else
367 #  define PRINTF_ARGS(string_index,first_to_check)
368 # endif                         /* GNUC */
369 #endif
370
371 #ifndef DOESNT_RETURN
372 # if defined __GNUC__
373 #  if ((__GNUC__ > 2) || (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))
374 #   define DOESNT_RETURN void
375 #   define DECLARE_DOESNT_RETURN(decl) \
376            extern void decl __attribute__ ((noreturn))
377 #   define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
378      /* Should be able to state multiple independent __attribute__s, but  \
379         the losing syntax doesn't work that way, and screws losing cpp */ \
380            extern void decl \
381                   __attribute__ ((noreturn, format (printf, str, idx)))
382 #  else
383 #   define DOESNT_RETURN void volatile
384 #   define DECLARE_DOESNT_RETURN(decl) extern void volatile decl
385 #   define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
386            extern void volatile decl PRINTF_ARGS(str,idx)
387 #  endif                        /* GNUC 2.5 */
388 # else
389 #  define DOESNT_RETURN void
390 #  define DECLARE_DOESNT_RETURN(decl) extern void decl
391 #  define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
392           extern void decl PRINTF_ARGS(str,idx)
393 # endif                         /* GNUC */
394 #endif
395
396 /* No type has a greater alignment requirement than max_align_t.
397    (except perhaps for types we don't use, like long double) */
398 typedef union {
399         struct {
400                 long l;
401         } l;
402         struct {
403                 void *p;
404         } p;
405         struct {
406                 void (*f) (void);
407         } f;
408         struct {
409                 double d;
410         } d;
411 } max_align_t;
412
413 #ifndef ALIGNOF
414 # if defined (__GNUC__) && (__GNUC__ >= 2)
415 /* gcc has an extension that gives us exactly what we want. */
416 #  define ALIGNOF(type) __alignof__ (type)
417 # elif ! defined (__cplusplus)
418 /* The following is mostly portable, except that:
419    - it doesn't work for inside out declarations like void (*) (void).
420      (so just call ALIGNOF with a typedef'ed name)
421    - it doesn't work with C++.  The C++ committee has decided,
422      in its infinite wisdom, that:
423      "Types must be declared in declarations, not in expressions." */
424 #  define ALIGNOF(type) offsetof (struct { char c; type member; }, member)
425 # else
426 /* C++ is annoying, but it has a big bag of tricks.
427    The following doesn't have the "inside out" declaration bug C does. */
428 template < typename T > struct alignment_trick {
429         char c;
430         T member;
431 };
432 #  define ALIGNOF(type) offsetof (alignment_trick<type>, member)
433 # endif
434 #endif                          /* ALIGNOF */
435
436 #define ALIGN_SIZE(len, unit) \
437   ((((len) + (unit) - 1) / (unit)) * (unit))
438
439 /* #### Yuck, this is kind of evil */
440 #define ALIGN_PTR(ptr, unit) \
441   ((void *) ALIGN_SIZE ((size_t) (ptr), unit))
442
443 #ifndef DO_NOTHING
444 #define DO_NOTHING do {} while (0)
445 #endif
446
447 #ifndef DECLARE_NOTHING
448 #define DECLARE_NOTHING struct nosuchstruct
449 #endif
450
451 /*#ifdef DEBUG_SXEMACS*/
452 #define REGISTER
453 #define register
454 /*#else*/
455 /*#define REGISTER register*/
456 /*#endif*/
457
458 /* EMACS_INT is the underlying integral type into which a Lisp_Object must fit.
459    In particular, it must be large enough to contain a pointer.
460    config.h can override this, e.g. to use `long long' for bigger lisp ints.
461
462    #### In point of fact, it would NOT be a good idea for config.h to mess
463    with EMACS_INT.  A lot of code makes the basic assumption that EMACS_INT
464    is the size of a pointer. */
465
466 #ifndef SIZEOF_EMACS_INT
467 # define SIZEOF_EMACS_INT SIZEOF_VOID_P
468 #endif
469
470 #ifndef EMACS_INT
471 # if   SIZEOF_EMACS_INT == SIZEOF_LONG
472 #  define EMACS_INT long
473 # elif SIZEOF_EMACS_INT == SIZEOF_INT
474 #  define EMACS_INT int
475 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG_INT
476 #  define EMACS_INT long long
477 # else
478 #  error Unable to determine suitable type for EMACS_INT
479 # endif
480 #endif
481
482 #ifndef EMACS_UINT
483 # define EMACS_UINT unsigned EMACS_INT
484 #endif
485
486 #define BITS_PER_EMACS_INT (SIZEOF_EMACS_INT * BITS_PER_CHAR)
487 \f
488 /************************************************************************/
489 /*                                typedefs                              */
490 /************************************************************************/
491
492 /* We put typedefs here so that prototype declarations don't choke.
493    Note that we don't actually declare the structures here (except
494    maybe for simple structures like Dynarrs); that keeps them private
495    to the routines that actually use them. */
496
497 /* ------------------------------- */
498 /*     basic char/int typedefs     */
499 /* ------------------------------- */
500
501 /* The definitions we put here use typedefs to attribute specific meaning
502    to types that by themselves are pretty general.  Stuff pointed to by a
503    char * or unsigned char * will nearly always be one of four types:
504    a) pointer to internally-formatted text; b) pointer to text in some
505    external format, which can be defined as all formats other than the
506    internal one; c) pure ASCII text; d) binary data that is not meant to
507    be interpreted as text. [A fifth possible type "e) a general pointer
508    to memory" should be replaced with void *.]  Using these more specific
509    types rather than the general ones helps avoid the confusions that
510    occur when the semantics of a char * argument being studied are unclear. */
511
512 typedef unsigned char UChar;
513
514 /* The data representing the text in a buffer is logically a set
515    of Bufbytes, declared as follows. */
516
517 typedef UChar Bufbyte;
518
519 /* Explicitly signed or unsigned versions: */
520 typedef UChar UBufbyte;
521 typedef char SBufbyte;
522
523 /* The data representing a string in "external" format (binary or any
524    external encoding) is logically a set of Extbytes, declared as
525    follows.  Extbyte is guaranteed to be just a char, so for example
526    strlen (Extbyte *) is OK.  Extbyte is only a documentation device
527    for referring to external text. */
528
529 typedef char Extbyte;
530
531 /* A byte in a string in binary format: */
532 typedef char Char_Binary;
533 typedef UChar UChar_Binary;
534
535 /* A byte in a string in entirely US-ASCII format: (Nothing outside
536  the range 00 - 7F) */
537
538 typedef char Char_ASCII;
539 typedef UChar UChar_ASCII;
540
541 /* To the user, a buffer is made up of characters, declared as follows.
542    In the non-Mule world, characters and Bufbytes are equivalent.
543    In the Mule world, a character requires (typically) 1 to 4
544    Bufbytes for its representation in a buffer. */
545
546 typedef int Emchar;
547
548 /* Different ways of referring to a position in a buffer.  We use
549    the typedefs in preference to 'EMACS_INT' to make it clearer what
550    sort of position is being used.  See extents.c for a description
551    of the different positions.  We put them here instead of in
552    buffer.h (where they rightfully belong) to avoid syntax errors
553    in function prototypes. */
554
555 typedef EMACS_INT Bufpos;
556 typedef EMACS_INT Bytind;
557 typedef EMACS_INT Memind;
558
559 /* Counts of bytes or chars */
560
561 typedef EMACS_INT Bytecount;
562 typedef EMACS_INT Charcount;
563
564 /* Length in bytes of a string in external format */
565 typedef EMACS_INT Extcount;
566
567 /* ------------------------------- */
568 /*     structure/other typedefs    */
569 /* ------------------------------- */
570
571 /* Counts of bytes or array elements */
572 typedef EMACS_INT Memory_count;
573 typedef EMACS_INT Element_count;
574
575 /* is this right here? */
576 typedef struct lstream_s *lstream_t;
577 /* deprecated */
578 typedef struct lstream_s Lstream;
579
580 typedef unsigned int face_index;
581
582 typedef struct {
583         Dynarr_declare(struct face_cachel);
584 } face_cachel_dynarr;
585
586 typedef unsigned int glyph_index;
587
588 /* This is shared by process.h, events.h and others in future.
589    See events.h for description */
590 typedef long unsigned int USID;
591
592 typedef struct {
593         Dynarr_declare(struct glyph_cachel);
594 } glyph_cachel_dynarr;
595
596 struct buffer;                  /* "buffer.h" */
597 struct console;                 /* "console.h" */
598 struct device;                  /* "device.h" */
599 struct extent_fragment;
600 struct extent;
601 typedef struct extent *EXTENT;
602 struct frame;                   /* "frame.h" */
603 struct window;                  /* "window.h" */
604 typedef struct Lisp_Event Lisp_Event;   /* "events.h" */
605 typedef struct Lisp_Face Lisp_Face;     /* "faces.h" */
606 typedef struct Lisp_Process Lisp_Process;       /* "procimpl.h" */
607 struct stat;                    /* <sys/stat.h> */
608 typedef struct Lisp_Color_Instance Lisp_Color_Instance;
609 typedef struct Lisp_Font_Instance Lisp_Font_Instance;
610 typedef struct Lisp_Image_Instance Lisp_Image_Instance;
611 typedef struct Lisp_Gui_Item Lisp_Gui_Item;
612 struct display_line;
613 struct display_glyph_area;
614 struct display_box;
615 struct redisplay_info;
616 struct window_mirror;
617 struct scrollbar_instance;
618 struct font_metric_info;
619 struct face_cachel;
620 struct console_type_entry;
621
622 typedef struct {
623         Dynarr_declare(Bufbyte);
624 } Bufbyte_dynarr;
625
626 typedef struct {
627         Dynarr_declare(Extbyte);
628 } Extbyte_dynarr;
629
630 typedef struct {
631         Dynarr_declare(Emchar);
632 } Emchar_dynarr;
633
634 typedef struct {
635         Dynarr_declare(char);
636 } char_dynarr;
637
638 typedef unsigned char unsigned_char;
639 typedef struct {
640         Dynarr_declare(unsigned char);
641 } unsigned_char_dynarr;
642
643 typedef unsigned long unsigned_long;
644 typedef struct {
645         Dynarr_declare(unsigned long);
646 } unsigned_long_dynarr;
647
648 typedef struct {
649         Dynarr_declare(int);
650 } int_dynarr;
651
652 typedef struct {
653         Dynarr_declare(Bufpos);
654 } Bufpos_dynarr;
655
656 typedef struct {
657         Dynarr_declare(Bytind);
658 } Bytind_dynarr;
659
660 typedef struct {
661         Dynarr_declare(Charcount);
662 } Charcount_dynarr;
663
664 typedef struct {
665         Dynarr_declare(Bytecount);
666 } Bytecount_dynarr;
667
668 typedef struct {
669         Dynarr_declare(struct console_type_entry);
670 } console_type_entry_dynarr;
671
672 enum run_hooks_condition {
673         RUN_HOOKS_TO_COMPLETION,
674         RUN_HOOKS_UNTIL_SUCCESS,
675         RUN_HOOKS_UNTIL_FAILURE
676 };
677
678 #ifdef HAVE_TOOLBARS
679 enum toolbar_pos {
680         TOP_TOOLBAR,
681         BOTTOM_TOOLBAR,
682         LEFT_TOOLBAR,
683         RIGHT_TOOLBAR
684 };
685 #endif
686
687 enum edge_style {
688         EDGE_ETCHED_IN,
689         EDGE_ETCHED_OUT,