Skip to content
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

Closed
StefanScherer opened this issue Nov 18, 2015 · 5 comments
Closed

Wrong type in syscall type Utsname: uint8 instead of int8 #13318

StefanScherer opened this issue Nov 18, 2015 · 5 comments

Comments

@StefanScherer
Copy link

  • What version of Go are you using (go version)?

go version go1.4.3 linux/arm

  • What operating system and processor architecture are you using?

$ 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/"

  • What did you do?

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.

  • What did you expect to see?

To have the same types for linux/arm

  • What did you see instead?

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?

@minux
Copy link
Member

minux commented Nov 19, 2015 via email

@davecheney
Copy link
Contributor

Possibly this could be addressed in the implementation in the x/sys repo.
Possibly it already has, I haven't checked.

On Thu, Nov 19, 2015 at 11:03 AM, Minux Ma notifications@github.com wrote:

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.


Reply to this email directly or view it on GitHub
#13318 (comment).

@minux
Copy link
Member

minux commented Nov 19, 2015 via email

@robpike
Copy link
Contributor

robpike commented Nov 19, 2015

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.

@robpike robpike closed this as completed Nov 19, 2015
@StefanScherer
Copy link
Author

That to clarify this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants