C/C++

C/C++

C/C++

Your one-stop destination to learn and collaborate about the latest innovations in IBM C/C++ for z/OS compilers to develop high-performing C/C++ applications and system programs on z/OS while maximizing hardware use and improving application performance.

 View Only
  • 1.  64bit pointers for nonMetal C program that runs ILP31

    Posted Fri June 23, 2023 03:14 PM

    Hello,

    We are trying to define a 64bit area for a pointer (in case we decide to move to AMODE 64).

    We tried to use the __ptr64 qualifier, but it was rejected because (as it turns out) this is only supported in Metal C.

    Is there an equivalent for a non Metal ILP31 program?

    We looked in  'SYS1.SIEAHDR.H(IHACHDR)' and see this...

    #ifndef __ptr64_t                       
    #define __ptr64_t                       
      #if defined(__IBM_METAL__)            
        typedef void * __ptr64 ptr64_t;     
      #elif defined(_LP64)                  
        typedef void * ptr64_t;             
      #else                                 
        typedef unsigned long long ptr64_t; 
      #endif                                
    #endif        

    Is there a way we can create a qualifier that acts similarly to __ptr64?  

    So, we could use something like char * __ptr64likequaliefier myStuffPtr;  ?

    My understanding is that we would need the qualifier to indicate the length but the pointer type to indicate the type of pointer. 

    Thank you!

    Nancy



    ------------------------------
    Nancy Kilroy
    ------------------------------


  • 2.  RE: 64bit pointers for nonMetal C program that runs ILP31

    Posted Fri June 30, 2023 09:31 AM

    hi Nancy,

    Unfortunately there is no way to add in a qualifier via typedef or other language mechanism as those are syntax constructs. The best approach is what was shown in the header: Using an "unsigned long long" type and casting it as needed.

    Hope this helps.



    ------------------------------
    Linda Chui
    Compilation Technology & Enterprise Products
    IBM Canada
    ------------------------------



  • 3.  RE: 64bit pointers for nonMetal C program that runs ILP31

    Posted Fri June 30, 2023 02:03 PM

    Back in my PL/X days, I think we did something like this:

    dcl
       1 abigstructure,
          3 <some stuff>      
          3 a64bitpointer ptr(64),
             5 * fixed(32),
             5 a31bitpointer ptr(31),
         3 <more stuff>
       ;

    So we could reserve the space for the high order word of a future 64-bt pointer for future use.

    I think you could probably come up with an analogous "struct" in C the does something similar?

    In the future you'd need to do a "change all" in the functional code from a31bitpointer to a64bitpointer or use better names and just change the variable name in the structure...

    <apologies to those reading, Nancy and I have a history of torturing each other over which language is better...>

    Scott



    ------------------------------
    -------------------------
    Scott Fagen
    Mainframe Evangelist
    CDW
    www.cdw.com
    ------------------------------



  • 4.  RE: 64bit pointers for nonMetal C program that runs ILP31

    Posted Fri October 31, 2025 01:39 AM

    Good Analysis. Scott Fagen



    ------------------------------
    Julia Corney
    ------------------------------