Skip to content

Commit cff2141

Browse files
pre-commit-ci[bot]kddnewton
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9b130e6 commit cff2141

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

src/libImaging/Imaging.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ extern "C" {
5252
*/
5353

5454
#ifdef Py_GIL_DISABLED
55-
#if defined(__cplusplus)
56-
#define IMAGING_TLS thread_local
57-
#elif defined(HAVE_THREAD_LOCAL)
58-
#define IMAGING_TLS thread_local
59-
#elif defined(HAVE__THREAD_LOCAL)
60-
#define IMAGING_TLS _Thread_local
61-
#elif defined(HAVE___THREAD)
62-
#define IMAGING_TLS __thread
63-
#elif defined(HAVE___DECLSPEC_THREAD_)
64-
#define IMAGING_TLS __declspec(thread)
65-
#endif
55+
#if defined(__cplusplus)
56+
#define IMAGING_TLS thread_local
57+
#elif defined(HAVE_THREAD_LOCAL)
58+
#define IMAGING_TLS thread_local
59+
#elif defined(HAVE__THREAD_LOCAL)
60+
#define IMAGING_TLS _Thread_local
61+
#elif defined(HAVE___THREAD)
62+
#define IMAGING_TLS __thread
63+
#elif defined(HAVE___DECLSPEC_THREAD_)
64+
#define IMAGING_TLS __declspec(thread)
65+
#endif
6666
#endif
6767

6868
/* Handles */
@@ -216,7 +216,8 @@ extern struct ImagingMemoryArena ImagingDefaultArena;
216216
for ((arena) = &ImagingDefaultArena; (arena); (arena) = NULL)
217217
#endif
218218

219-
ImagingMemoryArena ImagingGetArena(void);
219+
ImagingMemoryArena
220+
ImagingGetArena(void);
220221

221222
extern int
222223
ImagingMemorySetBlocksMax(ImagingMemoryArena arena, int blocks_max);

src/libImaging/Storage.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,32 +274,35 @@ static IMAGING_TLS uint64_t ImagingArenaThreadIndex = UINT64_MAX;
274274

275275
/* These are the statically-allocated arenas. */
276276
struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT] = {
277-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 0, {0} },
278-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 1, {0} },
279-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 2, {0} },
280-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 3, {0} },
281-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 4, {0} },
282-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 5, {0} },
283-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 6, {0} },
284-
{ 1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 7, {0} },
285-
{ 0 }
277+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 0, {0}},
278+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 1, {0}},
279+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 2, {0}},
280+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 3, {0}},
281+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 4, {0}},
282+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 5, {0}},
283+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 6, {0}},
284+
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 7, {0}},
285+
{0}
286286
};
287287

288288
/* Get a pointer to the correct arena for this context. In this case where we
289289
* are using a round-robin approach to the statically allocated arenas, we will
290290
* return the arena that is assigned to the thread on first use.
291291
*/
292-
ImagingMemoryArena ImagingGetArena(void) {
292+
ImagingMemoryArena
293+
ImagingGetArena(void) {
293294
if (ImagingArenaThreadIndex == UINT64_MAX) {
294-
ImagingArenaThreadIndex = _Py_atomic_add_uint64(&ImagingArenaIndex, 1) % IMAGING_ARENAS_COUNT;
295+
ImagingArenaThreadIndex =
296+
_Py_atomic_add_uint64(&ImagingArenaIndex, 1) % IMAGING_ARENAS_COUNT;
295297
}
296298
return &ImagingArenas[ImagingArenaThreadIndex];
297299
}
298300

299301
/* Return the arena associated with the given image. In this case the index of
300302
* the arena is stored on the image itself.
301303
*/
302-
ImagingMemoryArena ImagingGetArenaFromImaging(Imaging im) {
304+
ImagingMemoryArena
305+
ImagingGetArenaFromImaging(Imaging im) {
303306
int arenaindex = im->arenaindex;
304307
assert(arenaindex >= 0 && arenaindex < IMAGING_ARENAS_COUNT);
305308
return &ImagingArenas[arenaindex];
@@ -309,7 +312,8 @@ ImagingMemoryArena ImagingGetArenaFromImaging(Imaging im) {
309312
* is necessary in order to return the blocks to the correct arena when the
310313
* image is destroyed.
311314
*/
312-
static void ImagingSetArenaOnImaging(Imaging im, ImagingMemoryArena arena) {
315+
static void
316+
ImagingSetArenaOnImaging(Imaging im, ImagingMemoryArena arena) {
313317
im->arenaindex = arena->index;
314318
}
315319
#else
@@ -340,7 +344,8 @@ struct ImagingMemoryArena ImagingDefaultArena = {
340344
* either have the GIL or we do not have TLS, we will return only the default
341345
* arena.
342346
*/
343-
ImagingMemoryArena ImagingGetArena(void) {
347+
ImagingMemoryArena
348+
ImagingGetArena(void) {
344349
return &ImagingDefaultArena;
345350
}
346351

@@ -589,9 +594,7 @@ ImagingNewInternal(const char *mode, int xsize, int ysize, int dirty) {
589594
ImagingSetArenaOnImaging(im, arena);
590595

591596
MUTEX_LOCK(&arena->mutex);
592-
Imaging tmp = ImagingAllocateArray(
593-
im, arena, dirty, arena->block_size
594-
);
597+
Imaging tmp = ImagingAllocateArray(im, arena, dirty, arena->block_size);
595598
MUTEX_UNLOCK(&arena->mutex);
596599
if (tmp) {
597600
return im;

0 commit comments

Comments
 (0)