diff options
author | 2017-01-21 04:44:43 +0000 | |
---|---|---|
committer | 2017-01-21 04:44:43 +0000 | |
commit | 76ce35bff9624860918ef3598916792715cee175 (patch) | |
tree | ac3185d613be54396c4ea7f2348b0e5deff5ede2 | |
parent | Expand DECLARE_OBJ_BSEARCH_CMP_FN and IMPLEMENT_OBJ_BSEARCH_CMP_FN macros. (diff) | |
download | wireguard-openbsd-76ce35bff9624860918ef3598916792715cee175.tar.xz wireguard-openbsd-76ce35bff9624860918ef3598916792715cee175.zip |
Expand DECLARE_OBJ_BSEARCH_CMP_FN and IMPLEMENT_OBJ_BSEARCH_CMP_FN macros.
No change to generated assembly excluding line numbers.
-rw-r--r-- | lib/libcrypto/objects/obj_dat.c | 62 | ||||
-rw-r--r-- | lib/libcrypto/objects/obj_xref.c | 42 |
2 files changed, 92 insertions, 12 deletions
diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index 1d6207072d7..e1dacc0d39f 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.37 2016/12/22 16:57:38 inoguchi Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.38 2017/01/21 04:44:43 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -72,9 +72,15 @@ /* obj_dat.h is generated from objects.h by obj_dat.pl */ #include "obj_dat.h" -DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); -DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); -DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); +static int sn_cmp_BSEARCH_CMP_FN(const void *, const void *); +static int sn_cmp(const ASN1_OBJECT * const *, unsigned int const *); +static unsigned int *OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num); +static int ln_cmp_BSEARCH_CMP_FN(const void *, const void *); +static int ln_cmp(const ASN1_OBJECT * const *, unsigned int const *); +static unsigned int *OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num); +static int obj_cmp_BSEARCH_CMP_FN(const void *, const void *); +static int obj_cmp(const ASN1_OBJECT * const *, unsigned int const *); +static unsigned int *OBJ_bsearch_obj(const ASN1_OBJECT * *key, unsigned int const *base, int num); #define ADDED_DATA 0 #define ADDED_SNAME 1 @@ -95,14 +101,42 @@ static int sn_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) return (strcmp((*a)->sn, nid_objs[*b].sn)); } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn); + +static int +sn_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) +{ + const ASN1_OBJECT * const *a = a_; + unsigned int const *b = b_; + return sn_cmp(a, b); +} + +static unsigned int * +OBJ_bsearch_sn(const ASN1_OBJECT * *key, unsigned int const *base, int num) +{ + return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), + sn_cmp_BSEARCH_CMP_FN); +} static int ln_cmp(const ASN1_OBJECT * const *a, const unsigned int *b) { return (strcmp((*a)->ln, nid_objs[*b].ln)); } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln); + +static int +ln_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) +{ + const ASN1_OBJECT * const *a = a_; + unsigned int const *b = b_; + return ln_cmp(a, b); +} + +static unsigned int * +OBJ_bsearch_ln(const ASN1_OBJECT * *key, unsigned int const *base, int num) +{ + return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), + ln_cmp_BSEARCH_CMP_FN); +} static unsigned long added_obj_hash(const ADDED_OBJ *ca) @@ -400,7 +434,21 @@ obj_cmp(const ASN1_OBJECT * const *ap, const unsigned int *bp) return (memcmp(a->data, b->data, a->length)); } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); + +static int +obj_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) +{ + const ASN1_OBJECT * const *a = a_; + unsigned int const *b = b_; + return obj_cmp(a, b); +} + +static unsigned int * +OBJ_bsearch_obj(const ASN1_OBJECT * *key, unsigned int const *base, int num) +{ + return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), + obj_cmp_BSEARCH_CMP_FN); +} int OBJ_obj2nid(const ASN1_OBJECT *a) diff --git a/lib/libcrypto/objects/obj_xref.c b/lib/libcrypto/objects/obj_xref.c index 94dd6293dd5..3e8730d1c6b 100644 --- a/lib/libcrypto/objects/obj_xref.c +++ b/lib/libcrypto/objects/obj_xref.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_xref.c,v 1.7 2014/06/12 15:49:30 deraadt Exp $ */ +/* $OpenBSD: obj_xref.c,v 1.8 2017/01/21 04:44:43 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -68,8 +68,24 @@ sig_cmp(const nid_triple *a, const nid_triple *b) return a->sign_id - b->sign_id; } -DECLARE_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); -IMPLEMENT_OBJ_BSEARCH_CMP_FN(nid_triple, nid_triple, sig); +static int sig_cmp_BSEARCH_CMP_FN(const void *, const void *); +static int sig_cmp(nid_triple const *, nid_triple const *); +static nid_triple *OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num); + +static int +sig_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) +{ + nid_triple const *a = a_; + nid_triple const *b = b_; + return sig_cmp(a, b); +} + +static nid_triple * +OBJ_bsearch_sig(nid_triple *key, nid_triple const *base, int num) +{ + return (nid_triple *)OBJ_bsearch_(key, base, num, sizeof(nid_triple), + sig_cmp_BSEARCH_CMP_FN); +} static int sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) @@ -77,7 +93,9 @@ sig_sk_cmp(const nid_triple * const *a, const nid_triple * const *b) return (*a)->sign_id - (*b)->sign_id; } -DECLARE_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); +static int sigx_cmp_BSEARCH_CMP_FN(const void *, const void *); +static int sigx_cmp(const nid_triple * const *, const nid_triple * const *); +static const nid_triple * *OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num); static int sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) @@ -90,7 +108,21 @@ sigx_cmp(const nid_triple * const *a, const nid_triple * const *b) return (*a)->pkey_id - (*b)->pkey_id; } -IMPLEMENT_OBJ_BSEARCH_CMP_FN(const nid_triple *, const nid_triple *, sigx); + +static int +sigx_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) +{ + const nid_triple * const *a = a_; + const nid_triple * const *b = b_; + return sigx_cmp(a, b); +} + +static const nid_triple * * +OBJ_bsearch_sigx(const nid_triple * *key, const nid_triple * const *base, int num) +{ + return (const nid_triple * *)OBJ_bsearch_(key, base, num, sizeof(const nid_triple *), + sigx_cmp_BSEARCH_CMP_FN); +} int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid) |