unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Is INLINE_HEADER_BEGIN still useful?
@ 2015-04-29 11:21 Oleh Krehel
  2015-04-29 14:00 ` Paul Eggert
  0 siblings, 1 reply; 6+ messages in thread
From: Oleh Krehel @ 2015-04-29 11:21 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]


Hi all,

This macro, encountered in most headers, seems to work around some
compilers not supporting C99.  A quick internet search shows that no
other software except Emacs uses this (any more, I assume some did in
the past).

Is it still useful? If not, it unnecessarily complicates the header
structure and should be removed.

I attach an example patch for only buffer.h that compiles and works
well.

Also, what's the stance on C11? I don't know a lot of C outside of what
C++ includes, but I'm considering to learn more of it just for Emacs.
Is C11 encouraged / allowed / discouraged / disallowed?

I assume that C99 is at least allowed since #17487. Is it encouraged?
In that case, surely INLINE_HEADER_BEGIN should be removed.

Oleh


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Remove-INLINE_HEADER_BEGIN-in-buffer.h.patch --]
[-- Type: text/x-diff, Size: 7669 bytes --]

From 6da130ba276a9c7f0f13b5993cace8f943cb7334 Mon Sep 17 00:00:00 2001
From: Oleh Krehel <ohwoeowho@gmail.com>
Date: Wed, 29 Apr 2015 13:11:18 +0200
Subject: [PATCH] Remove INLINE_HEADER_BEGIN in buffer.h

---
 src/buffer.h | 80 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 38 insertions(+), 42 deletions(-)

diff --git a/src/buffer.h b/src/buffer.h
index a0410d4..0a72154 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -21,8 +21,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/types.h>
 #include <time.h>
 
-INLINE_HEADER_BEGIN
-
 /* Accessing the parameters of the current buffer.  */
 
 /* These macros come in pairs, one for the char position
@@ -878,102 +876,102 @@ struct buffer
 /* 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.)  */
-INLINE void
+inline void
 bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
 {
   b->bidi_paragraph_direction_ = val;
 }
-INLINE void
+inline void
 bset_cache_long_scans (struct buffer *b, Lisp_Object val)
 {
   b->cache_long_scans_ = val;
 }
-INLINE void
+inline void
 bset_case_canon_table (struct buffer *b, Lisp_Object val)
 {
   b->case_canon_table_ = val;
 }
-INLINE void
+inline void
 bset_case_eqv_table (struct buffer *b, Lisp_Object val)
 {
   b->case_eqv_table_ = val;
 }
-INLINE void
+inline void
 bset_directory (struct buffer *b, Lisp_Object val)
 {
   b->directory_ = val;
 }
-INLINE void
+inline void
 bset_display_count (struct buffer *b, Lisp_Object val)
 {
   b->display_count_ = val;
 }
-INLINE void
+inline void
 bset_display_time (struct buffer *b, Lisp_Object val)
 {
   b->display_time_ = val;
 }
-INLINE void
+inline void
 bset_downcase_table (struct buffer *b, Lisp_Object val)
 {
   b->downcase_table_ = val;
 }
-INLINE void
+inline void
 bset_enable_multibyte_characters (struct buffer *b, Lisp_Object val)
 {
   b->enable_multibyte_characters_ = val;
 }
-INLINE void
+inline void
 bset_filename (struct buffer *b, Lisp_Object val)
 {
   b->filename_ = val;
 }
-INLINE void
+inline void
 bset_keymap (struct buffer *b, Lisp_Object val)
 {
   b->keymap_ = val;
 }
-INLINE void
+inline void
 bset_last_selected_window (struct buffer *b, Lisp_Object val)
 {
   b->last_selected_window_ = val;
 }
-INLINE void
+inline void
 bset_local_var_alist (struct buffer *b, Lisp_Object val)
 {
   b->local_var_alist_ = val;
 }
-INLINE void
+inline void
 bset_mark_active (struct buffer *b, Lisp_Object val)
 {
   b->mark_active_ = val;
 }
-INLINE void
+inline void
 bset_point_before_scroll (struct buffer *b, Lisp_Object val)
 {
   b->point_before_scroll_ = val;
 }
-INLINE void
+inline void
 bset_read_only (struct buffer *b, Lisp_Object val)
 {
   b->read_only_ = val;
 }
-INLINE void
+inline void
 bset_truncate_lines (struct buffer *b, Lisp_Object val)
 {
   b->truncate_lines_ = val;
 }
-INLINE void
+inline void
 bset_undo_list (struct buffer *b, Lisp_Object val)
 {
   b->undo_list_ = val;
 }
-INLINE void
+inline void
 bset_upcase_table (struct buffer *b, Lisp_Object val)
 {
   b->upcase_table_ = val;
 }
-INLINE void
+inline void
 bset_width_table (struct buffer *b, Lisp_Object val)
 {
   b->width_table_ = val;
@@ -1090,7 +1088,7 @@ extern void set_buffer_if_live (Lisp_Object);
 
 /* Return B as a struct buffer pointer, defaulting to the current buffer.  */
 
-INLINE struct buffer *
+inline struct buffer *
 decode_buffer (Lisp_Object b)
 {
   return NILP (b) ? current_buffer : (CHECK_BUFFER (b), XBUFFER (b));
@@ -1105,7 +1103,7 @@ decode_buffer (Lisp_Object b)
    windows than the selected one requires a select_window at some
    time, and that increments windows_or_buffers_changed.  */
 
-INLINE void
+inline void
 set_buffer_internal (struct buffer *b)
 {
   if (current_buffer != b)
@@ -1115,7 +1113,7 @@ set_buffer_internal (struct buffer *b)
 /* Arrange to go back to the original buffer after the next
    call to unbind_to if the original buffer is still alive.  */
 
-INLINE void
+inline void
 record_unwind_current_buffer (void)
 {
   record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
@@ -1150,7 +1148,7 @@ extern Lisp_Object Vbuffer_alist;
 
 /* Get text properties of B.  */
 
-INLINE INTERVAL
+inline INTERVAL
 buffer_intervals (struct buffer *b)
 {
   eassert (b->text != NULL);
@@ -1159,7 +1157,7 @@ buffer_intervals (struct buffer *b)
 
 /* Set text properties of B to I.  */
 
-INLINE void
+inline void
 set_buffer_intervals (struct buffer *b, INTERVAL i)
 {
   eassert (b->text != NULL);
@@ -1168,7 +1166,7 @@ set_buffer_intervals (struct buffer *b, INTERVAL i)
 
 /* Non-zero if current buffer has overlays.  */
 
-INLINE bool
+inline bool
 buffer_has_overlays (void)
 {
   return current_buffer->overlays_before || current_buffer->overlays_after;
@@ -1188,7 +1186,7 @@ buffer_has_overlays (void)
    the buffer to the next character after fetching this one.  Instead,
    use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH.  */
 
-INLINE int
+inline int
 FETCH_MULTIBYTE_CHAR (ptrdiff_t pos)
 {
   unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0)
@@ -1200,7 +1198,7 @@ FETCH_MULTIBYTE_CHAR (ptrdiff_t pos)
    If POS doesn't point the head of valid multi-byte form, only the byte at
    POS is returned.  No range checking.  */
 
-INLINE int
+inline int
 BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
 {
   unsigned char *p
@@ -1211,7 +1209,7 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
 
 /* Return number of windows showing B.  */
 
-INLINE int
+inline int
 buffer_window_count (struct buffer *b)
 {
   if (b->base_buffer)
@@ -1318,13 +1316,13 @@ extern int last_per_buffer_idx;
 /* Functions to get and set default value of the per-buffer
    variable at offset OFFSET in the buffer structure.  */
 
-INLINE Lisp_Object
+inline Lisp_Object
 per_buffer_default (int offset)
 {
   return *(Lisp_Object *)(offset + (char *) &buffer_defaults);
 }
 
-INLINE void
+inline void
 set_per_buffer_default (int offset, Lisp_Object value)
 {
   *(Lisp_Object *)(offset + (char *) &buffer_defaults) = value;
@@ -1333,20 +1331,20 @@ set_per_buffer_default (int offset, Lisp_Object value)
 /* Functions to get and set buffer-local value of the per-buffer
    variable at offset OFFSET in the buffer structure.  */
 
-INLINE Lisp_Object
+inline Lisp_Object
 per_buffer_value (struct buffer *b, int offset)
 {
   return *(Lisp_Object *)(offset + (char *) b);
 }
 
-INLINE void
+inline void
 set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
 {
   *(Lisp_Object *)(offset + (char *) b) = value;
 }
 
 /* Downcase a character C, or make no change if that cannot be done.  */
-INLINE int
+inline int
 downcase (int c)
 {
   Lisp_Object downcase_table = BVAR (current_buffer, downcase_table);
@@ -1355,10 +1353,10 @@ downcase (int c)
 }
 
 /* True if C is upper case.  */
-INLINE bool uppercasep (int c) { return downcase (c) != c; }
+inline bool uppercasep (int c) { return downcase (c) != c; }
 
 /* Upcase a character C known to be not upper case.  */
-INLINE int
+inline int
 upcase1 (int c)
 {
   Lisp_Object upcase_table = BVAR (current_buffer, upcase_table);
@@ -1367,13 +1365,11 @@ upcase1 (int c)
 }
 
 /* True if C is lower case.  */
-INLINE bool
+inline bool
 lowercasep (int c)
 {
   return !uppercasep (c) && upcase1 (c) != c;
 }
 
 /* Upcase a character C, or make no change if that cannot be done.  */
-INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
-
-INLINE_HEADER_END
+inline int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-29 17:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-29 11:21 Is INLINE_HEADER_BEGIN still useful? Oleh Krehel
2015-04-29 14:00 ` Paul Eggert
2015-04-29 14:12   ` Oleh Krehel
2015-04-29 15:07     ` Paul Eggert
2015-04-29 15:33       ` Oleh Krehel
2015-04-29 17:54         ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).