[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrapper around macro around ...???

From: Niels Möller
Subject: Re: Wrapper around macro around ...???
Date: 27 Nov 2001 12:41:18 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Jan Atle Ramsli <trollet@skynet.be> writes:

> >  error_t
> >  _hurd_ports_use (int which, error_t (*operate) (mach_port_t))
> >  {
> > +  if (_hurd_ports == NULL)
> > +    return ENOENT;
> >    return HURD_PORT_USE (&_hurd_ports[which], (*operate) (port));
> >  }
> > 
> Could someone please explain what tihs function is doing?

I think it works like this: glibc keeps a process global table
_hurd_ports of ports (like the root directory, current directory,
...). I don't have the glibc sources here, so I'm not sure exactly
what ports are stored there, perhaps also things like open files are
stored in the same table.

_hurd_ports_use extracts one of the ports from that table, and invokes
the function (pointed to by) operate with the port as argument. To
access the table, it uses the macro HURD_PORT_USE, which puts the port
into the local variable port (which exists only in the expansion of
that macro), and which also takes care of all locking that is needed
before and after using the table and the port.

I don't understand all the details of HURD_PORT_USE, like the struct
hurd_userlink argument that is passed to _hurd_port_get and
_hurd_port_free, or what information, besides a mach_port_t, is stored
in a struct hurd_port.

But the overall meaning of the _hurd_ports_use function seems quite
clear. Its first argument, which, is used to select a port from the
table, and its second argument, operate, says what to do with the


reply via email to

[Prev in Thread] Current Thread [Next in Thread]