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 |
|
---|
24 | typedef 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 |
|
---|
46 | void* 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 |
|
---|
51 | void* ODINAPI ODIN_realloc( void * p1, size_t s1 )
|
---|
52 | ODIN_TEB_OFF
|
---|
53 | void* rc = realloc(p1,s1);
|
---|
54 | ODIN_TEB_ON1(rc)
|
---|
55 |
|
---|
56 | void* ODINAPI ODIN_malloc (size_t size)
|
---|
57 | ODIN_TEB_OFF
|
---|
58 | void *rc = malloc(size);
|
---|
59 | ODIN_TEB_ON1(rc)
|
---|
60 |
|
---|
61 | void ODINAPI ODIN_free (void *ptr)
|
---|
62 | ODIN_TEB_OFF
|
---|
63 | free(ptr);
|
---|
64 | ODIN_TEB_ON0()
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | /****************************************************************************
|
---|
69 | * String operations *
|
---|
70 | ****************************************************************************/
|
---|
71 |
|
---|
72 | char* ODINAPI ODIN_strdup( const char *s1)
|
---|
73 | ODIN_TEB_OFF
|
---|
74 | char *rc = strdup(s1);
|
---|
75 | ODIN_TEB_ON1(rc)
|
---|
76 |
|
---|
77 |
|
---|