mirror of
git://git.musl-libc.org/musl
synced 2024-12-25 16:12:48 +00:00
9b732fe51b
in theory this should not be an issue, since major() should only be applied to type dev_t, which is 64-bit. however, it appears some applications are not using dev_t but a smaller integer type (which works on Linux because the kernel's dev_t is really only 32-bit). to avoid the undefined behavior, do it as two shifts.
16 lines
394 B
C
16 lines
394 B
C
#ifndef _SYS_SYSMACROS_H
|
|
#define _SYS_SYSMACROS_H
|
|
|
|
#define major(x) \
|
|
((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) ))
|
|
#define minor(x) \
|
|
((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) ))
|
|
|
|
#define makedev(x,y) ( \
|
|
(((x)&0xfffff000ULL) << 32) | \
|
|
(((x)&0x00000fffULL) << 8) | \
|
|
(((y)&0xffffff00ULL) << 12) | \
|
|
(((y)&0x000000ffULL)) )
|
|
|
|
#endif
|