Using built-in functions to improve performance

A built-in function is inline code that is generated in place of an actual function call. The compiler will generate inline code for built-in functions, if the appropriate header files are included in the source code. For a list of the built-in functions, see Using hardware built-in functions.

If you have included the header files but you want to call either the library version of the function or your own version, enclose the function name in parentheses when you make the call. For example, if you wanted to call only memcpy from the header file and use the built-in functions for other memory-related functions, code the function call as follows:
(memcpy)(buf1, buf2, len)
Note: When NOOPT or COMPACT is specified, the compiler might not expand all built-in functions.

The compiler can also generate inline code for some of the C library functions, if the appropriate header files are included in the source code. The inline code behaves exactly the same as these C library functions. For more information, see Using hardware built-in functions in z/OS XL C/C++ Runtime Library Reference.

The following table lists the C library built-in functions and the header files that they belong to.

Table 1. C-library built-in functions
Built-In Function Header File
abs() stdlib.h
alloca() stdlib.h
ceil()1 math.h
ceilf()1 math.h
ceill()1 math.h
decabs() decimal.h
decchk() decimal.h
decfix() decimal.h
fabs()1 math.h
floor()1 math.h
floorf()1 math.h
floorl()1 math.h
fortrc() stdlib.h
memchr() string.h
memcpy() string.h
memcmp() string.h
memset() string.h
strcat() string.h
strchr() string.h
strcmp() string.h
strcpy() string.h
strlen() string.h
strncat() string.h
strncmp() string.h
strncpy() string.h
strrchr() string.h
wmemchr()2 wchar.h
wmemcmp()2 wchar.h
wmemcpy()2 wchar.h
wmemset()2 wchar.h
Notes:
  1. The compiler only attempts to generate inline code for this built-in function when the OPTIMIZE(2) compiler option is in effect.
  2. The compiler only attempts to generate inline code for this built-in function when the ARCH(7) compiler option is in effect. LP64 compiles will not generate inline code.

Related information