Changeset 609


Ignore:
Timestamp:
1999-09-21T23:36:42+12:00 (25 years ago)
Author:
sjboddie
Message:

tidied up file locking stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/gsdlconf.h

    r595 r609  
    3333// Note: all macros used in the gsdl software (except the _H macros) should
    3434// now start with GSDL_
    35 
    3635
    3736// GSDL_NEED_STRINGS_H should be defined if some string functions
     
    8079
    8180#if defined(__WIN32__)
    82 #define MY_UNLOCK    0
    83 #define MY_READLOCK  1
    84 #define MY_WRITELOCK 2
    85 int my_locking(int fd, int lmode, long lockoffset, long nbytes);
    86 
    87 #define UNLOCK_FILE(fd)    my_locking(fd, MY_UNLOCK, 0, 10)
    88 #define READLOCK_FILE(fd)  lock_val = my_locking(fd, MY_READLOCK, 0, 10)
    89 #define WRITELOCK_FILE(fd) lock_val = my_locking(fd, MY_WRITELOCK, 0, 10)
     81#include <io.h>
     82#include <sys/locking.h>
     83#define GSDL_GET_FILEDESC(str) str.fd()
     84#define GSDL_UNLOCK_FILE(fd) _locking(fd, LK_UNLCK, 200)
     85#define GSDL_LOCK_FILE(fd) lock_val = _locking(fd, LK_NBLCK, 200)
    9086
    9187#else
     88#define GSDL_GET_FILEDESC(str) str.filedesc()
    9289
    9390#if GSDL_USE_FLOCK
     
    110107#endif
    111108
    112 #define UNLOCK_FILE(fd) flock (fd, LOCK_UN)
    113 #define READLOCK_FILE(fd) lock_val = flock (fd, LOCK_SH + LOCK_NB)
    114 #define WRITELOCK_FILE(fd) lock_val = flock (fd, LOCK_EX + LOCK_NB)
     109#define GSDL_UNLOCK_FILE(fd) flock (fd, LOCK_UN)
     110#define GSDL_LOCK_FILE(fd) lock_val = flock (fd, LOCK_EX + LOCK_NB)
    115111
    116112#else
    117113// use fcntl
    118114#include <fcntl.h>
    119 #define UNLOCK_FILE(fd) \
     115#define GSDL_UNLOCK_FILE(fd) \
    120116    {                   \
    121117      struct flock flock;           \
     
    125121      fcntl (fd, F_SETLK, &flock);  \
    126122    }
    127 #define READLOCK_FILE(fd) \
    128     {                   \
    129       struct flock flock;           \
    130       flock.l_type = F_RDLCK;       \
    131       flock.l_whence = SEEK_SET;            \
    132       flock.l_start = flock.l_len = 0L; \
    133       lock_val = fcntl (fd, F_SETLK, &flock);   \
    134     }
    135 #define WRITELOCK_FILE(fd) \
     123#define GSDL_LOCK_FILE(fd) \
    136124    {                   \
    137125      struct flock flock;           \
Note: See TracChangeset for help on using the changeset viewer.