From nobody Tue Dec 20 02:15:33 2022 X-Original-To: doc@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NbgCT6FLZz1Gn2P for ; Tue, 20 Dec 2022 02:15:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NbgCT5DhHz42qC for ; Tue, 20 Dec 2022 02:15:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671502533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xCe0Sc7FoGPSUPVR8g51SYOBOLJwNWxp17px6YMOc+U=; b=Wz8iVzKVbOodvvuVLBFNQjvLKk1AGq2Fnu13eTIeWF5cLYjQUJB/y08dikSfbyjQ2myi/n ZtyKXy3NB9/mIPrqBpejRomxItJ9X5EiO+sb2KHXer8YI7j6yP8aY+SkJYiFWlGLHoqpkG FZi7KknKTsLw5Akpn06QSDsgK/ACqd1WzvM2uRiPatov+VYlccFSRJYHljHh3D7rIISDz7 Fdvh1magRibovUxA1X+mkETq6A6I5njxq5JaWUlACmaP9Ta7S9I80cKyxEUxkBMAYAPES/ 3U+9KQHs1OSuUx6R3wMD+5NwXIUdsY5Zp9Rqu/nf9Q0E72gnBOnGWKuURgu9Bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671502533; a=rsa-sha256; cv=none; b=DBk+9JBNzKvrSZkUSiQ3uUSob2FWZk+BKx2IYllFvDp8OId16hF9vwhSjqQAs16ufYJkQO /F07O6DYLRGbfq0RcJ5LpfbjqaRkfihsKA5tcnQ+Lt79ogYUnf3lwlnOYGAeioikCwrgxD kSd8dHbf/oWMXS27DZJNAA00NOE5p61hDV8ow0Kt5nwWPWxq7Y7o3wseEvju2otWTxftnX B5HkOzv8O6c+RKy3etN9ffVYj7cG/tuyhoVCY2Sm7kU6+kVGuxdc2qNP+imdl9GO2qp19h 0YsLB5OAacthjIWqGFFRmEfzLlED1zIXvDwP0AkA7gbgi7+r9o5So4eXsQ9XvQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NbgCT4CqFzJX9 for ; Tue, 20 Dec 2022 02:15:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 2BK2FXw9037288 for ; Tue, 20 Dec 2022 02:15:33 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2BK2FXFX037287 for doc@FreeBSD.org; Tue, 20 Dec 2022 02:15:33 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: doc@FreeBSD.org Subject: [Bug 268310] add sizeof(7) man page Date: Tue, 20 Dec 2022 02:15:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Documentation X-Bugzilla-Component: Manual Pages X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: jschauma@netmeister.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Documentation project List-Archive: https://lists.freebsd.org/archives/freebsd-doc List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-doc@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268310 --- Comment #7 from jschauma@netmeister.org --- Here you go: --- in-tree.txt 2022-12-19 21:13:16.000000000 -0500 +++ sizeof.7 2022-12-19 21:14:16.000000000 -0500 @@ -1,6 +1,5 @@ .\" .\" Copyright (C) 2022 Jan Schaumann . -.\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -35,17 +34,30 @@ .br .Nm Vt expression .Sh DESCRIPTION -The size of primitive data types in C may differ -across hardware platforms and implementations. -It may be necessary or useful for a program to be able -to determine the storage size of a data type or object. -.Pp The unary .Nm operator yields the storage size of an expression or -data type in +data type in bytes. +.Sh DETAILS +The size of data types in C (such as e.g., integers or +pointers) may differ across hardware platforms and +implementations. +For example, systems on which integers, longs, and +pointers are using 32 bits (e.g., i386) are referred +to as using the "ILP32" data model, systems using +64 bit longs and pointers (e.g., amd64 / x86_64) +as the "LP64" data model. +.Pp +As it may be necessary or useful for a program to be able +to determine the storage size of a data type or +object, +.Nm +yields that size in .Em char sized units . -As a result, 'sizeof(char)' is always guaranteed to be 1. +As a result, +.Pf ' Vt sizeof(char) Ns ' +is always guaranteed to be +1. (The number of bits per .Vt char is given by the @@ -59,13 +71,6 @@ .In sys/param.h header.) .Sh EXAMPLES -Different platforms may use different data models. -For example, systems on which integers, longs, and -pointers are using 32 bits (e.g., i386) are referred -to as using the "ILP32" data model, systems using -64 bit longs and pointers (e.g., amd64 / x86_64) -as the "LP64" data model. -.Pp The following examples illustrate the possible results of calling .Nm @@ -129,7 +134,7 @@ .Pp When applied to a struct or union, .Nm -returns the total number of units in the object, +returns the total number of bytes in the object, including any internal or trailing padding used to align the object in memory. This result may thus be larger than if the storage @@ -229,7 +234,7 @@ Many systems provide this shortcut as the macro .Dv ntimes() via the -.In sys/param.h +.Dv sys/param.h header file. .Sh RESULT The result of the @@ -252,8 +257,10 @@ .Ed .Pp In that case, the operator will return the storage -size of the pointer ('sizeof(char *)'), not the -allocated memory! +size of the pointer +.Pf (' Vt sizeof(char *) Ns '), +not the +allocated memory. .Pp .Nm determines the @@ -270,6 +277,11 @@ preprocessor, the .Nm operator cannot be used in a preprocessor expression. +.Pp +The +.Nm +operator cannot be used on a bit-field object, a +function type, or an incomplete type. .Sh SEE ALSO .Xr arch 7 , .Xr operator 7 --=20 You are receiving this mail because: You are on the CC list for the bug.=