summaryrefslogtreecommitdiff
path: root/src/common/common_funcs.h
diff options
context:
space:
mode:
authorGravatar bunnei2019-11-03 18:54:03 -0500
committerGravatar bunnei2019-11-03 22:22:41 -0500
commit1bdae0fe29f87daa81d2aba052a10a709b87485a (patch)
tree16d0f4aa4c4a11222c6950b3ad60e7d1d9905036 /src/common/common_funcs.h
parentMerge pull request #3059 from FearlessTobi/stub-am-commands (diff)
downloadyuzu-1bdae0fe29f87daa81d2aba052a10a709b87485a.tar.gz
yuzu-1bdae0fe29f87daa81d2aba052a10a709b87485a.tar.xz
yuzu-1bdae0fe29f87daa81d2aba052a10a709b87485a.zip
common_func: Use std::array for INSERT_PADDING_* macros.
- Zero initialization here is useful for determinism.
Diffstat (limited to 'src/common/common_funcs.h')
-rw-r--r--src/common/common_funcs.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 04ecac959..c029dc7b3 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -1,10 +1,11 @@
1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project 1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm> 7#include <algorithm>
8#include <array>
8#include <string> 9#include <string>
9 10
10#if !defined(ARCHITECTURE_x86_64) 11#if !defined(ARCHITECTURE_x86_64)
@@ -16,18 +17,15 @@
16#define CONCAT2(x, y) DO_CONCAT2(x, y) 17#define CONCAT2(x, y) DO_CONCAT2(x, y)
17#define DO_CONCAT2(x, y) x##y 18#define DO_CONCAT2(x, y) x##y
18 19
19// helper macro to properly align structure members. 20/// Helper macros to insert unused bytes or words to properly align structs. These values will be
20// Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", 21/// zero-initialized.
21// depending on the current source line to make sure variable names are unique. 22#define INSERT_PADDING_BYTES(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__){};
22#define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)] 23#define INSERT_PADDING_WORDS(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__){};
23#define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)]
24 24
25// Inlining 25/// These are similar to the INSERT_PADDING_* macros, but are needed for padding unions. This is
26#ifdef _WIN32 26/// because unions can only be initialized by one member.
27#define FORCE_INLINE __forceinline 27#define INSERT_UNION_PADDING_BYTES(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__);
28#else 28#define INSERT_UNION_PADDING_WORDS(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__);
29#define FORCE_INLINE inline __attribute__((always_inline))
30#endif
31 29
32#ifndef _MSC_VER 30#ifndef _MSC_VER
33 31