LibC: Move makedev(), major(), minor(), to sys/types.h
It's technically not specified by POSIX, but it appears most Unix-like systems worth mentioning put those definitions there. Also, it's more logical since the dev_t type is defined there.
This commit is contained in:
parent
eecf7a2097
commit
d76987be96
Notes:
sideshowbarker
2024-07-18 18:08:32 +09:00
Author: https://github.com/boricj Commit: https://github.com/SerenityOS/serenity/commit/d76987be96a Pull-request: https://github.com/SerenityOS/serenity/pull/7105
4 changed files with 6 additions and 4 deletions
|
@ -78,8 +78,4 @@ int fstat(int fd, struct stat* statbuf);
|
|||
int lstat(const char* path, struct stat* statbuf);
|
||||
int stat(const char* path, struct stat* statbuf);
|
||||
|
||||
inline dev_t makedev(unsigned int major, unsigned int minor) { return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u); }
|
||||
inline unsigned int major(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
|
||||
inline unsigned int minor(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -91,4 +91,8 @@ typedef struct __pthread_condattr_t {
|
|||
int clockid; // clockid_t
|
||||
} pthread_condattr_t;
|
||||
|
||||
inline dev_t makedev(unsigned int major, unsigned int minor) { return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u); }
|
||||
inline unsigned int major(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
|
||||
inline unsigned int minor(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue