diff --git libstuff/writeout.c libstuff/writeout.c index 50cbb8d..b1675e7 100644 --- libstuff/writeout.c +++ libstuff/writeout.c @@ -142,17 +142,25 @@ uint32_t *throttle) seen_archive = FALSE; #ifndef __OPENSTEP__ + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (__builtin_available(macOS 10.12, *)) { if (clock_gettime(CLOCK_REALTIME, &toc_timespec)) { system_error("clock_gettime failed"); return; } } else { +#endif + if (gettimeofday(&toc_timeval, NULL)) { system_error("gettimeofday failed"); return; } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 } +#endif + #else /* * The environment variable ZERO_AR_DATE is used here and other @@ -291,6 +299,8 @@ no_throttle: * have been zeroed out when the library was created. writeout * will not zero out the modification time in the filesystem. */ + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (__builtin_available(macOS 10.12, *)) { struct timespec times[2] = {0}; memcpy(×[0], &toc_timespec, sizeof(struct timespec)); @@ -298,11 +308,16 @@ no_throttle: time_result = utimensat(AT_FDCWD, output, times, 0); } else { +#endif struct timeval times[2] = {0}; memcpy(×[0], &toc_timeval, sizeof(struct timeval)); memcpy(×[1], &toc_timeval, sizeof(struct timeval)); time_result = utimes(output, times); + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 } +#endif + #else timep[0] = toc_time; timep[1] = toc_time; diff --git misc/libtool.c misc/libtool.c index bb18341..067f107 100644 --- misc/libtool.c +++ misc/libtool.c @@ -1325,6 +1325,7 @@ char **envp) /* remember common values used in the archive table of contents */ if (cmd_flags.D == FALSE && zero_ar_date == FALSE) { #ifndef __OPENSTEP__ +#if MAC_OS_X_VERSION_MAX_ALLOWED > 101300 if (__builtin_available(macOS 10.12, *)) { if (clock_gettime(CLOCK_REALTIME, &toc_timespec)) { system_fatal("clock_gettime failed"); @@ -1332,12 +1333,18 @@ char **envp) } toc_time = toc_timespec.tv_sec; } else { +#endif + if (gettimeofday(&toc_timeval, NULL)) { system_fatal("gettimeofday failed"); return(EXIT_FAILURE); } toc_time = toc_timeval.tv_sec; + +#if MAC_OS_X_VERSION_MAX_ALLOWED > 101300 } +#endif + #else toc_time = time(NULL); #endif /* !defined(__OPENSTEP__) */ @@ -3023,6 +3030,8 @@ struct ofile *ofile) * when we first closed it. */ #ifndef __OPENSTEP__ + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (__builtin_available(macOS 10.12, *)) { struct timespec times[2]; memcpy(×[0], &stat_buf.st_atimespec, sizeof(struct timespec)); @@ -3030,10 +3039,14 @@ struct ofile *ofile) time_result = utimensat(AT_FDCWD, tempfile, times, 0); } else { +#endif TIMESPEC_TO_TIMEVAL(&timep[0], &stat_buf.st_atimespec); TIMESPEC_TO_TIMEVAL(&timep[1], &stat_buf.st_mtimespec); time_result = utimes(tempfile, timep); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 } +#endif + #else timep[0] = stat_buf.st_mtime; timep[1] = stat_buf.st_mtime; diff --git misc/lipo.c misc/lipo.c index bb0cb86..62d86ab 100644 --- misc/lipo.c +++ misc/lipo.c @@ -621,13 +621,21 @@ unknown_flag: if(close(fd) == -1) system_fatal("can't close output file: %s",output_file); #ifndef __OPENSTEP__ + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (__builtin_available(macOS 10.12, *)) { time_result = utimensat(AT_FDCWD, output_file, output_times, 0); } else { +#endif + time_result = utimes(output_file, output_timev); + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 } +#endif + #else time_result = utime(output_file, output_timep); #endif @@ -1155,6 +1163,7 @@ struct input_file *input) /* * Select the first modify time */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 if (__builtin_available(macOS 10.12, *)) { if (output_times[1].tv_sec == 0) { memcpy(&output_times[0], &stat_buf.st_atimespec, @@ -1163,11 +1172,16 @@ struct input_file *input) sizeof(struct timespec)); } } else { +#endif if (output_timev[1].tv_sec == 0) { TIMESPEC_TO_TIMEVAL(&output_timev[0], &stat_buf.st_atimespec); TIMESPEC_TO_TIMEVAL(&output_timev[1], &stat_buf.st_mtimespec); } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 } +#endif + #else /* * Select the eariliest modify time so that if the output file