Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
hameerabbasi committed Jan 14, 2025
1 parent 4adb130 commit 202944b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Run clang-format style check for C/C++ code.
uses: jidicula/[email protected]
with:
clang-format-version: '18'
clang-format-version: '19'
check-path: 'src'
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ test-command = "pytest --pyargs uarray"
[tool.cibuildwheel.macos]
archs = ["universal2"]

[[tool.cibuildwheel.overrides]]
inherit.environment = "append"
environment.MACOSX_DEPLOYMENT_TARGET = "10.13"

[tool.cibuildwheel.config-settings]
"cmake.verbose" = true
"logging.level" = "INFO"
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.15...3.30)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version")

project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)

Expand Down
42 changes: 21 additions & 21 deletions src/_uarray_dispatch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@ namespace {

template <typename T>
class immortal {
alignas(T) std::byte storage[sizeof(T)];
alignas(T) std::byte storage[sizeof(T)];

public:
template <typename... Args>
immortal(Args&&... args) {
// Construct new T in storage
new(&storage) T(std::forward<Args>(args)...);
}
~immortal() {
// Intentionally don't call destructor
}

T* get() { return reinterpret_cast<T*>(&storage); }
const T* get() const { return reinterpret_cast<const T*>(&storage); }
const T* get_const() const { return reinterpret_cast<const T*>(&storage); }
template <typename... Args>
immortal(Args &&... args) {
// Construct new T in storage
new (&storage) T(std::forward<Args>(args)...);
}
~immortal() {
// Intentionally don't call destructor
}

const T* operator ->() const { return get(); }
T* operator ->() { return get(); }
T * get() { return reinterpret_cast<T *>(&storage); }
const T * get() const { return reinterpret_cast<const T *>(&storage); }
const T * get_const() const { return reinterpret_cast<const T *>(&storage); }

T& operator*() { return *get(); }
const T& operator*() const { return *get(); }
const T * operator->() const { return get(); }
T * operator->() { return get(); }

T & operator*() { return *get(); }
const T & operator*() const { return *get(); }
};

/** Handle to a python object that automatically DECREFs */
Expand Down Expand Up @@ -1196,7 +1195,8 @@ py_ref Function::canonicalize_kwargs(PyObject * kwargs) {

py_func_args Function::replace_dispatchables(
PyObject * backend, PyObject * args, PyObject * kwargs, PyObject * coerce) {
auto has_ua_convert = PyObject_HasAttr(backend, identifiers.ua_convert->get());
auto has_ua_convert =
PyObject_HasAttr(backend, identifiers.ua_convert->get());
if (!has_ua_convert) {
return {py_ref::ref(args), py_ref::ref(kwargs)};
}
Expand Down Expand Up @@ -1548,8 +1548,8 @@ PyObject * set_state(PyObject * /* self */, PyObject * args) {
local_domain_map = state->locals;
bool use_thread_local_globals =
(!reset_allowed) || state->use_thread_local_globals;
current_global_state =
use_thread_local_globals ? &thread_local_domain_map : global_domain_map.get();
current_global_state = use_thread_local_globals ? &thread_local_domain_map
: global_domain_map.get();

if (use_thread_local_globals)
thread_local_domain_map = state->globals;
Expand Down Expand Up @@ -1845,7 +1845,7 @@ PyMODINIT_FUNC PyInit__uarray(void) {
return nullptr;

#if Py_GIL_DISABLED
PyUnstable_Module_SetGIL(m.get(), Py_MOD_GIL_NOT_USED);
PyUnstable_Module_SetGIL(m.get(), Py_MOD_GIL_NOT_USED);
#endif

return m.release();
Expand Down

0 comments on commit 202944b

Please sign in to comment.