diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-11-12 00:06:02 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-11-12 00:06:02 +0000 |
commit | cc3fa755128c70f8afc2d604936f33e4d7d652d8 (patch) | |
tree | 0c68c1298140e1524078e8bfdf5154fb6129b680 /db2/os | |
parent | 86187531d302de284b67ac162cf76c60c86bd7da (diff) | |
download | glibc-cc3fa755128c70f8afc2d604936f33e4d7d652d8.zip glibc-cc3fa755128c70f8afc2d604936f33e4d7d652d8.tar.gz glibc-cc3fa755128c70f8afc2d604936f33e4d7d652d8.tar.bz2 |
Update.cvs/libc-ud-971111
1997-11-11 21:30 Ulrich Drepper <drepper@cygnus.com>
* include/sys/stat.h: Define stat, fstat, lstat and *64 variants
as macros so the the library compiles correctly even without
optimization.
* io/fstat.c: Undef fstat.
* io/fstat64.c: Undef fstat64
* io/lstat.c: Undef lstat.
* io/lstat64.c: Undef lstat64
* io/stat.c: Undef stat.
* io/stat64.c: Undef stat64
* io/fts.c: Include <include/sys/stat.h> to get macro definitions.
* io/ftw.c: Likewise.
* io/getdirname.c: Likewise.
* Makefile (install): Run test-installation.pl if possible.
* db2/Makefile: Update from db-2.3.12.
* db2/db.h: Likewise.
* db2/db_int.h: Likewise.
* db2/btree/bt_cursor.c: Likewise.
* db2/btree/bt_delete.c: Likewise.
* db2/btree/bt_open.c: Likewise.
* db2/btree/bt_put.c: Likewise.
* db2/btree/bt_rec.c: Likewise.
* db2/btree/bt_recno.c: Likewise.
* db2/btree/bt_search.c: Likewise.
* db2/btree/bt_split.c: Likewise.
* db2/btree/bt_stat.c: Likewise.
* db2/btree/btree.src: Likewise.
* db2/btree/btree_auto.c: Likewise.
* db2/btree/bt_cursor.c: Likewise.
* db2/btree/bt_delete.c: Likewise.
* db2/btree/bt_open.c: Likewise.
* db2/btree/bt_put.c: Likewise.
* db2/btree/bt_rec.c: Likewise.
* db2/btree/bt_recno.c: Likewise.
* db2/btree/bt_search.c: Likewise.
* db2/btree/bt_split.c: Likewise.
* db2/btree/bt_stat.c: Likewise.
* db2/btree/btree.src: Likewise.
* db2/btree/btree_auto.c: Likewise.
* db2/common/db_appinit.c: Likewise.
* db2/common/db_apprec.c: Likewise.
* db2/common/db_byteorder.c: Likewise.
* db2/common/db_region.c: Likewise.
* db2/db/db.c: Likewise
* db2/db/db.src: Likewise
* db2/db/db_auto.c: Likewise
* db2/db/db_dispatch.c: Likewise
* db2/db/db_dup.c: Likewise
* db2/db/db_overflow.c: Likewise
* db2/db/db_pr.c: Likewise
* db2/db/db_rec.c: Likewise
* db2/db/db_ret.c: Likewise
* db2/db/db_thread.c: Likewise
* db2/db185/db185.c: Likewise.
* db2/hash/hash.c: Likewise.
* db2/hash/hash.src: Likewise.
* db2/hash/hash_auto.c: Likewise.
* db2/hash/hash_dup.c: Likewise.
* db2/hash/hash_page.c: Likewise.
* db2/hash/hash_rec.c: Likewise.
* db2/include/btree_auto.h: Likewise.
* db2/include/btree_ext.h: Likewise.
* db2/include/clib_ext.h: Likewise.
* db2/include/common_ext.h: Likewise.
* db2/include/db.h.src: Likewise.
* db2/include/db_am.h: Likewise.
* db2/include/db_auto.h: Likewise.
* db2/include/db_cxx.h: Likewise.
* db2/include/db_ext.h: Likewise.
* db2/include/db_int.h.src: Likewise.
* db2/include/hash.h: Likewise.
* db2/include/hash_auto.h: Likewise.
* db2/include/hash_ext.h: Likewise.
* db2/include/lock.h: Likewise.
* db2/include/lock_ext.h: Likewise.
* db2/include/log.h: Likewise.
* db2/include/log_ext.h: Likewise.
* db2/include/mp.h: Likewise.
* db2/include/mp_ext.h: Likewise.
* db2/include/mutex_ext.h: Likewise.
* db2/include/os_ext.h: Likewise.
* db2/include/os_func.h: Likewise.
* db2/include/txn.h: Likewise.
* db2/include/txn_ext.h: Likewise.
* db2/lock/lock.c: Likewise.
* db2/lock/lock_deadlock.c: Likewise.
* db2/log/log.c: Likewise.
* db2/log/log_archive.c: Likewise.
* db2/log/log_auto.c: Likewise.
* db2/log/log_findckp.c: Likewise.
* db2/log/log_get.c: Likewise.
* db2/log/log_put.c: Likewise.
* db2/log/log_rec.c: Likewise.
* db2/log/log_register.c: Likewise.
* db2/mp/mp_bh.c: Likewise.
* db2/mp/mp_fget.c: Likewise.
* db2/mp/mp_fopen.c: Likewise.
* db2/mp/mp_fput.c: Likewise.
* db2/mp/mp_fset.c: Likewise.
* db2/mp/mp_open.c: Likewise.
* db2/mp/mp_pr.c: Likewise.
* db2/mp/mp_region.c: Likewise.
* db2/mp/mp_sync.c: Likewise.
* db2/mutex/mutex.c: Likewise.
* db2/os/os_abs.c: Likewise.
* db2/os/os_dir.c: Likewise.
* db2/os/os_fid.c: Likewise.
* db2/os/os_fsync.c: Likewise.
* db2/os/os_func.c: Likewise.
* db2/os/os_map.c: Likewise.
* db2/os/os_oflags.c: Likewise.
* db2/os/os_open.c: Likewise.
* db2/os/os_rpath.c: Likewise.
* db2/os/os_rw.c: Likewise.
* db2/os/os_seek.c: Likewise.
* db2/os/os_sleep.c: Likewise.
* db2/os/os_stat.c: Likewise.
* db2/os/os_unlink.c: Likewise.
* db2/progs/db_deadlock/db_deadlock.c: Likewise.
* db2/progs/db_dump/db_dump.c: Likewise.
* db2/progs/db_load/db_load.c: Likewise.
* db2/progs/db_recover/db_recover.c: Likewise.
* db2/progs/db_stat/db_stat.c: Likewise.
* db2/txn/txn.c: Likewise.
* db2/txn/txn_auto.c: Likewise.
* db2/txn/txn_rec.c: Likewise.
* db2/os/db_os_abs.c: Removed.
* db2/os/db_os_dir.c: Removed.
* db2/os/db_os_fid.c: Removed.
* db2/os/db_os_lseek.c: Removed.
* db2/os/db_os_mmap.c: Removed.
* db2/os/db_os_open.c: Removed.
* db2/os/db_os_rw.c: Removed.
* db2/os/db_os_sleep.c: Removed.
* db2/os/db_os_stat.c: Removed.
* db2/os/db_os_unlink.c: Removed.
* libio/stdio.h (fopen): Add __restrict to parameters.
* manual/process.texi (system): Describe behaviour for NULL argument.
* stdio-common/printf-parse.h: Parse hh modifier.
* stdio-common/vfprintf.c: Handle hh modifier.
* stdio-common/vfscanf.c: Likewise.
* manual/stdio.texi: Describe hh modifier for scanf/printf.
* math/complex.h: Don't define _Imaginary_I, but instead _Complex_I.
gcc does no yet know the `imaginary' keyword.
* math/test-math.c: Add little test for know gcc bug.
* math/tgmath.h: Make complex versions of log10() only available
if __USE_GNU.
* stdlib/test-canon.c: Fix typo.
* sysdeps/generic/setenv.c: Avoid compilation warnings.
Reported by Jim Meyering.
* sysdeps/generic/bits/errno.h: EILSEQ is an ISO C error number.
* sysdeps/mach/hurd/bits/errno.h: Likewise.
* sysdeps/standalone/bits/errno.h: Likewise.
* sysdeps/unix/sysv/linux/bits/errno.h: Likewise.
* sysdeps/i386/i586/memcpy.S: New file.
* sysdeps/i386/i586/mempcpy.S: New file.
* sysdeps/i386/i586/memset.S: Fix typo.
* sysdeps/posix/getcwd.c: Define HAVE_MEMPCPY for _LIBC. Add casts.
* sysdeps/posix/system.c: Add comment to explain code.
* sysdeps/wordsize-32/inttypes.h: Include <stddef.h> for wchar_t.
Define PTRDIFF_{MIN,MAX}, SIG_ATOMIC_{MIN,MAX}, SIZE_MAX,
WCHAR_{MIN,MAX}, WINT_{MIN,MAX}.
Define wcstoimax, wcstoumax.
* sysdeps/wordsize-64/inttypes.h: Likewise.
* wcsmbs/wchar.h: Define WCHAR_{MIN,MAX} if not already defined.
Declare __wcsto{l,ul,ll,ull}_internal only if not already done.
* time/Makefile (routines): Add strfxtime.
* time/strftime.c: Implement %F and %f format.
* time/strfxtime.c: New file.
* time/time.h: Define new types and symbols from ISO C 9X.
* time/mktime.c: Little comment correction.
1997-11-10 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/libm-ieee754/s_sincosl.c: Fix typo.
* sysdeps/libm-ieee754/s_tanl.c: Fix typo.
* sysdeps/libm-ieee754/s_floorl.c: Correct typos.
* sysdeps/libm-ieee754/e_remainderl.c: Replace
EXTRACT_LDOUBLE_WORDS by GET_LDOUBLE_WORDS.
* sysdeps/libm-ieee754/e_atan2l.c: Replace EXTRACT_LDOUBLE_WORDS
by GET_LDOUBLE_WORDS.
* sysdeps/libm-ieee754/s_scalbnl.c: Replace ";" by "," for correct
variable declaration.
* sysdeps/libm-ieee754/s_scalblnl.c: Likewise.
* sysdeps/libm-ieee754/s_lrint.c (__lrint): Correct function.
* math/libm-test.c (sqrt_test): Add test for sqrt (0.25).
(asin_test): Add more test.
1997-11-10 23:34 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/libm-ieee754/e_asin.c: Add braces to make code clearer
and to not confuse the poor compiler.
* sysdeps/libm-ieee754/e_asinf.c: Likewise.
Reported by vertex@cagent.com.
1997-11-09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* elf/dl-lookup.c (do_lookup): Don't accept the base version if we
require a specific one.
* libio/oldfreopen.c: Bind old symbols to version GLIBC_2.0.
* libio/oldiofopen.c: Likewise.
* libio/oldstdfiles.c: Likewise.
* libc.map: Export them.
1997-11-10 07:40 H.J. Lu <hjl@gnu.ai.mit.edu>
* stdlib/exit.c (exit): Handle recursive calls to exit ().
1997-11-09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/m68k/fpu/s_llrint.c: Fixed to take double argument
instead of long double.
* sysdeps/m68k/fpu/s_llrintf.c: New file.
* sysdeps/m68k/fpu/s_llrintl.c: New file.
* sysdeps/libm-ieee754/s_llrint.c: Make compilable and fix
overflow condition.
* sysdeps/libm-ieee754/s_llrintf.c: Fix overflow condition.
* sysdeps/libm-ieee754/s_llrintl.c: Likewise.
* sysdeps/libm-ieee754/s_llround.c: Likewise.
* sysdeps/libm-ieee754/s_llroundf.c: Likewise.
* sysdeps/libm-ieee754/s_llroundl.c: Likewise.
* sysdeps/libm-ieee754/s_lrint.c: Likewise.
* sysdeps/libm-ieee754/s_lrintf.c: Likewise.
* sysdeps/libm-ieee754/s_lrintl.c: Likewise.
* sysdeps/libm-ieee754/s_lround.c: Likewise.
* sysdeps/libm-ieee754/s_lroundf.c: Likewise.
* sysdeps/libm-ieee754/s_lroundl.c: Likewise.
* math/libm-test.c: Test all three variants of lrint and llrint.
Fix typos in lround and llround tests. Add tests for boundary
cases for lrint and llround.
1997-11-08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/arith.texi: Misc doc fixes.
* manual/ctype.texi: Likewise.
* manual/pattern.texi: Likewise.
* manual/terminal.texi: Likewise.
1997-11-08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/xstatconv.c: Use struct assignment
instead of memcpy to let the compiler use whatever it regards as
optimal.
* sysdeps/unix/sysv/linux/alpha/xstatconv.c: Likewise.
1997-11-08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers)
[$(subdir)=misc]: Add sys/prctl.h.
* sysdeps/unix/sysv/linux/Dist: Distribute it.
1997-11-08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* io/ftwtest-sh: Don't use the unknown which command, instead try
pwd as /bin/pwd and /usr/bin/pwd.
1997-11-08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* manual/maint.texi (Tools for Installation): Don't recommend
broken version 3.76.1 of make.
(Porting): Fix wording.
1997-11-06 06:13 H.J. Lu <hjl@gnu.ai.mit.edu>
* config.make.in (build-pic-default): New, defined with
pic_default.
* configure.in (pic_default): New, set to yes if PIC is
default.
* Makeconfig (CPPFLAGS-.o, CPPFLAGS-.op, CPPFLAGS-.og,
CPPFLAGS-.ob): Add -DPIC if $(build-pic-default) is yes.
1997-11-09 18:15 Ulrich Drepper <drepper@cygnus.com>
* Makerules (libc.so): Fix typo.
* csu/Makefile (CFLAGS-initfini.s): Correctly fix moving function
definition. Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.
* stdlib/strtod.c: Handle numbers like 0.0e10000 correctly which
produce ±0.0. Reported by Joe Keane <jgk@jgk.org>.
* sysdeps/libm-ieee754/s_ceill.c: Fix typos.
* sysdeps/libm-ieee754/s_llrint.c: Correct code, it never worked.
1997-11-06 07:00 H.J. Lu <hjl@gnu.ai.mit.edu>
* sysdeps/unix/sysv/i386/i686/time.S: Removed.
1997-11-08 14:07 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/libnsl.map: Add __do_niscall2 for nis_cachemgr.
* nis/nis_call.c: Set UDP resend timeout correct.
* nis/nss_compat/compat-grp.c: Rewritten to make it faster.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/compat-spwd.c: Likewise.
* nis/ypclnt.c: Fix UDP resend timeout, fix yp_bind/do_ypcall
interaction.
* inet/protocols/routed.h: Include sys/socket.h.
* inet/protocols/talkd.h: Likewise.
* inet/protocols/timed.h: Include rpc/types.h.
* sunrpc/rpc/pmap_clnt.h: Include rpc/clnt.h.
1997-11-06 01:39 Ulrich Drepper <drepper@cygnus.com>
* Makerules (libc.so): Add missing closing brace.
1997-11-05 Brendan Kehoe <brendan@lisa.cygnus.com>
* libio.h (__P): Name its arg `p' instead of `params'.
This was added solely to work around problems with
the definition of __P in the Solaris math.h header.
Diffstat (limited to 'db2/os')
-rw-r--r-- | db2/os/db_os_abs.c | 82 | ||||
-rw-r--r-- | db2/os/db_os_dir.c | 138 | ||||
-rw-r--r-- | db2/os/db_os_lseek.c | 60 | ||||
-rw-r--r-- | db2/os/db_os_mmap.c | 106 | ||||
-rw-r--r-- | db2/os/os_abs.c | 31 | ||||
-rw-r--r-- | db2/os/os_dir.c | 100 | ||||
-rw-r--r-- | db2/os/os_fid.c (renamed from db2/os/db_os_fid.c) | 55 | ||||
-rw-r--r-- | db2/os/os_fsync.c | 34 | ||||
-rw-r--r-- | db2/os/os_func.c | 153 | ||||
-rw-r--r-- | db2/os/os_map.c | 71 | ||||
-rw-r--r-- | db2/os/os_oflags.c | 48 | ||||
-rw-r--r-- | db2/os/os_open.c (renamed from db2/os/db_os_open.c) | 58 | ||||
-rw-r--r-- | db2/os/os_rpath.c | 42 | ||||
-rw-r--r-- | db2/os/os_rw.c (renamed from db2/os/db_os_rw.c) | 7 | ||||
-rw-r--r-- | db2/os/os_seek.c | 42 | ||||
-rw-r--r-- | db2/os/os_sleep.c (renamed from db2/os/db_os_sleep.c) | 16 | ||||
-rw-r--r-- | db2/os/os_stat.c (renamed from db2/os/db_os_stat.c) | 20 | ||||
-rw-r--r-- | db2/os/os_unlink.c (renamed from db2/os/db_os_unlink.c) | 5 |
18 files changed, 549 insertions, 519 deletions
diff --git a/db2/os/db_os_abs.c b/db2/os/db_os_abs.c deleted file mode 100644 index 8795205..0000000 --- a/db2/os/db_os_abs.c +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1997 - * Sleepycat Software. All rights reserved. - */ - -#include "config.h" - -#ifndef lint -static const char sccsid[] = "@(#)db_os_abs.c 10.5 (Sleepycat) 7/5/97"; -#endif /* not lint */ - -#ifndef NO_SYSTEM_INCLUDES -#include <string.h> -#endif - -#include "db_int.h" -#include "os_ext.h" - -/* - * __db_abspath -- - * Return if a path is an absolute path. - * - * PUBLIC: int __db_abspath __P((const char *)); - */ -int -__db_abspath(path) - const char *path; -{ -#ifdef _WIN32 - /* - * !!! - * Check for drive specifications, e.g., "C:". In addition, the path - * separator used by the win32 DB (PATH_SEPARATOR) is \; look for both - * / and \ since these are user-input paths. - */ - if (isalpha(path[0]) && path[1] == ':') - path += 2; - return (path[0] == '/' || path[0] == '\\'); -#else -#ifdef macintosh - /* - * !!! - * Absolute pathnames always start with a volume name, which must be - * followed by a colon, thus they are of the form: - * volume: or volume:dir1:dir2:file - * - * Relative pathnames are either a single name without colons or a - * path starting with a colon, thus of the form: - * file or :file or :dir1:dir2:file - */ - return (strchr(path, ':') != NULL && path[0] != ':'); -#else - return (path[0] == '/'); -#endif -#endif -} - -/* - * __db_rpath -- - * Return the last path separator in the path or NULL if none found. - * - * PUBLIC: char *__db_rpath __P((const char *)); - */ -char * -__db_rpath(path) - const char *path; -{ - const char *s, *last; - - last = NULL; - if (PATH_SEPARATOR[1] != '\0') { - for (s = path; s[0] != '\0'; ++s) - if (strchr(PATH_SEPARATOR, s[0]) != NULL) - last = s; - } else - for (s = path; s[0] != '\0'; ++s) - if (s[0] == PATH_SEPARATOR[0]) - last = s; - return ((char *)last); -} diff --git a/db2/os/db_os_dir.c b/db2/os/db_os_dir.c deleted file mode 100644 index 1206e3f..0000000 --- a/db2/os/db_os_dir.c +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1997 - * Sleepycat Software. All rights reserved. - */ - -#include "config.h" - -#ifndef lint -static const char sccsid[] = "@(#)db_os_dir.c 10.10 (Sleepycat) 9/17/97"; -#endif /* not lint */ - -#ifndef NO_SYSTEM_INCLUDES -#include <sys/types.h> - -#if HAVE_DIRENT_H -# include <dirent.h> -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -# define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen -# if HAVE_SYS_NDIR_H -# include <sys/ndir.h> -# endif -# if HAVE_SYS_DIR_H -# include <sys/dir.h> -# endif -# if HAVE_NDIR_H -# include <ndir.h> -# endif -#endif - -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#endif - -#include "db_int.h" -#include "os_ext.h" -#include "common_ext.h" - -/* - * __db_dir -- - * Return a list of the files in a directory. - * - * PUBLIC: int __db_dir __P((DB_ENV *, const char *, char ***, int *)); - */ -int -__db_dir(dbenv, dir, namesp, cntp) - DB_ENV *dbenv; - const char *dir; - char ***namesp; - int *cntp; -{ - int arraysz, cnt; - char **names; -#ifdef _WIN32 - struct _finddata_t fdata; - long dirhandle; - int finished; - char filespec[MAX_PATH]; - - (void)snprintf(filespec, sizeof(filespec), "%s/*", dir); - if ((dirhandle = _findfirst(filespec, &fdata)) == -1) { - __db_err(dbenv, "%s: %s", filespec, strerror(errno)); - return (errno); - } - - names = NULL; - finished = 0; - for (arraysz = cnt = 0; finished != 1; ++cnt) { - if (cnt >= arraysz) { - arraysz += 100; - names = (char **)(names == NULL ? - malloc(arraysz * sizeof(names[0])) : - realloc(names, arraysz * sizeof(names[0]))); - if (names == NULL) - goto nomem; - } - if ((names[cnt] = (char *)strdup(fdata.name)) == NULL) - goto nomem; - if (_findnext(dirhandle,&fdata) != 0) - finished = 1; - } - _findclose(dirhandle); -#else /* !_WIN32 */ - struct dirent *dp; - DIR *dirp; - - if ((dirp = opendir(dir)) == NULL) { - __db_err(dbenv, "%s: %s", dir, strerror(errno)); - return (errno); - } - names = NULL; - for (arraysz = cnt = 0; (dp = readdir(dirp)) != NULL; ++cnt) { - if (cnt >= arraysz) { - arraysz += 100; - names = (char **)(names == NULL ? - malloc(arraysz * sizeof(names[0])) : - realloc(names, arraysz * sizeof(names[0]))); - if (names == NULL) - goto nomem; - } - if ((names[cnt] = (char *)strdup(dp->d_name)) == NULL) - goto nomem; - } - (void)closedir(dirp); -#endif /* !_WIN32 */ - - *namesp = names; - *cntp = cnt; - return (0); - -nomem: if (names != NULL) - __db_dirf(dbenv, names, cnt); - __db_err(dbenv, "%s", strerror(ENOMEM)); - return (ENOMEM); -} - -/* - * __db_dirf -- - * Free the list of files. - * - * PUBLIC: void __db_dirf __P((DB_ENV *, char **, int)); - */ -void -__db_dirf(dbenv, names, cnt) - DB_ENV *dbenv; - char **names; - int cnt; -{ - dbenv = dbenv; /* XXX: Shut the compiler up. */ - while (cnt > 0) - free(names[--cnt]); - free (names); -} diff --git a/db2/os/db_os_lseek.c b/db2/os/db_os_lseek.c deleted file mode 100644 index cecf0e1..0000000 --- a/db2/os/db_os_lseek.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1997 - * Sleepycat Software. All rights reserved. - */ - -#include "config.h" - -#ifndef lint -static const char sccsid[] = "@(#)db_os_lseek.c 10.3 (Sleepycat) 6/28/97"; -#endif /* not lint */ - -#ifndef NO_SYSTEM_INCLUDES -#include <sys/types.h> - -#include <errno.h> -#include <unistd.h> -#endif - -#include "db_int.h" -#include "os_ext.h" - -/* - * __db_lseek -- - * Seek to a page/byte offset in the file. - * - * PUBLIC: int __db_lseek __P((int, size_t, db_pgno_t, u_long, int)); - */ -int -__db_lseek(fd, pgsize, pageno, relative, whence) - int fd; - size_t pgsize; - db_pgno_t pageno; - u_long relative; - int whence; -{ - /* 64-bit offsets are done differently by different vendors. */ -#undef __LSEEK_SET -#ifdef HAVE_LLSEEK -#define __LSEEK_SET - offset_t offset; /* Solaris. */ - - offset = pgsize * pageno + relative; - return (llseek(fd, offset, whence) == -1 ? errno : 0); -#endif -#ifdef HAVE_LSEEKI -#define __LSEEK_SET - __int64 offset; /* WNT */ - - offset = pgsize * pageno + relative; - return (_lseeki64(fd, offset, whence) == -1 ? errno : 0); -#endif -#ifndef __LSEEK_SET - off_t offset; /* Default. */ - - offset = pgsize * pageno + relative; - return (lseek(fd, offset, whence) == -1 ? errno : 0); -#endif -} diff --git a/db2/os/db_os_mmap.c b/db2/os/db_os_mmap.c deleted file mode 100644 index 0cd8fad..0000000 --- a/db2/os/db_os_mmap.c +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1996, 1997 - * Sleepycat Software. All rights reserved. - */ - -#include "config.h" - -#ifndef lint -static const char sccsid[] = "@(#)db_os_mmap.c 10.4 (Sleepycat) 6/28/97"; -#endif /* not lint */ - -#ifndef NO_SYSTEM_INCLUDES -#include <sys/types.h> -#include <sys/mman.h> - -#include <errno.h> -#endif - -#include "db_int.h" -#include "os_ext.h" - -/* - * __db_mmap -- - * Map in some shared memory backed by a file descriptor. - * - * PUBLIC: int __db_mmap __P((int, size_t, int, int, void *)); - */ -int -__db_mmap(fd, len, is_private, rdonly, addr) - int fd, is_private, rdonly; - size_t len; - void *addr; -{ -#ifdef _WIN32 - /* We have not implemented copy-on-write here */ - void * pMemory = 0; - HANDLE hFile = (HANDLE)_get_osfhandle(fd); - HANDLE hMemory = CreateFileMapping( - hFile, - 0, - (rdonly ? PAGE_READONLY : PAGE_READWRITE), - 0, - len, /* This code fails if the library is ever compiled on a 64-bit machine */ - 0 - ); - if (NULL == hMemory) - { - return errno; - } - pMemory = MapViewOfFile( - hMemory, - (rdonly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS), - 0, - 0, - len - ); - CloseHandle(hMemory); - *(void **)addr = pMemory; - return 0; - -#else /* !_WIN32 */ - - void *p; - int flags, prot; - - flags = is_private ? MAP_PRIVATE : MAP_SHARED; -#ifdef MAP_HASSEMAPHORE - flags += MAP_HASSEMAPHORE; -#endif - prot = PROT_READ | (rdonly ? 0 : PROT_WRITE); - -#ifndef MAP_FAILED /* XXX: Mmap(2) failure return. */ -#define MAP_FAILED -1 -#endif - if ((p = - mmap(NULL, len, prot, flags, fd, (off_t)0)) == (void *)MAP_FAILED) - return (errno); - - *(void **)addr = p; - return (0); -#endif /* _WIN32 */ -} - -/* - * __db_unmap -- - * Release the specified shared memory. - * - * PUBLIC: int __db_munmap __P((void *, size_t)); - */ -int -__db_munmap(addr, len) - void *addr; - size_t len; -{ - /* - * !!! - * The argument len is always the same length as was mapped. - */ -#ifdef _WIN32 - return (!UnmapViewOfFile(addr) ? errno : 0); -#else - return (munmap(addr, len) ? errno : 0); -#endif -} diff --git a/db2/os/os_abs.c b/db2/os/os_abs.c new file mode 100644 index 0000000..872e46d --- /dev/null +++ b/db2/os/os_abs.c @@ -0,0 +1,31 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_abs.c 10.7 (Sleepycat) 10/24/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> +#endif + +#include "db_int.h" + +/* + * __db_abspath -- + * Return if a path is an absolute path. + * + * PUBLIC: int __db_abspath __P((const char *)); + */ +int +__db_abspath(path) + const char *path; +{ + return (path[0] == '/'); +} diff --git a/db2/os/os_dir.c b/db2/os/os_dir.c new file mode 100644 index 0000000..10fb8b6 --- /dev/null +++ b/db2/os/os_dir.c @@ -0,0 +1,100 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_dir.c 10.13 (Sleepycat) 10/28/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#if HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# if HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# if HAVE_NDIR_H +# include <ndir.h> +# endif +#endif + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#endif + +#include "db_int.h" +#include "common_ext.h" + +/* + * __os_dirlist -- + * Return a list of the files in a directory. + * + * PUBLIC: int __os_dirlist __P((const char *, char ***, int *)); + */ +int +__os_dirlist(dir, namesp, cntp) + const char *dir; + char ***namesp; + int *cntp; +{ + struct dirent *dp; + DIR *dirp; + int arraysz, cnt; + char **names; + + if ((dirp = opendir(dir)) == NULL) + return (errno); + names = NULL; + for (arraysz = cnt = 0; (dp = readdir(dirp)) != NULL; ++cnt) { + if (cnt >= arraysz) { + arraysz += 100; + names = (char **)(names == NULL ? + __db_malloc(arraysz * sizeof(names[0])) : + __db_realloc(names, arraysz * sizeof(names[0]))); + if (names == NULL) + goto nomem; + } + if ((names[cnt] = (char *)__db_strdup(dp->d_name)) == NULL) + goto nomem; + } + (void)closedir(dirp); + + *namesp = names; + *cntp = cnt; + return (0); + +nomem: if (names != NULL) + __os_dirfree(names, cnt); + return (ENOMEM); +} + +/* + * __os_dirfree -- + * Free the list of files. + * + * PUBLIC: void __os_dirfree __P((char **, int)); + */ +void +__os_dirfree(names, cnt) + char **names; + int cnt; +{ + while (cnt > 0) + __db_free(names[--cnt]); + __db_free(names); +} diff --git a/db2/os/db_os_fid.c b/db2/os/os_fid.c index 960d580..6820b88 100644 --- a/db2/os/db_os_fid.c +++ b/db2/os/os_fid.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_fid.c 10.8 (Sleepycat) 8/27/97"; +static const char sccsid[] = "@(#)os_fid.c 10.9 (Sleepycat) 10/24/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -22,8 +22,6 @@ static const char sccsid[] = "@(#)db_os_fid.c 10.8 (Sleepycat) 8/27/97"; #endif #include "db_int.h" -#include "db_page.h" -#include "os_ext.h" #include "common_ext.h" /* @@ -39,58 +37,11 @@ __db_fileid(dbenv, fname, timestamp, fidp) int timestamp; u_int8_t *fidp; { + struct stat sb; size_t i; time_t now; u_int8_t *p; -#ifdef _WIN32 - /* - * The documentation for GetFileInformationByHandle() states that the - * inode-type numbers are not constant between processes. Actually, - * they are, they're the NTFS MFT indexes. So, this works on NTFS, - * but perhaps not on other platforms, and perhaps not over a network. - * Can't think of a better solution right now. - */ - int fd = 0; - HANDLE fh = 0; - BY_HANDLE_FILE_INFORMATION fi; - BOOL retval = FALSE; - - /* Clear the buffer. */ - memset(fidp, 0, DB_FILE_ID_LEN); - - /* first we open the file, because we're not given a handle to it */ - fd = open(fname,_O_RDONLY,_S_IREAD); - if (-1 == fd) { - /* If we can't open it, we're in trouble */ - return (errno); - } - - /* File open, get its info */ - fh = (HANDLE)_get_osfhandle(fd); - if ((HANDLE)(-1) != fh) { - retval = GetFileInformationByHandle(fh,&fi); - } - close(fd); - - /* - * We want the three 32-bit words which tell us the volume ID and - * the file ID. We make a crude attempt to copy the bytes over to - * the callers buffer. - * - * DBDB: really we should ensure that the bytes get packed the same - * way on all compilers, platforms etc. - */ - if ( ((HANDLE)(-1) != fh) && (TRUE == retval) ) { - memcpy(fidp, &fi.nFileIndexLow, sizeof(u_int32_t)); - fidp += sizeof(u_int32_t); - memcpy(fidp, &fi.nFileIndexHigh, sizeof(u_int32_t)); - fidp += sizeof(u_int32_t); - memcpy(fidp, &fi.dwVolumeSerialNumber, sizeof(u_int32_t)); - } -#else - struct stat sb; - /* Clear the buffer. */ memset(fidp, 0, DB_FILE_ID_LEN); @@ -115,7 +66,7 @@ __db_fileid(dbenv, fname, timestamp, fidp) for (p = (u_int8_t *)&sb.st_dev + sizeof(sb.st_dev), i = 0; i < sizeof(sb.st_dev); ++i) *fidp++ = *--p; -#endif + if (timestamp) { (void)time(&now); for (p = (u_int8_t *)&now + diff --git a/db2/os/os_fsync.c b/db2/os/os_fsync.c new file mode 100644 index 0000000..7b001ce --- /dev/null +++ b/db2/os/os_fsync.c @@ -0,0 +1,34 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_fsync.c 10.3 (Sleepycat) 10/25/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <errno.h> +#include <unistd.h> +#endif + +#include "db_int.h" + +/* + * __db_fsync -- + * Flush a file descriptor. + * + * PUBLIC: int __db_fsync __P((int)); + */ +int +__db_fsync(fd) + int fd; +{ + return (__os_fsync(fd) ? errno : 0); +} diff --git a/db2/os/os_func.c b/db2/os/os_func.c new file mode 100644 index 0000000..afd40f4 --- /dev/null +++ b/db2/os/os_func.c @@ -0,0 +1,153 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_func.c 10.4 (Sleepycat) 10/28/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <errno.h> +#endif + +#include "db_int.h" + +/* + * XXX + * We provide our own extern declarations so that we don't collide with + * systems that get them wrong, e.g., SunOS. + */ +#ifdef _WIN32 +#define fsync _commit +#define imported __declspec(dllimport) +#else +#define imported +#endif + +imported extern void *calloc __P((size_t, size_t)); +imported extern int close __P((int)); +imported extern void free __P((void *)); +imported extern int fsync __P((int)); +imported extern void *malloc __P((size_t)); +imported extern int open __P((const char *, int, ...)); +imported extern ssize_t read __P((int, void *, size_t)); +imported extern char *strdup __P((const char *)); +imported extern void *realloc __P((void *, size_t)); +imported extern int unlink __P((const char *)); +imported extern ssize_t write __P((int, const void *, size_t)); + +/* + * __db_jump -- + * This list of interfaces that applications can replace. In some + * cases, the user is permitted to replace the standard ANSI C or + * POSIX 1003.1 call, e.g., calloc or read. In others, we provide + * a local interface to the functionality, e.g., __os_map. + */ +struct __db_jumptab __db_jump = { + calloc, /* DB_FUNC_CALLOC */ + close, /* DB_FUNC_CLOSE */ + __os_dirfree, /* DB_FUNC_DIRFREE */ + __os_dirlist, /* DB_FUNC_DIRLIST */ + __os_exists, /* DB_FUNC_EXISTS */ + free, /* DB_FUNC_FREE */ + fsync, /* DB_FUNC_FSYNC */ + __os_ioinfo, /* DB_FUNC_IOINFO */ + malloc, /* DB_FUNC_MALLOC */ + __os_map, /* DB_FUNC_MAP */ + open, /* DB_FUNC_OPEN */ + read, /* DB_FUNC_READ */ + realloc, /* DB_FUNC_REALLOC */ + __os_seek, /* DB_FUNC_SEEK */ + __os_sleep, /* DB_FUNC_SLEEP */ + strdup, /* DB_FUNC_STRDUP */ + unlink, /* DB_FUNC_UNLINK */ + __os_unmap, /* DB_FUNC_UNMAP */ + write, /* DB_FUNC_WRITE */ + NULL /* DB_FUNC_YIELD */ +}; + +/* + * db_jump_set -- + * Replace an interface. + */ +int +db_jump_set(func, which) + void *func; + int which; +{ + switch (which) { + case DB_FUNC_CALLOC: + __db_calloc = (void *(*) __P((size_t, size_t)))func; + break; + case DB_FUNC_CLOSE: + __os_close = (int (*) __P((int)))func; + break; + case DB_FUNC_DIRFREE: + __db_dirfree = (void (*) __P((char **, int)))func; + break; + case DB_FUNC_DIRLIST: + __db_dirlist = + (int (*) __P((const char *, char ***, int *)))func; + break; + case DB_FUNC_EXISTS: + __db_exists = (int (*) __P((const char *, int *)))func; + break; + case DB_FUNC_FREE: + __db_free = (void (*) __P((void *)))func; + break; + case DB_FUNC_FSYNC: + __os_fsync = (int (*) __P((int)))func; + break; + case DB_FUNC_IOINFO: + __db_ioinfo = + (int (*) __P((const char *, int, off_t *, off_t *)))func; + break; + case DB_FUNC_MALLOC: + __db_malloc = (void *(*) __P((size_t)))func; + break; + case DB_FUNC_MAP: + __db_map = (int (*) __P((int, size_t, int, int, void **)))func; + break; + case DB_FUNC_OPEN: + __os_open = (int (*) __P((const char *, int, ...)))func; + break; + case DB_FUNC_READ: + __os_read = (ssize_t (*) __P((int, void *, size_t)))func; + break; + case DB_FUNC_REALLOC: + __db_realloc = (void *(*) __P((void *, size_t)))func; + break; + case DB_FUNC_SEEK: + __db_seek = + (int (*) __P((int, size_t, db_pgno_t, u_long, int)))func; + break; + case DB_FUNC_SLEEP: + __db_sleep = (int (*) __P((u_long, u_long)))func; + break; + case DB_FUNC_STRDUP: + __db_strdup = (char *(*) __P((const char *)))func; + break; + case DB_FUNC_UNLINK: + __os_unlink = (int (*) __P((const char *)))func; + break; + case DB_FUNC_UNMAP: + __db_unmap = (int (*) __P((void *, size_t)))func; + break; + case DB_FUNC_WRITE: + __os_write = (ssize_t (*) __P((int, const void *, size_t)))func; + break; + case DB_FUNC_YIELD: + __db_yield = (int (*) __P((void)))func; + break; + default: + return (EINVAL); + } + return (0); +} diff --git a/db2/os/os_map.c b/db2/os/os_map.c new file mode 100644 index 0000000..b155318 --- /dev/null +++ b/db2/os/os_map.c @@ -0,0 +1,71 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1996, 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_map.c 10.7 (Sleepycat) 10/25/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> +#include <sys/mman.h> + +#include <errno.h> +#endif + +#include "db_int.h" + +/* + * __os_map -- + * Map in some shared memory backed by a file descriptor. + * + * PUBLIC: int __os_map __P((int, size_t, int, int, void **)); + */ +int +__os_map(fd, len, is_private, is_rdonly, addr) + int fd, is_private, is_rdonly; + size_t len; + void **addr; +{ + void *p; + int flags, prot; + + flags = is_private ? MAP_PRIVATE : MAP_SHARED; +#ifdef MAP_HASSEMAPHORE + flags |= MAP_HASSEMAPHORE; +#endif + prot = PROT_READ | (is_rdonly ? 0 : PROT_WRITE); + +#ifndef MAP_FAILED /* XXX: Mmap(2) failure return. */ +#define MAP_FAILED -1 +#endif + if ((p = + mmap(NULL, len, prot, flags, fd, (off_t)0)) == (void *)MAP_FAILED) + return (errno); + + *addr = p; + return (0); +} + +/* + * __os_unmap -- + * Release the specified shared memory. + * + * PUBLIC: int __os_unmap __P((void *, size_t)); + */ +int +__os_unmap(addr, len) + void *addr; + size_t len; +{ + /* + * !!! + * The argument len is always the same length as was mapped. + */ + return (munmap(addr, len) ? errno : 0); +} diff --git a/db2/os/os_oflags.c b/db2/os/os_oflags.c new file mode 100644 index 0000000..3656eef --- /dev/null +++ b/db2/os/os_oflags.c @@ -0,0 +1,48 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_oflags.c 10.2 (Sleepycat) 10/24/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <fcntl.h> +#endif + +#include "db_int.h" + +/* + * __db_oflags -- + * Convert open(2) flags to DB flags. + * + * PUBLIC: int __db_oflags __P((int)); + */ +int +__db_oflags(oflags) + int oflags; +{ + int dbflags; + + /* + * XXX + * Convert POSIX 1003.1 open(2) flags to DB flags. Not an exact + * science as most POSIX implementations don't have a flag value + * for O_RDONLY, it's simply the lack of a write flag. + */ + dbflags = 0; + if (oflags & O_CREAT) + dbflags |= DB_CREATE; + if (!(oflags & (O_RDWR | O_WRONLY)) || oflags & O_RDONLY) + dbflags |= DB_RDONLY; + if (oflags & O_TRUNC) + dbflags |= DB_TRUNCATE; + return (dbflags); +} diff --git a/db2/os/db_os_open.c b/db2/os/os_open.c index 1d67ef9..05784e4 100644 --- a/db2/os/db_os_open.c +++ b/db2/os/os_open.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_open.c 10.14 (Sleepycat) 7/5/97"; +static const char sccsid[] = "@(#)os_open.c 10.19 (Sleepycat) 10/28/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,44 +20,15 @@ static const char sccsid[] = "@(#)db_os_open.c 10.14 (Sleepycat) 7/5/97"; #endif #include "db_int.h" -#include "os_ext.h" /* - * __db_oflags -- - * Convert open(2) flags to DB flags. - * - * PUBLIC: int __db_oflags __P((int)); - */ -int -__db_oflags(oflags) - int oflags; -{ - int dbflags; - - /* - * XXX - * Convert POSIX 1003.1 open(2) flags to DB flags. Not an exact - * science as most POSIX implementations don't have a flag value - * for O_RDONLY, it's simply the lack of a write flag. - */ - dbflags = 0; - if (oflags & O_CREAT) - dbflags |= DB_CREATE; - if (!(oflags & (O_RDWR | O_WRONLY)) || oflags & O_RDONLY) - dbflags |= DB_RDONLY; - if (oflags & O_TRUNC) - dbflags |= DB_TRUNCATE; - return (dbflags); -} - -/* - * __db_fdopen -- + * __db_open -- * Open a file descriptor. * - * PUBLIC: int __db_fdopen __P((const char *, int, int, int, int *)); + * PUBLIC: int __db_open __P((const char *, int, int, int, int *)); */ int -__db_fdopen(name, arg_flags, ok_flags, mode, fdp) +__db_open(name, arg_flags, ok_flags, mode, fdp) const char *name; int arg_flags, ok_flags, mode, *fdp; { @@ -95,13 +66,13 @@ __db_fdopen(name, arg_flags, ok_flags, mode, fdp) flags |= O_TRUNC; /* Open the file. */ - if ((fd = open(name, flags, mode)) == -1) + if ((fd = __os_open(name, flags, mode)) == -1) return (errno); #ifndef _WIN32 /* Delete any temporary file; done for Win32 by _O_TEMPORARY. */ if (arg_flags & DB_TEMPORARY) - (void)unlink(name); + (void)__os_unlink(name); #endif #if !defined(_WIN32) && !defined(macintosh) @@ -112,7 +83,7 @@ __db_fdopen(name, arg_flags, ok_flags, mode, fdp) if (fcntl(fd, F_SETFD, 1) == -1) { int ret = errno; - (void)__db_close(fd); + (void)__os_close(fd); return (ret); } #endif @@ -121,19 +92,6 @@ __db_fdopen(name, arg_flags, ok_flags, mode, fdp) } /* - * __db_fsync -- - * Flush a file descriptor. - * - * PUBLIC: int __db_fsync __P((int)); - */ -int -__db_fsync(fd) - int fd; -{ - return (fsync(fd) ? errno : 0); -} - -/* * __db_close -- * Close a file descriptor. * @@ -143,5 +101,5 @@ int __db_close(fd) int fd; { - return (close(fd) ? errno : 0); + return (__os_close(fd) ? errno : 0); } diff --git a/db2/os/os_rpath.c b/db2/os/os_rpath.c new file mode 100644 index 0000000..44fd4ec --- /dev/null +++ b/db2/os/os_rpath.c @@ -0,0 +1,42 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_rpath.c 10.2 (Sleepycat) 10/24/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <string.h> +#endif + +#include "db_int.h" + +/* + * __db_rpath -- + * Return the last path separator in the path or NULL if none found. + * + * PUBLIC: char *__db_rpath __P((const char *)); + */ +char * +__db_rpath(path) + const char *path; +{ + const char *s, *last; + + last = NULL; + if (PATH_SEPARATOR[1] != '\0') { + for (s = path; s[0] != '\0'; ++s) + if (strchr(PATH_SEPARATOR, s[0]) != NULL) + last = s; + } else + for (s = path; s[0] != '\0'; ++s) + if (s[0] == PATH_SEPARATOR[0]) + last = s; + return ((char *)last); +} diff --git a/db2/os/db_os_rw.c b/db2/os/os_rw.c index 5a6c219..48f7fdc 100644 --- a/db2/os/db_os_rw.c +++ b/db2/os/os_rw.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_rw.c 10.4 (Sleepycat) 6/28/97"; +static const char sccsid[] = "@(#)os_rw.c 10.6 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -19,7 +19,6 @@ static const char sccsid[] = "@(#)db_os_rw.c 10.4 (Sleepycat) 6/28/97"; #endif #include "db_int.h" -#include "os_ext.h" /* * __db_read -- @@ -40,7 +39,7 @@ __db_read(fd, addr, len, nrp) for (taddr = addr, offset = 0; offset < len; taddr += nr, offset += nr) { - if ((nr = read(fd, taddr, len - offset)) < 0) + if ((nr = __os_read(fd, taddr, len - offset)) < 0) return (errno); if (nr == 0) break; @@ -68,7 +67,7 @@ __db_write(fd, addr, len, nwp) for (taddr = addr, offset = 0; offset < len; taddr += nw, offset += nw) - if ((nw = write(fd, taddr, len - offset)) < 0) + if ((nw = __os_write(fd, taddr, len - offset)) < 0) return (errno); *nwp = len; return (0); diff --git a/db2/os/os_seek.c b/db2/os/os_seek.c new file mode 100644 index 0000000..e27044b --- /dev/null +++ b/db2/os/os_seek.c @@ -0,0 +1,42 @@ +/*- + * See the file LICENSE for redistribution information. + * + * Copyright (c) 1997 + * Sleepycat Software. All rights reserved. + */ + +#include "config.h" + +#ifndef lint +static const char sccsid[] = "@(#)os_seek.c 10.6 (Sleepycat) 10/25/97"; +#endif /* not lint */ + +#ifndef NO_SYSTEM_INCLUDES +#include <sys/types.h> + +#include <errno.h> +#include <unistd.h> +#endif + +#include "db_int.h" + +/* + * __os_seek -- + * Seek to a page/byte offset in the file. + * + * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_long, int)); + */ +int +__os_seek(fd, pgsize, pageno, relative, whence) + int fd; + size_t pgsize; + db_pgno_t pageno; + u_long relative; + int whence; +{ + off_t offset; + + offset = pgsize * pageno + relative; + + return (lseek(fd, offset, whence) == -1 ? errno : 0); +} diff --git a/db2/os/db_os_sleep.c b/db2/os/os_sleep.c index 5591789..2d2cb71 100644 --- a/db2/os/db_os_sleep.c +++ b/db2/os/os_sleep.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_sleep.c 10.6 (Sleepycat) 6/28/97"; +static const char sccsid[] = "@(#)os_sleep.c 10.8 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -28,21 +28,18 @@ static const char sccsid[] = "@(#)db_os_sleep.c 10.6 (Sleepycat) 6/28/97"; #endif #include "db_int.h" -#include "os_ext.h" /* - * __db_sleep -- + * __os_sleep -- * Yield the processor for a period of time. * - * PUBLIC: int __db_sleep __P((u_long, u_long)); + * PUBLIC: int __os_sleep __P((u_long, u_long)); */ int -__db_sleep(secs, usecs) +__os_sleep(secs, usecs) u_long secs, usecs; /* Seconds and microseconds. */ { -#ifndef _WIN32 struct timeval t; -#endif /* Don't require that the values be normalized. */ for (; usecs >= 1000000; ++secs, usecs -= 1000000); @@ -51,12 +48,7 @@ __db_sleep(secs, usecs) * It's important that we yield the processor here so that other * processes or threads are permitted to run. */ -#ifdef _WIN32 - Sleep(secs * 1000 + usecs / 1000); - return (0); -#else t.tv_sec = secs; t.tv_usec = usecs; return (select(0, NULL, NULL, NULL, &t) == -1 ? errno : 0); -#endif } diff --git a/db2/os/db_os_stat.c b/db2/os/os_stat.c index 7929b6b..ee84ab0 100644 --- a/db2/os/db_os_stat.c +++ b/db2/os/os_stat.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_stat.c 10.6 (Sleepycat) 7/2/97"; +static const char sccsid[] = "@(#)os_stat.c 10.8 (Sleepycat) 10/25/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,17 +20,16 @@ static const char sccsid[] = "@(#)db_os_stat.c 10.6 (Sleepycat) 7/2/97"; #endif #include "db_int.h" -#include "os_ext.h" #include "common_ext.h" /* - * __db_exists -- + * __os_exists -- * Return if the file exists. * - * PUBLIC: int __db_exists __P((const char *, int *)); + * PUBLIC: int __os_exists __P((const char *, int *)); */ int -__db_exists(path, isdirp) +__os_exists(path, isdirp) const char *path; int *isdirp; { @@ -44,25 +43,22 @@ __db_exists(path, isdirp) } /* - * __db_stat -- + * __os_ioinfo -- * Return file size and I/O size; abstracted to make it easier * to replace. * - * PUBLIC: int __db_stat __P((DB_ENV *, const char *, int, off_t *, off_t *)); + * PUBLIC: int __os_ioinfo __P((const char *, int, off_t *, off_t *)); */ int -__db_stat(dbenv, path, fd, sizep, iop) - DB_ENV *dbenv; +__os_ioinfo(path, fd, sizep, iop) const char *path; int fd; off_t *sizep, *iop; { struct stat sb; - if (fstat(fd, &sb) == -1) { - __db_err(dbenv, "%s: fstat: %s", path, strerror(errno)); + if (fstat(fd, &sb) == -1) return (errno); - } /* Return the size of the file. */ if (sizep != NULL) diff --git a/db2/os/db_os_unlink.c b/db2/os/os_unlink.c index 872beba..473ce77 100644 --- a/db2/os/db_os_unlink.c +++ b/db2/os/os_unlink.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_unlink.c 10.2 (Sleepycat) 6/28/97"; +static const char sccsid[] = "@(#)os_unlink.c 10.4 (Sleepycat) 10/28/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -19,7 +19,6 @@ static const char sccsid[] = "@(#)db_os_unlink.c 10.2 (Sleepycat) 6/28/97"; #endif #include "db_int.h" -#include "os_ext.h" /* * __db_unlink -- @@ -31,5 +30,5 @@ int __db_unlink(path) const char *path; { - return (unlink(path) == -1 ? errno : 0); + return (__os_unlink(path) == -1 ? errno : 0); } |