summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/lhash
diff options
context:
space:
mode:
authortb <>2024-03-02 11:04:52 +0000
committertb <>2024-03-02 11:04:52 +0000
commit2e45bf0bb5ba5d679b984ec185fbc3d2a6270f6f (patch)
tree14fe1625d8e95a578ceba0d94f1fefdd60ec9146 /src/lib/libcrypto/lhash
parente046d31060c0d98e03e2a00a0f27d8b56aac8cd6 (diff)
downloadopenbsd-2e45bf0bb5ba5d679b984ec185fbc3d2a6270f6f.tar.gz
openbsd-2e45bf0bb5ba5d679b984ec185fbc3d2a6270f6f.tar.bz2
openbsd-2e45bf0bb5ba5d679b984ec185fbc3d2a6270f6f.zip
Remove lh stats
This could have been removed in an earlier bump. Now it's time for it to say goodbye. ok jsing
Diffstat (limited to 'src/lib/libcrypto/lhash')
-rw-r--r--src/lib/libcrypto/lhash/lh_stats.c263
-rw-r--r--src/lib/libcrypto/lhash/lhash.h18
2 files changed, 1 insertions, 280 deletions
diff --git a/src/lib/libcrypto/lhash/lh_stats.c b/src/lib/libcrypto/lhash/lh_stats.c
deleted file mode 100644
index 123792a2ab..0000000000
--- a/src/lib/libcrypto/lhash/lh_stats.c
+++ /dev/null
@@ -1,263 +0,0 @@
1/* $OpenBSD: lh_stats.c,v 1.13 2023/07/07 13:40:44 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <string.h>
61#include <stdlib.h>
62
63#include <openssl/opensslconf.h>
64
65#ifndef OPENSSL_NO_BIO
66#include <openssl/bio.h>
67#endif
68#include <openssl/lhash.h>
69
70#ifdef OPENSSL_NO_BIO
71
72void
73lh_stats(LHASH *lh, FILE *out)
74{
75 fprintf(out, "num_items = %lu\n", lh->num_items);
76 fprintf(out, "num_nodes = %u\n", lh->num_nodes);
77 fprintf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes);
78 fprintf(out, "num_expands = %lu\n", lh->num_expands);
79 fprintf(out, "num_expand_reallocs = %lu\n", lh->num_expand_reallocs);
80 fprintf(out, "num_contracts = %lu\n", lh->num_contracts);
81 fprintf(out, "num_contract_reallocs = %lu\n",
82 lh->num_contract_reallocs);
83 fprintf(out, "num_hash_calls = %lu\n", lh->num_hash_calls);
84 fprintf(out, "num_comp_calls = %lu\n", lh->num_comp_calls);
85 fprintf(out, "num_insert = %lu\n", lh->num_insert);
86 fprintf(out, "num_replace = %lu\n", lh->num_replace);
87 fprintf(out, "num_delete = %lu\n", lh->num_delete);
88 fprintf(out, "num_no_delete = %lu\n", lh->num_no_delete);
89 fprintf(out, "num_retrieve = %lu\n", lh->num_retrieve);
90 fprintf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss);
91 fprintf(out, "num_hash_comps = %lu\n", lh->num_hash_comps);
92#if 0
93 fprintf(out, "p = %u\n", lh->p);
94 fprintf(out, "pmax = %u\n", lh->pmax);
95 fprintf(out, "up_load = %lu\n", lh->up_load);
96 fprintf(out, "down_load = %lu\n", lh->down_load);
97#endif
98}
99LCRYPTO_ALIAS(lh_stats);
100
101void
102lh_node_stats(LHASH *lh, FILE *out)
103{
104 LHASH_NODE *n;
105 unsigned int i, num;
106
107 for (i = 0; i < lh->num_nodes; i++) {
108 for (n = lh->b[i], num = 0; n != NULL; n = n->next)
109 num++;
110 fprintf(out, "node %6u -> %3u\n", i, num);
111 }
112}
113LCRYPTO_ALIAS(lh_node_stats);
114
115void
116lh_node_usage_stats(LHASH *lh, FILE *out)
117{
118 LHASH_NODE *n;
119 unsigned long num;
120 unsigned int i;
121 unsigned long total = 0, n_used = 0;
122
123 for (i = 0; i < lh->num_nodes; i++) {
124 for (n = lh->b[i], num = 0; n != NULL; n = n->next)
125 num++;
126 if (num != 0) {
127 n_used++;
128 total += num;
129 }
130 }
131 fprintf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes);
132 fprintf(out, "%lu items\n", total);
133 if (n_used == 0)
134 return;
135 fprintf(out, "load %d.%02d actual load %d.%02d\n",
136 (int)(total / lh->num_nodes),
137 (int)((total % lh->num_nodes) * 100 / lh->num_nodes),
138 (int)(total / n_used),
139 (int)((total % n_used) * 100 / n_used));
140}
141LCRYPTO_ALIAS(lh_node_usage_stats);
142
143#else
144
145void
146lh_stats(const _LHASH *lh, FILE *fp)
147{
148 BIO *bp;
149
150 bp = BIO_new(BIO_s_file());
151 if (bp == NULL)
152 goto end;
153 BIO_set_fp(bp, fp, BIO_NOCLOSE);
154 lh_stats_bio(lh, bp);
155 BIO_free(bp);
156end:;
157}
158LCRYPTO_ALIAS(lh_stats);
159
160void
161lh_node_stats(const _LHASH *lh, FILE *fp)
162{
163 BIO *bp;
164
165 bp = BIO_new(BIO_s_file());
166 if (bp == NULL)
167 goto end;
168 BIO_set_fp(bp, fp, BIO_NOCLOSE);
169 lh_node_stats_bio(lh, bp);
170 BIO_free(bp);
171end:;
172}
173LCRYPTO_ALIAS(lh_node_stats);
174
175void
176lh_node_usage_stats(const _LHASH *lh, FILE *fp)
177{
178 BIO *bp;
179
180 bp = BIO_new(BIO_s_file());
181 if (bp == NULL)
182 goto end;
183 BIO_set_fp(bp, fp, BIO_NOCLOSE);
184 lh_node_usage_stats_bio(lh, bp);
185 BIO_free(bp);
186end:;
187}
188LCRYPTO_ALIAS(lh_node_usage_stats);
189
190
191void
192lh_stats_bio(const _LHASH *lh, BIO *out)
193{
194 BIO_printf(out, "num_items = %lu\n", lh->num_items);
195 BIO_printf(out, "num_nodes = %u\n", lh->num_nodes);
196 BIO_printf(out, "num_alloc_nodes = %u\n", lh->num_alloc_nodes);
197 BIO_printf(out, "num_expands = %lu\n", lh->num_expands);
198 BIO_printf(out, "num_expand_reallocs = %lu\n",
199 lh->num_expand_reallocs);
200 BIO_printf(out, "num_contracts = %lu\n", lh->num_contracts);
201 BIO_printf(out, "num_contract_reallocs = %lu\n",
202 lh->num_contract_reallocs);
203 BIO_printf(out, "num_hash_calls = %lu\n", lh->num_hash_calls);
204 BIO_printf(out, "num_comp_calls = %lu\n", lh->num_comp_calls);
205 BIO_printf(out, "num_insert = %lu\n", lh->num_insert);
206 BIO_printf(out, "num_replace = %lu\n", lh->num_replace);
207 BIO_printf(out, "num_delete = %lu\n", lh->num_delete);
208 BIO_printf(out, "num_no_delete = %lu\n", lh->num_no_delete);
209 BIO_printf(out, "num_retrieve = %lu\n", lh->num_retrieve);
210 BIO_printf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss);
211 BIO_printf(out, "num_hash_comps = %lu\n", lh->num_hash_comps);
212#if 0
213 BIO_printf(out, "p = %u\n", lh->p);
214 BIO_printf(out, "pmax = %u\n", lh->pmax);
215 BIO_printf(out, "up_load = %lu\n", lh->up_load);
216 BIO_printf(out, "down_load = %lu\n", lh->down_load);
217#endif
218}
219LCRYPTO_ALIAS(lh_stats_bio);
220
221void
222lh_node_stats_bio(const _LHASH *lh, BIO *out)
223{
224 LHASH_NODE *n;
225 unsigned int i, num;
226
227 for (i = 0; i < lh->num_nodes; i++) {
228 for (n = lh->b[i], num = 0; n != NULL; n = n->next)
229 num++;
230 BIO_printf(out, "node %6u -> %3u\n", i, num);
231 }
232}
233LCRYPTO_ALIAS(lh_node_stats_bio);
234
235void
236lh_node_usage_stats_bio(const _LHASH *lh, BIO *out)
237{
238 LHASH_NODE *n;
239 unsigned long num;
240 unsigned int i;
241 unsigned long total = 0, n_used = 0;
242
243 for (i = 0; i < lh->num_nodes; i++) {
244 for (n = lh->b[i], num = 0; n != NULL; n = n->next)
245 num++;
246 if (num != 0) {
247 n_used++;
248 total += num;
249 }
250 }
251 BIO_printf(out, "%lu nodes used out of %u\n", n_used, lh->num_nodes);
252 BIO_printf(out, "%lu items\n", total);
253 if (n_used == 0)
254 return;
255 BIO_printf(out, "load %d.%02d actual load %d.%02d\n",
256 (int)(total / lh->num_nodes),
257 (int)((total % lh->num_nodes) * 100 / lh->num_nodes),
258 (int)(total / n_used),
259 (int)((total % n_used) * 100 / n_used));
260}
261LCRYPTO_ALIAS(lh_node_usage_stats_bio);
262
263#endif
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h
index 9c63657396..8db0174a61 100644
--- a/src/lib/libcrypto/lhash/lhash.h
+++ b/src/lib/libcrypto/lhash/lhash.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: lhash.h,v 1.12 2014/06/12 15:49:29 deraadt Exp $ */ 1/* $OpenBSD: lhash.h,v 1.13 2024/03/02 11:04:51 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -179,16 +179,6 @@ void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
179unsigned long lh_strhash(const char *c); 179unsigned long lh_strhash(const char *c);
180unsigned long lh_num_items(const _LHASH *lh); 180unsigned long lh_num_items(const _LHASH *lh);
181 181
182void lh_stats(const _LHASH *lh, FILE *out);
183void lh_node_stats(const _LHASH *lh, FILE *out);
184void lh_node_usage_stats(const _LHASH *lh, FILE *out);
185
186#ifndef OPENSSL_NO_BIO
187void lh_stats_bio(const _LHASH *lh, BIO *out);
188void lh_node_stats_bio(const _LHASH *lh, BIO *out);
189void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
190#endif
191
192/* Type checking... */ 182/* Type checking... */
193 183
194#define LHASH_OF(type) struct lhash_st_##type 184#define LHASH_OF(type) struct lhash_st_##type
@@ -217,12 +207,6 @@ void lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);
217 lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg)) 207 lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))
218#define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh)) 208#define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))
219#define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load) 209#define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)
220#define LHM_lh_node_stats_bio(type, lh, out) \
221 lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)
222#define LHM_lh_node_usage_stats_bio(type, lh, out) \
223 lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)
224#define LHM_lh_stats_bio(type, lh, out) \
225 lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)
226#define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh)) 210#define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))
227 211
228DECLARE_LHASH_OF(OPENSSL_STRING); 212DECLARE_LHASH_OF(OPENSSL_STRING);