Skip to content

Commit

Permalink
Replace custom macro FALLTHROUGH with a native one
Browse files Browse the repository at this point in the history
  • Loading branch information
sangjinhan committed Jun 28, 2018
1 parent 5994415 commit 3496cd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
10 changes: 0 additions & 10 deletions core/utils/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@
#error Must be built with C++17
#endif

#if !defined(__cplusplus) // C
#define FALLTHROUGH __attribute__((fallthrough))
#elif __cplusplus <= 201402L && defined(__clang__) // C++14 or older, Clang
#define FALLTHROUGH [[clang::fallthrough]]
#elif __cplusplus <= 201402L && __GNUC__ < 7 // C++14 or older, pre-GCC 7
#define FALLTHROUGH
#else
#define FALLTHROUGH [[fallthrough]]
#endif

/* Hint for performance optimization. Same as _nDCHECK() of TI compilers */
#define promise(cond) \
({ \
Expand Down
18 changes: 9 additions & 9 deletions core/utils/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static inline void CopySmall(void *__restrict__ dst,
break;
case 9:
memcpy(d + 8, s + 8, 1);
FALLTHROUGH;
[[fallthrough]];
case 8:
memcpy(d, s, 8);
break;
Expand All @@ -120,13 +120,13 @@ static inline void CopySmall(void *__restrict__ dst,
break;
case 5:
memcpy(d + 4, s + 4, 1);
FALLTHROUGH;
[[fallthrough]];
case 4:
memcpy(d, s, 4);
break;
case 3:
memcpy(d + 2, s + 2, 1);
FALLTHROUGH;
[[fallthrough]];
case 2:
memcpy(d, s, 2);
break;
Expand Down Expand Up @@ -200,22 +200,22 @@ static inline void CopyInlined(void *__restrict__ dst,
switch (leftover_blocks) {
case 7:
copy_block(d + 6, s + 6);
FALLTHROUGH;
[[fallthrough]];
case 6:
copy_block(d + 5, s + 5);
FALLTHROUGH;
[[fallthrough]];
case 5:
copy_block(d + 4, s + 4);
FALLTHROUGH;
[[fallthrough]];
case 4:
copy_block(d + 3, s + 3);
FALLTHROUGH;
[[fallthrough]];
case 3:
copy_block(d + 2, s + 2);
FALLTHROUGH;
[[fallthrough]];
case 2:
copy_block(d + 1, s + 1);
FALLTHROUGH;
[[fallthrough]];
case 1:
copy_block(d + 0, s + 0);
}
Expand Down

0 comments on commit 3496cd8

Please sign in to comment.