| 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 | #define INCL_NOPMAPI
|
|---|
| 25 | #define INCL_DOSINFOSEG
|
|---|
| 26 | #include <os2.h>
|
|---|
| 27 |
|
|---|
| 28 | #include <devhelp.h>
|
|---|
| 29 | #include <devinfo.h>
|
|---|
| 30 |
|
|---|
| 31 | #include <malloc.h>
|
|---|
| 32 | #include <include.h>
|
|---|
| 33 | #include <irqos2.h>
|
|---|
| 34 |
|
|---|
| 35 | //*****************************************************************************
|
|---|
| 36 | //*****************************************************************************
|
|---|
| 37 | extern "C" void __wcpp_2_undefed_cdtor_(void)
|
|---|
| 38 | {
|
|---|
| 39 | int3();
|
|---|
| 40 | }
|
|---|
| 41 | //*****************************************************************************
|
|---|
| 42 | //*****************************************************************************
|
|---|
| 43 | extern "C" void __wcpp_2_undefined_member_function_(void)
|
|---|
| 44 | {
|
|---|
| 45 | int3();
|
|---|
| 46 | }
|
|---|
| 47 | //*****************************************************************************
|
|---|
| 48 | //*****************************************************************************
|
|---|
| 49 | extern "C" void __wcpp_2_pure_error_(void)
|
|---|
| 50 | {
|
|---|
| 51 | int3();
|
|---|
| 52 | }
|
|---|
| 53 | //*****************************************************************************
|
|---|
| 54 | //*****************************************************************************
|
|---|
| 55 | extern "C" void __wcpp_2_undef_vfun_(void)
|
|---|
| 56 | {
|
|---|
| 57 | int3();
|
|---|
| 58 | }
|
|---|
| 59 | //*****************************************************************************
|
|---|
| 60 | //*****************************************************************************
|
|---|
| 61 | extern "C" void __wcpp_4_undefed_cdtor_(void)
|
|---|
| 62 | {
|
|---|
| 63 | int3();
|
|---|
| 64 | }
|
|---|
| 65 | //*****************************************************************************
|
|---|
| 66 | //*****************************************************************************
|
|---|
| 67 | extern "C" void __wcpp_4_undefined_member_function_(void)
|
|---|
| 68 | {
|
|---|
| 69 | int3();
|
|---|
| 70 | }
|
|---|
| 71 | //*****************************************************************************
|
|---|
| 72 | //*****************************************************************************
|
|---|
| 73 | extern "C" void __wcpp_4_pure_error_(void)
|
|---|
| 74 | {
|
|---|
| 75 | int3();
|
|---|
| 76 | }
|
|---|
| 77 | //*****************************************************************************
|
|---|
| 78 | //*****************************************************************************
|
|---|
| 79 | extern "C" void __wcpp_4_undef_vfun_(void)
|
|---|
| 80 | {
|
|---|
| 81 | int3();
|
|---|
| 82 | }
|
|---|
| 83 | //*****************************************************************************
|
|---|
| 84 | //*****************************************************************************
|
|---|
| 85 | void* operator new(unsigned u)
|
|---|
| 86 | {
|
|---|
| 87 | #ifdef DEBUGHEAP
|
|---|
| 88 | return malloc(u, __FILE__, __LINE__);
|
|---|
| 89 | #else
|
|---|
| 90 | return malloc(u);
|
|---|
| 91 | #endif
|
|---|
| 92 | }
|
|---|
| 93 | //*****************************************************************************
|
|---|
| 94 | //*****************************************************************************
|
|---|
| 95 | void operator delete(void *p)
|
|---|
| 96 | {
|
|---|
| 97 | #ifdef DEBUGHEAP
|
|---|
| 98 | free(p, __FILE__, __LINE__);
|
|---|
| 99 | #else
|
|---|
| 100 | free(p);
|
|---|
| 101 | #endif
|
|---|
| 102 | }
|
|---|
| 103 | //*****************************************************************************
|
|---|
| 104 | //*****************************************************************************
|
|---|
| 105 | void *operator new(unsigned u, void near *p)
|
|---|
| 106 | {
|
|---|
| 107 | return u ? p : NULL;
|
|---|
| 108 | }
|
|---|
| 109 | //*****************************************************************************
|
|---|
| 110 | //*****************************************************************************
|
|---|
| 111 | static GINFO FAR48 *pGIS = 0;
|
|---|
| 112 | //*****************************************************************************
|
|---|
| 113 | //*****************************************************************************
|
|---|
| 114 | ULONG os2gettimesec()
|
|---|
| 115 | {
|
|---|
| 116 | APIRET rc;
|
|---|
| 117 | FARPTR16 p;
|
|---|
| 118 |
|
|---|
| 119 | if(pGIS == NULL) {
|
|---|
| 120 | // Build a pointer to the Global Information Segment.
|
|---|
| 121 | rc = DevGetDOSVar( DHGETDOSV_SYSINFOSEG, 0, (VOID NEAR *)&p );
|
|---|
| 122 | if (rc) {
|
|---|
| 123 | return 0;
|
|---|
| 124 | }
|
|---|
| 125 | SEL FAR48 *pSel = (SEL FAR48 *)MAKE_FARPTR32(p);
|
|---|
| 126 | pGIS = (GINFO FAR48 *)MAKE_FARPTR32((ULONG)(*pSel << 16));
|
|---|
| 127 | }
|
|---|
| 128 | return pGIS->Time;
|
|---|
| 129 | }
|
|---|
| 130 | //*****************************************************************************
|
|---|
| 131 | //*****************************************************************************
|
|---|
| 132 | ULONG os2gettimemsec()
|
|---|
| 133 | {
|
|---|
| 134 | APIRET rc;
|
|---|
| 135 | FARPTR16 p;
|
|---|
| 136 |
|
|---|
| 137 | if(pGIS == NULL) {
|
|---|
| 138 | // Build a pointer to the Global Information Segment.
|
|---|
| 139 | rc = DevGetDOSVar( DHGETDOSV_SYSINFOSEG, 0, (VOID NEAR *)&p );
|
|---|
| 140 | if (rc) {
|
|---|
| 141 | return 0;
|
|---|
| 142 | }
|
|---|
| 143 | SEL FAR48 *pSel = (SEL FAR48 *)MAKE_FARPTR32(p);
|
|---|
| 144 | pGIS = (GINFO FAR48 *)MAKE_FARPTR32((ULONG)(*pSel << 16));
|
|---|
| 145 | }
|
|---|
| 146 | return pGIS->MilliSeconds;
|
|---|
| 147 | }
|
|---|
| 148 | //*****************************************************************************
|
|---|
| 149 | //*****************************************************************************
|
|---|
| 150 |
|
|---|