1b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov/* ThreadSanitizer 2b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * Copyright (c) 2011, Google Inc. All rights reserved. 3b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * Author: Dmitry Vyukov (dvyukov) 4b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * 5b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * Redistribution and use in source and binary forms, with or without 6b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * modification, are permitted provided that the following conditions are met: 7b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * 8b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * * Redistributions of source code must retain the above copyright 9b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * notice, this list of conditions and the following disclaimer. 10b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * * Neither the name of Google Inc. nor the names of its 11b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * contributors may be used to endorse or promote products derived from 12b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * this software without specific prior written permission. 13b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * 14b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov */ 26b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 27b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#ifndef TS_ATOMIC_INT_H_INCLUDED 28b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#define TS_ATOMIC_INT_H_INCLUDED 29b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 30b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#include "ts_atomic.h" 31b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#include "ts_util.h" 32b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#include <stddef.h> 33b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 34b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov// Helper functions for atomic support 35b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 36b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovchar const* tsan_atomic_to_str(tsan_memory_order mo); 37b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovchar const* tsan_atomic_to_str(tsan_atomic_op op); 38b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovbool tsan_atomic_is_acquire(tsan_memory_order mo); 39b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovbool tsan_atomic_is_release(tsan_memory_order mo); 40b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovbool tsan_atomic_is_rmw(tsan_atomic_op op); 41b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovvoid tsan_atomic_verify(tsan_atomic_op op, 42b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov tsan_memory_order mo, 43b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov tsan_memory_order fail_mo, 44b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov size_t size, 45b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov void volatile* a); 46b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovuint64_t tsan_atomic_do_op(tsan_atomic_op op, 47b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov tsan_memory_order mo, 48b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov tsan_memory_order fail_mo, 49b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov size_t size, 50b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov void volatile* a, 51b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov uint64_t v, 52b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov uint64_t cmp, 53b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov uint64_t* newv, 54b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov uint64_t* prev); 55b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 56b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov#endif // #ifndef TS_ATOMIC_INT_H_INCLUDED 57b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 58