home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / MT / STARTUP2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  789 b   |  43 lines

  1. /* startup2.c (emx+gcc) -- Copyright (c) 1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #define INCL_DOSSEMAPHORES
  5. #define INCL_DOSEXCEPTIONS
  6. #define INCL_DOSPROCESS
  7. #define INCL_DOSERRORS
  8. #include <os2emx.h>
  9.  
  10. static HMTX _heap_mutex;
  11.  
  12.  
  13. void _startup_emxlibc_dll (void)
  14. {
  15.   ULONG rc;
  16.  
  17.   rc = DosCreateMutexSem (NULL, &_heap_mutex, 0, FALSE);
  18.   if (rc != 0)
  19.     DosBeep (466, 500);
  20. }
  21.  
  22.  
  23. void _heap_lock (void)
  24. {
  25.   ULONG nesting, rc;
  26.  
  27.   DosEnterMustComplete (&nesting);
  28.   do
  29.     {
  30.       rc = DosRequestMutexSem (_heap_mutex, SEM_INDEFINITE_WAIT);
  31.     } while (rc == ERROR_SEM_OWNER_DIED);
  32.   if (rc != 0)
  33.     DosBeep (466, 500);
  34. }
  35.  
  36. void _heap_unlock (void)
  37. {
  38.   ULONG nesting;
  39.  
  40.   DosReleaseMutexSem (_heap_mutex);
  41.   DosExitMustComplete (&nesting);
  42. }
  43.