/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2011 Danny Robson */ #include "si.hpp" uintmax_t to_KiB (uintmax_t bytes) { return bytes >> 10; } uintmax_t to_MiB (uintmax_t bytes) { return bytes >> 20; } uintmax_t to_GiB (uintmax_t bytes) { return bytes >> 30; } uintmax_t from_KiB (uintmax_t bytes) { return bytes << 10; } uintmax_t from_MiB (uintmax_t bytes) { return bytes << 20; } uintmax_t from_GiB (uintmax_t bytes) { return bytes << 30; }