-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
Wrong type in syscall type Utsname: uint8 instead of int8 #13318
Comments
The problem is because the signedness of the char type in C is different on
different architectures.
On ARM, due to limitations of old generation architectures, char is
unsigned, so the translated Go type is uint8 not int8.
We probably should have fixed this before Go 1, but now we cannot do
anything about it due to the Go 1 API guarantee.
|
Possibly this could be addressed in the implementation in the x/sys repo. On Thu, Nov 19, 2015 at 11:03 AM, Minux Ma notifications@github.com wrote:
|
I don't think we should change x/sys/unix too, as it will
break already working programs.
It hasn't changed:
https://github.com/golang/sys/blob/master/unix/ztypes_linux_arm.go#L542
|
Package syscall is OS-dependent. One should guard code that uses it with +build tags. You should never expect a syscall invocation to work on multiple platforms. That's what the os package is for. |
That to clarify this. |
go version go1.4.3 linux/arm
$ uname -a
Linux ef19e7655f61 4.2.5-263 #1 SMP Wed Nov 4 17:03:17 UTC 2015 armv7l armv7l armv7l GNU/Linux
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
I want to compile Docker for ARM but stumbled upon a problem that the type of Utsname is different for linux/arm to all other intel platforms.
Also the official golang docs says that it uses
[65]int8
but for linux/arm it is[65]uint8
.To have the same types for linux/arm
I had to add a workaround to read the value into a string in two different ways, one for intel, one for linux/arm.
Is there any reason that the type is different here?
The text was updated successfully, but these errors were encountered: