1 /*
2  * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 /**
19  * \file
20  * \brief gbldefs.h - syminit/symutil utility definitions
21  */
22 
23 #ifndef INIT
24 #define TM_I8
25 #endif
26 
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <ctype.h>
31 
32 #define CNULL ((char *)0)
33 
34 #define MAXIDLEN 31
35 
36 #define FIELD unsigned
37 
38 typedef unsigned short ILM_T;
39 
40 #if defined(_WIN32) || defined(HOST_WIN)
41 #define DCL_INT8(name) int name : 8
42 #define DCL_UINT8(name) FIELD name : 8
43 #define DCL_INT16(name) int name : 16
44 #define DCL_UINT16(name) unsigned name : 16
45 #else
46 #define DCL_INT8(name) char name
47 #define DCL_UINT8(name) FIELD name : 8
48 #define DCL_INT16(name) short int name
49 #define DCL_UINT16(name) unsigned short int name
50 #endif
51 
52 /* define a host type which represents 'size_t' for array extents. */
53 #define ISZ_T BIGINT
54 #define UISZ_T BIGUINT
55 #define ISZ_PF BIGIPFSZ
56 
57 typedef int LOGICAL;
58 #undef TRUE
59 #define TRUE 1
60 #undef FALSE
61 #define FALSE 0
62 
63 #define BCOPY(p, q, dt, n) memcpy((char *)(p), (char *)(q), (sizeof(dt) * (n)))
64 #define BZERO(p, dt, n) memset((char *)(p), 0, (sizeof(dt) * (n)))
65 #define FREE(p) free((char *)p)
66 
67 #define NEW(p, dt, n)                                       \
68   if ((p = (dt *)malloc((UINT)(sizeof(dt) * (n)))) == NULL) \
69     symini_interr("out of memory", 0, 4);                   \
70   else
71 
72 #define NEED(n, p, dt, size, newsize)                                       \
73   if (n > size) {                                                           \
74     if ((p = (dt *)realloc((char *)p, ((UINT)((newsize) * sizeof(dt))))) == \
75         NULL)                                                               \
76       symini_interr("out of memory", 0, 4);                                 \
77     size = newsize;                                                         \
78   } else
79