VMS Help
CC, Language topics, Builtin Functions
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Built-in functions allow you to directly access hardware and
machine instructions to perform operations that are cumbersome,
slow, or impossible in pure C.
These functions are very efficient because they are built into the
Compaq 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 VAX or Alpha 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.
Compaq 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 Compaq C for OpenVMS VAX built-in functions use enumerated
typedefs to define possible return values. We recommend that you
use the enumerated types to store and compare return values.
1 - Add Aligned Word Interlocked
|
The _ADAWI function adds its source operand to the destination.
This operation is interlocked against similar operations by other
processors or devices in the system.
Syntax:
typedef enum {_adawi_sum_neg=-1, _adawi_sum_zero,
_adawi_sum_pos} _ADAWI_STATUS;
_ADAWI_STATUS _ADAWI(short __src, short *__dest);
Allocates n bytes from the stack and returns a pointer to the
allocated memory.
Syntax:
void *__ALLOCA (unsigned int n);
3 - Branch on Bit Clear-Clear Interlocked
|
The _BBCCI function performs the following functions in interlocked
fashion:
o Returns the complement of the bit specified by the two
arguments
o Clears the bit specified by the two arguments
Syntax:
typedef enum {_bbcci_oldval_1, _bbcci_oldval_0} _BBCCI_STATUS;
_BBCCI_STATUS _BBCCI(int __position, void *__address);
4 - Branch on Bit Set-Set Interlocked
|
The _BBSSI function performs the following functions in interlocked
fashion:
o Returns the status of the bit specified by the two arguments
o Sets the bit specified by the two arguments
Syntax:
typedef enum {_bbssi_oldval_0, _bbcci_oldval_1} _BBSSI_STATUS;
_BBSSI_STATUS _BBSSI(int __position, void *__address);
The _FFC function finds the position of the first clear bit in a
field. The bits are tested for clear status starting at bit 0 and
extending to the highest bit in the field.
Syntax:
typedef enum {_ff_bit_not_found, _ff_bit_found} _FF_STATUS;
_FF_STATUS _FFC(int __start, char __size, const void * __base,
int *__position);
The _FFS function finds the position of the first set bit in a
field. The bits are tested for set status starting at bit 0 and
extending to the highest bit in the field.
Syntax:
typedef enum {_ff_bit_not_found, _ff_bit_found} _FF_STATUS;
_FF_STATUS _FFS(int __start, char __size, const void *__base,
int *__position);
The _HALT function halts the processor when executed by a process
running in kernel mode. This is a privileged function.
Syntax:
void _HALT(void);
8 - Insert Entry into Queue at Head Interlocked
|
The _INSQHI function inserts an entry into the front of a queue in
an indivisible manner. This operation is interlocked against
similar operations by other processors or devices in the system.
Syntax:
typedef enum {_insqi_inserted_many, _insqi_not_inserted,
_insqi_inserted_only} _INSQI_STATUS;
_INSQI_STATUS _INSQHI(void *__new_entry, void *__head);
9 - Insert Entry into Queue at Tail Interlocked
|
The _INSQTI function inserts an entry at the end of a queue in an
indivisible manner. This operation is interlocked against similar
operations by other processors or devices in the system.
Syntax:
typedef enum {_insqi_inserted_many, _insqi_not_inserted,
_insqi_inserted_only} _INSQI_STATUS;
_INSQI_STATUS _INSQTI(void *__new_entry, void *__head);
10 - Insert Entry in Queue
|
The _INSQUE function inserts a new entry into a queue following an
existing entry.
Syntax:
typedef enum {_insque_inserted_only, _insque_inserted_many}
_INSQUE_STATUS;
_INSQUE_STATUS _INSQUE(void *__new_entry, void
*__predecessor);
The _LOCC function locates the first character in a string matching
the target character.
Syntax:
unsigned short _LOCC(char __target, unsigned short __length,
const char *__string, ...);
where the optional argument (...) is char **position.
12 - Move from Processor Register
|
The _MFPR function returns the contents of a processor register.
This is a privileged function.
Syntax:
void _MFPR(int register_num, int *destination);
void _MFPR(int register_num, unsigned int *destination);
13 - Move Character 3 Operand
|
The _MOVC3 function copies a block of memory. It is the preferred
way to copy a block of memory to a new location.
Syntax:
void _MOVC3(unsigned short __length, const char *__src, char
*__dest, ...);
where the ... is one or two optional arguments:
o char **endscr
o char **enddest
14 - Move Character 5 Operand
|
The _MOVC5 function allows the source string specified by the
pointer and length pair to be moved to the destination string
specified by the other pointer and length pair. If the source
string is smaller than the destination string, the destination
string is padded with the specified character.
Syntax:
void _MOVC5(unsigned short __srclen, const char *__src, char
__fill, unsigned short __destlen, char *__dest,
...);
where the ... is one to three optional arguments:
o unsigned short *unmoved_src
o char ** endscr
o char **enddest
15 - Move from Processor Status Longword
|
The _MOVPSL function stores the value of the Processor Status
Longword (PSL).
Syntax:
void _MOVPSL(void *__psl);
16 - Move to Processor Register
|
The _MTPR function loads a value into one of the special processor
registers. It is a privileged function.
Syntax:
int _MTPR(int src, int register_num);
17 - Probe Read Accessibility
|
The _PROBER function checks to see if you can read the first and
last byte of the given address and length pair.
Syntax:
typedef enum {_probe_not_accessible, _probe_accessible}
_PROBE_STATUS;
_PROBE_STATUS _PROBER(char __mode, unsigned short __length,
const void *__address);
18 - Probe Write Accessibility
|
The _PROBEW function checks the write accessibility of the first
and last byte of the given address and length pair.
Syntax:
typedef enum {_probe_not_accessible, _probe_accessible}
_PROBE_STATUS;
_PROBE_STATUS _PROBEW(char __mode, unsigned short __length,
const void *__address);
19 - Read General-Purpose Register
|
The _READ_GPR function returns the value of a general-purpose
register.
Syntax:
int _READ_GPR(int register_number);
20 - Remove Entry from Queue at Head Interlocked
|
The _REMQHI function removes the first entry from the queue in an
indivisible manner. This operation is interlocked against similar
operations by other processors or devices in the system.
Syntax:
typedef enum {_remqi_removed_more, _remqi_not_removed,
_remqi_removed_empty, _remqi_empty}
_REMQI_STATUS;
_REMQI_STATUS _REMQHI(void *__head), void *__removed_entry);
21 - Remove Entry from Queue at Tail Interlocked
|
The _REMQTI function removes the last entry from the queue in an
indivisible manner. This operation is interlocked against similar
operations by other processors or devices in the system.
Syntax:
typedef enum {_remqi_removed_more, _remqi_not_removed,
_remqi_removed_empty, _remqi_empty}
_REMQI_STATUS;
_REMQI_STATUS _REMQTI(void *__head, void *__removed_entry);
22 - Remove Entry from Queue
|
The _REMQUE function removes an entry from a queue.
Syntax:
typedef enum {_remque_removed_more, _remque_removed_empty,
_remque_empty} _REMQUE_STATUS;
_REMQUE_STATUS _REMQUE(void *__entry, void *__removed_entry);
The _SCANC function locates the first character in a string with
the desired attributes. The attributes are specified through a
table and a mask.
Syntax:
unsigned short _SCANC(unsigned short __length, const char
*__string, const char *__table, char
__mask, ...);
where the optional argument (...) is char **match.
The _SKPC function locates the first character in a string that
does not match the target character.
Syntax:
unsigned short _SKPC(char __target, unsigned short __length,
const char *__string, ... );
where the optional argument (...) is char **position.
The _SPANC function locates the first character in a string without
certain attributes. The attributes are specified through a table
and a mask.
Syntax:
unsigned short _SPANC(unsigned short __length, const char
*__string, const char *__table, char
__mask, ...);
where the optional argument (...) is char **mask.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.