Linux caddr_t 的意义是什么,什么时候使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6381526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:35:15  来源:igfitidea点击:

What is the significance of caddr_t and when is it used?

clinuxmemory-management

提问by kingsmasher1

Can somebody please tell me:

有人可以告诉我:

  1. What is caddr_t?
  2. When is it used ?
  3. How it is different from void*?
  4. When to use void*and when to use caddr_t?
  1. 什么是caddr_t
  2. 什么时候使用?
  3. 它与void*?有什么不同?
  4. 何时使用void*,何时使用caddr_t

Thanks in advance.

提前致谢。

采纳答案by R.. GitHub STOP HELPING ICE

caddr_tis a legacy BSD type associated with some low level calls like mmap, and it should never be used in modern code. It was rejected by the POSIX standard. The standardized mmapuses void *.

caddr_t是与一些低级调用相关的遗留 BSD 类型,如mmap,它永远不应该在现代代码中使用。它被 POSIX 标准拒绝。标准化mmap使用void *

回答by Keith Smith

caddr_twas used as a pointer to a core address. I used it in SVR4 when I needed to access kernel structures from user space (having used mmap to access /dev/kmem). Even when "/proc" existed, the ps command still used mmap of the kernel to start walking the process table. As everybody states it was superseded by void *.

caddr_t被用作指向核心地址的指针。当我需要从用户空间访问内核结构时(使用 mmap 访问/dev/kmem),我在 SVR4 中使用了它。即使/proc存在“ ”,ps 命令仍然使用内核的 mmap 开始遍历进程表。正如每个人所说,它已被 void * 取代。