From b8c3d3c5f1b3db3b89ed975bb51c7546676f2bd1 Mon Sep 17 00:00:00 2001
From: Wenkai Lin <linwenkai6@hisilicon.com>
Date: Mon, 10 Jan 2022 18:52:04 +0800
Subject: [PATCH 41/53] uadk: include: fix uadk compatibility

Fix that C++ program can't call the uadk interface.

Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com>
---
 include/drv/wd_aead_drv.h   | 9 +++++++++
 include/drv/wd_cipher_drv.h | 9 +++++++++
 include/drv/wd_comp_drv.h   | 8 ++++++++
 include/drv/wd_dh_drv.h     | 8 ++++++++
 include/drv/wd_digest_drv.h | 9 +++++++++
 include/drv/wd_ecc_drv.h    | 8 ++++++++
 include/drv/wd_rsa_drv.h    | 8 ++++++++
 include/hisi_qm_udrv.h      | 8 ++++++++
 include/uacce.h             | 9 +++++++++
 include/wd.h                | 8 ++++++++
 include/wd_aead.h           | 8 ++++++++
 include/wd_alg_common.h     | 8 ++++++++
 include/wd_cipher.h         | 8 ++++++++
 include/wd_common.h         | 8 ++++++++
 include/wd_comp.h           | 8 ++++++++
 include/wd_dh.h             | 8 ++++++++
 include/wd_digest.h         | 8 ++++++++
 include/wd_rsa.h            | 8 ++++++++
 include/wd_sched.h          | 8 ++++++++
 include/wd_util.h           | 8 ++++++++
 20 files changed, 164 insertions(+)

diff --git a/include/drv/wd_aead_drv.h b/include/drv/wd_aead_drv.h
index d2016f0..78a5673 100644
--- a/include/drv/wd_aead_drv.h
+++ b/include/drv/wd_aead_drv.h
@@ -7,6 +7,10 @@
 #include "include/wd_alg_common.h"
 #include "include/wd_aead.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct wd_aead_msg {
 	struct wd_aead_req req;
 	/* Request identifier */
@@ -87,4 +91,9 @@ static void __attribute__((constructor)) set_aead_driver(void)		      \
 	wd_aead_set_driver(&drv);					      \
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_AEAD_DRV_H */
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index d6798c0..e649869 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -7,6 +7,10 @@
 #include "../wd_cipher.h"
 #include "../wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* fixme wd_cipher_msg */
 struct wd_cipher_msg {
 	struct wd_cipher_req req;
@@ -72,4 +76,9 @@ static void __attribute__((constructor)) set_driver(void)		      \
 	wd_cipher_set_driver(&drv);					      \
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_CIPHER_DRV_H */
diff --git a/include/drv/wd_comp_drv.h b/include/drv/wd_comp_drv.h
index b4dc722..8146a50 100644
--- a/include/drv/wd_comp_drv.h
+++ b/include/drv/wd_comp_drv.h
@@ -7,6 +7,10 @@
 #include <pthread.h>
 #include "../wd_comp.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum wd_comp_strm_pos {
 	WD_COMP_STREAM_NEW,
 	WD_COMP_STREAM_OLD,
@@ -79,4 +83,8 @@ static void __attribute__((constructor)) set_driver(void)		      \
 }
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_COMP_DRV_H */
diff --git a/include/drv/wd_dh_drv.h b/include/drv/wd_dh_drv.h
index 08212b1..5d436d1 100644
--- a/include/drv/wd_dh_drv.h
+++ b/include/drv/wd_dh_drv.h
@@ -6,6 +6,10 @@
 
 #include "../wd_dh.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* DH message format */
 struct wd_dh_msg {
 	struct wd_dh_req req;
@@ -45,4 +49,8 @@ static void __attribute__((constructor)) set_driver_dh(void)		\
 }
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_DH_DRV_H */
diff --git a/include/drv/wd_digest_drv.h b/include/drv/wd_digest_drv.h
index ac3b028..fdde772 100644
--- a/include/drv/wd_digest_drv.h
+++ b/include/drv/wd_digest_drv.h
@@ -6,6 +6,10 @@
 #include "include/wd_digest.h"
 #include "include/wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* fixme wd_digest_msg */
 struct wd_digest_msg {
 	struct wd_digest_req req;
@@ -75,4 +79,9 @@ static void __attribute__((constructor)) set_drivers(void)		      \
 	wd_digest_set_driver(&drv);					      \
 }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_DIGEST_DRV_H */
diff --git a/include/drv/wd_ecc_drv.h b/include/drv/wd_ecc_drv.h
index 9f4575f..7e0d27e 100644
--- a/include/drv/wd_ecc_drv.h
+++ b/include/drv/wd_ecc_drv.h
@@ -7,6 +7,10 @@
 #include "../wd_ecc.h"
 #include "../wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* ECC */
 #define ECDH_IN_PARAM_NUM		2
 #define ECDH_OUT_PARAM_NUM		2
@@ -198,4 +202,8 @@ static void __attribute__((constructor)) set_driver_ecc(void)		\
 }
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_ECC_DRV_H */
diff --git a/include/drv/wd_rsa_drv.h b/include/drv/wd_rsa_drv.h
index 3c4b144..948625f 100644
--- a/include/drv/wd_rsa_drv.h
+++ b/include/drv/wd_rsa_drv.h
@@ -5,6 +5,10 @@
 
 #include "../wd_rsa.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct wd_rsa_kg_in {
 	__u8 *e;
 	__u8 *p;
@@ -70,4 +74,8 @@ static void __attribute__((constructor)) set_driver_rsa(void)		      \
 }
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_RSA_DRV_H */
diff --git a/include/hisi_qm_udrv.h b/include/hisi_qm_udrv.h
index 11ee4ad..707d0e3 100644
--- a/include/hisi_qm_udrv.h
+++ b/include/hisi_qm_udrv.h
@@ -12,6 +12,10 @@
 #include "wd.h"
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define WD_CAPA_PRIV_DATA_SIZE		64
 
 #define QM_L32BITS_MASK		0xffffffff
@@ -180,4 +184,8 @@ __u32 hisi_qm_get_list_size(struct wd_datalist *start_node,
 
 void hisi_qm_enable_interrupt(handle_t ctx, __u8 enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/uacce.h b/include/uacce.h
index 7c69df8..07e36fe 100644
--- a/include/uacce.h
+++ b/include/uacce.h
@@ -10,6 +10,10 @@
 #include <linux/types.h>
 #include <linux/ioctl.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define UACCE_CMD_START         _IO('W', 0)
 #define UACCE_CMD_PUT_Q         _IO('W', 1)
 #define UACCE_CMD_GET_SS_DMA    _IOR('W', 100, unsigned long)
@@ -33,4 +37,9 @@ enum uacce_qfrt {
 	UACCE_QFRT_DUS = 1,	/* device user share */
 	UACCE_QFRT_MAX,
 };
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/wd.h b/include/wd.h
index ac564d8..273cbb8 100644
--- a/include/wd.h
+++ b/include/wd.h
@@ -14,6 +14,10 @@
 #include <unistd.h>
 #include "uacce.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define PATH_STR_SIZE			256
 #define MAX_ATTR_STR_SIZE		384
 #define WD_NAME_SIZE			64
@@ -483,4 +487,8 @@ void wd_mempool_stats(handle_t mempool, struct wd_mempool_stats *stats);
  */
 void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/wd_aead.h b/include/wd_aead.h
index 6377008..f169812 100644
--- a/include/wd_aead.h
+++ b/include/wd_aead.h
@@ -14,6 +14,10 @@
 #include "wd_digest.h"
 #include "wd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  * wd_aead_op_type - Algorithm type of option
  */
@@ -214,4 +218,8 @@ void wd_aead_ctx_num_uninit(void);
 int wd_aead_get_env_param(__u32 node, __u32 type, __u32 mode,
 			  __u32 *num, __u8 *is_enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_AEAD_H */
diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h
index 01a12ca..94336f0 100644
--- a/include/wd_alg_common.h
+++ b/include/wd_alg_common.h
@@ -12,6 +12,10 @@
 #include "wd.h"
 #include "wd_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Required compiler attributes */
 #define likely(x)       __builtin_expect(!!(x), 1)
 #define unlikely(x)     __builtin_expect(!!(x), 0)
@@ -103,4 +107,8 @@ struct wd_datalist {
 	struct wd_datalist *next;
 };
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/wd_cipher.h b/include/wd_cipher.h
index 8c73396..660d7e8 100644
--- a/include/wd_cipher.h
+++ b/include/wd_cipher.h
@@ -11,6 +11,10 @@
 #include "wd.h"
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define AES_KEYSIZE_128	16
 #define AES_KEYSIZE_192	24
 #define AES_KEYSIZE_256	32
@@ -185,4 +189,8 @@ void wd_cipher_ctx_num_uninit(void);
 int wd_cipher_get_env_param(__u32 node, __u32 type, __u32 mode,
 			    __u32 *num, __u8 *is_enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_CIPHER_H */
diff --git a/include/wd_common.h b/include/wd_common.h
index 61919d5..91dd066 100644
--- a/include/wd_common.h
+++ b/include/wd_common.h
@@ -7,9 +7,17 @@
 #ifndef __WD_COMMON_H
 #define __WD_COMMON_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum wd_buff_type {
 	WD_FLAT_BUF,
 	WD_SGL_BUF,
 };
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_COMMON_H */
diff --git a/include/wd_comp.h b/include/wd_comp.h
index b6225df..460cfa7 100644
--- a/include/wd_comp.h
+++ b/include/wd_comp.h
@@ -12,6 +12,10 @@
 #include "wd.h"
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum wd_comp_alg_type {
 	WD_DEFLATE,
 	WD_ZLIB,
@@ -217,4 +221,8 @@ void wd_comp_ctx_num_uninit(void);
 int wd_comp_get_env_param(__u32 node, __u32 type, __u32 mode,
 			  __u32 *num, __u8 *is_enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_COMP_H */
diff --git a/include/wd_dh.h b/include/wd_dh.h
index c0bce85..f342722 100644
--- a/include/wd_dh.h
+++ b/include/wd_dh.h
@@ -12,6 +12,10 @@
 #include "wd.h"
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define BYTE_BITS			8
 #define BYTE_BITS_SHIFT			3
 #define GET_NEGATIVE(val)		(0 - (val))
@@ -69,4 +73,8 @@ void wd_dh_ctx_num_uninit(void);
 int wd_dh_get_env_param(__u32 node, __u32 type, __u32 mode,
 			__u32 *num, __u8 *is_enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_DH_H */
diff --git a/include/wd_digest.h b/include/wd_digest.h
index 8e8e236..7e93a80 100644
--- a/include/wd_digest.h
+++ b/include/wd_digest.h
@@ -11,6 +11,10 @@
 #include "wd_alg_common.h"
 #include "wd.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_HMAC_KEY_SIZE	128U
 
 /**
@@ -209,4 +213,8 @@ void wd_digest_ctx_num_uninit(void);
 int wd_digest_get_env_param(__u32 node, __u32 type, __u32 mode,
 			    __u32 *num, __u8 *is_enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_DIGEST_H */
diff --git a/include/wd_rsa.h b/include/wd_rsa.h
index 044819b..081bc2a 100644
--- a/include/wd_rsa.h
+++ b/include/wd_rsa.h
@@ -12,6 +12,10 @@
 #include "wd.h"
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define BYTE_BITS			8
 #define BYTE_BITS_SHIFT			3
 #define CRT_PARAMS_SZ(key_size)		((5 * (key_size)) >> 1)
@@ -216,4 +220,8 @@ void wd_rsa_ctx_num_uninit(void);
 int wd_rsa_get_env_param(__u32 node, __u32 type, __u32 mode,
 			 __u32 *num, __u8 *is_enable);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_RSA_H */
diff --git a/include/wd_sched.h b/include/wd_sched.h
index 78125f4..2ae6103 100644
--- a/include/wd_sched.h
+++ b/include/wd_sched.h
@@ -8,6 +8,10 @@
 #define SCHED_SAMPLE_h
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define INVALID_POS	0xFFFFFFFF
 
 /* The global policy type */
@@ -56,4 +60,8 @@ struct wd_sched *wd_sched_rr_alloc(__u8 sched_type, __u8 type_num,
  */
 void wd_sched_rr_release(struct wd_sched *sched);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/include/wd_util.h b/include/wd_util.h
index de2cd44..ef95907 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -10,6 +10,10 @@
 #include <stdbool.h>
 #include "wd_alg_common.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define FOREACH_NUMA(i, config, config_numa) \
 	for (i = 0, config_numa = config->config_per_numa; \
 	     i < config->numa_num; config_numa++, i++)
@@ -309,4 +313,8 @@ int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
  */
 int wd_check_ctx(struct wd_ctx_config_internal *config, __u8 mode, __u32 idx);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __WD_UTIL_H */
-- 
2.25.1

