-/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>.
+ <https://www.gnu.org/licenses/>.
As a special exception, if you link the code in this file with
files compiled with a GNU compiler to produce an executable,
#include "libioP.h"
int
-_IO_ungetc (c, fp)
- int c;
- _IO_FILE *fp;
+_IO_ungetc (int c, FILE *fp)
{
int result;
CHECK_FILE (fp, EOF);
if (c == EOF)
return EOF;
- _IO_acquire_lock (fp);
+ if (!_IO_need_lock (fp))
+ return _IO_sputbackc (fp, (unsigned char) c);
+ _IO_acquire_lock (fp);
result = _IO_sputbackc (fp, (unsigned char) c);
_IO_release_lock (fp);
return result;
}
-#ifdef weak_alias
weak_alias (_IO_ungetc, ungetc)
-#endif