* [U-Boot] [PATCH 1/1] fix min/max macros in common.h
@ 2011-01-25 22:30 Aaron Williams
2011-01-27 22:44 ` Aaron Williams
2011-01-31 23:14 ` Aaron Williams
0 siblings, 2 replies; 3+ messages in thread
From: Aaron Williams @ 2011-01-25 22:30 UTC (permalink / raw)
To: u-boot
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
diff --git a/include/common.h b/include/common.h
index d8c912d..cf5c076 100644
--- a/include/common.h
+++ b/include/common.h
@@ -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)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] fix min/max macros in common.h
2011-01-25 22:30 [U-Boot] [PATCH 1/1] fix min/max macros in common.h Aaron Williams
@ 2011-01-27 22:44 ` Aaron Williams
2011-01-31 23:14 ` Aaron Williams
1 sibling, 0 replies; 3+ messages in thread
From: Aaron Williams @ 2011-01-27 22:44 UTC (permalink / raw)
To: u-boot
Any comments on this? This bug caused me a lot of problems since we make use
of 64-bit values quite a bit.
-Aaron
On Tuesday, January 25, 2011 02:30:55 pm Aaron Williams wrote:
> 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
>
> diff --git a/include/common.h b/include/common.h
> index d8c912d..cf5c076 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] fix min/max macros in common.h
2011-01-25 22:30 [U-Boot] [PATCH 1/1] fix min/max macros in common.h Aaron Williams
2011-01-27 22:44 ` Aaron Williams
@ 2011-01-31 23:14 ` Aaron Williams
1 sibling, 0 replies; 3+ messages in thread
From: Aaron Williams @ 2011-01-31 23:14 UTC (permalink / raw)
To: u-boot
Any comments on this? This bug caused me a lot of troube.
-Aaron
On Tuesday, January 25, 2011 02:30:55 pm Aaron Williams wrote:
> 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
>
> diff --git a/include/common.h b/include/common.h
> index d8c912d..cf5c076 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-31 23:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 22:30 [U-Boot] [PATCH 1/1] fix min/max macros in common.h Aaron Williams
2011-01-27 22:44 ` Aaron Williams
2011-01-31 23:14 ` Aaron Williams
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.