Example #1
0
void
console_log(const char* str)
{
    uint32_t len = 0;

    for(const char* p = str; *p; p++) {
        len++;
    }

    _syscall2(SYS_CONSOLE_LOG, (uint32_t)str, len);
}
Example #2
0
time_t time(time_t *timer)
{
  time_t ans;
  struct timeval {
    long tv_sec;        /* seconds since Jan. 1, 1970 */
    long tv_usec;       /* and microseconds */
  } tv;
  errno = 0;
  if (_syscall2(SYS_gettimeofday, (int)&tv, NULL) == 0)
    ans = (time_t)tv.tv_sec;
  else ans = (time_t)-1;
  if (timer != NULL) *timer = ans;
  return ans;      
}
Example #3
0
/* 以flag方式打开文件pathname */
int32_t open(char* pathname, uint8_t flag) {
	   return _syscall2(SYS_OPEN, pathname, flag);
}
Example #4
0
//获取当前工作目录
char* getcwd(char* buf,uint32_t size){
	return (char*)_syscall2(SYS_GETCWD,buf,size);
}
Example #5
0
//将文件描述符old_local_fd重定向到new_local_fd
void fd_redirect(uint32_t old_local_fd,uint32_t new_local_fd){
	_syscall2(SYS_FD_REDIRECT,old_local_fd,new_local_fd);
}
Example #6
0
//执行pathname
int execv(const char* pathname,char** argv){
	return _syscall2(SYS_EXECV,pathname,argv);
}
Example #7
0
/* 获取path属性到buf中 */
int32_t stat(const char* path, struct stat* buf) {
	   return _syscall2(SYS_STAT, path, buf);
}
Example #8
0
clock_t clock()
{   struct rusage usage;
    _syscall2(SYS_getrusage, 0, (int) &usage);
    return (clock_t)(1000*usage.ru_utime.tv_sec+(usage.ru_utime.tv_usec/1000));
}
Example #9
0
int _fh_length(FILEHANDLE fh)
{
  struct stat buf;
  if (_syscall2(SYS_fstat, (int)fh, (int)(&buf))==0) return (int)buf.st_size;
  return -1;
}