From 0695d2cabcfeb84bb62105f6fcf58bdda5454e39 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 17 Jan 2005 23:18:56 +0000 Subject: add posix_fadvise / posix_fadvise64 support --- libc/sysdeps/linux/common/Makefile | 16 ++++---- libc/sysdeps/linux/common/posix_fadvise.c | 34 +++++++++++++++++ libc/sysdeps/linux/common/posix_fadvise64.c | 57 +++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 libc/sysdeps/linux/common/posix_fadvise.c create mode 100644 libc/sysdeps/linux/common/posix_fadvise64.c diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile index b5ea8d261..e42987859 100644 --- a/libc/sysdeps/linux/common/Makefile +++ b/libc/sysdeps/linux/common/Makefile @@ -37,14 +37,14 @@ CSRC= __rt_sigtimedwait.c __socketcall.c __syscall_fcntl.c \ mlockall.c mmap.c mmap64.c modify_ldt.c mount.c mprotect.c \ mremap.c msync.c munlock.c munlockall.c munmap.c nanosleep.c \ nice.c noophooks.c ntp_gettime.c open.c open64.c pause.c \ - personality.c pipe.c pivot_root.c poll.c prctl.c pread_write.c \ - ptrace.c query_module.c quotactl.c read.c readlink.c readv.c \ - reboot.c rename.c rmdir.c sched_get_priority_max.c \ - sched_get_priority_min.c sched_getparam.c sched_getscheduler.c \ - sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c \ - sched_yield.c select.c sendfile.c sendfile64.c setdomainname.c \ - setegid.c seteuid.c setfsgid.c setfsuid.c setgid.c setgroups.c \ - sethostname.c setitimer.c setpgid.c setpgrp.c setpriority.c \ + personality.c pipe.c pivot_root.c poll.c posix_fadvise.c \ + posix_fadvise64.c prctl.c pread_write.c ptrace.c query_module.c \ + quotactl.c read.c readlink.c readv.c reboot.c rename.c rmdir.c \ + sched_get_priority_max.c sched_get_priority_min.c sched_getparam.c \ + sched_getscheduler.c sched_rr_get_interval.c sched_setparam.c \ + sched_setscheduler.c sched_yield.c select.c sendfile.c sendfile64.c \ + setdomainname.c setegid.c seteuid.c setfsgid.c setfsuid.c setgid.c \ + setgroups.c sethostname.c setitimer.c setpgid.c setpgrp.c setpriority.c \ setregid.c setresgid.c setresuid.c setreuid.c setrlimit.c \ setrlimit64.c setsid.c settimeofday.c setuid.c sigaltstack.c \ sigpending.c sigprocmask.c sigsuspend.c stat.c stat64.c statfs.c \ diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c new file mode 100644 index 000000000..b75a6c313 --- /dev/null +++ b/libc/sysdeps/linux/common/posix_fadvise.c @@ -0,0 +1,34 @@ +/* vi: set sw=4 ts=4: */ +/* + * posix_fadvise() for uClibc + * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html + * + * Copyright (C) 2000-2005 by Erik Andersen + * + * GNU Library General Public License (LGPL) version 2 or later. + */ + +#include "syscalls.h" +#include + +#ifdef __NR_fadvise64 +#define __NR___syscall_fadvise64 __NR_fadvise64 +_syscall4(int, __syscall_fadvise64, int, fd, off_t, offset, + off_t, len, int, advice); +int __libc_posix_fadvise(int fd, off_t offset, off_t len, int advice) +{ + return (__syscall_fadvise64(fd, offset, len, advice)); +} +weak_alias(__libc_posix_fadvise, posix_fadvise); + +#else +int posix_fadvise(int fd, off_t offset, off_t len, int advice) +{ + __set_errno(ENOSYS); + return -1; +} +#endif + +#if ! defined __NR_fadvise64_64 && defined __UCLIBC_HAS_LFS__ +weak_alias(__libc_posix_fadvise, posix_fadvise64); +#endif diff --git a/libc/sysdeps/linux/common/posix_fadvise64.c b/libc/sysdeps/linux/common/posix_fadvise64.c new file mode 100644 index 000000000..93d56d6cb --- /dev/null +++ b/libc/sysdeps/linux/common/posix_fadvise64.c @@ -0,0 +1,57 @@ +/* vi: set sw=4 ts=4: */ +/* + * posix_fadvise64() for uClibc + * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html + * + * Copyright (C) 2000-2005 by Erik Andersen + * + * GNU Library General Public License (LGPL) version 2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined __UCLIBC_HAS_LFS__ && defined __NR_fadvise64_64 +#define __NR___syscall_fadvise64_64 __NR_fadvise64_64 + +/* 64 bit implementation is cake ... or more like pie ... */ +#if __WORDSIZE == 64 +_syscall4(int, __syscall_fadvise64_64, int, fd, __off64_t, offset, + __off64_t, len, int, advice); +int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) +{ + return (__syscall_fadvise64_64(fd, offset, len, advice)); +} +weak_alias(__libc_posix_fadvise64, posix_fadvise64); + +/* 32 bit implementation is kind of a pita */ +#elif __WORDSIZE == 32 + +#ifdef _syscall6 /* workaround until everyone has _syscall6() */ +_syscall6(int, __syscall_fadvise64_64, int, fd, + unsigned long, high_offset, unsigned long, low_offset, + unsigned long, high_len, unsigned long, low_len, + int, advice); +int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) +{ + return (__syscall_fadvise64_64(fd, + __LONG_LONG_PAIR(offset >> 32, offset & 0xffffffff), + __LONG_LONG_PAIR(len >> 32, len & 0xffffffff), + advice)); +} +weak_alias(__libc_posix_fadvise64, posix_fadvise64); +#else +#warning _syscall6 has not been defined for your machine :( +#endif /* _syscall6 */ + +#else +#error your machine is neither 32 bit or 64 bit ... it must be magical +#endif + +#endif -- cgit v1.2.3