Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: linux_syscall_support.h

Issue 1743093002: Fix usage with musl libc. Base URL: https://chromium.googlesource.com/linux-syscall-support@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2005-2011, Google Inc. 1 /* Copyright (c) 2005-2011, Google Inc.
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 : "esp", "memory", "ecx", "edx", "esi", "edi"); 1835 : "esp", "memory", "ecx", "edx", "esi", "edi");
1836 LSS_RETURN(int, __res); 1836 LSS_RETURN(int, __res);
1837 } 1837 }
1838 1838
1839 #define __NR__fadvise64_64 __NR_fadvise64_64 1839 #define __NR__fadvise64_64 __NR_fadvise64_64
1840 LSS_INLINE _syscall6(int, _fadvise64_64, int, fd, 1840 LSS_INLINE _syscall6(int, _fadvise64_64, int, fd,
1841 unsigned, offset_lo, unsigned, offset_hi, 1841 unsigned, offset_lo, unsigned, offset_hi,
1842 unsigned, len_lo, unsigned, len_hi, 1842 unsigned, len_lo, unsigned, len_hi,
1843 int, advice) 1843 int, advice)
1844 1844
1845 LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset, 1845 LSS_INLINE int LSS_NAME(fadvise64)(int fd, int64_t offset,
1846 loff_t len, int advice) { 1846 int64_t len, int advice) {
1847 return LSS_NAME(_fadvise64_64)(fd, 1847 return LSS_NAME(_fadvise64_64)(fd,
1848 (unsigned)offset, (unsigned)(offset >>32), 1848 (unsigned)offset, (unsigned)(offset >>32),
1849 (unsigned)len, (unsigned)(len >> 32), 1849 (unsigned)len, (unsigned)(len >> 32),
1850 advice); 1850 advice);
1851 } 1851 }
1852 1852
1853 #define __NR__fallocate __NR_fallocate 1853 #define __NR__fallocate __NR_fallocate
1854 LSS_INLINE _syscall6(int, _fallocate, int, fd, 1854 LSS_INLINE _syscall6(int, _fallocate, int, fd,
1855 int, mode, 1855 int, mode,
1856 unsigned, offset_lo, unsigned, offset_hi, 1856 unsigned, offset_lo, unsigned, offset_hi,
1857 unsigned, len_lo, unsigned, len_hi) 1857 unsigned, len_lo, unsigned, len_hi)
1858 1858
1859 LSS_INLINE int LSS_NAME(fallocate)(int fd, int mode, 1859 LSS_INLINE int LSS_NAME(fallocate)(int fd, int mode,
1860 loff_t offset, loff_t len) { 1860 int64_t offset, int64_t len) {
1861 union { loff_t off; unsigned w[2]; } o = { offset }, l = { len }; 1861 union { int64_t off; unsigned w[2]; } o = { offset }, l = { len };
1862 return LSS_NAME(_fallocate)(fd, mode, o.w[0], o.w[1], l.w[0], l.w[1]); 1862 return LSS_NAME(_fallocate)(fd, mode, o.w[0], o.w[1], l.w[0], l.w[1]);
1863 } 1863 }
1864 1864
1865 LSS_INLINE _syscall1(int, set_thread_area, void *, u) 1865 LSS_INLINE _syscall1(int, set_thread_area, void *, u)
1866 LSS_INLINE _syscall1(int, get_thread_area, void *, u) 1866 LSS_INLINE _syscall1(int, get_thread_area, void *, u)
1867 1867
1868 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { 1868 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) {
1869 /* On i386, the kernel does not know how to return from a signal 1869 /* On i386, the kernel does not know how to return from a signal
1870 * handler. Instead, it relies on user space to provide a 1870 * handler. Instead, it relies on user space to provide a
1871 * restorer function that calls the {rt_,}sigreturn() system call. 1871 * restorer function that calls the {rt_,}sigreturn() system call.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 "r"(LSS_SYSCALL_ARG(arg)), 2142 "r"(LSS_SYSCALL_ARG(arg)),
2143 "d"(LSS_SYSCALL_ARG(parent_tidptr)), 2143 "d"(LSS_SYSCALL_ARG(parent_tidptr)),
2144 "r"(LSS_SYSCALL_ARG(newtls)), 2144 "r"(LSS_SYSCALL_ARG(newtls)),
2145 "r"(LSS_SYSCALL_ARG(child_tidptr)) 2145 "r"(LSS_SYSCALL_ARG(child_tidptr))
2146 : "rsp", "memory", "r8", "r10", "r11", "rcx"); 2146 : "rsp", "memory", "r8", "r10", "r11", "rcx");
2147 } 2147 }
2148 LSS_RETURN(int, __res); 2148 LSS_RETURN(int, __res);
2149 } 2149 }
2150 LSS_INLINE _syscall2(int, arch_prctl, int, c, void *, a) 2150 LSS_INLINE _syscall2(int, arch_prctl, int, c, void *, a)
2151 2151
2152 /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ 2152 /* Need to make sure int_t isn't truncated to 32-bits under x32. */
2153 LSS_INLINE int LSS_NAME(fadvise64)(int fd, loff_t offset, loff_t len, 2153 LSS_INLINE int LSS_NAME(fadvise64)(int fd, int64_t offset, int64_t len,
2154 int advice) { 2154 int advice) {
2155 LSS_BODY(4, int, fadvise64, LSS_SYSCALL_ARG(fd), (uint64_t)(offset), 2155 LSS_BODY(4, int, fadvise64, LSS_SYSCALL_ARG(fd), (uint64_t)(offset),
2156 (uint64_t)(len), LSS_SYSCALL_ARG(advice)); 2156 (uint64_t)(len), LSS_SYSCALL_ARG(advice));
2157 } 2157 }
2158 2158
2159 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) { 2159 LSS_INLINE void (*LSS_NAME(restore_rt)(void))(void) {
2160 /* On x86-64, the kernel does not know how to return from 2160 /* On x86-64, the kernel does not know how to return from
2161 * a signal handler. Instead, it relies on user space to provide a 2161 * a signal handler. Instead, it relies on user space to provide a
2162 * restorer function that calls the rt_sigreturn() system call. 2162 * restorer function that calls the rt_sigreturn() system call.
2163 * Unfortunately, we cannot just reference the glibc version of this 2163 * Unfortunately, we cannot just reference the glibc version of this
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 int, f, 3184 int, f,
3185 const struct kernel_sockaddr*, a, int, t) 3185 const struct kernel_sockaddr*, a, int, t)
3186 LSS_INLINE _syscall2(int, shutdown, int, s, 3186 LSS_INLINE _syscall2(int, shutdown, int, s,
3187 int, h) 3187 int, h)
3188 LSS_INLINE _syscall3(int, socket, int, d, 3188 LSS_INLINE _syscall3(int, socket, int, d,
3189 int, t, int, p) 3189 int, t, int, p)
3190 LSS_INLINE _syscall4(int, socketpair, int, d, 3190 LSS_INLINE _syscall4(int, socketpair, int, d,
3191 int, t, int, p, int*, s) 3191 int, t, int, p, int*, s)
3192 #endif 3192 #endif
3193 #if defined(__x86_64__) 3193 #if defined(__x86_64__)
3194 /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ 3194 /* Need to make sure int64_t isn't truncated to 32-bits under x32. */
3195 LSS_INLINE int LSS_NAME(fallocate)(int f, int mode, loff_t offset, 3195 LSS_INLINE int LSS_NAME(fallocate)(int f, int mode, int64_t offset,
3196 loff_t len) { 3196 int64_t len) {
3197 LSS_BODY(4, int, fallocate, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(mode), 3197 LSS_BODY(4, int, fallocate, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(mode),
3198 (uint64_t)(offset), (uint64_t)(len)); 3198 (uint64_t)(offset), (uint64_t)(len));
3199 } 3199 }
3200 3200
3201 LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid, 3201 LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid,
3202 gid_t *egid, 3202 gid_t *egid,
3203 gid_t *sgid) { 3203 gid_t *sgid) {
3204 return LSS_NAME(getresgid)(rgid, egid, sgid); 3204 return LSS_NAME(getresgid)(rgid, egid, sgid);
3205 } 3205 }
3206 3206
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__) 3446 (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || defined(__PPC__)
3447 #define __NR__sigaction __NR_sigaction 3447 #define __NR__sigaction __NR_sigaction
3448 #define __NR__sigpending __NR_sigpending 3448 #define __NR__sigpending __NR_sigpending
3449 #define __NR__sigprocmask __NR_sigprocmask 3449 #define __NR__sigprocmask __NR_sigprocmask
3450 #define __NR__sigsuspend __NR_sigsuspend 3450 #define __NR__sigsuspend __NR_sigsuspend
3451 #define __NR__socketcall __NR_socketcall 3451 #define __NR__socketcall __NR_socketcall
3452 LSS_INLINE _syscall2(int, fstat64, int, f, 3452 LSS_INLINE _syscall2(int, fstat64, int, f,
3453 struct kernel_stat64 *, b) 3453 struct kernel_stat64 *, b)
3454 LSS_INLINE _syscall5(int, _llseek, uint, fd, 3454 LSS_INLINE _syscall5(int, _llseek, uint, fd,
3455 unsigned long, hi, unsigned long, lo, 3455 unsigned long, hi, unsigned long, lo,
3456 loff_t *, res, uint, wh) 3456 int64_t *, res, uint, wh)
3457 #if !defined(__ARM_EABI__) 3457 #if !defined(__ARM_EABI__)
3458 LSS_INLINE _syscall1(void*, mmap, void*, a) 3458 LSS_INLINE _syscall1(void*, mmap, void*, a)
3459 #endif 3459 #endif
3460 LSS_INLINE _syscall6(void*, mmap2, void*, s, 3460 LSS_INLINE _syscall6(void*, mmap2, void*, s,
3461 size_t, l, int, p, 3461 size_t, l, int, p,
3462 int, f, int, d, 3462 int, f, int, d,
3463 off_t, o) 3463 off_t, o)
3464 LSS_INLINE _syscall3(int, _sigaction, int, s, 3464 LSS_INLINE _syscall3(int, _sigaction, int, s,
3465 const struct kernel_old_sigaction*, a, 3465 const struct kernel_old_sigaction*, a,
3466 struct kernel_old_sigaction*, o) 3466 struct kernel_old_sigaction*, o)
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3855 #endif 3855 #endif
3856 } 3856 }
3857 case _SC_PAGESIZE: 3857 case _SC_PAGESIZE:
3858 return __getpagesize(); 3858 return __getpagesize();
3859 default: 3859 default:
3860 LSS_ERRNO = ENOSYS; 3860 LSS_ERRNO = ENOSYS;
3861 return -1; 3861 return -1;
3862 } 3862 }
3863 } 3863 }
3864 #if defined(__x86_64__) 3864 #if defined(__x86_64__)
3865 /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ 3865 /* Need to make sure int64_t isn't truncated to 32-bits under x32. */
3866 LSS_INLINE ssize_t LSS_NAME(pread64)(int f, void *b, size_t c, loff_t o) { 3866 LSS_INLINE ssize_t LSS_NAME(pread64)(int f, void *b, size_t c, int64_t o) {
3867 LSS_BODY(4, ssize_t, pread64, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(b), 3867 LSS_BODY(4, ssize_t, pread64, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(b),
3868 LSS_SYSCALL_ARG(c), (uint64_t)(o)); 3868 LSS_SYSCALL_ARG(c), (uint64_t)(o));
3869 } 3869 }
3870 3870
3871 LSS_INLINE ssize_t LSS_NAME(pwrite64)(int f, const void *b, size_t c, 3871 LSS_INLINE ssize_t LSS_NAME(pwrite64)(int f, const void *b, size_t c,
3872 loff_t o) { 3872 int64_t o) {
3873 LSS_BODY(4, ssize_t, pwrite64, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(b), 3873 LSS_BODY(4, ssize_t, pwrite64, LSS_SYSCALL_ARG(f), LSS_SYSCALL_ARG(b),
3874 LSS_SYSCALL_ARG(c), (uint64_t)(o)); 3874 LSS_SYSCALL_ARG(c), (uint64_t)(o));
3875 } 3875 }
3876 3876
3877 LSS_INLINE int LSS_NAME(readahead)(int f, loff_t o, unsigned c) { 3877 LSS_INLINE int LSS_NAME(readahead)(int f, int64_t o, unsigned c) {
3878 LSS_BODY(3, int, readahead, LSS_SYSCALL_ARG(f), (uint64_t)(o), 3878 LSS_BODY(3, int, readahead, LSS_SYSCALL_ARG(f), (uint64_t)(o),
3879 LSS_SYSCALL_ARG(c)); 3879 LSS_SYSCALL_ARG(c));
3880 } 3880 }
3881 #elif defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64 3881 #elif defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI64
3882 LSS_INLINE _syscall4(ssize_t, pread64, int, f, 3882 LSS_INLINE _syscall4(ssize_t, pread64, int, f,
3883 void *, b, size_t, c, 3883 void *, b, size_t, c,
3884 loff_t, o) 3884 int64_t, o)
3885 LSS_INLINE _syscall4(ssize_t, pwrite64, int, f, 3885 LSS_INLINE _syscall4(ssize_t, pwrite64, int, f,
3886 const void *, b, size_t, c, 3886 const void *, b, size_t, c,
3887 loff_t, o) 3887 int64_t, o)
3888 LSS_INLINE _syscall3(int, readahead, int, f, 3888 LSS_INLINE _syscall3(int, readahead, int, f,
3889 loff_t, o, unsigned, c) 3889 int64_t, o, unsigned, c)
3890 LSS_INLINE _syscall6(void *, mmap, void *, addr, size_t, length, int, prot, 3890 LSS_INLINE _syscall6(void *, mmap, void *, addr, size_t, length, int, prot,
3891 int, flags, int, fd, int64_t, offset) 3891 int, flags, int, fd, int64_t, offset)
3892 #else 3892 #else
3893 #define __NR__pread64 __NR_pread64 3893 #define __NR__pread64 __NR_pread64
3894 #define __NR__pwrite64 __NR_pwrite64 3894 #define __NR__pwrite64 __NR_pwrite64
3895 #define __NR__readahead __NR_readahead 3895 #define __NR__readahead __NR_readahead
3896 #if defined(__ARM_EABI__) || defined(__mips__) 3896 #if defined(__ARM_EABI__) || defined(__mips__)
3897 /* On ARM and MIPS, a 64-bit parameter has to be in an even-odd register 3897 /* On ARM and MIPS, a 64-bit parameter has to be in an even-odd register
3898 * pair. Hence these calls ignore their fourth argument (r3) so that their 3898 * pair. Hence these calls ignore their fourth argument (r3) so that their
3899 * fifth and sixth make such a pair (r4,r5). 3899 * fifth and sixth make such a pair (r4,r5).
(...skipping 18 matching lines...) Expand all
3918 long, o2) 3918 long, o2)
3919 LSS_INLINE _syscall4(int, _readahead, int, f, 3919 LSS_INLINE _syscall4(int, _readahead, int, f,
3920 unsigned, o1, unsigned, o2, size_t, c) 3920 unsigned, o1, unsigned, o2, size_t, c)
3921 #endif 3921 #endif
3922 /* We force 64bit-wide parameters onto the stack, then access each 3922 /* We force 64bit-wide parameters onto the stack, then access each
3923 * 32-bit component individually. This guarantees that we build the 3923 * 32-bit component individually. This guarantees that we build the
3924 * correct parameters independent of the native byte-order of the 3924 * correct parameters independent of the native byte-order of the
3925 * underlying architecture. 3925 * underlying architecture.
3926 */ 3926 */
3927 LSS_INLINE ssize_t LSS_NAME(pread64)(int fd, void *buf, size_t count, 3927 LSS_INLINE ssize_t LSS_NAME(pread64)(int fd, void *buf, size_t count,
3928 loff_t off) { 3928 int64_t off) {
3929 union { loff_t off; unsigned arg[2]; } o = { off }; 3929 union { int64_t off; unsigned arg[2]; } o = { off };
3930 return LSS_NAME(_pread64)(fd, buf, count, 3930 return LSS_NAME(_pread64)(fd, buf, count,
3931 LSS_LLARG_PAD o.arg[0], o.arg[1]); 3931 LSS_LLARG_PAD o.arg[0], o.arg[1]);
3932 } 3932 }
3933 LSS_INLINE ssize_t LSS_NAME(pwrite64)(int fd, const void *buf, 3933 LSS_INLINE ssize_t LSS_NAME(pwrite64)(int fd, const void *buf,
3934 size_t count, loff_t off) { 3934 size_t count, int64_t off) {
3935 union { loff_t off; unsigned arg[2]; } o = { off }; 3935 union { int64_t off; unsigned arg[2]; } o = { off };
3936 return LSS_NAME(_pwrite64)(fd, buf, count, 3936 return LSS_NAME(_pwrite64)(fd, buf, count,
3937 LSS_LLARG_PAD o.arg[0], o.arg[1]); 3937 LSS_LLARG_PAD o.arg[0], o.arg[1]);
3938 } 3938 }
3939 LSS_INLINE int LSS_NAME(readahead)(int fd, loff_t off, int len) { 3939 LSS_INLINE int LSS_NAME(readahead)(int fd, int64_t off, int len) {
3940 union { loff_t off; unsigned arg[2]; } o = { off }; 3940 union { int64_t off; unsigned arg[2]; } o = { off };
3941 return LSS_NAME(_readahead)(fd, LSS_LLARG_PAD o.arg[0], o.arg[1], len); 3941 return LSS_NAME(_readahead)(fd, LSS_LLARG_PAD o.arg[0], o.arg[1], len);
3942 } 3942 }
3943 #endif 3943 #endif
3944 #endif 3944 #endif
3945 3945
3946 #if defined(__aarch64__) 3946 #if defined(__aarch64__)
3947 LSS_INLINE _syscall3(int, dup3, int, s, int, d, int, f) 3947 LSS_INLINE _syscall3(int, dup3, int, s, int, d, int, f)
3948 LSS_INLINE _syscall6(void *, mmap, void *, addr, size_t, length, int, prot, 3948 LSS_INLINE _syscall6(void *, mmap, void *, addr, size_t, length, int, prot,
3949 int, flags, int, fd, int64_t, offset) 3949 int, flags, int, fd, int64_t, offset)
3950 LSS_INLINE _syscall4(int, newfstatat, int, dirfd, const char *, pathname, 3950 LSS_INLINE _syscall4(int, newfstatat, int, dirfd, const char *, pathname,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 # pragma pop_macro("fstat64") 4028 # pragma pop_macro("fstat64")
4029 # pragma pop_macro("lstat64") 4029 # pragma pop_macro("lstat64")
4030 #endif 4030 #endif
4031 4031
4032 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) 4032 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS)
4033 } 4033 }
4034 #endif 4034 #endif
4035 4035
4036 #endif 4036 #endif
4037 #endif 4037 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698