diff --git a/js/src/configure.in b/js/src/configure.in index a3400b6d7a62..14c6b30c8275 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -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 ], diff --git a/js/src/jsscan.cpp b/js/src/jsscan.cpp index 46f588795ef2..7cbd7ef3839f 100644 --- a/js/src/jsscan.cpp +++ b/js/src/jsscan.cpp @@ -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 */