• Aucun résultat trouvé

atan, atanl

Dans le document Library Reference (Page 48-63)

Function

asin, asinl

asin of a real argument returns the arc sine of the input value. sinl is the long double version; it takes a long double argument and returns a long double result.

Real arguments to asin and asinl must be in the range -1 to I, or else asin and asinl return NAN and set the global variable errno to

EDOM Domain error

This function can be used with bcd and complex types.

asin and asinl of a real argument return a value in the range -pi/2 to pi/2.

Error handling for these functions can be modified through the functions _matherr and _matherrl.

acos, atan, atan2, bcd, complex, cos, _matherr, sin, tan

assert.h

Tests a condition and possibly aborts.

void assert(int test);

assert is a macro that expands to an if statement; if test evaluates to zero, assert prints a message on stderr and aborts the program (by calling abort).

assert displays this message:

Assertion failed: test, file filename, line linenum

The filename and linenum listed in the message are the source file name and line number where the assert macro appears.

If you place the #define NDEBUG directive ("no debugging") in the source code before the #include <assert. h> directive, the effect is to comment out the assert statement.

None.

abort

math.h

Calculates the arc tangent.

atan, atanl

Syntax

atan atan!

Remarks

double atan(double xl i

long double atanl(long double Xli

DOS UNIX Win 16 Win 32 ANSI C ANSI C++ OS/2

• •

• •

• •

atan calculates the arc tangent of the input value.

atanl is the long double version; it takes a long double argument and returns a long double result. This function can be used with bcd and complex types.

Return value atan and atanl of a real argument return a value in the range -pil2 to pil2.

Error handling for these functions can be modified through the functions _math err and _matherrl.

See also acos, asin, atan2, bcd, complex, cos, _matherr, sin, tan

atan2, atan21 math.h

Function Calculates the arc tangent of y I x.

Syntax double atan2(double y, double Xli

Remarks

Return value

See also

atan2 atan2!

long double atan2l(long double y, long double Xli

DOS UNIX Win 16 Win 32 ANSI C ANSI C++ OS/2

• •

atan2 returns the arc tangent of y I x; it produces correct results even when the resulting angle is near pil2 or -pil2 (x near 0). If both x and yare set to 0, the function sets the global variable errno to EDOM, indicating a domain error.

atan21 is the long double version; it takes long double arguments and returns a long double result.

atan2 and atan21 return a value in the range -pi to pi. Error handling for these functions can be modified through the functions _matherr and _matherrl.

acos, asin, atan, cos, _matherr, sin, tan

atexit

Function Syntax

Remarks

Return value See also

.st01, _atold

Function Syntax

Remarks

afof _a told

atexit

stdlib.h

Registers termination function.

int atexit(void (_USERENTRY * func) (void));

atexit registers the function pointed to by func as an exit function. Upon normal termination of the program, exit calls func just before returning to the operating system. func must be used,with the _USERENTRY calling convention.

Each call to atexit registers another exit function. Up to 32 functions can be registered. They are executed on a last-in, first-out basis (that is, the last function registered is the first to be executed).

atexit returns 0 on success and nonzero on failure (no space left to register the function).

abort, _exit, exit, spawn ...

math.h

Converts a string to a floating-point number.

double atof(const char *s);

long double _atold(const char *s);

DOS UNIX Win 16 Win 32 ANSI C ANSI C++ OS/2

• • • • • • •

• • • •

atof converts a string pointed to by s to double; this function recognizes the character representation of a floating-point number, made up of the following:

• An optional string of tabs and spaces

• An optional sign

• A string of digits and an optional decimal point (the digits can be on both sides of the decimal point)

• An optional e or E followed by an optional signed integer

atof, _atold

Return value

See also

atoi

Function SY,ntax

Remarks

Return value

The characters must match this generic format:

[whitespace] [sign] [ddd] [.] [ddd] [e I E[sign]ddd]

atof also recognizes +INF and -INF for plus and minus infinity, and +NAN and -NAN for Not-a-Number .

. In this function, the first umecognized character ends the conversion.

_atold is the long double version; it converts the string pointed to by s to a long double.

strtod and _strtold are similar to atof and _atold; they provide better error detection, and hence are preferred in some applications.

atof and _atold return the converted value of the input string.

If there is an overflow, atof (or _atold) returns plus or minus HUGE_VAL (or _LHUGE_ VAL), errno is set to ERANGE (Result out of range), and _matherr (or _matherrl) is not called.

atoi, atol, ecvt, fcvt, gcvt, scanf, strtod

stdlib.h

Converts a string to an integer.

int atoi(const char *s);

DOS UNIX

atoi converts a string pointed to by s to int; atoi recognizes (in the following order)

• An optional string of tabs and spaces

• An optional sign

• A string of digits

The characters must match this generic format:

[ws] [sn] [ddd]

In this function, the first unrecognized character ends the conversion. There are no provisions for overflow in atoi (results are undefined).

atoi returns the converted value of the input string. If the string cannot be converted to a number of the corresponding type (int), atoi returns O.

See also

atol

Function Syntax

Remarks

Return value See also

bdos

Function Syntax

atai

atof, atol, ecvt, fcvt, gcvt, scanf, strtod

stdlib.h

Converts a string to a long.

long atol(const char *s) i

atol converts the string pointed to by s to long. atol recognizes (in the following order)

• An optional string of tabs and spaces

• An optional sign

• A string of digits

The characters must match this generic format:

[ws] [sn] [ddd]

In this function, the first unrecognized character ends the conversion. There are no provisions for overflow in atol (results are undefined).

atol returns the converted value of the input string. If the string cannot be converted to a number of the corresponding type (long), atol returns

o.

atof, atoi, ecvt, fcvt, gcvt, scanf, strtod, strtol, strtoul

See atof.

dos.h

Accesses DOS system calls.

int bdos(int dosfun~ unsigned dosdx, unsigned dosal)i

bdos

Remarks

Return value

·See also

bdosptr

Function Syntax

Remarks

Return value See also

bdos provides direct access to many of the DOS system calls. See your DOS reference manuals for details on each system call.

For system calls that require an integer argument, use bdos; if they require a pointer argument, use bdosptr. In the large data models (compact, large, and huge), it is important to use bdosptr instead of bdos for system calls that require a pointer as the call argument.

dosfun is defined in your DOS reference manuals.

dosdx is the value of register OX.

dosal is the value of register AL.

The return value of bdos is the value of AX set by the system call.

bdosptr,geninterrupt,int86,int86x,intdos,intdosx

Accesses DOS system calls.

int bdosptr(int dosfun, void *argument, unsigned dosal);

dos.h

bdosptr provides direct access to many of the DOS system calls. See your DOS reference manuals for details of each system call.

For system calls that require an integer argument, use bdos; if calls require a pointer argument, use bdosptr. In the large data models (compact, large, and huge), it is important to use bdosptr for system calls that require a pointer as the call argument. In the small data models, the argument parameter to bdosptr specifies OX; in the large data models, it gives the DS:DX values to be used by the system call.

dosfun is defined in your DOS reference manuals. dosal is the value of register AL.

The return value of bdosptr is the value of AX on success or -Ion failure.

On failure, the global variables errno and _doserrno are set.

bdos, geninterrupt, int86, int86x, intdos, intdosx

_beginthread

Function Syntax

Remarks

Return value

See also

Starts execution of a new thread.

unsigned long _beginthread(_USERENTRY (*start_address) (void *), unsigned stack_size, void *arglist)

_beginthread

process.h

The _begin thread function creates and starts a new thread. The thread starts execution at start_address. (Note that start_address must be declared to be _USERENTRY. )The size of its stack in bytes is stack_size; the stack is allocated by the operating system after the stack size is rounded up to the next multiple of 4096. The thread is passed arglist as its only parameter; it can be NULL, but must be present. The thread terminates by simply returning, or by calling _endthread.

Either this function or _beginthreadNT must be used instead of the operating system thread-creation API function because _beginthread and

_beginthreadNT perform initialization required for correct operation of the run-time library functions.

This function is available only in the multithread libraries.

The function is also available for OS/2. However, under OS/2 the function returns and int and does not require _USERENTRY.

_begin thread returns the handle of the new thread. In the event of an error, the function returns -I, and the global variable errno is set to one of the following values:

EAGAIN Too many threads EINV AL Invalid request

See also the Win32 description of GetLastError.

_beginthreadNT, _end thread

_beginthreadNT process.h

Function Starts execution of a new thread under Windows NT.

_beginthreadNT

,Syntax

Remarks

Return value

See also

unsigned long _beginthreadNT(void (_USERENTRY *start_address) (void *), unsigned stack_size, void *arglist,

void *security_attrib, unsigned long create_flags, unsigned long *thread_id);

All multithread Windows NT programs must use _beginthreadNT or the _begin thread function instead of the operating system thread-creation API function because _begin thread and _beginthreadNT perform initialization required for correct operation of the run-time library functions. The _beginthreadNT function provides support for the operating system security. These functions are available only in the multithread libraries.

The _beginthreadNT function creates and starts a new thread. The thread starts execution at start_address. (Note 'that start_address must be declared to be -,,-USERENTRY.) The size of its stack in bytes is stack_size; the stack is allocated by the operating system after the stack size is rounded up to the next multiple of 4096. The thread arglist can be NULL, but must be present.

_ The thread terminates by simply returning, or by calling _end thread.

The function uses the security_attr pointer to access the

SECURITY_ATTRIBUTES structure. The structure contains the security attributes for the thread. If security_attr is NULL, the thread is created with default security attributes. The thread handle is not inherited if security_attr is NULL.

The function reads the createJlags variable for flags that provide additional information about the thread creation. This variable can be zero, specifying that the thread will run immediately upon creation. The variable can also be CREATE_SUSPENDED, in which case the thread will not run until the ResumeThread function is called. ResumeThread is provided by the Win32 API. See the Win32 description of ResumeThread for additional information.

The function initializes the thread_id variable with the thread identifier.

_beginthreadNT returns the handle of the new thread. In the event of an error, the function returns -I, and the global variable errno is set to one of the following values:

EAGAIN Too many threads EINV AL Invalid,request _begin thread, _endthread

biosequip

Function Syntax

Remarks Return value

DOS only sees two ports but can be pushed to see four;

the IBM PS/2 can see up to eight.

biosequip

bios.h

Checks equipment.

int biosequip(void)i

biosequip uses BIOS interrupt Ox11 to return an integer describing the equip-ment connected to the system.

The return value is interpreted as a collection of bit-sized fields. The IBM PC values follow:

Bits 14-15 Number of parallel printers installed 00

=

0 printers

Bit 13 Bit 12

01 = 1 printer 10 = 2 printers 11

=

3 printers

Serial printer attached Game I/O attached Bits 9-11 Number of COM ports

000

= a

ports

001 = 1 port 010

=

2 ports 011 = 3 ports 100

=

4 ports

101

=

5 ports

110

=

6 ports 111 = 7 ports

Bit 8 Direct memory access (DMA)

o =

Machine has DMA

1

=

Machine does not have DMA; for example, PC Jr.

Bits 6-7 Number of disk drives 00

=

1 drive

01

=

2 drives

10

=

3 drives

11 = 4 drives, only if bit 0 is 1

II

biosequip

Function Syntax

Remarks Return value

Bits 4-5

Bits 2-3

Bit 1 Bit 0

Initial video mode 00

=

Unused

01 = 40x25 BW with color card 10

=

80x25 BW with color card . 11 = 80x25 BW with mono card

Motherboard RAM size 00

=

16K

01

=

32K 10 =48K 11

=

64K

Floating-point coprocessor Boot from disk

Checks equipment.

unsigned _bios_equiplist(voidl;

bios.h

_bios_equiplist uses BIOS interrupt Ox11 to return an integer describing the equipment connected to the system.

The return value is interpreted as a collection of bit-sized fields. The IBM PC values follow:

Bits 14-15

Bit 13 Bit 12 Bits 9-11

Number of parallel printers installed 00

=

0 printers

01

=

1 printer

10 = 2 printers 11 = 3 printers

Serial printer attached Game I/O attached Number of COM ports 000

=

0 ports .

001

=

1 port

010

=

2 ports

011

=

3 ports

100 = 4 ports 101

=

5 ports

bioskey

Direct memory access (DMA)

o =

Machine has DMA

Number of disk drives 00

=

1 drive

Keyboard interface, using BIOS services directly.

int bioskey(int cmd);

bioskey performs various keyboard operations using BIOS interrupt Ox16.

The parameter emd determines the exact operation.

The value returned by bioskey depends on the task it performs, determined by the value of emd:

o

If the lower 8 bits are nonzero, bioskey returns the ASCII character for the next keystroke waiting in the queue or the next key pressed at the keyboard. If the lower8 bits are zero, the upper 8

bioskey

bits are the extended keyboard codes defined in the IBM PC Technical Reference Manual.

1 This tests whether a keystroke is available to be read. A return value of zero means no key is available. The return value is OxFFFFF (-1) if Gtrl-Brkhas been pressed. Otherwise, the value of the next keystroke is returned. The keystroke itself is kept to be returned by the next call to bioskey that has a cmd value of zero.

2 Requests the current shift key status. The value is obtained by ORing the following values together:

Bit 7 Bit 6 BitS Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

Ox80 Ox40 Ox20 Ox10 Ox08 Ox04 Ox02 OxOl

Insert on Gaps on NumLockon Scroll Lock on Altpressed Gtrl pressed

f -Shift pressed

~ Shift pressed

biosmemory bios.h

Function Returns memory size.

Syntax int biosrnernory (void) i

Remarks biosmemory returns the size of RAM memory using BIOS interrupt Ox12.

This does not include display adapter memory, extended memory, or expanded memory.

Return value biosmemory returns the size of RAM memory in 1K blocks.

_bios_memsize bios.h

Function Returns memory size.

Syntax unsigned _bios_rnernsize (void) ;

Remarks

Return value

biostime

Function Syntax

Remarks

Return value

Function Syntax

Remarks

OS/2

_bios_memsize returns the size of RAM memory using BIOS interrupt Ox12.

This does not include display adapter memory, extended memory, or expanded memory.

_bios _memsize returns the size of RAM memory in 1K blocks.

bios.h

Reads or sets the BIOS timer.

long biostime(int cmd, long newtime)i

UNIX Wi n 16

biostime either reads or sets the BIOS timer. This is a timer counting ticks since midnight at a rate of roughly 18.2 ticks per second. biostime uses BIOS interrupt Ox1A.

If cmd equals 0, biostime returns the current value of the timer. If cmd ,equals 1, the timer is set to the long value in new time.

When biostime reads the BIOS timer (cmd = 0), it returns the timer's current value.

bios.h

Reads or sets the BIOS timer.

unsigned _bios_timeofday(int cmd, long *timep)i

_bios_timeofday either reads or sets the BIOS timer. This is a timer counting ticks since midnight ata rate of roughly 18.2 ticks per second.

_bios _timeofday uses BIOS interrupt Ox1A.

_biosJimeofday

Return value

bsearch

Function Syntax

Remarks

The emd parameter can be either of the following values:

_TIME_GETCLOCK The function stores the current BIOS timer value into the location pointed to by timep. If the timer has not been read or written since midnight, the function returns 1. Otherwise, the function returns O.

_TIME_SETCLOCK The function sets the BIOS timer to the long value pointed to by timep. The function does not return a

value. .

The _bios_timeofday returns the value in AX that was set by the BIOS timer call.

stdlib.h

Binary search of an array.

void *bsearch(const void *key, canst void *base, size_t nelem, size_t width, int (_USERENTRY *fcmp) (canst void *, canst void *));

bseareh searches a table (array) of nelem elements in memory, and returns the address of the first entry in the table that matches the search key. The 'array must be in order. If no match is found, bseareh returns O. Note that

because this is a binary search, the first matching entry is not necessarily the first entry in the table.

The type size _t is defined in stddef.h header file .

• nelem gives the number of elements in the table .

• width specifies the number of bytes in each table entry.

The comparison routine femp must be used with the _USERENTRY calling convention.

femp is called with two arguments: eleml and elem2. Each argument points to an item to be compared. The comparison function compares each of the pointed-to items (*eleml and *elem2), and returns an integer based on the results of the comparison.

Return value See also

bsearch

For bsearch, the fcmp return value is

• < 0 if *eleml < *elem2

• ==

0 if *eleml

==

*elem2

• > 0 if *e1eml > *elem2

bsearch returns the address of the first entry in the table that matches the search key. If no match is found, bsearch returns O.

lfind, lsearch, qsort

cabs, cabsl math.h

Function Syntax

Remarks

cabs cabsl

Calculates the absolute value of complex number.

double cabs(struct complex Z}i

long double cabsl(struct _complexl Z}i

DOS UNIX Win 16 Win 32 ANSI C ANSI C++ OS/2

• • •

cabs is a macro that calculates the absolute value of z, a complex number. z is a structure with type complex. The structure is defined in math.h as

struct complex { double x, Yi

};

struct _complexl' { long double x, Yi

}i

where x is the real part, and y is the imaginary part.

Calling cabs is equivalent to calling sqrt with the real and imaginary components of z, as shown here:

sqrt(z.x *'z.x + z.y * z.y}

cabsl is the long double version; it takes a structure with type _complexl as an argument, and returns a long double result.

. . ,If you're using C++, you may also use the complex class defined in complex.h, and use the function abs to get the absolute value of a complex number.

cabs, cabsl

Return value

See also

calloc

Function Syntax

Remarks

Memory models are available only for

16-bit applications.

Return value See also

Dans le document Library Reference (Page 48-63)