Update.
[glibc.git] / db2 / os / db_os_lseek.c
blobcecf0e156be0626d3aaf9d1c3576e49bb0278630
1 /*-
2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997
5 * Sleepycat Software. All rights reserved.
6 */
8 #include "config.h"
10 #ifndef lint
11 static const char sccsid[] = "@(#)db_os_lseek.c 10.3 (Sleepycat) 6/28/97";
12 #endif /* not lint */
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #endif
21 #include "db_int.h"
22 #include "os_ext.h"
25 * __db_lseek --
26 * Seek to a page/byte offset in the file.
28 * PUBLIC: int __db_lseek __P((int, size_t, db_pgno_t, u_long, int));
30 int
31 __db_lseek(fd, pgsize, pageno, relative, whence)
32 int fd;
33 size_t pgsize;
34 db_pgno_t pageno;
35 u_long relative;
36 int whence;
38 /* 64-bit offsets are done differently by different vendors. */
39 #undef __LSEEK_SET
40 #ifdef HAVE_LLSEEK
41 #define __LSEEK_SET
42 offset_t offset; /* Solaris. */
44 offset = pgsize * pageno + relative;
45 return (llseek(fd, offset, whence) == -1 ? errno : 0);
46 #endif
47 #ifdef HAVE_LSEEKI
48 #define __LSEEK_SET
49 __int64 offset; /* WNT */
51 offset = pgsize * pageno + relative;
52 return (_lseeki64(fd, offset, whence) == -1 ? errno : 0);
53 #endif
54 #ifndef __LSEEK_SET
55 off_t offset; /* Default. */
57 offset = pgsize * pageno + relative;
58 return (lseek(fd, offset, whence) == -1 ? errno : 0);
59 #endif