github.com/aloncn/graphics-go@v0.0.1/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 cgo
     6  
     7  // +build linux,amd64
     8  
     9  #include <errno.h>
    10  #include <stdint.h>
    11  #include <sys/mman.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  	p = mmap(addr, length, prot, flags, fd, offset);
    18  	if (p == MAP_FAILED) {
    19  		/* This is what the Go code expects on failure.  */
    20  		p = (void *) (uintptr_t) errno;
    21  	}
    22  	return p;
    23  }