summaryrefslogtreecommitdiff
path: root/Modules/_bz2module.c
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-09-07 18:56:24 +0200
committerVictor Stinner <victor.stinner@gmail.com>2017-09-07 18:56:24 +0200
commita6a4dc816d68df04a7d592e0b6af8c7ecc4d4344 (patch)
tree1c31738009bee903417cea928e705a112aea2392 /Modules/_bz2module.c
parent1f06a680de465be0c24a78ea3b610053955daa99 (diff)
downloadcpython-git-a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344.tar.gz
bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config * Always define WITH_THREAD for compatibility.
Diffstat (limited to 'Modules/_bz2module.c')
-rw-r--r--Modules/_bz2module.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c
index 409522f972..dba0e19384 100644
--- a/Modules/_bz2module.c
+++ b/Modules/_bz2module.c
@@ -5,9 +5,7 @@
#include "Python.h"
#include "structmember.h"
-#ifdef WITH_THREAD
#include "pythread.h"
-#endif
#include <bzlib.h>
#include <stdio.h>
@@ -23,7 +21,6 @@
#endif /* ! BZ_CONFIG_ERROR */
-#ifdef WITH_THREAD
#define ACQUIRE_LOCK(obj) do { \
if (!PyThread_acquire_lock((obj)->lock, 0)) { \
Py_BEGIN_ALLOW_THREADS \
@@ -31,19 +28,13 @@
Py_END_ALLOW_THREADS \
} } while (0)
#define RELEASE_LOCK(obj) PyThread_release_lock((obj)->lock)
-#else
-#define ACQUIRE_LOCK(obj)
-#define RELEASE_LOCK(obj)
-#endif
typedef struct {
PyObject_HEAD
bz_stream bzs;
int flushed;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} BZ2Compressor;
typedef struct {
@@ -59,9 +50,7 @@ typedef struct {
separately. Conversion and looping is encapsulated in
decompress_buf() */
size_t bzs_avail_in_real;
-#ifdef WITH_THREAD
PyThread_type_lock lock;
-#endif
} BZ2Decompressor;
static PyTypeObject BZ2Compressor_Type;
@@ -325,13 +314,11 @@ _bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel)
return -1;
}
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return -1;
}
-#endif
self->bzs.opaque = NULL;
self->bzs.bzalloc = BZ2_Malloc;
@@ -343,10 +330,8 @@ _bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel)
return 0;
error:
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
self->lock = NULL;
-#endif
return -1;
}
@@ -354,10 +339,8 @@ static void
BZ2Compressor_dealloc(BZ2Compressor *self)
{
BZ2_bzCompressEnd(&self->bzs);
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -651,13 +634,11 @@ _bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self)
{
int bzerror;
-#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
if (self->lock == NULL) {
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
return -1;
}
-#endif
self->needs_input = 1;
self->bzs_avail_in_real = 0;
@@ -675,10 +656,8 @@ _bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self)
error:
Py_CLEAR(self->unused_data);
-#ifdef WITH_THREAD
PyThread_free_lock(self->lock);
self->lock = NULL;
-#endif
return -1;
}
@@ -689,10 +668,8 @@ BZ2Decompressor_dealloc(BZ2Decompressor *self)
PyMem_Free(self->input_buffer);
BZ2_bzDecompressEnd(&self->bzs);
Py_CLEAR(self->unused_data);
-#ifdef WITH_THREAD
if (self->lock != NULL)
PyThread_free_lock(self->lock);
-#endif
Py_TYPE(self)->tp_free((PyObject *)self);
}