From 7ff738390e55d57a0f513c467a9da3b08c6902ab Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 29 Oct 2024 01:02:02 -0600 Subject: Add a way to make private object members --- lib9p/include/lib9p/srv.h | 20 +++++++++----------- lib9p/srv.c | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'lib9p') diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index 0617e57..ab7ec43 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -23,21 +24,14 @@ struct lib9p_srv_ctx { uint32_t uid; char *uname; + BEGIN_PRIVATE(LIB9P_SRV_H) _lib9p_srv_flushch_t _flushch; + END_PRIVATE(LIB9P_SRV_H) }; -static inline bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) { - assert(ctx); - return _lib9p_srv_flushch_can_send(&ctx->_flushch); -} +bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx); -static inline int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { - assert(ctx); - assert(_lib9p_srv_flushch_can_send(&ctx->_flushch)); - lib9p_error(&ctx->basectx, LINUX_ECANCELED, "request canceled by flush"); - _lib9p_srv_flushch_send(&ctx->_flushch, true); - return -1; -} +int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx); /* interface definitions ******************************************************/ @@ -47,6 +41,7 @@ struct __lib9p_srv_file; typedef struct __lib9p_srv_file { struct lib9p_srv_file_vtable *vtable; + BEGIN_PRIVATE(LIB9P_SRV_H) /* Managed by srv.c, but should be cloned by ->vtable->clone(). */ struct __lib9p_srv_file *_parent_dir; /* clone this @@ -54,6 +49,7 @@ typedef struct __lib9p_srv_file { /* ref type 1: an entry in fidmap * ref type 2: ->_parent_dir of another file */ unsigned int _refcount; + END_PRIVATE(LIB9P_SRV_H) } implements_lib9p_srv_file; struct lib9p_srv_file_vtable { @@ -103,7 +99,9 @@ struct lib9p_srv { implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename); /* For internal use */ + BEGIN_PRIVATE(LIB9P_SRV_H) _lib9p_srv_reqch_t _reqch; + END_PRIVATE(LIB9P_SRV_H) }; /** diff --git a/lib9p/srv.c b/lib9p/srv.c index 3a3807c..9192794 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -16,9 +16,25 @@ #include #include +#define IMPLEMENTATION_FOR_LIB9P_SRV_H YES #include #include "internal.h" +/* context ********************************************************************/ + +bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) { + assert(ctx); + return _lib9p_srv_flushch_can_send(&ctx->_flushch); +} + +int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { + assert(ctx); + assert(_lib9p_srv_flushch_can_send(&ctx->_flushch)); + lib9p_error(&ctx->basectx, LINUX_ECANCELED, "request canceled by flush"); + _lib9p_srv_flushch_send(&ctx->_flushch, true); + return -1; +} + /* structs ********************************************************************/ #define FIDFLAG_OPEN_R (1<<0) -- cgit v1.2.3-2-g168b