BRL-CAD
bresource.h
Go to the documentation of this file.
1/* B R E S O U R C E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2015-2023 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/** @addtogroup bu_resource
21 *
22 * BRL-CAD system compatibility wrapper header that provides
23 * declarations for standard system RESOURCE LIMIT routines.
24 *
25 * This header is commonly used in lieu of including the following:
26 * sys/resource.h sys/time.h sys/wait.h
27 *
28 * This header does not belong to any BRL-CAD library but may used by
29 * all of them.
30 *
31 * The following preprocessor variables control header inclusions:
32 * HAVE_SYS_TIME_H
33 * HAVE_SYS_RESOURCE_H
34 * HAVE_SYS_WAIT_H
35 */
36/** @{ */
37/** @file bresource.h */
38
39#ifndef BRESOURCE_H
40#define BRESOURCE_H
41
42/* intentionally not included for header independence */
43/* #include "common.h" */
44
45#ifdef HAVE_SYS_TIME_H
46# include <sys/time.h>
47#endif
48
49/* this ugly hack overcomes a c89 + -pedantic-errors bug in glibc <2.9
50 * where it raises a warning for a trailing comma when including the
51 * sys/resource.h system header.
52 *
53 * need a better solution that preserves pedantic c89 compilation,
54 * ideally without resorting to a sys/resource.h compilation feature
55 * test (which will vary with build flags).
56 */
57#if !defined(__USE_GNU) && defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ < 9)
58# define __USE_GNU 1
59# define DEFINED_USE_GNU 1
60#endif
61#ifdef HAVE_SYS_RESOURCE_H
62# include <sys/resource.h>
63#endif
64#ifdef DEFINED_USE_GNU
65# undef __USE_GNU
66# undef DEFINED_USE_GNU
67#endif
68
69#ifdef HAVE_SYS_WAIT_H
70# include <sys/wait.h>
71#endif
72
73#endif /* BRESOURCE_H */
74
75/** @} */
76
77/*
78 * Local Variables:
79 * tab-width: 8
80 * mode: C
81 * indent-tabs-mode: t
82 * c-file-style: "stroustrup"
83 * End:
84 * ex: shiftwidth=4 tabstop=8
85 */