From 613df788425dcfa19a222478dbae16a917442f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Buchm=C3=BCller?= Date: Sat, 5 Sep 2020 22:30:58 +0200 Subject: [PATCH] cln: use templates for {int,float}param.h for cross When cross building the configure script hangs or at least takes insane amounts of time for some architectures to create the values for the header files include/cln/{int,float}param.h Since we know our architectures and the sizes of their integer and floating point values, we can just as well create the files from templates using $XBPS_TARGET_WORDSIZE and $XBPS_TARGET_ENDIAN. [ci skip] --- srcpkgs/cln/files/floatparam.h | 17 ++++++ srcpkgs/cln/files/intparam.h | 96 ++++++++++++++++++++++++++++++++++ srcpkgs/cln/template | 40 ++++++++++---- 3 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 srcpkgs/cln/files/floatparam.h create mode 100644 srcpkgs/cln/files/intparam.h diff --git a/srcpkgs/cln/files/floatparam.h b/srcpkgs/cln/files/floatparam.h new file mode 100644 index 00000000000..76237d8575c --- /dev/null +++ b/srcpkgs/cln/files/floatparam.h @@ -0,0 +1,17 @@ +/* Rounding modes, for use below */ +#define rounds_to_nearest 0 /* 0.5 ulp */ +#define rounds_to_zero 1 /* 1 ulp */ +#define rounds_to_infinity 2 /* 1 ulp */ +#define rounds_to_minus_infinity 3 /* 1 ulp */ + +/* Properties of type \`float: */ +/* Largest n for which 1+2^(-n) is exactly represented is 23. */ +/* Largest n for which 1-2^(-n) is exactly represented is 24. */ +#define float_mant_bits 24 +#define float_rounds rounds_to_nearest + +/* Properties of type \`double': */ +/* Largest n for which 1+2^(-n) is exactly represented is 52. */ +/* Largest n for which 1-2^(-n) is exactly represented is 53. */ +#define double_mant_bits 53 +#define double_rounds rounds_to_nearest diff --git a/srcpkgs/cln/files/intparam.h b/srcpkgs/cln/files/intparam.h new file mode 100644 index 00000000000..01740100982 --- /dev/null +++ b/srcpkgs/cln/files/intparam.h @@ -0,0 +1,96 @@ +/* Generated by Void Linux scrpkgs/cln/template */ + +/* Integers of type char have 8 bits. */ +#define char_bitsize 8 + +/* Integers of type short have 16 bits. */ +#define short_bitsize 16 + +/* Integers of type int have 32 bits. */ +#define int_bitsize 32 + +/* Integers of type long have @LBITS@ bits. */ +#define long_bitsize @LBITS@ + +/* Integers of type long long have 64 bits. */ +#define long_long_bitsize 64 + +/* Integers of type unsigned char have 8 bits. */ + +/* Integers of type unsigned short have 16 bits. */ + +/* Integers of type unsigned int have 32 bits. */ + +/* Integers of type unsigned long have @LBITS@ bits. */ + +/* Integers of type unsigned long long have 64 bits. */ + +/* Integer types char and unsigned char have the same binary representation. */ +/* Integer types short and unsigned short have the same binary representation. */ +/* Integer types int and unsigned int have the same binary representation. */ +/* Integer types long and unsigned long have the same binary representation. */ +/* Integer types long long and unsigned long long have the same binary representation. */ + +/* Pointers of type char * have @LBITS@ bits. */ +#define pointer_bitsize @LBITS@ + +/* Casts from long * to char * is OK (does nothing). */ +/* Casts from char * to long * is OK (does nothing). */ +/* Casts from function * to char * is OK (does nothing). */ +/* Casts from char * to function * is OK (does nothing). */ + +/* Type char has sizeof = 1 and alignment = 1. */ +#define sizeof_char 1 +#define alignment_char 1 + +/* Type unsigned char has sizeof = 1 and alignment = 1. */ + +/* Type short has sizeof = 2 and alignment = 2. */ +#define sizeof_short 2 +#define alignment_short 2 + +/* Type unsigned short has sizeof = 2 and alignment = 2. */ + +/* Type int has sizeof = 4 and alignment = 4. */ +#define sizeof_int 4 +#define alignment_int 4 + +/* Type unsigned int has sizeof = 4 and alignment = 4. */ + +/* Type long has sizeof = @LBYTES@ and alignment = @LBYTES@. */ +#define sizeof_long @LBYTES@ +#define alignment_long @LBYTES@ + +/* Type unsigned long has sizeof = @LBYTES@ and alignment = @LBYTES@. */ + +/* Type long long has sizeof = 8 and alignment = 8. */ +#define sizeof_long_long 8 +#define alignment_long_long 8 + +/* Type unsigned long long has sizeof = 8 and alignment = 8. */ + +/* Type float has sizeof = 4 and alignment = 4. */ +#define sizeof_float 4 +#define alignment_float 4 + +/* Type double has sizeof = 8 and alignment = 8. */ +#define sizeof_double 8 +#define alignment_double 8 + +/* Type char * has sizeof = @LBYTES@ and alignment = @LBYTES@. */ + +/* Type long * has sizeof = @LBYTES@ and alignment = @LBYTES@. */ + +/* Type function * has sizeof = @LBYTES@ and alignment = @LBYTES@. */ + +/* Type unsigned short is stored @ENDIAN@-ENDIAN in memory. */ +#define short_@endian@_endian +/* Type unsigned int is stored @ENDIAN@-ENDIAN in memory. */ +#define int_@endian@_endian +/* Type unsigned long is stored @ENDIAN@-ENDIAN in memory. */ +#define long_@endian@_endian +/* Type unsigned long long is stored @ENDIAN@-ENDIAN in memory. */ +#define long_long_@endian@_endian + +/* Stack grows up, ca. @LBYTES@ bytes per function call. */ +#define stack_grows_up diff --git a/srcpkgs/cln/template b/srcpkgs/cln/template index be35057c503..fc771b0f9ad 100644 --- a/srcpkgs/cln/template +++ b/srcpkgs/cln/template @@ -15,15 +15,37 @@ case "$XBPS_TARGET_MACHINE" in arm*|aarch64*) CPPFLAGS="-DNO_ASM";; esac -if [ "$CROSS_BUILD" ]; then - pre_build() { - # During cross build, script builds intparam.h - # with a line starting with: - # #error char size does not fit in intptr - # even though the sizes are correct. - vsed -e '/#error/d' -i include/cln/intparam.h - } -fi +pre_configure() { + if [ "$CROSS_BUILD" ]; then + local ENDIAN="UNKNOWN" + local LBITS=$XBPS_TARGET_WORDSIZE + local LBYTES=$(($XBPS_TARGET_WORDSIZE / 8)) + local INTPARAM_H=${wrksrc}/include/cln/intparam.h + local FLOATPARAM_H=${wrksrc}/include/cln/floatparam.h + + if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then + ENDIAN="BIG" + fi + if [ "$XBPS_TARGET_ENDIAN" = "le" ]; then + ENDIAN="LITTLE" + fi + + # Make substitutions in intparam.h + sed ${FILESDIR}/intparam.h \ + -e "s;@LBITS@;$LBITS;g" \ + -e "s;@LBYTES@;$LBYTES;g" \ + -e "s;@ENDIAN@;$ENDIAN;g" \ + -e "s;@endian@;${ENDIAN,,};g" \ + > ${INTPARAM_H} + + # No substitutions in floatparam.h + cat ${FILESDIR}/floatparam.h \ + > ${FLOATPARAM_H} + + configure_args+=" cl_cv_file_intparam_h=$INTPARAM_H" + configure_args+=" cl_cv_file_floatparam_h=$FLOATPARAM_H" + fi +} cln-devel_package() { short_desc+=" - development files"