From e888eb3aa0ee76cdbb9a8193be40075857d1cf41 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期一, 22 二月 2021 14:07:25 +0800
Subject: [PATCH] add shm start resycle
---
bhomebus.go | 9 +++++++++
libcbhomebus.c | 8 ++++++++
libcbhomebus_func.h | 6 ++++++
libcbhomebus.h | 3 +++
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/bhomebus.go b/bhomebus.go
index 1e3aec3..1ddcc17 100644
--- a/bhomebus.go
+++ b/bhomebus.go
@@ -169,6 +169,15 @@
return nil
}
+// ShmStartRecycle recycle
+func ShmStartRecycle() error {
+ if libbhomebus == nil {
+ return errors.New("C BHomeBus Handle Is Nil")
+ }
+ C.wrap_fn_shm_start_recycle(libbhomebus)
+ return nil
+}
+
// ShmAllocKey alloc key
func ShmAllocKey() int {
if libbhomebus == nil {
diff --git a/libcbhomebus.c b/libcbhomebus.c
index 7d3796f..c255be5 100644
--- a/libcbhomebus.c
+++ b/libcbhomebus.c
@@ -65,6 +65,14 @@
return fn_shm_alloc_key();
}
+int wrap_fn_shm_start_recycle(hbhomebus lib){
+ if (!fn_shm_start_recycle){
+ fn_shm_start_recycle = (tfn_shm_start_resycle)dlsym(lib, l_shm_start_recycle);
+ check_with_ret(fn_shm_start_recycle, lib, -1);
+ }
+ return fn_shm_start_recycle();
+}
+
void wrap_fn_shm_destroy(hbhomebus lib){
if (!fn_shm_destroy){
printf("shm destroy failed\n");
diff --git a/libcbhomebus.h b/libcbhomebus.h
index da0fd2c..7ce55b0 100644
--- a/libcbhomebus.h
+++ b/libcbhomebus.h
@@ -12,6 +12,7 @@
// shm manipulate
static tfn_shm_init fn_shm_init = NULL;
static tfn_shm_alloc_key fn_shm_alloc_key = NULL;
+static tfn_shm_start_resycle fn_shm_start_recycle = NULL;
static tfn_shm_destroy fn_shm_destroy = NULL;
static tfn_shm_remove_keys fn_shm_remove_keys = NULL;
static tfn_shm_remove_keys_exclude fn_shm_remove_keys_exclude = NULL;
@@ -63,6 +64,7 @@
// shm
const static char l_shm_init[] = "shm_mm_wrapper_init";
const static char l_shm_destroy[] = "shm_mm_wrapper_destroy";
+const static char l_shm_start_recycle[] = "shm_mm_wrapper_start_resycle";
const static char l_shm_alloc_key[] = "shm_mm_wrapper_alloc_key";
const static char l_shm_remove_keys[] = "shm_mm_wrapper_remove_keys";
const static char l_shm_remove_keys_exclude[] = "shm_mm_wrapper_remove_keys_exclude";
@@ -119,6 +121,7 @@
// shm manipulate
void wrap_fn_shm_init(hbhomebus lib, int size);
int wrap_fn_shm_alloc_key(hbhomebus lib);
+int wrap_fn_shm_start_recycle(hbhomebus lib);
void wrap_fn_shm_destroy(hbhomebus lib);
int wrap_fn_shm_remove_keys(hbhomebus lib, void *keys, int length);
int wrap_fn_shm_remove_keys_exclude(hbhomebus lib, void *keys, int length);
diff --git a/libcbhomebus_func.h b/libcbhomebus_func.h
index a104766..6923987 100644
--- a/libcbhomebus_func.h
+++ b/libcbhomebus_func.h
@@ -47,6 +47,12 @@
typedef int(*tfn_shm_alloc_key) ();
/**
+ * @brief 鍥炴敹鏍囪涓哄垹闄ょ殑闃熷垪
+ * @return 閿欒鐮�
+ */
+typedef int (*tfn_shm_start_resycle)() ;
+
+/**
* 鎵归噺鍒犻櫎key瀵瑰簲鐨勫叡浜槦鍒楋紝骞跺湪bus閲屽垹闄よkey鐨勮闃�
*/
typedef int(*tfn_shm_remove_keys) (int*, int);
--
Gitblit v1.8.0