Architecture dependent representation clause
Iβm writing a wrapper around some Linux ioctl(2) calls and am using a representation clause to replace the macros in ioctl.h Β« asm-generic Β« uapi Β« include - kernel/git/stable/linux.git - Linux kernel stable tree
However, this header is architecture dependent and has different field sizes and constants for some older architectures: parisc, mips, powerpc, alpha, sparc.
-- /usr/include/asm-generic/ioctl.h
type IOC_DIR_Field is (None, Write, Read)
with Size => 2;
for IOC_DIR_Field use (0, 1, 2);
-- parisc: Read and Write are swapped
-- mips, powerpc, alpha, sparc: IOC_DIR_Field'Size = 3, Write is 4
type IOC is record
NR : UInt8;
TYP : UInt8;
SIZE : UInt14; -- 13 bits on mips, powerpc, alpha, sparc
DIR : IOC_DIR_Field; -- 3 bits on mips, powerpc, alpha, sparc
end record
with Size => 32;
for IOC use record
NR at 0 range 0 .. 7;
TYP at 1 range 0 .. 7;
SIZE at 2 range 0 .. 13;
DIR at 2 range 14 .. 15;
end record;
Should I create a separate
package for each architecture to define these fields, or is there a better way to make a representation clause architecture dependent?
6 posts - 3 participants