source: trunk/src/odincrt/odincrt.cpp@ 470

Last change on this file since 470 was 470, checked in by phaller, 26 years ago

Add: new() experiment

File size: 3.8 KB
Line 
1/************************************************************************/
2/* odincrt.c */
3/************************************************************************/
4/* */
5/* Odin shared C runtime library for IBM VAC++ 3.08 */
6/* */
7/************************************************************************/
8/* Created: 99/08/08 */
9/* Last Edited: 99/00/08 */
10/************************************************************************/
11/* (C)'99 Patrick Haller, Achim Hasenmueller */
12/************************************************************************/
13
14/* we need all prototypes for the C runtime library */
15/****************************************************************************
16 * Includes *
17 ****************************************************************************/
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <odincrt.h>
23
24typedef unsigned short USHORT;
25
26
27/****************************************************************************
28 * Macros *
29 ****************************************************************************/
30
31#define ODIN_TEB_OFF { \
32 USHORT sel = RestoreOS2FS();
33
34#define ODIN_TEB_ON1(rc) SetFS(sel);\
35 return(rc);\
36 }
37
38#define ODIN_TEB_ON0() SetFS(sel);\
39 }
40
41
42/****************************************************************************
43 * Memory Management *
44 ****************************************************************************/
45
46void* ODINAPI ODIN_calloc ( size_t s1, size_t s2 )
47 ODIN_TEB_OFF
48 void* rc = calloc(s1,s2);
49 ODIN_TEB_ON1(rc)
50
51void* ODINAPI ODIN_realloc( void * p1, size_t s1 )
52 ODIN_TEB_OFF
53 void* rc = realloc(p1,s1);
54 ODIN_TEB_ON1(rc)
55
56void* ODINAPI ODIN_malloc (size_t size)
57 ODIN_TEB_OFF
58 void *rc = malloc(size);
59 ODIN_TEB_ON1(rc)
60
61void ODINAPI ODIN_free (void *ptr)
62 ODIN_TEB_OFF
63 free(ptr);
64 ODIN_TEB_ON0()
65
66void * ODINAPI ODIN_debug_calloc ( size_t s1, size_t s2, const char *p1, size_t s3)
67 ODIN_TEB_OFF
68 void* rc = _debug_calloc(s1,s2,p1,s3);
69 ODIN_TEB_ON1(rc)
70
71void ODINAPI ODIN_debug_free ( void *p1, const char *p2, size_t s1)
72 ODIN_TEB_OFF
73 _debug_free(p1,p2,s1);
74 ODIN_TEB_ON0()
75
76void * ODINAPI ODIN_debug_malloc ( size_t s1, const char * p1, size_t s2)
77 ODIN_TEB_OFF
78 void *rc = _debug_malloc(s1,p1,s2);
79 ODIN_TEB_ON1(rc)
80
81void * ODINAPI ODIN_debug_realloc( void *p1, size_t s1, const char *p2, size_t s2)
82 ODIN_TEB_OFF
83 void* rc = _debug_realloc(p1,s1,p2,s2);
84 ODIN_TEB_ON1(rc)
85
86
87
88
89/****************************************************************************
90 * String operations *
91 ****************************************************************************/
92
93char* ODINAPI ODIN_strdup( const char *s1)
94 ODIN_TEB_OFF
95 char *rc = strdup(s1);
96 ODIN_TEB_ON1(rc)
97
98
99/****************************************************************************
100 * C++ operator wrappers (experimental) *
101 ****************************************************************************/
102
103// operator new()
104// @@@PH wrong calling convention
105//void* _Optlink __nw__FUi(void* p1)
106// ODIN_TEB_OFF
107// void *rc = __nw__FUi(p1);
108// ODIN_TEB_ON1(rc)
109
Note: See TracBrowser for help on using the repository browser.