1case "$machine" in
2riscv*)
3    xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'`
4    flen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_flen \(.*\)/\1/p'`
5    float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_float_abi_\([^ ]*\) .*/\1/p'`
6    atomic=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep '#define __riscv_atomic' | cut -d' ' -f2`
7
8    case "$xlen" in
9    64 | 32)
10	;;
11    *)
12	echo "Unable to determine XLEN" >&2
13	exit 1
14	;;
15    esac
16
17    case "$flen" in
18    64)
19	float_machine=rvd
20	with_fp_cond=1
21	;;
22    32)
23	echo "glibc does not yet support systems with the F but not D extensions" >&2
24	exit 1
25	;;
26    "")
27	with_fp_cond=0
28	;;
29    *)
30	echo "Unable to determine FLEN" >&2
31	exit 1
32	;;
33    esac
34
35    case "$float_abi" in
36    soft)
37	abi_flen=0
38	;;
39    single)
40	echo "glibc does not yet support the single floating-point ABI" >&2
41	exit 1
42	;;
43    double)
44	abi_flen=64
45	;;
46    *)
47	echo "Unable to determine floating-point ABI" >&2
48	exit 1
49	;;
50    esac
51
52    case "$atomic" in
53    __riscv_atomic)
54        ;;
55    *)
56        echo "glibc requires the A extension" >&2
57	exit 1
58	;;
59    esac
60
61    base_machine=riscv
62    machine=riscv/rv$xlen/$float_machine
63
64    $as_echo "#define RISCV_ABI_XLEN $xlen" >>confdefs.h
65    $as_echo "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h
66    ;;
67esac
68