Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pal_endian.h « Common « Native « src - github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 69315acc613cad7e2de7b8638e700ada1f455a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#pragma once

#include <inttypes.h>

inline uint16_t SWAP16(uint16_t x)
{
    return (x >> 8) | (x << 8);
}

inline uint32_t SWAP32(uint32_t x)
{
    return  (x >> 24) |
            ((x >> 8) & 0x0000FF00L) |
            ((x & 0x0000FF00L) << 8) |
            (x << 24);
}