source: npl/system/klibc/patches/klibc-add-pread-and-pwrite-32bit-syscall-wrappers-for-parisc.patch @ 26ffad7

Last change on this file since 26ffad7 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 3.5 KB
  • usr/include/endian.h

    From: Helge Deller <deller@gmx.de>
    Subject: [klibc] Add pread and pwrite 32bit syscall wrappers for parisc
    Date: Wed, 23 Apr 2014 22:52:53 +0200
    Bug-Debian: https://bugs.debian.org/745660
    Forwarded: http://www.zytor.com/pipermail/klibc/2016-January/003880.html
    
    On the hppa arch (32bit userspace and 32 or 64bit kernel), the fstype
    program fails to detect the filesystem.  The reason for this failure
    is, that fstype calls the pread() syscall, which has on some
    architectures with 32bit userspace a different calling syntax.  I
    noticed this bug on hppa, but I assume s390 (32bit) and others might
    run into similiar issues.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    ---
    a b  
    1212#define PDP_ENDIAN      __PDP_ENDIAN
    1313#define BYTE_ORDER      __BYTE_ORDER
    1414
     15#if __BYTE_ORDER == __LITTLE_ENDIAN
     16# define __LONG_LONG_PAIR(HI, LO) LO, HI
     17#elif __BYTE_ORDER == __BIG_ENDIAN
     18# define __LONG_LONG_PAIR(HI, LO) HI, LO
     19#endif
     20
    1521#endif                          /* _ENDIAN_H */
  • usr/klibc/Kbuild

    a b klib-y += vsnprintf.o snprintf.o vsprint 
    3535          siglongjmp.o \
    3636          sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
    3737          pselect.o ppoll.o \
     38          pread.o pwrite.o \
    3839          brk.o sbrk.o malloc.o realloc.o zalloc.o calloc.o \
    3940          mmap.o shm_open.o shm_unlink.o \
    4041          memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
  • new file usr/klibc/pread.c

    - +  
     1/*
     2 * pread.c
     3 *
     4 * Some architectures need to wrap the system call
     5 */
     6
     7#include <endian.h>
     8#include <sys/syscall.h>
     9
     10#if defined(__hppa__)
     11
     12#if _BITSIZE == 32
     13extern size_t __pread(int, void *, size_t, unsigned int, unsigned int);
     14#else
     15extern size_t __pread(int, void *, size_t, off_t);
     16#endif
     17
     18size_t pread(int fd, void *buf, size_t count, off_t offset)
     19{
     20#if _BITSIZE == 32
     21        unsigned int hi = offset >> 32;
     22        unsigned int lo = (unsigned int) offset;
     23        return __pread(fd, buf, count, __LONG_LONG_PAIR(hi, lo));
     24#else
     25        return __pread(fd, buf, count, offset);
     26#endif
     27}
     28
     29#endif
  • new file usr/klibc/pwrite.c

    - +  
     1/*
     2 * pwrite.c
     3 *
     4 * Some architectures need to wrap the system call
     5 */
     6
     7#include <endian.h>
     8#include <sys/syscall.h>
     9
     10#if defined(__hppa__)
     11
     12#if _BITSIZE == 32
     13extern ssize_t __pwrite(int, const void *, size_t, unsigned int, unsigned int);
     14#else
     15extern ssize_t __pwrite(int, const void *, size_t, off_t);
     16#endif
     17
     18size_t pwrite(int fd, void *buf, size_t count, off_t offset)
     19{
     20#if _BITSIZE == 32
     21        unsigned int hi = offset >> 32;
     22        unsigned int lo = (unsigned int) offset;
     23        return __pwrite(fd, buf, count, __LONG_LONG_PAIR(hi, lo));
     24#else
     25        return __pwrite(fd, buf, count, offset);
     26#endif
     27}
     28
     29#endif
  • usr/klibc/SYSCALLS.def

    a b int fdatasync,fsync::fdatasync(int); 
    189189int readv(int, const struct iovec *, int);
    190190int writev(int, const struct iovec *, int);
    191191int ftruncate64,ftruncate::ftruncate(int, off_t);
    192 ssize_t pread64,pread::pread(int, void *, size_t, off_t);
    193 ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t);
     192<parisc> ssize_t pread64,pread::__pread(int, void *, size_t, off_t);
     193<parisc> ssize_t pwrite64,pwrite::__pwrite(int, void *, size_t, off_t);
     194<!parisc> ssize_t pread64,pread::pread(int, void *, size_t, off_t);
     195<!parisc> ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t);
    194196int sync_file_range,fdatasync,fsync::sync_file_range(int, off_t, off_t, unsigned int);
    195197<?> int splice(int, off_t *, int, off_t *, size_t, unsigned int);
    196198<?> int tee(int, int, size_t, unsigned int);
Note: See TracBrowser for help on using the repository browser.