1996-09-21 23:54:18 +00:00
|
|
|
/* System dependent pieces of sysconf; Mach version
|
2020-01-01 00:14:33 +00:00
|
|
|
Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
1997-06-23 21:55:26 +00:00
|
|
|
This file is part of the GNU C Library.
|
1996-09-21 23:54:18 +00:00
|
|
|
|
1997-06-23 21:55:26 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1996-09-21 23:54:18 +00:00
|
|
|
|
1997-06-23 21:55:26 +00:00
|
|
|
The GNU C Library 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
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1996-09-21 23:54:18 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
1996-09-21 23:54:18 +00:00
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <mach.h>
|
|
|
|
#include <hurd.h>
|
*** empty log message ***
Sat Sep 21 23:42:39 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/getsysstats.c: Include <sys/sysinfo.h>.
(__get_nproc_conf): New function.
Sat Sep 21 14:59:22 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/getsysstats.c: New file.
* shlib-versions (*-*-gnu*): Increment libc to 0.2 for upcoming
binary distribution.
* sysdeps/mach/hurd/Makefile (rtld-installed-name): Provide
definition to override dangerous one in Makeconfig.
* hurd/Makefile (install-headers-nosubdir): Install <rpc/netdb.h>.
($(includedir)/rpc/netdb.h): New rule.
[ This is XXX until sunrpc can be built; <rpc/netdb.h> is
essential. ]
Fri Sep 20 16:06:06 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/hurd/i386/init-first.c (_dl_start): Add definition,
to guarantee link errors if this is included in ld.so.
Thu Sep 19 23:36:19 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* hurd/hurdinit.c (__libc_argv): Provide common decl.
(_hurd_setproc): Don't declare __libc_argv here.
Tue Sep 17 10:51:58 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* malloc/memalign.c (memalign): Only acquire __libc_malloc_lock
for actual modifications to global state.
Fri Sep 13 01:21:36 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/Makefile (includes): Add -I$(common-objpfx)mach/.
* sysdeps/mach/hurd/Makefile (includes): Add
-I$(common-objpfx)hurd/. Reported by Marcus Daniels.
* sysdeps/generic/schedbits.h (struct sched_param): Renamed from
struct sched_params.
* sysdeps/stub/sched_setp.c (__sched_setparam): struct
sched_params -> struct sched_param.
* sysdeps/stub/sched_getp.c (__sched_getparam): Likewise.
* sysdeps/stub/sched_sets.c (__sched_setscheduler): Likewise.
Thu Sep 12 23:58:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/libc-lock.h (__libc_cleanup_region_start): Fix
syntax error.
* stdio-common/Makefile: Put lockfile in routines
unconditionally.
* stdio-common/vfprintf.c (__flockfile, __funlockfile): Declare
this always, not just if _LIBC_REENTRANT.
(__funlockfile): Don't use weak_extern for this one;
__libc_cleanup_region_end might be defined and the use of
__funlockfile can't be protected the way the use of __flockfile
can be.
1996-09-22 03:44:47 +00:00
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the number of processors configured on the system. */
|
|
|
|
int
|
2013-06-08 00:22:23 +00:00
|
|
|
__get_nprocs_conf (void)
|
*** empty log message ***
Sat Sep 21 23:42:39 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/getsysstats.c: Include <sys/sysinfo.h>.
(__get_nproc_conf): New function.
Sat Sep 21 14:59:22 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/getsysstats.c: New file.
* shlib-versions (*-*-gnu*): Increment libc to 0.2 for upcoming
binary distribution.
* sysdeps/mach/hurd/Makefile (rtld-installed-name): Provide
definition to override dangerous one in Makeconfig.
* hurd/Makefile (install-headers-nosubdir): Install <rpc/netdb.h>.
($(includedir)/rpc/netdb.h): New rule.
[ This is XXX until sunrpc can be built; <rpc/netdb.h> is
essential. ]
Fri Sep 20 16:06:06 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/hurd/i386/init-first.c (_dl_start): Add definition,
to guarantee link errors if this is included in ld.so.
Thu Sep 19 23:36:19 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* hurd/hurdinit.c (__libc_argv): Provide common decl.
(_hurd_setproc): Don't declare __libc_argv here.
Tue Sep 17 10:51:58 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* malloc/memalign.c (memalign): Only acquire __libc_malloc_lock
for actual modifications to global state.
Fri Sep 13 01:21:36 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/Makefile (includes): Add -I$(common-objpfx)mach/.
* sysdeps/mach/hurd/Makefile (includes): Add
-I$(common-objpfx)hurd/. Reported by Marcus Daniels.
* sysdeps/generic/schedbits.h (struct sched_param): Renamed from
struct sched_params.
* sysdeps/stub/sched_setp.c (__sched_setparam): struct
sched_params -> struct sched_param.
* sysdeps/stub/sched_getp.c (__sched_getparam): Likewise.
* sysdeps/stub/sched_sets.c (__sched_setscheduler): Likewise.
Thu Sep 12 23:58:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/libc-lock.h (__libc_cleanup_region_start): Fix
syntax error.
* stdio-common/Makefile: Put lockfile in routines
unconditionally.
* stdio-common/vfprintf.c (__flockfile, __funlockfile): Declare
this always, not just if _LIBC_REENTRANT.
(__funlockfile): Don't use weak_extern for this one;
__libc_cleanup_region_end might be defined and the use of
__funlockfile can't be protected the way the use of __flockfile
can be.
1996-09-22 03:44:47 +00:00
|
|
|
{
|
|
|
|
struct host_basic_info hbi;
|
|
|
|
kern_return_t err;
|
|
|
|
mach_msg_type_number_t cnt = HOST_BASIC_INFO_COUNT;
|
1997-06-23 21:55:26 +00:00
|
|
|
|
1999-02-27 20:00:41 +00:00
|
|
|
err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
|
|
|
|
(host_info_t) &hbi, &cnt);
|
*** empty log message ***
Sat Sep 21 23:42:39 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/getsysstats.c: Include <sys/sysinfo.h>.
(__get_nproc_conf): New function.
Sat Sep 21 14:59:22 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/getsysstats.c: New file.
* shlib-versions (*-*-gnu*): Increment libc to 0.2 for upcoming
binary distribution.
* sysdeps/mach/hurd/Makefile (rtld-installed-name): Provide
definition to override dangerous one in Makeconfig.
* hurd/Makefile (install-headers-nosubdir): Install <rpc/netdb.h>.
($(includedir)/rpc/netdb.h): New rule.
[ This is XXX until sunrpc can be built; <rpc/netdb.h> is
essential. ]
Fri Sep 20 16:06:06 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/hurd/i386/init-first.c (_dl_start): Add definition,
to guarantee link errors if this is included in ld.so.
Thu Sep 19 23:36:19 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* hurd/hurdinit.c (__libc_argv): Provide common decl.
(_hurd_setproc): Don't declare __libc_argv here.
Tue Sep 17 10:51:58 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* malloc/memalign.c (memalign): Only acquire __libc_malloc_lock
for actual modifications to global state.
Fri Sep 13 01:21:36 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/Makefile (includes): Add -I$(common-objpfx)mach/.
* sysdeps/mach/hurd/Makefile (includes): Add
-I$(common-objpfx)hurd/. Reported by Marcus Daniels.
* sysdeps/generic/schedbits.h (struct sched_param): Renamed from
struct sched_params.
* sysdeps/stub/sched_setp.c (__sched_setparam): struct
sched_params -> struct sched_param.
* sysdeps/stub/sched_getp.c (__sched_getparam): Likewise.
* sysdeps/stub/sched_sets.c (__sched_setscheduler): Likewise.
Thu Sep 12 23:58:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* sysdeps/mach/libc-lock.h (__libc_cleanup_region_start): Fix
syntax error.
* stdio-common/Makefile: Put lockfile in routines
unconditionally.
* stdio-common/vfprintf.c (__flockfile, __funlockfile): Declare
this always, not just if _LIBC_REENTRANT.
(__funlockfile): Don't use weak_extern for this one;
__libc_cleanup_region_end might be defined and the use of
__funlockfile can't be protected the way the use of __flockfile
can be.
1996-09-22 03:44:47 +00:00
|
|
|
if (err)
|
|
|
|
return __hurd_fail (err);
|
|
|
|
else if (cnt != HOST_BASIC_INFO_COUNT)
|
|
|
|
return __hurd_fail (EIEIO);
|
|
|
|
|
|
|
|
return hbi.max_cpus;
|
|
|
|
}
|
2017-10-01 22:57:00 +00:00
|
|
|
libc_hidden_def (__get_nprocs_conf)
|
2010-01-27 01:44:58 +00:00
|
|
|
weak_alias (__get_nprocs_conf, get_nprocs_conf)
|
1996-09-21 23:54:18 +00:00
|
|
|
|
|
|
|
/* Return the number of processors currently available on the system. */
|
|
|
|
int
|
2013-06-08 00:22:23 +00:00
|
|
|
__get_nprocs (void)
|
1996-09-21 23:54:18 +00:00
|
|
|
{
|
|
|
|
struct host_basic_info hbi;
|
|
|
|
kern_return_t err;
|
|
|
|
mach_msg_type_number_t cnt = HOST_BASIC_INFO_COUNT;
|
1997-06-23 21:55:26 +00:00
|
|
|
|
1999-02-27 20:00:41 +00:00
|
|
|
err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
|
|
|
|
(host_info_t) &hbi, &cnt);
|
1996-09-21 23:54:18 +00:00
|
|
|
if (err)
|
|
|
|
return __hurd_fail (err);
|
|
|
|
else if (cnt != HOST_BASIC_INFO_COUNT)
|
|
|
|
return __hurd_fail (EIEIO);
|
|
|
|
|
|
|
|
return hbi.avail_cpus;
|
|
|
|
}
|
2017-10-01 22:57:00 +00:00
|
|
|
libc_hidden_def (__get_nprocs)
|
2010-01-27 01:44:58 +00:00
|
|
|
weak_alias (__get_nprocs, get_nprocs)
|
1996-09-21 23:54:18 +00:00
|
|
|
|
|
|
|
/* Return the number of physical pages on the system. */
|
2001-02-18 10:38:14 +00:00
|
|
|
long int
|
2013-06-08 00:22:23 +00:00
|
|
|
__get_phys_pages (void)
|
1996-09-21 23:54:18 +00:00
|
|
|
{
|
|
|
|
struct host_basic_info hbi;
|
|
|
|
kern_return_t err;
|
|
|
|
mach_msg_type_number_t cnt = HOST_BASIC_INFO_COUNT;
|
1997-06-23 21:55:26 +00:00
|
|
|
|
1999-02-27 20:00:41 +00:00
|
|
|
err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
|
|
|
|
(host_info_t) &hbi, &cnt);
|
1996-09-21 23:54:18 +00:00
|
|
|
if (err)
|
|
|
|
return __hurd_fail (err);
|
|
|
|
else if (cnt != HOST_BASIC_INFO_COUNT)
|
|
|
|
return __hurd_fail (EIEIO);
|
1997-06-23 21:55:26 +00:00
|
|
|
|
1996-09-21 23:54:18 +00:00
|
|
|
return hbi.memory_size / __vm_page_size;
|
|
|
|
}
|
2017-10-01 22:57:00 +00:00
|
|
|
libc_hidden_def (__get_phys_pages)
|
2010-01-27 01:44:58 +00:00
|
|
|
weak_alias (__get_phys_pages, get_phys_pages)
|
1996-09-21 23:54:18 +00:00
|
|
|
|
|
|
|
/* Return the number of available physical pages */
|
2001-02-18 10:38:14 +00:00
|
|
|
long int
|
2013-06-08 00:22:23 +00:00
|
|
|
__get_avphys_pages (void)
|
1996-09-21 23:54:18 +00:00
|
|
|
{
|
|
|
|
vm_statistics_data_t vs;
|
|
|
|
kern_return_t err;
|
|
|
|
|
2002-02-18 01:50:52 +00:00
|
|
|
#ifdef HOST_VM_INFO
|
|
|
|
{
|
|
|
|
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
|
|
|
|
err = __host_info (__mach_host_self (), HOST_VM_INFO,
|
|
|
|
(host_info_t) &vs, &count);
|
|
|
|
if (!err && count < HOST_VM_INFO_COUNT)
|
|
|
|
err = EGRATUITOUS;
|
|
|
|
}
|
|
|
|
#else
|
1996-09-21 23:54:18 +00:00
|
|
|
err = __vm_statistics (__mach_task_self (), &vs);
|
2002-02-18 01:50:52 +00:00
|
|
|
#endif
|
1996-09-21 23:54:18 +00:00
|
|
|
if (err)
|
|
|
|
return __hurd_fail (err);
|
1997-06-23 21:55:26 +00:00
|
|
|
|
1996-09-21 23:54:18 +00:00
|
|
|
return vs.free_count;
|
|
|
|
}
|
2017-10-01 22:57:00 +00:00
|
|
|
libc_hidden_def (__get_avphys_pages)
|
2010-01-27 01:44:58 +00:00
|
|
|
weak_alias (__get_avphys_pages, get_avphys_pages)
|