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

x/sys/unix: Missing constants for fadvise() #15114

Closed
fd0 opened this issue Apr 4, 2016 · 4 comments
Closed

x/sys/unix: Missing constants for fadvise() #15114

fd0 opened this issue Apr 4, 2016 · 4 comments

Comments

@fd0
Copy link

fd0 commented Apr 4, 2016

  1. What version of Go are you using (go version)?
    go version go1.6 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
    Archlinux on amd64:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fd0/shared/work/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

The program at https://gist.github.com/6587a615cea63183676e2f2887d59d62 uses Fadvise from the unix package to purge data written to a file from the OS cache. The constants for this function (FADV_*) are defined in types_linux.go, but cannot be accessed from the outside of the unix package. This makes using Fadvise() awkward because I need to define the constants myself.

For the reference, here are the constants I'm missing:
https://github.com/golang/sys/blob/master/unix/types_linux.go#L175-L185

Running GOOS=linux GOARCH=amd64 mkall.sh inserts the constants into ztypes_linux_amd64.go.

I'm happy to submit a CL if someone gives me a hint on how to fix this.

  1. What did you expect to see?

The FADV_* constants (e.g. FADV_DONTNEED) exported in the package unix.

  1. What did you see instead?

FADV_DONTNEED is either not defined or not exported in the package, so users need to define that themselves.

@bradfitz bradfitz added this to the Unreleased milestone Apr 4, 2016
@fd0
Copy link
Author

fd0 commented Apr 8, 2016

@bradfitz can you advise me how to fix this? I'd be happy to submit a CL :)

When running mkall.sh, many more things are changed besides the introduction of the missing constants...

@ianlancetaylor
Copy link
Contributor

Add the constants to x/sys/unix/types_*.go, run mkall.sh, revert the unrelated changes. Some day we will clean up mkall.sh, and if you want to tackle that that would be great, but you don't have to.

@fd0
Copy link
Author

fd0 commented Apr 9, 2016

Submitted as https://go-review.googlesource.com/#/c/21753/, thanks for the advice.

@gopherbot
Copy link

CL https://golang.org/cl/21753 mentions this issue.

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

4 participants