| | varnish-cache/bin/varnishd/common/common_param.h |
0 |
|
/*- |
1 |
|
* Copyright (c) 2006 Verdens Gang AS |
2 |
|
* Copyright (c) 2006-2011 Varnish Software AS |
3 |
|
* All rights reserved. |
4 |
|
* |
5 |
|
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk> |
6 |
|
* |
7 |
|
* SPDX-License-Identifier: BSD-2-Clause |
8 |
|
* |
9 |
|
* Redistribution and use in source and binary forms, with or without |
10 |
|
* modification, are permitted provided that the following conditions |
11 |
|
* are met: |
12 |
|
* 1. Redistributions of source code must retain the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer. |
14 |
|
* 2. Redistributions in binary form must reproduce the above copyright |
15 |
|
* notice, this list of conditions and the following disclaimer in the |
16 |
|
* documentation and/or other materials provided with the distribution. |
17 |
|
* |
18 |
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
19 |
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 |
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 |
|
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
22 |
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 |
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 |
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 |
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 |
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 |
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 |
|
* SUCH DAMAGE. |
29 |
|
* |
30 |
|
* This file contains the heritage passed when mgt forks cache |
31 |
|
*/ |
32 |
|
|
33 |
|
#ifdef COMMON_COMMON_PARAM_H |
34 |
|
#error "Multiple includes of common/common_param.h" |
35 |
|
#endif |
36 |
|
#define COMMON_COMMON_PARAM_H |
37 |
|
|
38 |
|
#include "vre.h" |
39 |
|
|
40 |
|
#define VSM_CLASS_PARAM "Params" |
41 |
|
|
42 |
|
enum debug_bits { |
43 |
|
#define DEBUG_BIT(U, l, d) DBG_##U, |
44 |
|
#include "tbl/debug_bits.h" |
45 |
|
DBG_Reserved |
46 |
|
}; |
47 |
|
|
48 |
|
static inline int |
49 |
103927527 |
COM_DO_DEBUG(const volatile uint8_t *p, enum debug_bits x) |
50 |
|
{ |
51 |
103927527 |
return ((p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))) != 0); |
52 |
|
} |
53 |
|
|
54 |
|
enum experimental_bits { |
55 |
|
#define EXPERIMENTAL_BIT(U, l, d) EXPERIMENT_##U, |
56 |
|
#include "tbl/experimental_bits.h" |
57 |
|
EXPERIMENT_Reserved |
58 |
|
}; |
59 |
|
|
60 |
|
static inline int |
61 |
80 |
COM_EXPERIMENT(const volatile uint8_t *p, enum experimental_bits x) |
62 |
|
{ |
63 |
80 |
return ((p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))) != 0); |
64 |
|
} |
65 |
|
|
66 |
|
enum feature_bits { |
67 |
|
#define FEATURE_BIT(U, l, d) FEATURE_##U, |
68 |
|
#include "tbl/feature_bits.h" |
69 |
|
FEATURE_Reserved |
70 |
|
}; |
71 |
|
|
72 |
|
static inline int |
73 |
1918447 |
COM_FEATURE(const volatile uint8_t *p, enum feature_bits x) |
74 |
|
{ |
75 |
1918447 |
return ((p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))) != 0); |
76 |
|
} |
77 |
|
|
78 |
|
enum vcc_feature_bits { |
79 |
|
#define VCC_FEATURE_BIT(U, l, d) VCC_FEATURE_##U, |
80 |
|
#include "tbl/vcc_feature_bits.h" |
81 |
|
VCC_FEATURE_Reserved |
82 |
|
}; |
83 |
|
|
84 |
|
static inline int |
85 |
179760 |
COM_VCC_FEATURE(const volatile uint8_t *p, enum vcc_feature_bits x) |
86 |
|
{ |
87 |
179760 |
return ((p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))) != 0); |
88 |
|
} |
89 |
|
|
90 |
|
struct poolparam { |
91 |
|
unsigned min_pool; |
92 |
|
unsigned max_pool; |
93 |
|
vtim_dur max_age; |
94 |
|
}; |
95 |
|
|
96 |
|
#define PARAM_BITMAP(name, len) typedef uint8_t name[(len + 7)>>3] |
97 |
|
|
98 |
|
PARAM_BITMAP(vsl_mask_t, 256); |
99 |
|
PARAM_BITMAP(debug_t, DBG_Reserved); |
100 |
|
PARAM_BITMAP(experimental_t, EXPERIMENT_Reserved); |
101 |
|
PARAM_BITMAP(feature_t, FEATURE_Reserved); |
102 |
|
PARAM_BITMAP(vcc_feature_t, VCC_FEATURE_Reserved); |
103 |
|
#undef PARAM_BITMAP |
104 |
|
|
105 |
|
struct params { |
106 |
|
|
107 |
|
#define ptyp_boolean unsigned |
108 |
|
#define ptyp_bytes ssize_t |
109 |
|
#define ptyp_bytes_u unsigned |
110 |
|
#define ptyp_debug debug_t |
111 |
|
#define ptyp_double double |
112 |
|
#define ptyp_duration vtim_dur |
113 |
|
#define ptyp_experimental experimental_t |
114 |
|
#define ptyp_feature feature_t |
115 |
|
#define ptyp_poolparam struct poolparam |
116 |
|
#define ptyp_thread_pool_max unsigned |
117 |
|
#define ptyp_thread_pool_min unsigned |
118 |
|
#define ptyp_timeout vtim_dur |
119 |
|
#define ptyp_uint unsigned |
120 |
|
#define ptyp_vcc_feature vcc_feature_t |
121 |
|
#define ptyp_vsl_buffer unsigned |
122 |
|
#define ptyp_vsl_mask vsl_mask_t |
123 |
|
#define ptyp_vsl_reclen unsigned |
124 |
|
#define PARAM(typ, fld, nm, ...) \ |
125 |
|
ptyp_##typ fld; |
126 |
|
#include <tbl/params.h> |
127 |
|
#undef ptyp_boolean |
128 |
|
#undef ptyp_bytes |
129 |
|
#undef ptyp_bytes_u |
130 |
|
#undef ptyp_debug |
131 |
|
#undef ptyp_double |
132 |
|
#undef ptyp_duration |
133 |
|
#undef ptyp_experimental |
134 |
|
#undef ptyp_feature |
135 |
|
#undef ptyp_poolparam |
136 |
|
#undef ptyp_thread_pool_max |
137 |
|
#undef ptyp_thread_pool_min |
138 |
|
#undef ptyp_timeout |
139 |
|
#undef ptyp_uint |
140 |
|
#undef ptyp_vsl_buffer |
141 |
|
#undef ptyp_vsl_mask |
142 |
|
#undef ptyp_vsl_reclen |
143 |
|
|
144 |
|
struct vre_limits vre_limits; |
145 |
|
}; |