On Wed, Nov 2, 2011 at 6:06 AM, Ian Lance Taylor <i...@google.com> wrote:
>>> The problem with your proposal is that the output would be invalid Go, >>> because it would attempt to define the name _aa twice. However, it does >>> seem plausible that in most scenarios of this type it would be more >>> useful for -fdump-go-spec to generate >>> >>> const _aa = 3 >> >> I agree. > > This patch implements this approach. Bootstrapped and ran Go testsuite > on x86_64-unknown-linux-gnu. Committed to mainline. Thanks, bu this is still not enough to determine corretc IOCTL number :( #defines with arguments are not working at all. Please consider following testcase: --cut here-- #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 #define _IOC_SIZEBITS 13 #define _IOC_DIRBITS 3 #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit. * And this turns out useful to catch old ioctl numbers in header * files for us. */ #define _IOC_NONE 1U #define _IOC_READ 2U #define _IOC_WRITE 3U #define _IOC(dir,type,nr,size) \ ((unsigned int) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT))) /* used to create numbers */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) #define FIOCLEX _IO('f', 1) #define FIONCLEX _IO('f', 2) #define TCGETS _IOR('t', 19, struct termios) #define TCSETS _IOW('t', 20, struct termios) --cut here-- Resulting -fdump-go-spec file: ... const __IOC_NRSHIFT = 0 const __IOC_TYPESHIFT = (__IOC_NRSHIFT+__IOC_NRBITS) const __IOC_SIZESHIFT = (__IOC_TYPESHIFT+__IOC_TYPEBITS) const __IOC_DIRSHIFT = (__IOC_SIZESHIFT+__IOC_SIZEBITS) const __IOC_NONE = 1 const __IOC_READ = 2 const __IOC_WRITE = 3 // unknowndefine FIOCLEX _IO('f', 1) // unknowndefine FIONCLEX _IO('f', 2) // unknowndefine TCGETS _IOR('t', 19, struct termios) // unknowndefine TCSETS _IOW('t', 20, struct termios) Please note missing "struct terminfos" define, so I understand that TC[GS]ETS is unknown, but FIOCLEX should be fully defined by preceeding definitions. Uros.