Re: [PATCH] 2.5 fast poll on ppc64

From: Linus Torvalds (torvalds@transmeta.com)
Date: Thu Dec 26 2002 - 16:23:19 EST


On Thu, 26 Dec 2002, Mikael Pettersson wrote:
>
> Technically speaking, the kernel code which uses 'entries[0]' is
> non-compliant since the proper syntax is 'entries[]', but the empty
> array size syntax isn't implemented in gcc 2.95.3.

The two things have two totally different semantics:

 - array[0] is a zero-sized array, and is a long-time gcc extension that
   has nothing to do with the modern "flexible array". The kernel uses
   zero-sized arrays, because flexible arrays simply aren't historically
   supported by gcc at all.

 - array[] is the standard "flexible array" thing, and has different rules
   than array[0]. For example, sizeof() is undefined on flexible arrays,
   but is well-defined on zero-sized ones (at zero). Also, the alignment
   constraints are potentially quite different.

The gcc people want to make the two behave fairly similarly to ease
implementation issues, but they are definitely not the same.

> My mistake. The old code is Ok for C99, but broken for ANSI-C.

The old code is ugly and arguably always broken, I agree 100% with making
the usage code use "pp->entries". Whether the allocators use "sizeof" or
"offsetof" is secondary, at worst it ends up being conservative.

                Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Dec 31 2002 - 22:00:09 EST