Deleted Added
sdiff udiff text old ( 8766:b0773af78423 ) new ( 8795:0909f8ed7aa0 )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 664 unchanged lines hidden (view full) ---

673 (new_length % TheISA::VMPageSize != 0)) {
674 warn("mremap failing: arguments not page aligned");
675 return -EINVAL;
676 }
677
678 if (new_length > old_length) {
679 if ((start + old_length) == process->mmap_end) {
680 uint64_t diff = new_length - old_length;
681 process->pTable->allocate(process->mmap_end, diff);
682 process->mmap_end += diff;
683 return start;
684 } else {
685 // sys/mman.h defined MREMAP_MAYMOVE
686 if (!(flags & 1)) {
687 warn("can't remap here and MREMAP_MAYMOVE flag not set\n");
688 return -ENOMEM;
689 } else {
690 process->pTable->remap(start, old_length, process->mmap_end);
691 warn("mremapping to totally new vaddr %08p-%08p, adding %d\n",
692 process->mmap_end, process->mmap_end + new_length, new_length);
693 start = process->mmap_end;
694 // add on the remaining unallocated pages
695 process->pTable->allocate(start + old_length, new_length - old_length);
696 process->mmap_end += new_length;
697 warn("returning %08p as start\n", start);
698 return start;
699 }
700 }
701 } else {
702 process->pTable->deallocate(start + new_length, old_length -
703 new_length);
704 return start;
705 }
706}
707
708/// Target stat() handler.
709template <class OS>
710SyscallReturn
711statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

--- 311 unchanged lines hidden (view full) ---

1023 if ((start % TheISA::VMPageSize) != 0 ||
1024 (length % TheISA::VMPageSize) != 0) {
1025 warn("mmap failing: arguments not page-aligned: "
1026 "start 0x%x length 0x%x",
1027 start, length);
1028 return -EINVAL;
1029 }
1030
1031 if (start != 0) {
1032 warn("mmap: ignoring suggested map address 0x%x, using 0x%x",
1033 start, p->mmap_end);
1034 }
1035
1036 // pick next address from our "mmap region"
1037 if (OS::mmapGrowsDown()) {
1038 start = p->mmap_end - length;
1039 p->mmap_end = start;
1040 } else {
1041 start = p->mmap_end;
1042 p->mmap_end += length;
1043 }
1044 p->pTable->allocate(start, length);
1045
1046 return start;
1047}
1048
1049/// Target getrlimit() handler.
1050template <class OS>
1051SyscallReturn
1052getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1053 ThreadContext *tc)

--- 187 unchanged lines hidden ---