Re: [dev] Local vs global variables

From: pancake <pancake_AT_youterm.com>
Date: Fri, 6 Nov 2009 21:50:05 +0100

Looks hard to me to think that plan9 is doing kernel2user memory
copies to pass a errno string...

Errno in unix is not for kernel land. But kernel wrappers in libc do
the task to fill errno corretly. But at te end.. Errno is just a int,
not a string. Why don't just change a pointer?

In unix there's errstr for this and perror which is a funny spanish
word that means dog-r :P

But the point is.. Why are the negative numbers not used for this? Any
error for a syscall should return a negative value that should be used
as an index in an array mapped in the process space by the kernel.
Like the vdso in Linux.

That will be a good implemention for errno :)

Is someone is in plan9 dev feel free to fwd this mail

On Nov 6, 2009, at 8:19 PM, Anselm R Garbe <anselm_AT_garbe.us> wrote:

> 2009/11/6 QUINTIN Guillaume <coincoin169g_AT_gmail.com>:
>> Someone just told me that, when writing C code, one should NOT use
>> ANY
>> global variables. He did not tell me to use global variables as few
>> as
>> possible, he did tell me to use ABSOLUTELY NO global variables in any
>> kind of C code (single program, library, OS kernel, any kind there is
>> ...)
>>
>> What do you think about that ?
>
> Is he sure he never uses global variables? What about our old friend
> errno?
>
> Kind regards,
> Anselm
>
Received on Fri Nov 06 2009 - 20:50:05 UTC

This archive was generated by hypermail 2.2.0 : Fri Nov 06 2009 - 21:00:02 UTC