Request for review: 7102489: RFE: cleanup jlong typedef on __APPLE__ and _LP64 systems

harold seigel harold.seigel at
Fri Jan 11 06:36:06 PST 2013

Hi Vladimir,

Thank you for your comments.  Mac OS defines int64_t as 'long long'.  
So, int64_t needs a different format specifier than jlong, which this 
fix now defines as 'long'.  This is because, as shown below, the Mac OS 
C++ compiler is picky about format specifiers for values of types 'long 
long' and 'long'.

    $ gcc lld.cpp
    lld.cpp: In function int main(int, char**):
    lld.cpp:8: warning: format %lld expects type long long int, but
    argument 2 has type long int
    lld.cpp:9: warning: format %ld expects type long int, but argument 2
    has type int64_t

    $ cat lld.cpp
    #include <stdio.h>
    #include <stdint.h>

    int main(int argc, char * argv[]) {
       long long_val = 5;
       int64_t int64_val = 8;
       printf("long_val: %ld\n", long_val);
       printf("long_val: %lld\n", long_val); <---- Line 8
       printf("int64_val: %ld\n", int64_val); <--- Line 9
       printf("int64_val: %lld\n", int64_val);
       return 0;

That is why I added JLONG_FORMAT.

Thanks, Harold

On 1/10/2013 9:46 PM, Vladimir Kozlov wrote:
> Can we just define INT64_FORMAT as platform specific and use it 
> instead of adding new JLONG_FORMAT?
> Thanks,
> Vladimir
> On 1/10/13 10:39 AM, harold seigel wrote:
>> Hi,
>> Please review the following changes to fix bug 7102489.
>> Summary:
>> The definition of type jlong differed on Mac OS from the other 64 bit
>> platforms.  This fix makes it consistent.  In order to do this, this fix
>> defines new macros, JLONG_FORMAT and JULONG_FORMAT, for printing and
>> scanning jlongs and julongs.
>> This fix also does some cleanup.  Methods jlong_format_specifier() and
>> julong_format_specifer() were removed and some format specifiers were
>> replaced with appropriate macros.
>> Open webrev at
>> <>
>> Bug link at
>> Thank you,
>> Harold
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the hotspot-runtime-dev mailing list