Commit f5b9c1e5 authored by Paul Eggert's avatar Paul Eggert

Reorder lisp.h to declare types before using them

This puts basic functions for types to be after the corresponding
type definitions.  This is a more-common programming style in C,
and will make it easier to port Emacs to gcc
-fcheck-pointer-bounds, since the functions now have access to the
corresponding types' sizes.  This patch does not change the code;
it just moves declarations and definitions and removes
no-longer-needed forward declarations (Bug#25128).
* src/buffer.c, src/data.c, src/image.c:
Include process.h, for PROCESSP.
* src/buffer.h (BUFFERP, CHECK_BUFFER, XBUFFER):
* src/process.h (PROCESSP, CHECK_PROCESS, XPROCESS):
* src/termhooks.h (TERMINALP, XTERMINAL):
* src/window.h (WINDOWP, CHECK_WINDOW, XWINDOW):
* src/thread.h (THREADP, CHECK_THREAD, XTHREAD, MUTEXP, CHECK_MUTEX)
(XMUTEX, CONDVARP, CHECK_CONDVAR, XCONDVAR):
Move here from lisp.h.
* src/intervals.h: Include buffer.h, for BUFFERP.
Include lisp.h, for Lisp_Object.
* src/lisp.h: Reorder declarations and definitions as described
above.  Move thread includes to be later, so that they can use the
reordered definitions.  Move some symbols to other headers (noted
elsewhere).  Remove forward decls that are no longer needed.
* src/thread.h: Include systhread.h here, not in lisp.h,
since lisp.h itself does not need systhread.h.
parent e5ef59b8
......@@ -32,6 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "intervals.h"
#include "process.h"
#include "systime.h"
#include "window.h"
#include "commands.h"
......
......@@ -881,6 +881,25 @@ struct buffer
Lisp_Object undo_list_;
};
INLINE bool
BUFFERP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_BUFFER);
}
INLINE void
CHECK_BUFFER (Lisp_Object x)
{
CHECK_TYPE (BUFFERP (x), Qbufferp, x);
}
INLINE struct buffer *
XBUFFER (Lisp_Object a)
{
eassert (BUFFERP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
/* Most code should use these functions to set Lisp fields in struct
buffer. (Some setters that are private to a single .c file are
defined as static in those files.) */
......
......@@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "character.h"
#include "buffer.h"
#include "keyboard.h"
#include "process.h"
#include "frame.h"
#include "keymap.h"
......
......@@ -36,6 +36,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "frame.h"
#include "process.h"
#include "window.h"
#include "buffer.h"
#include "dispextern.h"
......
......@@ -19,6 +19,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef EMACS_INTERVALS_H
#define EMACS_INTERVALS_H
#include "buffer.h"
#include "lisp.h"
INLINE_HEADER_BEGIN
/* Basic data type for use of intervals. */
......
This diff is collapsed.
......@@ -202,6 +202,25 @@ struct Lisp_Process
#endif
};
INLINE bool
PROCESSP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_PROCESS);
}
INLINE void
CHECK_PROCESS (Lisp_Object x)
{
CHECK_TYPE (PROCESSP (x), Qprocessp, x);
}
INLINE struct Lisp_Process *
XPROCESS (Lisp_Object a)
{
eassert (PROCESSP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
/* Every field in the preceding structure except for the first two
must be a Lisp_Object, for GC's sake. */
......
......@@ -654,6 +654,19 @@ struct terminal
void (*delete_terminal_hook) (struct terminal *);
};
INLINE bool
TERMINALP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_TERMINAL);
}
INLINE struct terminal *
XTERMINAL (Lisp_Object a)
{
eassert (TERMINALP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
/* Most code should use these functions to set Lisp fields in struct
terminal. */
INLINE void
......
......@@ -28,6 +28,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "sysselect.h" /* FIXME */
#include "systime.h" /* FIXME */
#include "systhread.h"
struct thread_state
{
......@@ -175,6 +176,25 @@ struct thread_state
struct thread_state *next_thread;
};
INLINE bool
THREADP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_THREAD);
}
INLINE void
CHECK_THREAD (Lisp_Object x)
{
CHECK_TYPE (THREADP (x), Qthreadp, x);
}
INLINE struct thread_state *
XTHREAD (Lisp_Object a)
{
eassert (THREADP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
/* A mutex in lisp is represented by a system condition variable.
The system mutex associated with this condition variable is the
global lock.
......@@ -203,6 +223,25 @@ struct Lisp_Mutex
lisp_mutex_t mutex;
};
INLINE bool
MUTEXP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_MUTEX);
}
INLINE void
CHECK_MUTEX (Lisp_Object x)
{
CHECK_TYPE (MUTEXP (x), Qmutexp, x);
}
INLINE struct Lisp_Mutex *
XMUTEX (Lisp_Object a)
{
eassert (MUTEXP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
/* A condition variable as a lisp object. */
struct Lisp_CondVar
{
......@@ -218,6 +257,25 @@ struct Lisp_CondVar
sys_cond_t cond;
};
INLINE bool
CONDVARP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_CONDVAR);
}
INLINE void
CHECK_CONDVAR (Lisp_Object x)
{
CHECK_TYPE (CONDVARP (x), Qcondition_variable_p, x);
}
INLINE struct Lisp_CondVar *
XCONDVAR (Lisp_Object a)
{
eassert (CONDVARP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
extern struct thread_state *current_thread;
extern void finalize_one_thread (struct thread_state *state);
......
......@@ -397,6 +397,25 @@ struct window
ptrdiff_t window_end_bytepos;
};
INLINE bool
WINDOWP (Lisp_Object a)
{
return PSEUDOVECTORP (a, PVEC_WINDOW);
}
INLINE void
CHECK_WINDOW (Lisp_Object x)
{
CHECK_TYPE (WINDOWP (x), Qwindowp, x);
}
INLINE struct window *
XWINDOW (Lisp_Object a)
{
eassert (WINDOWP (a));
return XUNTAG (a, Lisp_Vectorlike);
}
/* Most code should use these functions to set Lisp fields in struct
window. */
INLINE void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment