From af43bad53b2f05ba0d4403a59433f587a1e32b22 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 29 Aug 2016 05:58:49 +0300 Subject: Use fwrite_unlocked if it exists. Nice speedup in output. --- ChangeLog | 6 ++++++ NEWS | 3 +++ TODO | 2 -- awk.h | 4 ++++ configh.in | 3 +++ configure | 1 + configure.ac | 1 + 7 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75d1bd37..023fa884 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-08-29 Aharon Robbins + + * configure.ac (fwrite_unlocked): Check for it. + * awk.h (fwrite): Define to fwrite_unlocked if we have it. + * NEWS: Make note of speed improvement. + 2016-08-25 Arnold D. Robbins POSIX now says use strcmp for == and !=. Thanks to Chet Ramey diff --git a/NEWS b/NEWS index e4ec58f3..7163ecff 100644 --- a/NEWS +++ b/NEWS @@ -76,6 +76,9 @@ Changes from 4.1.x to 4.2.0 19. The extension API now provides a mechanism for generating nonfatal error messages. +20. Gawk now uses fwrite_unlocked if it's available. The yields a 7% - 18% + improvement in raw output speed (gawk '{ print }' on a large file). + Changes from 4.1.3 to 4.1.4 --------------------------- diff --git a/TODO b/TODO index e9e5e192..bafb82c8 100644 --- a/TODO +++ b/TODO @@ -15,8 +15,6 @@ TODO Minor Cleanups and Code Improvements ------------------------------------ - Use fwrite_unlocked if available. Brings about 7% speedup for output. - API: ??? #if !defined(GAWK) && !defined(GAWK_OMIT_CONVENIENCE_MACROS) diff --git a/awk.h b/awk.h index 2234abf8..edd9cb95 100644 --- a/awk.h +++ b/awk.h @@ -178,6 +178,10 @@ extern void *memset_ulong(void *dest, int val, unsigned long l); #define memset memset_ulong #endif +#ifdef HAVE_FWRITE_UNLOCKED +#define fwrite fwrite_unlocked +#endif /* HAVE_FWRITE_UNLOCKED */ + #if defined(__EMX__) || defined(__MINGW32__) #include "nonposix.h" #endif /* defined(__EMX__) || defined(__MINGW32__) */ diff --git a/configh.in b/configh.in index 478f712b..41f63d4f 100644 --- a/configh.in +++ b/configh.in @@ -48,6 +48,9 @@ /* Define to 1 if you have the `fmod' function. */ #undef HAVE_FMOD +/* Define to 1 if you have the `fwrite_unlocked' function. */ +#undef HAVE_FWRITE_UNLOCKED + /* have getaddrinfo */ #undef HAVE_GETADDRINFO diff --git a/configure b/configure index c9955354..1fd6e4e8 100755 --- a/configure +++ b/configure @@ -9811,6 +9811,7 @@ esac # Need the check for mkstemp and tmpfile for missing_d/snprintf.c. for ac_func in __etoa_l atexit btowc fmod getgrent getgroups grantpt \ + fwrite_unlocked \ isascii iswctype iswlower iswupper mbrlen \ memcmp memcpy memcpy_ulong memmove memset \ memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \ diff --git a/configure.ac b/configure.ac index bfe785db..518a7398 100644 --- a/configure.ac +++ b/configure.ac @@ -264,6 +264,7 @@ esac # Need the check for mkstemp and tmpfile for missing_d/snprintf.c. AC_CHECK_FUNCS(__etoa_l atexit btowc fmod getgrent getgroups grantpt \ + fwrite_unlocked \ isascii iswctype iswlower iswupper mbrlen \ memcmp memcpy memcpy_ulong memmove memset \ memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \ -- cgit v1.2.3