diff --git a/meson.build b/meson.build index b72368a379..38bc3f6eae 100644 --- a/meson.build +++ b/meson.build @@ -183,6 +183,20 @@ else conf.set('fallthrough', 'do {} while (0) /* fallthrough */') endif +if cc.has_function('TEMP_FAILURE_RETRY', prefix : '#include ') + conf.set('TFR', 'TEMP_FAILURE_RETRY') +else + conf.set('TFR(exp)', ''' \ +({ \ + long int __result = 0; \ + do { \ + __result = (long int)(exp); \ + } while ((__result == -1) && (errno == EINTR)); \ + __result; \ +}) +''') +endif + configure_file( output: 'config.h', configuration: conf diff --git a/util/logging.c b/util/logging.c index a855a3dd67..9aea1f1e2e 100644 --- a/util/logging.c +++ b/util/logging.c @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -96,7 +97,7 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd, if (log_level >= LOG_DEBUG) gettimeofday(&start, NULL); - err = ioctl(fd, ioctl_cmd, cmd); + err = TFR(ioctl(fd, ioctl_cmd, cmd)); if (log_level >= LOG_DEBUG) { gettimeofday(&end, NULL); @@ -122,7 +123,7 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd, gettimeofday(&start, NULL); - err = ioctl(fd, ioctl_cmd, cmd); + err = TFR(ioctl(fd, ioctl_cmd, cmd)); if (log_level >= LOG_DEBUG) { gettimeofday(&end, NULL);