From b865d90bffa23a9bb2aacb94f220e5aae2fdbc66 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 10 Mar 2020 10:14:53 +0100 Subject: [PATCH] Use toolchain's struct stat if available Fixes https://github.com/arduino/ArduinoCore-nRF528x-mbedos/issues/49 The patch should be as safe as possible, since __has_include is guarded itself. --- platform/mbed_retarget.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/mbed_retarget.h b/platform/mbed_retarget.h index a2be2bdf39..0f0368802f 100644 --- a/platform/mbed_retarget.h +++ b/platform/mbed_retarget.h @@ -40,6 +40,13 @@ #include #endif +#if defined __has_include +# if __has_include () +# include +# define HAVE_SYS_STAT_H +# endif +#endif + /* We can get the following standard types from sys/types for gcc, but we * need to define the types ourselves for the other compilers that normally * target embedded systems */ @@ -495,6 +502,8 @@ typedef struct Dir DIR; #define S_IWOTH 0000002 ///< write permission, other #define S_IXOTH 0000001 ///< execute/search permission, other +#ifndef HAVE_SYS_STAT_H + /* Refer to sys/stat standard * Note: Not all fields may be supported by the underlying filesystem */ @@ -514,6 +523,8 @@ struct stat { time_t st_ctime; ///< Time of last status change }; +#endif + struct statvfs { unsigned long f_bsize; ///< Filesystem block size unsigned long f_frsize; ///< Fragment size (block size)