HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


log1p (INTEGRITY SERVERS, ALPHA)

Computes ln(1+y) accurately.

Format

#include <math.h>

double log1p (double y);

float log1pf (float y);

long double log1pl (long double y);


Argument

y

A real number greater than - 1.

Description

The log1p functions compute ln(1+y) accurately, even for tiny y.

Return Values

x The natural logarithm of (1+ y).
- HUGE_VAL y is less than - 1 ( errno is set to EDOM), or y = - 1 ( errno is set to ERANGE).
NaN y is NaN; errno is set to EDOM.

logb (INTEGRITY SERVERS, ALPHA)

Returns the radix-independent exponent of the argument.

Format

#include <math.h>

double logb (double x);

float logbf (float x);

long double logbl (long double x);


Argument

x

A nonzero, real number.

Description

The logb functions return the exponent of x, which is the integral part of log2|x|, as a signed floating-point value, for nonzero x.

Return Values

x The exponent of x.
- HUGE_VAL x = 0.0; errno is set to EDOM.
+Infinity x is +Infinity or - Infinity.
NaN y is NaN; errno is set to EDOM.

longjmp

Provides a way to transfer control from a nested series of function invocations back to a predefined point without returning normally; that is, by not using a series of return statements. The longjmp function restores the context of the environment buffer.

Format

#include <setjmp.h>

void longjmp (jmp_buf env, int value);


Arguments

env

The environment buffer, which must be an array of integers long enough to hold the register context of the calling function. The type jmp_buf is defined in the <setjmp.h> header file. The contents of the general-purpose registers, including the program counter (PC), are stored in the buffer.

value

Passed from longjmp to setjmp , and then becomes the subsequent return value of the setjmp call. If value is passed as 0, it is converted to 1.

Description

When setjmp is first called, it returns the value 0. If longjmp is then called, naming the same environment as the call to setjmp , control is returned to the setjmp call as if it had returned normally a second time. The return value of setjmp in this second return is the value you supply in the longjmp call. To preserve the true value of setjmp , the function calling setjmp must not be called again until the associated longjmp is called.

The setjmp function preserves the hardware general-purpose registers, and the longjmp function restores them. After a longjmp , all variables have their values as of the time of the longjmp except for local automatic variables not marked volatile . These variables have indeterminate values.

The setjmp and longjmp functions rely on the OpenVMS condition-handling facility to effect a nonlocal goto with a signal handler. The longjmp function is implemented by generating a HP C RTL specified signal and allowing the OpenVMS condition-handling facility to unwind back to the desired destination. The HP C RTL must be in control of signal handling for any HP C image.

For HP C to be in control of signal handling, you must establish all exception handlers through a call to the VAXC$ESTABLISH function (rather than LIB$ESTABLISH ). See Section 4.2.5 and the VAXC$ESTABLISH function for more information.

Note

The C RTL provides nonstandard decc$setjmp and decc$fast_longjmp functions for Alpha and Integrity server systems. To use these nonstandard functions instead of the standard ones, a program must be compiled with the __FAST_SETJMP or __UNIX_SETJMP macros defined.

Unlike the standard longjmp function, the decc$fast_longjmp function does not convert its second argument from 0 to 1. After a call to decc$fast_longjmp , a corresponding setjmp function returns with the exact value of the second argument specified in the decc$fast_longjmp call.

Restrictions

You cannot invoke the longjmp function from an OpenVMS condition handler. However, you may invoke longjmp from a signal handler that has been established for any signal supported by the HP C RTL, subject to the following nesting restrictions:

longname

Returns the full name of the terminal.

Format

#include <curses.h>

void longname (char *termbuf, char *name);

Function Variants The longname function has variants named _longname32 and _longname64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.9 for more information on using pointer-size-specific functions.

Arguments

termbuf

A string containing the name of the terminal.

name

A character-string buffer with a minimum length of 64 characters.

Description

The terminal name is in a readable format so that you can double-check to be sure that Curses has correctly identified your terminal. The dummy argument termbuf is required for UNIX software compatibility and serves no function in the OpenVMS environment. If portability is a concern, you must write a set of dummy routines to perform the functionality provided by the database termcap in the UNIX system environment.

lrand48

Generates uniformly distributed pseudorandom-number sequences. Returns 48-bit signed long integers.

Format

#include <stdlib.h>

long int lrand48 (void);


Description

The lrand48 function generates pseudorandom numbers using the linear congruential algorithm and 48-bit integer arithmetic.

It returns nonnegative, long integers uniformly distributed over the range of y values such that 0 <= y < 231 .

Before you call the lrand48 function use either srand48 , seed48 , or lcong48 to initialize the random-number generator. You must initialize prior to invoking the lrand48 function, because it stores the last 48-bit Xi generated into an internal buffer. (Although it is not recommended, constant default initializer values are supplied automatically if the drand48 , lrand48 , or mrand48 functions are called without first calling an initialization function.)

The function works by generating a sequence of 48-bit integer values, Xi, according to the linear congruential formula:


       Xn+1 = (aXn+c)mod m        n >= 0 

The argument m equals 248 , so 48-bit integer arithmetic is performed. Unless you invoke the lcong48 function, the multiplier value a and the addend value c are:


      a = 5DEECE66D16 = 2736731631558
      c = B16 = 138

The value returned by the lrand48 function is computed by first generating the next 48-bit Xi in the sequence. Then the appropriate bits, according to the type of data item to be returned, are copied from the high-order (most significant) bits of Xi and transformed into the returned value.

See also drand48 , lcong48 , mrand48 , seed48 , and srand48 .


Return Value

n Signed nonnegative long integers uniformly distributed over the range 0 <= y < 2 31 .

lrint (INTEGRITY SERVERS, ALPHA)

Rounds to the nearest integer value, rounding according to the current rounding direction.

Format

#include <math.h>

long lrint (double x);

long lrintf (float x);

long lrintl (long double x);


Argument

x

A real value.

Description

The lrint functions return the rounded integer value of x, rounded according to the current rounding direction.

Return Values

n Upon success, the rounded integer value.

lround (INTEGRITY SERVERS, ALPHA)

Rounds to the nearest integer value, rounding halfway cases away from zero regardless of the current rounding direction.

Format

#include <math.h>

long lround (double x);

long lroundf (float x);

long lroundl (long double x);


Argument

x

A real value.

Description

The lround functions return the rounded integer value of x, with halfway cases rounded away from zero regardless of the current rounding direction.

Return Values

n Upon success, the rounded integer value.

lseek

Positions a file to an arbitrary byte position and returns the new position.

Format

#include <unistd.h>

off_t lseek (int file_desc, off_t offset, int direction);


Arguments

file_desc

An integer returned by open , creat , dup , or dup2 .

offset

The offset, specified in bytes. The off_t data type is either a 32-bit or a 64-bit integer. The 64-bit interface allows for file sizes greater than 2 GB, and can be selected at compile time by defining the _LARGEFILE feature-test macro as follows:


CC/DEFINE=_LARGEFILE 

direction

An integer indicating whether the offset is to be measured forward from the beginning of the file (direction=SEEK_SET), forward from the current position (direction=SEEK_CUR), or backward from the end of the file (direction=SEEK_END).

Description

The lseek function can position a fixed-length record-access file with no carriage control or a stream-access file on any byte offset, but can position all other files only on record boundaries.

The available Standard I/O functions position a record file at its first byte, at the end-of-file, or on a record boundary. Therefore, the arguments given to lseek must specify either the beginning or end of the file, a 0 offset from the current position (an arbitrary record boundary), or the position returned by a previous, valid lseek call.

This function returns the new file position as an integer of type off_t which, like the offset argument, is either a 64-bit integer if _LARGEFILE is defined, or a 32-bit integer if not.

For a portable way to position an arbitrary byte location with any type of file, see the fgetpos and fsetpos functions.

Caution

If, while accessing a stream file, you seek beyond the end-of-file and then write to the file, the lseek function creates a hole by filling the skipped bytes with zeros.

In general, for record files, lseek should only be directed to an absolute position that was returned by a previous valid call to lseek or to the beginning or end of a file. If a call to lseek does not satisfy these conditions, the results are unpredictable.

See also open , creat , dup , dup2 , and fseek .


Return Values

x The new file position.
- 1 Indicates that the file descriptor is undefined, or a seek was attempted before the beginning of the file.

lstat (INTEGRITY SERVERS, ALPHA)

Retrieves information about the specified file.

Format

#include <sys/stat.h>

int lstat (const char *restrict file_path, struct stat *restrict user_buffer);


Arguments

file_path

The name of the file for which you want to retrieve information.

user_buffer

The stat structure in which information is returned.

Description

The lstat function retrieves information about the specified file (file_path). If the file is a symbolic link, information about the link itself is returned (in contrast to stat , which returns information about the file that the symbolic link points to).

See also symlink , unlink , readlink , realpath , and lchown .


Return Values

0 Successful completion.
-1 Indicates an error. errno is set to any errno value returned by stat .

lwait

Waits for I/O on a specific file to complete.

Format

#include <stdio.h>

int lwait (int fd);


Argument

fd

A file descriptor corresponding to an open file.

Description

The lwait function is used primarily to wait for completion of pending asynchronous I/O.

Return Values

0 Indicates successful completion.
- 1 Indicates an error.

malloc

Allocates an area of memory. These functions are AST-reentrant.

Format

#include <stdlib.h>

void *malloc (size_t size);

Function Variants The malloc function has variants named _malloc32 and _malloc64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.9 for more information on using pointer-size-specific functions.

Argument

size

The total number of bytes to be allocated.

Description

The malloc function allocates a contiguous area of memory whose size, in bytes, is supplied as an argument. The space is not initialized.

Note

The malloc routines call the system routine LIB$VM_MALLOC. Because LIB$VM_MALLOC is designed as a general-purpose routine to allocate memory, it is called upon in a wide array of scenarios to allocate and reallocate blocks efficiently. The most common usage is the management of smaller blocks of memory, and the most important aspect of memory allocation under these circumstances is efficiency.

LIB$VM_MALLOC makes use of its own free space to satisfy requests, once the heap storage is consumed by splitting large blocks and merging adjacent blocks. Memory can still become fragmented, leaving unused blocks. Once heap storage is consumed, LIB$VM_MALLOC manages its own free space and merged blocks to satisfy requests, but varying sizes of memory allocations can cause blocks to be left unused.

Because LIB$VM_MALLOC cannot be made to satisfy all situations in the best possible manner, perform your own memory management if you have special memory usage needs. This assures the best use of memory for your particular application.

The OpenVMS Programming Concepts Manual explains the several memory allocation routines that are available. They are grouped into three levels of hierarchy:
  1. At the highest level are the RTL Heap Management Routines LIB$GET_VM and LIB$FREE_VM, which provide a mechanism for allocating and freeing blocks of memory of arbitrary size. Also at this level are the routines based on the concept of zones, such as LIB$CREATE_VM_ZONE, and so on.
  2. At the next level are the RTL Page Management routines LIB$GET_VM_PAGE and LIB$FREE_VM_PAGE, which allocate a specified number of contiguous pages.
  3. At the lowest level are the Memory Management System Services, such as $CRETVA and $EXPREG, that provide extensive control over address space allocation. At this level, you must manage the allocation precisely.

The maximum amount of memory allocated at once is limited to 0xFFFFD000.


Return Values

x The address of the first byte, which is aligned on a quadword boundary (ALPHA ONLY) or an octaword boundary (INTEGRITY SERVERS ONLY) .
NULL Indicates that the function is unable to allocate enough memory. errno is set to ENOMEM.


Previous Next Contents Index