1 /* Linux version of pread so we can have a weak_alias */ 2 3 #include <_ansi.h> 4 #include <unistd.h> 5 #include <reent.h> 6 #include <machine/weakalias.h> 7 8 ssize_t 9 _DEFUN (_pread_r, (rptr, fd, buf, n, off), 10 struct _reent *rptr _AND 11 int fd _AND 12 _PTR buf _AND 13 size_t n _AND 14 off_t off) 15 { 16 off_t cur_pos; 17 _READ_WRITE_RETURN_TYPE num_read; 18 19 if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1) 20 return -1; 21 22 if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1) 23 return -1; 24 25 num_read = _read_r (rptr, fd, buf, n); 26 27 if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1) 28 return -1; 29 30 return (ssize_t)num_read; 31 } 32 33 #ifndef _REENT_ONLY 34 35 ssize_t 36 _DEFUN (__libc_pread, (fd, buf, n, off), 37 int fd _AND 38 _PTR buf _AND 39 size_t n _AND 40 off_t off) 41 { 42 return _pread_r (_REENT, fd, buf, n, off); 43 } 44 weak_alias(__libc_pread,pread) 45 46 #endif 47