Back to index

lightning-sunbird  0.9+nobinonly
os_unix.h
Go to the documentation of this file.
00001 /*
00002 ** 2004 May 22
00003 **
00004 ** The author disclaims copyright to this source code.  In place of
00005 ** a legal notice, here is a blessing:
00006 **
00007 **    May you do good and not evil.
00008 **    May you find forgiveness for yourself and forgive others.
00009 **    May you share freely, never taking more than you give.
00010 **
00011 ******************************************************************************
00012 **
00013 ** This header file defined OS-specific features for Unix.
00014 */
00015 #ifndef _SQLITE_OS_UNIX_H_
00016 #define _SQLITE_OS_UNIX_H_
00017 
00018 /*
00019 ** Helpful hint:  To get this to compile on HP/UX, add -D_INCLUDE_POSIX_SOURCE
00020 ** to the compiler command line.
00021 */
00022 
00023 /*
00024 ** These #defines should enable >2GB file support on Posix if the
00025 ** underlying operating system supports it.  If the OS lacks
00026 ** large file support, or if the OS is windows, these should be no-ops.
00027 **
00028 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
00029 ** on the compiler command line.  This is necessary if you are compiling
00030 ** on a recent machine (ex: RedHat 7.2) but you want your code to work
00031 ** on an older machine (ex: RedHat 6.0).  If you compile on RedHat 7.2
00032 ** without this option, LFS is enable.  But LFS does not exist in the kernel
00033 ** in RedHat 6.0, so the code won't work.  Hence, for maximum binary
00034 ** portability you should omit LFS.
00035 **
00036 ** Similar is true for MacOS.  LFS is only supported on MacOS 9 and later.
00037 */
00038 #ifndef SQLITE_DISABLE_LFS
00039 # define _LARGE_FILE       1
00040 # ifndef _FILE_OFFSET_BITS
00041 #   define _FILE_OFFSET_BITS 64
00042 # endif
00043 # define _LARGEFILE_SOURCE 1
00044 #endif
00045 
00046 /*
00047 ** standard include files.
00048 */
00049 #include <sys/types.h>
00050 #include <sys/stat.h>
00051 #include <fcntl.h>
00052 #include <unistd.h>
00053 
00054 /*
00055 ** Macros used to determine whether or not to use threads.  The
00056 ** SQLITE_UNIX_THREADS macro is defined if we are synchronizing for
00057 ** Posix threads and SQLITE_W32_THREADS is defined if we are
00058 ** synchronizing using Win32 threads.
00059 */
00060 #if defined(THREADSAFE) && THREADSAFE
00061 # include <pthread.h>
00062 # define SQLITE_UNIX_THREADS 1
00063 #endif
00064 
00065 /*
00066 ** The OsFile structure is a operating-system independing representation
00067 ** of an open file handle.  It is defined differently for each architecture.
00068 **
00069 ** This is the definition for Unix.
00070 **
00071 ** OsFile.locktype takes one of the values SHARED_LOCK, RESERVED_LOCK,
00072 ** PENDING_LOCK or EXCLUSIVE_LOCK.
00073 */
00074 typedef struct OsFile OsFile;
00075 struct OsFile {
00076   struct Pager *pPager;     /* The pager that owns this OsFile.  Might be 0 */
00077   struct openCnt *pOpen;    /* Info about all open fd's on this inode */
00078   struct lockInfo *pLock;   /* Info about locks on this inode */
00079   int h;                    /* The file descriptor */
00080   unsigned char locktype;   /* The type of lock held on this fd */
00081   unsigned char isOpen;     /* True if needs to be closed */
00082   unsigned char fullSync;   /* Use F_FULLSYNC if available */
00083   int dirfd;                /* File descriptor for the directory */
00084 #ifdef SQLITE_UNIX_THREADS
00085   pthread_t tid;            /* The thread authorized to use this OsFile */
00086 #endif
00087 };
00088 
00089 /*
00090 ** A macro to set the OsFile.fullSync flag, if it exists.
00091 */
00092 #define SET_FULLSYNC(x,y)  ((x).fullSync = (y))
00093 
00094 /*
00095 ** Maximum number of characters in a temporary file name
00096 */
00097 #define SQLITE_TEMPNAME_SIZE 200
00098 
00099 /*
00100 ** Minimum interval supported by sqlite3OsSleep().
00101 */
00102 #if defined(HAVE_USLEEP) && HAVE_USLEEP
00103 # define SQLITE_MIN_SLEEP_MS 1
00104 #else
00105 # define SQLITE_MIN_SLEEP_MS 1000
00106 #endif
00107 
00108 /*
00109 ** Default permissions when creating a new file
00110 */
00111 #ifndef SQLITE_DEFAULT_FILE_PERMISSIONS
00112 # define SQLITE_DEFAULT_FILE_PERMISSIONS 0644
00113 #endif
00114 
00115 
00116 #endif /* _SQLITE_OS_UNIX_H_ */