This repository was archived by the owner on Feb 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +44
-7
lines changed Expand file tree Collapse file tree 2 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -2476,10 +2476,10 @@ <h3 id="functions-offsetof">offsetof</h3>
24762476< div class ="title "> variants</ div >
24772477< ul >
24782478< li >
2479- < p > < code > offsetof(STRUCT, FIELD)</ code > </ p >
2479+ < p > < code > offsetof(STRUCT, FIELD[.SUBFIELD] )</ code > </ p >
24802480</ li >
24812481< li >
2482- < p > < code > offsetof(EXPRESSION, FIELD)</ code > </ p >
2482+ < p > < code > offsetof(EXPRESSION, FIELD[.SUBFIELD] )</ code > </ p >
24832483</ li >
24842484</ ul >
24852485</ div >
@@ -2488,8 +2488,27 @@ <h3 id="functions-offsetof">offsetof</h3>
24882488</ div >
24892489< div class ="paragraph ">
24902490< p > Returns offset of the field offset bytes in struct.
2491- Similar to kernel < code > offsetof</ code > operator.
2492- Note that subfields are not yet supported.</ p >
2491+ Similar to kernel < code > offsetof</ code > operator.</ p >
2492+ </ div >
2493+ < div class ="paragraph ">
2494+ < p > Support any number of sub field levels, for example:</ p >
2495+ </ div >
2496+ < div class ="listingblock ">
2497+ < div class ="content ">
2498+ < pre > struct Foo {
2499+ struct {
2500+ struct {
2501+ struct {
2502+ int d;
2503+ } c;
2504+ } b;
2505+ } a;
2506+ }
2507+ BEGIN {
2508+ @x = offsetof(struct Foo, a.b.c.d);
2509+ exit();
2510+ }</ pre >
2511+ </ div >
24932512</ div >
24942513</ div >
24952514< div class ="sect2 ">
Original file line number Diff line number Diff line change @@ -1782,14 +1782,32 @@ You can also pass the address type (e.g. AF_INET) explicitly as the first parame
17821782=== offsetof
17831783
17841784.variants
1785- * `offsetof(STRUCT, FIELD)`
1786- * `offsetof(EXPRESSION, FIELD)`
1785+ * `offsetof(STRUCT, FIELD[.SUBFIELD] )`
1786+ * `offsetof(EXPRESSION, FIELD[.SUBFIELD] )`
17871787
17881788*compile time*
17891789
17901790Returns offset of the field offset bytes in struct.
17911791Similar to kernel `offsetof` operator.
1792- Note that subfields are not yet supported.
1792+
1793+ Support any number of sub field levels, for example:
1794+
1795+ ----
1796+ struct Foo {
1797+ struct {
1798+ struct {
1799+ struct {
1800+ int d;
1801+ } c;
1802+ } b;
1803+ } a;
1804+ }
1805+ BEGIN {
1806+ @x = offsetof(struct Foo, a.b.c.d);
1807+ exit();
1808+ }
1809+ ----
1810+
17931811
17941812[#functions-override]
17951813=== override
You can’t perform that action at this time.
0 commit comments