Why atexit is limited to 32 functions?

L

lak

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?
 
S

santosh

lak said:
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.
 
S

santosh

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


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>
 
G

Gerry Ford

lak said:
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.
 
U

user923005

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).
 
K

Keith Thompson

Gerry Ford said:
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.
 
W

WANG Cong

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]
 
U

user923005

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;
}
 
G

Gerry Ford

Keith Thompson said:
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.
 
W

William Pursell

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;
}
 
K

Keith Thompson

Gerry Ford said:
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.
 
R

Richard Bos

Gerry Ford said:
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
 
I

Ian Collins

Keith said:
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.
 
W

Wolfgang Riedel

Richard said:
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
 
S

santosh

Richard said:
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".
 
C

CBFalconer

Keith said:
.... snip ...


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.
 
T

Tony Giles

CBFalconer said:
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
 
G

Gerry Ford

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

Wolfgang

Mich duenkt, dass Ausbomben intersyntaktisch sei. Tschuessy motherfuckers,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top