common_types.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright (C) 2005-2012 Gekko Emulator
  3. *
  4. * @file common_types.h
  5. * @author ShizZy <shizzy247@gmail.com>
  6. * @date 2012-02-11
  7. * @brief Common types used throughout the project
  8. *
  9. * @section LICENSE
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details at
  19. * http://www.gnu.org/copyleft/gpl.html
  20. *
  21. * Official project repository can be found at:
  22. * http://code.google.com/p/gekko-gc-emu/
  23. */
  24. #pragma once
  25. #include <array>
  26. #include <cstdint>
  27. #ifdef _MSC_VER
  28. #ifndef __func__
  29. #define __func__ __FUNCTION__
  30. #endif
  31. #endif
  32. typedef std::uint8_t u8; ///< 8-bit unsigned byte
  33. typedef std::uint16_t u16; ///< 16-bit unsigned short
  34. typedef std::uint32_t u32; ///< 32-bit unsigned word
  35. typedef std::uint64_t u64; ///< 64-bit unsigned int
  36. typedef std::int8_t s8; ///< 8-bit signed byte
  37. typedef std::int16_t s16; ///< 16-bit signed short
  38. typedef std::int32_t s32; ///< 32-bit signed word
  39. typedef std::int64_t s64; ///< 64-bit signed int
  40. typedef float f32; ///< 32-bit floating point
  41. typedef double f64; ///< 64-bit floating point
  42. // TODO: It would be nice to eventually replace these with strong types that prevent accidental
  43. // conversion between each other.
  44. typedef u64 VAddr; ///< Represents a pointer in the userspace virtual address space.
  45. typedef u64 PAddr; ///< Represents a pointer in the ARM11 physical address space.
  46. using u128 = std::array<std::uint64_t, 2>;
  47. static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide");
  48. // An inheritable class to disallow the copy constructor and operator= functions
  49. class NonCopyable {
  50. protected:
  51. constexpr NonCopyable() = default;
  52. ~NonCopyable() = default;
  53. NonCopyable(const NonCopyable&) = delete;
  54. NonCopyable& operator=(const NonCopyable&) = delete;
  55. };