Esempio n. 1
0
/**
 * fclose
 *
 * @return 0 - upon successful completion,
 *         non-zero value - otherwise.
 */
int
fclose (FILE *fp) /**< stream pointer */
{
  syscall_2 (SYSCALL_NO (close), (long int) fp, 0);

  return 0;
} /* fclose */
Esempio n. 2
0
/**
 * fclose
 *
 * @return 0 - upon successful completion,
 *         non-zero value - otherwise.
 */
int
fclose (FILE *fp) /**< stream pointer */
{
  syscall_2 (__NR_close, (long int) fp, 0);

  return 0;
} /* fclose */
Esempio n. 3
0
unsigned int sleep(unsigned int seconds){
    struct timespec req;
    int ret;
    req.tv_sec=seconds;
    req.tv_nsec=0L;
    struct timespec rem;
    ret=syscall_2(SYS_nanosleep,(uint64_t)&req,(uint64_t)&rem);
    if(ret < 0){
		errno=-ret;
		ret = -1;
	}
    return ret;
}
Esempio n. 4
0
/**
 * Abort current process, producing an abnormal program termination.
 * The function raises the SIGABRT signal.
 */
void __attr_noreturn___ __attr_used___
abort (void)
{
  syscall_1 (__NR_close, (long int) stdin);
  syscall_1 (__NR_close, (long int) stdout);
  syscall_1 (__NR_close, (long int) stderr);

  syscall_2 (__NR_kill, syscall_0 (__NR_getpid), SIGABRT);

  while (true)
  {
    /* unreachable */
  }
} /* abort */
Esempio n. 5
0
/**
 * Setup new memory limits
 */
void
jrt_set_mem_limits (size_t data_size, /**< limit for data + bss + brk heap */
                    size_t stack_size) /**< limit for stack */
{
  struct
  {
    unsigned long long rlim_cur;
    unsigned long long rlim_max;
  } data_limit = { data_size, data_size };

  struct
  {
    unsigned long long rlim_cur;
    unsigned long long rlim_max;
  } stack_limit = { stack_size, stack_size };

  long int ret;

#ifdef __TARGET_HOST_x64
  ret = syscall_2 (__NR_setrlimit, RLIMIT_DATA, (intptr_t) &data_limit);
  LIBC_ASSERT (ret == 0);

  ret = syscall_2 (__NR_setrlimit, RLIMIT_STACK, (intptr_t) &stack_limit);
  LIBC_ASSERT (ret == 0);
#elif defined (__TARGET_HOST_ARMv7)
  ret = syscall_3 (__NR_prlimit64, 0, RLIMIT_DATA, (intptr_t) &data_limit);
  LIBC_ASSERT (ret == 0);

  ret = syscall_3 (__NR_prlimit64, 0, RLIMIT_STACK, (intptr_t) &stack_limit);
  LIBC_ASSERT (ret == 0);
#elif defined (__TARGET_HOST_x86)
# error "__TARGET_HOST_x86 case is not implemented"
#else /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */
# error "!__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86"
#endif /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */
} /* jrt_set_mem_limits */
Esempio n. 6
0
int open(const char *pathname, int flags)
{
        int ret;
        ret =syscall_2(SYS_open,((long)pathname),flags);
        return ret;
}
Esempio n. 7
0
/**
 * This function can get the time as well as a timezone.
 *
 * @return 0 if success, -1 otherwise
 */
int
gettimeofday (void *tp,  /**< struct timeval */
              void *tzp) /**< struct timezone */
{
  return (int) syscall_2 (__NR_gettimeofday, (long int) tp, (long int) tzp);
} /* gettimeofday */
Esempio n. 8
0
int dup2(int oldfd, int newfd)
{
        int ret;
        ret =syscall_2(SYS_dup2,oldfd,newfd);
        return ret;
}
Esempio n. 9
0
/**
 * Send a signal to the current process.
 */
int __attr_used___
raise (int sig)
{
  return (int) syscall_2 (SYSCALL_NO (kill), syscall_0 (SYSCALL_NO (getpid)), sig);
} /* raise */
Esempio n. 10
0
/**
 * This function can get the time as well as a timezone.
 *
 * @return 0 if success, -1 otherwise
 */
int
gettimeofday (void *tp,  /**< struct timeval */
              void *tzp) /**< struct timezone */
{
  return (int) syscall_2 (SYSCALL_NO (gettimeofday), (long int) tp, (long int) tzp);
} /* gettimeofday */
Esempio n. 11
0
int nanosleep(const struct spec *req, struct spec *rem)
{
        int ret;
        ret =syscall_2(SYS_nanosleep, ((long)(req)),((long)(rem)) );
        return ret;
}
Esempio n. 12
0
File: dir.c Progetto: upasee/SBUnix
char *getcwd(char *buf, size_t size)
{
        syscall_2(SYS_getcwd, (uint64_t)buf, (uint64_t)size);
        return buf;
}
Esempio n. 13
0
int munmap(void *addr, size_t length) {
    return syscall_2(SYS_munmap, (uint64_t)addr, (uint64_t)length);
}