Why atexit is limited to 32 functions?

Discussion in 'C Programming' started by lak, Feb 26, 2008.

  1. lak

    lak Guest

    I am studying the Advanced programming in the unix environment.
    There they says that we can register upto 32 functions with atexit().
    Why that is limited to 32 functions?
    can any one tell the answer?
     
    lak, Feb 26, 2008
    #1
    1. Advertising

  2. lak

    santosh Guest

    lak wrote:

    > I am studying the Advanced programming in the unix environment.
    > There they says that we can register upto 32 functions with atexit().
    > Why that is limited to 32 functions?
    > can any one tell the answer?


    It should support *at* *least* 32 functions to be conforming to the C
    Standard. Most implementations will likely support more.
     
    santosh, Feb 26, 2008
    #2
    1. Advertising

  3. lak

    santosh Guest

    WANG Cong wrote:

    > On Mon, 25 Feb 2008 20:55:39 -0800?lak wrote?
    >
    >> I am studying the Advanced programming in the unix environment. There
    >> they says that we can register upto 32 functions with atexit(). Why
    >> that is limited to 32 functions?
    >> can any one tell the answer?

    >
    > It's off-topic here. Here we only talk about standard C.
    > I think you'd better post your question to comp.unix.programmer.


    No necessary. Atexit is also part of ISO C and the limit in question is,
    AFAIK, the same for POSIX and ISO 9899:1999.

    <snip>
     
    santosh, Feb 26, 2008
    #3
  4. lak

    Gerry Ford Guest

    "lak" <> wrote in message
    news:...
    >I am studying the Advanced programming in the unix environment.
    > There they says that we can register upto 32 functions with atexit().
    > Why that is limited to 32 functions?
    > can any one tell the answer?


    yeah.

    Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
    bombs out.

    It's a simultaneous miscalculation in both syntaxes.

    --
    Gerry Ford

    "Er hat sich georgiert." Der Spiegel, 2008, sich auf Chimpy Eins komma null
    beziehend.
     
    Gerry Ford, Feb 26, 2008
    #4
  5. lak

    user923005 Guest

    On Feb 25, 8:55 pm, lak <> wrote:
    > I am studying the Advanced programming in the unix environment.
    > There they says that we can register upto 32 functions with atexit().
    > Why that is limited to 32 functions?


    It is not limited to 32 functions. It must allow _at least_ 32
    functions. An implementation that supported 1,000,000 functions would
    be conforming.

    From "ISO/IEC 9899:1999 (E)":

    7.20.4.2 The atexit function
    Synopsis
    1 #include <stdlib.h>
    int atexit(void (*func)(void));
    Description
    2 The atexit function registers the function pointed to by func, to be
    called without arguments at normal program termination.
    Environmental limits
    3 The implementation shall support the registration of at least 32
    functions.
    Returns
    4 The atexit function returns zero if the registration succeeds,
    nonzero if it fails.
    Forward references: the exit function (7.20.4.3).
     
    user923005, Feb 26, 2008
    #5
  6. "Gerry Ford" <> writes:
    > "lak" <> wrote in message
    > news:...
    >>I am studying the Advanced programming in the unix environment.
    >> There they says that we can register upto 32 functions with atexit().
    >> Why that is limited to 32 functions?
    >> can any one tell the answer?

    >
    > yeah.
    >
    > Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
    > bombs out.
    >
    > It's a simultaneous miscalculation in both syntaxes.


    Yes, you're mistaken. I'd explain how you're mistaken if I could
    figure out what you're trying to say.

    --
    Keith Thompson (The_Other_Keith) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Feb 26, 2008
    #6
  7. lak

    WANG Cong Guest

    On Mon, 25 Feb 2008 20:55:39 -0800,lak wrote:

    > I am studying the Advanced programming in the unix environment. There
    > they says that we can register upto 32 functions with atexit(). Why that
    > is limited to 32 functions?
    > can any one tell the answer?


    It's off-topic here. Here we only talk about standard C.
    I think you'd better post your question to comp.unix.programmer.

    [OT]
    But I still answer your question here. That's because:

    " POSIX.1-2001 requires that an implementation allow at least ATEXIT_MAX
    (32) such functions to be registered."

    [/OT]
     
    WANG Cong, Feb 26, 2008
    #7
  8. lak

    user923005 Guest

    On Feb 25, 8:55 pm, lak <> wrote:
    > I am studying the Advanced programming in the unix environment.
    > There they says that we can register upto 32 functions with atexit().
    > Why that is limited to 32 functions?
    > can any one tell the answer?


    Run this program and redirect the output to a file, then compile and
    run the output:

    #include <stdio.h>
    #define LIMIT_ATEXIT_TEST 1024
    int main(void)
    {
    unsigned i;
    puts("#include <stdlib.h>");
    puts("#include <stdio.h>");
    puts("#include <string.h>");

    for (i = 0; i < LIMIT_ATEXIT_TEST; i++)
    printf("void ae%04u(void){puts(\"%04u \");return;}\n", i, i);

    puts("int main(void) {");

    for (i = 0; i < LIMIT_ATEXIT_TEST; i++)
    printf("atexit(ae%04u);\n", i);
    puts("return 0;");
    puts("}");
    return 0;
    }
     
    user923005, Feb 26, 2008
    #8
  9. lak

    Gerry Ford Guest

    "Keith Thompson" <> wrote in message
    news:...
    > "Gerry Ford" <> writes:
    >> "lak" <> wrote in message
    >> news:...
    >>>I am studying the Advanced programming in the unix environment.
    >>> There they says that we can register upto 32 functions with atexit().
    >>> Why that is limited to 32 functions?
    >>> can any one tell the answer?

    >>
    >> yeah.
    >>
    >> Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
    >> bombs out.
    >>
    >> It's a simultaneous miscalculation in both syntaxes.

    >
    > Yes, you're mistaken. I'd explain how you're mistaken if I could
    > figure out what you're trying to say.


    I thought that bombing out was intersyntactic.

    This, of course, differs with persons who miss with such sincerity.

    --
    Gerry Ford

    "Er hat sich georgiert." Der Spiegel, 2008, sich auf Chimpy Eins komma null
    beziehend.
     
    Gerry Ford, Feb 26, 2008
    #9
  10. On Feb 26, 6:35 am, user923005 <> wrote:
    > On Feb 25, 8:55 pm, lak <> wrote:
    >
    > > I am studying the Advanced programming in the unix environment.
    > > There they says that we can register upto 32 functions with atexit().
    > > Why that is limited to 32 functions?
    > > can any one tell the answer?

    >
    > Run this program and redirect the output to a file, then compile and
    > run the output:
    >
    > #include <stdio.h>
    > #define LIMIT_ATEXIT_TEST 1024
    > int main(void)
    > {
    > unsigned i;
    > puts("#include <stdlib.h>");
    > puts("#include <stdio.h>");
    > puts("#include <string.h>");
    >
    > for (i = 0; i < LIMIT_ATEXIT_TEST; i++)
    > printf("void ae%04u(void){puts(\"%04u \");return;}\n", i, i);
    >
    > puts("int main(void) {");
    >
    > for (i = 0; i < LIMIT_ATEXIT_TEST; i++)
    > printf("atexit(ae%04u);\n", i);
    > puts("return 0;");
    > puts("}");
    > return 0;
    >
    > }



    The following should work directly (I say
    "should", because the limit on my system is
    (2^31 -1), and the program hasn't finished yet).
    It's not necessary to have distinct names, since
    functions can be registered multiple times.

    #include <stdlib.h>
    #include <stdio.h>

    void foo ( void ) {}

    int
    main( void )
    {
    int i;
    for( i = 0; ! atexit( foo ); i++ )
    continue;

    printf( "Limit is %d\n", i );
    return 0;
    }
     
    William Pursell, Feb 26, 2008
    #10
  11. "Gerry Ford" <> writes:
    > "Keith Thompson" <> wrote in message
    > news:...
    >> "Gerry Ford" <> writes:
    >>> "lak" <> wrote in message
    >>> news:...
    >>>>I am studying the Advanced programming in the unix environment.
    >>>> There they says that we can register upto 32 functions with atexit().
    >>>> Why that is limited to 32 functions?
    >>>> can any one tell the answer?
    >>>
    >>> yeah.
    >>>
    >>> Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
    >>> bombs out.
    >>>
    >>> It's a simultaneous miscalculation in both syntaxes.

    >>
    >> Yes, you're mistaken. I'd explain how you're mistaken if I could
    >> figure out what you're trying to say.

    >
    > I thought that bombing out was intersyntactic.
    >
    > This, of course, differs with persons who miss with such sincerity.


    Is this supposed to be word salad? (Consult Google if you don't know
    what "word salad" means.)

    If you don't start making sense soon, you can expect to be ignored.

    --
    Keith Thompson (The_Other_Keith) <>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Feb 26, 2008
    #11
  12. lak

    Richard Bos Guest

    "Gerry Ford" <> wrote:

    > I thought that bombing out was intersyntactic.
    >
    > This, of course, differs with persons who miss with such sincerity.


    You are not making sense at all. Are you, perhaps, literally translating
    idiomatic German into English? Das ist ein Becherspiel.

    Richard
     
    Richard Bos, Feb 26, 2008
    #12
  13. lak

    Ian Collins Guest

    Keith Thompson wrote:
    >
    > If you don't start making sense soon, you can expect to be ignored.
    >

    He has been making something or an arse of himself down the hall in
    c.l.c++ for a while now.

    --
    Ian Collins.
     
    Ian Collins, Feb 26, 2008
    #13
  14. Keith Thompson said:

    > "Gerry Ford" <> writes:

    <snip>
    >>
    >> This, of course, differs with persons who miss with such sincerity.

    >
    > Is this supposed to be word salad? (Consult Google if you don't know
    > what "word salad" means.)


    Or consult comp.programming, which boasts the world's leading expert.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Feb 26, 2008
    #14
  15. Richard Bos schrieb:
    > "Gerry Ford" <> wrote:
    >
    >
    >>I thought that bombing out was intersyntactic.
    >>
    >>This, of course, differs with persons who miss with such sincerity.

    >
    >
    > You are not making sense at all. Are you, perhaps, literally translating
    > idiomatic German into English? Das ist ein Becherspiel.
    >
    > Richard


    'ich dachte, dass ausbomben intersyntaktisch ist.'
    doesn't make more sense in german...

    Wolfgang
     
    Wolfgang Riedel, Feb 26, 2008
    #15
  16. lak

    santosh Guest

    Richard Bos wrote:

    > "Gerry Ford" <> wrote:
    >
    >> I thought that bombing out was intersyntactic.
    >>
    >> This, of course, differs with persons who miss with such sincerity.

    >
    > You are not making sense at all. Are you, perhaps, literally
    > translating idiomatic German into English? Das ist ein Becherspiel.


    I think this is just another handle for whoever was previously "werty".
     
    santosh, Feb 26, 2008
    #16
  17. lak

    CBFalconer Guest

    Keith Thompson wrote:
    > "Gerry Ford" <> writes:
    >

    .... snip ...
    >
    >> This, of course, differs with persons who miss with such sincerity.

    >
    > Is this supposed to be word salad? (Consult Google if you don't
    > know what "word salad" means.)
    >
    > If you don't start making sense soon, you can expect to be ignored.


    For unknown reasons 'Ford's posts never get here. I suspect he is
    intercepted by some newsserver along the path to me. I am NOT
    complaining.

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home.att.net>
    Try the download section.



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    CBFalconer, Feb 26, 2008
    #17
  18. lak

    Randy Howard Guest

    On Tue, 26 Feb 2008 02:03:19 -0600, Richard Heathfield wrote
    (in article <>):

    > Keith Thompson said:
    >
    >> "Gerry Ford" <> writes:

    > <snip>
    >>>
    >>> This, of course, differs with persons who miss with such sincerity.

    >>
    >> Is this supposed to be word salad? (Consult Google if you don't know
    >> what "word salad" means.)

    >
    > Or consult comp.programming, which boasts the world's leading expert.


    Quite. But, do we really have to boast about it? :)



    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
     
    Randy Howard, Feb 26, 2008
    #18
  19. lak

    Tony Giles Guest

    CBFalconer wrote:

    >
    > For unknown reasons 'Ford's posts never get here. I suspect he is
    > intercepted by some newsserver along the path to me. I am NOT
    > complaining.
    >

    Or perhaps you plonked him when he was Wade Ward and your software is
    being very clever.

    Tja
     
    Tony Giles, Feb 27, 2008
    #19
  20. lak

    Gerry Ford Guest

    "Wolfgang Riedel" <> wrote in message
    news:fq0mgo$1re$...
    > Richard Bos schrieb:
    >> "Gerry Ford" <> wrote:
    >>
    >>
    >>>I thought that bombing out was intersyntactic.
    >>>
    >>>This, of course, differs with persons who miss with such sincerity.

    >>
    >>
    >> You are not making sense at all. Are you, perhaps, literally translating
    >> idiomatic German into English? Das ist ein Becherspiel.
    >>
    >> Richard

    >
    > 'ich dachte, dass ausbomben intersyntaktisch ist.'
    > doesn't make more sense in german...
    >
    > Wolfgang


    Mich duenkt, dass Ausbomben intersyntaktisch sei. Tschuessy motherfuckers,

    --
    Gerry Ford

    "Er hat sich georgiert." Der Spiegel, 2008, sich auf Chimpy Eins komma null
    beziehend.
     
    Gerry Ford, Feb 28, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    4,659
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    907
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,984
    Smokey Grindel
    Dec 2, 2006
  4. Nebula

    Why no/limited checking on enum values ?

    Nebula, Jan 17, 2005, in forum: C Programming
    Replies:
    17
    Views:
    527
    Rufus V. Smith
    Jan 21, 2005
  5. Replies:
    11
    Views:
    673
    SM Ryan
    Jan 1, 2008
Loading...

Share This Page