'_control87'에 해당되는 글 1건

  1. 2021.06.18 Watcom C Library Reference : close, closedir, _control87

 

 

Watcom C Library Reference : close, closedir, _control87

 

 

 

 

close

 

Synopsis : #include <io.h> 

              int close( int handle );

Description : The close function closes a file at the operating system level. The handle value is the file handle returned by a successful execution of one of the creat, dup, dup2, open or sopen functions.



Returns : The close function returns zero if successful. Otherwise, it returns -1 and errno is set to indicate the error.

 

Errors : When an error has occurred, errno contains a value indicating the type of en been detected.

 Constant  Meaning
 EBADF  The handle argument is not a valid file handle.

 


See Also : creat, dup, dup2, open, sopen

Example :

#include <fcntl.h> 

#include <io.h>


void main( )

{
    int handle;


    handle = open( "file", O_RDONLY );

    if( handle != -1 ) {
        /* process file */

        close( handle );

    }

}

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

 

closedir

 

Synopsis : #include <direct.h> 

              int closedir( DIR *dirp );

Description : The closedir function closes the directory specified by dirp and frees the memory allocated by opendir.

 

 

Returns : The closedir function returns zero if successful, non-zero otherwise.

 

Errors : When an error has occurred, errno contains a value indicating the type of error that has been detected.

 Constant  Meaning
 EBADF  The argument dirp does not refer to an open directory stream.

 


See Also : _dos_find Functions, opendir, readdir



Example : To get a list of files contained in the directory \watcom\h on your default disk:

#include <stdio.h> 

#include <direct.h>


void main( )

{
    DIR *dirp;

    struct dirent *direntp;


    dirp = opendir( " \\watcom\\h" );

    if( dirp != NULL ) {
        for( ; ; ) {
            direntp = readdir( dirp );

            if( direntp == NULL ) break;

            printf( "%s\n", direntp->d_name );

        }    
        closedir( dirp );

    }

}


Note the use of two adjacent backslash characters (\) within character-string constant signify a single backslash.

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

_control87

 

Synopsis : #include <float.h> 

              unsigned int _control87 ( unsigned int newcw, unsigned int mask );


Description : The _control87 function updates the control word of the 8087/80287/80387/80486. If mask is zero, then the control word is not updated. If mask is non-zero, then the control word is updated with bits from newcw corresponding to every bit that is on in mask.

 

 

Returns : The _control87 function returns the new control word. The description of bits defined for the control word is found in the <float.h> header file.

 

 

See Also : _clear87, _fpreset, _status87

Example :

#include <stdio.h> 

#include <float.h>


char *status [2] = { "disabled", "enabled" };


void main( )

{
    unsigned int fp_cw = 0;

    unsigned int fp_mask = 0;

    unsigned int bits;


    fp_cw = _control87 ( fp_cw, fp_mask );


    printf( "Interrupt Exception Masks\n" );

    bits = fp_cw & MCW_EM;

    printf( " Invalid Operation exception %s\n", status[ (bits & EM_INVALID) == 0 ] );

    printf( " Denormalized exception %s\n",     status[ (bits & EM_DENORMAL) == 0 ] );

    printf( " Divide-By-Zero exception %s\n",  status[ (bits & EM_ZERODIVIDE) == 0 ] );

    printf( " Overflow exception %s\n",          status[ (bits & EM_OVERFLOW) == 0 ] );

    printf( " Underflow exception %s\n",         status[ (bits & EM_UNDERFLOW) == 0 ] );

    printf( " Precision exception %s\n",         status[ (bits & EM_PRECISION) == 0 ] );

    printf( " Infinity Control = " );

    bits = fp_cw & MCW_IC;

    if( bits == IC_AFFINE )         printf( "affine\n" );

    if( bits == IC_PROJECTIVE )   printf( "projective\n" );


    printf( "Rounding Control = " );

    bits = fp_cw & MCW_RC;

    if( bits == RC_NEAR )          printf( "near\n" ); 

    if( bits == RC_DOWN )        printf( "down\n" );

    if( bits == RC_UP )             printf( "up\n" );

    if( bits == RC_CHOP )         printf( "chop\n" );

 

    printf( "Precision Control = " );

    bits = fp_cw & MCW_PC;

    if( bits == PC_24 )               printf( "24 bits\n" );

    if( bits == PC_53 )               printf( "53 bits\n" ); 

    if( bits == PC_64 )               printf( "64 bits\n" );

}

 

Classification : Intel
Systems : All

 

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,