Blender  V3.3
Classes | Variables
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 108 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 109 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 148 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 165 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 154 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 162 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 138 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 160 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 157 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 177 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 127 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 186 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 151 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 86 of file atomic_ops_unix.h.

References lock.

◆ atomic_spin_unlock()

ATOMIC_INLINE void atomic_spin_unlock ( volatile AtomicSpinLock lock)

Definition at line 94 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 125 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::SpaceNodeAccessor::acquire_image_buffer(), blender::draw::image_engine::SpaceImageAccessor::acquire_image_buffer(), Progress::add_finished_tile(), Progress::add_samples(), Profiler::add_state(), InstancesComponent::almost_unique_ids(), blender::ed::spreadsheet::GeometryDataSource::apply_selection_filter(), atomic_spin_lock(), atomic_spin_unlock(), Device::available_devices(), blender::ed::space_node::backimage_fit_exec(), bake_object_check(), bake_targets_init_internal(), BKE_gpencil_from_image(), 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_release_ibuf(), BKE_image_save_options_init(), BKE_image_scale(), BKE_volume_load(), blender::draw::image_engine::ImageEngine< DrawingMode >::cache_populate(), NURBSpline::calculate_basis_cache(), PathTrace::cancel(), HdCyclesDelegate::CommitResources(), BezierSpline::control_point_offsets(), data_device_handle_drop(), data_device_handle_enter(), data_device_handle_leave(), data_device_handle_motion(), data_device_handle_selection(), data_source_handle_send(), OIDNDenoiser::denoise_buffer(), Device::device_capabilities(), ShaderManager::device_update_common(), display_destroy(), PathTraceDisplay::draw(), BlenderSession::draw(), blender::ed::space_node::draw_nodespace_back_pix(), draw_plane_marker_image(), 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(), BezierSpline::ensure_auto_handles(), blender::bke::CurvesGeometry::ensure_evaluated_lengths(), blender::bke::CurvesGeometry::ensure_evaluated_offsets(), Spline::evaluated_lengths(), BezierSpline::evaluated_mappings(), blender::bke::CurvesGeometry::evaluated_normals(), Spline::evaluated_normals(), blender::bke::CurvesGeometry::evaluated_positions(), BezierSpline::evaluated_positions(), NURBSpline::evaluated_positions(), blender::bke::CurvesGeometry::evaluated_tangents(), Spline::evaluated_tangents(), TaskScheduler::exit(), HdCyclesGeometry< Base, CyclesBase >::Finalize(), HdCyclesLight::Finalize(), HdCyclesMaterial::Finalize(), ShaderManager::get_attribute_id(), Progress::get_cancel_message(), blender::ed::spreadsheet::GeometryDataSource::get_column_values(), Progress::get_current_sample(), CurveComponent::get_curve_for_render(), Progress::get_denoised_tiles(), Progress::get_error_message(), get_next_free_id(), Progress::get_progress(), Progress::get_rendered_tiles(), Progress::get_status(), Progress::get_time(), gizmo_xform_message_subscribe(), gpencil_boundaryfill_area(), gpencil_erase_processed_area(), gpencil_find_and_mark_empty_areas(), gpencil_get_outline_points(), gpencil_image_texture_get(), gpencil_invert_image(), gpencil_set_borders(), GPU_context_create(), GPU_context_discard(), icon_create(), icon_ghash_lookup(), image_buttons_region_draw(), image_camera_background_texture_get(), image_file_format_writable(), image_from_context_has_data_poll(), image_main_region_draw(), image_rect_update(), image_sample_apply(), image_sample_line_exec(), image_save_single(), TaskScheduler::init(), NURBSpline::knots(), lineart_bounding_area_split(), blender::threading::EnumerableThreadSpecific< T >::local(), TaskScheduler::max_concurrency(), metadata_panel_context_draw(), Progress::operator=(), palette_extract_img_exec(), pose_slide_apply_vec3(), pose_slide_rest_pose_apply_vec3(), GHOST_SystemWayland::putClipboard(), RE_bake_ibuf_clear(), thread_counting_semaphore::release(), blender::draw::image_engine::SpaceNodeAccessor::release_buffer(), blender::draw::image_engine::SpaceImageAccessor::release_buffer(), Profiler::remove_state(), InstancesComponent::remove_unused_references(), BlenderSession::render(), PathTrace::render(), render_drawlock(), render_endjob(), PathTraceDisplay::reset(), Progress::reset_sample(), BlenderSession::reset_session(), RNA_property_pointer_get(), Profiler::run(), blender::ed::space_node::sample_apply(), screen_opengl_render_apply(), 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_total_pixel_samples(), Progress::set_update(), blender::modifiers::geometry_nodes::GeometryNodesEvaluator::should_forward_to_socket(), blender::ed::space_node::snode_bg_viewmove_invoke(), HdCyclesField::Sync(), HdCyclesLight::Sync(), HdCyclesMaterial::Sync(), HdCyclesGeometry< Base, CyclesBase >::Sync(), BVHBuild::thread_build_node(), trace_start_job(), uiTemplateColorPicker(), uiTemplateImage(), uiTemplateImageInfo(), PathTraceDisplay::update_begin(), blender::ed::space_node::viewer_border_exec(), 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(), and write_internal_bake_pixels().

◆ pad

int pad[32 - sizeof(int)]