Yet Another eXchange Tool  0.9.0
ppm_xfuncs.h
Go to the documentation of this file.
1 
10 /*
11  * Keywords: fail-safe wrappers
12  * Maintainer: Thomas Jahns <jahns@dkrz.de>
13  * URL: https://www.dkrz.de/redmine/projects/scales-ppm
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions are
17  * met:
18  *
19  * Redistributions of source code must retain the above copyright notice,
20  * this list of conditions and the following disclaimer.
21  *
22  * Redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution.
25  *
26  * Neither the name of the DKRZ GmbH nor the names of its contributors
27  * may be used to endorse or promote products derived from this software
28  * without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
31  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
32  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
33  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  */
42 
43 #ifndef PPM_XFUNCS_INCLUDED
44 #define PPM_XFUNCS_INCLUDED
45 
46 #ifdef HAVE_CONFIG_H
47 # include <config.h>
48 #endif
49 
50 #include <stdio.h>
51 #include <stdlib.h>
52 
53 #ifdef USE_MPI
54 # include <mpi.h>
55 #endif
56 
57 #include "core/symprefix.h"
58 
59 void *
60 SymPrefix(xcalloc)(size_t nmemb, size_t size, const char *source, int line);
61 
62 void *
63 SymPrefix(xmalloc)(size_t size, const char *source, int line);
64 
65 void *
66 SymPrefix(xrealloc)(void *ptr, size_t size, const char *source, int line);
67 
68 #define xcalloc(nmemb,size) \
69  SymPrefix(xcalloc)((nmemb), (size), __FILE__, __LINE__)
70 #define xmalloc(size) SymPrefix(xmalloc)((size), __FILE__, __LINE__)
71 #define xrealloc(ptr,size) \
72  SymPrefix(xrealloc)((ptr), (size), __FILE__, __LINE__)
73 
74 FILE *
75 SymPrefix(xfopen)(const char *path, const char *mode,
76  const char *source, int line);
77 
78 #define xfopen(path, mode) SymPrefix(xfopen)(path, mode, __FILE__, __LINE__)
79 
80 void
81 SymPrefix(xfclose)(FILE *fp, const char *source, int line);
82 
83 #define xfclose(fp) SymPrefix(xfclose)(fp, __FILE__, __LINE__)
84 
85 int
86 SymPrefix(xfputc)(int c, FILE *stream, const char *source, int line);
87 
88 #define xfputc(c,stream) SymPrefix(xfputc)((c),(stream), __FILE__, __LINE__)
89 
90 #ifdef USE_MPI
91 void
92 SymPrefix(xmpi)(int errcode, const char *source, int line);
93 
94 #define xmpi(errcode) \
95  do { \
96  if (errcode == MPI_SUCCESS) ; else \
97  SymPrefix(xmpi)(errcode, __FILE__, __LINE__); \
98  } while (0)
99 #endif
100 
101 #endif
102 /*
103  * Local Variables:
104  * license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
105  * license-markup: "doxygen"
106  * license-default: "bsd"
107  * End:
108  */
#define xfputc(c, stream)
Definition: ppm_xfuncs.h:88
#define xrealloc(ptr, size)
Definition: ppm_xfuncs.h:71
#define xcalloc(nmemb, size)
Definition: ppm_xfuncs.h:68
#define xmalloc(size)
Definition: ppm_xfuncs.h:70
#define xfclose(fp)
Definition: ppm_xfuncs.h:83
#define xfopen(path, mode)
Definition: ppm_xfuncs.h:78
Define library-specific symbol prefix macros.
#define SymPrefix(symbol)
Definition: symprefix.h:53