Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

Andreev Konstantin

unread,
Sep 16, 2009, 6:00:08 AM9/16/09
to
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.

Nelson Bolyard

unread,
Sep 16, 2009, 11:31:26 PM9/16/09
to
On 2009-09-16 03:00 , Andreev Konstantin wrote:
> Hello.

Hello. Welcome.
A quick question for you. In some places, your name appears as
Andreev Konstantin and in other places it appears as
Konstantin Andreev. By which name would you prefer to be hailed?

[snip]


> 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 ?

In this email, you have some very specific suggestions that I think could
well be accepted into the NSPR source code. Please register your email
address in Mozilla's bug tracking system bugzilla.mozilla.org and file a
"bug" there, product NSPR, severity: enhancement, and include the text of
your original email proposal.

Our policies and procedures require us to have a bug on file for every
change we make, and you can help accelerate the process by filing the bug.

Thanks and regards,
/Nelson Bolyard

0 new messages