@@ -226,6 +226,14 @@ func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e
226
226
return (* [1 << 30 ]byte )(addr )[:length :length ], nil
227
227
}
228
228
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
+
229
237
func Mprotect (b []byte , prot int ) (err error ) {
230
238
errCode := libc_mprotect (unsafe .Pointer (& b [0 ]), uintptr (len (b )), int32 (prot ))
231
239
if errCode != 0 {
@@ -234,6 +242,10 @@ func Mprotect(b []byte, prot int) (err error) {
234
242
return
235
243
}
236
244
245
+ func Getpagesize () int {
246
+ return int (libc_getpagesize ())
247
+ }
248
+
237
249
func Environ () []string {
238
250
239
251
// This function combines all the environment into a single allocation.
@@ -343,10 +355,18 @@ func libc_dup(fd int32) int32
343
355
//export mmap
344
356
func libc_mmap (addr unsafe.Pointer , length uintptr , prot , flags , fd int32 , offset uintptr ) unsafe.Pointer
345
357
358
+ // int munmap(void *addr, size_t length);
359
+ //export munmap
360
+ func libc_munmap (addr unsafe.Pointer , length uintptr ) int32
361
+
346
362
// int mprotect(void *addr, size_t len, int prot);
347
363
//export mprotect
348
364
func libc_mprotect (addr unsafe.Pointer , len uintptr , prot int32 ) int32
349
365
366
+ // int getpagesize();
367
+ //export getpagesize
368
+ func libc_getpagesize () int32
369
+
350
370
// int chdir(const char *pathname, mode_t mode);
351
371
//export chdir
352
372
func libc_chdir (pathname * byte ) int32
0 commit comments