Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions coverage/ctracer/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,8 @@ static PyObject *
CTracer_start(CTracer *self, PyObject *args_unused)
{
PyEval_SetTrace((Py_tracefunc)CTracer_trace, (PyObject*)self);
self->started = TRUE;
self->tracing_arcs = self->trace_arcs && PyObject_IsTrue(self->trace_arcs);
atomic_store(&self->started, TRUE);

/* start() returns a trace function usable with sys.settrace() */
Py_INCREF(self);
Expand All @@ -993,13 +993,11 @@ CTracer_start(CTracer *self, PyObject *args_unused)
static PyObject *
CTracer_stop(CTracer *self, PyObject *args_unused)
{
if (self->started) {
/* Set the started flag only. The actual call to
PyEval_SetTrace(NULL, NULL) is delegated to the callback
itself to ensure that it called from the right thread.
*/
self->started = FALSE;
}
/* Set the started flag only. The actual call to
PyEval_SetTrace(NULL, NULL) is delegated to the callback
itself to ensure that it called from the right thread.
*/
atomic_store(&self->started, FALSE);

Py_RETURN_NONE;
}
Expand Down
2 changes: 1 addition & 1 deletion coverage/ctracer/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct CTracer {
PyObject * disable_plugin;

/* Has the tracer been started? */
BOOL started;
_Atomic BOOL started;
/* Are we tracing arcs, or just lines? */
BOOL tracing_arcs;
/* Have we had any activity? */
Expand Down
1 change: 1 addition & 0 deletions coverage/ctracer/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define _COVERAGE_UTIL_H

#include <Python.h>
#include <stdatomic.h>

/* Compile-time debugging helpers */
#undef WHAT_LOG /* Define to log the WHAT params in the trace function. */
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ def run(self):

def build_extension(self, ext):
"""Wrap `build_extension` with `BuildFailed`."""
if self.compiler.compiler_type == "msvc":
ext.extra_compile_args = (ext.extra_compile_args or []) + [
"/std:c11",
"/experimental:c11atomics",
]
try:
# Uncomment to test compile failure handling:
# raise errors.CCompilerError("OOPS")
Expand Down
Loading