History

Merge "add static_assert.h"

James Zern committed 6 years ago

Commit 7adcbf22 parents b78d3b2 bc9b7f54 files · +37 −36Browse files

Unified · Split

4 files
  1. vp8/vp8_cx_iface.c +3 −18
  2. vp9/vp9_cx_iface.c +3 −18
  3. vpx_ports/static_assert.h +30 −0
  4. vpx_ports/vpx_ports.mk +1 −0
vp8/vp8_cx_iface.c+3−18
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include "vpx/internal/vpx_codec_internal.h"
1717 #include "vpx_version.h"
1818 #include "vpx_mem/vpx_mem.h"
19+#include "vpx_ports/static_assert.h"
1920 #include "vpx_ports/system_state.h"
2021 #include "vpx_ports/vpx_once.h"
2122 #include "vpx_util/vpx_timestamp.h"
@@ -131,22 +132,6 @@ static vpx_codec_err_t update_error_state( · 109 unmodified lines
131132 if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \
132133 } while (0)
133134
134−#if defined(_MSC_VER)
135−#define COMPILE_TIME_ASSERT(boolexp) \
136− do { \
137− char compile_time_assert[(boolexp) ? 1 : -1]; \
138− (void)compile_time_assert; \
139− } while (0)
140−#else /* !_MSC_VER */
141−#define COMPILE_TIME_ASSERT(boolexp) \
142− do { \
143− struct { \
144− unsigned int compile_time_assert : (boolexp) ? 1 : -1; \
145− } compile_time_assert; \
146− (void)compile_time_assert; \
147− } while (0)
148−#endif /* _MSC_VER */
149−
150135 static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
151136 const vpx_codec_enc_cfg_t *cfg,
152137 const struct vp8_extracfg *vp8_cfg,
@@ -751,8 +736,8 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, · 598 unmodified lines
751736 /* Convert duration parameter from stream timebase to microseconds */
752737 uint64_t duration_us;
753738
754− COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 &&
755− (TICKS_PER_SEC % 1000000) == 0);
739+ VPX_STATIC_ASSERT(TICKS_PER_SEC > 1000000 &&
740+ (TICKS_PER_SEC % 1000000) == 0);
756741
757742 duration_us = duration * (uint64_t)ctx->timestamp_ratio.num /
758743 (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000));
vp9/vp9_cx_iface.c+3−18
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include "vpx/vpx_encoder.h"
1616 #include "vpx_dsp/psnr.h"
1717 #include "vpx_ports/vpx_once.h"
18+#include "vpx_ports/static_assert.h"
1819 #include "vpx_ports/system_state.h"
1920 #include "vpx_util/vpx_timestamp.h"
2021 #include "vpx/internal/vpx_codec_internal.h"
@@ -160,22 +161,6 @@ static vpx_codec_err_t update_error_state( · 139 unmodified lines
160161 if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \
161162 } while (0)
162163
163−#if defined(_MSC_VER)
164−#define COMPILE_TIME_ASSERT(boolexp) \
165− do { \
166− char compile_time_assert[(boolexp) ? 1 : -1]; \
167− (void)compile_time_assert; \
168− } while (0)
169−#else // !_MSC_VER
170−#define COMPILE_TIME_ASSERT(boolexp) \
171− do { \
172− struct { \
173− unsigned int compile_time_assert : (boolexp) ? 1 : -1; \
174− } compile_time_assert; \
175− (void)compile_time_assert; \
176− } while (0)
177−#endif // _MSC_VER
178−
179164 static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
180165 const vpx_codec_enc_cfg_t *cfg,
181166 const struct vp9_extracfg *extra_cfg) {
@@ -968,8 +953,8 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, · 786 unmodified lines
968953 // Convert duration parameter from stream timebase to microseconds.
969954 uint64_t duration_us;
970955
971− COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 &&
972− (TICKS_PER_SEC % 1000000) == 0);
956+ VPX_STATIC_ASSERT(TICKS_PER_SEC > 1000000 &&
957+ (TICKS_PER_SEC % 1000000) == 0);
973958
974959 duration_us = duration * (uint64_t)ctx->timestamp_ratio.num /
975960 (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000));
vpx_ports/static_assert.h+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 2020 The WebM project authors. All Rights Reserved.
3+ *
4+ * Use of this source code is governed by a BSD-style license
5+ * that can be found in the LICENSE file in the root of the source
6+ * tree. An additional intellectual property rights grant can be found
7+ * in the file PATENTS. All contributing project authors may
8+ * be found in the AUTHORS file in the root of the source tree.
9+ */
10+
11+#ifndef VPX_VPX_PORTS_STATIC_ASSERT_H_
12+#define VPX_VPX_PORTS_STATIC_ASSERT_H_
13+
14+#if defined(_MSC_VER)
15+#define VPX_STATIC_ASSERT(boolexp) \
16+ do { \
17+ char vpx_static_assert[(boolexp) ? 1 : -1]; \
18+ (void)vpx_static_assert; \
19+ } while (0)
20+#else // !_MSC_VER
21+#define VPX_STATIC_ASSERT(boolexp) \
22+ do { \
23+ struct { \
24+ unsigned int vpx_static_assert : (boolexp) ? 1 : -1; \
25+ } vpx_static_assert; \
26+ (void)vpx_static_assert; \
27+ } while (0)
28+#endif // _MSC_VER
29+
30+#endif // VPX_VPX_PORTS_STATIC_ASSERT_H_
vpx_ports/vpx_ports.mk+1−0
@@ -14,6 +14,7 @@ PORTS_SRCS-yes += vpx_ports.mk · 13 unmodified lines
1414 PORTS_SRCS-yes += bitops.h
1515 PORTS_SRCS-yes += mem.h
1616 PORTS_SRCS-yes += msvc.h
17+PORTS_SRCS-yes += static_assert.h
1718 PORTS_SRCS-yes += system_state.h
1819 PORTS_SRCS-yes += vpx_timer.h
1920

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t