代码拉取完成,页面将自动刷新
同步操作将从 wuyi/shm_hash 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#pragma once
#include <stdint.h>
#include "wx_log.h"
//基于偏移的简单的单实现,用于共享内存
//只提供受限操作,操作链表经量步骤少,防止进程崩溃,链表断裂
typedef struct s_offset_list_s s_offset_list_t;
struct s_offset_list_s {
volatile uint64_t next;
};
typedef s_offset_list_t* OFFSET_TO_PTR_FUNC_T(void* context, uint64_t offset);
typedef uint64_t PTR_TO_OFFSET_FUNC_T(void* context, s_offset_list_t* node);
//需要实现,把偏移转指针
//offset_list_t* offset_to_ptr(void* context,uint32_t offset);
//需要实现,把指针转偏移
//uint32_t ptr_to_offset(void* context,offset_list_t* node);
static inline
void s_offset_list_init(s_offset_list_t* head) {
head->next = 0;
}
//向链表上头节点挂,先改待插入节点
static inline
void s_offset_list_insert_head(s_offset_list_t* head, s_offset_list_t* node, void* context,
OFFSET_TO_PTR_FUNC_T offset_to_ptr, PTR_TO_OFFSET_FUNC_T ptr_to_offset) {
// auto next= offset_to_ptr(context,node->next);
auto node_offset=ptr_to_offset(context,node);
// auto h_offset= ptr_to_offset(context,head);
(node)->next = (head)->next;
(head)->next = node_offset;
}
static inline
bool s_offset_list_empty(s_offset_list_t* head) {
return (head->next == 0);
}
static inline
void s_offset_list_clear(s_offset_list_t* head) {
head->next = 0;
}
static inline
s_offset_list_t* s_offset_list_get_head(s_offset_list_t* list,void* context, OFFSET_TO_PTR_FUNC_T offset_to_ptr, PTR_TO_OFFSET_FUNC_T ptr_to_offset) {
return offset_to_ptr(context, list->next) ;
}
static inline
s_offset_list_t* s_offset_list_get_next(s_offset_list_t* node, void* context,OFFSET_TO_PTR_FUNC_T offset_to_ptr, PTR_TO_OFFSET_FUNC_T ptr_to_offset) {
return offset_to_ptr(context, node->next);
}
static inline
s_offset_list_t* s_offset_list_remove_head(s_offset_list_t* list,void* context, OFFSET_TO_PTR_FUNC_T offset_to_ptr, PTR_TO_OFFSET_FUNC_T ptr_to_offset) {
s_offset_list_t* head=offset_to_ptr(context, list->next);
if (head != nullptr) {
list->next = head->next;
}
else {
list->next = 0;
}
return head;
}
static inline
void s_offset_list_remove_head_next(s_offset_list_t* list, uint64_t next, void* context, OFFSET_TO_PTR_FUNC_T offset_to_ptr, PTR_TO_OFFSET_FUNC_T ptr_to_offset) {
list->next = next;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。