Sponsored Content
Full Discussion: Register variables
Top Forums Programming Register variables Post 21838 by Perderabo on Thursday 23rd of May 2002 12:41:55 PM
Old 05-23-2002
The register keyword is just a hint to the compiler. There is no limit on how many times you can use that hint. There is also no guarantee that any of the variables will wind up with a somewhat dedicated register.

The register keyword is largely obsolete and I would not recommend using it for new code. Today's optimizers are very good at allocating registers where they are do the most good. And, by the way, today's risc and post-risc cpu's tend to have lots of registers to allocate. Registers aren't the scarce resource that they were in the 70's.
 

9 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Can't register

I tried registering, but no matter what email address I provide, it says not a valid address and not the same in confirm. I tried many times, but no go. I thought I had already registered as Sully but even that didn't like my email address for password info. Of course, that could be someone else... (2 Replies)
Discussion started by: Not registered
2 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Not able to register

I tried my best to register myself on unix.com but i am not lucky, can you pls give me instruction. (1 Reply)
Discussion started by: Kuldeep_Sngh333
1 Replies

3. Forum Support Area for Unregistered Users & Account Problems

Cant register

Registration denied. Sorry, The UNIX and Linux Forums runs an active policy of not allowing spammers. Please contact us via by posting in this forum if you believe this is in error What's with this? Tried 2 email accounts in case your forum blocks either. (1 Reply)
Discussion started by: Diagonal
1 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Can not register

I need help from the scripting threads and want to register. I tried it several times, but I was all the time rejected, because of your spam policy. I do what you have written, but I wasn't still able to register. (1 Reply)
Discussion started by: ScAr
1 Replies

5. Forum Support Area for Unregistered Users & Account Problems

I can't register

Hello admin, I come from Vietnam, it's in blocked country list. Can you help me to register I want to register with following information: Username: bojankikrick Email: <removed> Thanks very much! (1 Reply)
Discussion started by: Unregistered
1 Replies

6. Forum Support Area for Unregistered Users & Account Problems

Can't register

I am in China. China is in the blocked country list. I can't register. And I don't have a static ip. Can u help me to fix it. I want to register with following information: Username:liuchengzhang email:<removed> Thanks! (1 Reply)
Discussion started by: liuchengzhang
1 Replies

7. Forum Support Area for Unregistered Users & Account Problems

Cannot able to Register!

Hi Admin, I am unable to register . Request you to help me in getting my registration done. Name: Raghavendra Kulkarni Mail id : <removed> Thanking you in advance for your support. (1 Reply)
Discussion started by: Unregistered
1 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Not able to register

Hi Admin, Currently, i am not able to register in this site. Kindly let me know what need to done. Thanks, ramesh (1 Reply)
Discussion started by: Unregistered
1 Replies

9. Forum Support Area for Unregistered Users & Account Problems

I can not register

I want to register as "nezabudka", but I can't and I have a dynamic ip address. My country is not in the list of restrictions. I'm alive, I'm not a bot ))) (3 Replies)
Discussion started by: nezabudka
3 Replies
setjmp(3UCB)					     SunOS/BSD Compatibility Library Functions					      setjmp(3UCB)

NAME
setjmp, longjmp, _setjmp, _longjmp - non-local goto SYNOPSIS
/usr/ucb/cc [ flag ... ] file ... #include <setjmp.h> int setjmp(env); jmp_buf env; void longjmp(env, val); jmp_buf env; int val; int _setjmp(env); jmp_buf env; void _longjmp(env, val); jmp_buf env; int val; DESCRIPTION
The setjmp() and longjmp() functions are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. The setjmp() function saves its stack environment in env for later use by longjmp(). A normal call to setjmp() returns zero. setjmp() also saves the register environment. If a longjmp() call will be made, the routine which called setjmp() should not return until after the longjmp() has returned control (see below). The longjmp() function restores the environment saved by the last call of setjmp(), and then returns in such a way that execution continues as if the call of setjmp() had just returned the value val to the function that invoked setjmp(); however, if val were zero, execution would continue as if the call of setjmp() had returned one. This ensures that a ``return'' from setjmp() caused by a call to longjmp() can be distinguished from a regular return from setjmp(). The calling function must not itself have returned in the interim, otherwise longjmp() will be returning control to a possibly non-existent environment. All memory-bound data have values as of the time longjmp() was called. The CPU and floating-point data registers are restored to the values they had at the time that setjmp() was called. But, because the register storage class is only a hint to the C compiler, variables declared as register variables may not necessarily be assigned to machine registers, so their values are unpredictable after a longjmp(). This is especially a problem for programmers trying to write machine-independent C routines. The setjmp() and longjmp() functions save and restore the signal mask while _setjmp() and _longjmp() manipulate only the C stack and regis- ters. None of these functions save or restore any floating-point status or control registers. EXAMPLES
Example 1: Examples of setjmp() and longjmp(). The following example uses both setjmp() and longjmp() to return the flow of control to the appropriate instruction block: #include <stdio.h> #include <setjmp.h> #include <signal.h> #include <unistd.h> jmp_buf env; static void signal_handler(); main() { int returned_from_longjump, processing = 1; unsigned int time_interval = 4; if ((returned_from_longjump = setjmp(env)) != 0) switch (returned_from_longjump) { case SIGINT: printf("longjumped from interrupt %d ",SIGINT); break; case SIGALRM: printf("longjumped from alarm %d ",SIGALRM); break; } (void) signal(SIGINT, signal_handler); (void) signal(SIGALRM, signal_handler); alarm(time_interval); while (processing) { printf(" waiting for you to INTERRUPT (cntrl-C) ... "); sleep(1); } /* end while forever loop */ } static void signal_handler(sig) int sig; { switch (sig) { case SIGINT: ... /* process for interrupt */ longjmp(env,sig); /* break never reached */ case SIGALRM: ... /* process for alarm */ longjmp(env,sig); /* break never reached */ default: exit(sig); } } When this example is compiled and executed, and the user sends an interrupt signal, the output will be: longjumped from interrupt Additionally, every 4 seconds the alarm will expire, signalling this process, and the output will be: longjumped from alarm SEE ALSO
cc(1B), sigvec(3UCB), setjmp(3C), signal(3C) NOTES
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. BUGS
The setjmp() function does not save the current notion of whether the process is executing on the signal stack. The result is that a longjmp() to some place on the signal stack leaves the signal stack state incorrect. On some systems setjmp() also saves the register environment. Therefore, all data that are bound to registers are restored to the values they had at the time that setjmp() was called. All memory-bound data have values as of the time longjmp() was called. However, because the register storage class is only a hint to the C compiler, variables declared as register variables may not necessarily be assigned to machine registers, so their values are unpredictable after a longjmp(). When using compiler options that specify automatic register alloca- tion (see cc(1B)), the compiler will not attempt to assign variables to registers in routines that call setjmp(). The longjmp() function never causes setjmp() to return 0, so programmers should not depend on longjmp() being able to cause setjmp() to return 0. SunOS 5.10 7 Apr 1993 setjmp(3UCB)
All times are GMT -4. The time now is 02:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy