1 /* Copyright (C) 1992-2022 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 Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the 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 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <https://www.gnu.org/licenses/>. */ 17 18 #include <mach.h> 19 20 /* These functions are called by MiG-generated code. */ 21 22 static mach_port_t reply_port; 23 24 /* Called by MiG to get a reply port. */ 25 mach_port_t __mig_get_reply_port(void)26__mig_get_reply_port (void) 27 { 28 if (reply_port == MACH_PORT_NULL) 29 reply_port = __mach_reply_port (); 30 31 return reply_port; 32 } 33 34 /* Called by MiG to deallocate the reply port. */ 35 void __mig_dealloc_reply_port(void)36__mig_dealloc_reply_port (void) 37 { 38 mach_port_t port = reply_port; 39 reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */ 40 __mach_port_mod_refs (__mach_task_self (), port, 41 MACH_PORT_RIGHT_RECEIVE, -1); 42 } 43 44 45 /* Called at startup with CPROC == NULL. cthreads has a different version 46 of this function that is sometimes called with a `cproc_t' pointer. */ 47 void __mig_init(void * cproc)48__mig_init (void *cproc) 49 { 50 if (cproc == 0) 51 reply_port = MACH_PORT_NULL; 52 } 53