Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | fix OS/2 files to compile again (looking at Windows equivalents for guidance) (CVS 5239) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8b14a220f261b354e7d2d16dc3fe30c5 |
User & Date: | pweilbacher 2008-06-18 21:08:16.000 |
Context
2008-06-19
| ||
00:16 | Add some test logic to the new memory allocation subsystem. (Lots more needed.) The test suite is currently indicating memory leaks, though it is unclear if this is a true code problem or just an instrumentation problem. (CVS 5240) (check-in: cb1f11cd97 user: drh tags: trunk) | |
2008-06-18
| ||
21:08 | fix OS/2 files to compile again (looking at Windows equivalents for guidance) (CVS 5239) (check-in: 8b14a220f2 user: pweilbacher tags: trunk) | |
18:57 | Remove public APIs sqlite3_mutex_init() and sqlite3_mutex_end(). This commit only changes the code, documentation is not updated yet. (CVS 5238) (check-in: 42a2a8f493 user: danielk1977 tags: trunk) | |
Changes
Changes to src/mutex_os2.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2007 August 28 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the C functions that implement mutexes for OS/2 ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2007 August 28 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the C functions that implement mutexes for OS/2 ** ** $Id: mutex_os2.c,v 1.8 2008/06/18 21:08:16 pweilbacher Exp $ */ #include "sqliteInt.h" /* ** The code in this file is only used if SQLITE_MUTEX_OS2 is defined. ** See the mutex.h file for details. */ |
︙ | ︙ | |||
38 39 40 41 42 43 44 | }; #define OS2_MUTEX_INITIALIZER 0,0,0,0 /* ** Initialize and deinitialize the mutex subsystem. */ | | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | }; #define OS2_MUTEX_INITIALIZER 0,0,0,0 /* ** Initialize and deinitialize the mutex subsystem. */ int os2MutexInit(void){ return SQLITE_OK; } int os2MutexEnd(void){ return SQLITE_OK; } /* ** The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. If it returns NULL ** that means that a mutex could not be allocated. ** SQLite will unwind its stack and return an error. The argument ** to sqlite3_mutex_alloc() is one of these integer constants: |
︙ | ︙ | |||
80 81 82 83 84 85 86 | ** ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() ** returns a different mutex on every call. But for the static ** mutex types, the same mutex is returned on every call that has ** the same type number. */ | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | ** ** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() ** returns a different mutex on every call. But for the static ** mutex types, the same mutex is returned on every call that has ** the same type number. */ sqlite3_mutex *os2MutexAlloc(int iType){ sqlite3_mutex *p = NULL; switch( iType ){ case SQLITE_MUTEX_FAST: case SQLITE_MUTEX_RECURSIVE: { p = sqlite3MallocZero( sizeof(*p) ); if( p ){ p->id = iType; |
︙ | ︙ | |||
148 149 150 151 152 153 154 | } /* ** This routine deallocates a previously allocated mutex. ** SQLite is careful to deallocate every mutex that it allocates. */ | | | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | } /* ** This routine deallocates a previously allocated mutex. ** SQLite is careful to deallocate every mutex that it allocates. */ void os2MutexFree(sqlite3_mutex *p){ if( p==0 ) return; assert( p->nRef==0 ); assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ); DosCloseMutexSem( p->mutex ); sqlite3_free( p ); } /* ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt ** to enter a mutex. If another thread is already within the mutex, ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can ** be entered multiple times by the same thread. In such cases the, ** mutex must be exited an equal number of times before another thread ** can enter. If the same thread tries to enter any other kind of mutex ** more than once, the behavior is undefined. */ void os2MutexEnter(sqlite3_mutex *p){ TID tid; PID holder1; ULONG holder2; if( p==0 ) return; assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) ); DosRequestMutexSem(p->mutex, SEM_INDEFINITE_WAIT); DosQueryMutexSem(p->mutex, &holder1, &tid, &holder2); p->owner = tid; p->nRef++; } int os2MutexTry(sqlite3_mutex *p){ int rc; TID tid; PID holder1; ULONG holder2; if( p==0 ) return SQLITE_OK; assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) ); if( DosRequestMutexSem(p->mutex, SEM_IMMEDIATE_RETURN) == NO_ERROR) { |
︙ | ︙ | |||
203 204 205 206 207 208 209 | /* ** The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. The behavior ** is undefined if the mutex is not currently entered or ** is not currently allocated. SQLite will never do either. */ | | | | > > > > > > > > > > > > > > > > > | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | /* ** The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. The behavior ** is undefined if the mutex is not currently entered or ** is not currently allocated. SQLite will never do either. */ void os2MutexLeave(sqlite3_mutex *p){ TID tid; PID holder1; ULONG holder2; if( p==0 ) return; assert( p->nRef>0 ); DosQueryMutexSem(p->mutex, &holder1, &tid, &holder2); assert( p->owner==tid ); p->nRef--; assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE ); DosReleaseMutexSem(p->mutex); } /* ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are ** intended for use inside assert() statements. */ int os2MutexHeld(sqlite3_mutex *p){ TID tid; PID pid; ULONG ulCount; PTIB ptib; if( p!=0 ) { DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount); } else { DosGetInfoBlocks(&ptib, NULL); tid = ptib->tib_ptib2->tib2_ultid; } return p==0 || (p->nRef!=0 && p->owner==tid); } int os2MutexNotheld(sqlite3_mutex *p){ TID tid; PID pid; ULONG ulCount; PTIB ptib; if( p!= 0 ) { DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount); } else { DosGetInfoBlocks(&ptib, NULL); tid = ptib->tib_ptib2->tib2_ultid; } return p==0 || p->nRef==0 || p->owner!=tid; } sqlite3_mutex_methods *sqlite3DefaultMutex(void){ static sqlite3_mutex_methods sMutex = { os2MutexInit, os2MutexAlloc, os2MutexFree, os2MutexEnter, os2MutexTry, os2MutexLeave, os2MutexEnd, os2MutexHeld, os2MutexNotheld }; return &sMutex; } #endif /* SQLITE_MUTEX_OS2 */ |
Changes to src/os_os2.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to OS/2. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains code that is specific to OS/2. ** ** $Id: os_os2.c,v 1.44 2008/06/18 21:08:16 pweilbacher Exp $ */ #include "sqliteInt.h" #if OS_OS2 /* |
︙ | ︙ | |||
691 692 693 694 695 696 697 | ULONG ulFileAttribute = 0; ULONG ulOpenFlags = 0; ULONG ulOpenMode = 0; os2File *pFile = (os2File*)id; APIRET rc = NO_ERROR; ULONG ulAction; char *zNameCp; | | | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | ULONG ulFileAttribute = 0; ULONG ulOpenFlags = 0; ULONG ulOpenMode = 0; os2File *pFile = (os2File*)id; APIRET rc = NO_ERROR; ULONG ulAction; char *zNameCp; char zTmpname[CCHMAXPATH+1]; /* Buffer to hold name of temp file */ /* If the second argument to this function is NULL, generate a ** temporary file name to use */ if( !zName ){ int rc = getTempname(CCHMAXPATH+1, zTmpname); if( rc!=SQLITE_OK ){ return rc; } zName = zTmpname; } |
︙ | ︙ | |||
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 | #ifdef SQLITE_TEST if( sqlite3_current_time ){ *prNow = sqlite3_current_time/86400.0 + 2440587.5; } #endif return 0; } /* ** Return a pointer to the sqlite3DefaultVfs structure. We use ** a function rather than give the structure global scope because ** some compilers (MSVC) do not allow forward declarations of ** initialized structures. */ | > > > > | 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | #ifdef SQLITE_TEST if( sqlite3_current_time ){ *prNow = sqlite3_current_time/86400.0 + 2440587.5; } #endif return 0; } static int os2GetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ return 0; } /* ** Return a pointer to the sqlite3DefaultVfs structure. We use ** a function rather than give the structure global scope because ** some compilers (MSVC) do not allow forward declarations of ** initialized structures. */ |
︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 | os2FullPathname, /* xFullPathname */ os2DlOpen, /* xDlOpen */ os2DlError, /* xDlError */ os2DlSym, /* xDlSym */ os2DlClose, /* xDlClose */ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ | | | 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 | os2FullPathname, /* xFullPathname */ os2DlOpen, /* xDlOpen */ os2DlError, /* xDlError */ os2DlSym, /* xDlSym */ os2DlClose, /* xDlClose */ os2Randomness, /* xRandomness */ os2Sleep, /* xSleep */ os2CurrentTime, /* xCurrentTime */ os2GetLastError /* xGetLastError */ }; return &os2Vfs; } /* |
︙ | ︙ |