/* Copyright 2018 ComdivByZero
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#if !defined HEADER_GUARD_Uint32Bits
#    define  HEADER_GUARD_Uint32Bits 1

#include "Uint32.h"

O7_PURE_INLINE o7_uint_t Uint32Bits_Bits(Uint32_Type v) {
  return *(Uint32_t *)v;
}

O7_ALWAYS_INLINE void
  Uint32Bits_And(Uint32_Type res, Uint32_Type a1, Uint32_Type a2)
{
  *(Uint32_t *)res = *(Uint32_t *)a1 & *(Uint32_t *)a2;
}

O7_ALWAYS_INLINE void
  Uint32Bits_Or(Uint32_Type res, Uint32_Type a1, Uint32_Type a2)
{
  *(Uint32_t *)res = *(Uint32_t *)a1 | *(Uint32_t *)a2;
}

O7_ALWAYS_INLINE void
  Uint32Bits_Xor(Uint32_Type res, Uint32_Type a1, Uint32_Type a2)
{
  *(Uint32_t *)res = *(Uint32_t *)a1 ^ *(Uint32_t *)a2;
}

O7_ALWAYS_INLINE void Uint32Bits_Not(Uint32_Type res, Uint32_Type a) {
  *(Uint32_t *)res = ~*(Uint32_t *)a;
}

O7_ALWAYS_INLINE void
  Uint32Bits_Shl(Uint32_Type res, Uint32_Type a, int shift)
{
  assert(0 <= shift);
  *(Uint32_t *)res = *(Uint32_t *)a << (unsigned)shift;
}

O7_ALWAYS_INLINE void
  Uint32Bits_Shr(Uint32_Type res, Uint32_Type a, int shift)
{
  assert(0 <= shift);
  *(Uint32_t *)res = *(Uint32_t *)a >> (unsigned)shift;
}

O7_ALWAYS_INLINE void Uint32Bits_init(void) {}
O7_ALWAYS_INLINE void Uint32Bits_done(void) {}

#endif
