home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_04 / 8n04086b < prev    next >
Text File  |  1990-03-20  |  1KB  |  44 lines

  1. *****Listing 3*****
  2.  
  3. #ifndef RWSEM_H        /* prevent multiple includes */
  4. #define RWSEM_H
  5.  
  6. #include <limits.h>
  7. #include "semaphor.h"
  8.  
  9. /* constants */
  10. #define RWSOPEN_MAX    SEMOPEN_MAX    /* max # rwsem sets open at once */
  11.  
  12. /* type definitions */
  13. typedef struct {            /* rwsem set control structure */
  14.     char rwsdir[PATH_MAX + 1];    /* directory */
  15.     int rwsc;            /* r/w semaphore count */
  16.     semset_t *ssp;            /* semaphore set */
  17.     short *lockheld;        /* locks held by calling process */
  18. } rwsset_t;
  19.  
  20. /* function declarations */
  21. int        rwsclose(rwsset_t *rwsp);
  22. #define        rwscount(rwsp)    ((rwsp)->rwsc)
  23. int        rwslock(rwsset_t *rwsp, int rwsno, int ltype);
  24. rwsset_t *    rwsopen(char *rwsdir, int flags, int rwsc);
  25. int        rwsremove(char *rwsdir);
  26.  
  27. /* rwsopen command flags */
  28. #define RWS_CREAT    (01000)        /* create and open */
  29. #define RWS_EXCL    (02000)        /* exclusive open */
  30.  
  31. /* lock types */
  32. #define RWS_UNLCK    (0)        /* unlock */
  33. #define RWS_RDLCK    (1)        /* read lock */
  34. #define RWS_WRLCK    (2)        /* write lock */
  35.  
  36. /* error codes */
  37. #define RWSEOS        (-20)        /* start of error code domain */
  38. #define RWSEMFILE    (RWSEOS - 1)    /* too many rwsem sets open */
  39. #define RWSPANIC    (RWSEOS - 2)    /* internal rwsem error */
  40.  
  41. #endif    /* #ifndef RWSEM_H */
  42.  
  43.  
  44.