xaizek / tos (License: GPLv3 only) (since 2018-12-07)
This is an alternative version of sources presented as part of Write Your Own OS video tutorial by Viktor Engelmann.
<root> / src / utils / conv.hpp (0144259bd158c4433f3819e3dc7215776d4aa108) (609B) (mode 100644) [raw]
#ifndef TOS__UTILS__CONV_HPP__
#define TOS__UTILS__CONV_HPP__

#include <cstdint>

constexpr std::uint16_t
ntoh(std::uint16_t word)
{
    return ((word & 0x00ff) << 8)
         | ((word & 0xff00) >> 8);
}

constexpr std::uint32_t
ntoh(std::uint32_t dword)
{
    return ((dword & 0x000000ff) << 24)
         | ((dword & 0x0000ff00) << 8)
         | ((dword & 0x00ff0000) >> 8)
         | ((dword & 0xff000000) >> 24);
}

constexpr std::uint16_t
hton(std::uint16_t word)
{
    return ntoh(word);
}

constexpr std::uint32_t
hton(std::uint32_t dword)
{
    return ntoh(dword);
}

#endif // TOS__UTILS__CONV_HPP__
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/tos

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/tos

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master