Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit fee36ff

Browse files
authored
Merge pull request #3116 from n8sh/issue-20787-followup
Followup to #3076: make core.sys.darwin.sys.attr.attrlist usable in betterC merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 69d120f + 49b7054 commit fee36ff

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/core/sys/darwin/sys/attr.d

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern (C):
1919
nothrow:
2020
@nogc:
2121

22+
import core.internal.attributes : betterC;
2223
import core.sys.darwin.sys.cdefs : c_ulong;
2324
import core.sys.posix.sys.time : timeval;
2425

@@ -53,8 +54,7 @@ alias uint text_encoding_t, fsobj_type_t, fsobj_tag_t, fsfile_type_t, fsvolid_t,
5354

5455
struct attrlist
5556
{
56-
ushort bitmapcount = ATTR_BIT_MAP_COUNT;
57-
ushort reserved = 0;
57+
ushort bitmapcount, reserved;
5858
attrgroup_t commonattr, volattr, dirattr, fileattr, forkattr;
5959
}
6060
enum ATTR_BIT_MAP_COUNT = 5;
@@ -314,3 +314,25 @@ static assert(searchstate.sizeof == uint.sizeof * 2 + searchstate.ss_fsstate.siz
314314
"searchstate struct must be packed");
315315

316316
enum FST_EOF = -1;
317+
318+
@betterC @nogc nothrow pure @safe unittest
319+
{
320+
// Use an enum instead of `version (Darwin)` so it works with the betterc test extractor.
321+
version (OSX) enum isDarwin = true;
322+
else version (iOS) enum isDarwin = true;
323+
else version (TVOS) enum isDarwin = true;
324+
else version (WatchOS) enum isDarwin = true;
325+
else enum isDarwin = false;
326+
static if (isDarwin)
327+
{
328+
// Verify that these types don't need __initZ and so can be used in betterC.
329+
attrlist al;
330+
attribute_set_t as;
331+
attrreference_t ar;
332+
diskextent de;
333+
vol_capabilities_attr_t vca;
334+
vol_attributes_attr_t vaa;
335+
fssearchblock fsb;
336+
searchstate ss;
337+
}
338+
}

0 commit comments

Comments
 (0)