__KERNEL__ 在 linux 内核中有什么用? [英] what is __KERNEL__ used for in linux kernel?

查看:35
本文介绍了__KERNEL__ 在 linux 内核中有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下下面的代码是什么意思?

who can explain what does the following code means?

如果 __KERNEL__ 未定义,则定义以下宏.何时何地定义 __KERNEL__ ?

if __KERNEL__ is not defined, define following macros. when and where define __KERNEL__ ?

/* only for userspace compatibility */
#ifndef __KERNEL__

/* IP6 Hooks */
/* After promisc drops, checksum checks. */
#define NF_IP6_PRE_ROUTING  0
/* If the packet is destined for this box. */
#define NF_IP6_LOCAL_IN     1
/* If the packet is destined for another interface. */
#define NF_IP6_FORWARD      2
/* Packets coming from a local process. */
#define NF_IP6_LOCAL_OUT        3
/* Packets about to hit the wire. */
#define NF_IP6_POST_ROUTING 4
#define NF_IP6_NUMHOOKS     5
#endif /* ! __KERNEL__ */

推荐答案

当您编译内核时,__KERNEL__ 在命令行中定义.

When you compile your kernel, __KERNEL__ is defined on the command line.

用户空间程序需要访问内核头文件,但内核头文件中的一些信息仅适用于内核.将一些语句包装在 #ifdef __KERNEL__/#endif 块中可确保用户空间程序看不到这些语句.

User-space programs need access to the kernel headers, but some of the info in kernel headers is intended only for the kernel. Wrapping some statements in an #ifdef __KERNEL__/#endif block ensures that user-space programs don't see those statements.

这篇关于__KERNEL__ 在 linux 内核中有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆