为什么 getpagesize() return 是一个整数?
Why does getpagesize() return an int?
为什么系统调用 getpagesize()
return 是 int
而不是 unsigned int
或 size_t
?
原型和简短描述如下:
GETPAGESIZE(2)
NAME
getpagesize - get memory page size
SYNOPSIS
#include <unistd.h>
int getpagesize(void);
int
在发明时可能就足够了。但这不再是问题,因为
getpagesize()
自 2001 年以来已从 POSIX 标准中删除,并已被 sysconf()
取代。
你应该使用 sysconf(_SC_PAGESIZE)
.
getpagesize()
returning an int was one of the major reasons why it was removed:
getpagesize
The getpagesize( ) function returns the current page size. It is equivalent to sysconf (_SC_PAGE_SIZE) and sysconf (_SC_PAGESIZE). This interface, returning an int, may have problems representing appropriate values in the future. Also the behaviour is not specified for this interface on systems that support variable size pages. On variable page size systems, a page can be extremely large (theoretically, up to the size of memory). This allows very efficient address translations for large segments of memory that have common page attributes. A note about this has been added to Application Usage, and the interface marked Legacy, with the recommendation that applications should use the sysconf() interface instead.
(强调我的)。
为什么系统调用 getpagesize()
return 是 int
而不是 unsigned int
或 size_t
?
原型和简短描述如下:
GETPAGESIZE(2)
NAME
getpagesize - get memory page size
SYNOPSIS
#include <unistd.h>
int getpagesize(void);
int
在发明时可能就足够了。但这不再是问题,因为
getpagesize()
自 2001 年以来已从 POSIX 标准中删除,并已被 sysconf()
取代。
你应该使用 sysconf(_SC_PAGESIZE)
.
getpagesize()
returning an int was one of the major reasons why it was removed:
getpagesize
The getpagesize( ) function returns the current page size. It is equivalent to sysconf (_SC_PAGE_SIZE) and sysconf (_SC_PAGESIZE). This interface, returning an int, may have problems representing appropriate values in the future. Also the behaviour is not specified for this interface on systems that support variable size pages. On variable page size systems, a page can be extremely large (theoretically, up to the size of memory). This allows very efficient address translations for large segments of memory that have common page attributes. A note about this has been added to Application Usage, and the interface marked Legacy, with the recommendation that applications should use the sysconf() interface instead.
(强调我的)。