HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index

For the _SC_CPU_CHIP_TYPE symbolic constant:

These fields are described in the following table:
Field Bits Description
number 7:0 Index of the largest implemented CPUID register (one less than the number of implemented CPUID registers). This value will be at least 4.
rev 15:8 Processor revision number. An 8-bit value that represents the revision or stepping of this processor implementation within the processor model.
model 23:16 Processor model number. A unique 8-bit value representing the processor model within the processor family.
family 31:24 Processor family number. A unique 8-bit value representing the processor family.


Return Values

x The current variable value on the system. The value does not change during the lifetime of the calling process.
- 1 Indicates an error.

If the value of the name argument is invalid, errno is set to indicate the error.

If the value of the name argument is undefined, errno is unchanged.


system

Passes a given string to the host environment to be executed by a command processor. This function is nonreentrant.

Format

#include <stdlib.h>

int system (const char *string);


Argument

string

A pointer to the string to be executed. If string is NULL, a nonzero value is returned. The string is a DCL command, not the name of an image. To execute an image, use one of the exec routines.

Description

The system function spawns a subprocess and executes the command specified by string in that subprocess. The system function waits for the subprocess to complete before returning the subprocess status as the return value of the function.

The subprocess is spawned within the system call by a call to vfork . Because of this, a call to system should not be made after a call to vfork and before the corresponding call to an exec function.

For OpenVMS Version 7.0 and higher systems, if you include <stdlib.h> and compile with the _POSIX_EXIT feature-test macro set, then the system function returns the status as if it called waitpid to wait for the child. Therefore, use the WIFEXITED and WEXITSTATUS macros (described in the wait * routines) to retrieve the exit status in the range of 0 to 255.

You set the _POSIX_EXIT feature-test macro by using /DEFINE=_POSIX_EXIT or #define _POSIX_EXIT at the top of your file, before any file inclusions.


Return Value

nonzero value If string is NULL, a value of 1 is returned, indicating that the system function is supported. If string is not NULL, the value is the subprocess OpenVMS return status.

Example


#include <stdlib.h> 
#include <stdio.h> 
#include <unistd.h>     /* write, close */ 
#include <fcntl.h>      /* Creat */ 
 
main() 
{ 
    int status, 
        fd; 
 
    /* Creat a file we are sure is there        */ 
 
    fd = creat("system.test", 0); 
    write(fd, "this is an example of using system", 34); 
    close(fd); 
 
    if (system(NULL)) { 
        status = system("DIR/NOHEAD/NOTRAIL/SIZE SYSTEM.TEST"); 
        printf("system status = %d\n", status); 
    } 
    else 
        printf("system() not supported.\n"); 
} 

Running this example program produces the following result:


DISK3$:[JONES.CRTL.2059.SRC]SYSTEM.TEST;1 
                           1 
system status = 1 


tan

Returns a double value that is the tangent of its radian argument.

Format

#include <math.h>

double tan (double x);

float tanf (float x); (INTEGRITY SERVERS, ALPHA)

long double tanl (long double x); (INTEGRITY SERVERS, ALPHA)

double tand (double x); (INTEGRITY SERVERS, ALPHA)

float tandf (float x); (INTEGRITY SERVERS, ALPHA)

long double tandl (long double x); (INTEGRITY SERVERS, ALPHA)


Argument

x

A radian expressed as a real number.

Description

The tan functions compute the tangent of x, measured in radians.

The tand functions compute the tangent of x, measured in degrees.


Return Values

x The tangent of the argument.
HUGE_VAL x is a singular point (... - 3pi/2, - pi/2, pi/2...).
NaN x is NaN; errno is set to EDOM.
0 x is ±Infinity; errno is set to EDOM.
±HUGE_VAL Overflow occurred; errno is set to ERANGE.
0 Underflow occurred; errno is set to ERANGE.

tanh

Returns the hyperbolic tangent of its argument.

Format

#include <math.h>

double tanh (double x);

float tanhf (float x); (INTEGRITY SERVERS, ALPHA)

long double tanhl (long double x); (INTEGRITY SERVERS, ALPHA)


Argument

x

A real number.

Description

The tanh functions return the hyperbolic tangent their argument, calculated as (e**x - e**( - x))/(e**x + e**( - x)).

Return Values

n The hyperbolic tangent of the argument.
HUGE_VAL The argument is too large; errno is set to ERANGE.
NaN x is NaN; errno is set to EDOM.
0 Underflow occurred; errno is set to ERANGE.

telldir

Returns the current location associated with a specified directory stream. Performs operations on directories.

Format

#include <dirent.h>

long int telldir (DIR *dir_pointer);


Argument

dir_pointer

A pointer to the DIR structure of an open directory.

Description

The telldir function returns the current location associated with the specified directory stream.

Return Values

x The current location.
- 1 Indicates an error and is further specified in the global errno .

tempnam

Constructs the name for a temporary file.

Format

#include <stdio.h>

char *tempnam (const char *directory, const char *prefix, ...;)


Arguments

directory

A pointer to the pathname of the directory where you want to create a file.

prefix

A pointer to an initial character sequence of the filename. The prefix argument can be null, or it can point to a string of up to five characters used as the first characters of the temporary filename.

...

An optional argument that can be either 1 or 0. If you specify 1, tempnam returns the file specification in OpenVMS format. If you specify 0, tempnam returns the file specification in UNIX style format. For more information about UNIX style directory specifications, see Section 1.3.3.

Description

The tempnam function generates filenames for temporary files. It allows you to control the choice of a directory.

If the directory argument is null or points to a string that is not a pathname for an appropriate directory, the pathname defined as P_tmpdir in the < stdio.h > header file is used. For programs running under a detached process, the directory argument cannot be null.

You can bypass the selection of a pathname by providing the TMPDIR environment variable in the user environment. The value of the TMPDIR variable is a pathname for the desired temporary file directory.

Use the prefix argument to specify a prefix of up to five characters for the temporary filename.

The tempnam function returns a pointer to the generated pathname, suitable for use in a subsequent call to the free function.

See also free .

Note

In contrast to tmpnam , tempnam does not have to generate a different filename on each call. tempnam generates a new filename only if the file with the specified name exists. If you need a unique filename on each call, use tmpnam instead of tempnam .

Return Values

x A pointer to the generated pathname, suitable for use in a subsequent call to the free function.
NULL An error occurred; errno is set to indicate the error.

tgamma (INTEGRITY SERVERS, ALPHA)

Returns the gamma function of its argument.

Format

#include <math.h>

double tgamma (double x);

float tgammaf (float x);

long double tgammal (long double x);


Argument

x

A real value.

Description

The tgamma functions compute the gamma function of x.

Return Values

n Upon success, the gamma function of x.
- 1 If x is negative. errno is set to EDOM.
±HUGE_VAL Overflow occurred, or x is ±0. errno is set to ERANGE.
NaN If x is NaN or - Inf. errno is set to EDOM.
x If x is +Inf.

time

Returns the time (expressed as Universal Coordinated Time) elapsed since 00:00:00, January 1, 1970, in seconds.

Format

#include <time.h>

time_t time (time_t *time_location);

Function Variants Compiling with the _DECC_V4_SOURCE and _VMS_V6_SOURCE feature-test macros defined enables a local-time-based entry point to the time function that is equivalent to the behavior before OpenVMS Version 7.0.

Argument

time_location

Either NULL or a pointer to the place where the returned time is also stored. The time_t type is defined in the <time.h> header file as follows:


typedef unsigned long int time_t; 


Return Values

x The time elapsed past the Epoch.
( time_t )( - 1) Indicates an error. If the value of SYS$TIMEZONE_DIFFERENTIAL logical is wrong, the function will fail with errno set to EINVAL.

times

Passes back the accumulated times of the current process and its terminated child processes.

Format

#include <times.h>

clock_t times (struct tms *buffer); (OPENVMS V7.0 AND HIGHER)

void times (tbuffer_t *buffer); (PRE OPENVMS V7.0)


Argument

buffer

A pointer to the terminal buffer.

Description

For both process and children times, the structure breaks down the time by user and system time. Since the OpenVMS system does not differentiate between system and user time, all system times are returned as 0. Accumulated CPU times are returned in 10-millisecond units.

Only the accumulated times for child processes running a C main program or a program that calls VAXC$CRTL_INIT or DECC$CRTL_INIT are included.

On OpenVMS Version 7.0 and higher systems, the times function returns the elapsed real time in clock ticks since an arbitrary reference time in the past (for example, system startup time). This reference time does not change from one times function call to another. The return value can overflow the possible range of type clock_t values. When times fails, it returns a value of - 1. The HP C RTL uses system-boot time as its reference time.


Return Values

x The elapsed real time in clock ticks since system-boot time.
( clock_t )( - 1) Indicates an error.

tmpfile

Creates a temporary file that is opened for update.

Format

#include <stdio.h>

FILE *tmpfile (void);


Description

The file exists only for the duration of the process, or until the file is closed and is preserved across calls to vfork .

Return Values

x The address of a file pointer (defined in the <stdio.h> header file).
NULL Indicates an error.

tmpnam

Generates filenames that can be safely used for a temporary file.

Format

#include <stdio.h>

char *tmpnam (char *name);

Function Variants The tmpnam function has variants named _tmpnam32 and _tmpnam64 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

name

A character string containing a name to use in place of file-name arguments in functions or macros. Successive calls to tmpnam with a null argument cause the function to overwrite the current name.

Return Value

x If the name argument is the NULL pointer value NULL, tmpnam returns the address of an internal storage area. If name is not NULL, then it is considered the address of an area of length L_tmpnam (defined in the <stdio.h> header file). In this case, tmpnam returns the name argument as the result.

toascii

Converts its argument, an 8-bit ASCII character, to a 7-bit ASCII character.

Format

#include <ctype.h>

int toascii (char character);


Argument

character

An object of type char .

Return Value

x A 7-bit ASCII character.

tolower

Converts a character to lowercase.

Format

#include <ctype.h>

int tolower (int character);


Argument

character

An object of type int representable as an unsigned char or the value of EOF. For any other value, the behavior is undefined.

Description

If the argument represents an uppercase letter, and there is a corresponding lowercase letter, as defined by character type information in the program locale category LC_CTYPE, the corresponding lowercase letter is returned.

If the argument is not an uppercase character, it is returned unchanged.


Return Value

x The lowercase letter corresponding to the argument. Or, the unchanged argument, if it is not an uppercase character.

_tolower

Converts an uppercase character to lowercase.

Format

#include <ctype.h>

int _tolower (int character);


Argument

character

This argument must be an uppercase letter.

Description

The _tolower macro is equivalent to the tolower function except that its argument must be an uppercase letter (not lowercase, not EOF).

As of OpenVMS Version 8.3 and to comply with the C99 ANSI standard and X/Open Specification, the _tolower macro by default does not evaluate its parameter more than once. It simply calls the tolower function. This avoids side effects (such as i++ or function calls) where the user can tell how many times an expression is evaluated.

To keep the older, optimized _tolower macro behavior, compile with /DEFINE=_FAST_TOUPPER. Then, as in previous releases, _tolower optimizes the call to avoid the overhead of a runtime call. The parameters are checked to determine how to calculate the result, thereby creating unwanted side effects. Therefore, when compiling with /DEFINE=_FAST_TOUPPER, do not use the _tolower macro with arguments that contain side-effect operations. For instance, the following example will not return the expected result:


d = _tolower (C++); 


Return Value

x The lowercase letter corresponding to the argument.


Previous Next Contents Index