Changeset 523
- Timestamp:
- 1999-09-02T21:44:30+12:00 (25 years ago)
- Location:
- trunk/gsdl/packages/wingdbm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/packages/wingdbm/global.c
r18 r523 35 35 #include "gdbmerrno.h" 36 36 37 #include <io.h> 38 #include <windows.h> 37 39 38 40 /* The global variables used for the "original" interface. */ … … 45 47 /* The dbm error number is placed in the variable GDBM_ERRNO. */ 46 48 gdbm_error gdbm_errno = GDBM_NO_ERROR; 49 50 51 /* a simple locking function for windows that uses file descriptors */ 52 int my_locking(int fh, int lmode, long lockoffset, long nbytes) { 53 int result = -1; 54 int trys = 10; 55 56 lseek (fh, lockoffset, L_SET); 57 58 while (trys > 0 && result != 0) { 59 if (lmode == MY_UNLOCK) { 60 if (UnlockFile((HANDLE)_get_osfhandle(fh),lockoffset,0,nbytes,0)) 61 result = 0; 62 63 } else if (lmode == MY_READLOCK) { 64 /* if (LockFileEx((HANDLE)_get_osfhandle(fh),0,0,nbytes,0,0))*/ 65 if (LockFile((HANDLE)_get_osfhandle(fh),lockoffset,0,nbytes,0)) 66 result = 0; 67 68 } else if (lmode == MY_WRITELOCK) { 69 if (LockFile((HANDLE)_get_osfhandle(fh),lockoffset,0,nbytes,0)) 70 result = 0; 71 } 72 73 Sleep(100L); 74 trys--; 75 } 76 77 return result; 78 } -
trunk/gsdl/packages/wingdbm/systems.h
r18 r523 100 100 101 101 #ifdef MSDOS 102 #define UNLOCK_FILE(dbf) /* later !!! */ 103 #define READLOCK_FILE(dbf) lock_val = 0; 104 #define WRITELOCK_FILE(dbf) lock_val = 0; 102 #define MY_UNLOCK 0 103 #define MY_READLOCK 1 104 #define MY_WRITELOCK 2 105 int my_locking(int fh, int lmode, long lockoffset, long nbytes); 106 107 #define UNLOCK_FILE(dbf) my_locking(dbf->desc,MY_UNLOCK,0,10) 108 #define READLOCK_FILE(dbf) lock_val=my_locking(dbf->desc,MY_READLOCK,0,10) 109 #define WRITELOCK_FILE(dbf) lock_val=my_locking(dbf->desc,MY_WRITELOCK,0,10) 110 105 111 #else 106 112 /* Assume it is done like System V. */ … … 173 179 typedef long word_t; 174 180 #endif 181 182 183 #include <io.h> 184 185 #ifdef __GNUC__ 186 #define alloca __builtin_alloca 187 #else /* not __GNUC__ */ 188 #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) 189 #include <alloca.h> 190 #else 191 #ifndef _AIX 192 char *alloca (); 193 #endif 194 #endif /* alloca.h */ 195 #endif /* not __GNUC__ */
Note:
See TracChangeset
for help on using the changeset viewer.