__compiler_offsetof in fio's flist.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In flist.h (https://github.com/axboe/fio/blob/fio-2.17/flist.h#L6 )
there's the following:
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

The problem is that __compiler_offsetof usually not defined (in the
Linux kernel it gets set when you are using gcc 4+ -
http://lxr.free-electrons.com/source/include/linux/compiler-gcc4.h?v=3.8#L14
. This leads to a hand rolled offsetof being used that can trigger
undefined behaviour checks
(https://en.wikipedia.org/wiki/Offsetof#Implementation ).

While it's possible to produce a configure check that tests for
__builtin_offsetof and adds -D__compiler_offsetof=__builtin_offsetof
to the CFLAGS is there any particular reason why the offsetof from
stdlib (which will avoid undefined behaviour if possible) is replaced?

-- 
Sitsofe | http://sucs.org/~sits/
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux