diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-05-28 12:54:39 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2018-05-28 14:08:55 +0200 |
commit | cd0a2de679a81829b7323bc5db46222b9eaab1d9 (patch) | |
tree | a0bfaffd628292fbaceb335913cda1b4ab80d8e9 | |
parent | e4c5d3b34941bdc433072a492a0a7fdbddba0cc2 (diff) |
pkcs11: Exercise GNU calling convention at compile time
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | p11-kit/Makefile.am | 32 | ||||
-rw-r--r-- | p11-kit/iter.h | 10 | ||||
-rw-r--r-- | p11-kit/uri.h | 4 |
4 files changed, 47 insertions, 0 deletions
@@ -99,6 +99,7 @@ x86_64-w64-mingw32 /p11-kit/pkcs11.conf.example /p11-kit/p11-kit-remote@.service /p11-kit/virtual-fixed.c +/p11-kit/*.gnu.c /p11-kit-remote /p11-kit-server diff --git a/p11-kit/Makefile.am b/p11-kit/Makefile.am index 97e03dd..155ef3b 100644 --- a/p11-kit/Makefile.am +++ b/p11-kit/Makefile.am @@ -104,6 +104,7 @@ noinst_LTLIBRARIES += \ check_LTLIBRARIES += \ libp11-kit-testable.la \ + libp11-kit-pkcs11-gnu.la \ $(NULL) libp11_kit_internal_la_LDFLAGS = -no-undefined @@ -117,6 +118,37 @@ libp11_kit_testable_la_SOURCES = \ $(NULL) libp11_kit_testable_la_LIBADD = $(COMMON_LIBS) +pkcs11_gnu_sources = \ + p11-kit/uri.gnu.c \ + p11-kit/iter.gnu.c \ + p11-kit/pin.gnu.c \ + $(NULL) + +BUILT_SOURCES += $(pkcs11_gnu_sources) +CLEANFILES += $(pkcs11_gnu_sources) + +p11-kit/uri.gnu.c: p11-kit/uri.h +p11-kit/iter.gnu.c: p11-kit/iter.h +p11-kit/pin.gnu.c: p11-kit/pin.h + +SUFFIXES = .h .gnu.c +.h.gnu.c: + $(AM_V_GEN) src=$<; dst=$@; rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + echo; \ + echo '#include <stdlib.h>'; \ + echo '#include "p11-kit/p11-kit.h"'; \ + cat $$src; \ + echo "void *$${dst}_funcs[] = {" | sed 's/[^][ *a-z0-9_={]/_/g'; \ + sed -n -e '/^typedef/d' -e 's/.* \(p11_kit_[^ ]*\) *(.*/ \1,/p' $<; \ + echo '};'; \ + } > $@-t && \ + mv -f $@-t $@ + +libp11_kit_pkcs11_gnu_la_LDFLAGS = -no-undefined +libp11_kit_pkcs11_gnu_la_SOURCES = $(pkcs11_gnu_sources) +libp11_kit_pkcs11_gnu_la_CFLAGS = -DCRYPTOKI_GNU=1 -DP11_KIT_FUTURE_UNSTABLE_API=1 + if OS_WIN32 libp11_kit_testable_la_CFLAGS = \ diff --git a/p11-kit/iter.h b/p11-kit/iter.h index fabcd2f..991dcc9 100644 --- a/p11-kit/iter.h +++ b/p11-kit/iter.h @@ -45,6 +45,16 @@ extern "C" { #ifdef P11_KIT_FUTURE_UNSTABLE_API +/* + * If the caller is using the PKCS#11 GNU calling convention, then we cater + * to that here. + */ +#ifdef CRYPTOKI_GNU +typedef unsigned char CK_BBOOL; +typedef ck_object_handle_t CK_OBJECT_HANDLE; +typedef ck_session_handle_t CK_SESSION_HANDLE; +#endif + typedef struct p11_kit_iter P11KitIter; typedef P11KitIter p11_kit_iter; diff --git a/p11-kit/uri.h b/p11-kit/uri.h index 6eb470f..d95bd00 100644 --- a/p11-kit/uri.h +++ b/p11-kit/uri.h @@ -79,11 +79,15 @@ typedef enum { * to that here. */ #ifdef CRYPTOKI_GNU +typedef struct ck_info CK_INFO; typedef struct ck_info *CK_INFO_PTR; +typedef struct ck_token_info CK_TOKEN_INFO; typedef struct ck_token_info *CK_TOKEN_INFO_PTR; typedef ck_attribute_type_t CK_ATTRIBUTE_TYPE; +typedef struct ck_attribute CK_ATTRIBUTE; typedef struct ck_attribute *CK_ATTRIBUTE_PTR; typedef unsigned long int CK_ULONG; +typedef struct ck_slot_info CK_SLOT_INFO; typedef struct ck_slot_info *CK_SLOT_INFO_PTR; typedef ck_slot_id_t CK_SLOT_ID; typedef P11KitUriType p11_kit_uri_type_t; |