From nobody Tue Dec 20 02:15:33 2022 X-Original-To: bugs@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 4NbgCT5FRvz1GnBQ 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 4NbgCT3s0Tz42wT 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=l1v9qKyZHMLk9qCAoxKeoWpfsYBK/hoe9VixkADauT0=; b=xSa5K3+mLBGXjpYSTUh4UcswRnA7/vJADQddN/p7cxorULiYqQTpQ0oIXKcOQ/Av+nDs3g Z04JpWkYOqHj+ScAmpRYIgFpbIXhTEzdL9MauhgWjafaAvyzgw5fiAlkP0rmENhsMbXQkZ 9b3D8qWxi9sIiEuWZ80S6XkqfFL8gtwqsaEtncNYtzpGsGtrBTmxiGMwpTUIpDGe43lFh6 pQRfRXeKa470KtVPaesgSmAgBAK453K43Qy2H0Bw5lE6Kpa3bpAFuytoFxUayiL1Lrhfcv FVYzzQNkGyiuGdS3c+eRWFOiFzoCgbjzSROn/gt4cGv7l3HcmFgIBZ6BTqf9kA== 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=inKPooxS2SvjXV7LeFQkFTmg2pjlwI/AEEFHG/Ruz82vvBDSmaVwG+CUZqS7bweDb1eOQJ /CjgPZcGG/cusVGZOXKzTwn8HpQUdLr3RSKFDpHer4o357MgIyeZMpwX5aJUxqu5Ciddvm 09bkKU67NaDHe3FUiLg7G39KuB3Az7lEZpCaxQOSOctfBMOXXoUxA7osyYVy09rnrrGoMG hAe2f4DBnP/Jxu2jeInQC7LHQtUb1Xtq2c9+Ucuu0B+TIEegeXRx5xBNV0YDyQvOHs/fkp 2CaMBAl4r2sOfi9AH3KpJjxrjeEAqD0Zm6jng+DWhv7H1RanGQRutcfzdXIhUA== 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 4NbgCT2pTZzJCJ 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 2BK2FXbl037280 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 2BK2FXsT037277 for bugs@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: bugs@FreeBSD.org Subject: [Bug 268310] add sizeof(7) man page Date: Tue, 20 Dec 2022 02:15:33 +0000 X-Bugzilla-Reason: AssignedTo 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: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@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 the assignee for the bug.=