mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-27 07:30:59 -08:00
Sizeroundup, change.epcore.anchovy.160134
Copied from Perforce Change: 20061 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
b1f65db60a
commit
f79e42e1a9
2 changed files with 30 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/* impl.c.mpm: GENERAL MPM SUPPORT
|
||||
*
|
||||
* $HopeName: MMsrc!mpm.c(trunk.25) $
|
||||
* $HopeName: MMsrc!mpm.c(trunk.26) $
|
||||
* Copyright (C) 1996. Harlequin Group plc. All rights reserved.
|
||||
*
|
||||
* .readership: MM developers.
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
#include <float.h>
|
||||
|
||||
|
||||
SRCID(mpm, "$HopeName: MMsrc!mpm.c(trunk.25) $");
|
||||
SRCID(mpm, "$HopeName: MMsrc!mpm.c(trunk.26) $");
|
||||
|
||||
|
||||
/* MPMCheck -- test MPM assumptions */
|
||||
|
|
@ -140,6 +140,25 @@ Word (WordAlignUp)(Word word, Align align)
|
|||
return WordAlignUp(word, align);
|
||||
}
|
||||
|
||||
/* WordRoundUp -- round word up to round.
|
||||
*
|
||||
* .wordroundup.arg.word: the quantity to be rounded.
|
||||
* .wordroundup.arg.round: The modulus to round to. Not necessarily
|
||||
* an alignment (ie not a power of two).
|
||||
*
|
||||
* .wordroundup.result:
|
||||
* Let m be congruent to 0 mod r (m == 0(r)),
|
||||
* and let m be the least m >= w.
|
||||
* If w+r-1 (!) is representible in Word then result is m.
|
||||
* Otherwise result is 0. Wittily.
|
||||
* (NB result may be 0 even if m is representible)
|
||||
*/
|
||||
Word (WordRoundUp)(Word word, Size round)
|
||||
{
|
||||
AVER(round > 0);
|
||||
return WordRoundUp(word, round);
|
||||
}
|
||||
|
||||
|
||||
/* WordAlignUp -- round a word down to the nearest aligned value */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* impl.h.mpm: MEMORY POOL MANAGER DEFINITIONS
|
||||
*
|
||||
* $HopeName: MMsrc!mpm.h(trunk.99) $
|
||||
* $HopeName: MMsrc!mpm.h(trunk.100) $
|
||||
* Copyright (C) 1998. Harlequin Group plc. All rights reserved.
|
||||
*/
|
||||
|
||||
|
|
@ -50,6 +50,10 @@ extern Bool (WordIsAligned)(Word word, Align align);
|
|||
extern Word (WordAlignUp)(Word word, Align align);
|
||||
#define WordAlignUp(w, a) (((w) + (a) - 1) & ~((Word)(a) - 1))
|
||||
|
||||
/* Rounds w up to a multiple of r, see impl.c.mpm for exact behaviour */
|
||||
extern Word (WordRoundUp)(Word word, Size round);
|
||||
#define WordRoundUp(w, r) (((w)+(r)-1) - ((w)+(r)-1)%(r))
|
||||
|
||||
extern Word (WordAlignDown)(Word word, Align align);
|
||||
#define WordAlignDown(w, a) ((w) & ~((Word)(a) - 1))
|
||||
|
||||
|
|
@ -90,6 +94,10 @@ extern Addr (AddrAlignDown)(Addr addr, Align align);
|
|||
#define SizeAlignUp(s, a) ((Size)WordAlignUp(SizeWord(s), (a)))
|
||||
#define SizeAlignDown(s, a) ((Size)WordAlignDown(SizeWord(s), (a)))
|
||||
|
||||
/* r not required to be a power of 2 */
|
||||
#define SizeRoundUp(s, r) \
|
||||
((Size)WordRoundUp(SizeWord(s), (Size)(r)))
|
||||
|
||||
extern Addr (AddrSet)(Addr target, Byte value, Size size);
|
||||
/* This is one of the places that implements Addr, so it's allowed to */
|
||||
/* convert to void *, see design.mps.type.addr.ops.mem. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue