[PATCH] Abstract calls to in/out with IN/OUT macros

Matt Turner mattst88 at gmail.com
Sun Nov 1 13:40:28 PST 2009


On Sun, Nov 1, 2009 at 3:29 PM, keithp <keithp at keithp.com> wrote:
> Excerpts from Matt Turner's message of Sun Nov 01 11:01:20 -0800 2009:
>> This will allow us to include sys/io.h and use libc's in/out when
>> available.
>
> That's a fine goal, but given the ambiguity between Linux and BSD on
> the outb argument ordering, I've got some suggestions
>
>>  #    ifdef linux
>> -/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
>> -/* note that the appropriate setup via "ioperm" needs to be done */
>> -/*  *before* any inx/outx is done. */
>> +#     include <sys/io.h>
>> +#     define OUTB(port, val) outb((val), (port))
>> +#     define OUTW(port, val) outw((val), (port))
>> +#     define OUTL(port, val) outl((val), (port))
>
> Please use inline functions instead of macros. Also, please make it
> obvious that these macros belong to X.org and are not brought from
> some other package. Further, it would be nice to have them
> self-documenting as far as argument order somehow, perhaps
>
> static inline void xorg_outb_port_val(uint16_t port, uint8_t val)
>
> (suggestions welcome here, I just want to make people aware of any
> ordering change here).
>
> What isn't clear is how this affects the current API; ideally, we'd
> make all existing drivers using whatever old names they've got
> continue to compile, but with warnings so that developers will know
> what to do to fix them.
>
> --
> keith.packard at intel.com
>

Please see attached patch. I've made xorg_out{b,w,l}_port_val and
xorg_out{b,w,l} static inline functions.

There are a couple of FIXMEs, namely
 o there are a lot of lines like 'extern _X_EXPORT void outb(... ';
these shouldn't have to exist. #include the right header instead.
 o the Linux/IA64 section does funky stuff by including sys/io.h,
undef'ing in/out, and then redeclaring them as mentioned previously.
 o The FreeBSD/AMD64 section defines in/out because I don't know what
header FreeBSD uses to define these.

Thanks,
Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Abstract-calls-to-in-out-with-xorg_-in-out-functions.patch
Type: application/octet-stream
Size: 31125 bytes
Desc: not available
Url : http://lists.x.org/archives/xorg-devel/attachments/20091101/9ae5934c/attachment-0001.obj 


More information about the xorg-devel mailing list