nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
279 stars 39 forks source link

Fix `sysrand` for Android (and some other POSIX platforms) #1391

Closed starsiderfox closed 4 months ago

starsiderfox commented 4 months ago

Summary

Fixes a bug that caused the compiler to fail to compile anything with e.g. --os:android (and some uncommon POSIX platforms) when it uses sysrand in any way, such as when importing random . koch was affected so one couldn't bootstrap nimskull in android as the host platform.

Details

There's two POSIX constants used in sysrand.nim that are not actually constants for some platforms like Android. EINTR and EAGAIN are required to be constants at compile time because they're used in a case of but the condition is so simple that we can replace it by an if statement.

They're technically constants in all platforms, but on the C side (taken from errno.h ), not in nimskull, and the latter is oblivious to the content of those header files.

zerbina commented 4 months ago

The change itself looks good, but the PR descriptions needs adjustment.

Please make sure that the summary makes it clear what didn't work and works now, namely that importing the sysrand module (directly or indirectly) caused compilation failures when building for Android or some other Posix platforms.

starsiderfox commented 4 months ago

The change itself looks good, but the PR descriptions needs adjustment.

Please make sure that the summary makes it clear what didn't work and works now, namely that importing the sysrand module (directly or indirectly) caused compilation failures when building for Android or some other Posix platforms.

Done

zerbina commented 4 months ago

/merge

github-actions[bot] commented 4 months ago

Merge requested by: @zerbina

Contents after the first section break of the PR description has been removed and preserved below: