mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-11 06:26:41 +00:00
15ff64e03a
Nintendo does this as of latest firmware. It's desirable because it removes the only usage of util::SNPrintf() from os library, which means programs which don't otherwise use SNPrintf do not need to link it into .text. This saves ~0xD40 of .text as of time-of-commit when successfully unlinking, and e.g. reduces our sm (and other modules) memory size by a page.
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include <stratosphere.hpp>
|
|
#include "os_utility.hpp"
|
|
|
|
namespace ams::os::impl {
|
|
|
|
void ExpandUnsignedValueToAscii(char *dst, u64 value) {
|
|
/* Determine size needed. */
|
|
constexpr size_t SizeNeeded = (BITSIZEOF(value) / 4) * sizeof(char);
|
|
|
|
/* Write null-terminator. */
|
|
dst[SizeNeeded] = '\x00';
|
|
|
|
/* Write characters. */
|
|
for (size_t i = 0; i < SizeNeeded; ++i) {
|
|
/* Determine current character. */
|
|
const auto nybble = (value & 0xF);
|
|
const char cur_c = (nybble < 10) ? ('0' + nybble) : ('A' + nybble - 10);
|
|
|
|
/* Write current character. */
|
|
dst[SizeNeeded - 1 - i] = cur_c;
|
|
|
|
/* Shift to next nybble. */
|
|
value >>= 4;
|
|
}
|
|
}
|
|
|
|
}
|