#! /bin/sh # Copyright (C) 2005 Axis Communications. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Neither the name of Axis Communications nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS # COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # To avoid an abundance of copyright/license messages for boilerplate # code, we instead generate them from this file. Generating the # function code could also be done automatically, but at the cost of # slightly more intricate build machinery and/or scattered syscall # information. Beware that the cat-lines must match the sed regexp # "^cat > \([^ ]*\).*". lu='/* -*- buffer-read-only: t -*- THIS FILE IS AUTOMATICALLY GENERATED FROM "'$0'". */ #include "linunistd.h" #define R(x) return (x); } ' lui="$lu int" r=") { R (_Sys_" cat > close.c < execve.c < exit.c < fcntl.c < fork.c < fstat.c < #include int _fstat (int fd, struct stat *buf) { struct new_stat ks; int retval = _Sys_fstat (fd, &ks); /* Blank before filling it in. */ memset (buf, 0, sizeof (*buf)); /* We have to translate from the linux struct new_stat. It seems we don't have to translate the contents, though. */ buf->st_dev = ks.st_dev; buf->st_ino = ks.st_ino; buf->st_mode = ks.st_mode; buf->st_nlink = ks.st_nlink; buf->st_uid = ks.st_uid; buf->st_gid = ks.st_gid; buf->st_rdev = ks.st_rdev; buf->st_size = ks.st_size; buf->st_blksize = ks.st_blksize; buf->st_blocks = ks.st_blocks; buf->st_atime = ks.st_atime; buf->st_mtime = ks.st_mtime; buf->st_ctime = ks.st_ctime; R (retval) EOF cat > getpid.c < gettod.c < #include int _gettimeofday (struct timeval *tp, void *tzp ${r}gettimeofday (tp, tzp)) EOF cat > isatty.c < kill.c < link.c < lseek.c < open.c < read.c < rename.c < sbrk.c < stat.c < #include int _stat (const char *path, struct stat *buf) { struct new_stat ks; int retval = _Sys_stat (path, &ks); /* Blank before filling it in. */ memset (buf, 0, sizeof (*buf)); /* We have to translate from the linux struct new_stat. It seems we don't have to translate the contents, though. */ buf->st_dev = ks.st_dev; buf->st_ino = ks.st_ino; buf->st_mode = ks.st_mode; buf->st_nlink = ks.st_nlink; buf->st_uid = ks.st_uid; buf->st_gid = ks.st_gid; buf->st_rdev = ks.st_rdev; buf->st_size = ks.st_size; buf->st_blksize = ks.st_blksize; buf->st_blocks = ks.st_blocks; buf->st_atime = ks.st_atime; buf->st_mtime = ks.st_mtime; buf->st_ctime = ks.st_ctime; R (retval) EOF cat > times.c < clock_t _times (struct tms * tp${r}times (tp)) EOF cat > unlink.c < wait.c < write.c <