From: Oleh Krehel <ohwoeowho@gmail.com>
To: emacs-devel@gnu.org
Subject: Is INLINE_HEADER_BEGIN still useful?
Date: Wed, 29 Apr 2015 13:21:59 +0200 [thread overview]
Message-ID: <87h9rzb2nc.fsf@gmail.com> (raw)
[-- 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
next reply other threads:[~2015-04-29 11:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 11:21 Oleh Krehel [this message]
2015-04-29 14:00 ` Is INLINE_HEADER_BEGIN still useful? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h9rzb2nc.fsf@gmail.com \
--to=ohwoeowho@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.