Re: System calls parameter restrictions
- From: Rafael Almeida <rafaelc@xxxxxxxxxxx>
- Date: Fri, 27 Oct 2006 16:54:36 -0300
On 26 Oct 2006 01:54:12 -0700
"David Schwartz" <davids@xxxxxxxxxxxxx> wrote:
Obviously, nobody would design a system that had a system call thatObviously you can pass pretty much anything through a pointer, but what
required a parameter you couldn't pass the value for. You can always
pass pointers, otherwise 'read' and 'write' wouldn't work. A struct
would be passed by address.
I didn't understand was whether you could pass a struct by value or not.
Mine doesn't cast the parameter to a long. It looks like this:Hum. What's your kernel version? On linux 2.6.18.1 (i386 code) it goes
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{\
return syscall(__NR_##name, arg1);\
}
And 'syscall' takes the number of the system call and then '...'.
like this:
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(arg1))); \
__syscall_return(type,__res); \
}
So you can see from that that passing a struct (and not a pointer to a
struct) as a parameter is going to fail.
I believe structs and unions are never passed by value, but I'm notYeah, I couldn't find any system call that gets a struct as a parameter.
sure.
That's why I thought it was a restriction on the possible parameter
types. And I want to know the reason of that restriction. Not because I
want to pass a struct as a parameter so bad, but because I want to learn
what I'm missing that would make passing a struct by value a bad idea.
.
- Follow-Ups:
- Re: System calls parameter restrictions
- From: David Schwartz
- Re: System calls parameter restrictions
- From: phil-news-nospam
- Re: System calls parameter restrictions
- References:
- System calls parameter restrictions
- From: Rafael Almeida
- Re: System calls parameter restrictions
- From: David Schwartz
- System calls parameter restrictions
- Prev by Date: Problems with server shutdown
- Next by Date: Re: System calls parameter restrictions
- Previous by thread: Re: System calls parameter restrictions
- Next by thread: Re: System calls parameter restrictions
- Index(es):
Relevant Pages
|