diff options
author | Georg Brandl <georg@python.org> | 2009-04-05 11:47:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-04-05 11:47:34 (GMT) |
commit | dfd734429ec24b6d55b11f48afe4a9bc8f3db730 (patch) | |
tree | 69e87b57ac63973e280d9b62c380d1ec09b60bf4 /Modules/_io | |
parent | 0c0daf059bbc63047c7d0821f6e9caa161a17de0 (diff) | |
download | cpython-dfd734429ec24b6d55b11f48afe4a9bc8f3db730.zip cpython-dfd734429ec24b6d55b11f48afe4a9bc8f3db730.tar.gz cpython-dfd734429ec24b6d55b11f48afe4a9bc8f3db730.tar.bz2 |
Merge revision 71222 from trunk: #5615: make it possible to configure --without-threads again.
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/bufferedio.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 9960dba..fb41c1d 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -204,7 +204,9 @@ typedef struct { isn't ready for writing. */ Py_off_t write_end; +#ifdef WITH_THREAD PyThread_type_lock lock; +#endif Py_ssize_t buffer_size; Py_ssize_t buffer_mask; @@ -239,6 +241,7 @@ typedef struct { /* These macros protect the BufferedObject against concurrent operations. */ +#ifdef WITH_THREAD #define ENTER_BUFFERED(self) \ Py_BEGIN_ALLOW_THREADS \ PyThread_acquire_lock(self->lock, 1); \ @@ -246,6 +249,10 @@ typedef struct { #define LEAVE_BUFFERED(self) \ PyThread_release_lock(self->lock); +#else +#define ENTER_BUFFERED(self) +#define LEAVE_BUFFERED(self) +#endif #define CHECK_INITIALIZED(self) \ if (self->ok <= 0) { \ @@ -305,10 +312,12 @@ BufferedObject_dealloc(BufferedObject *self) PyMem_Free(self->buffer); self->buffer = NULL; } +#ifdef WITH_THREAD if (self->lock) { PyThread_free_lock(self->lock); self->lock = NULL; } +#endif Py_CLEAR(self->dict); Py_TYPE(self)->tp_free((PyObject *)self); } @@ -565,11 +574,13 @@ _Buffered_init(BufferedObject *self) PyErr_NoMemory(); return -1; } +#ifdef WITH_THREAD self->lock = PyThread_allocate_lock(); if (self->lock == NULL) { PyErr_SetString(PyExc_RuntimeError, "can't allocate read lock"); return -1; } +#endif /* Find out whether buffer_size is a power of 2 */ /* XXX is this optimization useful? */ for (n = self->buffer_size - 1; n & 1; n >>= 1) |