From 0b47305caa39c0b11f0488f0cc115fd6b09f7922 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 19 Mar 2009 20:14:26 +0100 Subject: 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 | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/dd.c') diff --git a/src/dd.c b/src/dd.c index 9a1c875fe..3ba616b57 100644 --- a/src/dd.c +++ b/src/dd.c @@ -265,23 +265,28 @@ 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 = ~(0 + | 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) -- cgit v1.2.3-54-g00ecf