1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Invoke the unix open() system call through a wrapper to avoid problems

resulting from differing declarations to that function in various systems.

FossilOrigin-Name: 4c7ff4dd352276e9c01cc536e188cbcd69396952
This commit is contained in:
drh
2011-04-25 18:01:27 +00:00
parent 713de341a7
commit 9a3baf10ca
3 changed files with 21 additions and 9 deletions

View File

@@ -281,6 +281,18 @@ struct unixFile {
#define threadid 0
#endif
/*
** Different Unix systems declare open() in different ways. Same use
** open(const char*,int,mode_t). Others use open(const char*,int,...).
** The difference is important when using a pointer to the function.
**
** The safest way to deal with the problem is to always use this wrapper
** which always has the same well-defined interface.
*/
static int posixOpen(const char *zFile, int flags, int mode){
return open(zFile, flags, mode);
}
/*
** Many system calls are accessed through pointer-to-functions so that
** they may be overridden at runtime to facilitate fault injection during
@@ -292,8 +304,8 @@ static struct unix_syscall {
sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
sqlite3_syscall_ptr pDefault; /* Default value */
} aSyscall[] = {
{ "open", (sqlite3_syscall_ptr)open, 0 },
#define osOpen ((int(*)(const char*,int,...))aSyscall[0].pCurrent)
{ "open", (sqlite3_syscall_ptr)posixOpen, 0 },
#define osOpen ((int(*)(const char*,int,int))aSyscall[0].pCurrent)
{ "close", (sqlite3_syscall_ptr)close, 0 },
#define osClose ((int(*)(int))aSyscall[1].pCurrent)