BRL-CAD
globals.c
Go to the documentation of this file.
1 /* G L O B A L S . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libbu/globals.c
21  *
22  * Global variables in LIBBU.
23  *
24  * New global variables are discouraged and refactoring in ways that
25  * eliminates existing global variables without reducing functionality
26  * is always encouraged.
27  *
28  */
29 
30 #include "bu/debug.h"
31 #include "bu/getopt.h"
32 #include "bu/malloc.h"
33 #include "bu/parallel.h"
34 #include "bu/vls.h"
35 
36 /**
37  * number of calls to bu_malloc()/bu_calloc()/bu_alloc().
38  *
39  * used by rt.
40  * not semaphore-protected and is thus only an estimate.
41  */
42 long bu_n_malloc = 0;
43 
44 /**
45  * number of calls to bu_realloc().
46  *
47  * used by rt.
48  * not semaphore-protected and is thus only an estimate.
49  */
50 long bu_n_realloc = 0;
51 
52 /**
53  * used by malloc and vls as the bu_malloc/bu_free debug string.
54  *
55  * NOT published in a public header.
56  */
57 EXTERNVARINIT const char bu_vls_message[] = "bu_vls_str";
58 
59 /**
60  * used by malloc and vls as the bu_strdup debug string.
61  *
62  * NOT published in a public header.
63  */
64 EXTERNVARINIT const char bu_strdup_message[] = "bu_strdup string";
65 
66 /**
67  * Marker for knowing if an exception handler is set. bu_setjmp_valid
68  * is global array because BU_SETJUMP() *must* be a macro (jump calls
69  * must be embedded into the frame they return to).
70  *
71  * If you replace bu_bomb() with one of your own, you must also
72  * provide these variables, even if you don't use them.
73  */
75 
76 /**
77  * Exception handling contexts used by BU_SETJUMP(). bu_jmpbuf is a
78  * global array because BU_SETJUMP() *must* be a macro (jump calls
79  * must be embedded into the frame they return to).
80  *
81  * If you replace bu_bomb() with one of your own, you must also
82  * provide these variables, even if you don't use them.
83  */
84 jmp_buf bu_jmpbuf[MAX_PSW];
85 
86 /* externed in bu/ headers */
87 int bu_debug = 0;
88 int bu_opterr = 1;
89 int bu_optind = 1;
90 int bu_optopt = 0;
91 char *bu_optarg = NULL;
92 
93 
94 /*
95  * Local Variables:
96  * tab-width: 8
97  * mode: C
98  * indent-tabs-mode: t
99  * c-file-style: "stroustrup"
100  * End:
101  * ex: shiftwidth=4 tabstop=8
102  */
char * bu_optarg
Definition: globals.c:91
int bu_optind
Definition: globals.c:89
EXTERNVARINIT const char bu_vls_message[]
Definition: globals.c:57
int bu_setjmp_valid[MAX_PSW]
Definition: globals.c:74
int bu_optopt
Definition: globals.c:90
EXTERNVARINIT const char bu_strdup_message[]
Definition: globals.c:64
long bu_n_realloc
Definition: globals.c:50
#define MAX_PSW
Definition: parallel.h:48
int bu_debug
Definition: globals.c:87
int bu_opterr
Definition: globals.c:88
#define EXTERNVARINIT
Definition: common.h:347
jmp_buf bu_jmpbuf[MAX_PSW]
Definition: globals.c:84
long bu_n_malloc
Definition: globals.c:42