summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-08-29 05:58:49 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-08-29 05:58:49 +0300
commitaf43bad53b2f05ba0d4403a59433f587a1e32b22 (patch)
tree3140c3e94c82bb687009bdcf547786b73f3f276b
parent00682d87a1a1c0535c0fa5adb27867578dc76d49 (diff)
downloadgawk-af43bad53b2f05ba0d4403a59433f587a1e32b22.tar.gz
Use fwrite_unlocked if it exists. Nice speedup in output.
-rw-r--r--ChangeLog6
-rw-r--r--NEWS3
-rw-r--r--TODO2
-rw-r--r--awk.h4
-rw-r--r--configh.in3
-rwxr-xr-xconfigure1
-rw-r--r--configure.ac1
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 <aharon.robbins@intel.com>
+
+ * 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 <arnold@skeeve.com>
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 \