linux kernel c code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • slurper

    linux kernel c code

    i encounter regularly in the linux source code signatures like this:

    static void __init do_initcalls(vo id)
    {
    definition(what ever)
    }

    "__init" en "do_initcal ls" are two different words. how must one interpret
    this? i don't understand a function definition with two separate words.
    anybody can explain me this?

  • Jens.Toerring@physik.fu-berlin.de

    #2
    Re: linux kernel c code

    slurper <slurper1234@sk ynet.be> wrote:[color=blue]
    > i encounter regularly in the linux source code signatures like this:[/color]
    [color=blue]
    > static void __init do_initcalls(vo id)
    > {
    > definition(what ever)
    > }[/color]
    [color=blue]
    > "__init" en "do_initcal ls" are two different words. how must one interpret
    > this? i don't understand a function definition with two separate words.
    > anybody can explain me this?[/color]

    You shouldn't expect things like kernels to be clean, standard
    conforming C - lots and lots of non-portable, compiler-dependend
    extensions are typically used. A place where this kind of questions
    is on-topic is e.g. comp.os.linux.d evelopment.syst em, here in clc
    they are heavily frowned upon since they are compiler- and platform
    dependend. In "clean" C the only possibility I can see at the moment
    to make that __init stuff at least halfway legal would be by having
    a define somewhere before like

    #define __init

    i.e. by making it invisible or with

    #define __init *

    (but in this case you would also have to change the function to make
    it return a void pointer;-)

    <OT>
    To satisfy you're curiosity have a look at the init.h header file
    in the kernel sources - you will find that __init is defined as
    some gcc-supplied extension, a function attribute, which gives
    the compiler some additional hints on how the function is going
    to be used - nothing you can do in standard C.
    </OT>
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
    \______________ ____________ http://www.toerring.de

    Comment

    • Erik de Castro Lopo

      #3
      Re: linux kernel c code

      slurper wrote:[color=blue]
      >
      > i encounter regularly in the linux source code signatures like this:
      >
      > static void __init do_initcalls(vo id)
      > {
      > definition(what ever)
      > }
      >
      > "__init" en "do_initcal ls" are two different words. how must one interpret
      > this? i don't understand a function definition with two separate words.
      > anybody can explain me this?[/color]

      This newsgroups is really about ISO standard C and the above is not ISO
      standard C.

      However, __init is explained a little about 3/4 of the way doen this
      page (found by searching google):



      Erik
      --
      +-----------------------------------------------------------+
      Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid)
      +-----------------------------------------------------------+
      "It's not that perl programmers are idiots, it's that the
      language rewards idiotic behavior in a way that no other
      language or tool has ever done." -- Erik Naggum

      Comment

      • CBFalconer

        #4
        Re: linux kernel c code

        Jens.Toerring@p hysik.fu-berlin.de wrote:[color=blue]
        >[/color]
        .... snip ...[color=blue]
        >
        > <OT>
        > To satisfy you're curiosity have a look at the init.h header file
        > in the kernel sources - you will find that __init is defined as[/color]

        While your English is generally excellent, this usage is wrong.
        "you're" is an abbreviation for "you are", while "your" is the
        possessive. If you don't want to hear it, my apologies and I will
        try to remember not to do it again.

        --
        Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
        Available for consulting/temporary embedded and systems.
        <http://cbfalconer.home .att.net> USE worldnet address!


        Comment

        • James McIninch

          #5
          Re: linux kernel c code

          <posted & mailed>

          slurper wrote:
          [color=blue]
          > i encounter regularly in the linux source code signatures like this:
          >
          > static void __init do_initcalls(vo id)
          > {
          > definition(what ever)
          > }
          >
          > "__init" en "do_initcal ls" are two different words. how must one interpret
          > this? i don't understand a function definition with two separate words.
          > anybody can explain me this?[/color]

          Not that it has naything to do with Linux, but __init must either be
          something compiler specific, or a macro. The declaration above is not using
          two words as a function name, the first world is a qualifier just like
          'static' and 'void' are. In this particular case, it's a macro that does
          something compiler-specific.

          --
          remove .nospam from e-mail address to reply

          Comment

          • Joona I Palaste

            #6
            Re: linux kernel c code

            CBFalconer <cbfalconer@yah oo.com> scribbled the following:[color=blue]
            > Jens.Toerring@p hysik.fu-berlin.de wrote:
            > ... snip ...[color=green]
            >>
            >> <OT>
            >> To satisfy you're curiosity have a look at the init.h header file
            >> in the kernel sources - you will find that __init is defined as[/color][/color]
            [color=blue]
            > While your English is generally excellent, this usage is wrong.
            > "you're" is an abbreviation for "you are", while "your" is the
            > possessive. If you don't want to hear it, my apologies and I will
            > try to remember not to do it again.[/color]

            Seeing as countless native English speakers get it wrong too, Jens
            Toerring can be excused for mixing up those words.

            --
            /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
            \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
            "No, Maggie, not Aztec, Olmec! Ol-mec!"
            - Lisa Simpson

            Comment

            • Jens.Toerring@physik.fu-berlin.de

              #7
              Re: linux kernel c code

              Joona I Palaste <palaste@cc.hel sinki.fi> wrote:[color=blue]
              > CBFalconer <cbfalconer@yah oo.com> scribbled the following:[color=green]
              >> Jens.Toerring@p hysik.fu-berlin.de wrote:
              >> ... snip ...[color=darkred]
              >>>
              >>> <OT>
              >>> To satisfy you're curiosity have a look at the init.h header file
              >>> in the kernel sources - you will find that __init is defined as[/color][/color][/color]
              [color=blue][color=green]
              >> While your English is generally excellent, this usage is wrong.
              >> "you're" is an abbreviation for "you are", while "your" is the
              >> possessive. If you don't want to hear it, my apologies and I will
              >> try to remember not to do it again.[/color][/color]
              [color=blue]
              > Seeing as countless native English speakers get it wrong too, Jens
              > Toerring can be excused for mixing up those words.[/color]

              Well, it's nice that CBFalconer tried to help me with that (in
              principle I know about the difference, but it still happens
              again and again that for some reasons I don't understand I get
              them mixed up). Better getting such a thing expained once than
              repeating the same stupid mistake over and over again;-)

              Regards, Jens
              --
              \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
              \______________ ____________ http://www.toerring.de

              Comment

              • Joona I Palaste

                #8
                Re: linux kernel c code

                Jens.Toerring@p hysik.fu-berlin.de scribbled the following:[color=blue]
                > Joona I Palaste <palaste@cc.hel sinki.fi> wrote:[color=green]
                >> CBFalconer <cbfalconer@yah oo.com> scribbled the following:[color=darkred]
                >>> Jens.Toerring@p hysik.fu-berlin.de wrote:
                >>> ... snip ...
                >>>>
                >>>> <OT>
                >>>> To satisfy you're curiosity have a look at the init.h header file
                >>>> in the kernel sources - you will find that __init is defined as[/color][/color][/color]
                [color=blue][color=green][color=darkred]
                >>> While your English is generally excellent, this usage is wrong.
                >>> "you're" is an abbreviation for "you are", while "your" is the
                >>> possessive. If you don't want to hear it, my apologies and I will
                >>> try to remember not to do it again.[/color][/color][/color]
                [color=blue][color=green]
                >> Seeing as countless native English speakers get it wrong too, Jens
                >> Toerring can be excused for mixing up those words.[/color][/color]
                [color=blue]
                > Well, it's nice that CBFalconer tried to help me with that (in
                > principle I know about the difference, but it still happens
                > again and again that for some reasons I don't understand I get
                > them mixed up). Better getting such a thing expained once than
                > repeating the same stupid mistake over and over again;-)[/color]

                I'm lucky my native language has a nearly 1-1 correspondence between
                writing and pronunciation. One of the best such ones in Europe, in fact.
                Thus my knowledge of English spelling is nearly perfect. The downside is
                that I don't speak English aloud too well - I have a horrible Finnish
                accent.

                --
                /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
                \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
                "And according to Occam's Toothbrush, we only need to optimise the most frequent
                instructions."
                - Teemu Kerola

                Comment

                • Emmanuel Delahaye

                  #9
                  Re: linux kernel c code

                  Joona I Palaste wrote on 07/08/04 :[color=blue]
                  > CBFalconer <cbfalconer@yah oo.com> scribbled the following:[color=green]
                  >> Jens.Toerring@p hysik.fu-berlin.de wrote:
                  >> ... snip ...[color=darkred]
                  >>>
                  >>> <OT>
                  >>> To satisfy you're curiosity have a look at the init.h header file
                  >>> in the kernel sources - you will find that __init is defined as[/color][/color]
                  >[color=green]
                  >> While your English is generally excellent, this usage is wrong.
                  >> "you're" is an abbreviation for "you are", while "your" is the
                  >> possessive. If you don't want to hear it, my apologies and I will
                  >> try to remember not to do it again.[/color]
                  >
                  > Seeing as countless native English speakers get it wrong too, Jens
                  > Toerring can be excused for mixing up those words.[/color]

                  But it's good to know, anyway...

                  --
                  Emmanuel
                  The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

                  "C is a sharp tool"

                  Comment

                  • CBFalconer

                    #10
                    Re: linux kernel c code

                    Joona I Palaste wrote:[color=blue]
                    > CBFalconer <cbfalconer@yah oo.com> scribbled the following:[color=green]
                    >> Jens.Toerring@p hysik.fu-berlin.de wrote:
                    >> ... snip ...[color=darkred]
                    >>>
                    >>> <OT>
                    >>> To satisfy you're curiosity have a look at the init.h header file
                    >>> in the kernel sources - you will find that __init is defined as[/color][/color]
                    >[color=green]
                    >> While your English is generally excellent, this usage is wrong.
                    >> "you're" is an abbreviation for "you are", while "your" is the
                    >> possessive. If you don't want to hear it, my apologies and I will
                    >> try to remember not to do it again.[/color]
                    >
                    > Seeing as countless native English speakers get it wrong too, Jens
                    > Toerring can be excused for mixing up those words.[/color]

                    Agreed. By and large non-native English speakers write better
                    English than natives - after all, they have been taught. Joseph
                    Conrad is a fine example in the literary world. Europeans have
                    the advantage that they need to speak more than one language,
                    while USanians don't.

                    --
                    Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
                    Available for consulting/temporary embedded and systems.
                    <http://cbfalconer.home .att.net> USE worldnet address!


                    Comment

                    • CBFalconer

                      #11
                      Re: linux kernel c code

                      Joona I Palaste wrote:[color=blue]
                      >[/color]
                      .... snip ...[color=blue]
                      >
                      > I'm lucky my native language has a nearly 1-1 correspondence
                      > between writing and pronunciation. One of the best such ones in
                      > Europe, in fact. Thus my knowledge of English spelling is nearly
                      > perfect. The downside is that I don't speak English aloud too
                      > well - I have a horrible Finnish accent.[/color]

                      Hmm. I haven't noticed it. :-)

                      --
                      Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
                      Available for consulting/temporary embedded and systems.
                      <http://cbfalconer.home .att.net> USE worldnet address!


                      Comment

                      • Dave Thompson

                        #12
                        Re: linux kernel c code

                        On 7 Aug 2004 19:27:36 GMT, Jens.Toerring@p hysik.fu-berlin.de wrote:
                        [color=blue]
                        > Joona I Palaste <palaste@cc.hel sinki.fi> wrote:[color=green]
                        > > CBFalconer <cbfalconer@yah oo.com> scribbled the following:[/color][/color]
                        <minor English correction: your versus you're>[color=blue][color=green]
                        > > Seeing as countless native English speakers get it wrong too, Jens
                        > > Toerring can be excused for mixing up those words.[/color]
                        >
                        > Well, it's nice that CBFalconer tried to help me with that (in
                        > principle I know about the difference, but it still happens
                        > again and again that for some reasons I don't understand I get[/color]

                        Possibly the reason I have seen quite a few native speakers -- well,
                        here native writers -- have trouble: the possessive of a specific
                        thing uses apostrophe ess: Fred's house; the machine's capacity, etc.
                        But those of pronouns do not: your; its; his; her; our; their. I think
                        I once long ago learned that there is actually a reason for this --
                        unlike many things in English which are arbitrary or accidental or
                        even actually wrong but enshrined by long usage -- but I have
                        forgotten it and in any case the original reason no longer matters;
                        <NearlyTopica l> once it's "standard" that becomes the reason. </>
                        [color=blue]
                        > them mixed up). Better getting such a thing expained once than
                        > repeating the same stupid mistake over and over again;-)
                        >[/color]
                        I'm certain, completely certain, you meant "explained" .

                        But "expained", even though it isn't a word, sounds so perfectly
                        apropos as well as mellifluous that it really *should* be!


                        - David.Thompson1 at worldnet.att.ne t

                        Comment

                        Working...