home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / i-os2syn.ads < prev    next >
Text File  |  2000-07-19  |  9KB  |  270 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --    I N T E R F A C E S . O S 2 L I B . S Y N C H R O N I Z A T I O N     --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.17 $                            --
  10. --                                                                          --
  11. --          Copyright (C) 1993-1998 Free Software Foundation, Inc.          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with Interfaces.OS2Lib.Threads;
  37.  
  38. package Interfaces.OS2Lib.Synchronization is
  39. pragma Preelaborate (Synchronization);
  40.  
  41.    package IC  renames Interfaces.C;
  42.    package IOT renames Interfaces.OS2Lib.Threads;
  43.    package S   renames System;
  44.  
  45.    --  Semaphore Attributes
  46.  
  47.    DC_SEM_SHARED : constant := 16#01#;
  48.    --  DosCreateMutex, DosCreateEvent, and DosCreateMuxWait use it to indicate
  49.    --  whether the semaphore is shared or private when the PSZ is null
  50.  
  51.    SEM_INDEFINITE_WAIT  : constant ULONG := -1;
  52.    SEM_IMMEDIATE_RETURN : constant ULONG :=  0;
  53.  
  54.    type HSEM is new LHANDLE;
  55.    type PHSEM is access all HSEM;
  56.  
  57.    type SEMRECORD is record
  58.       hsemCur : HSEM;
  59.       ulUser  : ULONG;
  60.    end record;
  61.  
  62.    type PSEMRECORD is access all SEMRECORD;
  63.  
  64.    --  Quad word structure
  65.  
  66.    --  Originally QWORD is defined as a record containing two ULONGS,
  67.    --  the first containing low word and the second for the high word,
  68.    --  but it is cleaner to define it as follows:
  69.  
  70.    type QWORD is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0;
  71.    type PQWORD is access all QWORD;
  72.  
  73.    type HEV is new HSEM;
  74.    type PHEV is access all HEV;
  75.  
  76.    type HMTX  is new HSEM;
  77.    type PHMTX is access all HMTX;
  78.  
  79.    type HMUX  is new HSEM;
  80.    type PHMUX is access all HMUX;
  81.  
  82.    type HTIMER is new LHANDLE;
  83.    type PHTIMER is access all HTIMER;
  84.  
  85.    -----------------------
  86.    -- Critical sections --
  87.    -----------------------
  88.  
  89.    function DosEnterCritSec return APIRET;
  90.    pragma Import (C, DosEnterCritSec, "DosEnterCritSec");
  91.  
  92.    function DosExitCritSec return APIRET;
  93.    pragma Import (C, DosExitCritSec, "DosExitCritSec");
  94.  
  95.    --------------
  96.    -- EventSem --
  97.    --------------
  98.  
  99.    function DosCreateEventSem
  100.      (pszName   : PSZ;
  101.       f_phev    : PHEV;
  102.       flAttr    : ULONG;
  103.       fState    : BOOL32)
  104.       return      APIRET;
  105.    pragma Import (C, DosCreateEventSem, "DosCreateEventSem");
  106.  
  107.    function DosOpenEventSem
  108.      (pszName   : PSZ;
  109.       F_phev    : PHEV)
  110.       return      APIRET;
  111.    pragma Import (C, DosOpenEventSem, "DosOpenEventSem");
  112.  
  113.    function DosCloseEventSem
  114.      (F_hev     : HEV)
  115.       return      APIRET;
  116.    pragma Import (C, DosCloseEventSem, "DosCloseEventSem");
  117.  
  118.    function DosResetEventSem
  119.      (F_hev     : HEV;
  120.       pulPostCt : PULONG)
  121.       return      APIRET;
  122.    pragma Import (C, DosResetEventSem, "DosResetEventSem");
  123.  
  124.    function DosPostEventSem
  125.      (F_hev     : HEV)
  126.       return      APIRET;
  127.    pragma Import (C, DosPostEventSem, "DosPostEventSem");
  128.  
  129.    function DosWaitEventSem
  130.      (F_hev     : HEV;
  131.       ulTimeout : ULONG)
  132.       return      APIRET;
  133.    pragma Import (C, DosWaitEventSem, "DosWaitEventSem");
  134.  
  135.    function DosQueryEventSem
  136.      (F_hev     : HEV;
  137.       pulPostCt : PULONG)
  138.       return      APIRET;
  139.    pragma Import (C, DosQueryEventSem, "DosQueryEventSem");
  140.  
  141.    --------------
  142.    -- MutexSem --
  143.    --------------
  144.  
  145.    function DosCreateMutexSem
  146.      (pszName   : PSZ;
  147.       F_phmtx   : PHMTX;
  148.       flAttr    : ULONG;
  149.       fState    : BOOL32)
  150.       return      APIRET;
  151.    pragma Import (C, DosCreateMutexSem, "DosCreateMutexSem");
  152.  
  153.    function DosOpenMutexSem
  154.      (pszName   : PSZ;
  155.       F_phmtx   : PHMTX)
  156.       return      APIRET;
  157.    pragma Import (C, DosOpenMutexSem, "DosOpenMutexSem");
  158.  
  159.    function DosCloseMutexSem
  160.      (F_hmtx    : HMTX)
  161.       return      APIRET;
  162.    pragma Import (C, DosCloseMutexSem, "DosCloseMutexSem");
  163.  
  164.    function DosRequestMutexSem
  165.      (F_hmtx    : HMTX;
  166.       ulTimeout : ULONG)
  167.       return      APIRET;
  168.    pragma Import (C, DosRequestMutexSem, "DosRequestMutexSem");
  169.  
  170.    function DosReleaseMutexSem
  171.      (F_hmtx    : HMTX)
  172.       return      APIRET;
  173.    pragma Import (C, DosReleaseMutexSem, "DosReleaseMutexSem");
  174.  
  175.    function DosQueryMutexSem
  176.      (F_hmtx    : HMTX;
  177.       F_ppid    : IOT.PPID;
  178.       F_ptid    : IOT.PTID;
  179.       pulCount  : PULONG)
  180.       return      APIRET;
  181.    pragma Import (C, DosQueryMutexSem, "DosQueryMutexSem");
  182.  
  183.    ----------------
  184.    -- MuxWaitSem --
  185.    ----------------
  186.  
  187.    function DosCreateMuxWaitSem
  188.      (pszName   : PSZ;
  189.       F_phmux   : PHMUX;
  190.       cSemRec   : ULONG;
  191.       pSemRec   : PSEMRECORD;
  192.       flAttr    : ULONG)
  193.       return      APIRET;
  194.    pragma Import (C, DosCreateMuxWaitSem, "DosCreateMuxWaitSem");
  195.  
  196.    DCMW_WAIT_ANY : constant := 16#02#;  -- wait on any event/mutex to occur
  197.    DCMW_WAIT_ALL : constant := 16#04#;  -- wait on all events/mutexes to occur
  198.    --  Values for "flAttr" parameter in DosCreateMuxWaitSem call
  199.  
  200.    function DosOpenMuxWaitSem
  201.      (pszName   : PSZ;
  202.       F_phmux   : PHMUX)
  203.       return      APIRET;
  204.    pragma Import (C, DosOpenMuxWaitSem, "DosOpenMuxWaitSem");
  205.  
  206.    function DosCloseMuxWaitSem
  207.      (F_hmux    : HMUX)
  208.       return      APIRET;
  209.    pragma Import (C, DosCloseMuxWaitSem, "DosCloseMuxWaitSem");
  210.  
  211.    function DosWaitMuxWaitSem
  212.      (F_hmux    : HMUX;
  213.       ulTimeout : ULONG;
  214.       pulUser   : PULONG)
  215.       return      APIRET;
  216.    pragma Import (C, DosWaitMuxWaitSem, "DosWaitMuxWaitSem");
  217.  
  218.    function DosAddMuxWaitSem
  219.      (F_hmux    : HMUX;
  220.       pSemRec   : PSEMRECORD)
  221.       return      APIRET;
  222.    pragma Import (C, DosAddMuxWaitSem, "DosAddMuxWaitSem");
  223.  
  224.    function DosDeleteMuxWaitSem
  225.      (F_hmux    : HMUX;
  226.       F_hsem    : HSEM)
  227.       return      APIRET;
  228.    pragma Import (C, DosDeleteMuxWaitSem, "DosDeleteMuxWaitSem");
  229.  
  230.    function DosQueryMuxWaitSem
  231.      (F_hmux    : HMUX;
  232.      pcSemRec   : PULONG;
  233.      pSemRec    : PSEMRECORD;
  234.      pflAttr    : PULONG)
  235.      return       APIRET;
  236.    pragma Import (C, DosQueryMuxWaitSem, "DosQueryMuxWaitSem");
  237.  
  238.    -----------
  239.    -- Timer --
  240.    -----------
  241.  
  242.    function DosAsyncTimer
  243.     (msec      : ULONG;
  244.      F_hsem    : HSEM;
  245.      F_phtimer : PHTIMER)
  246.      return      APIRET;
  247.    pragma Import (C, DosAsyncTimer, "DosAsyncTimer");
  248.  
  249.    function DosStartTimer
  250.     (msec      : ULONG;
  251.      F_hsem    : HSEM;
  252.      F_phtimer : PHTIMER)
  253.      return      APIRET;
  254.    pragma Import (C, DosStartTimer, "DosStartTimer");
  255.  
  256.    function DosStopTimer
  257.      (F_htimer : HTIMER)
  258.       return     APIRET;
  259.    pragma Import (C, DosStopTimer, "DosStopTimer");
  260.  
  261.    --  DosTmrQueryTime provides a snapshot of the time
  262.    --  from the IRQ0 high resolution timer (Intel 8254)
  263.  
  264.    function DosTmrQueryTime
  265.      (pqwTmrTime : access QWORD)   --  Time in 8254 ticks (1_192_755.2 Hz)
  266.       return       APIRET;
  267.    pragma Import (C, DosTmrQueryTime, "DosTmrQueryTime");
  268.  
  269. end Interfaces.OS2Lib.Synchronization;
  270.