summaryrefslogtreecommitdiffstats
path: root/share/man/man3
diff options
context:
space:
mode:
authorjmc <jmc@openbsd.org>2010-02-18 18:28:18 +0000
committerjmc <jmc@openbsd.org>2010-02-18 18:28:18 +0000
commitf8088df460e3a159d9b4a37a4c0cd7ab7f936b09 (patch)
tree493d0db2e00e18f514f50f55a8f2aa0373a8af40 /share/man/man3
parentFix a leak that could happen with multiple requests on the one (diff)
downloadwireguard-openbsd-f8088df460e3a159d9b4a37a4c0cd7ab7f936b09.tar.xz
wireguard-openbsd-f8088df460e3a159d9b4a37a4c0cd7ab7f936b09.zip
document offsetof; from Thomas Pfaff
ok kettenis millert otto
Diffstat (limited to 'share/man/man3')
-rw-r--r--share/man/man3/Makefile4
-rw-r--r--share/man/man3/offsetof.344
2 files changed, 46 insertions, 2 deletions
diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile
index d4bfafcc210..f4fef38f6b0 100644
--- a/share/man/man3/Makefile
+++ b/share/man/man3/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.20 2008/05/11 22:19:09 millert Exp $
+# $OpenBSD: Makefile,v 1.21 2010/02/18 18:28:18 jmc Exp $
# @(#)Makefile 8.2 (Berkeley) 12/13/93
MAN= assert.3 bitstring.3 CMSG_DATA.3 dlfcn.3 dl_iterate_phdr.3 end.3 \
- intro.3 queue.3 stdarg.3 sysexits.3 tree.3
+ intro.3 offsetof.3 queue.3 stdarg.3 sysexits.3 tree.3
MLINKS+=bitstring.3 bit_alloc.3 bitstring.3 bit_clear.3 \
bitstring.3 bit_decl.3 bitstring.3 bit_ffc.3 bitstring.3 bit_ffs.3 \
bitstring.3 bit_nclear.3 bitstring.3 bit_set.3 \
diff --git a/share/man/man3/offsetof.3 b/share/man/man3/offsetof.3
new file mode 100644
index 00000000000..08cf5cc4ef3
--- /dev/null
+++ b/share/man/man3/offsetof.3
@@ -0,0 +1,44 @@
+.\" $OpenBSD: offsetof.3,v 1.1 2010/02/18 18:28:18 jmc Exp $
+.\"
+.\" Copyright (c) 2010 Thomas Pfaff <tpfaff@tp76.info>
+.\"
+.\" 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: February 18 2010 $
+.Dt OFFSETOF 3
+.Os
+.Sh NAME
+.Nm offsetof
+.Nd offset of a structure member
+.Sh SYNOPSIS
+.Fd #include <stddef.h>
+.Ft size_t
+.Fn offsetof "type" "member"
+.Sh DESCRIPTION
+The
+.Fn offsetof
+macro expands to an integer constant expression and yields the offset,
+in bytes, of the field
+.Ar member
+from the start of the structure
+.Ar type .
+.Pp
+A compiler error will result if
+.Ar member
+is not aligned to a byte boundary (i.e. it is a bit-field).
+.Sh STANDARDS
+The
+.Fn offsetof
+macro conforms to
+.St -ansiC .