Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DinoV committed Feb 5, 2024
1 parent 44afe35 commit c326efa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 12 additions & 3 deletions Include/internal/pycore_critical_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,18 @@ extern "C" {
// Asserts that the mutex for the given object is locked. The mutex must
// be held by the top-most critical section otherwise there's the
// possibility that the mutex would be swalled out in some code paths.
#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) \
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&_PyObject_CAST(op)->ob_mutex)
#ifdef Py_DEBUG

#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op) \
if (Py_REFCNT(op) != 1) { \
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&_PyObject_CAST(op)->ob_mutex); \
}

#else /* Py_DEBUG */

#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op)

#endif /* Py_DEBUG */

#else /* !Py_GIL_DISABLED */
// The critical section APIs are no-ops with the GIL.
Expand Down Expand Up @@ -263,7 +271,8 @@ _PyCriticalSection_AssertHeld(PyMutex *mutex) {
if (prev & _Py_CRITICAL_SECTION_TWO_MUTEXES) {
_PyCriticalSection2 *cs = (_PyCriticalSection2 *)(prev & ~_Py_CRITICAL_SECTION_MASK);
assert(cs != NULL && (cs->base.mutex == mutex || cs->mutex2 == mutex));
} else {
}
else {
_PyCriticalSection *cs = (_PyCriticalSection *)(tstate->critical_section & ~_Py_CRITICAL_SECTION_MASK);
assert(cs != NULL && cs->mutex == mutex);
}
Expand Down
14 changes: 5 additions & 9 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ it's USABLE_FRACTION (currently two-thirds) full.
static inline void
ASSERT_DICT_LOCKED(PyObject *op)
{
if (Py_REFCNT(op) != 1) {
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op);
}
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op);
}
#define ASSERT_DICT_LOCKED(op) ASSERT_DICT_LOCKED(_Py_CAST(PyObject*, op))

Expand Down Expand Up @@ -1987,7 +1985,8 @@ _PyDict_SetItem_KnownHash(PyObject *op, PyObject *key, PyObject *value,

if (mp->ma_keys == Py_EMPTY_KEYS) {
res = insert_to_emptydict(interp, mp, Py_NewRef(key), hash, Py_NewRef(value));
} else {
}
else {
/* insertdict() handles any resizing that might be necessary */
res = insertdict(interp, mp, Py_NewRef(key), hash, Py_NewRef(value));
}
Expand Down Expand Up @@ -2521,7 +2520,8 @@ _PyDict_FromKeys(PyObject *cls, PyObject *iterable, PyObject *value)
d = (PyObject *)dict_dict_fromkeys(interp, mp, iterable, value);
Py_END_CRITICAL_SECTION2();
return d;
} else if (PyAnySet_CheckExact(iterable)) {
}
else if (PyAnySet_CheckExact(iterable)) {
PyDictObject *mp = (PyDictObject *)d;

Py_BEGIN_CRITICAL_SECTION2(d, iterable);
Expand Down Expand Up @@ -2874,7 +2874,6 @@ PyDict_Values(PyObject *dict)
Py_BEGIN_CRITICAL_SECTION(dict);
res = values_lock_held(dict);
Py_END_CRITICAL_SECTION();

return res;
}

Expand Down Expand Up @@ -3732,11 +3731,9 @@ PyObject *
PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *defaultobj)
{
PyObject *res;

Py_BEGIN_CRITICAL_SECTION(d);
res = setdefault_lock_held(d, key, defaultobj);
Py_END_CRITICAL_SECTION();

return res;
}

Expand Down Expand Up @@ -4089,7 +4086,6 @@ PyDict_Contains(PyObject *op, PyObject *key)
Py_BEGIN_CRITICAL_SECTION(op);
res = contains_lock_held((PyDictObject *)op, key);
Py_END_CRITICAL_SECTION();

return res;
}

Expand Down

0 comments on commit c326efa

Please sign in to comment.