<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Isn’t this going to run into the same issues?<div class=""><br class=""></div><div class="">The DEFINE_ expansions need to be in their own .c file (one file with all or one file per, I’m not fussed much but the latter seems nicer).</div><div class=""><br class=""></div><div class="">The DEFINE_ macros need to stay in the header for compatibility.  To handle the external linkage, a new macro that declares the function prototypes should be introduced.  I.e.:</div><div class=""><br class=""></div><div class=""># define DECLARE_LHASH_OF(type) \</div><div class="">    LHASH_OF(type) * ln_##type##_new(unsigned long (*)(const type *), int (*)(const type *, const type *)); \</div><div class="">    void lh_##type##_free(LHASH_OF(type) *); \</div><div class="">    …</div><div class=""><br class=""></div><div class=""><div class=""># define DEFINE_LHASH_OF(type) \</div><div class="">    DECLARE LHASH_OF(type); \</div><div class="">    LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \</div><div class="">    static ossl_inline LHASH_OF(type) * \</div><div class="">        lh_##type##_new(unsigned long (*hfn)(const type *), \</div><div class="">                        int (*cfn)(const type *, const type *)) \</div><div class="">    { \</div><div class="">        return (LHASH_OF(type) *) \</div><div class="">            OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \</div><div class="">    } \</div><div class="">    static ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \</div><div class="">    { \</div><div class="">        OPENSSL_LH_free((OPENSSL_LHASH *)lh); \</div><div class="">    } \</div><div class="">    …</div></div><div class=""><br class=""></div><div class="">The headers can then use the DECLARE_LHASH_OF macro to prototype the functions.  The .c file uses the DEFINE_LHASH_OF macro to create them.</div><div class=""><br class=""></div><div class="">I chose lhash here because it is the simpler of the two, safestack has more options and is a bit more convoluted.  I’m willing to make a stab at a PR for this.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Pauli<br class=""><div class="">
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">-- <br class="">Dr Paul Dale | Cryptographer | Network Security & Encryption <br class="">Phone +61 7 3031 7217<br class="">Oracle Australia</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><br class=""></div><br class="Apple-interchange-newline">
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 28 Jan 2019, at 4:56 am, Richard Levitte <<a href="mailto:levitte@openssl.org" class="">levitte@openssl.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Sun, 27 Jan 2019 18:51:58 +0100,<br class="">Viktor Dukhovni wrote:<br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">On Jan 27, 2019, at 5:33 AM, Tim Hudson <<a href="mailto:tjh@openssl.org" class="">tjh@openssl.org</a>> wrote:<br class=""><br class="">Tim - I think inline functions in public header files simply shouldn't be present.<br class=""></blockquote><br class="">I think they have their place, and we should try to make them more portable<br class="">to less capable toolchains as needed.<br class=""></blockquote><br class="">A simple way to handle it is to move the DEFINE_ expansions to another<br class="">header file.  I suggest common_stacks.h and common_lhashes.h<br class=""><br class="">At the very least for 3.0.0.  For 1.1.1, I have no idea...<br class=""><br class="">Cheers,<br class="">Richard<br class=""><br class="">-- <br class="">Richard Levitte         <a href="mailto:levitte@openssl.org" class="">levitte@openssl.org</a><br class="">OpenSSL Project         <a href="http://www.openssl.org/~levitte/" class="">http://www.openssl.org/~levitte/</a><br class="">_______________________________________________<br class="">openssl-project mailing list<br class=""><a href="mailto:openssl-project@openssl.org" class="">openssl-project@openssl.org</a><br class="">https://mta.openssl.org/mailman/listinfo/openssl-project<br class=""></div></div></blockquote></div><br class=""></div></body></html>