.\" $OpenBSD: SMR_PTR_GET.9,v 1.3 2019/07/05 04:46:26 dlg Exp $ .\" .\" Copyright (c) 2019 Visa Hankala .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: July 5 2019 $ .Dt SMR_PTR_GET 9 .Os .Sh NAME .Nm SMR_PTR_GET , .Nm SMR_PTR_GET_LOCKED , .Nm SMR_PTR_SET_LOCKED .Nd safe memory reclamation pointer API .Sh SYNOPSIS .Ft TYPE .Fn SMR_PTR_GET "TYPE *pptr" .Ft TYPE .Fn SMR_PTR_GET_LOCKED "TYPE *pptr" .Ft void .Fn SMR_PTR_SET_LOCKED "TYPE *pptr" "TYPE v" .Sh DESCRIPTION The SMR_PTR macros are used for accessing SMR-protected pointers. .Pp The macro .Fn SMR_PTR_GET reads the pointer referenced by .Fa pptr for dereferencing inside SMR read-side critical section. .Pp .Fn SMR_PTR_GET_LOCKED reads the pointer referenced by .Fa pptr for dereferencing inside writer context. .Pp .Fn SMR_PTR_SET_LOCKED writes value .Fa v to the pointer referenced by .Fa pptr . The operation issues a write-write memory barrier with .Xr membar_producer 9 before the pointer write. .Sh CONTEXT .Fn SMR_PTR_GET , .Fn SMR_PTR_GET_LOCKED and .Fn SMR_PTR_SET_LOCKED can be called during autoconf, from process context, or from interrupt context. .Pp .Fn SMR_PTR_GET can be used from SMR read-side critical section. .Fn SMR_PTR_GET_LOCKED and .Fn SMR_PTR_SET_LOCKED can be used from writer context. .Sh SEE ALSO .Xr membar_producer 9 , .Xr SMR_LIST_INIT 9 , .Xr smr_read_enter 9 .Sh HISTORY The SMR_PTR macros first appeared in .Ox 6.5 .