This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH] Time-Hires: Fix declaration-after-statement error with darwin threads
authorReini Urban <rurban@cpanel.net>
Mon, 18 Apr 2016 07:38:13 +0000 (09:38 +0200)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 23 Apr 2016 15:43:40 +0000 (11:43 -0400)
rt #113856: the flag -Werror=declaration-after-statement is seemingly
not working for clang (in OS X, not yet tested elsewhere), but working
as intended for gcc.  Since the system cc for OS X is clang (via Apple),
this failure to fail has been masked.

To restate: without this patch the Time-HiRes does not build in OS X
with gcc under usethreads.

dist/Time-HiRes/HiRes.xs

index 8b8f25c..38ca0dc 100644 (file)
@@ -767,11 +767,11 @@ static mach_timebase_info_data_t timebase_info;
 static struct timespec timespec_init;
 
 static int darwin_time_init() {
+  struct timeval tv;
+  int success = 1;
 #ifdef USE_ITHREADS
   MUTEX_LOCK(&darwin_time_mutex);
 #endif
-  struct timeval tv;
-  int success = 1;
   if (absolute_time_init == 0) {
     /* mach_absolute_time() cannot fail */
     absolute_time_init = mach_absolute_time();