Ignore:
Timestamp:
Nov 1, 2018, 12:48:51 PM (5 years ago)
Author:
alain
Message:

Introduce a pause() syscall in mini-libc/unistd library.

File:
1 edited

Legend:

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

    r476 r589  
    2626#include <hal_user.h>
    2727#include <syscalls_numbers.h>
     28#include <shared_signal.h>
     29
     30//////////////////////////////////
     31unsigned alarm( unsigned seconds )
     32{
     33    return hal_user_syscall( SYS_ALARM,
     34                             (reg_t)seconds, 0, 0, 0 );
     35}
     36
     37//////////////////////////////////
     38int chdir( const char * pathname )
     39{
     40    return hal_user_syscall( SYS_CHDIR,
     41                             (reg_t)pathname, 0, 0, 0 );
     42}
     43
     44///////////////////
     45int close( int fd )
     46{
     47    return hal_user_syscall( SYS_CLOSE,
     48                             (reg_t)fd, 0, 0, 0 );
     49}
     50
     51///////////////////////////
     52int execve( char  * pathname,
     53            char ** argv,
     54            char ** envp )
     55{
     56    return hal_user_syscall( SYS_EXEC,
     57                             (reg_t)pathname,
     58                             (reg_t)argv,
     59                             (reg_t)envp, 0 );
     60}
     61
     62////////////////
     63int fork( void )
     64{
     65    return hal_user_syscall( SYS_FORK, 0, 0, 0, 0 );
     66}
    2867
    2968/////////////////////////////
     
    3574                             (reg_t)bytes, 0, 0 );
    3675}
     76
     77////////////
     78int getpid( void )
     79{
     80    return hal_user_syscall( SYS_GETPID, 0, 0, 0, 0 );
     81}
     82
     83///////////////////
     84int isatty(int fd )
     85{
     86    return hal_user_syscall( SYS_ISATTY,
     87                             (reg_t)fd, 0, 0, 0 );
     88}
     89
     90///////////////////////////
     91int lseek( int          fd,
     92           unsigned int offset,
     93           int          whence )
     94{
     95    return hal_user_syscall( SYS_LSEEK,
     96                             (reg_t)fd,
     97                             (reg_t)offset,
     98                             (reg_t)whence, 0 );
     99}
     100
     101/////////////////
     102int pause( void )
     103{
     104    return hal_user_syscall( SYS_KILL,
     105                             getpid(),
     106                             SIGSTOP, 0, 0 );
     107}
     108
     109/////////////////////
     110int pipe( int fd[2] )
     111{
     112    return hal_user_syscall( SYS_PIPE,
     113                             (reg_t)fd, 0, 0, 0 );
     114}
     115
    37116//////////////////////////
    38117int read( int          fd,
     
    44123                             (reg_t)buf,
    45124                             (reg_t)count, 0 );
     125}
     126
     127////////////////////////////
     128int rmdir( char * pathname )
     129{
     130    return hal_user_syscall( SYS_RMDIR,
     131                             (reg_t)pathname, 0, 0, 0 );
     132}
     133
     134///////////////////////////////////
     135int unlink( const char * pathname )
     136{
     137    return hal_user_syscall( SYS_UNLINK,
     138                             (reg_t)pathname, 0, 0, 0 );
    46139}
    47140
     
    57150}
    58151
    59 ///////////////////////////
    60 int lseek( int          fd,
    61            unsigned int offset,
    62            int          whence )
    63 {
    64     return hal_user_syscall( SYS_LSEEK,
    65                              (reg_t)fd,
    66                              (reg_t)offset,
    67                              (reg_t)whence, 0 );
    68 }
    69 
    70 ///////////////////
    71 int close( int fd )
    72 {
    73     return hal_user_syscall( SYS_CLOSE,
    74                              (reg_t)fd, 0, 0, 0 );
    75 }
    76 
    77 /////////////////////
    78 int pipe( int fd[2] )
    79 {
    80     return hal_user_syscall( SYS_PIPE,
    81                              (reg_t)fd, 0, 0, 0 );
    82 }
    83 
    84 //////////////////////////////////
    85 int chdir( const char * pathname )
    86 {
    87     return hal_user_syscall( SYS_CHDIR,
    88                              (reg_t)pathname, 0, 0, 0 );
    89 }
    90 
    91 ////////////////////////////
    92 int rmdir( char * pathname )
    93 {
    94     return hal_user_syscall( SYS_RMDIR,
    95                              (reg_t)pathname, 0, 0, 0 );
    96 }
    97 
    98 //////////
    99 int fork( void )
    100 {
    101     return hal_user_syscall( SYS_FORK, 0, 0, 0, 0 );
    102 }
    103 
    104 ////////////
    105 int getpid( void )
    106 {
    107     return hal_user_syscall( SYS_GETPID, 0, 0, 0, 0 );
    108 }
    109152
    110153
    111 ///////////////////////////
    112 int execve( char  * pathname,
    113             char ** argv,
    114             char ** envp )
    115 {
    116     return hal_user_syscall( SYS_EXEC,
    117                              (reg_t)pathname,
    118                              (reg_t)argv,
    119                              (reg_t)envp, 0 );
    120 }
    121 
    122 
    123 ///////////////////////////////////
    124 int unlink( const char * pathname )
    125 {
    126     return hal_user_syscall( SYS_UNLINK,
    127                              (reg_t)pathname, 0, 0, 0 );
    128 }
    129 
    130 ///////////////////
    131 int isatty(int fd )
    132 {
    133     return hal_user_syscall( SYS_ISATTY,
    134                              (reg_t)fd, 0, 0, 0 );
    135 }
    136 
    137 //////////////////////////////////
    138 unsigned alarm( unsigned seconds )
    139 {
    140     return hal_user_syscall( SYS_ALARM,
    141                              (reg_t)seconds, 0, 0, 0 );
    142 }
    143 
    144 
Note: See TracChangeset for help on using the changeset viewer.