fix min/max macros in common.h
PATCH 1/1 fix min/max macros in common.h
In some of my work with the Cavium Octeon 64-bit processor I ran into a problem with the min and max macros provided in common.h. The problem occurs if x is 32-bit and y is 64-bit. In this case, y will always be truncated to 32-bits. This patch fixes this problem.
-Aaron
include/common.h +4 -2
@@ -180,11 +180,13 @@ typedef void (interrupt_handler_t)(void *);* General Purpose Utilities */ #define min (X ,Y ) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x < __y) ? __x : __y; })#define max (X ,Y ) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x > __y) ? __x : __y; })#define MIN (x, y) min(x, y)
PATCH 1/1 fix min/max macros in common.h
Any comments on this? This bug caused me a lot of problems since we make use of 64-bit values quite a bit.
-Aaron
Quoted 31 lines · Aaron Williams
In some of my work with the Cavium Octeon 64-bit processor I ran into a problem with the min and max macros provided in
common.h. The problem occurs if x is 32-bit and y is 64-bit. In this case, y will always be truncated to 32-bits. This patch fixes this problem.(quoted diff) +0
-1-Aaroninclude/common.h +4
-2@@ -180,11 +180,13 @@ typedef void (interrupt_handler_t)(void *);* General Purpose Utilities */ #define min (X ,Y ) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x < __y) ? __x : __y; })#define max (X ,Y ) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x > __y) ? __x : __y; })#define MIN (x, y) min(x, y)_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 1/1 fix min/max macros in common.h
In reply to Aaron WilliamsAny comments on this? This bug caused me a lot of troube.
-Aaron
Quoted 31 lines · Aaron Williams
In some of my work with the Cavium Octeon 64-bit processor I ran into a problem with the min and max macros provided in
common.h. The problem occurs if x is 32-bit and y is 64-bit. In this case, y will always be truncated to 32-bits. This patch fixes this problem.(quoted diff) +0
-1-Aaroninclude/common.h +4
-2@@ -180,11 +180,13 @@ typedef void (interrupt_handler_t)(void *);* General Purpose Utilities */ #define min (X ,Y ) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x < __y) ? __x : __y; })#define max (X ,Y ) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x > __y) ? __x : __y; })#define MIN (x, y) min(x, y)_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot