1
dnl ###########################################################################
3
dnl lc_PHYSMEM - Check how to find out the amount of physical memory
5
dnl - sysconf() gives all the needed info on GNU+Linux and Solaris.
6
dnl - BSDs use sysctl().
7
dnl - sysinfo() works on Linux/dietlibc and probably on other Linux systems
8
dnl whose libc may lack sysconf().
10
dnl ###########################################################################
12
dnl Author: Lasse Collin
14
dnl This file has been put into the public domain.
15
dnl You can do whatever you want with this file.
17
dnl ###########################################################################
18
AC_DEFUN([lc_PHYSMEM], [
19
AC_MSG_CHECKING([how to detect the amount of physical memory])
20
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
26
i = sysconf(_SC_PAGESIZE);
27
i = sysconf(_SC_PHYS_PAGES);
31
AC_DEFINE([HAVE_PHYSMEM_SYSCONF], [1],
32
[Define to 1 if the amount of physical memory can be detected
33
with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
34
AC_MSG_RESULT([sysconf])
36
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
37
#include <sys/types.h>
38
#ifdef HAVE_SYS_PARAM_H
39
# include <sys/param.h>
41
#include <sys/sysctl.h>
45
int name[2] = { CTL_HW, HW_PHYSMEM };
47
size_t mem_ptr_size = sizeof(mem);
48
sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
52
AC_DEFINE([HAVE_PHYSMEM_SYSCTL], [1],
53
[Define to 1 if the amount of physical memory can be detected
55
AC_MSG_RESULT([sysctl])
57
dnl sysinfo() is Linux-specific. Some non-Linux systems have
58
dnl incompatible sysinfo() so we must check $host_os.
61
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
62
#include <sys/sysinfo.h>
71
AC_DEFINE([HAVE_PHYSMEM_SYSINFO], [1],
72
[Define to 1 if the amount of physical memory
73
can be detected with Linux sysinfo().])
74
AC_MSG_RESULT([sysinfo])
76
AC_MSG_RESULT([unknown])
80
AC_MSG_RESULT([unknown])