[Ltrace-devel] [PATCH] Define _POSIX_C_SOURCE instead of _GNU_SOURCE to get open_memstream

Petr Machata pmachata at redhat.com
Fri Nov 23 12:30:06 UTC 2012


Drop dummy uses of struct timezone, which isn't defined under POSIX 2008.
---

 Would anyone, who has uClibc handy (probably Edgar or Sedat), check
 that the following doesn't break the build on their MIPSen?  We used to
 define _GNU_SOURCE to get open_memstream, but the more obvious fix
 should be to define _POSIX_C_SOURCE.

 This applies cleanly on top of both the current master and 0.7.0.

 Thank you,
 PM

 output.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/output.c b/output.c
index 9df8ae1..5464bc3 100644
--- a/output.c
+++ b/output.c
@@ -22,9 +22,8 @@
  * 02110-1301 USA
  */
 
-/* glibc before 2.10, eglibc and uClibc all need _GNU_SOURCE defined
- * for open_memstream to become visible.  */
-#define _GNU_SOURCE
+/* For open_memstream.  */
+#define _POSIX_C_SOURCE 200809L
 
 #include "config.h"
 
@@ -78,11 +77,10 @@ begin_of_line(Process *proc, int is_func, int indent)
 	}
 	if (opt_r) {
 		struct timeval tv;
-		struct timezone tz;
 		static struct timeval old_tv = { 0, 0 };
 		struct timeval diff;
 
-		gettimeofday(&tv, &tz);
+		gettimeofday(&tv, NULL);
 
 		if (old_tv.tv_sec == 0 && old_tv.tv_usec == 0) {
 			old_tv.tv_sec = tv.tv_sec;
@@ -102,9 +100,7 @@ begin_of_line(Process *proc, int is_func, int indent)
 	}
 	if (opt_t) {
 		struct timeval tv;
-		struct timezone tz;
-
-		gettimeofday(&tv, &tz);
+		gettimeofday(&tv, NULL);
 		if (opt_t > 2) {
 			current_column += fprintf(options.output, "%lu.%06d ",
 						  tv.tv_sec, (int)tv.tv_usec);
-- 
1.7.6.5



More information about the Ltrace-devel mailing list