Lack of PR_UINT64 macro - for portable 64-bit unsigned int literals.

Andreev Konstantin <[email protected]> Wed, 16 Sep 2009 14:00:08 +0400
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
Hello.

NSPR defines very useful portable macros for integer literals:

   32-bit: PR_INT32{,_MIN,_MAX} PR_UINT32{,_MAX}

There are analogues for

   64-bit: LL{_INIT,_MININT,_MAXINT}  ---- LL_MAXUINT

Unfortunately, there is no macro to define 64-bit unsigned int literal. LL_INIT is not a workaround, because constructs like LL_INIT( 0xff..., ... ) produce compiler warnings about sign change.

So, developers, who need 64-bit unsigned integers, must duplicate platform detection code from prtypes.h/prlong.h. With time these duplicates go out of sync. Here is what NSS SHA-512 (at freebl) does:

---( begin )----
#if PR_BYTES_PER_LONG == 8
#define ULLC(hi,lo) 0x ## hi ## lo ## UL
#elif defined(_MSC_VER)
#define ULLC(hi,lo) 0x ## hi ## lo ## ui64
#else
#define ULLC(hi,lo) 0x ## hi ## lo ## ULL
#endif
---( end )------

  - out of sync, because corresponding detection sequence from prtypes.h/prlong.h is:

---( begin )----
#if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__)
   /*    ## UL   */
#elif defined(WIN32) && !defined(__GNUC__)
   /*    ## ui64   */
#else
   /*    ## ULL   */
#endif
---( end )------

Could NSPR developers, please, add PR_UINT64 macros into the rtypes.h:

   #define PR_UINT64(x) x ## UL
   #define PR_UINT64(x) x ## ui64
   #define PR_UINT64(x) x ## ULL

and LL_UINIT macros into the prlong.h ?

Best regards,
--
Konstantin Andreev, software engineer.