summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@raeburn.org>2016-10-27 00:50:07 -0400
committerKen Raeburn <raeburn@raeburn.org>2017-06-21 22:34:33 -0400
commitefe200c10da02db68c6eeadc3cd82a8cc3108c96 (patch)
tree9d194249f93b74a18eef167efad5a5d9b1f06ce8
parent6af67b4a8842fd3b949fa5bfb68811f62a521ae2 (diff)
downloademacs-efe200c10da02db68c6eeadc3cd82a8cc3108c96.tar.gz
Use getc_unlocked.
* configure.ac: Check for getc_unlocked. * src/charset.c (read_hex, load_charset_map_from_file): Use getc_unlocked instead of getc. (getc_unlocked) [!HAVE_GETC_UNLOCKED]: Fall back to getc. * src/lread.c (readbyte_from_file, Fget_file_char, read1, getc_unlocked): Likewise.
-rw-r--r--configure.ac2
-rw-r--r--src/charset.c14
-rw-r--r--src/lread.c12
3 files changed, 18 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index 164454dff30..3fdcff5e7ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4218,7 +4218,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h)
AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
-AC_CHECK_FUNCS_ONCE([sbrk])
+AC_CHECK_FUNCS_ONCE([getc_unlocked sbrk])
ok_so_far=yes
AC_CHECK_FUNC(socket, , ok_so_far=no)
diff --git a/src/charset.c b/src/charset.c
index f0b41400843..9d15375dd79 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -198,6 +198,10 @@ static struct
#define GET_TEMP_CHARSET_WORK_DECODER(CODE) \
(temp_charset_work->table.decoder[(CODE)])
+
+#ifndef HAVE_GETC_UNLOCKED
+#define getc_unlocked getc
+#endif
/* Set to 1 to warn that a charset map is loaded and thus a buffer
@@ -416,15 +420,15 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
int c;
unsigned n;
- while ((c = getc (fp)) != EOF)
+ while ((c = getc_unlocked (fp)) != EOF)
{
if (c == '#')
{
- while ((c = getc (fp)) != EOF && c != '\n');
+ while ((c = getc_unlocked (fp)) != EOF && c != '\n');
}
else if (c == '0')
{
- if ((c = getc (fp)) == EOF || c == 'x')
+ if ((c = getc_unlocked (fp)) == EOF || c == 'x')
break;
}
}
@@ -434,7 +438,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
return 0;
}
n = 0;
- while (c_isxdigit (c = getc (fp)))
+ while (c_isxdigit (c = getc_unlocked (fp)))
{
if (INT_LEFT_SHIFT_OVERFLOW (n, 4))
*overflow = 1;
@@ -508,7 +512,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
from = read_hex (fp, &eof, &overflow);
if (eof)
break;
- if (getc (fp) == '-')
+ if (getc_unlocked (fp) == '-')
to = read_hex (fp, &eof, &overflow);
else
to = from;
diff --git a/src/lread.c b/src/lread.c
index a6d04ec5af7..b4ee3015e5d 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -72,6 +72,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define file_tell ftell
#endif
+#ifndef HAVE_GETC_UNLOCKED
+#define getc_unlocked getc
+#endif
+
/* The association list of objects read with the #n=object form.
Each member of the list has the form (n . object), and is used to
look up the object for the corresponding #n# construct.
@@ -445,7 +449,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
}
block_input ();
- c = getc (instream);
+ c = getc_unlocked (instream);
/* Interrupted reads have been observed while reading over the network. */
while (c == EOF && ferror (instream) && errno == EINTR)
@@ -454,7 +458,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
maybe_quit ();
block_input ();
clearerr (instream);
- c = getc (instream);
+ c = getc_unlocked (instream);
}
unblock_input ();
@@ -757,7 +761,7 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
{
register Lisp_Object val;
block_input ();
- XSETINT (val, getc (instream));
+ XSETINT (val, getc_unlocked (instream));
unblock_input ();
return val;
}
@@ -2901,7 +2905,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
/* Copy that many characters into saved_doc_string. */
block_input ();
for (i = 0; i < nskip && c >= 0; i++)
- saved_doc_string[i] = c = getc (instream);
+ saved_doc_string[i] = c = getc_unlocked (instream);
unblock_input ();
saved_doc_string_length = i;