ndbuf_setflags manual has been added;

This commit is contained in:
Alexander Vdolainen 2025-10-28 04:07:05 +02:00
parent 1d37a8fbba
commit 546667e837
4 changed files with 86 additions and 1 deletions

View File

@ -4,5 +4,5 @@ man_MANS = ndbuf_new.3 ndbuf_new_palloc.3 ndbuf_new_wmops.3 ndbuf_new_frombuf.3
ndbuf_write_u32.3 ndbuf_write_u64.3 ndbuf_write_raw_head.3 ndbuf_escan.3 \
ndbuf_escan_va.3 ndbuf_escan_wot.3 ndbuf_print.3 ndbuf_print_va.3 ndbuf_print_wot.3 \
ndbuf_length.3 ndbuf_alength.3 ndbuf_leftlength.3 ndbuf_setlength.3 ndbuf_rdata.3 \
ndbuf_rdatacur.3 ndbuf_resetcur.3
ndbuf_rdatacur.3 ndbuf_resetcur.3 ndbuf_setflags.3 ndbuf_exflags.3 ndbuf_flagsreset.3

1
man/ndbuf_exflags.3 Symbolic link
View File

@ -0,0 +1 @@
ndbuf_setflags.3

1
man/ndbuf_flagsreset.3 Symbolic link
View File

@ -0,0 +1 @@
ndbuf_setflags.3

83
man/ndbuf_setflags.3 Normal file
View File

@ -0,0 +1,83 @@
.TH NDBUF_SETFLAGS 3 "28 October 2021" "NDBUF" "Binary buffers library manual"
.SH NAME
ndbuf_setflags, ndbuf_exflags, ndbuf_flagsreset - manage flags controlling ndbuf behaviour
.SH SYNOPSIS
.nf
#include <ndbuf/ndbuf.h>
void ndbuf_setflags(ndbuf_t *b, int flags);
void ndbuf_exflags(ndbuf_t *b, int flags);
#define ndbuf_flagsreset(a) ndbuf_exflags((a), 0)
.nf
.SH LIBRARY
libndbuf
.SH DESCRIPTION
These functions manipulate the flags associated with an ndbuf_t instance. Flags control behavioural aspects such as zero-copy/copyless operation, burn semantics, read/write permissions, and other implementation-specific options. See SUPPORTED FLAGS.
.IP "\fBvoid ndbuf_setflags(ndbuf_t *b, int flags)\fR"
Set the buffer's flags to the provided flags value. This replaces the current flag set with flags. Use this when you want to explicitly assign a new flags mask.
.IP "\fBvoid ndbuf_exflags(ndbuf_t *b, int flags)\fR"
Exchange (apply) flags with the buffer; semantics are implementation-dependent but commonly used to modify or merge flags. In libndbuf this function is used to set flags while optionally returning or replacing previous flags state (check the header/source for exact behavior). Typically exflags will update the buffer's flags to flags; callers expecting previous flags should obtain them via the appropriate accessor if available.
.IP "\fB#define ndbuf_flagsreset(a) ndbuf_exflags((a), 0)\fR"
Reset all flags on the buffer by calling ndbuf_exflags with 0. This macro provides a convenient way to clear all flag bits.
.SH SUPPORTED FLAGS
.IP "\fBNDBUF_BURN\fR"
Burn data before freeing.
.IP "\fBNDBUF_NREA\fR"
Make the data buffer non-reallocatable.
.IP "\fBNDBUF_UCMD\fR"
Buffer with custom memory operations provided.
.IP "\fBNDBUF_RORB\fR"
Buffer is read-only.
.IP "\fBNDBUF_MOLS\fR"
Zero-copy buffer.
.SH BEHAVIOR AND USAGE NOTES
Flags are implementation-defined bitmasks; use only the constants defined by libndbuf.
Changing flags can affect memory ownership and lifetime semantics (for example, toggling zero-copy/copyless may change whether returned pointers reference internal storage or newly allocated memory). Ensure callers understand implications before changing flags on a buffer containing live data.
These functions do not allocate memory themselves. However, changing flags that affect ownership semantics may influence subsequent operations that allocate or free memory.
There is no return value; error conditions (if any) are reported via ndbuf_t state or other library diagnostics. Passing a NULL pointer yields undefined behavior.
.SH THREAD SAFETY
Concurrent modification of flags on the same ndbuf_t without external synchronization is unsafe. Use appropriate locking when multiple threads may read or modify flags.
.SH EXAMPLES
.nf
/* Set buffer to copyless (zero-copy) and burn mode */
ndbuf_setflags(buf, NDBUF_MOLS | NDBUF_BURN);
/* Clear all flags */
ndbuf_flagsreset(buf);
/* Exchange flags - set read-only */
ndbuf_exflags(buf, NDBUF_RORB);
.nf
.SH SEE ALSO
.BR ndbuf_new(3) ,
.BR ndbuf_free_item(3) ,
.BR ndbuf_escan(3) ,
.BR ndbuf_print(3)
.SH COPYRIGHT
This software is licensed under the GNU Lesser General Public License version 2.1 or later. See the COPYING file in the project repository for full license text.
.PP
(c) Authors of libndbuf 2017-2018 (http://vapaa.xyz)
.SH AUTHOR
Alexander Vdolainen <alex@vapaa.xyz>