2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid
[] = "@(#)os_config.c 10.26 (Sleepycat) 5/23/98";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
24 * We provide our own extern declarations so that we don't collide with
25 * systems that get them wrong, e.g., SunOS.
29 #define imported __declspec(dllimport)
36 * HP/UX MPE doesn't have fsync, but you can build one using FCONTROL.
39 #define fsync __mpe_fsync
42 imported
extern int close
__P((int));
43 imported
extern void free
__P((void *));
44 imported
extern int fsync
__P((int));
45 imported
extern void *malloc
__P((size_t));
46 imported
extern int open
__P((const char *, int, ...));
47 imported
extern ssize_t read
__P((int, void *, size_t));
48 imported
extern void *realloc
__P((void *, size_t));
49 imported
extern int unlink
__P((const char *));
50 imported
extern ssize_t write
__P((int, const void *, size_t));
54 * This list of interfaces that applications can replace. In some
55 * cases, the user is permitted to replace the standard ANSI C or
56 * POSIX 1003.1 call, e.g., malloc or read. In others, we provide
57 * a local interface to the functionality, e.g., __os_ioinfo.
59 struct __db_jumptab __db_jump
= {
60 close
, /* DB_FUNC_CLOSE */
61 __os_dirfree
, /* DB_FUNC_DIRFREE */
62 __os_dirlist
, /* DB_FUNC_DIRLIST */
63 __os_exists
, /* DB_FUNC_EXISTS */
64 free
, /* DB_FUNC_FREE */
65 fsync
, /* DB_FUNC_FSYNC */
66 __os_ioinfo
, /* DB_FUNC_IOINFO */
67 malloc
, /* DB_FUNC_MALLOC */
68 NULL
, /* DB_FUNC_MAP */
69 open
, /* DB_FUNC_OPEN */
70 read
, /* DB_FUNC_READ */
71 realloc
, /* DB_FUNC_REALLOC */
72 NULL
, /* DB_FUNC_RUNLINK */
73 __os_seek
, /* DB_FUNC_SEEK */
74 __os_sleep
, /* DB_FUNC_SLEEP */
75 unlink
, /* DB_FUNC_UNLINK */
76 NULL
, /* DB_FUNC_UNMAP */
77 write
, /* DB_FUNC_WRITE */
78 NULL
/* DB_FUNC_YIELD */
81 DB_GLOBALS __db_global_values
= {
82 1, /* DB_MUTEXLOCKS */
83 0, /* DB_REGION_ANON, DB_REGION_NAME */
84 0, /* DB_REGION_INIT */
91 * Replace functions for the DB package.
94 db_jump_set(func
, which
)
100 __db_jump
.j_close
= (int (*) __P((int)))func
;
102 case DB_FUNC_DIRFREE
:
103 __db_jump
.j_dirfree
= (void (*) __P((char **, int)))func
;
105 case DB_FUNC_DIRLIST
:
106 __db_jump
.j_dirlist
=
107 (int (*) __P((const char *, char ***, int *)))func
;
110 __db_jump
.j_exists
= (int (*) __P((const char *, int *)))func
;
113 __db_jump
.j_free
= (void (*) __P((void *)))func
;
116 __db_jump
.j_fsync
= (int (*) __P((int)))func
;
119 __db_jump
.j_ioinfo
= (int (*) __P((const char *,
120 int, u_int32_t
*, u_int32_t
*, u_int32_t
*)))func
;
123 __db_jump
.j_malloc
= (void *(*) __P((size_t)))func
;
126 __db_jump
.j_map
= (int (*)
127 __P((char *, int, size_t, int, int, int, void **)))func
;
130 __db_jump
.j_open
= (int (*) __P((const char *, int, ...)))func
;
134 (ssize_t (*) __P((int, void *, size_t)))func
;
136 case DB_FUNC_REALLOC
:
137 __db_jump
.j_realloc
= (void *(*) __P((void *, size_t)))func
;
139 case DB_FUNC_RUNLINK
:
140 __db_jump
.j_runlink
= (int (*) __P((char *)))func
;
143 __db_jump
.j_seek
= (int (*)
144 __P((int, size_t, db_pgno_t
, u_int32_t
, int, int)))func
;
147 __db_jump
.j_sleep
= (int (*) __P((u_long
, u_long
)))func
;
150 __db_jump
.j_unlink
= (int (*) __P((const char *)))func
;
153 __db_jump
.j_unmap
= (int (*) __P((void *, size_t)))func
;
157 (ssize_t (*) __P((int, const void *, size_t)))func
;
160 __db_jump
.j_yield
= (int (*) __P((void)))func
;
170 * Replace values for the DB package.
173 db_value_set(value
, which
)
180 DB_GLOBAL(db_mutexlocks
) = value
;
183 DB_GLOBAL(db_pageyield
) = value
;
186 if (value
!= 0 && (ret
= __db_mapanon_ok(0)) != 0)
188 DB_GLOBAL(db_region_anon
) = value
;
191 DB_GLOBAL(db_region_init
) = value
;
194 if (value
!= 0 && (ret
= __db_mapanon_ok(1)) != 0)
196 DB_GLOBAL(db_region_anon
) = value
;
201 DB_GLOBAL(db_tsl_spins
) = value
;