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.
pull/12607/head
Martino Facchin 2020-03-10 10:14:53 +01:00
parent fe85cbd903
commit b865d90bff
1 changed files with 11 additions and 0 deletions

View File

@ -40,6 +40,13 @@
#include <errno.h>
#endif
#if defined __has_include
# if __has_include (<sys/stat.h>)
# include <sys/stat.h>
# 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)