syscall_emul.hh (8324:aa7a67647c7b) syscall_emul.hh (8600:b0d7c64ada19)
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;

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

1022 if ((start % TheISA::VMPageSize) != 0 ||
1023 (length % TheISA::VMPageSize) != 0) {
1024 warn("mmap failing: arguments not page-aligned: "
1025 "start 0x%x length 0x%x",
1026 start, length);
1027 return -EINVAL;
1028 }
1029
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;

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

1022 if ((start % TheISA::VMPageSize) != 0 ||
1023 (length % TheISA::VMPageSize) != 0) {
1024 warn("mmap failing: arguments not page-aligned: "
1025 "start 0x%x length 0x%x",
1026 start, length);
1027 return -EINVAL;
1028 }
1029
1030 if (start != 0) {
1031 warn("mmap: ignoring suggested map address 0x%x, using 0x%x",
1032 start, p->mmap_end);
1030 // are we ok with clobbering existing mappings? only set this to
1031 // true if the user has been warned.
1032 bool clobber = false;
1033
1034 // try to use the caller-provided address if there is one
1035 bool use_provided_address = (start != 0);
1036
1037 if (use_provided_address) {
1038 // check to see if the desired address is already in use
1039 if (!p->pTable->isUnmapped(start, length)) {
1040 // there are existing mappings in the desired range
1041 // whether we clobber them or not depends on whether the caller
1042 // specified MAP_FIXED
1043 if (flags & OS::TGT_MAP_FIXED) {
1044 // MAP_FIXED specified: clobber existing mappings
1045 warn("mmap: MAP_FIXED at 0x%x overwrites existing mappings\n",
1046 start);
1047 clobber = true;
1048 } else {
1049 // MAP_FIXED not specified: ignore suggested start address
1050 warn("mmap: ignoring suggested map address 0x%x\n", start);
1051 use_provided_address = false;
1052 }
1053 }
1033 }
1034
1054 }
1055
1035 // pick next address from our "mmap region"
1036 if (OS::mmapGrowsDown()) {
1037 start = p->mmap_end - length;
1038 p->mmap_end = start;
1039 } else {
1040 start = p->mmap_end;
1041 p->mmap_end += length;
1056 if (!use_provided_address) {
1057 // no address provided, or provided address unusable:
1058 // pick next address from our "mmap region"
1059 if (OS::mmapGrowsDown()) {
1060 start = p->mmap_end - length;
1061 p->mmap_end = start;
1062 } else {
1063 start = p->mmap_end;
1064 p->mmap_end += length;
1065 }
1042 }
1066 }
1043 p->pTable->allocate(start, length);
1044
1067
1068 p->pTable->allocate(start, length, clobber);
1069
1045 return start;
1046}
1047
1048/// Target getrlimit() handler.
1049template <class OS>
1050SyscallReturn
1051getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1052 ThreadContext *tc)

--- 187 unchanged lines hidden ---
1070 return start;
1071}
1072
1073/// Target getrlimit() handler.
1074template <class OS>
1075SyscallReturn
1076getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
1077 ThreadContext *tc)

--- 187 unchanged lines hidden ---