1N/A/*-
1N/A * See the file LICENSE for redistribution information.
1N/A *
1N/A * Copyright (c) 1997, 1998
1N/A * Sleepycat Software. All rights reserved.
1N/A */
1N/A
1N/A#include "config.h"
1N/A
1N/A#ifndef lint
1N/Astatic const char sccsid[] = "@(#)os_config.c 10.30 (Sleepycat) 10/12/98";
1N/A#endif /* not lint */
1N/A
1N/A#ifndef NO_SYSTEM_INCLUDES
1N/A#include <sys/types.h>
1N/A
1N/A#include <errno.h>
1N/A#endif
1N/A
1N/A#include "db_int.h"
1N/A#include "os_jump.h"
1N/A
1N/Astruct __db_jumptab __db_jump;
1N/A
1N/ADB_GLOBALS __db_global_values = {
1N/A 1, /* DB_MUTEXLOCKS */
1N/A 0, /* DB_PAGEYIELD */
1N/A 0, /* DB_REGION_ANON, DB_REGION_NAME */
1N/A 0, /* DB_REGION_INIT */
1N/A 0, /* DB_TSL_SPINS */
1N/A {NULL, &__db_global_values.db_envq.tqh_first}, /* Environemnt queue */
1N/A {NULL, &__db_global_values.db_nameq.tqh_first} /* Name queue */
1N/A};
1N/A
1N/A/*
1N/A * db_jump_set --
1N/A * Replace functions for the DB package.
1N/A */
1N/Aint
1N/Adb_jump_set(func, which)
1N/A void *func;
1N/A int which;
1N/A{
1N/A switch (which) {
1N/A case DB_FUNC_CLOSE:
1N/A __db_jump.j_close = (int (*) __P((int)))func;
1N/A break;
1N/A case DB_FUNC_DIRFREE:
1N/A __db_jump.j_dirfree = (void (*) __P((char **, int)))func;
1N/A break;
1N/A case DB_FUNC_DIRLIST:
1N/A __db_jump.j_dirlist =
1N/A (int (*) __P((const char *, char ***, int *)))func;
1N/A break;
1N/A case DB_FUNC_EXISTS:
1N/A __db_jump.j_exists = (int (*) __P((const char *, int *)))func;
1N/A break;
1N/A case DB_FUNC_FREE:
1N/A __db_jump.j_free = (void (*) __P((void *)))func;
1N/A break;
1N/A case DB_FUNC_FSYNC:
1N/A __db_jump.j_fsync = (int (*) __P((int)))func;
1N/A break;
1N/A case DB_FUNC_IOINFO:
1N/A __db_jump.j_ioinfo = (int (*) __P((const char *,
1N/A int, u_int32_t *, u_int32_t *, u_int32_t *)))func;
1N/A break;
1N/A case DB_FUNC_MALLOC:
1N/A __db_jump.j_malloc = (void *(*) __P((size_t)))func;
1N/A break;
1N/A case DB_FUNC_MAP:
1N/A __db_jump.j_map = (int (*)
1N/A __P((char *, int, size_t, int, int, int, void **)))func;
1N/A break;
1N/A case DB_FUNC_OPEN:
1N/A __db_jump.j_open = (int (*) __P((const char *, int, ...)))func;
1N/A break;
1N/A case DB_FUNC_READ:
1N/A __db_jump.j_read =
1N/A (ssize_t (*) __P((int, void *, size_t)))func;
1N/A break;
1N/A case DB_FUNC_REALLOC:
1N/A __db_jump.j_realloc = (void *(*) __P((void *, size_t)))func;
1N/A break;
1N/A case DB_FUNC_RUNLINK:
1N/A __db_jump.j_runlink = (int (*) __P((char *)))func;
1N/A break;
1N/A case DB_FUNC_SEEK:
1N/A __db_jump.j_seek = (int (*)
1N/A __P((int, size_t, db_pgno_t, u_int32_t, int, int)))func;
1N/A break;
1N/A case DB_FUNC_SLEEP:
1N/A __db_jump.j_sleep = (int (*) __P((u_long, u_long)))func;
1N/A break;
1N/A case DB_FUNC_UNLINK:
1N/A __db_jump.j_unlink = (int (*) __P((const char *)))func;
1N/A break;
1N/A case DB_FUNC_UNMAP:
1N/A __db_jump.j_unmap = (int (*) __P((void *, size_t)))func;
1N/A break;
1N/A case DB_FUNC_WRITE:
1N/A __db_jump.j_write =
1N/A (ssize_t (*) __P((int, const void *, size_t)))func;
1N/A break;
1N/A case DB_FUNC_YIELD:
1N/A __db_jump.j_yield = (int (*) __P((void)))func;
1N/A break;
1N/A default:
1N/A return (EINVAL);
1N/A }
1N/A return (0);
1N/A}
1N/A
1N/A/*
1N/A * db_value_set --
1N/A * Replace values for the DB package.
1N/A */
1N/Aint
1N/Adb_value_set(value, which)
1N/A int value, which;
1N/A{
1N/A int ret;
1N/A
1N/A switch (which) {
1N/A case DB_MUTEXLOCKS:
1N/A DB_GLOBAL(db_mutexlocks) = value;
1N/A break;
1N/A case DB_PAGEYIELD:
1N/A DB_GLOBAL(db_pageyield) = value;
1N/A break;
1N/A case DB_REGION_ANON:
1N/A if (value != 0 && (ret = __db_mapanon_ok(0)) != 0)
1N/A return (ret);
1N/A DB_GLOBAL(db_region_anon) = value;
1N/A break;
1N/A case DB_REGION_INIT:
1N/A DB_GLOBAL(db_region_init) = value;
1N/A break;
1N/A case DB_REGION_NAME:
1N/A if (value != 0 && (ret = __db_mapanon_ok(1)) != 0)
1N/A return (ret);
1N/A DB_GLOBAL(db_region_anon) = value;
1N/A break;
1N/A case DB_TSL_SPINS:
1N/A if (value <= 0)
1N/A return (EINVAL);
1N/A DB_GLOBAL(db_tsl_spins) = value;
1N/A break;
1N/A default:
1N/A return (EINVAL);
1N/A }
1N/A return (0);
1N/A}