/* vi: set sw=4 ts=4: */
/*
* Syscalls for uClibc
*
* Copyright (C) 2000 by Lineo, inc
* Copyright (C) 2001, 2002 by Erik Andersen
* Written by Erik Andersen <andersen@codpoet.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
* for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <features.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/syscall.h>
//#define __NR_exit 1
#ifdef L__exit
/* Do not include unistd.h, so gcc doesn't whine about
* _exit returning. It really doesn't return... */
#define __NR__exit __NR_exit
_syscall1(void, _exit, int, status);
#endif
//#define __NR_fork 2
#ifdef L___libc_fork
#include <unistd.h>
# ifdef __UCLIBC_HAS_MMU__
#define __NR___libc_fork __NR_fork
_syscall0(pid_t, __libc_fork);
weak_alias (__libc_fork, fork)
# else
pid_t fork(void)
{
__set_errno(ENOSYS);
return -1;
}
# endif
#endif
//#define __NR_read 3
#ifdef L___libc_read
#include <unistd.h>
#define __NR___libc_read __NR_read
_syscall3(ssize_t, __libc_read, int, fd, __ptr_t, buf, size_t, count);
weak_alias(__libc_read, read)
#endif
//#define __NR_write 4
#ifdef L___libc_write
#include <unistd.h>
#define __NR___libc_write __NR_write
_syscall3(ssize_t, __libc_write, int, fd, const __ptr_t, buf, size_t, count);
weak_alias(__libc_write, write)
#endif
//#define __NR_open 5
#ifdef L___libc_open
#include <stdarg.h>
/* Do not include fcntl.h, so gcc doesn't whine the prototype */
#define __NR___libc_open __NR_open
_syscall3(int, __libc_open, const char *, fn, int, flags, mode_t, mode);
weak_alias(__libc_open, open)
#endif
//#define __NR_close 6
#ifdef L___libc_close
#include <unistd.h>
#define __NR___libc_close __NR_close
_syscall1(int, __libc_close, int, fd);
weak_alias(__libc_close, close)
#endif
//#define __NR_waitpid 7
// Implemented using wait4
//#define __NR_creat 8
#ifdef L_creat
#include <fcntl.h>
_syscall2(int, creat, const char *, file, mode_t, mode);
#endif
//#define __NR_link 9
#ifdef L_link
#include <unistd.h>
_syscall2(int, link, const char *, oldpath, const char *, newpath);
#endif
//#define __NR_unlink 10
#ifdef L_unlink
#include <unistd.h>
_syscall1(int, unlink, const char *, pathname);
#endif
//#define __NR_execve 11
#ifdef L_execve
#include <unistd.h>
_syscall3(int, execve, const char *, filename, char *const *, argv,
char *const *, envp);
#endif
//#define __NR_chdir 12
#ifdef L_chdir
#include <unistd.h>
_syscall1(int, chdir, const char *, path);
#endif
//#define __NR_time 13
#ifdef L_time
#include <time.h>
_syscall1(time_t, time, time_t *, t);
#endif
//#define __NR_mknod 14
#ifdef L_mknod
#include <unistd.h>
extern int mknod(const char *pathname, mode_t mode, dev_t dev);
_syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);
int __xmknod (int version, const char * path, mode_t mode, dev_t *dev)
{
switch(version)
{
case 1:
return mknod (path, mode, *dev);
default:
__set_errno(EINVAL);
return -1;
}
}
#endif
//#define __NR_chmod 15
#ifdef L_chmod
#include <sys/stat.h>
_syscall2(int, chmod, const char *, path, mode_t, mode);
#endif
/* Old kernels don't have lchown -- do chown instead. This
* is sick and wrong, but at least things will compile.
* They may not follow links when they should though... */
#ifndef __NR_lchown
#define __NR_lchown __NR_chown
#endif
//#define __NR_lch
|