configure framework: detect make_req_fn type
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
87
configure.d/1_make_req_type.conf
Normal file
87
configure.d/1_make_req_type.conf
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright(c) 2024 Huawei Technologies
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
. $(dirname $3)/conf_framework.sh
|
||||
|
||||
check() {
|
||||
cur_name=$(basename $2)
|
||||
config_file_path=$1
|
||||
|
||||
|
||||
# The commit c62b37d96b6eb3ec5 in the kernel repo introduces `submit_bio`
|
||||
# and removes make_request_fn
|
||||
if compile_module $cur_name "struct block_device_operations x; x.submit_bio;" "linux/blkdev.h";
|
||||
then
|
||||
# If it's impossible to cast the return value of submit_bio()
|
||||
# to an int we're assuming the function is of type void.
|
||||
# It's not a generic solution because the check would pass if
|
||||
# the return type would be a struct, but it can't happend in this
|
||||
# specific scenario
|
||||
# Mind the negation in the condition
|
||||
if ! compile_module $cur_name \
|
||||
"struct block_device_operations x; int y = (int)x.submit_bio(NULL);" "linux/blkdev.h";
|
||||
then
|
||||
# submit_bio is of type void
|
||||
echo $cur_name "1" >> $config_file_path
|
||||
elif compile_module $cur_name \
|
||||
"struct block_device_operations x; blk_qc_t y = x.submit_bio(NULL);" "linux/blkdev.h" ;
|
||||
then
|
||||
# submit_bio is of type blk_qc_t
|
||||
echo $cur_name "2" >> $config_file_path
|
||||
else
|
||||
echo $cur_name "X" >> $config_file_path
|
||||
fi
|
||||
else
|
||||
# If it's impossible to cast the return value of make_request_fn()
|
||||
# to an int we're assuming the function is of type void.
|
||||
# It's not a generic solution because the check would pass if
|
||||
# the return type would be a struct, but it can't happend in this
|
||||
# specific scenario
|
||||
# Mind the negation in the condition
|
||||
if ! compile_module $cur_name \
|
||||
"struct request_queue *q; int y = (int)q->make_request_fn(NULL);" "linux/blkdev.h";
|
||||
then
|
||||
# make_request_fn is of type void
|
||||
echo $cur_name "3" >> $config_file_path
|
||||
elif ! compile_module $cur_name \
|
||||
"struct request_queue *q; blk_qc_t y = q->make_request_fn(NULL);" "linux/blkdev.h";
|
||||
then
|
||||
# make_request_fn is of type blk_qc_t
|
||||
echo $cur_name "4" >> $config_file_path
|
||||
elif ! compile_module $cur_name \
|
||||
"struct request_queue *q; int y = q->make_request_fn(NULL);" "linux/blkdev.h";
|
||||
then
|
||||
# make_request_fn is of type int
|
||||
echo $cur_name "5" >> $config_file_path
|
||||
else
|
||||
echo $cur_name "X" >> $config_file_path
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
apply() {
|
||||
case "$1" in
|
||||
"1")
|
||||
add_define "CAS_KRETURN(_x) return "
|
||||
add_define "CAS_MAKE_REQ_RET_TYPE void " ;;
|
||||
"2")
|
||||
add_define "CAS_KRETURN(_x) ({ return (_x); }) "
|
||||
add_define "CAS_MAKE_REQ_RET_TYPE blk_qc_t " ;;
|
||||
"3")
|
||||
add_define "CAS_KRETURN(_x) return "
|
||||
add_define "CAS_MAKE_REQ_RET_TYPE void " ;;
|
||||
"4")
|
||||
add_define "CAS_KRETURN(_x) ({ return (_x); }) "
|
||||
add_define "CAS_MAKE_REQ_RET_TYPE blk_qc_t " ;;
|
||||
"5")
|
||||
add_define "CAS_KRETURN(_x) ({ return (_x); }) "
|
||||
add_define "CAS_MAKE_REQ_RET_TYPE int " ;;
|
||||
*)
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
conf_run $@
|
||||
Reference in New Issue
Block a user