add clang-compatible thread-pointer code for mips
[musl] / include / dirent.h
1 #ifndef _DIRENT_H
2 #define _DIRENT_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #if __STDC_VERSION__ >= 199901L
9 #define __restrict restrict
10 #elif !defined(__GNUC__)
11 #define __restrict
12 #endif
13
14 #define __NEED_ino_t
15 #define __NEED_off_t
16 #ifdef _BSD_SOURCE
17 #define __NEED_size_t
18 #endif
19
20 #include <bits/alltypes.h>
21
22 typedef struct __DIR_s DIR;
23
24 struct dirent
25 {
26         ino_t d_ino;
27         off_t d_off;
28         unsigned short d_reclen;
29         unsigned char d_type;
30         char d_name[256];
31 };
32
33 #define d_fileno d_ino
34
35 int            closedir(DIR *);
36 DIR           *fdopendir(int);
37 DIR           *opendir(const char *);
38 struct dirent *readdir(DIR *);
39 int            readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
40 void           rewinddir(DIR *);
41 void           seekdir(DIR *, long);
42 long           telldir(DIR *);
43 int            dirfd(DIR *);
44
45 int alphasort(const struct dirent **, const struct dirent **);
46 int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
47
48 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
49 #define DT_UNKNOWN 0
50 #define DT_FIFO 1
51 #define DT_CHR 2
52 #define DT_DIR 4
53 #define DT_BLK 6
54 #define DT_REG 8
55 #define DT_LNK 10
56 #define DT_SOCK 12
57 #define DT_WHT 14
58 #define IFTODT(x) ((x)>>12 & 017)
59 #define DTTOIF(x) ((x)<<12)
60 #endif
61
62 #ifdef _GNU_SOURCE
63 int versionsort(const struct dirent **, const struct dirent **);
64 #endif
65
66 #ifdef _BSD_SOURCE
67 int getdents(int, struct dirent *, size_t);
68 #endif
69
70 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
71 #define dirent64 dirent
72 #define readdir64 readdir
73 #define readdir64_r readdir_r
74 #define scandir64 scandir
75 #define alphasort64 alphasort
76 #define versionsort64 versionsort
77 #define off64_t off_t
78 #define ino64_t ino_t
79 #ifdef _BSD_SOURCE
80 #define getdents64 getdents
81 #endif
82 #endif
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif