[Commits] ad8b439: MDEV-9618 solaris sparc build fails on 10.1.

Alexey Botchkov holyfoot at askmonty.org
Mon May 2 11:06:45 EEST 2016


revision-id: ad8b4399f2fcd1d5e9dcdb8b2a8832cb3a6745ae (mariadb-10.1.13-23-gad8b439)
parent(s): ad4239cc3dc7ad5f6f264e1fb3cf6d24084bda90
committer: Alexey Botchkov
timestamp: 2016-05-02 12:03:39 +0400
message:

MDEV-9618 solaris sparc build fails on 10.1.

        Compiler on Solaris is sensitive to C/C++ call models
        differences, so it fails if we try to mix these two in
        '?' operator.
        Fixed by trying to keep the call models uniformity with the
        proper amount of 'extern "C"' hints.

---
 include/my_crypt.h                                         |  6 ++++++
 include/mysql/plugin_audit.h                               |  7 +++++++
 include/mysql/plugin_encryption.h                          |  9 +++++++++
 .../example_key_management_plugin.cc                       |  2 +-
 plugin/file_key_management/file_key_management_plugin.cc   |  2 +-
 sql/encryption.cc                                          | 14 ++++++++++----
 unittest/sql/mf_iocache-t.cc                               |  2 +-
 7 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/include/my_crypt.h b/include/my_crypt.h
index e1e94c9..db280ca 100644
--- a/include/my_crypt.h
+++ b/include/my_crypt.h
@@ -82,6 +82,12 @@ static inline uint my_aes_ctx_size(enum my_aes_mode mode __attribute__((unused))
   return MY_AES_CTX_SIZE;
 }
 
+static inline uint my_aes_ctx_size_for_handler(unsigned int a,
+                     unsigned int b __attribute__((unused)))
+{
+  return my_aes_ctx_size((enum my_aes_mode) a);
+}
+
 int my_random_bytes(uchar* buf, int num);
 
 #ifdef __cplusplus
diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h
index 31589f0..e96f743 100644
--- a/include/mysql/plugin_audit.h
+++ b/include/mysql/plugin_audit.h
@@ -23,6 +23,10 @@
 
 #include "plugin.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MYSQL_AUDIT_CLASS_MASK_SIZE 1
 
 #define MYSQL_AUDIT_INTERFACE_VERSION 0x0302
@@ -174,5 +178,8 @@ struct st_mysql_audit
   unsigned long class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
 };
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/include/mysql/plugin_encryption.h b/include/mysql/plugin_encryption.h
index 3f35c2b..d748c4f 100644
--- a/include/mysql/plugin_encryption.h
+++ b/include/mysql/plugin_encryption.h
@@ -27,6 +27,10 @@
 
 #include <mysql/plugin.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MariaDB_ENCRYPTION_INTERFACE_VERSION 0x0300
 
 /**
@@ -114,5 +118,10 @@ struct st_mariadb_encryption
   */
   unsigned int (*encrypted_length)(unsigned int slen, unsigned int key_id, unsigned int key_version);
 };
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
diff --git a/plugin/example_key_management/example_key_management_plugin.cc b/plugin/example_key_management/example_key_management_plugin.cc
index 2b41786..d9f33b1 100644
--- a/plugin/example_key_management/example_key_management_plugin.cc
+++ b/plugin/example_key_management/example_key_management_plugin.cc
@@ -118,7 +118,7 @@ struct st_mariadb_encryption example_key_management_plugin= {
   MariaDB_ENCRYPTION_INTERFACE_VERSION,
   get_latest_key_version,
   get_key,
-  (uint (*)(unsigned int, unsigned int))my_aes_ctx_size,
+  my_aes_ctx_size_for_handler,
   ctx_init,
   my_aes_crypt_update,
   my_aes_crypt_finish,
diff --git a/plugin/file_key_management/file_key_management_plugin.cc b/plugin/file_key_management/file_key_management_plugin.cc
index e0afbd6..cff27bf 100644
--- a/plugin/file_key_management/file_key_management_plugin.cc
+++ b/plugin/file_key_management/file_key_management_plugin.cc
@@ -156,7 +156,7 @@ struct st_mariadb_encryption file_key_management_plugin= {
   MariaDB_ENCRYPTION_INTERFACE_VERSION,
   get_latest_version,
   get_key_from_key_file,
-  (uint (*)(unsigned int, unsigned int))my_aes_ctx_size,
+  my_aes_ctx_size_for_handler,
   ctx_init,
   my_aes_crypt_update,
   my_aes_crypt_finish,
diff --git a/sql/encryption.cc b/sql/encryption.cc
index 209b092..8bcc57b 100644
--- a/sql/encryption.cc
+++ b/sql/encryption.cc
@@ -23,11 +23,16 @@
 static plugin_ref encryption_manager= 0;
 struct encryption_service_st encryption_handler;
 
-uint no_key(uint)
+extern "C" {
+
+static uint no_key(uint)
 {
   return ENCRYPTION_KEY_VERSION_INVALID;
 }
 
+static uint (*no_key_get)(uint, uint, uchar*, uint*)=
+      (uint (*)(uint, uint, uchar*, uint*))no_key;
+
 static int ctx_init(void *ctx, const unsigned char* key, unsigned int klen,
                     const unsigned char* iv, unsigned int ivlen, int flags,
                     unsigned int key_id, unsigned int key_version)
@@ -40,6 +45,7 @@ static unsigned int get_length(unsigned int slen, unsigned int key_id,
 {
   return my_aes_get_size(MY_AES_CBC, slen);
 }
+} /*extern "C"*/
 
 int initialize_encryption_plugin(st_plugin_int *plugin)
 {
@@ -59,7 +65,7 @@ int initialize_encryption_plugin(st_plugin_int *plugin)
 
   encryption_handler.encryption_ctx_size_func=
     handle->crypt_ctx_size ? handle->crypt_ctx_size :
-    (uint (*)(unsigned int, unsigned int))my_aes_ctx_size;
+                             my_aes_ctx_size_for_handler;
 
   encryption_handler.encryption_ctx_init_func=
     handle->crypt_ctx_init ? handle->crypt_ctx_init : ctx_init;
@@ -84,8 +90,7 @@ int initialize_encryption_plugin(st_plugin_int *plugin)
 
 int finalize_encryption_plugin(st_plugin_int *plugin)
 {
-  encryption_handler.encryption_key_get_func=
-      (uint (*)(uint, uint, uchar*, uint*))no_key;
+  encryption_handler.encryption_key_get_func= no_key_get;
   encryption_handler.encryption_key_get_latest_version_func= no_key;
 
   if (plugin && plugin->plugin->deinit && plugin->plugin->deinit(NULL))
@@ -99,6 +104,7 @@ int finalize_encryption_plugin(st_plugin_int *plugin)
   return 0;
 }
 
+
 /******************************************************************
   Encryption Scheme service
 ******************************************************************/
diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc
index e0c8c98..be5f7cd 100644
--- a/unittest/sql/mf_iocache-t.cc
+++ b/unittest/sql/mf_iocache-t.cc
@@ -72,7 +72,7 @@ struct encryption_service_st encryption_handler=
 {
   encryption_key_get_latest_version_func,
   encryption_key_get_func,
-  (uint (*)(unsigned int, unsigned int))my_aes_ctx_size,
+  my_aes_ctx_size_for_handler,
   encryption_ctx_init_func,
   my_aes_crypt_update,
   my_aes_crypt_finish,


More information about the commits mailing list