Changeset 589 for trunk/libs/mini-libc/unistd.c
- Timestamp:
- Nov 1, 2018, 12:48:51 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/unistd.c
r476 r589 26 26 #include <hal_user.h> 27 27 #include <syscalls_numbers.h> 28 #include <shared_signal.h> 29 30 ////////////////////////////////// 31 unsigned alarm( unsigned seconds ) 32 { 33 return hal_user_syscall( SYS_ALARM, 34 (reg_t)seconds, 0, 0, 0 ); 35 } 36 37 ////////////////////////////////// 38 int chdir( const char * pathname ) 39 { 40 return hal_user_syscall( SYS_CHDIR, 41 (reg_t)pathname, 0, 0, 0 ); 42 } 43 44 /////////////////// 45 int close( int fd ) 46 { 47 return hal_user_syscall( SYS_CLOSE, 48 (reg_t)fd, 0, 0, 0 ); 49 } 50 51 /////////////////////////// 52 int 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 //////////////// 63 int fork( void ) 64 { 65 return hal_user_syscall( SYS_FORK, 0, 0, 0, 0 ); 66 } 28 67 29 68 ///////////////////////////// … … 35 74 (reg_t)bytes, 0, 0 ); 36 75 } 76 77 //////////// 78 int getpid( void ) 79 { 80 return hal_user_syscall( SYS_GETPID, 0, 0, 0, 0 ); 81 } 82 83 /////////////////// 84 int isatty(int fd ) 85 { 86 return hal_user_syscall( SYS_ISATTY, 87 (reg_t)fd, 0, 0, 0 ); 88 } 89 90 /////////////////////////// 91 int 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 ///////////////// 102 int pause( void ) 103 { 104 return hal_user_syscall( SYS_KILL, 105 getpid(), 106 SIGSTOP, 0, 0 ); 107 } 108 109 ///////////////////// 110 int pipe( int fd[2] ) 111 { 112 return hal_user_syscall( SYS_PIPE, 113 (reg_t)fd, 0, 0, 0 ); 114 } 115 37 116 ////////////////////////// 38 117 int read( int fd, … … 44 123 (reg_t)buf, 45 124 (reg_t)count, 0 ); 125 } 126 127 //////////////////////////// 128 int rmdir( char * pathname ) 129 { 130 return hal_user_syscall( SYS_RMDIR, 131 (reg_t)pathname, 0, 0, 0 ); 132 } 133 134 /////////////////////////////////// 135 int unlink( const char * pathname ) 136 { 137 return hal_user_syscall( SYS_UNLINK, 138 (reg_t)pathname, 0, 0, 0 ); 46 139 } 47 140 … … 57 150 } 58 151 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 }109 152 110 153 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.