Bug 510895 - Select getc/getc_unlocked/_getc_nolock in autoconf. r=jimb.

--HG--
extra : rebase_source : 828e017e94ffd5f742d0ead3d48c42e7ad38eace
This commit is contained in:
Jason Orendorff 2009-08-25 12:33:03 -05:00
parent 345d4826bb
commit 40ac8532ae
2 changed files with 11 additions and 9 deletions

View File

@ -3115,9 +3115,10 @@ dnl Checks for library functions.
dnl ========================================================
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_CHECK_FUNCS([fchmod flockfile getpagesize lchown localtime_r lstat64 \
memmove random rint sbrk snprintf stat64 statvfs statvfs64 \
strerror strtok_r truncate64])
AC_CHECK_FUNCS([fchmod flockfile getc_unlocked _getc_nolock getpagesize \
lchown localtime_r lstat64 memmove random rint sbrk snprintf \
stat64 statvfs statvfs64 strerror strtok_r truncate64])
dnl Windows functions, for mingw.
AC_TRY_LINK([#include <windows.h>],

View File

@ -226,12 +226,13 @@ JSTokenStream::close(JSContext *cx)
cx->free((void *) filename);
}
#ifdef XP_WIN
#ifdef WINCE
#define getc_unlocked getc
/* Use the fastest available getc. */
#if defined(HAVE_GETC_UNLOCKED)
#define fast_getc getc_unlocked
#elif defined(HAVE__GETC_NOLOCK)
#define fast_getc _getc_nolock
#else
#define getc_unlocked _getc_nolock
#endif
#define fast_getc getc
#endif
JS_FRIEND_API(int)
@ -245,7 +246,7 @@ js_fgets(char *buf, int size, FILE *file)
return -1;
crflag = JS_FALSE;
for (i = 0; i < n && (c = getc_unlocked(file)) != EOF; i++) {
for (i = 0; i < n && (c = fast_getc(file)) != EOF; i++) {
buf[i] = c;
if (c == '\n') { /* any \n ends a line */
i++; /* keep the \n; we know there is room for \0 */