github.com/FenixAra/go@v0.0.0-20170127160404-96ea0918e670/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  #include "libcgo.h"
    12  
    13  void *
    14  x_cgo_mmap(void *addr, uintptr_t length, int32_t prot, int32_t flags, int32_t fd, uint32_t offset) {
    15  	void *p;
    16  
    17  	_cgo_tsan_acquire();
    18  	p = mmap(addr, length, prot, flags, fd, offset);
    19  	_cgo_tsan_release();
    20  	if (p == MAP_FAILED) {
    21  		/* This is what the Go code expects on failure.  */
    22  		p = (void *) (uintptr_t) errno;
    23  	}
    24  	return p;
    25  }