aboutsummaryrefslogtreecommitdiff
path: root/db2/os
diff options
context:
space:
mode:
Diffstat (limited to 'db2/os')
-rw-r--r--db2/os/os_abs.c31
-rw-r--r--db2/os/os_alloc.c219
-rw-r--r--db2/os/os_config.c153
-rw-r--r--db2/os/os_dir.c101
-rw-r--r--db2/os/os_fid.c76
-rw-r--r--db2/os/os_fsync.c59
-rw-r--r--db2/os/os_map.c447
-rw-r--r--db2/os/os_oflags.c99
-rw-r--r--db2/os/os_open.c152
-rw-r--r--db2/os/os_rpath.c42
-rw-r--r--db2/os/os_rw.c136
-rw-r--r--db2/os/os_seek.c52
-rw-r--r--db2/os/os_sleep.c59
-rw-r--r--db2/os/os_spin.c107
-rw-r--r--db2/os/os_stat.c99
-rw-r--r--db2/os/os_tmpdir.c113
-rw-r--r--db2/os/os_unlink.c39
17 files changed, 0 insertions, 1984 deletions
diff --git a/db2/os/os_abs.c b/db2/os/os_abs.c
deleted file mode 100644
index 547a6804b4..0000000000
--- a/db2/os/os_abs.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_abs.c 10.9 (Sleepycat) 7/21/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#endif
-
-#include "db_int.h"
-
-/*
- * __os_abspath --
- * Return if a path is an absolute path.
- *
- * PUBLIC: int __os_abspath __P((const char *));
- */
-int
-__os_abspath(path)
- const char *path;
-{
- return (path[0] == '/');
-}
diff --git a/db2/os/os_alloc.c b/db2/os/os_alloc.c
deleted file mode 100644
index 0090eb14a7..0000000000
--- a/db2/os/os_alloc.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_alloc.c 10.10 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * !!!
- * Correct for systems that return NULL when you allocate 0 bytes of memory.
- * There are several places in DB where we allocate the number of bytes held
- * by the key/data item, and it can be 0. Correct here so that malloc never
- * returns a NULL for that reason (which behavior is permitted by ANSI). We
- * could make these calls macros on non-Alpha architectures (that's where we
- * saw the problem), but it's probably not worth the autoconf complexity.
- *
- * !!!
- * Correct for systems that don't set errno when malloc and friends fail.
- *
- * Out of memory.
- * We wish to hold the whole sky,
- * But we never will.
- */
-
-/*
- * __os_strdup --
- * The strdup(3) function for DB.
- *
- * PUBLIC: int __os_strdup __P((const char *, void *));
- */
-int
-__os_strdup(str, storep)
- const char *str;
- void *storep;
-{
- size_t size;
- int ret;
- void *p;
-
- *(void **)storep = NULL;
-
- size = strlen(str) + 1;
- if ((ret = __os_malloc(size, NULL, &p)) != 0)
- return (ret);
-
- memcpy(p, str, size);
-
- *(void **)storep = p;
- return (0);
-}
-
-/*
- * __os_calloc --
- * The calloc(3) function for DB.
- *
- * PUBLIC: int __os_calloc __P((size_t, size_t, void *));
- */
-int
-__os_calloc(num, size, storep)
- size_t num, size;
- void *storep;
-{
- void *p;
- int ret;
-
- size *= num;
- if ((ret = __os_malloc(size, NULL, &p)) != 0)
- return (ret);
-
- memset(p, 0, size);
- *(void **)storep = p;
-
- return (0);
-}
-
-/*
- * __os_malloc --
- * The malloc(3) function for DB.
- *
- * PUBLIC: int __os_malloc __P((size_t, void *(*)(size_t), void *));
- */
-int
-__os_malloc(size, db_malloc, storep)
- size_t size;
- void *(*db_malloc) __P((size_t)), *storep;
-{
- void *p;
-
- *(void **)storep = NULL;
-
- /* Never allocate 0 bytes -- some C libraries don't like it. */
- if (size == 0)
- ++size;
-
- /* Some C libraries don't correctly set errno when malloc(3) fails. */
- errno = 0;
- if (db_malloc != NULL)
- p = db_malloc(size);
- else if (__db_jump.j_malloc != NULL)
- p = __db_jump.j_malloc(size);
- else
- p = malloc(size);
- if (p == NULL) {
- if (errno == 0)
- errno = ENOMEM;
- return (errno);
- }
-
-#ifdef DIAGNOSTIC
- memset(p, 0xdb, size);
-#endif
- *(void **)storep = p;
-
- return (0);
-}
-
-/*
- * __os_realloc --
- * The realloc(3) function for DB.
- *
- * PUBLIC: int __os_realloc __P((void *, size_t));
- */
-int
-__os_realloc(storep, size)
- void *storep;
- size_t size;
-{
- void *p, *ptr;
-
- ptr = *(void **)storep;
-
- /* If we haven't yet allocated anything yet, simply call malloc. */
- if (ptr == NULL)
- return (__os_malloc(size, NULL, storep));
-
- /* Never allocate 0 bytes -- some C libraries don't like it. */
- if (size == 0)
- ++size;
-
- /*
- * Some C libraries don't correctly set errno when realloc(3) fails.
- *
- * Don't overwrite the original pointer, there are places in DB we
- * try to continue after realloc fails.
- */
- errno = 0;
- if (__db_jump.j_realloc != NULL)
- p = __db_jump.j_realloc(ptr, size);
- else
- p = realloc(ptr, size);
- if (p == NULL) {
- if (errno == 0)
- errno = ENOMEM;
- return (errno);
- }
-
- *(void **)storep = p;
-
- return (0);
-}
-
-/*
- * __os_free --
- * The free(3) function for DB.
- *
- * PUBLIC: void __os_free __P((void *, size_t));
- */
-void
-__os_free(ptr, size)
- void *ptr;
- size_t size;
-{
-#ifdef DIAGNOSTIC
- if (size != 0)
- memset(ptr, 0xdb, size);
-#endif
-
- if (__db_jump.j_free != NULL)
- __db_jump.j_free(ptr);
- else
- free(ptr);
-}
-
-/*
- * __os_freestr --
- * The free(3) function for DB, freeing a string.
- *
- * PUBLIC: void __os_freestr __P((void *));
- */
-void
-__os_freestr(ptr)
- void *ptr;
-{
-#ifdef DIAGNOSTIC
- memset(ptr, 0xdb, strlen(ptr) + 1);
-#endif
-
- if (__db_jump.j_free != NULL)
- __db_jump.j_free(ptr);
- else
- free(ptr);
-}
diff --git a/db2/os/os_config.c b/db2/os/os_config.c
deleted file mode 100644
index 71d379a387..0000000000
--- a/db2/os/os_config.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_config.c 10.30 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-struct __db_jumptab __db_jump;
-
-DB_GLOBALS __db_global_values = {
- 1, /* DB_MUTEXLOCKS */
- 0, /* DB_PAGEYIELD */
- 0, /* DB_REGION_ANON, DB_REGION_NAME */
- 0, /* DB_REGION_INIT */
- 0, /* DB_TSL_SPINS */
- {NULL, &__db_global_values.db_envq.tqh_first}, /* Environemnt queue */
- {NULL, &__db_global_values.db_nameq.tqh_first} /* Name queue */
-};
-
-/*
- * db_jump_set --
- * Replace functions for the DB package.
- */
-int
-db_jump_set(func, which)
- void *func;
- int which;
-{
- switch (which) {
- case DB_FUNC_CLOSE:
- __db_jump.j_close = (int (*) __P((int)))func;
- break;
- case DB_FUNC_DIRFREE:
- __db_jump.j_dirfree = (void (*) __P((char **, int)))func;
- break;
- case DB_FUNC_DIRLIST:
- __db_jump.j_dirlist =
- (int (*) __P((const char *, char ***, int *)))func;
- break;
- case DB_FUNC_EXISTS:
- __db_jump.j_exists = (int (*) __P((const char *, int *)))func;
- break;
- case DB_FUNC_FREE:
- __db_jump.j_free = (void (*) __P((void *)))func;
- break;
- case DB_FUNC_FSYNC:
- __db_jump.j_fsync = (int (*) __P((int)))func;
- break;
- case DB_FUNC_IOINFO:
- __db_jump.j_ioinfo = (int (*) __P((const char *,
- int, u_int32_t *, u_int32_t *, u_int32_t *)))func;
- break;
- case DB_FUNC_MALLOC:
- __db_jump.j_malloc = (void *(*) __P((size_t)))func;
- break;
- case DB_FUNC_MAP:
- __db_jump.j_map = (int (*)
- __P((char *, int, size_t, int, int, int, void **)))func;
- break;
- case DB_FUNC_OPEN:
- __db_jump.j_open = (int (*) __P((const char *, int, ...)))func;
- break;
- case DB_FUNC_READ:
- __db_jump.j_read =
- (ssize_t (*) __P((int, void *, size_t)))func;
- break;
- case DB_FUNC_REALLOC:
- __db_jump.j_realloc = (void *(*) __P((void *, size_t)))func;
- break;
- case DB_FUNC_RUNLINK:
- __db_jump.j_runlink = (int (*) __P((char *)))func;
- break;
- case DB_FUNC_SEEK:
- __db_jump.j_seek = (int (*)
- __P((int, size_t, db_pgno_t, u_int32_t, int, int)))func;
- break;
- case DB_FUNC_SLEEP:
- __db_jump.j_sleep = (int (*) __P((u_long, u_long)))func;
- break;
- case DB_FUNC_UNLINK:
- __db_jump.j_unlink = (int (*) __P((const char *)))func;
- break;
- case DB_FUNC_UNMAP:
- __db_jump.j_unmap = (int (*) __P((void *, size_t)))func;
- break;
- case DB_FUNC_WRITE:
- __db_jump.j_write =
- (ssize_t (*) __P((int, const void *, size_t)))func;
- break;
- case DB_FUNC_YIELD:
- __db_jump.j_yield = (int (*) __P((void)))func;
- break;
- default:
- return (EINVAL);
- }
- return (0);
-}
-
-/*
- * db_value_set --
- * Replace values for the DB package.
- */
-int
-db_value_set(value, which)
- int value, which;
-{
- int ret;
-
- switch (which) {
- case DB_MUTEXLOCKS:
- DB_GLOBAL(db_mutexlocks) = value;
- break;
- case DB_PAGEYIELD:
- DB_GLOBAL(db_pageyield) = value;
- break;
- case DB_REGION_ANON:
- if (value != 0 && (ret = __db_mapanon_ok(0)) != 0)
- return (ret);
- DB_GLOBAL(db_region_anon) = value;
- break;
- case DB_REGION_INIT:
- DB_GLOBAL(db_region_init) = value;
- break;
- case DB_REGION_NAME:
- if (value != 0 && (ret = __db_mapanon_ok(1)) != 0)
- return (ret);
- DB_GLOBAL(db_region_anon) = value;
- break;
- case DB_TSL_SPINS:
- if (value <= 0)
- return (EINVAL);
- DB_GLOBAL(db_tsl_spins) = value;
- break;
- default:
- return (EINVAL);
- }
- return (0);
-}
diff --git a/db2/os/os_dir.c b/db2/os/os_dir.c
deleted file mode 100644
index f2ee128c1e..0000000000
--- a/db2/os/os_dir.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_dir.c 10.19 (Sleepycat) 10/12/98";
-#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>
-#endif
-
-#include "db_int.h"
-#include "os_jump.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, ret;
- char **names;
-
- if (__db_jump.j_dirlist != NULL)
- return (__db_jump.j_dirlist(dir, namesp, cntp));
-
- if ((dirp = opendir(dir)) == NULL)
- return (errno);
- names = NULL;
- for (arraysz = cnt = 0; (dp = readdir(dirp)) != NULL; ++cnt) {
- if (cnt >= arraysz) {
- arraysz += 100;
- if ((ret = __os_realloc(&names,
- arraysz * sizeof(names[0]))) != 0)
- goto nomem;
- }
- if ((ret = __os_strdup(dp->d_name, &names[cnt])) != 0)
- goto nomem;
- }
- (void)closedir(dirp);
-
- *namesp = names;
- *cntp = cnt;
- return (0);
-
-nomem: if (names != NULL)
- __os_dirfree(names, cnt);
- return (ret);
-}
-
-/*
- * __os_dirfree --
- * Free the list of files.
- *
- * PUBLIC: void __os_dirfree __P((char **, int));
- */
-void
-__os_dirfree(names, cnt)
- char **names;
- int cnt;
-{
- if (__db_jump.j_dirfree != NULL)
- __db_jump.j_dirfree(names, cnt);
-
- while (cnt > 0)
- __os_free(names[--cnt], 0);
- __os_free(names, 0);
-}
diff --git a/db2/os/os_fid.c b/db2/os/os_fid.c
deleted file mode 100644
index 62da590611..0000000000
--- a/db2/os/os_fid.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996, 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_fid.c 10.12 (Sleepycat) 7/21/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#endif
-
-#include "db_int.h"
-#include "common_ext.h"
-
-/*
- * __os_fileid --
- * Return a unique identifier for a file.
- *
- * PUBLIC: int __os_fileid __P((DB_ENV *, const char *, int, u_int8_t *));
- */
-int
-__os_fileid(dbenv, fname, timestamp, fidp)
- DB_ENV *dbenv;
- const char *fname;
- int timestamp;
- u_int8_t *fidp;
-{
- struct stat sb;
- size_t i;
- time_t now;
- u_int8_t *p;
-
- /* Clear the buffer. */
- memset(fidp, 0, DB_FILE_ID_LEN);
-
- /* Check for the unthinkable. */
- if (sizeof(sb.st_ino) +
- sizeof(sb.st_dev) + sizeof(time_t) > DB_FILE_ID_LEN)
- return (EINVAL);
-
- /* On UNIX, use a dev/inode pair. */
- if (stat(fname, &sb)) {
- __db_err(dbenv, "%s: %s", fname, strerror(errno));
- return (errno);
- }
-
- /*
- * Use the inode first and in reverse order, hopefully putting the
- * distinguishing information early in the string.
- */
- for (p = (u_int8_t *)&sb.st_ino +
- sizeof(sb.st_ino), i = 0; i < sizeof(sb.st_ino); ++i)
- *fidp++ = *--p;
- for (p = (u_int8_t *)&sb.st_dev +
- sizeof(sb.st_dev), i = 0; i < sizeof(sb.st_dev); ++i)
- *fidp++ = *--p;
-
- if (timestamp) {
- (void)time(&now);
- for (p = (u_int8_t *)&now +
- sizeof(now), i = 0; i < sizeof(now); ++i)
- *fidp++ = *--p;
- }
- return (0);
-}
diff --git a/db2/os/os_fsync.c b/db2/os/os_fsync.c
deleted file mode 100644
index 61a504f84d..0000000000
--- a/db2/os/os_fsync.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_fsync.c 10.7 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <fcntl.h> /* XXX: Required by __hp3000s900 */
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-#ifdef __hp3000s900
-int
-__mpe_fsync(fd)
- int fd;
-{
- extern FCONTROL(short, short, void *);
-
- FCONTROL(_MPE_FILENO(fd), 2, NULL); /* Flush the buffers */
- FCONTROL(_MPE_FILENO(fd), 6, NULL); /* Write the EOF */
- return (0);
-}
-#endif
-
-#ifdef __hp3000s900
-#define fsync(fd) __mpe_fsync(fd);
-#endif
-#ifdef _WIN32
-#define fsync(fd) _commit(fd);
-#endif
-
-/*
- * __os_fsync --
- * Flush a file descriptor.
- *
- * PUBLIC: int __os_fsync __P((int));
- */
-int
-__os_fsync(fd)
- int fd;
-{
- int ret;
-
- ret = __db_jump.j_fsync != NULL ? __db_jump.j_fsync(fd) : fsync(fd);
- return (ret == 0 ? 0 : errno);
-}
diff --git a/db2/os/os_map.c b/db2/os/os_map.c
deleted file mode 100644
index 5664a2edec..0000000000
--- a/db2/os/os_map.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996, 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_map.c 10.24 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#ifdef HAVE_MMAP
-#include <sys/mman.h>
-#endif
-
-#ifdef HAVE_SHMGET
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#endif
-
-#include <errno.h>
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-#include "common_ext.h"
-
-#ifdef HAVE_MMAP
-static int __os_map __P((char *, int, size_t, int, int, int, void **));
-#endif
-#ifdef HAVE_SHMGET
-static int __os_shmget __P((REGINFO *));
-#endif
-
-/*
- * __db_mapanon_ok --
- * Return if this OS can support anonymous memory regions.
- *
- * PUBLIC: int __db_mapanon_ok __P((int));
- */
-int
-__db_mapanon_ok(need_names)
- int need_names;
-{
- int ret;
-
- ret = EINVAL;
-
- /*
- * If we don't have spinlocks, we have to have a file descriptor
- * for fcntl(2) locking, which implies using mmap(2) to map in a
- * regular file. Theoretically, we could probably find ways to
- * get a file descriptor to lock other types of shared regions,
- * but I don't see any reason to do so.
- *
- * If need_names is set, the application wants to share anonymous
- * memory among multiple processes, so we have to have a way to
- * name it. This requires shmget(2), on UNIX systems.
- */
-#ifdef HAVE_SPINLOCKS
-#ifdef HAVE_SHMGET
- ret = 0;
-#endif
-#ifdef HAVE_MMAP
-#ifdef MAP_ANON
- if (!need_names)
- ret = 0;
-#endif
-#ifdef MAP_ANONYMOUS
- if (!need_names)
- ret = 0;
-#endif
-#else
- COMPQUIET(need_names, 0);
-#endif /* HAVE_MMAP */
-#endif /* HAVE_SPINLOCKS */
-
- return (ret);
-}
-
-/*
- * __db_mapinit --
- * Return if shared regions need to be initialized.
- *
- * PUBLIC: int __db_mapinit __P((void));
- */
-int
-__db_mapinit()
-{
- /*
- * Historically, some systems required that all of the bytes of the
- * region be written before it could be mmapped and accessed randomly.
- * We have the option of setting REGION_INIT_NEEDED at configuration
- * time if we're running on one of those systems.
- */
-#ifdef REGION_INIT_NEEDED
- return (1);
-#else
- return (0);
-#endif
-}
-
-/*
- * __db_mapregion --
- * Attach to a shared memory region.
- *
- * PUBLIC: int __db_mapregion __P((char *, REGINFO *));
- */
-int
-__db_mapregion(path, infop)
- char *path;
- REGINFO *infop;
-{
- int called, ret;
-
- called = 0;
- ret = EINVAL;
-
- /* If the user replaces the map call, call through their interface. */
- if (__db_jump.j_map != NULL) {
- F_SET(infop, REGION_HOLDINGSYS);
- return (__db_jump.j_map(path, infop->fd, infop->size,
- 1, F_ISSET(infop, REGION_ANONYMOUS), 0, &infop->addr));
- }
-
- if (F_ISSET(infop, REGION_ANONYMOUS)) {
- /*
- * !!!
- * If we're creating anonymous regions:
- *
- * If it's private, we use mmap(2). The problem with using
- * shmget(2) is that we may be creating a region of which the
- * application isn't aware, and if the application crashes
- * we'll have no way to remove the system resources for the
- * region.
- *
- * If it's not private, we use the shmget(2) interface if it's
- * available, because it allows us to name anonymous memory.
- * If shmget(2) isn't available, use the mmap(2) calls.
- *
- * In the case of anonymous memory, using mmap(2) means the
- * memory isn't named and only the single process and its
- * threads can access the region.
- */
-#ifdef HAVE_MMAP
-#ifdef MAP_ANON
-#define HAVE_MMAP_ANONYMOUS 1
-#else
-#ifdef MAP_ANONYMOUS
-#define HAVE_MMAP_ANONYMOUS 1
-#endif
-#endif
-#endif
-#ifdef HAVE_MMAP_ANONYMOUS
- if (!called && F_ISSET(infop, REGION_PRIVATE)) {
- called = 1;
- ret = __os_map(path,
- infop->fd, infop->size, 1, 1, 0, &infop->addr);
- }
-#endif
-#ifdef HAVE_SHMGET
- if (!called) {
- called = 1;
- ret = __os_shmget(infop);
- }
-#endif
-#ifdef HAVE_MMAP
- /*
- * If we're trying to join an unnamed anonymous region, fail --
- * that's not possible.
- */
- if (!called) {
- called = 1;
-
- if (!F_ISSET(infop, REGION_CREATED)) {
- __db_err(infop->dbenv,
- "cannot join region in unnamed anonymous memory");
- return (EINVAL);
- }
-
- ret = __os_map(path,
- infop->fd, infop->size, 1, 1, 0, &infop->addr);
- }
-#endif
- } else {
- /*
- * !!!
- * If we're creating normal regions, we use the mmap(2)
- * interface if it's available because it's POSIX 1003.1
- * standard and we trust it more than we do shmget(2).
- */
-#ifdef HAVE_MMAP
- if (!called) {
- called = 1;
-
- /* Mmap(2) regions that aren't anonymous can grow. */
- F_SET(infop, REGION_CANGROW);
-
- ret = __os_map(path,
- infop->fd, infop->size, 1, 0, 0, &infop->addr);
- }
-#endif
-#ifdef HAVE_SHMGET
- if (!called) {
- called = 1;
- ret = __os_shmget(infop);
- }
-#endif
- }
- return (ret);
-}
-
-/*
- * __db_unmapregion --
- * Detach from the shared memory region.
- *
- * PUBLIC: int __db_unmapregion __P((REGINFO *));
- */
-int
-__db_unmapregion(infop)
- REGINFO *infop;
-{
- int called, ret;
-
- called = 0;
- ret = EINVAL;
-
- if (__db_jump.j_unmap != NULL)
- return (__db_jump.j_unmap(infop->addr, infop->size));
-
-#ifdef HAVE_SHMGET
- if (infop->segid != INVALID_SEGID) {
- called = 1;
- ret = shmdt(infop->addr) ? errno : 0;
- }
-#endif
-#ifdef HAVE_MMAP
- if (!called) {
- called = 1;
- ret = munmap(infop->addr, infop->size) ? errno : 0;
- }
-#endif
- return (ret);
-}
-
-/*
- * __db_unlinkregion --
- * Remove the shared memory region.
- *
- * PUBLIC: int __db_unlinkregion __P((char *, REGINFO *));
- */
-int
-__db_unlinkregion(name, infop)
- char *name;
- REGINFO *infop;
-{
- int called, ret;
-
- called = 0;
- ret = EINVAL;
-
- if (__db_jump.j_runlink != NULL)
- return (__db_jump.j_runlink(name));
-
-#ifdef HAVE_SHMGET
- if (infop->segid != INVALID_SEGID) {
- called = 1;
- ret = shmctl(infop->segid, IPC_RMID, NULL) ? errno : 0;
- }
-#endif
-#ifdef HAVE_MMAP
- COMPQUIET(infop, NULL);
- if (!called) {
- called = 1;
- ret = 0;
- }
-#endif
- return (ret);
-}
-
-/*
- * __db_mapfile --
- * Map in a shared memory file.
- *
- * PUBLIC: int __db_mapfile __P((char *, int, size_t, int, void **));
- */
-int
-__db_mapfile(path, fd, len, is_rdonly, addr)
- char *path;
- int fd, is_rdonly;
- size_t len;
- void **addr;
-{
- if (__db_jump.j_map != NULL)
- return (__db_jump.j_map(path, fd, len, 0, 0, is_rdonly, addr));
-
-#ifdef HAVE_MMAP
- return (__os_map(path, fd, len, 0, 0, is_rdonly, addr));
-#else
- return (EINVAL);
-#endif
-}
-
-/*
- * __db_unmapfile --
- * Unmap the shared memory file.
- *
- * PUBLIC: int __db_unmapfile __P((void *, size_t));
- */
-int
-__db_unmapfile(addr, len)
- void *addr;
- size_t len;
-{
- if (__db_jump.j_unmap != NULL)
- return (__db_jump.j_unmap(addr, len));
-
-#ifdef HAVE_MMAP
- return (munmap(addr, len) ? errno : 0);
-#else
- return (EINVAL);
-#endif
-}
-
-#ifdef HAVE_MMAP
-/*
- * __os_map --
- * Call the mmap(2) function.
- */
-static int
-__os_map(path, fd, len, is_region, is_anonymous, is_rdonly, addr)
- char *path;
- int fd, is_region, is_anonymous, is_rdonly;
- size_t len;
- void **addr;
-{
- void *p;
- int flags, prot;
-
- COMPQUIET(path, NULL);
-
- /*
- * If it's read-only, it's private, and if it's not, it's shared.
- * Don't bother with an additional parameter.
- */
- flags = is_rdonly ? MAP_PRIVATE : MAP_SHARED;
-
- if (is_region && is_anonymous) {
- /*
- * BSD derived systems use MAP_ANON; Digital Unix and HP/UX
- * use MAP_ANONYMOUS.
- */
-#ifdef MAP_ANON
- flags |= MAP_ANON;
-#endif
-#ifdef MAP_ANONYMOUS
- flags |= MAP_ANONYMOUS;
-#endif
- fd = -1;
- }
-#ifdef MAP_FILE
- if (!is_region || !is_anonymous) {
- /*
- * Historically, MAP_FILE was required for mapping regular
- * files, even though it was the default. Some systems have
- * it, some don't, some that have it set it to 0.
- */
- flags |= MAP_FILE;
- }
-#endif
-
- /*
- * I know of no systems that implement the flag to tell the system
- * that the region contains semaphores, but it's not an unreasonable
- * thing to do, and has been part of the design since forever. I
- * don't think anyone will object, but don't set it for read-only
- * files, it doesn't make sense.
- */
-#ifdef MAP_HASSEMAPHORE
- if (!is_rdonly)
- flags |= MAP_HASSEMAPHORE;
-#endif
-
- prot = PROT_READ | (is_rdonly ? 0 : PROT_WRITE);
-
-/*
- * XXX
- * Work around a bug in the VMS V7.1 mmap() implementation. To map a file
- * into memory on VMS it needs to be opened in a certain way, originally.
- * To get the file opened in that certain way, the VMS mmap() closes the
- * file and re-opens it. When it does this, it doesn't flush any caches
- * out to disk before closing. The problem this causes us is that when the
- * memory cache doesn't get written out, the file isn't big enough to match
- * the memory chunk and the mmap() call fails. This call to fsync() fixes
- * the problem. DEC thinks this isn't a bug because of language in XPG5
- * discussing user responsibility for on-disk and in-memory synchronization.
- */
-#ifdef VMS
- if (__os_fsync(fd) == -1)
- return(errno);
-#endif
-
- /* MAP_FAILED was not defined in early mmap implementations. */
-#ifndef MAP_FAILED
-#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);
-}
-#endif
-
-#ifdef HAVE_SHMGET
-/*
- * __os_shmget --
- * Call the shmget(2) family of functions.
- */
-static int
-__os_shmget(infop)
- REGINFO *infop;
-{
- if (F_ISSET(infop, REGION_CREATED) &&
- (infop->segid = shmget(0, infop->size, IPC_PRIVATE | 0600)) == -1)
- return (errno);
-
- if ((infop->addr = shmat(infop->segid, NULL, 0)) == (void *)-1) {
- /*
- * If we're trying to join the region and failing, assume
- * that there was a reboot and the region no longer exists.
- */
- if (!F_ISSET(infop, REGION_CREATED))
- errno = EAGAIN;
- return (errno);
- }
-
- F_SET(infop, REGION_HOLDINGSYS);
- return (0);
-}
-#endif
diff --git a/db2/os/os_oflags.c b/db2/os/os_oflags.c
deleted file mode 100644
index a4003dd5f0..0000000000
--- a/db2/os/os_oflags.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_oflags.c 10.6 (Sleepycat) 4/19/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <fcntl.h>
-#endif
-
-#include "db_int.h"
-
-/*
- * __db_oflags --
- * Convert open(2) flags to DB flags.
- *
- * PUBLIC: u_int32_t __db_oflags __P((int));
- */
-u_int32_t
-__db_oflags(oflags)
- int oflags;
-{
- u_int32_t dbflags;
-
- /*
- * Convert POSIX 1003.1 open(2) flags to DB flags.
- */
- dbflags = 0;
- switch (oflags & O_ACCMODE) {
- case O_RDONLY:
- dbflags |= DB_RDONLY;
- break;
- case O_WRONLY:
- case O_RDWR:
- break;
- default: /* Bogus flags value from user. */
- /* XXX no way to return error from here */
- }
- if (oflags & O_CREAT)
- dbflags |= DB_CREATE;
- if (oflags & O_TRUNC)
- dbflags |= DB_TRUNCATE;
- return (dbflags);
-}
-
-/*
- * __db_omode --
- * Convert a permission string to the correct open(2) flags.
- *
- * PUBLIC: int __db_omode __P((const char *));
- */
-int
-__db_omode(perm)
- const char *perm;
-{
- int mode;
-
-#ifndef S_IRUSR
-#if defined(_WIN32) || defined(WIN16)
-#define S_IRUSR S_IREAD /* R for owner */
-#define S_IWUSR S_IWRITE /* W for owner */
-#define S_IRGRP 0 /* R for group */
-#define S_IWGRP 0 /* W for group */
-#define S_IROTH 0 /* R for other */
-#define S_IWOTH 0 /* W for other */
-#else
-#define S_IRUSR 0000400 /* R for owner */
-#define S_IWUSR 0000200 /* W for owner */
-#define S_IRGRP 0000040 /* R for group */
-#define S_IWGRP 0000020 /* W for group */
-#define S_IROTH 0000004 /* R for other */
-#define S_IWOTH 0000002 /* W for other */
-#endif /* _WIN32 || WIN16 */
-#endif
- mode = 0;
- if (perm[0] == 'r')
- mode |= S_IRUSR;
- if (perm[1] == 'w')
- mode |= S_IWUSR;
- if (perm[2] == 'r')
- mode |= S_IRGRP;
- if (perm[3] == 'w')
- mode |= S_IWGRP;
- if (perm[4] == 'r')
- mode |= S_IROTH;
- if (perm[5] == 'w')
- mode |= S_IWOTH;
- return (mode);
-}
diff --git a/db2/os/os_open.c b/db2/os/os_open.c
deleted file mode 100644
index c54fd7365d..0000000000
--- a/db2/os/os_open.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_open.c 10.33 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * __db_open --
- * Open a file descriptor.
- *
- * PUBLIC: int __db_open __P((const char *, u_int32_t, u_int32_t, int, int *));
- */
-int
-__db_open(name, arg_flags, ok_flags, mode, fdp)
- const char *name;
- u_int32_t arg_flags, ok_flags;
- int mode, *fdp;
-{
-#if !defined(_WIN32) && defined(HAVE_SIGFILLSET)
- sigset_t set, oset;
-#endif
- int flags, ret;
-
- if (arg_flags & ~ok_flags)
- return (EINVAL);
-
- flags = 0;
-
- /*
- * DB requires the semantic that two files opened at the same time
- * with O_CREAT and O_EXCL set will return failure in at least one.
- */
- if (arg_flags & DB_CREATE)
- flags |= O_CREAT;
-
- if (arg_flags & DB_EXCL)
- flags |= O_EXCL;
-
- if (arg_flags & DB_RDONLY)
- flags |= O_RDONLY;
- else
- flags |= O_RDWR;
-
-#if defined(_WIN32) || defined(WIN16)
-#ifdef _MSC_VER
- if (arg_flags & DB_SEQUENTIAL)
- flags |= _O_SEQUENTIAL;
- else
- flags |= _O_RANDOM;
-
- if (arg_flags & DB_TEMPORARY)
- flags |= _O_TEMPORARY;
-#endif
- flags |= O_BINARY | O_NOINHERIT;
-#endif
-
- if (arg_flags & DB_TRUNCATE)
- flags |= O_TRUNC;
-
-#if !defined(_WIN32) && defined(HAVE_SIGFILLSET)
- /*
- * We block every signal we can get our hands on so that the temporary
- * file isn't left around if we're interrupted at the wrong time. Of
- * course, if we drop core in-between the calls we'll hang forever, but
- * that's probably okay. ;-)
- */
- if (arg_flags & DB_TEMPORARY) {
- (void)sigfillset(&set);
- (void)sigprocmask(SIG_BLOCK, &set, &oset);
- }
-#endif
-
- /* Open the file. */
- if ((ret = __os_open(name, flags, mode, fdp)) != 0)
- return (ret);
-
-#if !defined(_WIN32)
- /* Delete any temporary file; done for Win32 by _O_TEMPORARY. */
- if (arg_flags & DB_TEMPORARY) {
- (void)__os_unlink(name);
-#if defined(HAVE_SIGFILLSET)
- (void)sigprocmask(SIG_SETMASK, &oset, NULL);
-#endif
- }
-#endif
-
-#if !defined(_WIN32) && !defined(WIN16) && !defined(VMS)
- /*
- * Deny access to any child process.
- * VMS: does not have fd inheritance.
- * Win32: done by O_NOINHERIT.
- */
- if (fcntl(*fdp, F_SETFD, 1) == -1) {
- ret = errno;
-
- (void)__os_close(*fdp);
- return (ret);
- }
-#endif
- return (0);
-}
-
-/*
- * __os_open --
- * Open a file.
- *
- * PUBLIC: int __os_open __P((const char *, int, int, int *));
- */
-int
-__os_open(name, flags, mode, fdp)
- const char *name;
- int flags, mode, *fdp;
-{
- *fdp = __db_jump.j_open != NULL ?
- __db_jump.j_open(name, flags, mode) : open(name, flags, mode);
- return (*fdp == -1 ? errno : 0);
-}
-
-/*
- * __os_close --
- * Close a file descriptor.
- *
- * PUBLIC: int __os_close __P((int));
- */
-int
-__os_close(fd)
- int fd;
-{
- int ret;
-
- ret = __db_jump.j_close != NULL ? __db_jump.j_close(fd) : close(fd);
- return (ret == 0 ? 0 : errno);
-}
diff --git a/db2/os/os_rpath.c b/db2/os/os_rpath.c
deleted file mode 100644
index 23867b35ac..0000000000
--- a/db2/os/os_rpath.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_rpath.c 10.3 (Sleepycat) 4/10/98";
-#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/os_rw.c b/db2/os/os_rw.c
deleted file mode 100644
index e0a8163d82..0000000000
--- a/db2/os/os_rw.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_rw.c 10.11 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * __os_io --
- * Do an I/O.
- *
- * PUBLIC: int __os_io __P((DB_IO *, int, ssize_t *));
- */
-int
-__os_io(db_iop, op, niop)
- DB_IO *db_iop;
- int op;
- ssize_t *niop;
-{
- int ret;
-
-#ifdef HAVE_PREAD
- switch (op) {
- case DB_IO_READ:
- if (__db_jump.j_read != NULL)
- goto slow;
- *niop = pread(db_iop->fd_io, db_iop->buf,
- db_iop->bytes, (off_t)db_iop->pgno * db_iop->pagesize);
- break;
- case DB_IO_WRITE:
- if (__db_jump.j_write != NULL)
- goto slow;
- *niop = pwrite(db_iop->fd_io, db_iop->buf,
- db_iop->bytes, (off_t)db_iop->pgno * db_iop->pagesize);
- break;
- }
- if (*niop == db_iop->bytes)
- return (0);
-slow:
-#endif
- if (db_iop->mutexp != NULL)
- (void)__db_mutex_lock(db_iop->mutexp, db_iop->fd_lock);
-
- if ((ret = __os_seek(db_iop->fd_io,
- db_iop->pagesize, db_iop->pgno, 0, 0, SEEK_SET)) != 0)
- goto err;
- switch (op) {
- case DB_IO_READ:
- ret =
- __os_read(db_iop->fd_io, db_iop->buf, db_iop->bytes, niop);
- break;
- case DB_IO_WRITE:
- ret =
- __os_write(db_iop->fd_io, db_iop->buf, db_iop->bytes, niop);
- break;
- }
-
-err: if (db_iop->mutexp != NULL)
- (void)__db_mutex_unlock(db_iop->mutexp, db_iop->fd_lock);
-
- return (ret);
-
-}
-
-/*
- * __os_read --
- * Read from a file handle.
- *
- * PUBLIC: int __os_read __P((int, void *, size_t, ssize_t *));
- */
-int
-__os_read(fd, addr, len, nrp)
- int fd;
- void *addr;
- size_t len;
- ssize_t *nrp;
-{
- size_t offset;
- ssize_t nr;
- u_int8_t *taddr;
-
- for (taddr = addr,
- offset = 0; offset < len; taddr += nr, offset += nr) {
- if ((nr = __db_jump.j_read != NULL ?
- __db_jump.j_read(fd, taddr, len - offset) :
- read(fd, taddr, len - offset)) < 0)
- return (errno);
- if (nr == 0)
- break;
- }
- *nrp = taddr - (u_int8_t *)addr;
- return (0);
-}
-
-/*
- * __os_write --
- * Write to a file handle.
- *
- * PUBLIC: int __os_write __P((int, void *, size_t, ssize_t *));
- */
-int
-__os_write(fd, addr, len, nwp)
- int fd;
- const void *addr;
- size_t len;
- ssize_t *nwp;
-{
- size_t offset;
- ssize_t nw;
- const u_int8_t *taddr;
-
- for (taddr = addr,
- offset = 0; offset < len; taddr += nw, offset += nw)
- if ((nw = __db_jump.j_write != NULL ?
- __db_jump.j_write(fd, taddr, len - offset) :
- 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
deleted file mode 100644
index ae5272bd1c..0000000000
--- a/db2/os/os_seek.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_seek.c 10.11 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * __os_seek --
- * Seek to a page/byte offset in the file.
- *
- * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_int32_t, int, int));
- */
-int
-__os_seek(fd, pgsize, pageno, relative, isrewind, whence)
- int fd;
- size_t pgsize;
- db_pgno_t pageno;
- u_int32_t relative;
- int isrewind, whence;
-{
- off_t offset;
- int ret;
-
- if (__db_jump.j_seek != NULL)
- ret = __db_jump.j_seek(fd,
- pgsize, pageno, relative, isrewind, whence);
- else {
- offset = (off_t)pgsize * pageno + relative;
- if (isrewind)
- offset = -offset;
-
- ret = lseek(fd, offset, whence);
- }
- return (ret == -1 ? errno : 0);
-}
diff --git a/db2/os/os_sleep.c b/db2/os/os_sleep.c
deleted file mode 100644
index 5aa476352e..0000000000
--- a/db2/os/os_sleep.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_sleep.c 10.12 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#include <errno.h>
-#ifndef HAVE_SYS_TIME_H
-#include <time.h>
-#endif
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * __os_sleep --
- * Yield the processor for a period of time.
- *
- * PUBLIC: int __os_sleep __P((u_long, u_long));
- */
-int
-__os_sleep(secs, usecs)
- u_long secs, usecs; /* Seconds and microseconds. */
-{
- struct timeval t;
-
- /* Don't require that the values be normalized. */
- for (; usecs >= 1000000; ++secs, usecs -= 1000000)
- ;
-
- if (__db_jump.j_sleep != NULL)
- return (__db_jump.j_sleep(secs, usecs));
-
- /*
- * It's important that we yield the processor here so that other
- * processes or threads are permitted to run.
- */
- t.tv_sec = secs;
- t.tv_usec = usecs;
- return (select(0, NULL, NULL, NULL, &t) == -1 ? errno : 0);
-}
diff --git a/db2/os/os_spin.c b/db2/os/os_spin.c
deleted file mode 100644
index cbde58894a..0000000000
--- a/db2/os/os_spin.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_spin.c 10.10 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#if defined(HAVE_PSTAT_GETDYNAMIC)
-#include <sys/pstat.h>
-#endif
-
-#include <limits.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-#if defined(HAVE_PSTAT_GETDYNAMIC)
-/*
- * __os_pstat_getdynamic --
- * HP/UX.
- */
-static int
-__os_pstat_getdynamic()
-{
- struct pst_dynamic psd;
-
- return (pstat_getdynamic(&psd,
- sizeof(psd), (size_t)1, 0) == -1 ? 1 : psd.psd_proc_cnt);
-}
-#endif
-
-#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
-/*
- * __os_sysconf --
- * Solaris, Linux.
- */
-static int
-__os_sysconf(void)
-{
- int nproc;
-
- return ((nproc = sysconf(_SC_NPROCESSORS_ONLN)) > 1 ? nproc : 1);
-}
-#endif
-
-/*
- * __os_spin --
- * Return the number of default spins before blocking.
- *
- * PUBLIC: int __os_spin __P((void));
- */
-int
-__os_spin()
-{
- /*
- * If the application specified a value or we've already figured it
- * out, return it.
- *
- * XXX
- * We don't want to repeatedly call the underlying function because
- * it can be expensive (e.g., requiring multiple filesystem accesses
- * under Debian Linux).
- */
- if (DB_GLOBAL(db_tsl_spins) != 0)
- return (DB_GLOBAL(db_tsl_spins));
-
- DB_GLOBAL(db_tsl_spins) = 1;
-#if defined(HAVE_PSTAT_GETDYNAMIC)
- DB_GLOBAL(db_tsl_spins) = __os_pstat_getdynamic();
-#endif
-#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
- DB_GLOBAL(db_tsl_spins) = __os_sysconf();
-#endif
-
- /*
- * Spin 50 times per processor, we have anecdotal evidence that this
- * is a reasonable value.
- */
- DB_GLOBAL(db_tsl_spins) *= 50;
-
- return (DB_GLOBAL(db_tsl_spins));
-}
-
-/*
- * __os_yield --
- * Yield the processor.
- *
- * PUBLIC: void __os_yield __P((u_long));
- */
-void
-__os_yield(usecs)
- u_long usecs;
-{
- if (__db_jump.j_yield != NULL && __db_jump.j_yield() == 0)
- return;
- __os_sleep(0, usecs);
-}
diff --git a/db2/os/os_stat.c b/db2/os/os_stat.c
deleted file mode 100644
index 65cba82efa..0000000000
--- a/db2/os/os_stat.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_stat.c 10.18 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * __os_exists --
- * Return if the file exists.
- *
- * PUBLIC: int __os_exists __P((const char *, int *));
- */
-int
-__os_exists(path, isdirp)
- const char *path;
- int *isdirp;
-{
- struct stat sb;
-
- if (__db_jump.j_exists != NULL)
- return (__db_jump.j_exists(path, isdirp));
-
- if (stat(path, &sb) != 0)
- return (errno);
-
-#if !defined(S_ISDIR) || defined(STAT_MACROS_BROKEN)
-#if defined(_WIN32) || defined(WIN16)
-#define S_ISDIR(m) (_S_IFDIR & (m))
-#else
-#define S_ISDIR(m) (((m) & 0170000) == 0040000)
-#endif
-#endif
- if (isdirp != NULL)
- *isdirp = S_ISDIR(sb.st_mode);
-
- return (0);
-}
-
-/*
- * __os_ioinfo --
- * Return file size and I/O size; abstracted to make it easier
- * to replace.
- *
- * PUBLIC: int __os_ioinfo
- * PUBLIC: __P((const char *, int, u_int32_t *, u_int32_t *, u_int32_t *));
- */
-int
-__os_ioinfo(path, fd, mbytesp, bytesp, iosizep)
- const char *path;
- int fd;
- u_int32_t *mbytesp, *bytesp, *iosizep;
-{
- struct stat sb;
-
- if (__db_jump.j_ioinfo != NULL)
- return (__db_jump.j_ioinfo(path, fd, mbytesp, bytesp, iosizep));
-
- if (fstat(fd, &sb) == -1)
- return (errno);
-
- /* Return the size of the file. */
- if (mbytesp != NULL)
- *mbytesp = sb.st_size / MEGABYTE;
- if (bytesp != NULL)
- *bytesp = sb.st_size % MEGABYTE;
-
- /*
- * Return the underlying filesystem blocksize, if available.
- *
- * XXX
- * Check for a 0 size -- the HP MPE/iX architecture has st_blksize,
- * but it's always 0.
- */
-#ifdef HAVE_ST_BLKSIZE
- if (iosizep != NULL && (*iosizep = sb.st_blksize) == 0)
- *iosizep = DB_DEF_IOSIZE;
-#else
- if (iosizep != NULL)
- *iosizep = DB_DEF_IOSIZE;
-#endif
- return (0);
-}
diff --git a/db2/os/os_tmpdir.c b/db2/os/os_tmpdir.c
deleted file mode 100644
index 0b0bbc7c61..0000000000
--- a/db2/os/os_tmpdir.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_tmpdir.c 10.3 (Sleepycat) 10/13/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#endif
-
-#include "db_int.h"
-#include "common_ext.h"
-
-#ifdef macintosh
-#include <TFileSpec.h>
-#endif
-
-/*
- * __os_tmpdir --
- * Set the temporary directory path.
- *
- * The order of items in the list structure and the order of checks in
- * the environment are documented.
- *
- * PUBLIC: int __os_tmpdir __P((DB_ENV *, u_int32_t));
- */
-int
-__os_tmpdir(dbenv, flags)
- DB_ENV *dbenv;
- u_int32_t flags;
-{
- /*
- * !!!
- * Don't change this to:
- *
- * static const char * const list[]
- *
- * because it creates a text relocation in position independent code.
- */
- static const char * list[] = {
- "/var/tmp",
- "/usr/tmp",
- "/temp", /* Windows. */
- "/tmp",
- "C:/temp", /* Windows. */
- "C:/tmp", /* Windows. */
- NULL
- };
- const char * const *lp, *p;
-
- /* Use the environment if it's permitted and initialized. */
- p = NULL;
-#ifdef HAVE_GETEUID
- if (LF_ISSET(DB_USE_ENVIRON) ||
- (LF_ISSET(DB_USE_ENVIRON_ROOT) && getuid() == 0))
-#else
- if (LF_ISSET(DB_USE_ENVIRON))
-#endif
- {
- if ((p = getenv("TMPDIR")) != NULL && p[0] == '\0') {
- __db_err(dbenv, "illegal TMPDIR environment variable");
- return (EINVAL);
- }
- /* Windows */
- if (p == NULL && (p = getenv("TEMP")) != NULL && p[0] == '\0') {
- __db_err(dbenv, "illegal TEMP environment variable");
- return (EINVAL);
- }
- /* Windows */
- if (p == NULL && (p = getenv("TMP")) != NULL && p[0] == '\0') {
- __db_err(dbenv, "illegal TMP environment variable");
- return (EINVAL);
- }
- /* Macintosh */
- if (p == NULL &&
- (p = getenv("TempFolder")) != NULL && p[0] == '\0') {
- __db_err(dbenv,
- "illegal TempFolder environment variable");
- return (EINVAL);
- }
- }
-
-#ifdef macintosh
- /* Get the path to the temporary folder. */
- if (p == NULL) {
- FSSpec spec;
-
- if (!Special2FSSpec(kTemporaryFolderType,
- kOnSystemDisk, 0, &spec))
- (void)__os_strdup(FSp2FullPath(&spec), &p);
- }
-#endif
-
- /* Step through the list looking for a possibility. */
- if (p == NULL)
- for (lp = list; *lp != NULL; ++lp)
- if (__os_exists(p = *lp, NULL) == 0)
- break;
- if (p == NULL)
- return (0);
-
- return (__os_strdup(p, &dbenv->db_tmp_dir));
-}
diff --git a/db2/os/os_unlink.c b/db2/os/os_unlink.c
deleted file mode 100644
index aa484de843..0000000000
--- a/db2/os/os_unlink.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997, 1998
- * Sleepycat Software. All rights reserved.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)os_unlink.c 10.7 (Sleepycat) 10/12/98";
-#endif /* not lint */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <errno.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "os_jump.h"
-
-/*
- * __os_unlink --
- * Remove a file.
- *
- * PUBLIC: int __os_unlink __P((const char *));
- */
-int
-__os_unlink(path)
- const char *path;
-{
- int ret;
-
- ret = __db_jump.j_unlink != NULL ?
- __db_jump.j_unlink(path) : unlink(path);
- return (ret == -1 ? errno : 0);
-}