aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-01-11 14:11:13 +0000
committerDr. Stephen Henson <steve@openssl.org>2016-01-11 17:50:27 +0000
commite6b5c341b94d357b0158ad74b12edd51399a4b87 (patch)
tree0957d4adb18236b4f70e0edf836023d7b39a0d23 /crypto
parent8e423bde2561bcddbc1d67f1fcc182d7dfa3f04d (diff)
downloadopenssl-e6b5c341b94d357b0158ad74b12edd51399a4b87.zip
openssl-e6b5c341b94d357b0158ad74b12edd51399a4b87.tar.gz
openssl-e6b5c341b94d357b0158ad74b12edd51399a4b87.tar.bz2
Inline LHASH_OF
Make LHASH_OF use static inline functions. Add new lh_get_down_load and lh_set_down_load functions and their typesafe inline equivalents. Make lh_error a function instead of a macro. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/conf/conf_api.c5
-rw-r--r--crypto/engine/eng_int.h4
-rw-r--r--crypto/engine/eng_table.c6
-rw-r--r--crypto/err/Makefile2
-rw-r--r--crypto/err/err.c4
-rw-r--r--crypto/err/err_lcl.h2
-rw-r--r--crypto/include/internal/cryptlib.h4
-rw-r--r--crypto/lhash/lhash.c15
-rw-r--r--crypto/mem_dbg.c16
-rw-r--r--crypto/objects/Makefile4
-rw-r--r--crypto/objects/o_names.c9
-rw-r--r--crypto/objects/o_names.h4
-rw-r--r--crypto/objects/obj_dat.c8
-rw-r--r--crypto/objects/obj_lcl.h7
14 files changed, 55 insertions, 35 deletions
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index 3badf7f..3421ee3 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -202,9 +202,8 @@ void _CONF_free_data(CONF *conf)
if (conf == NULL || conf->data == NULL)
return;
- lh_CONF_VALUE_down_load(conf->data) = 0; /* evil thing to make * sure the
- * 'OPENSSL_free()' works as *
- * expected */
+ /* evil thing to make sure the 'OPENSSL_free()' works as expected */
+ lh_CONF_VALUE_set_down_load(conf->data, 0);
lh_CONF_VALUE_doall_arg(conf->data,
LHASH_DOALL_ARG_FN(value_free_hash),
LHASH_OF(CONF_VALUE), conf->data);
diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h
index 8f775f5..e68ef44 100644
--- a/crypto/engine/eng_int.h
+++ b/crypto/engine/eng_int.h
@@ -216,6 +216,10 @@ struct engine_st {
struct engine_st *next;
};
+typedef struct st_engine_pile ENGINE_PILE;
+
+DECLARE_LHASH_OF(ENGINE_PILE);
+
#ifdef __cplusplus
}
#endif
diff --git a/crypto/engine/eng_table.c b/crypto/engine/eng_table.c
index 5fd00dd..73e72fe 100644
--- a/crypto/engine/eng_table.c
+++ b/crypto/engine/eng_table.c
@@ -58,7 +58,7 @@
#include "eng_int.h"
/* The type of the items in the table */
-typedef struct st_engine_pile {
+struct st_engine_pile {
/* The 'nid' of this algorithm/mode */
int nid;
/* ENGINEs that implement this algorithm/mode. */
@@ -69,9 +69,7 @@ typedef struct st_engine_pile {
* Zero if 'sk' is newer than the cached 'funct', non-zero otherwise
*/
int uptodate;
-} ENGINE_PILE;
-
-DECLARE_LHASH_OF(ENGINE_PILE);
+};
/* The type exposed in eng_int.h */
struct st_engine_table {
diff --git a/crypto/err/Makefile b/crypto/err/Makefile
index a49e37b..4db677d 100644
--- a/crypto/err/Makefile
+++ b/crypto/err/Makefile
@@ -20,7 +20,7 @@ LIBOBJ=err.o err_all.o err_prn.o
SRC= $(LIBSRC)
-HEADER=
+HEADER= err_lcl.h
ALL= $(GENERAL) $(SRC) $(HEADER)
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 77e8223..5ad5487 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -119,9 +119,7 @@
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/opensslconf.h>
-
-DECLARE_LHASH_OF(ERR_STRING_DATA);
-DECLARE_LHASH_OF(ERR_STATE);
+#include "err_lcl.h"
static void err_load_strings(int lib, ERR_STRING_DATA *str);
diff --git a/crypto/err/err_lcl.h b/crypto/err/err_lcl.h
new file mode 100644
index 0000000..16404df
--- /dev/null
+++ b/crypto/err/err_lcl.h
@@ -0,0 +1,2 @@
+
+DECLARE_LHASH_OF(ERR_STATE);
diff --git a/crypto/include/internal/cryptlib.h b/crypto/include/internal/cryptlib.h
index 1265a04..041ab7e 100644
--- a/crypto/include/internal/cryptlib.h
+++ b/crypto/include/internal/cryptlib.h
@@ -85,6 +85,10 @@ DEFINE_STACK_OF(EX_CALLBACK)
DEFINE_STACK_OF(CRYPTO_dynlock)
+typedef struct app_mem_info_st APP_INFO;
+DECLARE_LHASH_OF(APP_INFO);
+typedef struct mem_st MEM;
+DECLARE_LHASH_OF(MEM);
# ifndef OPENSSL_SYS_VMS
# define X509_CERT_AREA OPENSSLDIR
diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c
index 4018b60..4642bda 100644
--- a/crypto/lhash/lhash.c
+++ b/crypto/lhash/lhash.c
@@ -422,3 +422,18 @@ unsigned long lh_num_items(const _LHASH *lh)
{
return lh ? lh->num_items : 0;
}
+
+unsigned long lh_get_down_load(const _LHASH *lh)
+{
+ return lh->down_load;
+}
+
+void lh_set_down_load(_LHASH *lh, unsigned long down_load)
+{
+ lh->down_load = down_load;
+}
+
+int lh_error(_LHASH *lh)
+{
+ return lh->error;
+}
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 6e93c80..36ce5f4 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -139,10 +139,6 @@ static int mh_mode = CRYPTO_MEM_CHECK_OFF;
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
static unsigned long order = 0; /* number of memory requests */
-DECLARE_LHASH_OF(MEM);
-static LHASH_OF(MEM) *mh = NULL; /* hash-table of memory requests (address as
- * key); access requires MALLOC2 lock */
-
/*-
* For application-defined information (static C-string `info')
* to be displayed in memory leak list.
@@ -150,25 +146,24 @@ static LHASH_OF(MEM) *mh = NULL; /* hash-table of memory requests (address as
* OPENSSL_mem_debug_push("...") to push an entry,
* OPENSSL_mem_debug_pop() to pop an entry,
*/
-typedef struct app_mem_info_st {
+struct app_mem_info_st {
CRYPTO_THREADID threadid;
const char *file;
int line;
const char *info;
struct app_mem_info_st *next; /* tail of thread's stack */
int references;
-} APP_INFO;
+};
/*
* hash-table with those app_mem_info_st's that are at the
* top of their thread's stack (with `thread' as key); access requires
* MALLOC2 lock
*/
-DECLARE_LHASH_OF(APP_INFO);
static LHASH_OF(APP_INFO) *amih = NULL;
/* memory-block description */
-typedef struct mem_st {
+struct mem_st {
void *addr;
int num;
const char *file;
@@ -181,7 +176,10 @@ typedef struct mem_st {
void *array[30];
size_t array_siz;
#endif
-} MEM;
+};
+
+static LHASH_OF(MEM) *mh = NULL; /* hash-table of memory requests (address as
+ * key); access requires MALLOC2 lock */
/* num_disable > 0 iff mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE) */
static unsigned int num_disable = 0;
diff --git a/crypto/objects/Makefile b/crypto/objects/Makefile
index f413b0f..0cfaf5a 100644
--- a/crypto/objects/Makefile
+++ b/crypto/objects/Makefile
@@ -21,7 +21,7 @@ LIBOBJ= o_names.o obj_dat.o obj_lib.o obj_err.o obj_xref.o
SRC= $(LIBSRC)
-HEADER= obj_dat.h obj_xref.h o_names.h
+HEADER= obj_dat.h obj_xref.h obj_lcl.h
ALL= $(GENERAL) $(SRC) $(HEADER)
@@ -80,7 +80,7 @@ o_names.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
o_names.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
o_names.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
o_names.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-o_names.o: o_names.c o_names.h
+o_names.o: o_names.c obj_lcl.h
obj_dat.o: ../../e_os.h ../../include/openssl/asn1.h
obj_dat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
obj_dat.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c
index 476c377..df6240b 100644
--- a/crypto/objects/o_names.c
+++ b/crypto/objects/o_names.c
@@ -7,7 +7,7 @@
#include <openssl/objects.h>
#include <openssl/safestack.h>
#include <openssl/e_os2.h>
-#include "o_names.h"
+#include "obj_lcl.h"
/*
* Later versions of DEC C has started to add lnkage information to certain
@@ -25,7 +25,6 @@
* I use the ex_data stuff to manage the identifiers for the obj_name_types
* that applications may define. I only really use the free function field.
*/
-DECLARE_LHASH_OF(OBJ_NAME);
static LHASH_OF(OBJ_NAME) *names_lh = NULL;
static int names_type_num = OBJ_NAME_TYPE_NUM;
@@ -346,8 +345,8 @@ void OBJ_NAME_cleanup(int type)
return;
free_type = type;
- down_load = lh_OBJ_NAME_down_load(names_lh);
- lh_OBJ_NAME_down_load(names_lh) = 0;
+ down_load = lh_OBJ_NAME_get_down_load(names_lh);
+ lh_OBJ_NAME_set_down_load(names_lh, 0);
lh_OBJ_NAME_doall(names_lh, LHASH_DOALL_FN(names_lh_free));
if (type < 0) {
@@ -356,5 +355,5 @@ void OBJ_NAME_cleanup(int type)
names_lh = NULL;
name_funcs_stack = NULL;
} else
- lh_OBJ_NAME_down_load(names_lh) = down_load;
+ lh_OBJ_NAME_set_down_load(names_lh, down_load);
}
diff --git a/crypto/objects/o_names.h b/crypto/objects/o_names.h
deleted file mode 100644
index 914ed33..0000000
--- a/crypto/objects/o_names.h
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-typedef struct name_funcs_st NAME_FUNCS;
-DEFINE_STACK_OF(NAME_FUNCS)
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index bda9556..51a44a2 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -65,6 +65,7 @@
#include <openssl/objects.h>
#include <openssl/bn.h>
#include "internal/asn1_int.h"
+#include "obj_lcl.h"
/* obj_dat.h is generated from objects.h by obj_dat.pl */
#include "obj_dat.h"
@@ -78,11 +79,10 @@ DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
#define ADDED_LNAME 2
#define ADDED_NID 3
-typedef struct added_obj_st {
+struct added_obj_st {
int type;
ASN1_OBJECT *obj;
-} ADDED_OBJ;
-DECLARE_LHASH_OF(ADDED_OBJ);
+};
static int new_nid = NUM_NID;
static LHASH_OF(ADDED_OBJ) *added = NULL;
@@ -227,7 +227,7 @@ void OBJ_cleanup(void)
}
if (added == NULL)
return;
- lh_ADDED_OBJ_down_load(added) = 0;
+ lh_ADDED_OBJ_set_down_load(added, 0);
lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */
lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */
lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */
diff --git a/crypto/objects/obj_lcl.h b/crypto/objects/obj_lcl.h
new file mode 100644
index 0000000..6a8f75f
--- /dev/null
+++ b/crypto/objects/obj_lcl.h
@@ -0,0 +1,7 @@
+
+
+typedef struct name_funcs_st NAME_FUNCS;
+DEFINE_STACK_OF(NAME_FUNCS)
+DECLARE_LHASH_OF(OBJ_NAME);
+typedef struct added_obj_st ADDED_OBJ;
+DECLARE_LHASH_OF(ADDED_OBJ);