Re: [patch 1/3] epoll cleanups - epoll include diet ...



On Thu, 5 Apr 2007 18:12:58 -0700 (PDT)
Davide Libenzi <davidel@xxxxxxxxxxxxxxx> wrote:

On Thu, 5 Apr 2007, Andrew Morton wrote:

epoll uses signal stuff and might need signal.h. It implements syscalls
and it certainly needs to have those syscall's prototypes in scope. It
surely uses stuff from mm.h (doesn't everything??)

Ack about signal.h, I forgot about the pwait code :(
Why syscalls.h? The eventpoll.c file expots syscalls, but it doesn't use
anything declared in there.

So that the compiler can verify that our declarations of sys_epoll_foo()
match our definitions of them.

What does eventpoll.c use *directly* from mm.h? If eventpoll.c uses, let's
say sched.h, and sched.h needs mm.h, it is sched.h responsibility to
include the mm.h file not eventpoll.c one.


Sure. But if epoll.c _does_ use something from mm.h (or uses something
from a header which mm.h includes) then if we later remove the #include
mm.h from sched.h, eventpoll.c will break.

The general rule is: include in .c the header files which provide the stuff
which that .c file uses. Now, it maybe that eventpoll.c indeed uses nothing
which mm.h provides, and nothing which mm.h's includees provide. But it is
non-trivial to prove that. Once added, includes are hard to remove :(
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: c99/c++ localised variable definition
    ... When variables are used only in a limited scope I find it better to ... Forcing variable declarations to the top of the function means extra ... > reason why things like ancillary counter variables seem reasonable, ... you can combine the decl and the initialization. ...
    (freebsd-arch)
  • Re: Making C better (by borrowing from C++)
    ... there's no way to be certain unless declarations are restricted not ... merely to the top of the scope, but to the top of the function. ... line by line for the matching declaration; the context switch between ... the two search modes costs at least as much as the nominally more ...
    (comp.lang.c)
  • Re: Identify new pairs in an array
    ... Leaving us to figure it out for ourselves from the code? ... [declarations below rearranged into groups I can comment on] ... One-character variable names suck even more when they ... You should limit the scope of variables to the smallest possible scope. ...
    (comp.lang.perl.misc)
  • Re: About String
    ... My idea is that every statement list is a scope. ... What is so special in statement lists? ... and to me declarations intermixed with statements look similarly ... You declare something inside a loop body, ...
    (comp.lang.ada)
  • Re: Java needs "goto" (was Re: hi)
    ... declarations are collected at the start of the method, ... the whole thing and starting from scratch. ... Too much work to be done and too lil time to do it. ... Played with this scope thing in just about ...
    (comp.lang.java.programmer)