/* vi: set sw=4 ts=4: */
/*
* Syscalls for uClibc
*
* Copyright (C) 2000 by Lineo, inc
* Copyright (C) 2001 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_lchown 16
#ifdef L_lchown
#include <unistd.h>
_syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
#endif
//#define __NR_break 17
//#define __NR_oldstat 18
//#define __NR_lseek 19
#ifdef L___libc_lseek
#include <unistd.h>
#define __NR___libc_lseek __NR_lseek
_syscall3(off_t, __libc_lseek, int, fildes, off_t, offset, int, whence);
weak_alias(__libc_lseek, lseek)
#endif
//#define __NR_getpid 20
#ifdef L___libc_getpid
#include <unistd.h>
#define __NR___libc_getpid __NR_getpid
_syscall0(pid_t, __libc_getpid);
weak_alias(__libc_getpid, getpid)
weak_alias(__libc_getpid, __getpid)
#endif
//#define __NR_mount 21
#ifdef L_mount
#include <sys/mount.h>
_syscall5(int, mount, const char *, specialfile, const char *, dir,
const char *, filesystemtype, unsigned long, rwflag,
const void *, data);
#endif
//#define __NR_umount 22
#ifdef L_umount
#include <sys/mount.h>
_syscall1(int, umount, const char *, specialfile);
#endif
//#define __NR_setuid 23
#ifdef L___setuid
#define __NR___setuid __NR_setuid
#include <unistd.h>
static inline
_syscall1(int, __setuid, uid_t, uid);
int setuid(uid_t uid)
{
if (uid == (uid_t) ~0) {
__set_errno (EINVAL);
return -1;
}
return(__setuid(uid));
}
#endif
//#define __NR_getuid 24
#ifdef L_getuid
#include <unistd.h>
_syscall0(gid_t, getuid);
#endif
//#define __NR_stime 25
#ifdef L_stime
#include <time.h>
_syscall1(int, stime, const time_t *, t);
#endif
//#define __NR_ptrace 26
#ifdef L___ptrace
#include <sys/ptrace.h>
#define __NR___ptrace __NR_ptrace
_syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,
void*, addr, void*, data);
#endif
//#define __NR_alarm 27
#ifdef L_alarm
#include <unistd.h>
_syscall1(unsigned int, alarm, unsigned int, seconds);
#endif
//#define __NR_oldfstat 28
//#define __NR_pause 29
#ifdef L___libc_pause
#include <unistd.h>
#define __NR___libc_pause __NR_pause
_syscall0(int, __libc_pause);
weak_alias(__libc_pause, pause)
#endif
//#define __NR_utime 30
#ifdef L_utime
#include <utime.h>
_syscall2(int, utime, const char *, filename, const str
|