1*01869ca4Swiz.\" $NetBSD: __arraycount.3,v 1.7 2017/07/03 21:30:58 wiz Exp $ 2cf305798Sjruoho.\" 3cf305798Sjruoho.\" Copyright (c) 2010 The NetBSD Foundation, Inc. 4cf305798Sjruoho.\" All rights reserved. 5cf305798Sjruoho.\" 6cf305798Sjruoho.\" This code is derived from software contributed to The NetBSD Foundation 7cf305798Sjruoho.\" by Jukka Ruohonen. 8cf305798Sjruoho.\" 9cf305798Sjruoho.\" Redistribution and use in source and binary forms, with or without 10cf305798Sjruoho.\" modification, are permitted provided that the following conditions 11cf305798Sjruoho.\" are met: 12cf305798Sjruoho.\" 1. Redistributions of source code must retain the above copyright 13cf305798Sjruoho.\" notice, this list of conditions and the following disclaimer. 14cf305798Sjruoho.\" 2. Redistributions in binary form must reproduce the above copyright 15cf305798Sjruoho.\" notice, this list of conditions and the following disclaimer in the 16cf305798Sjruoho.\" documentation and/or other materials provided with the distribution. 17cf305798Sjruoho.\" 18cf305798Sjruoho.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19cf305798Sjruoho.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20cf305798Sjruoho.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21cf305798Sjruoho.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22cf305798Sjruoho.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23cf305798Sjruoho.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24cf305798Sjruoho.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25cf305798Sjruoho.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26cf305798Sjruoho.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27cf305798Sjruoho.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28cf305798Sjruoho.\" POSSIBILITY OF SUCH DAMAGE. 29cf305798Sjruoho.\" 30ec9cee68Sjruoho.Dd December 16, 2010 3180d11c3eSwiz.Dt __ARRAYCOUNT 3 3241e6d382Sjoerg.Os 33cf305798Sjruoho.Sh NAME 34cf305798Sjruoho.Nm __arraycount 35cf305798Sjruoho.Nd macro for statically allocated arrays 36cf305798Sjruoho.Sh SYNOPSIS 37cf305798Sjruoho.In sys/cdefs.h 38cf305798Sjruoho.Ft size_t 39cf305798Sjruoho.Fn __arraycount x 40cf305798Sjruoho.Sh DESCRIPTION 41cf305798SjruohoThe 42cf305798Sjruoho.Fn __arraycount 43cf305798Sjruohomacro returns the number of elements in a statically allocated buffer. 44cf305798Sjruoho.Sh EXAMPLES 459f37c55eSjruohoThe following example demonstrates a typical usage of 46cf305798Sjruoho.Fn __arraycount : 47cf305798Sjruoho.Bd -literal -offset indent 4861b1cb6fSjruohouint8_t buf[BUFSIZE]; 49cf305798Sjruohosize_t i; 50cf305798Sjruoho 51cf305798Sjruoho\&... 52cf305798Sjruoho 53*01869ca4Swizfor (i = 0; i < __arraycount(buf); i++) 54cf305798Sjruoho \&... 55cf305798Sjruoho.Ed 56ec9cee68Sjruoho.Sh SEE ALSO 57ec9cee68Sjruoho.Xr cdefs 3 58cf305798Sjruoho.Sh HISTORY 59cf305798SjruohoThe 60cf305798Sjruoho.Fn __arraycount 61cf305798Sjruohomacro first appeared in 62cf305798Sjruoho.Nx 4.0 . 63