[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX
From: |
Jim Meyering |
Subject: |
Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX |
Date: |
Fri, 20 Mar 2009 07:34:16 +0100 |
Eric Blake wrote:
> According to Jim Meyering on 3/19/2009 3:58 PM:
>> * src/dd.c (O_FULLBLOCK): Compute its value via cpp macros that
>> expand to less than 3KB of rather than to 180KB(!).
>
> Why use a macro at all? All we have to do is come up with a value that is
> bitwise distinct from all the others. In other words, much smaller than
> 3KB, let alone 180KB.
>
> --
> Don't work too hard, make some time for fun as well!
>
> Eric Blake address@hidden
>>From d6a83c9d49c2737a9a0ef9ca7fc4bb9f469e9576 Mon Sep 17 00:00:00 2001
> From: Eric Blake <address@hidden>
> Date: Thu, 19 Mar 2009 22:31:16 -0600
> Subject: [PATCH] dd: use a more portable definition of O_FULLBLOCK
>
> * src/dd.c (O_FULLBLOCK): Compute its value without using a 180KB
> macro. This avoids triggering a compilation failure with HP-UX's cc.
> Reported by Matthew Woehlke.
I like it. Thanks.
However, I'd like to keep O_FULLBLOCK as a single-bit value.
That's slightly less surprising, and makes the change a tad
smaller. How about this?
>From 8e48bb674042700f7c091f053ae5128e6ca691d7 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 19 Mar 2009 20:14:26 +0100
Subject: [PATCH] dd: use a more portable definition of O_FULLBLOCK
* src/dd.c (O_FULLBLOCK): Compute its value without using a 180KB
macro. This avoids triggering a compilation failure with HP-UX's cc.
Reported by Matthew Woehlke.
---
src/dd.c | 33 ++++++++++++++++++---------------
1 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/dd.c b/src/dd.c
index 9a1c875..a1bbd7f 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -265,23 +265,26 @@ static struct symbol_value const conversions[] =
enum
{
- /* Use a value that is larger than that of any other O_ symbol. */
- O_FULLBLOCK = ((MAX (O_APPEND,
- MAX (O_BINARY,
- MAX (O_CIO,
- MAX (O_DIRECT,
- MAX (O_DIRECTORY,
- MAX (O_DSYNC,
- MAX (O_NOATIME,
- MAX (O_NOCTTY,
- MAX (O_NOFOLLOW,
- MAX (O_NOLINKS,
- MAX (O_NONBLOCK,
- MAX (O_SYNC,
- MAX (O_TEXT, 0)))))))))))))) << 1)
+ /* Compute a value that's bitwise disjoint from the union
+ of all O_ values. */
+ v = ~(O_APPEND
+ | O_BINARY
+ | O_CIO
+ | O_DIRECT
+ | O_DIRECTORY
+ | O_DSYNC
+ | O_NOATIME
+ | O_NOCTTY
+ | O_NOFOLLOW
+ | O_NOLINKS
+ | O_NONBLOCK
+ | O_SYNC
+ | O_TEXT),
+ /* Use its lowest bit. */
+ O_FULLBLOCK = v ^ (v & (v - 1))
};
-/* Ensure that we didn't shift it off the end. */
+/* Ensure that we got something. */
verify (O_FULLBLOCK != 0);
#define MULTIPLE_BITS_SET(i) (((i) & ((i) - 1)) != 0)
--
1.6.2.rc1.285.gc5f54
- coreutils 7.1.49-ebb9 FTB risc/HP-UX, Matthew Woehlke, 2009/03/18
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Jim Meyering, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Matthew Woehlke, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Jim Meyering, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Matthew Woehlke, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Jim Meyering, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Jim Meyering, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Matthew Woehlke, 2009/03/19
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Eric Blake, 2009/03/20
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX,
Jim Meyering <=
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Eric Blake, 2009/03/20
- Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Jim Meyering, 2009/03/20
Re: coreutils 7.1.49-ebb9 FTB risc/HP-UX, Matthew Woehlke, 2009/03/19