[ffigen] Generate C wrappers for capturing errno
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 47
Description
Two subsequent FFI calls are not atomic from an OS point of view.
This means that accessing `GetLastError` and `errno` are flaky.
With the work progressing on native assets, our current idea to address this is to wrap the existing C call:
* https://github.com/dart-lang/sdk/issues/38832#issuecomment-1943800274
We'd rather not have users write wrappers by hand. So maybe we can explore generating them with FFIgen.
Some example uses of the APIs can be found in this abandoned CL: https://dart-review.googlesource.com/c/sdk/+/240847
Possible way of configuring wrappers
```yaml
functions:
capture-errno:
- '.*'
capture-GetLastError:
- '.*'
```
And we should probably generate a return type that is a tuple with the potential error and the normal return value.
Contributor guide
Assessment
This issue has not been assessed yet.