Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-04-29 23:31:23 +0400
committerJeff Johnston <jjohnstn@redhat.com>2002-04-29 23:31:23 +0400
commit29798f0d57549a89d7ec6c8717fda26347e6bbf7 (patch)
tree76ffe5ce7c145afb2449d0b56780d8cd03e98ae1 /newlib
parenteccebec08df9f2b74e2bf457f4063c86662727e0 (diff)
2002-04-29 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/unistd.h (pread, pwrite): Added prototypes. * libc/unix/Makefile.am: Add pread.c and pwrite.c. * libc/sys/linux/Makefile.am: Add pread64.c and pwrite64.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/unix/Makefile.in: Ditto. * libc/sys/linux/pread64.c: New file. * libc/sys/linux/pwrite64.c: Ditto. * libc/unix/pread.c: Ditto. * libc/unix/pwrite.c: Ditto.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog12
-rw-r--r--newlib/libc/include/sys/unistd.h2
-rw-r--r--newlib/libc/sys/linux/Makefile.am2
-rw-r--r--newlib/libc/sys/linux/Makefile.in19
-rw-r--r--newlib/libc/sys/linux/pread64.c62
-rw-r--r--newlib/libc/sys/linux/pwrite64.c62
-rw-r--r--newlib/libc/unix/Makefile.am3
-rw-r--r--newlib/libc/unix/Makefile.in13
-rw-r--r--newlib/libc/unix/pread.c91
-rw-r--r--newlib/libc/unix/pwrite.c92
10 files changed, 342 insertions, 16 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 37a7a11f6..ca3667ce6 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,15 @@
+2002-04-29 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/include/sys/unistd.h (pread, pwrite): Added prototypes.
+ * libc/unix/Makefile.am: Add pread.c and pwrite.c.
+ * libc/sys/linux/Makefile.am: Add pread64.c and pwrite64.c.
+ * libc/sys/linux/Makefile.in: Regenerated.
+ * libc/unix/Makefile.in: Ditto.
+ * libc/sys/linux/pread64.c: New file.
+ * libc/sys/linux/pwrite64.c: Ditto.
+ * libc/unix/pread.c: Ditto.
+ * libc/unix/pwrite.c: Ditto.
+
2002-04-26 Jeff Johnston <jjohnstn@redhat.com>
* libc/sys/linux/Makefile.am: Add io64.c.
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index 70682b2e0..9ea34844c 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -78,6 +78,8 @@ int _EXFUN(pause, (void ));
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
#endif
int _EXFUN(pipe, (int __fildes[2] ));
+ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
+ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
#if defined(__CYGWIN__)
int _EXFUN(revoke, (char *path));
diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am
index 6b919da8c..dfac93b92 100644
--- a/newlib/libc/sys/linux/Makefile.am
+++ b/newlib/libc/sys/linux/Makefile.am
@@ -9,7 +9,7 @@ SUBLIBS = $(LINUX_MACH_LIB)
LIB_SOURCES = \
brk.c getoptlong.c ids.c inode.c io.c io64.c linux.c mmap.c \
- process.c realpath.c sched.c \
+ pread64.c process.c pwrite64.c realpath.c sched.c \
select.c signal.c siglongjmp.c socket.c sleep.c stack.c \
sysconf.c systat.c termios.c time.c \
usleep.c wait.c
diff --git a/newlib/libc/sys/linux/Makefile.in b/newlib/libc/sys/linux/Makefile.in
index e4f840bc6..cec25fa0e 100644
--- a/newlib/libc/sys/linux/Makefile.in
+++ b/newlib/libc/sys/linux/Makefile.in
@@ -98,7 +98,7 @@ SUBLIBS = $(LINUX_MACH_LIB)
LIB_SOURCES = \
brk.c getoptlong.c ids.c inode.c io.c io64.c linux.c mmap.c \
- process.c realpath.c sched.c \
+ pread64.c process.c pwrite64.c realpath.c sched.c \
select.c signal.c siglongjmp.c socket.c sleep.c stack.c \
sysconf.c systat.c termios.c time.c \
usleep.c wait.c
@@ -132,18 +132,19 @@ DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = brk.o getoptlong.o ids.o inode.o \
-@USE_LIBTOOL_FALSE@io.o io64.o linux.o mmap.o process.o realpath.o \
-@USE_LIBTOOL_FALSE@sched.o select.o signal.o siglongjmp.o socket.o \
-@USE_LIBTOOL_FALSE@sleep.o stack.o sysconf.o systat.o termios.o time.o \
-@USE_LIBTOOL_FALSE@usleep.o wait.o
+@USE_LIBTOOL_FALSE@io.o io64.o linux.o mmap.o pread64.o process.o \
+@USE_LIBTOOL_FALSE@pwrite64.o realpath.o sched.o select.o signal.o \
+@USE_LIBTOOL_FALSE@siglongjmp.o socket.o sleep.o stack.o sysconf.o \
+@USE_LIBTOOL_FALSE@systat.o termios.o time.o usleep.o wait.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@liblinux_la_DEPENDENCIES =
@USE_LIBTOOL_TRUE@liblinux_la_OBJECTS = brk.lo getoptlong.lo ids.lo \
-@USE_LIBTOOL_TRUE@inode.lo io.lo io64.lo linux.lo mmap.lo process.lo \
-@USE_LIBTOOL_TRUE@realpath.lo sched.lo select.lo signal.lo \
-@USE_LIBTOOL_TRUE@siglongjmp.lo socket.lo sleep.lo stack.lo sysconf.lo \
-@USE_LIBTOOL_TRUE@systat.lo termios.lo time.lo usleep.lo wait.lo
+@USE_LIBTOOL_TRUE@inode.lo io.lo io64.lo linux.lo mmap.lo pread64.lo \
+@USE_LIBTOOL_TRUE@process.lo pwrite64.lo realpath.lo sched.lo select.lo \
+@USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo socket.lo sleep.lo stack.lo \
+@USE_LIBTOOL_TRUE@sysconf.lo systat.lo termios.lo time.lo usleep.lo \
+@USE_LIBTOOL_TRUE@wait.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
diff --git a/newlib/libc/sys/linux/pread64.c b/newlib/libc/sys/linux/pread64.c
new file mode 100644
index 000000000..c6d15f91d
--- /dev/null
+++ b/newlib/libc/sys/linux/pread64.c
@@ -0,0 +1,62 @@
+/*
+FUNCTION
+<<pread64>>---read a large file from specified position
+
+INDEX
+ pread64
+
+ANSI_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pread64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>);
+
+TRAD_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pread64(<[fd]>, <[buf]>, <[n]>, <[off]>)
+ int <[fd]>;
+ void *<[buf]>;
+ size_t <[n]>;
+ loff_t <[off]>;
+
+DESCRIPTION
+The <<pread64>> function is similar to <<pread>>. The only difference is
+that it operates on large files and so takes a 64-bit offset. Like <<pread>>>,
+the file position is unchanged by the function (i.e. the file position
+is the same before and after a call to <<pread>>).
+
+RETURNS
+<<pread64>> returns the number of bytes read or <<-1>> if failure occurred.
+
+PORTABILITY
+<<pread64>> is an EL/IX extension.
+
+Supporting OS subroutine required: <<read64>>, <<lseek64>>.
+*/
+
+#include <_ansi.h>
+#include <unistd.h>
+#include <reent.h>
+
+ssize_t
+_DEFUN (pread64, (fd, buf, n, off),
+ int fd _AND
+ _PTR buf _AND
+ size_t n _AND
+ loff_t off)
+{
+ loff_t cur_pos;
+ _READ_WRITE_RETURN_TYPE num_read;
+
+ if ((cur_pos = lseek64 (fd, 0, SEEK_CUR)) == (loff_t)-1)
+ return -1;
+
+ if (lseek64 (fd, off, SEEK_SET) == (loff_t)-1)
+ return -1;
+
+ num_read = read64 (fd, buf, n);
+
+ if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1)
+ return -1;
+
+ return (ssize_t)num_read;
+}
+
diff --git a/newlib/libc/sys/linux/pwrite64.c b/newlib/libc/sys/linux/pwrite64.c
new file mode 100644
index 000000000..fddd6d2da
--- /dev/null
+++ b/newlib/libc/sys/linux/pwrite64.c
@@ -0,0 +1,62 @@
+/*
+FUNCTION
+<<pwrite64>>---write a large file from specified position
+
+INDEX
+ pwrite64
+
+ANSI_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pwrite64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>);
+
+TRAD_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pwrite64(<[fd]>, <[buf]>, <[n]>, <[off]>)
+ int <[fd]>;
+ void *<[buf]>;
+ size_t <[n]>;
+ loff_t <[off]>;
+
+DESCRIPTION
+The <<pwrite64>> function is similar to <<pwrite>>. The only difference is
+that it operates on large files and so takes a 64-bit offset. Like <<pwrite>>>,
+the file position is unchanged by the function (i.e. the file position
+is the same before and after a call to <<pwrite>>).
+
+RETURNS
+<<pwrite64>> returns the number of bytes written or <<-1>> if failure occurred.
+
+PORTABILITY
+<<pwrite64>> is an EL/IX extension.
+
+Supporting OS subroutine required: <<write64>>, <<lseek64>>.
+*/
+
+#include <_ansi.h>
+#include <unistd.h>
+#include <reent.h>
+
+ssize_t
+_DEFUN (pwrite64, (fd, buf, n, off),
+ int fd _AND
+ _PTR buf _AND
+ size_t n _AND
+ loff_t off)
+{
+ loff_t cur_pos;
+ _READ_WRITE_RETURN_TYPE num_written;
+
+ if ((cur_pos = lseek64 (fd, 0, SEEK_CUR)) == (loff_t)-1)
+ return -1;
+
+ if (lseek64 (fd, off, SEEK_SET) == (loff_t)-1)
+ return -1;
+
+ num_written = write64 (fd, buf, n);
+
+ if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1)
+ return -1;
+
+ return (ssize_t)num_written;
+}
+
diff --git a/newlib/libc/unix/Makefile.am b/newlib/libc/unix/Makefile.am
index 5159c0ed0..83fd26254 100644
--- a/newlib/libc/unix/Makefile.am
+++ b/newlib/libc/unix/Makefile.am
@@ -5,7 +5,8 @@ AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
LIB_SOURCES = \
- getpass.c sigset.c getpwent.c ttyname.c getut.c getlogin.c getcwd.c
+ getcwd.c getlogin.c getpass.c getpwent.c getut.c \
+ pread.c pwrite.c sigset.c ttyname.c
libunix_la_LDFLAGS = -Xcompiler -nostdlib
diff --git a/newlib/libc/unix/Makefile.in b/newlib/libc/unix/Makefile.in
index 72ddaf49b..d1de62e59 100644
--- a/newlib/libc/unix/Makefile.in
+++ b/newlib/libc/unix/Makefile.in
@@ -100,7 +100,8 @@ AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
LIB_SOURCES = \
- getpass.c sigset.c getpwent.c ttyname.c getut.c getlogin.c getcwd.c
+ getcwd.c getlogin.c getpass.c getpwent.c getut.c \
+ pread.c pwrite.c sigset.c ttyname.c
libunix_la_LDFLAGS = -Xcompiler -nostdlib
@@ -130,13 +131,15 @@ DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
lib_a_LIBADD =
-@USE_LIBTOOL_FALSE@lib_a_OBJECTS = getpass.o sigset.o getpwent.o \
-@USE_LIBTOOL_FALSE@ttyname.o getut.o getlogin.o getcwd.o
+@USE_LIBTOOL_FALSE@lib_a_OBJECTS = getcwd.o getlogin.o getpass.o \
+@USE_LIBTOOL_FALSE@getpwent.o getut.o pread.o pwrite.o sigset.o \
+@USE_LIBTOOL_FALSE@ttyname.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
libunix_la_LIBADD =
-@USE_LIBTOOL_TRUE@libunix_la_OBJECTS = getpass.lo sigset.lo getpwent.lo \
-@USE_LIBTOOL_TRUE@ttyname.lo getut.lo getlogin.lo getcwd.lo
+@USE_LIBTOOL_TRUE@libunix_la_OBJECTS = getcwd.lo getlogin.lo getpass.lo \
+@USE_LIBTOOL_TRUE@getpwent.lo getut.lo pread.lo pwrite.lo sigset.lo \
+@USE_LIBTOOL_TRUE@ttyname.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
diff --git a/newlib/libc/unix/pread.c b/newlib/libc/unix/pread.c
new file mode 100644
index 000000000..68ed68eb1
--- /dev/null
+++ b/newlib/libc/unix/pread.c
@@ -0,0 +1,91 @@
+/*
+FUNCTION
+<<pread>>---read a file from specified position
+
+INDEX
+ pread
+INDEX
+ _pread_r
+
+ANSI_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pread(int <[fd]>, void *<[buf]>, size_t <[n]>, off_t <[off]>);
+ ssize_t _pread_r(struct _reent *<[rptr]>, int <[fd]>,
+ void *<[buf]>, size_t <[n]>, off_t <[off]>);
+
+TRAD_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pread(<[fd]>, <[buf]>, <[n]>, <[off]>)
+ int <[fd]>;
+ void *<[buf]>;
+ size_t <[n]>;
+ off_t <[off]>;
+
+ ssize_t _pread_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>)
+ struct _reent *<[rptr]>;
+ int <[fd]>;
+ void *<[buf]>;
+ size_t <[n]>;
+ off_t <[off]>;
+
+DESCRIPTION
+The <<pread>> function is similar to <<read>>. One difference is that
+<<pread>> has an additional parameter <[off]> which is the offset to
+position in the file before reading. The function also differs in that
+the file position is unchanged by the function (i.e. the file position
+is the same before and after a call to <<pread>>).
+
+The <<_pread_r>> function is the same as <<pread>>, only a reentrant
+struct pointer <[rptr]> is provided to preserve reentrancy.
+
+RETURNS
+<<pread>> returns the number of bytes read or <<-1>> if failure occurred.
+
+PORTABILITY
+<<pread>> is non-ANSI and is specified by the Single Unix Specification.
+
+Supporting OS subroutine required: <<read>>, <<lseek>>.
+*/
+
+#include <_ansi.h>
+#include <unistd.h>
+#include <reent.h>
+
+ssize_t
+_DEFUN (pread_r, (rptr, fd, buf, n, off),
+ struct _reent *rptr _AND
+ int fd _AND
+ _PTR buf _AND
+ size_t n _AND
+ off_t off)
+{
+ off_t cur_pos;
+ _READ_WRITE_RETURN_TYPE num_read;
+
+ if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1)
+ return -1;
+
+ if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1)
+ return -1;
+
+ num_read = _read_r (rptr, fd, buf, n);
+
+ if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
+ return -1;
+
+ return (ssize_t)num_read;
+}
+
+#ifndef _REENT_ONLY
+
+ssize_t
+_DEFUN (pread, (fd, buf, n, off),
+ int fd _AND
+ _PTR buf _AND
+ size_t n _AND
+ off_t off)
+{
+ return _pread_r (_REENT, fd, buf, n, off);
+}
+
+#endif
diff --git a/newlib/libc/unix/pwrite.c b/newlib/libc/unix/pwrite.c
new file mode 100644
index 000000000..2d672bfbe
--- /dev/null
+++ b/newlib/libc/unix/pwrite.c
@@ -0,0 +1,92 @@
+/*
+FUNCTION
+<<pwrite>>---write a file from specified position
+
+INDEX
+ pwrite
+INDEX
+ _pwrite_r
+
+ANSI_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pwrite(int <[fd]>, const void *<[buf]>,
+ size_t <[n]>, off_t <[off]>);
+ ssize_t _pwrite_r(struct _reent *<[rptr]>, int <[fd]>,
+ const void *<[buf]>, size_t <[n]>, off_t <[off]>);
+
+TRAD_SYNOPSIS
+ #include <unistd.h>
+ ssize_t pwrite(<[fd]>, <[buf]>, <[n]>, <[off]>)
+ int <[fd]>;
+ const void *<[buf]>;
+ size_t <[n]>;
+ off_t <[off]>;
+
+ ssize_t _pwrite_r(<[rptr]>, <[fd]>, <[buf]>, <[n]>, <[off]>)
+ struct _reent *<[rptr]>;
+ int <[fd]>;
+ const void *<[buf]>;
+ size_t <[n]>;
+ off_t <[off]>;
+
+DESCRIPTION
+The <<pwrite>> function is similar to <<write>>. One difference is that
+<<pwrite>> has an additional parameter <[off]> which is the offset to
+position in the file before writing. The function also differs in that
+the file position is unchanged by the function (i.e. the file position
+is the same before and after a call to <<pwrite>>).
+
+The <<_pwrite_r>> function is the same as <<pwrite>>, only a reentrant
+struct pointer <[rptr]> is provided to preserve reentrancy.
+
+RETURNS
+<<pwrite>> returns the number of bytes written or <<-1>> if failure occurred.
+
+PORTABILITY
+<<pwrite>> is non-ANSI and is specified by the Single Unix Specification.
+
+Supporting OS subroutine required: <<write>>, <<lseek>>.
+*/
+
+#include <_ansi.h>
+#include <unistd.h>
+#include <reent.h>
+
+ssize_t
+_DEFUN (pwrite_r, (rptr, fd, buf, n, off),
+ struct _reent *rptr _AND
+ int fd _AND
+ _CONST _PTR buf _AND
+ size_t n _AND
+ off_t off)
+{
+ off_t cur_pos;
+ _READ_WRITE_RETURN_TYPE num_written;
+
+ if ((cur_pos = _lseek_r (rptr, fd, 0, SEEK_CUR)) == (off_t)-1)
+ return -1;
+
+ if (_lseek_r (rptr, fd, off, SEEK_SET) == (off_t)-1)
+ return -1;
+
+ num_written = _write_r (rptr, fd, buf, n);
+
+ if (_lseek_r (rptr, fd, cur_pos, SEEK_SET) == (off_t)-1)
+ return -1;
+
+ return (ssize_t)num_written;
+}
+
+#ifndef _REENT_ONLY
+
+ssize_t
+_DEFUN (pwrite, (fd, buf, n, off),
+ int fd _AND
+ _CONST _PTR buf _AND
+ size_t n _AND
+ off_t off)
+{
+ return _pwrite_r (_REENT, fd, buf, n, off);
+}
+
+#endif