7c6da0c213
* include/mach/mach-init.h (__mach_host_self, __mach_task_self): Remove macro magic. (mach_host_self, mach_task_self): Remove macro magic; declare as function. * lib/mach/mach-init.c (mach_host_self, mach_task_self): New function. (mach_init): Use them. * lib/gnu/hurd-start.c (_hurd_start): Use mach_task_self (). * lib/gnu/_exit.c (_exit): Likewise.
76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
/* -*-comment-start: "//";comment-end:""-*-
|
|
* GNU Mes --- Maxwell Equations of Software
|
|
* Copyright © 1992-2016 Free Software Foundation, Inc.
|
|
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
|
*
|
|
* This file is part of GNU Mes.
|
|
*
|
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or (at
|
|
* your option) any later version.
|
|
*
|
|
* GNU Mes is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/** Commentary:
|
|
Taken from GNU C Library
|
|
*/
|
|
|
|
#define _GNU_SOURCE 1
|
|
#define __USE_GNU 1
|
|
#define __FILE_defined 1
|
|
|
|
#include <stdio.h>
|
|
#include <mach/mach-init.h>
|
|
#include <mach.h>
|
|
#include <unistd.h>
|
|
|
|
mach_port_t __mach_task_self_;
|
|
mach_port_t __mach_host_self_;
|
|
vm_size_t __vm_page_size = 0;
|
|
|
|
void
|
|
__mach_init (void)
|
|
{
|
|
kern_return_t err;
|
|
|
|
#ifdef HAVE_HOST_PAGE_SIZE
|
|
if (err = __host_page_size (mach_host_self (), &__vm_page_size))
|
|
_exit (err);
|
|
#else
|
|
{
|
|
vm_statistics_data_t stats;
|
|
if (err = __vm_statistics (mach_task_self (), &stats))
|
|
_exit (err);
|
|
__vm_page_size = stats.pagesize;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
extern mach_port_t __mach_host_self (void);
|
|
|
|
mach_port_t
|
|
mach_host_self (void)
|
|
{
|
|
if (!__mach_host_self_)
|
|
__mach_host_self_ = __mach_host_self ();
|
|
return __mach_host_self_;
|
|
}
|
|
|
|
extern mach_port_t __mach_task_self (void);
|
|
|
|
mach_port_t
|
|
mach_task_self (void)
|
|
{
|
|
if (!__mach_task_self_)
|
|
__mach_task_self_ = __mach_task_self ();
|
|
return __mach_task_self_;
|
|
}
|