public static int nextIntegerMultipleWithCongruence(int start, int multipleOf, int congruentTo, int modulo) { // FIXME: this is a stupid solution; improvements wanted (some maths is required) int candidate = start; while (candidate % modulo != congruentTo % modulo) { candidate = nextIntegerMultiple(candidate + 1, multipleOf); } return candidate; }
int vaddr = !requireModuloConstraint ? nextIntegerMultiple(nextAvailableVaddr, el.getAlignment()) : ObjectFile.nextIntegerMultipleWithCongruence(nextAvailableVaddr, el.getAlignment(), fileOffset % el.getOwner().getPageSize(), el.getOwner().getPageSize()); nextAvailableVaddr = vaddr + el.getMemSize(alreadyDecided);
public static int defaultGetOrDecideOffset(Map<Element, LayoutDecisionMap> alreadyDecided, Element el, int offsetHint) { // FIXME: in this implementation, we must not have decided the vaddr already! // We should instead support both cases, and if the vaddr is decided, apply // the modulo constraint (if necessary) here! assert (alreadyDecided.get(el).getDecision(LayoutDecision.Kind.VADDR) == null || !alreadyDecided.get(el).getDecision(LayoutDecision.Kind.VADDR).isTaken()); // now we are free to worry about the modulo constraint during vaddr assignment only // we take the hint, but bumped up to proper alignment return defaultGetOrDecide(alreadyDecided, el, LayoutDecision.Kind.OFFSET, nextIntegerMultiple(offsetHint, el.getAlignment())); }
int vmSize = ObjectFile.nextIntegerMultiple(maxVaddr - minVaddr, getPageSize()); effectiveFileSize = ObjectFile.nextIntegerMultiple(effectiveFileSize, getPageSize()); minimumFileSize = Math.max(minimumFileSize, effectiveFileOffset + effectiveFileSize);