What is the meaning of leading and trailing underscores in Linux kernel identifiers?

 ̄綄美尐妖づ 提交于 2019-12-05 04:31:55

There are several cases:

  • In public facing headers, i.e. anything that libc will be taking over and putting under /usr/include/linux, the standards specify which symbols should be defined and any other symbols specific to the system shall start with underscore and capital letter or two underscores. That's the reason for __KERNEL__ in particular, because it is used in headers that are included both in kernel and in libc and some declarations are different.
  • In internal code, the convention usually is that symbol __something is workhorse for something excluding some management, often locking. That is a reason for things like __d_lookup . Similar convention for system calls is that sys_something is the system call entry point that handles context switch to and from kernel and calls do_something to do the actual work.
  • The _t suffix is standard library convention for typedefs. E.g. size_t, ptrdiff_t, foff_t and such. Kernel code follows this convention for it's internal types too.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!