VMS Help CXX, Language Topics, Built-In Functions *Conan The Librarian |
Built-in functions allow you direct access hardware and machine instructions to perform operations that are cumbersome, slow, or impossible in pure C. These functions are efficient because they are built into the C++ compiler. This means that a call to one of these functions does not result in a reference to a function in the C run-time library or in your programs. Instead, the compiler generates the machine instructions necessary to carry out the function directly at the call site. Because most of these built-in functions closely correspond to single Alpha or I64 machine instructions, the result is small, fast code. Some of these functions (such as those that operate on strings or bits) are of general interest. Others (such as the functions dealing with process context) are of interest if you are writing device drivers or other privileged software. Some of the functions are privileged and unavailable to user mode programs. Be sure to include the <builtins.h> header file in your source program to access these built-in functions. C++ supports the #pragma builtins preprocessor directive for compatibility with VAX C, but it is not required. Some of the built-in functions have optional arguments or allow a particular argument to have one of many different types. To describe different valid combinations of arguments, the description of each built-in function may list several different prototypes for the function. As long as a call to a built-in function matches one of the prototypes listed, the call is valid. Furthermore, any valid call to a built-in function acts as if the corresponding prototype was in scope, so the compiler performs the argument checking and argument conversions specified by that prototype. The majority of the built-in functions are named after the machine instruction that they generate. For more information on these built-in functions, see the documentation on the corresponding machine instruction. In particular, see that reference for the structure of queue entries manipulated by the queue built-in functions. The C++ built-in functions available on OpenVMS Alpha systems are also available on I64 systems, with some differences. There are also built-in functions specific to I64 systems. For more information on built-in functions, see "Built-In Functions" in the HP C++ User's Guide for OpenVMS Systems. Translation_Macros C++ for OpenVMS Alpha and I64 systems does not support the VAX C built-in functions. However, the <builtins.h> header file contains macro definitions that translate some VAX C builtins to the equivalent C++ for OpenVMS Alpha builtins. Consequently, the following VAX C builtins are effectively supported: _BBCCI (position, address) _BBSSI (position, address) _INSQHI (new_entry, head) _INSQTI (new_entry, head) _INSQUE (new_entry, predecessor) _REMQHI (head, removed_entry) _REMQTI (head, removed_entry) _PROBER (mode, length, address) _PROBEW (mode, length, address) Intrinsic Functions On OpenVMS Alpha systems, C++ supports in-line assembly code, commonly called ASMs on UNIX platforms. OpenVMS I64 systems do not support ASMs. Like builtin-functions, ASMs are implemented with a function- call syntax. But unlike built-in functions, to use ASMs you must include the <c_asm.h> header file containing prototypes for the three types of ASMs, and the #pragma intrinsic preprocessor directive. Syntax: __int64 asm(const char *, ...); /* for integer operations, like mulq */ float fasm(const char *, ...); /* for single precision float instructions */ double dasm(const char *, ...); /* for double precision float instructions */ #pragma intrinsic (asm) #pragma intrinsic (fasm) #pragma intrinsic (dasm) The first argument to the asm, fasm, or dasm function contains the instruction(s) to be generated inline and the metalanguage that describes the interpretation of the arguments. The remaining arguments (if any) are the source and destination arguments for the instruction being generated.
|