headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / unistd / read.c
blob82ea0e091a39f413f6349d096f6afb096b6d046a
1 /*
2 * Copyright 2001, Manuel J. Petit. All rights reserved.
3 * Distributed under the terms of the NewOS License.
4 */
6 /*
7 * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
8 * Distributed under the terms of the MIT License.
9 */
12 #include <unistd.h>
14 #include <errno.h>
15 #include <pthread.h>
17 #include <syscall_utils.h>
19 #include <errno_private.h>
20 #include <syscalls.h>
23 ssize_t
24 read(int fd, void* buffer, size_t bufferSize)
26 ssize_t status = _kern_read(fd, -1, buffer, bufferSize);
28 RETURN_AND_SET_ERRNO_TEST_CANCEL(status);
32 ssize_t
33 read_pos(int fd, off_t pos, void* buffer, size_t bufferSize)
35 if (pos < 0)
36 RETURN_AND_SET_ERRNO_TEST_CANCEL(B_BAD_VALUE);
38 RETURN_AND_SET_ERRNO_TEST_CANCEL(_kern_read(fd, pos, buffer, bufferSize));
42 ssize_t
43 pread(int fd, void* buffer, size_t bufferSize, off_t pos)
45 if (pos < 0)
46 RETURN_AND_SET_ERRNO_TEST_CANCEL(B_BAD_VALUE);
48 RETURN_AND_SET_ERRNO_TEST_CANCEL(_kern_read(fd, pos, buffer, bufferSize));