Skip to content

[linux] better construction of setrlimit’s first parameter - #1835

Open
glessard wants to merge 2 commits into
swiftlang:mainfrom
glessard:glibc-rlimit_resource_t
Open

[linux] better construction of setrlimit’s first parameter#1835
glessard wants to merge 2 commits into
swiftlang:mainfrom
glessard:glibc-rlimit_resource_t

Conversation

@glessard

@glessard glessard commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

For Linux, construct setrlimit's first parameter using the name of its typedef rather than using CInt.

Motivation:

Glibc declares the typedef as 'int' normally, but as an enumeration under '_GNU_SOURCE’. Spelling the conversion using the typedef’s name allows this call to compile either way.

Modifications:

Substitution of a constructor name.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • [n/a] If public symbols are renamed or modified, DocC references should be updated.

Construct the parameter using its typedef rather than 'CInt’. Glibc declares the typedef as 'int' normally, but as an enumeration under '_GNU_SOURCE’. Spelling the conversion using the typedef’s name compiles either way.
@grynspan

Copy link
Copy Markdown
Contributor

Please try running @swift-ci commands against an empty PR on the swiftlang/swift repo.

We should make sure a full toolchain build succeeds before you merge this PR.

@grynspan grynspan added the linux 🐧 Linux support (all distros) label Aug 17, 2026
@grynspan grynspan added this to the Swift 6.5.0 (main) milestone Aug 17, 2026
Comment thread Sources/Testing/ExitTests/ExitTest.swift Outdated
@glessard

glessard commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

We should make sure a full toolchain build succeeds before you merge this PR.

swiftlang/swift#91514 (comment)
https://ci.swift.org/job/swift-PR-toolchain-Linux/1831/

Not from an empty PR, because GitHub is having a bad day. Used a stdlib-only PR instead.

Construct the parameter using an unnamed, unlabeled initializer. Glibc declares the typedef to be over 'int' normally, but under `_GNU_SOURCE` declares it over an enumeration. The unlabled initializer lets the compiler infer the precise type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linux 🐧 Linux support (all distros)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants