Jump to 
content
HP.com Home Products and Services Support and Drivers Solutions How to Buy
»  Contact HP

 

HP C

HP C
User's Guide for OpenVMS Systems


Previous Contents Index

6.2.1.24 Compare Store Quadword ( __CMP_STORE_QUAD)

The __CMP_STORE_QUAD function has the following format:

int __CMP_STORE_QUAD (volatile void *source, int64 old_value, int64 new_value,
volatile void *dest);

This function performs a conditional atomic compare and update operation involving one or two quadwords in the same lock region. The value pointed to by source is compared with the quadword old_value. If they are equal, the quadword new_value is conditionally stored into the value pointed to by dest.

The store will not complete if the compare yields unequal values or if there is an intervening store to the lock region involved. To be in the same lock region, source and dest must point to aligned quadwords in the same naturally aligned 16-byte region.

The function returns 0 if the store does not complete, and returns 1 if the store does complete.

6.2.1.25 Convert G_Floating to F_Floating Chopped ( __CVTGF_C)

The __CVTGF_C function converts a double-precision, VAX G_floating-point number to a single-precision, VAX F_floating-point number. This conversion chops to single-precision; then the 8-bit exponent range is checked for overflow or underflow.

This function has the following format:

float __CVTGF_C (double operand);

operand

A double-precision, VAX floating-point number.

6.2.1.26 Convert G_Floating to Quadword ( __CVTGQ)

The __CVTGQ function rounds a double-precision, VAX floating-point number to a 64-bit integer value and returns the result.

This function has the following format:

int64 __CVTGQ (double operand);

operand

A double-precision, VAX floating-point number.

6.2.1.27 Convert IEEE T_Floating to IEEE S_Floating Chopped ( __CVTTS_C)

The __CVTTS_C function converts a double-precision, IEEE T_floating-point number to a single-precision, IEEE S_floating-point number. This conversion chops to single-precision; then the 8-bit exponent range is checked for overflow or underflow.

This function has the following format:

float __CVTTS_C (double operand);

operand

A double-precision, IEEE floating-point number.

6.2.1.28 Convert IEEE T_Floating to Quadword ( __CVTTQ)

The __CVTTQ function rounds a double-precision, IEEE T_floating-point number to a 64-bit integer value and returns the result.

This function has the following format:

int64 __CVTTQ (double operand);

operand

A double-precision, IEEE T_floating-point number.

6.2.1.29 Convert X_Floating to Quadword ( __CVTXQ)

The __CVTXQ function converts an X_floating-point number to a 64-bit integer value and returns the result.

This function has the following format:

int64 __CVTXQ (long double operand);

operand

An X_floating-point number.

6.2.1.30 Convert X_Floating to IEEE T_Floating Chopped ( __CVTXT_C)

The __CVTXT_C function converts an X_floating-point number to an IEEE T_floating-point number and returns the result.

This function has the following format:

double __CVTXT_C (long double operand);

operand

An X_floating-point number.

6.2.1.31 Copy Sign Built-in Functions

Built-in functions are provided to copy selected portions of single- and double-precision, floating-point numbers.

These built-in functions have the following format:

float __CPYSF (float operand1, float operand2);
double __CPYS (double operand1, double operand2);
float __CPYSNF (float operand1, float operand2);
double __CPYSN (double operand1, double operand2);
float __CPYSEF (float operand1, float operand2);
double __CPYSE (double operand1, double operand2);

The copy sign built-ins (__CPYSF and __CPYS) fetch the sign bit in operand1, concatenate it with the exponent and fraction bits from operand2, and return the result.

The copy sign negate built-ins (__CPYSNF and __CPYSN) fetch the sign bit in operand1, complement it, concatenate it with the exponent and fraction bits from operand2, and return the result.

The copy sign exponent built-ins (__CPYSEF and __CPYSE) fetch the sign and exponent bits from operand1, concatenate them with the fraction bits from operand2, and return the result.

6.2.1.32 Cosine ( __COS)

The __COS built-in function is functionally equivalent to its counterpart, cos , in the standard header file <math.h> .

Its format is also the same:

#include <math.h>
double __COS (double x);

x

A radian value.

This built-in offers performance improvements because there is less call overhead associated with its use.

If you include <math.h> , the built-in is automatically used for all occurrences of cos . To disable the built-in, use #undef cos .

6.2.1.33 Double-Precision, Floating-Point Arithmetic Built-in Functions

The following built-in functions provide double-precision, floating-point chopped arithmetic:
__ADDG_C __ADDT_C __SUBG_C __SUBT_C
__MULG_C __MULT_C __DIVG_C __DIVT_C

They have the following format:

double __op{G,T}_C (double operand1, double operand2);

Where op is one of ADD, SUB, MUL, DIV, and {G,T} represents VAX or IEEE floating-point arithmetic, respectively.

The result of the arithmetic operation is returned.

6.2.1.34 Floating-Point Absolute Value ( __FABS)

The __FABS built-in function is functionally equivalent to its counterpart, fabs , in the standard header file <math.h> .

Its format is also the same:

#include <math.h>
double __FABS (double x);

x

A floating-point number.

This built-in offers performance improvements because there is no call overhead associated with its use.

If you include <math.h> , the built-in is automatically used for all occurrences of fab . To disable the built-in, use #undef fab .

6.2.1.35 _leadz

The _leadz built-in function returns the number of leading zeroes (starting at the most significant bit position) in its argument. For example, _leadz(1) returns 63, and _leadz(0) returns 64.

This function has the following format:

int64 _leadz (unsigned int64);

6.2.1.36 Long Double-Precision, Floating-Point Arithmetic Built-in Functions

The following built-in functions provide long double-precision, floating-point chopped arithmetic:
__ADDX_C __SUBX_C
__MULX_C __DIVX_C

They have the following format:

long double __opX_C (long double operand1, long double operand2);

Where op is one of ADD, SUB, MUL, DIV.

The result of the arithmetic operation is returned.

6.2.1.37 Longword Absolute Value ( __LABS)

The __LABS built-in is functionally equivalent to its counterpart, labs , in the standard header file <stdlib.h> .

Its format is also the same:

#include <stdlib.h>
long int __LABS (long int x);

x

An integer.

This built-in offers performance improvements because there is less call overhead associated with its use.

If you include <stdlib.h> , the built-in is automatically used for all occurrences of labs . To disable the built-in, use #undef labs .

6.2.1.38 Lock and Unlock Longword (__LOCK_LONG, __UNLOCK_LONG)

The __LOCK_LONG and __UNLOCK_LONG functions provide a binary spinlock capability based on the low-order bit of a longword.

The __LOCK_LONG function executes in a loop waiting for the bit to be cleared and then sets it within a load-locked/store-conditional sequence; it then issues a memory barrier. The __UNLOCK_LONG function issues a memory barrier and then zeroes the longword.

The __LOCK_LONG_RETRY function returns 1 if the lock was acquired in the specified number of retries and 0 if the lock was not acquired.

The __LOCK_LONG function has the following formats:

int __LOCK_LONG (volatile void *address);
int __LOCK_LONG_RETRY (volatile void *address, int retry);

The __UNLOCK_LONG function has the following format:

int __UNLOCK_LONG (volatile void *address);

address

The quadword-aligned address of the longword used for the lock.

retry

A retry count of type int that indicates the number of times the operation is attempted (which is at least once, even if the retry argument is 0). If the operation cannot be performed successfully in the specified number of retries, the function returns without updating the longword.

6.2.1.39 Memory Barrier ( __MB)

The __MB function directs the compiler to generate a memory barrier instruction.

This function has the following format:

void __MB (void);

6.2.1.40 Memory Copy and Set Functions ( __MEMCPY, __MEMMOVE, __MEMSET)

The __MEMCPY, __MEMMOVE, and __MEMSET built-ins are functionally equivalent to their run-time routine counterparts in the standard header file <string.h> .

Their format is also the same:

#include <string.h>
void *__MEMCPY (void *s1, const void *s2, size_t size);
void *__MEMMOVE (void *s1, const void *s2, size_t size);
void *__MEMSET (void *s, int value, size_t size);

These built-ins offer performance improvements because there is less call overhead associated with their use.

If you include <string.h> , the built-ins are automatically used for all occurrences of memcpy , memmove , and memset . To disable the built-ins, use #undef memcpy , #undef memmove , and #undef memset .

6.2.1.41 OR Atomic Longword ( __OR_ATOMIC_LONG)

The __OR_ATOMIC_LONG function performs a bit-wise or arithmetic OR of the specified expression with the aligned longword pointed to by the address parameter within a load-locked/store-conditional code sequence.

This function has the following format:

int __OR_ATOMIC_LONG (void *address, int expression, ...);

address

The address of the aligned longword.

expression

An integer expression.

...

An optional retry count of type int . If specified, the retry count indicates the number of times the operation is attempted (which will be at least once, even if the count argument is 0). If the operation cannot be performed successfully in the specified number of retries, a value of 0 is returned. If the operation is successful, a value of 1 is returned.

Note

If the optional retry count is omitted, this function loops back for a retry unconditionally on failure. In this case, the function can never return a failure value. It can either return a value of 1 upon successful completion, or it can hang in an endless failure loop.

6.2.1.42 OR Atomic Quadword ( __OR_ATOMIC_QUAD)

The __OR_ATOMIC_QUAD function performs a bit-wise or arithmetic OR of the specified expression with the aligned quadword pointed to by the address parameter within a load-locked/store-conditional code sequence.

This function has the following format:

int __OR_ATOMIC_QUAD (void *address, int expression, ...);

address

The address of the aligned quadword.

expression

An integer expression.

...

An optional retry count of type int . If specified, the retry count indicates the number of times the operation is attempted (which will be at least once, even if the count argument is 0). If the operation cannot be performed successfully in the specified number of retries, a value of 0 is returned. If the operation is successful, a value of 1 is returned.

Note

If the optional retry count is omitted, this function loops back for a retry unconditionally on failure. In this case, the function can never return a failure value. It can either return a value of 1 upon successful completion, or it can hang in an endless failure loop.

6.2.1.43 Privileged Architecture Library Code Instructions

The following sections describe the Privileged Architecture Library Code (PALcode) instructions that are available as built-in functions.

6.2.1.44 __PAL_BPT

This function is provided for program debugging. It switches the processor to kernel mode and pushes registers R2 through R7, the updated PC, and PS onto the kernel stack. It then dispatches to the address in the breakpoint vector, which is stored in a control block.

This function has the following format:

void __PAL_BPT (void);

6.2.1.45 __PAL_BUGCHK

This function is provided for error reporting. It switches the processor to kernel mode and pushes registers R2 through R7, the updated PC, and PS onto the kernel stack. It then dispatches to the address in the bugcheck vector, which is stored in a control block.

This function has the following format:

void __PAL_BUGCHK (unsigned __int64 code);

6.2.1.46 __PAL_CFLUSH

This function flushes at least the entire physical page specified by the page frame number value from any data caches associated with the current processor. After a CFLUSH is done, the first subsequent load on the same processor to an arbitrary address in the target page is fetched from physical memory.

This function has the following format:

void __PAL_CFLUSH (int value);

value

A page frame number.

6.2.1.47 __PAL_CHME

This function allows a process to change its mode to Executive in a controlled manner. The change in mode also results in a change of stack pointers: the old pointer is saved and the new pointer is loaded. Registers R2 through R7, PS, and PC are pushed onto the selected stack. The saved PC addresses the instruction following the CHME instruction.

This function has the following format:

void __PAL_CHME (void);

6.2.1.48 __PAL_CHMK

This function allows a process to change its mode to kernel in a controlled manner. The change in mode also results in a change of stack pointers: the old pointer is saved and the new pointer is loaded. Registers R2 through R7, PS, and PC are pushed onto the kernel stack. The saved PC addresses the instruction following the CHMK instruction.

This function has the following format:

void __PAL_CHMK (void);

6.2.1.49 __PAL_CHMS

This function allows a process to change its mode to Supervisor in a controlled manner. The change in mode also results in a change of stack pointers: the old pointer is saved and the new pointer is loaded. Registers R2 through R7, PS, and PC are pushed onto the selected stack. The saved PC addresses the instruction following the CHMS instruction.

This function has the following format:

void __PAL_CHMS (void);

6.2.1.50 __PAL_CHMU

This function allows a process to call a routine using the change mode mechanism. Registers R2 through R7, PS, and PC are pushed onto the current stack. The saved PC addresses the instruction following the CHMU instruction.

This function has the following format:

void __PAL_CHMU (void);

6.2.1.51 __PAL_DRAINA

This function stalls instruction issuing until all prior instructions are guaranteed to complete without incurring aborts.

This function has the following format:

void __PAL_DRAINA (void);


Previous Next Contents Index

Privacy statement Using this site means you accept its terms
© 2007 Hewlett-Packard Development Company, L.P.