home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / glibc-1.06 / hurd / hurdports.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-29  |  1.8 KB  |  66 lines

  1. /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <hurd.h>
  20.  
  21. static inline mach_port_t
  22. get (struct _hurd_port *cell)
  23. {
  24.   mach_port_t result;
  25.   error_t err = _HURD_PORT_USE (cell,
  26.                 __mach_port_mod_refs (__mach_task_self (),
  27.                               (result = port),
  28.                               MACH_PORT_RIGHT_SEND,
  29.                               1));
  30.   if (err)
  31.     {
  32.       errno = err;
  33.       return MACH_PORT_NULL;
  34.     }
  35.   else
  36.     return result;
  37. }
  38. #define    GET(type, what) \
  39.   type get##what (void) { return get (&what); }
  40.  
  41. static inline int
  42. set (struct _hurd_port *cell, mach_port_t new)
  43. {
  44.   error_t err;
  45.   if (err = __mach_port_mod_refs (__mach_task_self (), new,
  46.                   MACH_PORT_RIGHT_SEND, 1))
  47.     {
  48.       errno = EINVAL;
  49.       return -1;
  50.     }
  51.   _hurd_port_set (cell, new);
  52.   return 0;
  53. }
  54. #define SET(type, what) \
  55.   int set##what (type new) { return set (&what, new); }
  56.  
  57. #define    GETSET(type, what) \
  58.   GET (type, what) SET (type, what)
  59.  
  60. GETSET (process_t, proc)
  61. GETSET (file_t, cwdir)
  62. GETSET (file_t, crdir)
  63.  
  64. /* setauth is nontrivial; see __setauth.c.  */
  65. GET (auth_t, auth)
  66.