mark some init function as being safe for thread_sanitizer.

introduces the macro WEBP_TSAN_IGNORE_FUNCTION

Change-Id: I3de2b6c1a2076fba4da7ae50322551e026b2082b
This commit is contained in:
Pascal Massimino 2014-10-16 16:34:07 +02:00
parent 79b5bdbfde
commit 80247291c6
25 changed files with 75 additions and 64 deletions

View File

@ -347,7 +347,7 @@ extern void VP8FiltersInitMIPSdspR2(void);
extern void WebPInitAlphaProcessingMIPSdspR2(void);
extern void WebPInitAlphaProcessingSSE2(void);
void WebPInitAlphaProcessing(void) {
void WebPInitAlphaProcessing(void) WEBP_TSAN_IGNORE_FUNCTION {
WebPMultARGBRow = WebPMultARGBRowC;
WebPMultRow = WebPMultRowC;
WebPApplyAlphaMultiply = ApplyAlphaMultiply;

View File

@ -282,9 +282,9 @@ static void MultRow(uint8_t* const ptr, const uint8_t* const alpha,
//------------------------------------------------------------------------------
// Init function
extern void WebPInitAlphaProcessingSSE2(void);
extern void WebPInitAlphaProcessingSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitAlphaProcessingSSE2(void) {
void WebPInitAlphaProcessingSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_SSE2)
WebPMultARGBRow = MultARGBRow;
WebPMultRow = MultRow;

View File

@ -689,7 +689,7 @@ extern void VP8DspInitNEON(void);
extern void VP8DspInitMIPS32(void);
extern void VP8DspInitMIPSdspR2(void);
void VP8DspInit(void) {
void VP8DspInit(void) WEBP_TSAN_IGNORE_FUNCTION {
VP8InitClipTables();
VP8TransformWHT = TransformWHT;

View File

@ -344,7 +344,7 @@ const int8_t* const VP8ksclip2 = &sclip2[112];
const uint8_t* const VP8kclip1 = &clip1[255];
const uint8_t* const VP8kabs0 = &abs0[255];
void VP8InitClipTables(void) {
void VP8InitClipTables(void) WEBP_TSAN_IGNORE_FUNCTION {
#if !defined(USE_STATIC_TABLES)
int i;
if (!tables_ok) {

View File

@ -558,9 +558,9 @@ static void TransformTwo(const int16_t* in, uint8_t* dst, int do_two) {
//------------------------------------------------------------------------------
// Entry point
extern void VP8DspInitMIPS32(void);
extern void VP8DspInitMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8DspInitMIPS32(void) {
void VP8DspInitMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS32)
VP8InitClipTables();

View File

@ -658,9 +658,9 @@ static void HFilter8i(uint8_t* u, uint8_t* v, int stride,
//------------------------------------------------------------------------------
// Entry point
extern void VP8DspInitMIPSdspR2(void);
extern void VP8DspInitMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8DspInitMIPSdspR2(void) {
void VP8DspInitMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS_DSP_R2)
VP8TransformDC = TransformDC;
VP8TransformAC3 = TransformAC3;

View File

@ -1263,9 +1263,9 @@ static void TransformAC3(const int16_t* in, uint8_t* dst) {
//------------------------------------------------------------------------------
// Entry point
extern void VP8DspInitNEON(void);
extern void VP8DspInitNEON(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8DspInitNEON(void) {
void VP8DspInitNEON(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_NEON)
VP8Transform = TransformTwo;
VP8TransformAC3 = TransformAC3;

View File

@ -952,9 +952,9 @@ static void HFilter8i(uint8_t* u, uint8_t* v, int stride,
//------------------------------------------------------------------------------
// Entry point
extern void VP8DspInitSSE2(void);
extern void VP8DspInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8DspInitSSE2(void) {
void VP8DspInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_SSE2)
VP8Transform = Transform;
#if defined(USE_TRANSFORM_AC3)

View File

@ -80,6 +80,15 @@ extern "C" {
#endif
#endif
// This macro prevents thread_sanitizer from reporting known concurrent writes.
#define WEBP_TSAN_IGNORE_FUNCTION
#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
#undef WEBP_TSAN_IGNORE_FUNCTION
#define WEBP_TSAN_IGNORE_FUNCTION __attribute__((no_sanitize_thread))
#endif
#endif
typedef enum {
kSSE2,
kSSE3,
@ -147,7 +156,8 @@ typedef void (*VP8CHisto)(const uint8_t* ref, const uint8_t* pred,
extern const int VP8DspScan[16 + 4 + 4];
extern VP8CHisto VP8CollectHistogram;
void VP8EncDspInit(void); // must be called before using any of the above
// must be called before using any of the above
void VP8EncDspInit(void) WEBP_TSAN_IGNORE_FUNCTION;
//------------------------------------------------------------------------------
// Decoding
@ -174,7 +184,8 @@ extern const int8_t* const VP8ksclip1; // clips [-1020, 1020] to [-128, 127]
extern const int8_t* const VP8ksclip2; // clips [-112, 112] to [-16, 15]
extern const uint8_t* const VP8kclip1; // clips [-255,511] to [0,255]
extern const uint8_t* const VP8kabs0; // abs(x) for x in [-255,255]
void VP8InitClipTables(void); // must be called first
// must be called first
void VP8InitClipTables(void) WEBP_TSAN_IGNORE_FUNCTION;
// simple filter (only for luma)
typedef void (*VP8SimpleFilterFunc)(uint8_t* p, int stride, int thresh);
@ -201,7 +212,7 @@ extern VP8ChromaFilterFunc VP8VFilter8i; // filtering u and v altogether
extern VP8ChromaFilterFunc VP8HFilter8i;
// must be called before anything using the above
void VP8DspInit(void);
void VP8DspInit(void) WEBP_TSAN_IGNORE_FUNCTION;
//------------------------------------------------------------------------------
// WebP I/O
@ -250,11 +261,11 @@ extern WebPYUV444Converter WebPYUV444Converters[/* MODE_LAST */];
// Must be called before using the WebPUpsamplers[] (and for premultiplied
// colorspaces like rgbA, rgbA4444, etc)
void WebPInitUpsamplers(void);
void WebPInitUpsamplers(void) WEBP_TSAN_IGNORE_FUNCTION;
// Must be called before using WebPSamplers[]
void WebPInitSamplers(void);
void WebPInitSamplers(void) WEBP_TSAN_IGNORE_FUNCTION;
// Must be called before using WebPYUV444Converters[]
void WebPInitYUV444Converters(void);
void WebPInitYUV444Converters(void) WEBP_TSAN_IGNORE_FUNCTION;
//------------------------------------------------------------------------------
// Utilities for processing transparent channel.
@ -312,7 +323,7 @@ void WebPMultRowC(uint8_t* const ptr, const uint8_t* const alpha,
void WebPMultARGBRowC(uint32_t* const ptr, int width, int inverse);
// To be called first before using the above.
void WebPInitAlphaProcessing(void);
void WebPInitAlphaProcessing(void) WEBP_TSAN_IGNORE_FUNCTION;
#ifdef __cplusplus
} // extern "C"

View File

@ -701,7 +701,7 @@ extern void VP8EncDspInitAVX2(void);
extern void VP8EncDspInitNEON(void);
extern void VP8EncDspInitMIPS32(void);
void VP8EncDspInit(void) {
void VP8EncDspInit(void) WEBP_TSAN_IGNORE_FUNCTION {
VP8DspInit(); // common inverse transforms
InitTables();

View File

@ -765,9 +765,9 @@ static int SSE4x4(const uint8_t* a, const uint8_t* b) {
//------------------------------------------------------------------------------
// Entry point
extern void VP8EncDspInitMIPS32(void);
extern void VP8EncDspInitMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8EncDspInitMIPS32(void) {
void VP8EncDspInitMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS32)
VP8ITransform = ITransform;
VP8EncQuantizeBlock = QuantizeBlock;

View File

@ -904,9 +904,9 @@ static int Quantize2Blocks(int16_t in[32], int16_t out[32],
//------------------------------------------------------------------------------
// Entry point
extern void VP8EncDspInitNEON(void);
extern void VP8EncDspInitNEON(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8EncDspInitNEON(void) {
void VP8EncDspInitNEON(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_NEON)
VP8ITransform = ITransform;
VP8FTransform = FTransform;

View File

@ -944,9 +944,9 @@ void VP8SetResidualCoeffsSSE2(const int16_t* const coeffs,
//------------------------------------------------------------------------------
// Entry point
extern void VP8EncDspInitSSE2(void);
extern void VP8EncDspInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8EncDspInitSSE2(void) {
void VP8EncDspInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_SSE2)
VP8CollectHistogram = CollectHistogram;
VP8EncQuantizeBlock = QuantizeBlock;

View File

@ -1585,7 +1585,7 @@ extern void VP8LDspInitNEON(void);
extern void VP8LDspInitMIPS32(void);
extern void VP8LDspInitMIPSdspR2(void);
void VP8LDspInit(void) {
void VP8LDspInit(void) WEBP_TSAN_IGNORE_FUNCTION {
memcpy(VP8LPredictors, kPredictorsC, sizeof(VP8LPredictors));
VP8LSubtractGreenFromBlueAndRed = VP8LSubtractGreenFromBlueAndRed_C;

View File

@ -401,9 +401,9 @@ static void HistogramAdd(const VP8LHistogram* const a,
//------------------------------------------------------------------------------
// Entry point
extern void VP8LDspInitMIPS32(void);
extern void VP8LDspInitMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8LDspInitMIPS32(void) {
void VP8LDspInitMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS32)
VP8LFastSLog2Slow = FastSLog2Slow;
VP8LFastLog2Slow = FastLog2Slow;

View File

@ -301,9 +301,9 @@ static void AddGreenToBlueAndRed(uint32_t* argb_data, int num_pixels) {
//------------------------------------------------------------------------------
extern void VP8LDspInitNEON(void);
extern void VP8LDspInitNEON(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8LDspInitNEON(void) {
void VP8LDspInitNEON(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_NEON)
VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA;
VP8LConvertBGRAToBGR = ConvertBGRAToBGR;

View File

@ -503,9 +503,9 @@ static void HistogramAdd(const VP8LHistogram* const a,
//------------------------------------------------------------------------------
extern void VP8LDspInitSSE2(void);
extern void VP8LDspInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
void VP8LDspInitSSE2(void) {
void VP8LDspInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_SSE2)
VP8LPredictors[5] = Predictor5;
VP8LPredictors[6] = Predictor6;

View File

@ -171,9 +171,9 @@ YUV444_FUNC(Yuv444ToRgb565, VP8YuvToRgb565, 2)
WebPYUV444Converter WebPYUV444Converters[MODE_LAST];
extern void WebPInitYUV444ConvertersMIPSdspR2(void);
extern void WebPInitYUV444ConvertersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitYUV444Converters(void) {
void WebPInitYUV444Converters(void) WEBP_TSAN_IGNORE_FUNCTION {
WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;
WebPYUV444Converters[MODE_BGR] = Yuv444ToBgr;
@ -198,11 +198,11 @@ void WebPInitYUV444Converters(void) {
//------------------------------------------------------------------------------
// Main calls
extern void WebPInitUpsamplersSSE2(void);
extern void WebPInitUpsamplersNEON(void);
extern void WebPInitUpsamplersMIPSdspR2(void);
extern void WebPInitUpsamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
extern void WebPInitUpsamplersNEON(void) WEBP_TSAN_IGNORE_FUNCTION;
extern void WebPInitUpsamplersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitUpsamplers(void) {
void WebPInitUpsamplers(void) WEBP_TSAN_IGNORE_FUNCTION {
#ifdef FANCY_UPSAMPLING
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;

View File

@ -215,9 +215,9 @@ UPSAMPLE_FUNC(UpsampleRgb565LinePair, YuvToRgb565, 2)
#endif // WEBP_USE_MIPS_DSP_R2
extern void WebPInitUpsamplersMIPSdspR2(void);
extern void WebPInitUpsamplersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitUpsamplersMIPSdspR2(void) {
void WebPInitUpsamplersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS_DSP_R2)
#ifdef FANCY_UPSAMPLING
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
@ -259,9 +259,9 @@ YUV444_FUNC(Yuv444ToRgb565, YuvToRgb565, 2)
#endif // WEBP_USE_MIPS_DSP_R2
extern void WebPInitYUV444ConvertersMIPSdspR2(void);
extern void WebPInitYUV444ConvertersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitYUV444ConvertersMIPSdspR2(void) {
void WebPInitYUV444ConvertersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS_DSP_R2)
WebPYUV444Converters[MODE_RGB] = Yuv444ToRgb;
WebPYUV444Converters[MODE_RGBA] = Yuv444ToRgba;

View File

@ -242,13 +242,13 @@ NEON_UPSAMPLE_FUNC(UpsampleBgraLinePair, Bgra, 4)
//------------------------------------------------------------------------------
extern void WebPInitUpsamplersNEON(void);
extern void WebPInitUpsamplersNEON(void) WEBP_TSAN_IGNORE_FUNCTION;
#ifdef FANCY_UPSAMPLING
extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
void WebPInitUpsamplersNEON(void) {
void WebPInitUpsamplersNEON(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_NEON)
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
@ -262,6 +262,6 @@ void WebPInitUpsamplersNEON(void) {
#else
// this empty function is to avoid an empty .o
void WebPInitUpsamplersNEON(void) {}
void WebPInitUpsamplersNEON(void) WEBP_TSAN_IGNORE_FUNCTION {}
#endif // FANCY_UPSAMPLING

View File

@ -188,13 +188,13 @@ SSE2_UPSAMPLE_FUNC(UpsampleBgraLinePair, VP8YuvToBgra, 4)
//------------------------------------------------------------------------------
extern void WebPInitUpsamplersSSE2(void);
extern void WebPInitUpsamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
#ifdef FANCY_UPSAMPLING
extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
void WebPInitUpsamplersSSE2(void) {
void WebPInitUpsamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_SSE2)
VP8YUVInitSSE2();
WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
@ -209,6 +209,6 @@ void WebPInitUpsamplersSSE2(void) {
#else
// this empty function is to avoid an empty .o
void WebPInitUpsamplersSSE2(void) {}
void WebPInitUpsamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {}
#endif // FANCY_UPSAMPLING

View File

@ -26,7 +26,7 @@ int32_t VP8kVToG[256], VP8kUToG[256];
uint8_t VP8kClip[YUV_RANGE_MAX - YUV_RANGE_MIN];
uint8_t VP8kClip4Bits[YUV_RANGE_MAX - YUV_RANGE_MIN];
void VP8YUVInit(void) {
void VP8YUVInit(void) WEBP_TSAN_IGNORE_FUNCTION {
int i;
if (done) {
return;
@ -62,7 +62,7 @@ void VP8YUVInit(void) {
#else
void VP8YUVInit(void) {}
void VP8YUVInit(void) WEBP_TSAN_IGNORE_FUNCTION {}
#endif // WEBP_YUV_USE_TABLE
@ -120,11 +120,11 @@ void WebPSamplerProcessPlane(const uint8_t* y, int y_stride,
WebPSamplerRowFunc WebPSamplers[MODE_LAST];
extern void WebPInitSamplersSSE2(void);
extern void WebPInitSamplersMIPS32(void);
extern void WebPInitSamplersMIPSdspR2(void);
extern void WebPInitSamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
extern void WebPInitSamplersMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION;
extern void WebPInitSamplersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitSamplers(void) {
void WebPInitSamplers(void) WEBP_TSAN_IGNORE_FUNCTION {
WebPSamplers[MODE_RGB] = YuvToRgbRow;
WebPSamplers[MODE_RGBA] = YuvToRgbaRow;
WebPSamplers[MODE_BGR] = YuvToBgrRow;

View File

@ -88,9 +88,9 @@ ROW_FUNC(YuvToBgraRow, 4, 2, 1, 0, 3)
//------------------------------------------------------------------------------
extern void WebPInitSamplersMIPS32(void);
extern void WebPInitSamplersMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitSamplersMIPS32(void) {
void WebPInitSamplersMIPS32(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS32)
WebPSamplers[MODE_RGB] = YuvToRgbRow;
WebPSamplers[MODE_RGBA] = YuvToRgbaRow;

View File

@ -119,9 +119,9 @@ ROW_FUNC(YuvToBgraRow, 4, 2, 1, 0, 3)
//------------------------------------------------------------------------------
extern void WebPInitSamplersMIPSdspR2(void);
extern void WebPInitSamplersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitSamplersMIPSdspR2(void) {
void WebPInitSamplersMIPSdspR2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_MIPS_DSP_R2)
WebPSamplers[MODE_RGB] = YuvToRgbRow;
WebPSamplers[MODE_RGBA] = YuvToRgbaRow;

View File

@ -28,14 +28,14 @@ typedef union { // handy struct for converting SSE2 registers
#include "./yuv_tables_sse2.h"
void VP8YUVInitSSE2(void) {}
void VP8YUVInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {}
#else
static int done_sse2 = 0;
static VP8kCstSSE2 VP8kUtoRGBA[256], VP8kVtoRGBA[256], VP8kYtoRGBA[256];
void VP8YUVInitSSE2(void) {
void VP8YUVInitSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
if (!done_sse2) {
int i;
for (i = 0; i < 256; ++i) {
@ -309,9 +309,9 @@ static void YuvToBgrRowSSE2(const uint8_t* y,
//------------------------------------------------------------------------------
// Entry point
extern void WebPInitSamplersSSE2(void);
extern void WebPInitSamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION;
void WebPInitSamplersSSE2(void) {
void WebPInitSamplersSSE2(void) WEBP_TSAN_IGNORE_FUNCTION {
#if defined(WEBP_USE_SSE2)
WebPSamplers[MODE_RGB] = YuvToRgbRowSSE2;
WebPSamplers[MODE_RGBA] = YuvToRgbaRowSSE2;