• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define _GNU_SOURCE
2 #include <unistd.h>
3 #include <sys/mman.h>
4 #include <errno.h>
5 #include <stdint.h>
6 #include <stdarg.h>
7 #include "syscall.h"
8 
dummy(void)9 static void dummy(void) { }
10 weak_alias(dummy, __vm_wait);
11 
__mremap(void * old_addr,size_t old_len,size_t new_len,int flags,...)12 void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
13 {
14 	va_list ap;
15 	void *new_addr = 0;
16 
17 	if (new_len >= PTRDIFF_MAX) {
18 		errno = ENOMEM;
19 		return MAP_FAILED;
20 	}
21 
22 	if (flags & MREMAP_FIXED) {
23 		__vm_wait();
24 		va_start(ap, flags);
25 		new_addr = va_arg(ap, void *);
26 		va_end(ap);
27 	}
28 
29 	return (void *)syscall(SYS_mremap, old_addr, old_len, new_len, flags, new_addr);
30 }
31 
32 weak_alias(__mremap, mremap);
33