github.com/peggyl/go@v0.0.0-20151008231540-ae315999c2d5/src/runtime/cgo/gcc_mmap.c (about)

     1  // Copyright 2015 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build linux,amd64
     6  
     7  #include <errno.h>
     8  #include <stdint.h>
     9  #include <sys/mman.h>
    10  
    11  void *
    12  x_cgo_mmap(void *addr, uintptr_t length, int32_t prot, int32_t flags, int32_t fd, uint32_t offset) {
    13  	void *p;
    14  
    15  	p = mmap(addr, length, prot, flags, fd, offset);
    16  	if (p == MAP_FAILED) {
    17  		/* This is what the Go code expects on failure.  */
    18  		p = (void *) (uintptr_t) errno;
    19  	}
    20  	return p;
    21  }