home *** CD-ROM | disk | FTP | other *** search
- /* startup2.c (emx+gcc) -- Copyright (c) 1993 by Eberhard Mattes */
-
- #include <sys/emx.h>
- #define INCL_DOSSEMAPHORES
- #define INCL_DOSEXCEPTIONS
- #define INCL_DOSPROCESS
- #define INCL_DOSERRORS
- #include <os2emx.h>
-
- static HMTX _heap_mutex;
-
-
- void _startup_emxlibc_dll (void)
- {
- ULONG rc;
-
- rc = DosCreateMutexSem (NULL, &_heap_mutex, 0, FALSE);
- if (rc != 0)
- DosBeep (466, 500);
- }
-
-
- void _heap_lock (void)
- {
- ULONG nesting, rc;
-
- DosEnterMustComplete (&nesting);
- do
- {
- rc = DosRequestMutexSem (_heap_mutex, SEM_INDEFINITE_WAIT);
- } while (rc == ERROR_SEM_OWNER_DIED);
- if (rc != 0)
- DosBeep (466, 500);
- }
-
- void _heap_unlock (void)
- {
- ULONG nesting;
-
- DosReleaseMutexSem (_heap_mutex);
- DosExitMustComplete (&nesting);
- }
-