Skip to content

Commit

Permalink
Same user-defined literals, as functions for variable conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Jul 28, 2019
1 parent baa9ce9 commit 15145bb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions include/dosbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,34 @@ static inline constexpr bytecount_t operator "" _tebibytes(const bytecount_t x)
return x << bytecount_t(40u);
}

/* and the same, for variables */

static inline constexpr bytecount_t _bytes(const bytecount_t x) {
return x;
}

static inline constexpr bytecount_t _parabytes(const bytecount_t x) { /* AKA bytes per segment increment in real mode */
return x << bytecount_t(4u);
}

static inline constexpr bytecount_t _kibibytes(const bytecount_t x) {
return x << bytecount_t(10u);
}

static inline constexpr bytecount_t _pagebytes(const bytecount_t x) { /* bytes per 4KB page in protected mode */
return x << bytecount_t(12u);
}

static inline constexpr bytecount_t _mibibytes(const bytecount_t x) {
return x << bytecount_t(20u);
}

static inline constexpr bytecount_t _gibibytes(const bytecount_t x) {
return x << bytecount_t(30u);
}

static inline constexpr bytecount_t _tebibytes(const bytecount_t x) {
return x << bytecount_t(40u);
}

#endif /* DOSBOX_DOSBOX_H */

0 comments on commit 15145bb

Please sign in to comment.