Changeset 643 for trunk/libs/mini-libc


Ignore:
Timestamp:
Oct 17, 2019, 3:14:01 PM (5 years ago)
Author:
alain
Message:

Introduce FBF related syscalls.

Location:
trunk/libs/mini-libc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/mini-libc/stdio.c

    r628 r643  
    399399}  // end fclose()
    400400
     401//////////////////////////////////////////
     402unsigned int fread( void         * buffer,
     403                    unsigned int   size,
     404                    unsigned int   nitems,
     405                    FILE         * stream )
     406{
     407    // check stream valid
     408    if( stream->key != VALID_OPEN_FILE ) return EOF;
     409
     410    // get file descriptor from stream pointer
     411    int fd = stream->fd;
     412
     413    // compute nbytes
     414    unsigned int nbytes = size * nitems;
     415
     416    if( hal_user_syscall( SYS_READ,
     417                          (reg_t)fd,
     418                          (reg_t)buffer,
     419                          (reg_t)nbytes, 0 ) == nbytes ) return nitems;
     420    else return 0;
     421
     422}  // end fread()
     423
     424//////////////////////////////////////////
     425unsigned int fwrite( void         * buffer,
     426                     unsigned int   size,
     427                     unsigned int   nitems,
     428                     FILE         * stream )
     429{
     430    // check stream valid
     431    if( stream->key != VALID_OPEN_FILE ) return EOF;
     432
     433    // get file descriptor from stream pointer
     434    int fd = stream->fd;
     435
     436    // compute nbytes
     437    unsigned int nbytes = size * nitems;
     438
     439    if( hal_user_syscall( SYS_WRITE,
     440                          (reg_t)fd,
     441                          (reg_t)buffer,
     442                          (reg_t)nbytes, 0 ) == nbytes ) return nitems;
     443    else return 0;
     444
     445}  // end fwrite()
     446
    401447/////////////////////////////////
    402448int fprintf( FILE       * stream,
  • trunk/libs/mini-libc/stdio.h

    r637 r643  
    141141             const char * format, ... );
    142142
     143/*********************************************************************************************
     144 * This function moves <nitems> oblects, each <size> bytes long, from an input stream
     145 * identified by <stream>, to the user buffer identified by the <buffer> argument.
     146 * It can be a regular file or a character oriented input device.
     147 *********************************************************************************************
     148 * @ stream    : pointer on a stream.
     149 * @ format    : formated string.
     150 * @ returns actual number of items read if success / returns 0 if failure.
     151 ********************************************************************************************/
     152unsigned int fread( void         * buffer,
     153                    unsigned int   size,
     154                    unsigned int   nitems,
     155                    FILE         * stream ); 
     156
     157/*********************************************************************************************
     158 * This function moves <nitems> oblects, each <size> bytes long, from an user buffer
     159 * identified by the <buffer> argument, to an output stream identified by <stream>.
     160 * It can be a  regular file or a character oriented input device.
     161 *********************************************************************************************
     162 * @ stream    : pointer on a stream.
     163 * @ format    : formated string.
     164 * @ returns actual number of written items if success / returns 0 if failure.
     165 ********************************************************************************************/
     166unsigned int fwrite( void         * buffer,
     167                     unsigned int   size,
     168                     unsigned int   nitems,
     169                     FILE         * stream ); 
    143170
    144171#endif  // _STDIO_H_
  • trunk/libs/mini-libc/stdlib.h

    r476 r643  
    3939 * This function terminates a process.
    4040 *****************************************************************************************
    41  * @ status   : terminaison status : 0 / EXIT_SUCCESS / EXIT_FAILURE.
     41 * @ status   : terminaison status : EXIT_SUCCESS / EXIT_FAILURE.
    4242 ****************************************************************************************/
    4343void exit( int status );
Note: See TracChangeset for help on using the changeset viewer.