Wed Aug 28 22:11:25 2019 UTC ()
Add RCS Id, sort sections.


(wiz)
diff -r1.1 -r1.2 src/share/man/man9/thmap.9

cvs diff -r1.1 -r1.2 src/share/man/man9/thmap.9 (expand / switch to unified diff)

--- src/share/man/man9/thmap.9 2019/08/28 20:08:11 1.1
+++ src/share/man/man9/thmap.9 2019/08/28 22:11:25 1.2
@@ -1,13 +1,14 @@ @@ -1,13 +1,14 @@
 1.\" $NetBSD: thmap.9,v 1.2 2019/08/28 22:11:25 wiz Exp $
1.\" 2.\"
2.\" Copyright (c) 2018 Mindaugas Rasiukevicius <rmind at noxt eu> 3.\" Copyright (c) 2018 Mindaugas Rasiukevicius <rmind at noxt eu>
3.\" All rights reserved. 4.\" All rights reserved.
4.\" 5.\"
5.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
7.\" are met: 8.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
13.\" 14.\"
@@ -185,52 +186,52 @@ Return 0 on success and \-1 on failure ( @@ -185,52 +186,52 @@ Return 0 on success and \-1 on failure (
185Get the root node address. 186Get the root node address.
186The returned address will be relative to the base address. 187The returned address will be relative to the base address.
187.El 188.El
188.\" --- 189.\" ---
189.Pp 190.Pp
190Members of 191Members of
191.Vt thmap_ops_t 192.Vt thmap_ops_t
192are 193are
193.Bd -literal 194.Bd -literal
194 uintptr_t (*alloc)(size_t len); 195 uintptr_t (*alloc)(size_t len);
195 void (*free)(uintptr_t addr, size_t len); 196 void (*free)(uintptr_t addr, size_t len);
196.Ed 197.Ed
197.\" ----- 198.\" -----
198.Sh CAVEATS 
199The implementation uses pointer tagging and atomic operations. 
200This requires the base address and the allocations to provide at least word 
201alignment. 
202.Pp 
203While the 
204.Dv NULL 
205values may be inserted, 
206.Fn thmap_get 
207and 
208.Fn thmap_del 
209cannot indicate whether the key was not found or a key with a 
210.Dv NULL 
211value was found. 
212If the caller needs to indicate an "empty" value, it can use a 
213special pointer value, such as 
214.Li (void *)(uintptr_t)0x1 . 
215.\" ----- 
216.Sh EXAMPLES 199.Sh EXAMPLES
217Simple case backed by 200Simple case backed by
218.Xr malloc 3 , 201.Xr malloc 3 ,
219which could be used in multi-threaded environment: 202which could be used in multi-threaded environment:
220.Bd -literal 203.Bd -literal
221 thmap_t *kvmap; 204 thmap_t *kvmap;
222 struct obj *obj; 205 struct obj *obj;
223 206
224 kvmap = thmap_create(0, NULL); 207 kvmap = thmap_create(0, NULL);
225 assert(kvmap != NULL); 208 assert(kvmap != NULL);
226 ... 209 ...
227 obj = obj_create(); 210 obj = obj_create();
228 thmap_put(kvmap, "test", sizeof("test") - 1, obj); 211 thmap_put(kvmap, "test", sizeof("test") - 1, obj);
229 ... 212 ...
230 obj = thmap_get(kvmap, "test", sizeof("test") - 1); 213 obj = thmap_get(kvmap, "test", sizeof("test") - 1);
231 ... 214 ...
232 thmap_destroy(kvmap); 215 thmap_destroy(kvmap);
233.Ed 216.Ed
234.\" ----- 217.\" -----
235.Sh AUTHORS 218.Sh AUTHORS
236.An Mindaugas Rasiukevicius Aq Mt rmind@noxt.eu 219.An Mindaugas Rasiukevicius Aq Mt rmind@noxt.eu
 220.Sh CAVEATS
 221The implementation uses pointer tagging and atomic operations.
 222This requires the base address and the allocations to provide at least word
 223alignment.
 224.Pp
 225While the
 226.Dv NULL
 227values may be inserted,
 228.Fn thmap_get
 229and
 230.Fn thmap_del
 231cannot indicate whether the key was not found or a key with a
 232.Dv NULL
 233value was found.
 234If the caller needs to indicate an "empty" value, it can use a
 235special pointer value, such as
 236.Li (void *)(uintptr_t)0x1 .
 237.\" -----