autotools ac_check_member宏不适用于Linux内核结构
如果Linux内核结构(称为task_struct)在其中是否有成员变量__STATE,我想定义一个自动工具变量。此结构在Inclubple/linux/sched.h中定义。我还尝试检查该结构中的其他成员变量(例如flags
),但无济于事。
我可以将ac_check_member宏用于struct blk_zone.capacity(如下所示)并获得正确的结果。
我的裸露骨头配置。AC文件重现这一点是:
AC_INIT(hello-1.c)
CPPFLAGS="-I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64"
AC_CHECK_MEMBER([struct task_struct.__state],
[AC_DEFINE(WE_HAVE_STATE, [1], [__state member var was found])],
[], [[#include <linux/sched.h>]])
AC_CHECK_MEMBER([struct blk_zone.capacity],
[AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])],
[], [[#include <linux/blkzoned.h>]])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
我的config.log文件似乎在说文件中没有构造。任何帮助将不胜感激!
configure:2574: checking for struct task_struct.__state
configure:2574: gcc -c -g -O2 -I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64 conftest.c >&5
conftest.c: In function 'main':
conftest.c:14:27: error: storage size of 'ac_aggr' isn't known
static struct task_struct ac_aggr;
^~~~~~~
configure:2574: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #include <linux/sched.h>
|
| int
| main ()
| {
| static struct task_struct ac_aggr;
| if (ac_aggr.__state)
| return 0;
| ;
| return 0;
| }
configure:2574: gcc -c -g -O2 -I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64 conftest.c >&5
conftest.c: In function 'main':
conftest.c:14:27: error: storage size of 'ac_aggr' isn't known
static struct task_struct ac_aggr;
^~~~~~~
configure:2574: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #include <linux/sched.h>
|
| int
| main ()
| {
| static struct task_struct ac_aggr;
| if (sizeof ac_aggr.__state)
| return 0;
| ;
| return 0;
| }
configure:2574: result: no
configure:2582: checking for struct blk_zone.capacity
configure:2582: gcc -c -g -O2 -I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64 conftest.c >&5
configure:2582: $? = 0
configure:2582: result: yes
configure:2742: creating ./config.status
``` ^~~~~~~
I want to define an autotools variable if a Linux kernel struct (called task_struct) has the member variable __state in it or not. This struct is defined in include/linux/sched.h. I have also tried checking other member variables (like flags
) in that struct to no avail.
I am able to use the AC_CHECK_MEMBER macro for the struct blk_zone.capacity (as seen below) and get the correct result.
My bare bones configure.ac file to reproduce this is:
AC_INIT(hello-1.c)
CPPFLAGS="-I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64"
AC_CHECK_MEMBER([struct task_struct.__state],
[AC_DEFINE(WE_HAVE_STATE, [1], [__state member var was found])],
[], [[#include <linux/sched.h>]])
AC_CHECK_MEMBER([struct blk_zone.capacity],
[AC_DEFINE(HAVE_BLK_ZONE_REP_V2, [1], [report zones includes zone capacity])],
[], [[#include <linux/blkzoned.h>]])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
My config.log file seems to be saying that there's no struct named that in the file. Any help would be much appreciated!
configure:2574: checking for struct task_struct.__state
configure:2574: gcc -c -g -O2 -I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64 conftest.c >&5
conftest.c: In function 'main':
conftest.c:14:27: error: storage size of 'ac_aggr' isn't known
static struct task_struct ac_aggr;
^~~~~~~
configure:2574: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #include <linux/sched.h>
|
| int
| main ()
| {
| static struct task_struct ac_aggr;
| if (ac_aggr.__state)
| return 0;
| ;
| return 0;
| }
configure:2574: gcc -c -g -O2 -I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64 conftest.c >&5
conftest.c: In function 'main':
conftest.c:14:27: error: storage size of 'ac_aggr' isn't known
static struct task_struct ac_aggr;
^~~~~~~
configure:2574: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #include <linux/sched.h>
|
| int
| main ()
| {
| static struct task_struct ac_aggr;
| if (sizeof ac_aggr.__state)
| return 0;
| ;
| return 0;
| }
configure:2574: result: no
configure:2582: checking for struct blk_zone.capacity
configure:2582: gcc -c -g -O2 -I/usr/src/kernels/4.18.0-372.9.1.el8.x86_64 conftest.c >&5
configure:2582: $? = 0
configure:2582: result: yes
configure:2742: creating ./config.status
``` ^~~~~~~
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论