1 #ifndef SUMA_SUMA_SUMA_INCLUDED
2 #define SUMA_SUMA_SUMA_INCLUDED
3 
4 /* DRG- MacOS gcc clang sees suma_suma.h and SUMA_suma.h as close-enough.
5    It uses the wrong one and warns, so we use the ../ in the path name.
6    We really want the suma_suma.h  in the AFNI/src directory above.
7    We should probably rename the AFNI version to something a little different.
8    This more basic suma_suma.h is used by other C files in the SUMA directory,
9    so name changes should be repeated in SUMA_niprobe.c and SUMA_expval.c.
10 */
11 #include "SUMA_X_objs.h"
12 #include "SUMA_DataSets.h"
13 #include "TrackIO.h"
14 
15 /* memory allocation section, SUMA_COMPILED-specific */
16    #if defined(USING_MCW_MALLOC) && defined(ALLOW_MCW_MALLOC) && !defined(USE_OMP)
17       #ifdef SUMA_COMPILED
18          #undef SUMA_MEMTRACE_ON
19          #undef SUMA_MEMTRACE_TOGGLE
20          #define SUMA_MEMTRACE_ON {\
21             enable_mcw_malloc() ;   \
22             SUMAg_CF->MemTrace = YUP;  \
23          }
24          #define SUMA_MEMTRACE_TOGGLE {   \
25             if (!SUMAg_CF->MemTrace) { \
26                SUMAg_CF->MemTrace = YUP; \
27                enable_mcw_malloc() ;   \
28             }  \
29          }
30       #endif
31    #endif
32 
33    /* debug tracing section */
34    /* Undefine all that's been defined in suma_suma.h and is SUMA_COMPILED-specific */
35    #ifdef SUMA_COMPILED
36       #ifdef USE_TRACING
37          #undef SUMA_INOUT_NOTIFY_ON
38          #define SUMA_INOUT_NOTIFY_ON {\
39             SUMAg_CF->InOut_Notify = YUP; \
40             DBG_trace = 1;\
41          }
42          #undef SUMA_INOUT_NOTIFY_OFF
43          #define SUMA_INOUT_NOTIFY_OFF {\
44             SUMAg_CF->InOut_Notify = NOPE; \
45             DBG_trace = 0; \
46          }
47          #undef SUMA_INOUT_NOTIFY_TOGGLE
48          #define SUMA_INOUT_NOTIFY_TOGGLE {\
49             SUMAg_CF->InOut_Notify = !SUMAg_CF->InOut_Notify; \
50             if (!DBG_trace) DBG_trace = 1;  \
51             else DBG_trace = 0;  \
52          }
53          #undef SUMA_ECHO_KEYPRESS_ON
54          #define SUMA_ECHO_KEYPRESS_ON {\
55             SUMAg_CF->Echo_KeyPress = YUP; \
56          }
57          #undef SUMA_ECHO_KEYPRESS_OFF
58          #define SUMA_ECHO_KEYPRESS_OFF {\
59             SUMAg_CF->Echo_KeyPress = NOPE; \
60          }
61          #undef SUMA_ECHO_KEYPRESS_TOGGLE
62          #define SUMA_ECHO_KEYPRESS_TOGGLE {\
63             SUMAg_CF->Echo_KeyPress = !SUMAg_CF->Echo_KeyPress; \
64          }
65       #else
66          #undef SUMA_INOUT_NOTIFY_ON
67          #define SUMA_INOUT_NOTIFY_ON {\
68             SUMAg_CF->InOut_Notify = YUP; \
69          }
70          #undef SUMA_INOUT_NOTIFY_OFF
71          #define SUMA_INOUT_NOTIFY_OFF {\
72             SUMAg_CF->InOut_Notify = NOPE; \
73          }
74          #undef SUMA_INOUT_NOTIFY_TOGGLE
75          #define SUMA_INOUT_NOTIFY_TOGGLE {\
76             SUMAg_CF->InOut_Notify = !SUMAg_CF->InOut_Notify; \
77          }
78          #undef SUMA_ECHO_KEYPRESS_ON
79          #define SUMA_ECHO_KEYPRESS_ON {\
80             SUMAg_CF->Echo_KeyPress = YUP; \
81          }
82          #undef SUMA_ECHO_KEYPRESS_OFF
83          #define SUMA_ECHO_KEYPRESS_OFF {\
84             SUMAg_CF->Echo_KeyPress = NOPE; \
85          }
86          #undef SUMA_ECHO_KEYPRESS_TOGGLE
87          #define SUMA_ECHO_KEYPRESS_TOGGLE {\
88             SUMAg_CF->Echo_KeyPress = !SUMAg_CF->Echo_KeyPress; \
89          }
90       #endif
91    #endif
92 
93 /* The include files */
94 #if defined SUMA_COMPILED
95    /* Undefine all that's been defined in suma_suma.h and is SUMA_COMPILED-specific */
96 
97    #undef SUMA_STDERR
98    #undef SUMA_STDOUT
99 
100    #undef SUMA_SLP_Err
101    #undef SUMA_SL_Err
102    #undef SUMA_L_Err
103 
104    #undef SUMA_SLP_Note
105    #undef SUMA_SL_Note
106    #undef SUMA_L_Note
107 
108    #undef SUMA_SLP_Warn
109    #undef SUMA_SL_Warn
110    #undef SUMA_L_Warn
111 
112    #undef SUMA_SLP_Crit
113    #undef SUMA_SL_Crit
114    #undef SUMA_L_Crit
115 
116    #undef SUMA_LH
117    #undef SUMA_LHv
118    #undef SUMA_S_Warn
119    #undef SUMA_S_Warnv
120    #undef SUMA_S_Note
121    #undef SUMA_S_Notev
122    #undef SUMA_S_Err
123    #undef SUMA_S_Errv
124    #undef SUMA_S_Crit
125    #undef SUMA_S_Critv
126 
127    #ifdef SOLARIS
128 	   #include <GLw/GLwDrawA.h>  /* OpenGL drawing area. */
129    #else
130       #ifdef SUMA_MOTIF_GLXAREA
131          #include <GL/GLwMDrawA.h>
132       #else
133 	      #include <GL/GLwDrawA.h>  /* OpenGL drawing area. */
134       #endif
135    #endif
136    #include <GL/gl.h>
137    #include <GL/glu.h>
138    #include <GL/glx.h>
139    #include <GL/glut.h>
140 
141 
142 
143    /* SUMA specific includes*/
144    #include "SUMA_niml_defines.h"
145    #include "SUMA_define.h"
146    #include "SUMA_prototype.h"
147    #include "SUMA_ParseCommands.h"
148    #include "SUMA_niml.h"
149    #include "SUMA_ExpEval.h"
150    #include "SUMA_Engine.h"
151    #include "SUMA_display.h"
152    #include "SUMA_input.h"
153    #include "SUMA_SVmanip.h"
154    #include "SUMA_DOmanip.h"
155    #include "SUMA_MiscFunc.h"
156    #include "SUMA_trackball.h"
157    #include "SUMA_Color.h"
158    #include "SUMA_GeomComp.h"
159    #include "SUMA_CreateDO.h"
160    #include "SUMA_volume_render.h"
161    #include "SUMA_Load_Surface_Object.h"
162    #include "SUMA_Surface_IO.h"
163    #include "SUMA_SphericalMapping.h"
164    #include "SUMA_xColBar.h"
165    #include "SUMA_SurfClust.h"
166    #include "SUMA_IsoSurface.h"
167    #include "SUMA_BrainWrap.h"
168    #include "SUMA_SurfaceToSurface.h"
169    #include "SUMA_LocalStat.h"
170    #include "SUMA_dot.h"
171    #include "SUMA_SegOpts.h"
172    #include "SUMA_SegFunc.h"
173    #include "SUMA_driver.h"
174 #else
175    /* define the necessary macros */
176    #define SUMA_STDERR stderr
177    #define SUMA_STDOUT stdout
178 
179    #define SUMA_SLP_Err SUMA_S_Err
180    #define SUMA_SL_Err SUMA_S_Err
181    #define SUMA_L_Err SUMA_S_Err
182 
183    #define SUMA_SLP_Note SUMA_S_Note
184    #define SUMA_SL_Note SUMA_S_Note
185    #define SUMA_L_Note SUMA_S_Note
186 
187    #define SUMA_SLP_Warn SUMA_S_Warn
188    #define SUMA_SL_Warn SUMA_S_Warn
189    #define SUMA_L_Warn SUMA_S_Warn
190 
191    #define SUMA_SLP_Crit SUMA_S_Crit
192    #define SUMA_SL_Crit SUMA_S_Crit
193    #define SUMA_L_Crit SUMA_S_Crit
194 
195    #define SUMA_LHv( ... ) {\
196       if (LocalHead) {  \
197          fprintf (SUMA_STDERR, "##      %s (%s:%d):\n ", \
198                                FuncName, __FILE__, __LINE__);  \
199          fprintf (SUMA_STDERR, __VA_ARGS__ );  \
200       }  \
201    }
202 
203    #define SUMA_LH( ... ) {\
204       if (LocalHead) { SUMA_LHv( __VA_ARGS__ ); \
205                        fprintf (SUMA_STDERR,"\n"); } \
206    }
207 
208    #define SUMA_S_Warnv( ... ) {\
209       fprintf (SUMA_STDERR, "oo     Warning %s (%s:%d):\n ", \
210                             FuncName, __FILE__, __LINE__);  \
211       fprintf (SUMA_STDERR, __VA_ARGS__);  \
212    }
213 
214    #define SUMA_S_Warn( ... ) {\
215       SUMA_S_Warnv( __VA_ARGS__ );   \
216       fprintf (SUMA_STDERR, "\n");  \
217    }
218 
219    #define SUMA_S_Notev( ... ) {\
220       fprintf (SUMA_STDERR, "++     Notice %s (%s:%d):\n ",\
221                             FuncName, __FILE__, __LINE__);  \
222       fprintf (SUMA_STDERR, __VA_ARGS__);  \
223    }
224 
225    #define SUMA_S_Note( ... ) {\
226       SUMA_S_Notev( __VA_ARGS__ );   \
227       fprintf (SUMA_STDERR, "\n");  \
228    }
229 
230    #define SUMA_S_Errv( ... ) {\
231       fprintf (SUMA_STDERR, "--     Error %s (%s:%d):\n ", \
232                             FuncName, __FILE__, __LINE__);  \
233       fprintf (SUMA_STDERR, __VA_ARGS__);  \
234    }
235 
236    #define SUMA_S_Err( ... ) {\
237       SUMA_S_Errv( __VA_ARGS__ );   \
238       fprintf (SUMA_STDERR, "\n");  \
239    }
240 
241    #define SUMA_S_Critv(...) {\
242       fprintf (SUMA_STDERR, "**     Critical error %s (%s:%d):\n ", \
243                               FuncName, __FILE__, __LINE__);  \
244       fprintf (SUMA_STDERR, __VA_ARGS__);  \
245    }
246    #define SUMA_S_Crit( ... ) {\
247       SUMA_S_Critv( __VA_ARGS__ );   \
248       fprintf (SUMA_STDERR, "\n");  \
249    }
250 
251 #endif
252 
253 extern void SUMA_freep(void *) ; /* 07 Oct 2015 */
254 // drg - mac os 10.15 changes - gcc10 requires declarations
255 #include "mcw_malloc.h"
256 extern void resume_mcw_malloc(void);
257 extern void pause_mcw_malloc(void);
258 
259 
260 /******************************* BEGIN IGNORE THIS CHUNK ********************************/
261 #ifdef USE_SUMA_MALLOC
262    /* NO LONGER SUPPORTED Apr. 09 04 */
263 
264    /* The pre-March 3/04 way, SUMA uses its own version of memory allocation
265    and tracing. Those tools did not allow for memory corruption checking and
266    used linear pointer storage methods making for inefficient searching
267       Use -DUSE_SUMA_MALLOC in the compile line if you wish to use the old stuff
268    */
269    #define SUMA_free( p ) \
270 	   SUMA_free_fn( FuncName, p )
271    #define SUMA_calloc( nmemb,  size) \
272 	   SUMA_calloc_fn( FuncName, nmemb, size)
273    #define SUMA_malloc(size) \
274 	   SUMA_malloc_fn( FuncName, size)
275    #define SUMA_realloc( ptr, size) \
276 	   SUMA_realloc_fn( FuncName, ptr, size)
277    #define SUMA_ENTRY  { \
278       if (SUMAg_CF->InOut_Notify) SUMA_DBG_IN_NOTIFY(FuncName);   \
279    }
280    #define SUMA_RETURN(m_rvar) {\
281       if (SUMAg_CF->InOut_Notify) { SUMA_DBG_OUT_NOTIFY(FuncName); }\
282       return(m_rvar);\
283    }
284    #define SUMA_RETURNe  {\
285       if (SUMAg_CF->InOut_Notify) { SUMA_DBG_OUT_NOTIFY(FuncName); }\
286       return ;\
287    }
288    #define SUMA_mainENTRY {}
289 
290    #define SUMA_INOUT_NOTIFY_ON {\
291       SUMAg_CF->InOut_Notify = YUP; \
292    }
293    #define SUMA_INOUT_NOTIFY_OFF {\
294       SUMAg_CF->InOut_Notify = NOPE; \
295    }
296 
297    #define SUMA_INOUT_NOTIFY_TOGGLE {\
298       SUMAg_CF->InOut_Notify = !SUMAg_CF->InOut_Notify; \
299    }
300    #define SUMA_MEMTRACE_ON {\
301       SUMAg_CF->MemTrace = YUP;  \
302    }
303    #define SUMA_MEMTRACE_OFF {   \
304       SUMAg_CF->MemTrace = OFF;  \
305    }
306    #define SUMA_MEMTRACE_TOGGLE {   \
307       SUMAg_CF->MemTrace = !SUMAg_CF->MemTrace; \
308    }
309 #endif
310 /******************************* END IGNORE THIS CHUNK ********************************/
311 
312 
313 #endif
314