Browse Source

Add a definition of `struct stat` and supporting types.

This `struct stat` matches the x32 and x86-64 definitions.
pull/7/head
Dan Gohman 6 years ago
parent
commit
51d4922df8
  1. 35
      basics/include/__struct_stat.h
  2. 12
      basics/include/__struct_timespec.h
  3. 7
      basics/include/__typedef_blkcnt_t.h
  4. 7
      basics/include/__typedef_blksize_t.h
  5. 5
      basics/include/__typedef_clock_t.h
  6. 7
      basics/include/__typedef_dev_t.h
  7. 6
      basics/include/__typedef_gid_t.h
  8. 7
      basics/include/__typedef_ino_t.h
  9. 6
      basics/include/__typedef_mode_t.h
  10. 7
      basics/include/__typedef_nlink_t.h
  11. 7
      basics/include/__typedef_off_t.h
  12. 7
      basics/include/__typedef_ssize_t.h
  13. 8
      basics/include/__typedef_suseconds_t.h
  14. 5
      basics/include/__typedef_time_t.h
  15. 6
      basics/include/__typedef_uid_t.h
  16. 10
      basics/include/sys/stat.h
  17. 5
      basics/include/sys/types.h
  18. 1
      basics/include/time.h

35
basics/include/__struct_stat.h

@ -0,0 +1,35 @@
#ifndef __wasm_sysroot___struct_stat_h
#define __wasm_sysroot___struct_stat_h
#include <__typedef_dev_t.h>
#include <__typedef_ino_t.h>
#include <__typedef_nlink_t.h>
#include <__typedef_mode_t.h>
#include <__typedef_uid_t.h>
#include <__typedef_gid_t.h>
#include <__typedef_off_t.h>
#include <__typedef_blksize_t.h>
#include <__typedef_blkcnt_t.h>
#include <__struct_timespec.h>
struct stat {
dev_t st_dev;
ino_t st_ino;
nlink_t st_nlink;
mode_t st_mode;
uid_t st_uid;
gid_t st_gid;
unsigned int __pad0;
dev_t st_rdev;
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
long long __unused[3];
};
#endif

12
basics/include/__struct_timespec.h

@ -0,0 +1,12 @@
#ifndef __wasm_sysroot___struct_timespec_h
#define __wasm_sysroot___struct_timespec_h
#include "__typedef_time_t.h"
/* As specified in POSIX. */
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif

7
basics/include/__typedef_blkcnt_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_blkcnt_t_h
#define __wasm_sysroot___typedef_blkcnt_t_h
/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
typedef long long blkcnt_t;
#endif

7
basics/include/__typedef_blksize_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_blksize_t_h
#define __wasm_sysroot___typedef_blksize_t_h
/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
typedef long long blksize_t;
#endif

5
basics/include/__typedef_clock_t.h

@ -1,2 +1,7 @@
#ifndef __wasm_sysroot___typedef_clock_t_h
#define __wasm_sysroot___typedef_clock_t_h
/* Define this as a 64-bit signed integer to avoid wraparounds. */
typedef long long clock_t;
#endif

7
basics/include/__typedef_dev_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_dev_t_h
#define __wasm_sysroot___typedef_dev_t_h
/* Define these as 64-bit integers to support billions of devices. */
typedef unsigned long long dev_t;
#endif

6
basics/include/__typedef_gid_t.h

@ -0,0 +1,6 @@
#ifndef __wasm_sysroot___typedef_gid_t_h
#define __wasm_sysroot___typedef_gid_t_h
typedef unsigned gid_t;
#endif

7
basics/include/__typedef_ino_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_ino_t_h
#define __wasm_sysroot___typedef_ino_t_h
/* Define these as 64-bit integers to support billions of inodes. */
typedef unsigned long long ino_t;
#endif

6
basics/include/__typedef_mode_t.h

@ -0,0 +1,6 @@
#ifndef __wasm_sysroot___typedef_mode_t_h
#define __wasm_sysroot___typedef_mode_t_h
typedef unsigned mode_t;
#endif

7
basics/include/__typedef_nlink_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_nlink_t_h
#define __wasm_sysroot___typedef_nlink_t_h
/* Define these as 64-bit signed integers to support billions of links. */
typedef long long nlink_t;
#endif

7
basics/include/__typedef_off_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_off_t_h
#define __wasm_sysroot___typedef_off_t_h
/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
typedef long long off_t;
#endif

7
basics/include/__typedef_ssize_t.h

@ -0,0 +1,7 @@
#ifndef __wasm_sysroot___typedef_ssize_t_h
#define __wasm_sysroot___typedef_ssize_t_h
/* This is defined to be the same size as size_t. */
typedef long long ssize_t;
#endif

8
basics/include/__typedef_suseconds_t.h

@ -0,0 +1,8 @@
#ifndef __wasm_sysroot___typedef_suseconds_t_h
#define __wasm_sysroot___typedef_suseconds_t_h
/* Define this to be 64-bit as its main use is in struct timeval where the
extra space would otherwise be padding. */
typedef long long suseconds_t;
#endif

5
basics/include/__typedef_time_t.h

@ -1,2 +1,7 @@
#ifndef __wasm_sysroot___typedef_time_t_h
#define __wasm_sysroot___typedef_time_t_h
/* Define this as a 64-bit signed integer to avoid the 2038 bug. */
typedef long long time_t;
#endif

6
basics/include/__typedef_uid_t.h

@ -0,0 +1,6 @@
#ifndef __wasm_sysroot___typedef_uid_t_h
#define __wasm_sysroot___typedef_uid_t_h
typedef unsigned uid_t;
#endif

10
basics/include/sys/stat.h

@ -0,0 +1,10 @@
#ifndef __wasm_sysroot_sys_stat_h
#define __wasm_sysroot_sys_stat_h
#include <__struct_stat.h>
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
#endif

5
basics/include/sys/types.h

@ -6,6 +6,11 @@
#include <__typedef_clock_t.h>
#include <__typedef_time_t.h>
#include <__typedef_blksize_t.h>
#include <__typedef_off_t.h>
#include <__typedef_ssize_t.h>
#include <__typedef_suseconds_t.h>
#include <__typedef_nlink_t.h>
/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
typedef long long blksize_t;

1
basics/include/time.h

@ -6,5 +6,6 @@
#include <stddef.h>
#include <__typedef_time_t.h>
#include <__struct_timespec.h>
#endif

Loading…
Cancel
Save