On Tue, Jan 23, 2018 at 12:18 AM, Eugene Rudoy <[email protected]> wrote: > Unfortunately it is not possible in C to check for the existence of an enum > value at compile-time. Implement an alternative "kernel version check"-based > approach to workaround MTD_FILE_MODE_RAW related build problems with kernel > versions prior to 3.2.0 > > The same approach is already used elsewhere in busybox, > e.g. in ecce3a1999f3c5ded4baebbc0b17c48d80fe2781 > > Signed-off-by: Eugene Rudoy <[email protected]> > --- > miscutils/nandwrite.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c > index 29c800612..bfa4ea478 100644 > --- a/miscutils/nandwrite.c > +++ b/miscutils/nandwrite.c > @@ -53,12 +53,16 @@ > #include "libbb.h" > #include <mtd/mtd-user.h> > > -/* Old headers call it MTD_MODE_RAW. > - * FIXME: In kernel headers, MTD_FILE_MODE_RAW is not a define, > - * it's an enum. How I can test for existence of an enum? > +#include <linux/version.h> > +/* > + * MTD_FILE_MODE_RAW is an enum (i.e. cannot be tested for using #ifdef) and > is available since kernel 3.2 > + * s. http://elixir.free-electrons.com/linux/v3.2/ident/MTD_FILE_MODE_RAW > + * > + * In versions before 3.2 it's called MTD_MODE_RAW > + * s. http://elixir.free-electrons.com/linux/v3.1/ident/MTD_MODE_RAW > */ > -#if !defined(MTD_FILE_MODE_RAW) > -# define MTD_FILE_MODE_RAW 3 > +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0) > +#define MTD_FILE_MODE_RAW MTD_MODE_RAW > #endif
It does not look to be fixing any actual problems? _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
