diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-12-04 11:39:55 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-12-04 11:39:55 -0500 |
commit | 49e767ccb9dcfd2161b89f0d7a980eb85f056c5d (patch) | |
tree | 3cdb06282e30c02e3b37615d39b5c1c75af53e3d /util.h | |
parent | 6962fb41b8e57f8bc817b477cf16262a0ce876d5 (diff) | |
download | bfs-49e767ccb9dcfd2161b89f0d7a980eb85f056c5d.tar.xz |
Move portability code into util.h
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -14,6 +14,27 @@ #include <dirent.h> #include <stdbool.h> +#include <sys/stat.h> + +// Some portability concerns + +#if __APPLE__ +# define st_atim st_atimespec +# define st_ctim st_ctimespec +# define st_mtim st_mtimespec +#endif + +#ifndef S_ISDOOR +# define S_ISDOOR(mode) false +#endif + +#ifndef S_ISPORT +# define S_ISPORT(mode) false +#endif + +#ifndef S_ISWHT +# define S_ISWHT(mode) false +#endif /** * readdir() wrapper that makes error handling cleaner. @@ -40,4 +61,13 @@ bool isopen(int fd); */ int redirect(int fd, const char *path, int flags, ...); +/** + * Like dup(), but set the FD_CLOEXEC flag. + * + * @param fd + * The file descriptor to duplicate. + * @return A duplicated file descriptor, or -1 on failure. + */ +int dup_cloexec(int fd); + #endif // BFS_UTIL_H |