home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / os2apipm.zip / OS2API / OS2-SEM.ADS < prev    next >
Text File  |  1996-07-18  |  6KB  |  187 lines

  1.  
  2. -- ╔═══════════════════════════════════════════════════════════════════╗
  3. -- ║       D E S I G N   E N G I N E R I N G              ║D║S║        ║
  4. -- ║            S O F T W A R E                           ╚═╩═╝        ║
  5. -- ║                                                                   ║
  6. -- ║        Package  OS2.SEM                                           ║
  7. -- ║                                                                   ║
  8. -- ║        Author :  Leonid Dulman     1995                           ║
  9. -- ║                                                                   ║
  10. -- ║             GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS            ║
  11. -- ║                                                                   ║
  12. -- ║             synchronization                                       ║
  13. -- ║                                                                   ║
  14. -- ╚═══════════════════════════════════════════════════════════════════╝
  15.  
  16.  
  17. with Interfaces.C;          use Interfaces.C;
  18. with Interfaces.C.Strings; use Interfaces.C.Strings;
  19. -- with System;                use System;
  20. -- with System.OS2Lib.Threads; use System.OS2Lib.Threads;
  21.  
  22. package os2.sem is
  23. pragma Preelaborate (Sem);
  24.  
  25.    --  Semaphore Attributes
  26.  
  27.    DC_SEM_SHARED : constant := 16#01#;
  28.    --  DosCreateMutex, DosCreateEvent, and DosCreateMuxWait use it to indicate
  29.    --  whether the semaphore is shared or private when the PSZ is null
  30.  
  31.    DCMW_WAIT_ANY : constant := 16#02#;
  32.    --  DosCreateMuxWait option for wait on any event/mutex to occur
  33.  
  34.    DCMW_WAIT_ALL : constant := 16#04#;
  35.    --  DosCreateMuxWait option for wait on all events/mutexes to occur
  36.  
  37.    SEM_INDEFINITE_WAIT  : constant ULONG := -1;
  38.    SEM_IMMEDIATE_RETURN : constant ULONG :=  0;
  39.  
  40. -- subtype HSEM is System.Address;
  41. -- type PHSEM is access all HSEM;
  42.  
  43.    type SEMRECORD is
  44.       record
  45.          hsemCur : HSEM;
  46.          ulUser  : ULONG;
  47.       end record;
  48.    type PSEMRECORD is access all SEMRECORD;
  49.  
  50.  
  51.    subtype HEV is ulong;
  52.    type PHEV is access all HEV;
  53.  
  54.    subtype HMTX is ulong;
  55.    type PHMTX is access all HMTX;
  56.    subtype HMUX is ulong;
  57.    type PHMUX is access all HMUX;
  58.  
  59.    function DosCreateEventSem
  60.      (pszName   : PSZ;
  61.       f_phev    : PHEV;
  62.       flAttr    : ULONG;
  63.       fState    : BOOL32)
  64.       return      APIRET;
  65.    pragma Import (C, DosCreateEventSem, Link_Name => "_DosCreateEventSem");
  66.  
  67.    function DosOpenEventSem
  68.      (pszName   : PSZ;
  69.       F_phev    : PHEV)
  70.       return      APIRET;
  71.    pragma Import (C, DosOpenEventSem, Link_Name => "_DosOpenEventSem");
  72.  
  73.    function DosCloseEventSem
  74.      (F_hev     : HEV)
  75.       return      APIRET;
  76.    pragma Import (C, DosCloseEventSem, Link_Name => "_DosCloseEventSem");
  77.  
  78.    function DosResetEventSem
  79.      (F_hev     : HEV;
  80.       pulPostCt : PULONG)
  81.       return      APIRET;
  82.    pragma Import (C, DosResetEventSem, Link_Name => "_DosResetEventSem");
  83.  
  84.    function DosPostEventSem
  85.      (F_hev     : HEV)
  86.       return      APIRET;
  87.    pragma Import (C, DosPostEventSem, Link_Name => "_DosPostEventSem");
  88.  
  89.    function DosWaitEventSem
  90.      (F_hev     : HEV;
  91.       ulTimeout : ULONG)
  92.       return      APIRET;
  93.    pragma Import (C, DosWaitEventSem, Link_Name => "_DosWaitEventSem");
  94.  
  95.    function DosQueryEventSem
  96.      (F_hev     : HEV;
  97.       pulPostCt : PULONG)
  98.       return      APIRET;
  99.    pragma Import (C, DosQueryEventSem, Link_Name => "_DosQueryEventSem");
  100.  
  101.    function DosCreateMutexSem
  102.      (pszName   : PSZ;
  103.       F_phmtx   : PHMTX;
  104.       flAttr    : ULONG;
  105.       fState    : BOOL32)
  106.       return      APIRET;
  107.    pragma Import (C, DosCreateMutexSem, Link_Name => "_DosCreateMutexSem");
  108.  
  109.    function DosOpenMutexSem
  110.      (pszName   : PSZ;
  111.       F_phmtx   : PHMTX)
  112.       return      APIRET;
  113.    pragma Import (C, DosOpenMutexSem, Link_Name => "_DosOpenMutexSem");
  114.  
  115.    function DosCloseMutexSem
  116.      (F_hmtx    : HMTX)
  117.       return      APIRET;
  118.    pragma Import (C, DosCloseMutexSem, Link_Name => "_DosCloseMutexSem");
  119.  
  120.    function DosRequestMutexSem
  121.      (F_hmtx    : HMTX;
  122.       ulTimeout : ULONG)
  123.       return      APIRET;
  124.    pragma Import (C, DosRequestMutexSem, Link_Name => "_DosRequestMutexSem");
  125.  
  126.    function DosReleaseMutexSem
  127.      (F_hmtx    : HMTX)
  128.       return      APIRET;
  129.    pragma Import (C, DosReleaseMutexSem, Link_Name => "_DosReleaseMutexSem");
  130.  
  131.    function DosQueryMutexSem
  132.      (F_hmtx    : HMTX;
  133.       F_ppid    : PPID;
  134.       F_ptid    : PTID;
  135.       pulCount  : PULONG)
  136.       return      APIRET;
  137.    pragma Import (C, DosQueryMutexSem, Link_Name => "_DosQueryMutexSem");
  138.  
  139.    function DosCreateMuxWaitSem
  140.      (pszName   : PSZ;
  141.       F_phmux   : PHMUX;
  142.       cSemRec   : ULONG;
  143.       pSemRec   : PSEMRECORD;
  144.       flAttr    : ULONG)
  145.       return      APIRET;
  146.    pragma Import (C, DosCreateMuxWaitSem, Link_Name => "_DosCreateMuxWaitSem");
  147.  
  148.    function DosOpenMuxWaitSem
  149.      (pszName   : PSZ;
  150.       F_phmux   : PHMUX)
  151.       return      APIRET;
  152.    pragma Import (C, DosOpenMuxWaitSem, Link_Name => "_DosOpenMuxWaitSem");
  153.  
  154.    function DosCloseMuxWaitSem
  155.      (F_hmux    : HMUX)
  156.       return      APIRET;
  157.    pragma Import (C, DosCloseMuxWaitSem, Link_Name => "_DosCloseMuxWaitSem");
  158.  
  159.    function DosWaitMuxWaitSem
  160.      (F_hmux    : HMUX;
  161.       ulTimeout : ULONG;
  162.       pulUser   : PULONG)
  163.       return      APIRET;
  164.    pragma Import (C, DosWaitMuxWaitSem, Link_Name => "_DosWaitMuxWaitSem");
  165.  
  166.    function DosAddMuxWaitSem
  167.      (F_hmux    : HMUX;
  168.       pSemRec   : PSEMRECORD)
  169.       return      APIRET;
  170.    pragma Import (C, DosAddMuxWaitSem, Link_Name => "_DosAddMuxWaitSem");
  171.  
  172.    function DosDeleteMuxWaitSem
  173.      (F_hmux    : HMUX;
  174.       F_hsem    : HSEM)
  175.       return      APIRET;
  176.    pragma Import (C, DosDeleteMuxWaitSem, Link_Name => "_DosDeleteMuxWaitSem");
  177.  
  178.    function DosQueryMuxWaitSem
  179.      (F_hmux    : HMUX;
  180.      pcSemRec   : PULONG;
  181.      pSemRec    : PSEMRECORD;
  182.      pflAttr    : PULONG)
  183.      return       APIRET;
  184.    pragma Import (C, DosQueryMuxWaitSem, Link_Name => "_DosQueryMuxWaitSem");
  185.  
  186. end OS2.sem;
  187.