Skip to content

Commit

Permalink
lib/hx509: declare and apply HX509_LIB_xxx macros
Browse files Browse the repository at this point in the history
libhx509 is not built according to the same export and calling conventions
on Windows as the other libraries.  This change declares and applies
HX509_LIB_FUNCTION, HX509_LIB_NORETURN_FUNCTION, HX509_LIB_CALL and
HX509_LIB_VARIABLE to lib/hx509.

As a result of this change the calling convention for exported functions
will be __stdcall instead of __cdecl.

Change-Id: Ibc3f05e8088030ef7d13798f1d9c9b190bc57797
  • Loading branch information
jaltman authored and nicowilliams committed Jan 2, 2019
1 parent bec4818 commit 1dd38cc
Show file tree
Hide file tree
Showing 26 changed files with 321 additions and 299 deletions.
17 changes: 17 additions & 0 deletions include/config.h.w32
Expand Up @@ -68,6 +68,23 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
#endif


#ifdef BUILD_HX509_LIB
#ifndef HX509_LIB
#ifdef _WIN32
#define HX509_LIB_FUNCTION
#define HX509_LIB_NORETURN_FUNCTION __declspec(noreturn)
#define HX509_LIB_CALL __stdcall
#define HX509_LIB_VARIABLE
#else
#define HX509_LIB_FUNCTION
#define HX509_LIB_NORETURN_FUNCTION
#define HX509_LIB_CALL
#define HX509_LIB_VARIABLE
#endif
#endif
#endif


#ifdef BUILD_ROKEN_LIB
#ifndef ROKEN_LIB
#ifdef _WIN32
Expand Down
6 changes: 6 additions & 0 deletions lib/hx509/NTMakefile
Expand Up @@ -110,6 +110,12 @@ dist_libhx509_la_SOURCES = \
$(SRCDIR)\req.c \
$(SRCDIR)\revoke.c

{}.c{$(OBJ)}.obj::
$(C2OBJ_P) -DBUILD_HX509_LIB -DASN1_LIB

{$(OBJ)}.c{$(OBJ)}.obj::
$(C2OBJ_P) -DBUILD_HX509_LIB -DASN1_LIB

asn1_compile=$(BINDIR)\asn1_compile.exe

$(gen_files_ocsp:.x=.c): $$(@R).x
Expand Down
52 changes: 26 additions & 26 deletions lib/hx509/ca.c
Expand Up @@ -77,7 +77,7 @@ struct hx509_ca_tbs {
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_init(hx509_context context, hx509_ca_tbs *tbs)
{
*tbs = calloc(1, sizeof(**tbs));
Expand All @@ -95,7 +95,7 @@ hx509_ca_tbs_init(hx509_context context, hx509_ca_tbs *tbs)
* @ingroup hx509_ca
*/

void
HX509_LIB_FUNCTION void HX509_LIB_CALL
hx509_ca_tbs_free(hx509_ca_tbs *tbs)
{
if (tbs == NULL || *tbs == NULL)
Expand Down Expand Up @@ -132,7 +132,7 @@ hx509_ca_tbs_free(hx509_ca_tbs *tbs)
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_notBefore(hx509_context context,
hx509_ca_tbs tbs,
time_t t)
Expand All @@ -153,7 +153,7 @@ hx509_ca_tbs_set_notBefore(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_notAfter(hx509_context context,
hx509_ca_tbs tbs,
time_t t)
Expand All @@ -174,7 +174,7 @@ hx509_ca_tbs_set_notAfter(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_notAfter_lifetime(hx509_context context,
hx509_ca_tbs tbs,
time_t delta)
Expand Down Expand Up @@ -202,7 +202,7 @@ static const struct units templatebits[] = {
* @ingroup hx509_ca
*/

const struct units *
HX509_LIB_FUNCTION const struct units * HX509_LIB_CALL
hx509_ca_tbs_template_units(void)
{
return templatebits;
Expand All @@ -222,7 +222,7 @@ hx509_ca_tbs_template_units(void)
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_template(hx509_context context,
hx509_ca_tbs tbs,
int flags,
Expand Down Expand Up @@ -300,7 +300,7 @@ hx509_ca_tbs_set_template(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_ca(hx509_context context,
hx509_ca_tbs tbs,
int pathLenConstraint)
Expand All @@ -324,7 +324,7 @@ hx509_ca_tbs_set_ca(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_proxy(hx509_context context,
hx509_ca_tbs tbs,
int pathLenConstraint)
Expand All @@ -346,7 +346,7 @@ hx509_ca_tbs_set_proxy(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_domaincontroller(hx509_context context,
hx509_ca_tbs tbs)
{
Expand All @@ -368,7 +368,7 @@ hx509_ca_tbs_set_domaincontroller(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_spki(hx509_context context,
hx509_ca_tbs tbs,
const SubjectPublicKeyInfo *spki)
Expand All @@ -393,7 +393,7 @@ hx509_ca_tbs_set_spki(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_serialnumber(hx509_context context,
hx509_ca_tbs tbs,
const heim_integer *serialNumber)
Expand All @@ -418,7 +418,7 @@ hx509_ca_tbs_set_serialnumber(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_eku(hx509_context context,
hx509_ca_tbs tbs,
const heim_oid *oid)
Expand Down Expand Up @@ -462,7 +462,7 @@ hx509_ca_tbs_add_eku(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_crl_dp_uri(hx509_context context,
hx509_ca_tbs tbs,
const char *uri,
Expand Down Expand Up @@ -567,7 +567,7 @@ hx509_ca_tbs_add_crl_dp_uri(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_san_otherName(hx509_context context,
hx509_ca_tbs tbs,
const heim_oid *oid,
Expand Down Expand Up @@ -596,7 +596,7 @@ hx509_ca_tbs_add_san_otherName(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_san_pkinit(hx509_context context,
hx509_ca_tbs tbs,
const char *principal)
Expand Down Expand Up @@ -731,7 +731,7 @@ add_utf8_san(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_san_ms_upn(hx509_context context,
hx509_ca_tbs tbs,
const char *principal)
Expand All @@ -752,7 +752,7 @@ hx509_ca_tbs_add_san_ms_upn(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_san_jid(hx509_context context,
hx509_ca_tbs tbs,
const char *jid)
Expand All @@ -777,7 +777,7 @@ hx509_ca_tbs_add_san_jid(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_san_hostname(hx509_context context,
hx509_ca_tbs tbs,
const char *dnsname)
Expand Down Expand Up @@ -805,7 +805,7 @@ hx509_ca_tbs_add_san_hostname(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_add_san_rfc822name(hx509_context context,
hx509_ca_tbs tbs,
const char *rfc822Name)
Expand All @@ -832,7 +832,7 @@ hx509_ca_tbs_add_san_rfc822name(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_subject(hx509_context context,
hx509_ca_tbs tbs,
hx509_name subject)
Expand Down Expand Up @@ -860,7 +860,7 @@ hx509_ca_tbs_set_subject(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_unique(hx509_context context,
hx509_ca_tbs tbs,
const heim_bit_string *subjectUniqueID,
Expand Down Expand Up @@ -900,7 +900,7 @@ hx509_ca_tbs_set_unique(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_subject_expand(hx509_context context,
hx509_ca_tbs tbs,
hx509_env env)
Expand All @@ -920,7 +920,7 @@ hx509_ca_tbs_subject_expand(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_tbs_set_signature_algorithm(hx509_context context,
hx509_ca_tbs tbs,
const AlgorithmIdentifier *sigalg)
Expand Down Expand Up @@ -1583,7 +1583,7 @@ get_AuthorityKeyIdentifier(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_sign(hx509_context context,
hx509_ca_tbs tbs,
hx509_cert signer,
Expand Down Expand Up @@ -1627,7 +1627,7 @@ hx509_ca_sign(hx509_context context,
* @ingroup hx509_ca
*/

int
HX509_LIB_FUNCTION int HX509_LIB_CALL
hx509_ca_sign_self(hx509_context context,
hx509_ca_tbs tbs,
hx509_private_key signer,
Expand Down

0 comments on commit 1dd38cc

Please sign in to comment.