[18] | 1 | /* $Id: util.cpp,v 1.1.1.1 2003/07/02 13:56:56 eleph Exp $ */
|
---|
| 2 | /*
|
---|
| 3 | * Replacement runtime routines for Watcom C++
|
---|
| 4 | *
|
---|
| 5 | * (C) 2000-2002 InnoTek Systemberatung GmbH
|
---|
| 6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
| 7 | *
|
---|
| 8 | * This program is free software; you can redistribute it and/or
|
---|
| 9 | * modify it under the terms of the GNU General Public License as
|
---|
| 10 | * published by the Free Software Foundation; either version 2 of
|
---|
| 11 | * the License, or (at your option) any later version.
|
---|
| 12 | *
|
---|
| 13 | * This program is distributed in the hope that it will be useful,
|
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 16 | * GNU General Public License for more details.
|
---|
| 17 | *
|
---|
| 18 | * You should have received a copy of the GNU General Public
|
---|
| 19 | * License along with this program; if not, write to the Free
|
---|
| 20 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
| 21 | * USA.
|
---|
| 22 | *
|
---|
| 23 | */
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | #include "rm.hpp" // Will include os2.h, etc.
|
---|
| 27 | #include <devhelp.h>
|
---|
| 28 | #include <devinfo.h>
|
---|
| 29 |
|
---|
| 30 | #include <malloc.h>
|
---|
| 31 | #include <include.h>
|
---|
| 32 | #include <irqos2.h>
|
---|
| 33 |
|
---|
| 34 | //*****************************************************************************
|
---|
| 35 | //*****************************************************************************
|
---|
| 36 | extern "C" void __wcpp_2_undefed_cdtor_(void)
|
---|
| 37 | {
|
---|
| 38 | int3();
|
---|
| 39 | }
|
---|
| 40 | //*****************************************************************************
|
---|
| 41 | //*****************************************************************************
|
---|
| 42 | extern "C" void __wcpp_2_undefined_member_function_(void)
|
---|
| 43 | {
|
---|
| 44 | int3();
|
---|
| 45 | }
|
---|
| 46 | //*****************************************************************************
|
---|
| 47 | //*****************************************************************************
|
---|
| 48 | extern "C" void __wcpp_2_pure_error_(void)
|
---|
| 49 | {
|
---|
| 50 | int3();
|
---|
| 51 | }
|
---|
| 52 | //*****************************************************************************
|
---|
| 53 | //*****************************************************************************
|
---|
| 54 | extern "C" void __wcpp_2_undef_vfun_(void)
|
---|
| 55 | {
|
---|
| 56 | int3();
|
---|
| 57 | }
|
---|
| 58 | //*****************************************************************************
|
---|
| 59 | //*****************************************************************************
|
---|
| 60 | extern "C" void __wcpp_4_undefed_cdtor_(void)
|
---|
| 61 | {
|
---|
| 62 | int3();
|
---|
| 63 | }
|
---|
| 64 | //*****************************************************************************
|
---|
| 65 | //*****************************************************************************
|
---|
| 66 | extern "C" void __wcpp_4_undefined_member_function_(void)
|
---|
| 67 | {
|
---|
| 68 | int3();
|
---|
| 69 | }
|
---|
| 70 | //*****************************************************************************
|
---|
| 71 | //*****************************************************************************
|
---|
| 72 | extern "C" void __wcpp_4_pure_error_(void)
|
---|
| 73 | {
|
---|
| 74 | int3();
|
---|
| 75 | }
|
---|
| 76 | //*****************************************************************************
|
---|
| 77 | //*****************************************************************************
|
---|
| 78 | extern "C" void __wcpp_4_undef_vfun_(void)
|
---|
| 79 | {
|
---|
| 80 | int3();
|
---|
| 81 | }
|
---|
| 82 | //*****************************************************************************
|
---|
| 83 | //*****************************************************************************
|
---|
| 84 | void* operator new(unsigned u)
|
---|
| 85 | {
|
---|
| 86 | #ifdef DEBUGHEAP
|
---|
| 87 | return malloc(u, __FILE__, __LINE__);
|
---|
| 88 | #else
|
---|
| 89 | return malloc(u);
|
---|
| 90 | #endif
|
---|
| 91 | }
|
---|
| 92 | //*****************************************************************************
|
---|
| 93 | //*****************************************************************************
|
---|
| 94 | void operator delete(void *p)
|
---|
| 95 | {
|
---|
| 96 | #ifdef DEBUGHEAP
|
---|
| 97 | free(p, __FILE__, __LINE__);
|
---|
| 98 | #else
|
---|
| 99 | free(p);
|
---|
| 100 | #endif
|
---|
| 101 | }
|
---|
| 102 | //*****************************************************************************
|
---|
| 103 | //*****************************************************************************
|
---|
| 104 | void *operator new(unsigned u, void near *p)
|
---|
| 105 | {
|
---|
| 106 | return u ? p : NULL;
|
---|
| 107 | }
|
---|
| 108 | //*****************************************************************************
|
---|
| 109 | //*****************************************************************************
|
---|
| 110 | static GINFO FAR48 *pGIS = 0;
|
---|
| 111 | //*****************************************************************************
|
---|
| 112 | //*****************************************************************************
|
---|
| 113 | ULONG os2gettimesec()
|
---|
| 114 | {
|
---|
| 115 | APIRET rc;
|
---|
| 116 | FARPTR16 p;
|
---|
| 117 |
|
---|
| 118 | if(pGIS == NULL) {
|
---|
| 119 | // Build a pointer to the Global Information Segment.
|
---|
| 120 | rc = DevGetDOSVar( DHGETDOSV_SYSINFOSEG, 0, (VOID NEAR *)&p );
|
---|
| 121 | if (rc) {
|
---|
| 122 | return 0;
|
---|
| 123 | }
|
---|
| 124 | SEL FAR48 *pSel = (SEL FAR48 *)MAKE_FARPTR32(p);
|
---|
| 125 | pGIS = (GINFO FAR48 *)MAKE_FARPTR32((ULONG)(*pSel << 16));
|
---|
| 126 | }
|
---|
| 127 | return pGIS->Time;
|
---|
| 128 | }
|
---|
| 129 | //*****************************************************************************
|
---|
| 130 | //*****************************************************************************
|
---|
| 131 | ULONG os2gettimemsec()
|
---|
| 132 | {
|
---|
| 133 | APIRET rc;
|
---|
| 134 | FARPTR16 p;
|
---|
| 135 |
|
---|
| 136 | if(pGIS == NULL) {
|
---|
| 137 | // Build a pointer to the Global Information Segment.
|
---|
| 138 | rc = DevGetDOSVar( DHGETDOSV_SYSINFOSEG, 0, (VOID NEAR *)&p );
|
---|
| 139 | if (rc) {
|
---|
| 140 | return 0;
|
---|
| 141 | }
|
---|
| 142 | SEL FAR48 *pSel = (SEL FAR48 *)MAKE_FARPTR32(p);
|
---|
| 143 | pGIS = (GINFO FAR48 *)MAKE_FARPTR32((ULONG)(*pSel << 16));
|
---|
| 144 | }
|
---|
| 145 | return pGIS->MilliSeconds;
|
---|
| 146 | }
|
---|
| 147 | //*****************************************************************************
|
---|
| 148 | //*****************************************************************************
|
---|
| 149 |
|
---|