Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Patch for giga- and terabyte size specifiers



On Wed, 19 Feb 2014 13:52:42 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> #if defined(ZSH_64_BIT_TYPE) || defined(LONG_IS_64_BIT)
> #ifdef LONG_IS_64_BIT
> #define ZLONG_CONST(x)  x ## l
> #else
> #define ZLONG_CONST(x)  x ## ll
> #endif
>     case TT_GIGABYTES:
>         scaled += ZLONG_CONST(1073741823);
>         scaled /= ZLONG_CONST(1073741824);
>         break;
>     case TT_TERABYTES:
>         scaled += ZLONG_CONST(1099511627775);
>         scaled /= ZLONG_CONST(1099511627776);
>         break;
> #endif

OK, how about

#if defined(ZSH_64_BIT_TYPE) || defined(LONG_IS_64_BIT)
#ifdef LONG_IS_64_BIT
#define ZLONG_CONST(x)  x ## l
#else
#ifdef ZLONG_IS_LONG_LONG
#define ZLONG_CONST(x)  x ## ll
#else
/*
 * There's some 64-bit type, but we don't know what it is.
 * We'll just cast it and hope the compiler does the right thing.
 */
#define ZLONG_CONST(x) ((zlong)x)
#endif
#else
/* We're stuck with long */
#define ZLONG_CONST(x) (x ## l)
#endif

?  That seems to cover everything we can do within standard C.

pws



Messages sorted by: Reverse Date, Date, Thread, Author