Opened 11 years ago

Closed 11 years ago

#342 closed defect (fixed)

ffi-parser limitations need workaround

Reported by: gb Owned by: gb
Priority: major Milestone:
Component: Foreign Function Interface Version: unspecific
Keywords: Cc:

Description

On Fedora 9/PPC, /usr/include/asm/ioctl.h contains:

/* provoke compile error for invalid uses of size argument */
extern unsigned int __invalid_size_argument_for_IOC;
#define _IOC_TYPECHECK(t) \
	((sizeof(t) == sizeof(t[1]) && \
	  sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
	  sizeof(t) : __invalid_size_argument_for_IOC)

/* used to create numbers */
#define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
#define _IOR(type,nr,size)	_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOW(type,nr,size)	_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))

and some ioctl constants are then defined in terms of _IOR(), _IOW(), etc.

The conditional expression in the expansion of _IOC_TYPECHECK (and possibly the reference to the variable) cause the FFI parser to give up, so some IOCTL constants aren't defined.

We can either try to be more ambitious and interpret the expansion (it should always expand to "sizeof(t)" unless there's an error in the header file) or do all macroexpansion as if:

#define _IOC_TYPECHECK(t) sizeof(t)

was predefined and not overridden by the definition in the header file.

(We might be able to translate this particular macro into something that we can make sense of, but we can't always do that, so it seems like a mechanism for dealing with intractable nonsense would be desirable.)

Change History (2)

comment:1 Changed 11 years ago by gb

  • Status changed from new to assigned

comment:2 Changed 11 years ago by gb

  • Resolution set to fixed
  • Status changed from assigned to closed

Should be fixed in r11486.

Note: See TracTickets for help on using tickets.