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.  How should I use the __cu21 builtin function ?

    Posted 12/19/11 05:43 AM
    Hello,

    I wanted to use the builtin function __cu21 to convert UTF-16 to UTF-8 in a C program.
    int __cu21(char *op1, unsigned long op1_len, unsigned short *op2, unsigned long op2_len,unsigned char mask);


    At the end of the CU21 ASM instruction (CU21 R1,R2[,M3]), the contents of register R1+1 are decremented by the number of bytes placed at R1 location. This allows to know exactly the length of the UTF-8 sequence generated.

    It seems that I can't get this length with C interface.
    Moreover, I can't handle return code 1 (opt1 too small) without either parsing the buffer to know the length already converted or restarting the conversion from beggining.

    Can someone explain me why __cu21 doesn't use prototype like iconv which allows to get the registers value at the end of ASM instruction ?

    Thanks for your help.

    Regards,
    SystemAdmin


  • 2.  Re: How should I use the __cu21 builtin function ?

    Posted 02/23/12 12:36 PM
    Hello,

    Apologies for such late reply. Nevertheless your feedback is quite timely and very important to us.
    We in fact have the implementation you desire implemented for PL/1. Given your feedback we have decided to consider this implementation in the XL C/C++ compiler line.

    Thanks,
    Visda
    Visda


  • 3.  Re: How should I use the __cu21 builtin function ?

    Posted 02/23/12 10:29 PM
    Visda,

    I think this is another good example of why GENASM should be supported in all code, not just Metal/C.
    If it's good enough for gcc it should be good enough for xlc. In fact, xlc supports inline assembly in just
    about every platform other than z.
    David Crayford
    DaveyC


  • 4.  Re: How should I use the __cu21 builtin function ?

    Posted 06/02/17 06:45 AM

    Hello, David,

     

    Glad to tell you that the inlined assembly statement is now accepted in z/OS XL C/C++.  To enable this feature ASM option should be specified at compile invocation.

    Here is a link to the V2R2 User's Guide describing this option:

     

    https://www.ibm.com/support/knowledgecenter/SSLTBW_2.2.0/com.ibm.zos.v2r2.cbcux01/asmcop.htm

     

    Thanks,

    Visda

    Visda