Skip to content

Use toolchain's struct stat if available #12607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

facchinm
Copy link
Contributor

Summary of changes

Include <sys/stat.h> (if it's available ) to provide struct stat.
Fixes arduino/ArduinoCore-nRF528x-mbedos#49
The patch should be as safe as possible, since __has_include is guarded itself.

Impact of changes

Adds sizeof(dev_t) on every instance since GCC defines it as

struct  stat
{
  dev_t         st_dev;
  ino_t         st_ino;
  mode_t        st_mode;
  nlink_t       st_nlink;
  uid_t         st_uid;
  gid_t         st_gid;
  dev_t         st_rdev;
  off_t         st_size;
#if defined(__rtems__)
  struct timespec st_atim;
  struct timespec st_mtim;
  struct timespec st_ctim;
  blksize_t     st_blksize;
  blkcnt_t      st_blocks;
#else
  /* SysV/sco doesn't have the rest... But Solaris, eabi does.  */
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
  time_t        st_atime;
  time_t        st_mtime;
  time_t        st_ctime;
#else
  time_t        st_atime;
  long          st_spare1;
  time_t        st_mtime;
  long          st_spare2;
  time_t        st_ctime;
  long          st_spare3;
  long          st_blksize;
  long          st_blocks;
  long  st_spare4[2];
#endif
#endif
};

and dev_t st_rdev; is not part of mbed's struct.

Migration actions required

Documentation

None


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

Only tested on GCC_ARM, hope the CI helps with the other targets.

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


Fixes arduino/ArduinoCore-nRF528x-mbedos#49

The patch should be as safe as possible, since __has_include is guarded itself.
@ciarmcom
Copy link
Member

@facchinm, thank you for your changes.
@ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@kjbracey
Copy link
Contributor

Seems reasonable to me. I wasn't aware GCC supported __has_include in C++14 mode. Other compilers might not, but I guess as you're aiming for GCC it's fine.

@adbridge
Copy link
Contributor

@kjbracey-arm if you have looked at this and are happy could you approve please ?

@mergify mergify bot added needs: CI and removed needs: review labels Mar 12, 2020
@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Mar 12, 2020

Test run: FAILED

Summary: 1 of 7 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@mergify mergify bot added needs: work and removed needs: CI labels Mar 12, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented Mar 16, 2020

tests restarted

@mbed-ci
Copy link

mbed-ci commented Mar 16, 2020

Test run: SUCCESS

Summary: 7 of 7 test jobs passed
Build number : 2
Build artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error: redefinition of 'struct stat'
6 participants