CS318 - Pintos
Pintos source browser for JHU CS318 course
round.h
Go to the documentation of this file.
1 #ifndef __LIB_ROUND_H
2 #define __LIB_ROUND_H
3 
4 /** Yields X rounded up to the nearest multiple of STEP.
5  For X >= 0, STEP >= 1 only. */
6 #define ROUND_UP(X, STEP) (((X) + (STEP) - 1) / (STEP) * (STEP))
7 
8 /** Yields X divided by STEP, rounded up.
9  For X >= 0, STEP >= 1 only. */
10 #define DIV_ROUND_UP(X, STEP) (((X) + (STEP) - 1) / (STEP))
11 
12 /** Yields X rounded down to the nearest multiple of STEP.
13  For X >= 0, STEP >= 1 only. */
14 #define ROUND_DOWN(X, STEP) ((X) / (STEP) * (STEP))
15 
16 /** There is no DIV_ROUND_DOWN. It would be simply X / STEP. */
17 
18 #endif /**< lib/round.h */