diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-11-02 22:44:48 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-11-02 22:44:48 -0400 |
commit | 5cbf11475b9135c30f1da76268dbb3b27df55cd6 (patch) | |
tree | 0632af2aede29fa97f7a394b9352a50964054424 | |
parent | 2d0b6b31caff9405ae551079ca67e9f1061f9afc (diff) | |
download | bfs-5cbf11475b9135c30f1da76268dbb3b27df55cd6.tar.xz |
util: Provide fallback implementations of makedev()/major()/minor()
-rw-r--r-- | util.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -32,6 +32,8 @@ #if __GLIBC__ || BFS_HAS_INCLUDE(<sys/sysmacros.h>) # include <sys/sysmacros.h> +#elif BFS_HAS_INCLUDE(<sys/mkdev.h>) +# include <sys/mkdev.h> #endif int xreaddir(DIR *dir, struct dirent **de) { @@ -446,13 +448,25 @@ int ynprompt() { } dev_t bfs_makedev(int ma, int mi) { +#ifdef makedev return makedev(ma, mi); +#else + return (ma << 8) | mi; +#endif } int bfs_major(dev_t dev) { +#ifdef major return major(dev); +#else + return dev >> 8; +#endif } int bfs_minor(dev_t dev) { +#ifdef minor return minor(dev); +#else + return dev & 0xFF; +#endif } |