2 * See the file LICENSE for redistribution information.
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid[] = "@(#)os_func.c 10.4 (Sleepycat) 10/28/97";
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)
34 imported extern void *calloc __P((size_t, size_t));
35 imported extern int close __P((int));
36 imported extern void free __P((void *));
37 imported extern int fsync __P((int));
38 imported extern void *malloc __P((size_t));
39 imported extern int open __P((const char *, int, ...));
40 imported extern ssize_t read __P((int, void *, size_t));
41 imported extern char *strdup __P((const char *));
42 imported extern void *realloc __P((void *, size_t));
43 imported extern int unlink __P((const char *));
44 imported extern ssize_t write __P((int, const void *, size_t));
48 * This list of interfaces that applications can replace. In some
49 * cases, the user is permitted to replace the standard ANSI C or
50 * POSIX 1003.1 call, e.g., calloc or read. In others, we provide
51 * a local interface to the functionality, e.g., __os_map.
53 struct __db_jumptab __db_jump = {
54 calloc, /* DB_FUNC_CALLOC */
55 close, /* DB_FUNC_CLOSE */
56 __os_dirfree, /* DB_FUNC_DIRFREE */
57 __os_dirlist, /* DB_FUNC_DIRLIST */
58 __os_exists, /* DB_FUNC_EXISTS */
59 free, /* DB_FUNC_FREE */
60 fsync, /* DB_FUNC_FSYNC */
61 __os_ioinfo, /* DB_FUNC_IOINFO */
62 malloc, /* DB_FUNC_MALLOC */
63 __os_map, /* DB_FUNC_MAP */
64 open, /* DB_FUNC_OPEN */
65 read, /* DB_FUNC_READ */
66 realloc, /* DB_FUNC_REALLOC */
67 __os_seek, /* DB_FUNC_SEEK */
68 __os_sleep, /* DB_FUNC_SLEEP */
69 strdup, /* DB_FUNC_STRDUP */
70 unlink, /* DB_FUNC_UNLINK */
71 __os_unmap, /* DB_FUNC_UNMAP */
72 write, /* DB_FUNC_WRITE */
73 NULL /* DB_FUNC_YIELD */
78 * Replace an interface.
81 db_jump_set(func, which)
87 __db_calloc = (void *(*) __P((size_t, size_t)))func;
90 __os_close = (int (*) __P((int)))func;
93 __db_dirfree = (void (*) __P((char **, int)))func;
97 (int (*) __P((const char *, char ***, int *)))func;
100 __db_exists = (int (*) __P((const char *, int *)))func;
103 __db_free = (void (*) __P((void *)))func;
106 __os_fsync = (int (*) __P((int)))func;
110 (int (*) __P((const char *, int, off_t *, off_t *)))func;
113 __db_malloc = (void *(*) __P((size_t)))func;
116 __db_map = (int (*) __P((int, size_t, int, int, void **)))func;
119 __os_open = (int (*) __P((const char *, int, ...)))func;
122 __os_read = (ssize_t (*) __P((int, void *, size_t)))func;
124 case DB_FUNC_REALLOC:
125 __db_realloc = (void *(*) __P((void *, size_t)))func;
129 (int (*) __P((int, size_t, db_pgno_t, u_long, int)))func;
132 __db_sleep = (int (*) __P((u_long, u_long)))func;
135 __db_strdup = (char *(*) __P((const char *)))func;
138 __os_unlink = (int (*) __P((const char *)))func;
141 __db_unmap = (int (*) __P((void *, size_t)))func;
144 __os_write = (ssize_t (*) __P((int, const void *, size_t)))func;
147 __db_yield = (int (*) __P((void)))func;