]> git.proxmox.com Git - wasi-libc.git/blame - libc-top-half/musl/include/dirent.h
Don't define `_POSIX_THREADS` unless threads are enabled. (#356)
[wasi-libc.git] / libc-top-half / musl / include / dirent.h
CommitLineData
320054e8
DG
1#ifndef _DIRENT_H
2#define _DIRENT_H
3
e5f14be3 4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
320054e8
DG
5#else
6#include <__header_dirent.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#define __NEED_ino_t
15#define __NEED_off_t
16#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
17#define __NEED_size_t
18#endif
19
20#include <bits/alltypes.h>
21
575e1579
DG
22#include <bits/dirent.h>
23
e5f14be3 24#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
320054e8
DG
25typedef struct __dirstream DIR;
26#else
27#include <__typedef_DIR.h>
28#endif
29
320054e8
DG
30#define d_fileno d_ino
31
32int closedir(DIR *);
33DIR *fdopendir(int);
34DIR *opendir(const char *);
35struct dirent *readdir(DIR *);
36#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
37int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
38#endif
39void rewinddir(DIR *);
40int dirfd(DIR *);
41
42int alphasort(const struct dirent **, const struct dirent **);
43int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
44
45#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
46void seekdir(DIR *, long);
47long telldir(DIR *);
48#endif
49
50#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
e5f14be3 51#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
320054e8
DG
52#define DT_UNKNOWN 0
53#define DT_FIFO 1
54#define DT_CHR 2
55#define DT_DIR 4
56#define DT_BLK 6
57#define DT_REG 8
58#define DT_LNK 10
59#define DT_SOCK 12
60#define DT_WHT 14
61#define IFTODT(x) ((x)>>12 & 017)
62#define DTTOIF(x) ((x)<<12)
63#endif
64int getdents(int, struct dirent *, size_t);
65#endif
66
67#ifdef _GNU_SOURCE
68int versionsort(const struct dirent **, const struct dirent **);
69#endif
70
71#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
72#define dirent64 dirent
73#define readdir64 readdir
472b213b 74#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
320054e8 75#define readdir64_r readdir_r
472b213b 76#endif
320054e8
DG
77#define scandir64 scandir
78#define alphasort64 alphasort
79#define versionsort64 versionsort
80#define off64_t off_t
81#define ino64_t ino_t
82#define getdents64 getdents
83#endif
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif