Messages in this thread | | | Date | Tue, 16 Nov 2004 08:40:53 -0800 (PST) | From | Linus Torvalds <> | Subject | Re: fork pagesize patch |
| |
On Tue, 16 Nov 2004, David Howells wrote: > > > > Please don't do that. What you've done causes a divide-by-zero error to be > > > emitted by the compiler if PAGE_SIZE > THREAD_SIZE. That's why I used the > > > preprocessor in the first place. > > > > What kind of broken compiler are _you_ using? Fix your compiler. > > Sorry... I meant warning not error. It doesn't actually stop it building a > working kernel, but gcc _does_ complain, and not unreasonably, I think.
I think it _is_ unreasonable. It's like doing
if (a) x /= a;
and the compiler complaining that "a" can be zero. The above is perfectly reasonable code and may well have a constant zero as part of inlining or macro expansion. A compiler that does that is being silly. It's being _especially_ silly since it evaluates to
if (0) ..
at compile time in this case. Yeah, yeah, sparse gets it wrong too, but only if the left-hand side is zero as well.
But yes, at least the compiler isn't totally buggy if it's just a warning. After all, you can warn about anything you like ;)
Anyway, to make it not warn, why not change it to
max_threads = mempages / (8*THREAD_SIZE/PAGE_SIZE);
instead, and be done with it? If the thread size is _that_ small that we still divide by zero, color me impressed.
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/
| |