@@ -226,6 +226,14 @@ func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e
226226 return (* [1 << 30 ]byte )(addr )[:length :length ], nil
227227}
228228
229+ func Munmap (b []byte ) (err error ) {
230+ errCode := libc_munmap (unsafe .Pointer (& b [0 ]), uintptr (len (b )))
231+ if errCode != 0 {
232+ err = getErrno ()
233+ }
234+ return err
235+ }
236+
229237func Mprotect (b []byte , prot int ) (err error ) {
230238 errCode := libc_mprotect (unsafe .Pointer (& b [0 ]), uintptr (len (b )), int32 (prot ))
231239 if errCode != 0 {
@@ -234,6 +242,10 @@ func Mprotect(b []byte, prot int) (err error) {
234242 return
235243}
236244
245+ func Getpagesize () int {
246+ return int (libc_getpagesize ())
247+ }
248+
237249func Environ () []string {
238250
239251 // This function combines all the environment into a single allocation.
@@ -343,10 +355,18 @@ func libc_dup(fd int32) int32
343355//export mmap
344356func libc_mmap (addr unsafe.Pointer , length uintptr , prot , flags , fd int32 , offset uintptr ) unsafe.Pointer
345357
358+ // int munmap(void *addr, size_t length);
359+ //export munmap
360+ func libc_munmap (addr unsafe.Pointer , length uintptr ) int32
361+
346362// int mprotect(void *addr, size_t len, int prot);
347363//export mprotect
348364func libc_mprotect (addr unsafe.Pointer , len uintptr , prot int32 ) int32
349365
366+ // int getpagesize();
367+ //export getpagesize
368+ func libc_getpagesize () int32
369+
350370// int chdir(const char *pathname, mode_t mode);
351371//export chdir
352372func libc_chdir (pathname * byte ) int32
0 commit comments