Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /branches/destination-access/src/logging.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2000 - (show annotations) (download) (as text)
Sat Jul 27 16:52:11 2019 UTC (5 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 3946 byte(s)
Merge fom trunk (more checking of memory allocation success/failure).

1 /***************************************
2 Header file for logging function prototypes
3
4 Part of the Routino routing software.
5 ******************/ /******************
6 This file Copyright 2008-2015, 2017, 2019 Andrew M. Bishop
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
17
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ***************************************/
21
22
23 #ifndef LOGGING_H
24 #define LOGGING_H /*+ To stop multiple inclusions. +*/
25
26 #include <stdio.h>
27
28 #include "typesx.h"
29
30
31 /* Data structures */
32
33 /*+ A structure containing a single object as written by the logerror_*() functions. +*/
34 typedef struct _ErrorLogObject
35 {
36 char type; /*+ The type of the object. +*/
37
38 uint64_t id; /*+ The id of the object. +*/
39
40 uint32_t offset; /*+ The offset of the error message from the beginning of the text file. +*/
41 }
42 ErrorLogObject;
43
44
45 /* Variables */
46
47 extern int option_loggable;
48 extern int option_logtime;
49 extern int option_logmemory;
50
51
52 /* Runtime progress logging functions in logging.c */
53
54 void printf_program_start(void);
55 void printf_program_end(void);
56
57
58 #ifdef __GNUC__
59
60 void printf_first(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
61 void printf_middle(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
62 void printf_last(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
63
64 void fprintf_first(FILE *file,const char *format, ...) __attribute__ ((format (printf, 2, 3)));
65 void fprintf_middle(FILE *file,const char *format, ...) __attribute__ ((format (printf, 2, 3)));
66 void fprintf_last(FILE *file,const char *format, ...) __attribute__ ((format (printf, 2, 3)));
67
68 #else
69
70 void printf_first(const char *format, ...);
71 void printf_middle(const char *format, ...);
72 void printf_last(const char *format, ...);
73
74 void fprintf_first(FILE *file,const char *format, ...);
75 void fprintf_middle(FILE *file,const char *format, ...);
76 void fprintf_last(FILE *file,const char *format, ...);
77
78 #endif
79
80 void log_malloc(void *address,size_t size);
81 void log_free(void *address);
82
83 void log_mmap(size_t size);
84 void log_munmap(size_t size);
85
86
87 /* Error logging functions in logerror.c */
88
89 void open_errorlog(const char *filename,int append,int bin);
90 void close_errorlog(void);
91
92 #ifdef __GNUC__
93
94 void logerror(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
95
96 #else
97
98 void logerror(const char *format, ...);
99
100 #endif
101
102 node_t logerror_node (node_t id);
103 way_t logerror_way (way_t id);
104 relation_t logerror_relation(relation_t id);
105
106
107 /* Runtime fatal error assertion in logging.c */
108
109 #define logassert(xx,yy) do { if(!(xx)) _logassert(yy,__FILE__,__LINE__); } while(0)
110
111 #ifdef __GNUC__
112
113 void _logassert(const char *message,const char *file,int line) __attribute__ ((noreturn));
114
115 #else
116
117 void _logassert(const char *message,const char *file,int line);
118
119 #endif
120
121
122 /* Memory allocation with logging */
123
124 #define calloc_logassert(xx,yy) _calloc_logassert (xx,yy,__FILE__,__LINE__)
125
126 #define malloc_logassert(xx) _malloc_logassert (xx ,__FILE__,__LINE__)
127
128 #define realloc_logassert(xx,yy) _realloc_logassert(xx,yy,__FILE__,__LINE__)
129
130
131 void *_calloc_logassert (size_t nmemb,size_t size,const char *file,int line);
132 void *_malloc_logassert ( size_t size,const char *file,int line);
133 void *_realloc_logassert(void *ptr, size_t size,const char *file,int line);
134
135
136 #endif /* LOGGING_H */