dt: fix binary operation errors
PATCH 1/1 dt: fix binary operation errors
Some GCC toolchains does not define _BSD_SOURCE when passing -D_GNU_SOURCE, and that is causing the declaration of large_t as double.
In that case, GCC is complaining in some binary operations like the code below:
dtgen.c:1653:59: error: invalid operands to binary % (have ?large_t? and ?u_int32?)
(dip->di_data_limit != INFINITY) && (dip->di_data_limit % dip->di_dsize) ) {
^This patch adds a statement in the include file to define large_t as "long long int" when __GNUC__ is defined.
Fixes:
http://autobuild.buildroot.net/results/e7b803bd007c125e23eeae351acfc08628333706
http://autobuild.buildroot.net/results/72ca2970db41463435765b90c069417b8bb8a3fd
http://autobuild.buildroot.net/results/22d18f0ca19898be02118c64e615ffbbb23ee46d
http://autobuild.buildroot.net/results/ab50d1d4af47b026da77a81224500a4627c718ac
...
--- package/dt/0002-Fix-binary-operations-errors.patch | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 package/dt/0002-Fix-binary-operations-errors.patch
package/dt/0002-Fix-binary-operations-errors.patch new file +50 -0
@@ -0,0 +1,50 @@ +From 80bbf34b032bf11647d87ea07c1a0c5cf7f87957 Mon Sep 17 00:00:00 2001 +From: Sergio Prado <[email protected]> +Date: Fri, 4 Mar 2016 21:25:02 -0300 +Subject: [PATCH] Fix binary operations errors +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some GCC toolchains does not define _BSD_SOURCE when passing -D_GNU_SOURCE, and that is causing the declaration of large_t as double. + +In that case, GCC is complaining in some binary operations like the code below: + +dtgen.c:1653:59: error: invalid operands to binary % (have ?large_t? and ?u_int32?) + (dip->di_data_limit != INFINITY) && (dip->di_data_limit % dip->di_dsize) ) { + ^ + +So we need to add a statement to force large_t as "long long int" when __GNUC__ is defined. + +Signed-off-by: Sergio Prado <[email protected]> +--- + common.h | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/common.h b/common.h +index 0cf9dc2145ee..a702d2d8dcff 100644 +--- a/common.h ++++ b/common.h +@@ -170,11 +170,18 @@ typedef volatile slarge_t v_slarge; + #define FUF LUF + #define FXF LXF + +-#else /* !defined(MACHINE_64BITS) && !defined(__GNUC__) */ ++#else /* !defined(MACHINE_64BITS) */ + ++#if (defined(__GNUC__)) ++#define QuadIsLongLong ++typedef unsigned long long int large_t; ++typedef signed long long int slarge_t; ++#else + #define QuadIsDouble + typedef double large_t; + typedef double slarge_t; ++#endif ++ + typedef volatile large_t v_large; + typedef volatile slarge_t v_slarge; + +-- +1.9.1 +
Signature · 1 line
1.9.1
PATCH 1/1 dt: fix binary operation errors
Quoted 12 lines · Sergio Prado
Some GCC toolchains does not define
_BSD_SOURCEwhen passing -D_GNU_SOURCE, and that is causing the declaration oflarge_tas double.In that case, GCC is complaining in some binary operations like the code below:
dtgen.c:1653:59: error: invalid operands to binary % (have ?large_t? and ?u_int32?)
(dip->di_data_limit != INFINITY) && (dip->di_data_limit % dip->di_dsize) ) { ^This patch adds a statement in the include file to define
large_tas "long long int" when__GNUC__is defined.
Quoted 8 lines
Fixes:
http://autobuild.buildroot.net/results/e7b803bd007c125e23eeae351acfc08628333706
http://autobuild.buildroot.net/results/72ca2970db41463435765b90c069417b8bb8a3fd
http://autobuild.buildroot.net/results/22d18f0ca19898be02118c64e615ffbbb23ee46d
http://autobuild.buildroot.net/results/ab50d1d4af47b026da77a81224500a4627c718ac
...Signed-off-by Sergio Prado <[email protected]>
Hi Sergio.
Actually the correct fix is detecting/using _DEFAULT_SOURCE :
http://pkgs.fedoraproject.org/cgit/rpms/dt.git/commit/dt-default-source-define.patch?id=a3107b34a3efc6af66a5f892514f233bb66eb6b5
See: http://man7.org/linux/man-pages/man7/feature_test_macros.7.html
regarding _BSD_SOURCE deprecation and _DEFAULT_SOURCE. Care to spin a v2 with the proper fix?
Regards.