Skip to content

Commit

Permalink
Save progress on LHASH RUBY POC
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel40791765 committed Nov 12, 2024
1 parent 057320c commit b8441ac
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
5 changes: 0 additions & 5 deletions crypto/conf/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ typedef struct conf_section_st CONF_SECTION;
DEFINE_LHASH_OF(CONF_SECTION)
DEFINE_LHASH_OF(CONF_VALUE)

struct conf_st {
LHASH_OF(CONF_VALUE) *values;
LHASH_OF(CONF_SECTION) *sections;
};

// CONF_VALUE_new returns a freshly allocated and zeroed |CONF_VALUE|.
CONF_VALUE *CONF_VALUE_new(void);

Expand Down
1 change: 0 additions & 1 deletion crypto/lhash/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ typedef int (*lhash_cmp_func_helper)(lhash_cmp_func func, const void *a,
typedef uint32_t (*lhash_hash_func)(const void *a);
typedef uint32_t (*lhash_hash_func_helper)(lhash_hash_func func, const void *a);

typedef struct lhash_st _LHASH;

// OPENSSL_lh_new returns a new, empty hash table or NULL on error.
OPENSSL_EXPORT _LHASH *OPENSSL_lh_new(lhash_hash_func hash,
Expand Down
4 changes: 4 additions & 0 deletions crypto/lhash/lhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,7 @@ void OPENSSL_lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), void *arg) {
// resizing is done here.
lh_maybe_resize(lh);
}

void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), void *arg) {
OPENSSL_lh_doall_arg(lh, func, arg);
}
4 changes: 4 additions & 0 deletions include/openssl/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ struct conf_value_st {
DEFINE_STACK_OF(CONF_VALUE)
DECLARE_LHASH_OF(CONF_VALUE)

struct conf_st {
LHASH_OF(CONF_VALUE) *values;
LHASH_OF(CONF_SECTION) *sections;
};

// NCONF_new returns a fresh, empty |CONF|, or NULL on error. The |method|
// argument must be NULL.
Expand Down
22 changes: 22 additions & 0 deletions include/openssl/lhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,34 @@ extern "C" {
// lhash is an internal library and not exported for use outside BoringSSL. This
// header is provided for compatibility with code that expects OpenSSL.

typedef struct lhash_st _LHASH;

// These two macros are exported for compatibility with existing callers of
// |X509V3_EXT_conf_nid|. Do not use these symbols outside BoringSSL.
#define LHASH_OF(type) struct lhash_st_##type
#define DECLARE_LHASH_OF(type) LHASH_OF(type);

OPENSSL_EXPORT void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *),
void *arg);

#define DECLARE_LHASH_DOALL_FN(name, o_type) \
void name##_LHASH_DOALL(void *);
#define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \
void name##_LHASH_DOALL(void *arg) { \
o_type *a = arg; \
name##_doall(a); }
#define LHASH_DOALL_FN(name) name##_LHASH_DOALL

/* Fourth: "doall_arg" functions */
#define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
void name##_LHASH_DOALL_ARG(void *, void *);
#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
o_type *a = arg1; \
a_type *b = arg2; \
name##_doall_arg(a, b); }
#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG


#if defined(__cplusplus)
} // extern C
Expand Down

0 comments on commit b8441ac

Please sign in to comment.