(standard c libraries translation )getpagesize

getpagesize - get memory page size
getpagesize-获取内存页大小

所需头文件:
#include <unistd.h>

int getpagesize(void);

The  function getpagesize() returns the number of bytes in a memory page, where "page" is a fixed-length block, the unit for memory allocation and file mapping performed by mmap(2).
getpagesize函数返回一个内存页所包含的字节数,“页”是一个固定长度的块,内存分配和mmap文件映射单元

提示:
Whether getpagesize() is present as a Linux system call depends on the architecture.  If it is, it returns the kernel  symbol  PAGE_SIZE,  whose  value depends  on  the  architecture and machine model.  Generally, one uses binaries that are dependent on the architecture but not on the machine model, in order to have a single binary distribution per architecture.  This means that a user program should not find PAGE_SIZE at compile time  from  a  header file,  but  use  an  actual  system call, at least for those architectures (like sun4) where this dependency exists.  Here libc4, libc5, glibc 2.0 fail because their getpagesize() returns a statically derived value, and does not use a system call.  Things are OK in glibc 2.1.
getpagesize是否作为一个system call实现取决与架构,如果实现了,那么返回kernel的PAGE_SIZE标志,这个值取决于架构和机器的类型,一般来说,为了使每个架构都有一个对应的库函数版本,库函数的使用依赖于架构而不是机器类型,这也就是说用户程序不要在编译期间通过头文件去获取PAGE_SIZE,而是用system call,尤其是在某些架构(例如sun4)这种依赖是存在的,这里libc4,libc5,glibc2.0会失败是因为他们的getpagesize()返回一个静态的引申值,而不是使用system call。直到glibc2.1上这个事情才算解决。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值