Merge pull request #1298 from robertbaldyga/configure-add-get-define

configure: Add get_define() helper function
This commit is contained in:
Robert Baldyga 2022-08-10 14:32:17 +02:00 committed by GitHub
commit 645f221548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 119 additions and 86 deletions

View File

@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl" "linux/genhd.h"
if compile_module $cur_name "struct gendisk *disk = NULL; struct xarray xa; xa = disk->part_tbl;" "linux/genhd.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct gendisk *disk = NULL; struct disk_part_tbl *ptbl; ptbl = disk->part_tbl" "linux/genhd.h"
elif compile_module $cur_name "struct gendisk *disk = NULL; struct disk_part_tbl *ptbl; ptbl = disk->part_tbl;" "linux/genhd.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,13 +9,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "dev_t dev; lookup_bdev(\"some_path\", &dev)" "linux/blkdev.h"
if compile_module $cur_name "dev_t dev; lookup_bdev(\"some_path\", &dev);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "lookup_bdev(\"some_path\")" "linux/fs.h" "linux/blkdev.h"
elif compile_module $cur_name "lookup_bdev(\"some_path\");" "linux/fs.h" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "lookup_bdev(\"some_path\", 0)" "linux/fs.h" "linux/blkdev.h"
elif compile_module $cur_name "lookup_bdev(\"some_path\", 0);" "linux/fs.h" "linux/blkdev.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,13 +9,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bio_clone(NULL, 0)" "linux/bio.h"
if compile_module $cur_name "bio_clone(NULL, 0);" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "bio_clone_kmalloc(NULL, 0)" "linux/bio.h"
elif compile_module $cur_name "bio_clone_kmalloc(NULL, 0);" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "bio_clone_fast(NULL, 0, NULL)" "linux/bio.h"
elif compile_module $cur_name "bio_clone_fast(NULL, 0, NULL);" "linux/bio.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,13 +9,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct bio b = {}; bio_dev(&b); b.bi_bdev = NULL" "linux/bio.h" "linux/genhd.h"
if compile_module $cur_name "struct bio b = {}; bio_dev(&b); b.bi_bdev = NULL;" "linux/bio.h" "linux/genhd.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct bio b = {}; bio_dev(&b); b.bi_disk = NULL" "linux/bio.h"
elif compile_module $cur_name "struct bio b = {}; bio_dev(&b); b.bi_disk = NULL;" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "struct bio b; b.bi_bdev = NULL" "linux/bio.h"
elif compile_module $cur_name "struct bio b; b.bi_bdev = NULL;" "linux/bio.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,16 +9,16 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bio_op(NULL)" "linux/bio.h"
if compile_module $cur_name "bio_op(NULL);" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "REQ_OP_MASK" "linux/blk_types.h"
elif compile_module $cur_name "REQ_OP_MASK;" "linux/blk_types.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "REQ_OP_DISCARD" "linux/blk_types.h"
elif compile_module $cur_name "REQ_OP_DISCARD;" "linux/blk_types.h"
then
echo $cur_name "3" >> $config_file_path
elif compile_module $cur_name "REQ_DISCARD" "linux/blk_types.h"
elif compile_module $cur_name "REQ_DISCARD;" "linux/blk_types.h"
then
echo $cur_name "4" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,13 +9,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct bio b;b.bi_status" "linux/bio.h"
if compile_module $cur_name "struct bio b; b.bi_status;" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct bio b;b.bi_error" "linux/bio.h"
elif compile_module $cur_name "struct bio b; b.bi_error;" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "bio_endio(NULL, 0)" "linux/bio.h"
elif compile_module $cur_name "bio_endio(NULL, 0);" "linux/bio.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct bio b;b.bi_opf" "linux/bio.h"
if compile_module $cur_name "struct bio b; b.bi_opf;" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct bio b;b.bi_rw" "linux/bio.h"
elif compile_module $cur_name "struct bio b; b.bi_rw;" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct bio b;b.bi_iter.bi_size" "linux/bio.h"
if compile_module $cur_name "struct bio b; b.bi_iter.bi_size;" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct bio b;b.bi_size" "linux/bio.h"
elif compile_module $cur_name "struct bio b; b.bi_size;" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "blk_mq_end_request(NULL, 0)" "linux/blk-mq.h"
if compile_module $cur_name "blk_mq_end_request(NULL, 0);" "linux/blk-mq.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "blk_end_request_all(NULL, 0)" "linux/blkdev.h"
elif compile_module $cur_name "blk_end_request_all(NULL, 0);" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct dentry dentry;dentry.d_u.d_alias" "linux/dcache.h"
if compile_module $cur_name "struct dentry dentry; dentry.d_u.d_alias;" "linux/dcache.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct dentry dentry;dentry.d_alias" "linux/dcache.h"
elif compile_module $cur_name "struct dentry dentry; dentry.d_alias;" "linux/dcache.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,13 +9,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "BIO_FLUSH" "linux/bio.h"
if compile_module $cur_name "BIO_FLUSH;" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "REQ_FLUSH" "linux/blk_types.h"
elif compile_module $cur_name "REQ_FLUSH;" "linux/blk_types.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "REQ_PREFLUSH" "linux/blk_types.h"
elif compile_module $cur_name "REQ_PREFLUSH;" "linux/blk_types.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "global_zone_page_state(1)" "linux/mm.h"
if compile_module $cur_name "global_zone_page_state(1);" "linux/mm.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "global_page_state(1)" "linux/mm.h"
elif compile_module $cur_name "global_page_state(1);" "linux/mm.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct hlist_node list" "linux/types.h"
if compile_module $cur_name "struct hlist_node list;" "linux/types.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct list_head list" "linux/list.h"
elif compile_module $cur_name "struct list_head list;" "linux/list.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct file file;file.f_inode" "linux/fs.h"
if compile_module $cur_name "struct file file; file.f_inode;" "linux/fs.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct file file;file->f_dentry->d_inode" "linux/fs.h"
elif compile_module $cur_name "struct file file; file->f_dentry->d_inode;" "linux/fs.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -10,13 +10,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct queue_limits q;q.limits_aux" "linux/blkdev.h"
if compile_module $cur_name "struct queue_limits q; q.limits_aux;" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct queue_limits q;q.max_write_zeroes_sectors" "linux/blkdev.h"
elif compile_module $cur_name "struct queue_limits q; q.max_write_zeroes_sectors;" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "struct queue_limits q;q.max_write_same_sectors" "linux/blkdev.h"
elif compile_module $cur_name "struct queue_limits q; q.max_write_same_sectors;" "linux/blkdev.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -14,16 +14,16 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "submit_bio(NULL)" "linux/bio.h"
if compile_module $cur_name "submit_bio(NULL);" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "submit_bio(NULL)" "linux/fs.h"
elif compile_module $cur_name "submit_bio(NULL);" "linux/fs.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "void *t=submit_bio(0, NULL)" "linux/fs.h"
elif compile_module $cur_name "void *t=submit_bio(0, NULL);" "linux/fs.h"
then
echo $cur_name "4" >> $config_file_path
elif compile_module $cur_name "submit_bio(0, NULL)" "linux/fs.h"
elif compile_module $cur_name "submit_bio(0, NULL);" "linux/fs.h"
then
echo $cur_name "4" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "WRITE" "linux/blk_types.h"
if compile_module $cur_name "WRITE;" "linux/blk_types.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "REQ_WRITE" "linux/blk_types.h"
elif compile_module $cur_name "REQ_WRITE;" "linux/blk_types.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,13 +9,13 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "RQF_SOFTBARRIER" "linux/blkdev.h"
if compile_module $cur_name "RQF_SOFTBARRIER;" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "REQ_SOFTBARRIER" "linux/blk_types.h"
elif compile_module $cur_name "REQ_SOFTBARRIER;" "linux/blk_types.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "BIO_RW_BARRIER" "linux/fs.h"
elif compile_module $cur_name "BIO_RW_BARRIER;" "linux/fs.h"
then
echo $cur_name "3" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct bio b;b.bi_end_io(NULL, 0)" "linux/bio.h"
if compile_module $cur_name "struct bio b; b.bi_end_io(NULL, 0);" "linux/bio.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct bio b;b.bi_end_io(NULL)" "linux/bio.h"
elif compile_module $cur_name "struct bio b; b.bi_end_io(NULL);" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,19 +9,19 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bio_start_io_acct(NULL)" "linux/blkdev.h"
if compile_module $cur_name "bio_start_io_acct(NULL);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h"
elif compile_module $cur_name "generic_start_io_acct(NULL, 0, 0, NULL);" "linux/bio.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "generic_start_io_acct(0, 0, NULL)" "linux/bio.h"
elif compile_module $cur_name "generic_start_io_acct(0, 0, NULL);" "linux/bio.h"
then
echo $cur_name "3" >> $config_file_path
elif compile_module $cur_name "part_round_stats(1, 1)" "linux/genhd.h"
elif compile_module $cur_name "part_round_stats(1, 1);" "linux/genhd.h"
then
echo $cur_name "4" >> $config_file_path
elif compile_module $cur_name "part_round_stats(NULL, 1, 1)" "linux/genhd.h"
elif compile_module $cur_name "part_round_stats(NULL, 1, 1);" "linux/genhd.h"
then
echo $cur_name "5" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -9,10 +9,10 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "blk_queue_write_cache(NULL, 0, 0)" "linux/blkdev.h"
if compile_module $cur_name "blk_queue_write_cache(NULL, 0, 0);" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct request_queue rq;rq.flush_flags" "linux/blkdev.h"
elif compile_module $cur_name "struct request_queue rq; rq.flush_flags;" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# Copyright(c) 2012-2022 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
@ -20,10 +20,10 @@ add_function() {
printf "%s\n" $1 >> $DEFINE_FILE
}
compile_module(){
if [ $# -gt 2 ]
__compile_module(){
if [ $# -gt 1 ]
then
i=3
i=2
while [ "$i" -le "$#" ]; do
INCLUDE+=$(echo -e "\n#include <${!i}>\\n")
i=$((i + 1))
@ -32,9 +32,6 @@ compile_module(){
INCLUDE=""
fi
config_file=$1
test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir
test_module_log=$SCRIPTPATH/configure.d/.${config_file}.log
test_module_file=$test_module_dir/test_mod.c
test_module_obj=$test_module_dir/test_mod.o
@ -48,18 +45,29 @@ compile_module(){
$INCLUDE
int init_module(void) {
$2;
$1
return 0;
}
void cleanup_module(void) {};
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
EOF
#######################################
echo "### $2 ###" >> $test_module_log
echo "### $1 ###" >> $test_module_log
make -C $test_module_dir KERNEL_DIR=${KERNEL_DIR} &>> $test_module_log
return $?
}
compile_module(){
config_file=$1
shift
test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir
test_module_log=$SCRIPTPATH/configure.d/.${config_file}.log
__compile_module $@
local ret=$?
rm -Rf $test_module_dir
@ -72,6 +80,31 @@ compile_module(){
return $ret
}
get_define(){
config_file=$1
define_name=$2
include=$3
test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir
test_module_log=$SCRIPTPATH/configure.d/.${config_file}.log
read -r -d '' CODE << EOM
#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message "$define_name " XSTR($define_name)
EOM
__compile_module "$CODE" "$include"
rm -Rf $test_module_dir
grep -Pom 1 "note:.*$define_name .*" $test_module_log | cut -d' ' -f 5- | tr -d '"'
local ret=$?
rm -f $test_module_log
return $ret
}
kernel_not_supp_fail() {
echo "Current kernel is not supported!"
rm $DEFINE_FILE