<commit_before>#include <Python.h>
#include "structmember.h"

#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
#include <libkern/OSAtomic.h>
#endif

typedef struct Reference {
	PyObject_HEAD
	PyObject * value;
} Reference;

static int Reference_traverse(Reference * self, visitproc visit, void *arg) {
	Reference *s;
	s = (Reference *)self;
	Py_VISIT(s->value);
	return 0;
}

static int Reference_clear(Reference * self) {
	Reference *s;
	s = (Reference *)self;
	Py_CLEAR(s->value);
	return 0;
}

static void Reference_dealloc(Reference * self) {
	Reference_clear(self);
	Py_TYPE(self)->tp_free((PyObject *) self);
}

static PyObject * Reference_new(PyTypeObject * type, PyObject * args, PyObject * kwds) {
	Reference *self;
	self = (Reference *) type->tp_alloc(type, 0);
	if (self != NULL) {
			self->value = NULL;
	}
	return (PyObject *) self;
}

static int Reference_init(Reference * self, PyObject * args, PyObject * kwds) {
	PyObject *value;
	if (!PyArg_ParseTuple(args, "O", &value)) {
		return -1;
	}
	self->value = value;
	Py_INCREF(self->value);
	return 0;
}

static PyObject * Reference_get(Reference * self) {
	Py_INCREF(self->value);
	return self->value;
}

static PyObject * Reference_set(Reference * self, PyObject * args)
{
	PyObject *new_value;
	if (!PyArg_ParseTuple(args, "O", &new_value)) {
		return NULL;
	}
	self->value = new_value;
	Py_INCREF(self->value);
	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject * Reference_get_and_set(Reference * self, PyObject * args) {
	PyObject *new_value, *old_value;
	if (!PyArg_ParseTuple(args, "O", &new_value)) {
		return NULL;
	}
	old_value = self->value;
	self->value = new_value;
	Py_INCREF(self->value);
	Py_INCREF(old_value);
	return old_value;
}

static PyObject * Reference_compare_and_set(Reference * self, PyObject * args) {
	PyObject *expect_value, *new_value;
	if (!PyArg_ParseTuple(args, "OO", &expect_value, &new_value)) {
		return NULL;
	}
	Py_INCREF(self->value);
	Py_INCREF(expect_value);
	Py_INCREF(new_value);
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
	if (OSAtomicCompareAndSwapPtrBarrier(expect_value, new_value, (void *volatile)self->value)) {
		Py_INCREF(Py_True);
		return Py_True;
	}
#elif defined(_MSC_VER)
	if (InterlockedCompareExchange(&self->value, new_value, old_value)) {
		Py_INCREF(Py_True);
		return Py_True;
	}
#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
	if (__sync_bool_compare_and_swap(&self->value, expect_value, new_value)) {
		Py_INCREF(Py_True);
		return Py_True;
	}
#else
#error No CAS operation available for this platform
#endif
	Py_INCREF(Py_False);
	return Py_False;
}

static PyMemberDef reference_members[] = {
		{"value", T_OBJECT, offsetof(Reference, value), READONLY, "value"},
		{NULL}
};

<commit_msg>Fix bug in the C module affecting Mac OS X<commit_after>#include <Python.h>
#include "structmember.h"

#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
#include <libkern/OSAtomic.h>
#endif

typedef struct Reference {
	PyObject_HEAD
	PyObject * value;
} Reference;

static int Reference_traverse(Reference * self, visitproc visit, void *arg) {
	Reference *s;
	s = (Reference *)self;
	Py_VISIT(s->value);
	return 0;
}

static int Reference_clear(Reference * self) {
	Reference *s;
	s = (Reference *)self;
	Py_CLEAR(s->value);
	return 0;
}

static void Reference_dealloc(Reference * self) {
	Reference_clear(self);
	Py_TYPE(self)->tp_free((PyObject *) self);
}

static PyObject * Reference_new(PyTypeObject * type, PyObject * args, PyObject * kwds) {
	Reference *self;
	self = (Reference *) type->tp_alloc(type, 0);
	if (self != NULL) {
			self->value = NULL;
	}
	return (PyObject *) self;
}

static int Reference_init(Reference * self, PyObject * args, PyObject * kwds) {
	PyObject *value;
	if (!PyArg_ParseTuple(args, "O", &value)) {
		return -1;
	}
	self->value = value;
	Py_INCREF(self->value);
	return 0;
}

static PyObject * Reference_get(Reference * self) {
	Py_INCREF(self->value);
	return self->value;
}

static PyObject * Reference_set(Reference * self, PyObject * args)
{
	PyObject *new_value;
	if (!PyArg_ParseTuple(args, "O", &new_value)) {
		return NULL;
	}
	self->value = new_value;
	Py_INCREF(self->value);
	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject * Reference_get_and_set(Reference * self, PyObject * args) {
	PyObject *new_value, *old_value;
	if (!PyArg_ParseTuple(args, "O", &new_value)) {
		return NULL;
	}
	old_value = self->value;
	self->value = new_value;
	Py_INCREF(self->value);
	Py_INCREF(old_value);
	return old_value;
}

static PyObject * Reference_compare_and_set(Reference * self, PyObject * args) {
	PyObject *expect_value, *new_value;
	if (!PyArg_ParseTuple(args, "OO", &expect_value, &new_value)) {
		return NULL;
	}
	Py_INCREF(self->value);
	Py_INCREF(expect_value);
	Py_INCREF(new_value);
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
	if (OSAtomicCompareAndSwapPtrBarrier(expect_value, new_value,
				(void * volatile)&self->value)) {
		Py_INCREF(Py_True);
		return Py_True;
	}
#elif defined(_MSC_VER)
	if (InterlockedCompareExchange(&self->value, new_value, old_value)) {
		Py_INCREF(Py_True);
		return Py_True;
	}
#elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
	if (__sync_bool_compare_and_swap(&self->value, expect_value, new_value)) {
		Py_INCREF(Py_True);
		return Py_True;
	}
#else
#error No CAS operation available for this platform
#endif
	Py_INCREF(Py_False);
	return Py_False;
}

static PyMemberDef reference_members[] = {
		{"value", T_OBJECT, offsetof(Reference, value), READONLY, "value"},
		{NULL}
};


{'fraction_non_alphanumeric': 0.13346435590494907, 'fraction_numerical': 0.009290691441843845, 'mean_word_length': 5.5781433607520565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3666144', 'n_tokens_mistral': 2156, 'n_tokens_neox': 2130, 'n_words': 451}