Re: System calls parameter restrictions



On 27 Oct 2006 16:47:46 -0700 David Schwartz <davids@xxxxxxxxxxxxx> wrote:

| Rafael Almeida wrote:
|
|> Obviously you can pass pretty much anything through a pointer, but what
|> I didn't understand was whether you could pass a struct by value or not.
|
| I think it's an ABI restriction. As far as the ABI is concerned, a
| structure doesn't have a value, it's an arbitrarily-formatted chunk of
| memory. So the only way you could pass it by value would be to make a
| copy of it and pass a pointer to the copy.

Structs small enough to fit in available register space could be passed
in much the same way many archtectures do pass values. It's just a big
complex value. What if you were passing a 64 bit integer by value, on a
32 bit machine, knowing that there is really no true value as cuh, but
only a joining of a pair of 32 bit integers? It really doesn't matter.
It can be dealt with one way or another. It can be loaded into a register
or a copy can be made through use of pass by reference (pointer). It's
just a matter of how the kernel syscall interface is designed and to the
extent such a design depends on it, the ABI.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2006-10-27-2148@xxxxxxxx |
|------------------------------------/-------------------------------------|
.



Relevant Pages

  • Re: Another spinoza challenge
    ... You should test against the int type's limits: ... typedef struct complex ... a pointer to an integer ... A macro is preferable because it is replaced by inline code, ...
    (comp.lang.c)
  • Re: how to store list of varying types
    ... represent that with those in the struct definitions? ... pointer null, and the second one the CString object. ... then have to finish constructing the packet by copying the two data objects ... start with an upper-case letter (so, I would use DataElement ...
    (microsoft.public.vc.mfc)
  • Re: N1298 - try/finally for C
    ... Do you mean that "struct throwInfo" should be optional? ... that exception handling would be supported only on implementations ... If the standard mandates an integer as throw argument, ... should be an integer wide enough to encode a pointer if necessary. ...
    (comp.std.c)
  • Re: Memory Structure Pointer Problems
    ... typedef struct sta { ... char* name; ... int num_cmpnds; ... A pointer to a struct cmp is almost ...
    (comp.lang.c)
  • Re: [RFC][PATCH 1/4] cgroup: support per cgroup subsys state ID (CSS ID)
    ... Patch for Per-CSS(Cgroup Subsys State) ID and private hierarchy code. ... This patch attaches unique ID to each css and provides following. ... returns pointer to struct cgroup_subysys_state of id. ... using a pointer introduces no such restriction. ...
    (Linux-Kernel)