Blender V4.3
atomic_ops_unix.h File Reference
#include "atomic_ops_utils.h"

Go to the source code of this file.

Classes

struct  AtomicSpinLock
 

Macros

Common part of x64 implementation
#define __atomic_impl_load_generic(v)   (__sync_synchronize(), *(v))
 
#define __atomic_impl_store_generic(p, v)
 

Functions

Spin-lock implementation

Used to implement atomics on unsupported platforms. The spin implementation is shared for all platforms to make sure it compiles and tested.

struct AtomicSpinLock __attribute__ ((aligned(32))) AtomicSpinLock
 
ATOMIC_INLINE void atomic_spin_lock (volatile AtomicSpinLock *lock)
 
ATOMIC_INLINE void atomic_spin_unlock (volatile AtomicSpinLock *lock)
 

Variables

volatile int lock
 
int pad [32 - sizeof(int)]
 

Common part of locking fallback implementation

#define ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, _op_name, _op)
 
#define ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, _op_name, _op)
 
#define ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE(_type)    ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, add, +)
 
#define ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE(_type)    ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, sub, -)
 
#define ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE(_type)    ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, add, +)
 
#define ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE(_type)    ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, sub, -)
 
#define ATOMIC_LOCKING_FETCH_AND_OR_DEFINE(_type)   ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, or, |)
 
#define ATOMIC_LOCKING_FETCH_AND_AND_DEFINE(_type)    ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, and, &)
 
#define ATOMIC_LOCKING_CAS_DEFINE(_type)
 
#define ATOMIC_LOCKING_LOAD_DEFINE(_type)
 
#define ATOMIC_LOCKING_STORE_DEFINE(_type)
 
static _ATOMIC_MAYBE_UNUSED AtomicSpinLock _atomic_global_lock = {0}
 

Macro Definition Documentation

◆ __atomic_impl_load_generic

#define __atomic_impl_load_generic ( v)    (__sync_synchronize(), *(v))

Definition at line 106 of file atomic_ops_unix.h.

◆ __atomic_impl_store_generic

#define __atomic_impl_store_generic ( p,
v )
Value:
do { \
*(p) = (v); \
__sync_synchronize(); \
} while (0)
ATTR_WARN_UNUSED_RESULT const BMVert * v

Definition at line 107 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE

#define ATOMIC_LOCKING_ADD_AND_FETCH_DEFINE ( _type)     ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, add, +)

Definition at line 146 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_CAS_DEFINE

#define ATOMIC_LOCKING_CAS_DEFINE ( _type)
Value:
ATOMIC_INLINE _type##_t atomic_cas_##_type(_type##_t *v, _type##_t old, _type##_t _new) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t original_value = *v; \
if (*v == old) { \
*v = _new; \
} \
atomic_spin_unlock(&_atomic_global_lock); \
return original_value; \
}
static _ATOMIC_MAYBE_UNUSED AtomicSpinLock _atomic_global_lock
#define ATOMIC_INLINE

Definition at line 163 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE

#define ATOMIC_LOCKING_FETCH_AND_ADD_DEFINE ( _type)     ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, add, +)

Definition at line 152 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_FETCH_AND_AND_DEFINE

#define ATOMIC_LOCKING_FETCH_AND_AND_DEFINE ( _type)     ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, and, &)

Definition at line 160 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_FETCH_AND_OP_DEFINE

#define ATOMIC_LOCKING_FETCH_AND_OP_DEFINE ( _type,
_op_name,
_op )
Value:
ATOMIC_INLINE _type##_t atomic_fetch_and_##_op_name##_##_type(_type##_t *p, _type##_t x) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t original_value = *(p); \
*(p) = original_value _op(x); \
atomic_spin_unlock(&_atomic_global_lock); \
return original_value; \
}

Definition at line 136 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_FETCH_AND_OR_DEFINE

#define ATOMIC_LOCKING_FETCH_AND_OR_DEFINE ( _type)    ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, or, |)

Definition at line 158 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE

#define ATOMIC_LOCKING_FETCH_AND_SUB_DEFINE ( _type)     ATOMIC_LOCKING_FETCH_AND_OP_DEFINE(_type, sub, -)

Definition at line 155 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_LOAD_DEFINE

#define ATOMIC_LOCKING_LOAD_DEFINE ( _type)
Value:
ATOMIC_INLINE _type##_t atomic_load_##_type(const _type##_t *v) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t value = *v; \
atomic_spin_unlock(&_atomic_global_lock); \
return value; \
}

Definition at line 175 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_OP_AND_FETCH_DEFINE

#define ATOMIC_LOCKING_OP_AND_FETCH_DEFINE ( _type,
_op_name,
_op )
Value:
ATOMIC_INLINE _type##_t atomic_##_op_name##_and_fetch_##_type(_type##_t *p, _type##_t x) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
const _type##_t original_value = *(p); \
const _type##_t new_value = original_value _op(x); \
*(p) = new_value; \
atomic_spin_unlock(&_atomic_global_lock); \
return new_value; \
}

Definition at line 125 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_STORE_DEFINE

#define ATOMIC_LOCKING_STORE_DEFINE ( _type)
Value:
ATOMIC_INLINE void atomic_store_##_type(_type##_t *p, const _type##_t v) \
{ \
atomic_spin_lock(&_atomic_global_lock); \
*p = v; \
atomic_spin_unlock(&_atomic_global_lock); \
}

Definition at line 184 of file atomic_ops_unix.h.

◆ ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE

#define ATOMIC_LOCKING_SUB_AND_FETCH_DEFINE ( _type)     ATOMIC_LOCKING_OP_AND_FETCH_DEFINE(_type, sub, -)

Definition at line 149 of file atomic_ops_unix.h.

Function Documentation

◆ __attribute__()

struct AtomicSpinLock __attribute__ ( (aligned(32)) )

◆ atomic_spin_lock()

ATOMIC_INLINE void atomic_spin_lock ( volatile AtomicSpinLock * lock)

Definition at line 84 of file atomic_ops_unix.h.

References lock.

◆ atomic_spin_unlock()

ATOMIC_INLINE void atomic_spin_unlock ( volatile AtomicSpinLock * lock)

Definition at line 92 of file atomic_ops_unix.h.

References lock.

Variable Documentation

◆ _atomic_global_lock

_ATOMIC_MAYBE_UNUSED AtomicSpinLock _atomic_global_lock = {0}
static

Definition at line 123 of file atomic_ops_unix.h.

◆ lock

volatile int lock

Definition at line 0 of file atomic_ops_unix.h.

Referenced by thread_counting_semaphore::acquire(), blender::draw::image_engine::SpaceImageAccessor::acquire_image_buffer(), blender::draw::image_engine::SpaceNodeAccessor::acquire_image_buffer(), blender::deg::sync_writeback::add(), blender::gpu::render_graph::VKResourceStateTracker::add_buffer(), Progress::add_finished_tile(), blender::gpu::render_graph::VKResourceStateTracker::add_image(), mem_guarded::internal::add_memleak_data(), Progress::add_samples(), Profiler::add_state(), blender::ed::spreadsheet::GeometryDataSource::apply_selection_filter(), atomic_spin_lock(), atomic_spin_unlock(), Device::available_devices(), blender::ed::space_node::backimage_fit_exec(), blender::ed::object::bake_object_check(), blender::ed::object::bake_targets_init_internal(), blender::gpu::VKShaderCompiler::batch_compile(), blender::gpu::MTLParallelShaderCompiler::batch_finalize(), blender::gpu::VKShaderCompiler::batch_finalize(), blender::gpu::MTLParallelShaderCompiler::batch_is_ready(), blender::gpu::VKShaderCompiler::batch_is_ready(), BKE_icon_delete(), BKE_icon_delete_unmanaged(), BKE_icon_id_delete(), BKE_icon_set(), BKE_icons_deferred_free(), BKE_image_get_float_pixels_for_frame(), BKE_image_get_pixels_for_frame(), BKE_image_get_size(), BKE_image_has_alpha(), BKE_image_preview(), BKE_image_release_ibuf(), BKE_image_save_options_init(), BKE_image_scale(), BKE_mesh_wrapper_ensure_mdata(), BKE_mesh_wrapper_ensure_subdivision(), BKE_object_select_update(), BKE_report(), BKE_report_print_level_set(), BKE_report_store_level_set(), BKE_report_write_file_fp(), BKE_reportf(), BKE_reports_clear(), BKE_reports_contain(), BKE_reports_last_displayable(), BKE_reports_move_to_reports(), BKE_reports_string(), BKE_volume_load(), blf_glyph_cache_clear(), blender::ed::sculpt_paint::undo::bmesh_push(), bvhcache_find(), PathTrace::cancel(), blender::asset_system::AssetCatalogService::catalog_tree(), blender::memory_cache::clear(), blender::render::TilesHighlight::clear(), blender::ed::greasepencil::clipboard_free(), HdCyclesDelegate::CommitResources(), Render::compositor_execute(), Render::compositor_free(), blender::gpu::MTLParallelShaderCompiler::create_compile_threads(), data_device_handle_drop(), data_device_handle_enter(), data_device_handle_leave(), data_device_handle_motion(), data_device_handle_selection(), OIDNDenoiser::denoise_buffer(), Device::device_capabilities(), BlenderSession::draw(), PathTraceDisplay::draw(), blender::ed::space_node::draw_nodespace_back_pix(), draw_plane_marker_image(), blender::draw::drw_attributes_merge(), drw_deferred_shader_compilation_exec(), blender::nodes::GeometryNodesLazyFunctionLogger::dump_when_input_is_set_twice(), blender::nodes::GeometryNodesLazyFunctionLogger::dump_when_outputs_are_missing(), ED_space_image_color_sample(), ED_space_image_get_position(), ED_space_image_get_size(), ED_space_image_has_buffer(), ED_space_image_release_buffer(), ED_space_node_color_sample(), ED_space_node_get_position(), blender::CacheMutex::ensure(), blender::compositor::TranslateOperation::ensure_delta(), blender::nodes::ensure_geometry_nodes_lazy_function_graph(), blender::ed::greasepencil::ensure_grease_pencil_clipboard(), blender::ed::sculpt_paint::undo::ensure_node(), TaskScheduler::exit(), HdCyclesGeometry< Base, CyclesBase >::Finalize(), HdCyclesLight::Finalize(), HdCyclesMaterial::Finalize(), blender::gpu::VKPipelinePool::free_data(), GPUDevice::generic_alloc(), GPUDevice::generic_copy_to(), GPUDevice::generic_free(), blender::NodesModifierBakeParams::get(), blender::NodesModifierSimulationParams::get(), blender::render::TilesHighlight::get_all_highlighted_tiles(), blender::deg::get_all_registered_graphs(), ShaderManager::get_attribute_id(), blender::nodes::get_bake_draw_context(), blender::memory_cache::get_base(), Progress::get_cancel_message(), blender::ed::spreadsheet::GeometryDataSource::get_column_values(), Progress::get_current_sample(), blender::bke::CurveComponent::get_curve_for_render(), Progress::get_denoised_tiles(), Progress::get_error_message(), get_next_free_id(), blender::gpu::VKPipelinePool::get_or_create_compute_pipeline(), blender::gpu::VKPipelinePool::get_or_create_graphics_pipeline(), Progress::get_progress(), Progress::get_rendered_tiles(), blender::gpu::get_shared_parallel_shader_compiler(), Progress::get_status(), Progress::get_time(), gizmo_xform_message_subscribe(), GPU_context_create(), GPU_context_discard(), blender::ed::greasepencil::grease_pencil_paste_strokes_poll(), gwl_registry_wl_seat_remove(), icon_create(), icon_ghash_lookup(), image_buttons_region_draw(), image_clipboard_copy_exec(), image_file_format_writable(), image_from_context_has_data_poll(), image_get_gpu_texture(), image_main_region_draw(), image_rect_update(), image_sample_apply(), image_sample_line_exec(), image_save_single(), blender::draw::image_engine::ImageEngine< DrawingMode >::image_sync(), TaskScheduler::init(), blender::nodes::LazyFunctionForForeachGeometryElementZone::initialize_execution_graph(), blender::gpu::MTLSafeFreeList::insert_buffer(), blender::asset_system::AssetCatalogService::invalidate_catalog_tree(), lineart_bounding_area_split(), blender::asset_system::AssetLibrary::load_catalogs(), blender::threading::EnumerableThreadSpecific< T >::local(), blender::nodes::node_geo_bake_cc::DummyDataBlockMap::lookup_or_remember_missing(), blender::NodesModifierBakeDataBlockMap::lookup_or_remember_missing(), TaskScheduler::max_concurrency(), memory_usage_block_num(), memory_usage_current(), blender::bke::mesh_calc_modifiers(), metadata_panel_context_draw(), GPUDevice::move_textures_to_host(), blender::nodes::node_geo_image_info_cc::node_geo_exec(), blender::NodesModifierSimulationParams::NodesModifierSimulationParams(), Progress::operator=(), blender::NodesModifierSimulationParams::output_store_frame_cache(), palette_extract_img_exec(), pose_slide_apply_vec3(), pose_slide_rest_pose_apply_vec3(), primary_selection_device_handle_selection(), GHOST_SystemWayland::processEvents(), GHOST_SystemWayland::pushEvent_maybe_pending(), GHOST_SystemWayland::putClipboardImage(), RE_bake_ibuf_clear(), blender::bke::bake::DiskBlobReader::read(), blender::bke::bake::BlobReadSharing::read_shared(), blender::deg::register_graph(), thread_counting_semaphore::release(), blender::draw::image_engine::SpaceImageAccessor::release_buffer(), blender::draw::image_engine::SpaceNodeAccessor::release_buffer(), blender::gpu::release_shared_parallel_shader_compiler(), blender::ConcurrentMap< Key, Value, Hash, IsEqual >::remove(), blender::gpu::VKPipelinePool::remove(), blender::gpu::render_graph::VKResourceStateTracker::remove_buffer(), blender::gpu::render_graph::VKResourceStateTracker::remove_image(), blender::remove_outdated_bake_caches(), Profiler::remove_state(), blender::bke::Instances::remove_unused_references(), BlenderSession::render(), PathTrace::render(), render_drawlock(), render_endjob(), reports_prepend_impl(), PathTraceDisplay::reset(), Progress::reset_sample(), BlenderSession::reset_session(), RNA_property_pointer_get(), blender::eevee::LightBake::run(), Profiler::run(), blender::ed::space_node::sample_apply(), screen_opengl_render_apply(), seq_sequence_lookup_effects_by_seq(), SEQ_sequence_lookup_free(), SEQ_sequence_lookup_invalidate(), seq_sequence_lookup_meta_by_seq(), SEQ_sequence_lookup_owner_by_channel(), SEQ_sequence_lookup_seq_by_name(), Progress::set_cancel(), Progress::set_error(), Progress::set_render_start_time(), Progress::set_start_time(), Progress::set_status(), Progress::set_substatus(), Progress::set_sync_status(), Progress::set_sync_substatus(), Progress::set_time_limit(), Progress::set_total_pixel_samples(), Progress::set_update(), blender::ed::space_node::snode_bg_viewmove_invoke(), blender::gpu::MTLParallelShaderCompiler::specialization_batch_is_ready(), blender::NodesModifierSimulationParams::store_as_prev_items(), blender::gpu::render_graph::VKRenderGraph::submit_buffer_for_read(), blender::gpu::render_graph::VKRenderGraph::submit_for_present(), blender::gpu::render_graph::VKRenderGraph::submit_synchronization_event(), blender::gpu::render_graph::VKCommandBufferWrapper::submit_with_cpu_synchronization(), GHOST_ContextVK::swapBuffers(), HdCyclesField::Sync(), HdCyclesGeometry< Base, CyclesBase >::Sync(), HdCyclesLight::Sync(), HdCyclesMaterial::Sync(), system_clipboard_put(), system_clipboard_put_primary_selection(), BVHBuild::thread_build_node(), blender::seq::thumbnail_cache_clear(), blender::seq::thumbnail_cache_destroy(), blender::seq::thumbnail_cache_discard_requests_outside(), blender::seq::thumbnail_cache_get(), blender::seq::thumbnail_cache_invalidate_strip(), blender::seq::thumbnail_cache_maintain_capacity(), timeline_draw_cache(), blender::nodes::node_geo_bake_cc::DummyDataBlockMap::try_add(), blender::NodesModifierBakeDataBlockMap::try_add(), blender::ed::object::bake_simulation::try_delete_bake(), blender::memory_cache::try_enforce_limit(), uiTemplateColorPicker(), uiTemplateImage(), uiTemplateImageInfo(), blender::deg::unregister_graph(), blender::eevee::LightBake::update(), PathTraceDisplay::update_begin(), update_global_peak(), blender::ed::space_node::viewer_border_exec(), blender::render::Context::viewer_output_to_viewer_image(), blender::ed::space_node::WIDGETGROUP_node_corner_pin_refresh(), blender::ed::space_node::WIDGETGROUP_node_crop_refresh(), blender::ed::space_node::WIDGETGROUP_node_sbeam_refresh(), blender::ed::space_node::WIDGETGROUP_node_transform_refresh(), WM_set_locked_interface(), blender::ed::object::write_internal_bake_pixels(), and blender::gpu::MTLParallelShaderCompiler::~MTLParallelShaderCompiler().

◆ pad