-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utils: add arm32-specific NanoSleep implementation #3930
Conversation
util/sleep_linux.go
Outdated
@@ -14,6 +14,9 @@ | |||
// You should have received a copy of the GNU Affero General Public License | |||
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | |||
|
|||
//go:build !arm && linux | |||
// +build !arm,linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the _linux filename provides its own build tag constraints based on whether GOOS=linux ... I'm not sure if you can mix file suffixes with build tags? or maybe you can?
https://dave.cheney.net/2013/10/12/how-to-use-conditional-compilation-with-the-go-build-tool
if not maybe change the name of this file to not end with _linux (but otherwise keep the rest the same)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh found this: https://pkg.go.dev/cmd/go#hdr-Build_constraints
If a file's name, after stripping the extension and a possible _test suffix, matches any of the following patterns:
*_GOOS
*_GOARCH
*_GOOS_GOARCH
(example: source_windows_amd64.go) where GOOS and GOARCH represent any known operating system and architecture values respectively, then the file is considered to have an implicit build constraint requiring those terms (in addition to any explicit constraints in the file).
^^ "in addition to any explicit constraints in the file" so I guess that is OK (though you are getting the linux
constraint for free from the filename)
util/sleep_linux_arm.go
Outdated
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
//go:build arm && linux | ||
// +build arm,linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might as well throw 386
in too as well as arm
?
util/sleep_linux_common.go
Outdated
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
//go:build linux | ||
// +build linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very tiny nit, but wouldn't this file be better named sleep_linux.go and then have the other two be called sleep_linux_32.go and sleep_linux_64.go or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense, added 386 as well
7e8bbb6
to
407f472
Compare
407f472
to
3c12c4c
Compare
Codecov Report
@@ Coverage Diff @@
## master #3930 +/- ##
==========================================
+ Coverage 49.95% 49.98% +0.03%
==========================================
Files 400 400
Lines 68651 68651
==========================================
+ Hits 34295 34316 +21
+ Misses 30649 30628 -21
Partials 3707 3707
Continue to review full report at Codecov.
|
Summary
arm32 has int32 field members in Timespec struct, but Nanoseconds() returns int64.
The arm32-specific implementation of NanoSleep casts it to int32 as Timespec expects.
Test Plan
Existing tests