Skip to content

Commit 0c86675

Browse files
aras-pcary-ilm
andcommitted
OpenEXRCore: fix ILMTHREAD_THREADING_ENABLED checks (#2199)
The CMake setup is always defining ILMTHREAD_THREADING_ENABLED macro, just to either 1 or 0 value, so checking for it via #ifdef will always pass. The non-Core parts of the library were already using correct checks. Signed-off-by: Aras Pranckevicius <aras@nesnausk.org> Co-authored-by: Cary Phillips <cary@ilm.com>
1 parent 9eabc20 commit 0c86675

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/lib/OpenEXRCore/internal_posix_file_impl.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <sys/types.h>
1414
#include <unistd.h>
1515

16-
#ifdef ILMTHREAD_THREADING_ENABLED
16+
#if ILMTHREAD_THREADING_ENABLED
1717
# include <pthread.h>
1818
#endif
1919
#include <stdarg.h>
@@ -37,7 +37,7 @@ struct _internal_exr_filehandle
3737
struct _internal_exr_filehandle
3838
{
3939
int fd;
40-
# ifdef ILMTHREAD_THREADING_ENABLED
40+
# if ILMTHREAD_THREADING_ENABLED
4141
pthread_mutex_t mutex;
4242
# endif
4343
};
@@ -54,7 +54,7 @@ default_shutdown (exr_const_context_t c, void* userdata, int failed)
5454
{
5555
if (fh->fd >= 0) close (fh->fd);
5656
#if !CAN_USE_PREAD
57-
# ifdef ILMTHREAD_THREADING_ENABLED
57+
# if ILMTHREAD_THREADING_ENABLED
5858
pthread_mutex_destroy (&(fh->mutex));
5959
# endif
6060
#endif
@@ -141,7 +141,7 @@ default_read_func (
141141
}
142142

143143
#if !CAN_USE_PREAD
144-
# ifdef ILMTHREAD_THREADING_ENABLED
144+
# if ILMTHREAD_THREADING_ENABLED
145145
pthread_mutex_lock (&(fh->mutex));
146146
# endif
147147
{
@@ -152,7 +152,7 @@ default_read_func (
152152
# endif
153153
if (spos != offset)
154154
{
155-
# ifdef ILMTHREAD_THREADING_ENABLED
155+
# if ILMTHREAD_THREADING_ENABLED
156156
pthread_mutex_unlock (&(fh->mutex));
157157
# endif
158158
if (error_cb)
@@ -193,7 +193,7 @@ default_read_func (
193193
} while (retsz < (int64_t) sz);
194194

195195
#if !CAN_USE_PREAD
196-
# ifdef ILMTHREAD_THREADING_ENABLED
196+
# if ILMTHREAD_THREADING_ENABLED
197197
pthread_mutex_unlock (&(fh->mutex));
198198
# endif
199199
#endif
@@ -255,7 +255,7 @@ default_write_func (
255255
}
256256

257257
#if !CAN_USE_PREAD
258-
# ifdef ILMTHREAD_THREADING_ENABLED
258+
# if ILMTHREAD_THREADING_ENABLED
259259
pthread_mutex_lock (&(fh->mutex));
260260
# endif
261261
{
@@ -266,7 +266,7 @@ default_write_func (
266266
# endif
267267
if (spos != offset)
268268
{
269-
# ifdef ILMTHREAD_THREADING_ENABLED
269+
# if ILMTHREAD_THREADING_ENABLED
270270
pthread_mutex_unlock (&(fh->mutex));
271271
# endif
272272
if (error_cb)
@@ -306,7 +306,7 @@ default_write_func (
306306
} while (retsz < (int64_t) sz);
307307

308308
#if !CAN_USE_PREAD
309-
# ifdef ILMTHREAD_THREADING_ENABLED
309+
# if ILMTHREAD_THREADING_ENABLED
310310
pthread_mutex_unlock (&(fh->mutex));
311311
# endif
312312
#endif
@@ -332,7 +332,7 @@ default_init_read_file (exr_context_t file)
332332

333333
fh->fd = -1;
334334
#if !CAN_USE_PREAD
335-
# ifdef ILMTHREAD_THREADING_ENABLED
335+
# if ILMTHREAD_THREADING_ENABLED
336336
fd = pthread_mutex_init (&(fh->mutex), NULL);
337337
if (fd != 0)
338338
return file->print_error (
@@ -369,7 +369,7 @@ default_init_write_file (exr_context_t file)
369369
if (outfn == NULL) outfn = file->filename.str;
370370

371371
#if !CAN_USE_PREAD
372-
# ifdef ILMTHREAD_THREADING_ENABLED
372+
# if ILMTHREAD_THREADING_ENABLED
373373
fd = pthread_mutex_init (&(fh->mutex), NULL);
374374
if (fd != 0)
375375
return file->print_error (

src/lib/OpenEXRCore/internal_structs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <stdio.h>
1414
#include <string.h>
1515

16-
#ifdef ILMTHREAD_THREADING_ENABLED
16+
#if ILMTHREAD_THREADING_ENABLED
1717
# ifdef _WIN32
1818
# include <synchapi.h>
1919
# include <windows.h>
@@ -28,7 +28,7 @@ static void
2828
default_error_handler (
2929
exr_const_context_t ctxt, exr_result_t code, const char* msg)
3030
{
31-
#ifdef ILMTHREAD_THREADING_ENABLED
31+
#if ILMTHREAD_THREADING_ENABLED
3232
# ifdef _WIN32
3333
static CRITICAL_SECTION sMutex;
3434
volatile static long initialized = 0;
@@ -40,7 +40,7 @@ default_error_handler (
4040
# endif
4141
#endif
4242

43-
#ifdef ILMTHREAD_THREADING_ENABLED
43+
#if ILMTHREAD_THREADING_ENABLED
4444
# ifdef _WIN32
4545
EnterCriticalSection (&sMutex);
4646
# else
@@ -68,7 +68,7 @@ default_error_handler (
6868
fprintf (stderr, "<ERROR>: %s\n", msg);
6969
fflush (stderr);
7070

71-
#ifdef ILMTHREAD_THREADING_ENABLED
71+
#if ILMTHREAD_THREADING_ENABLED
7272
# ifdef _WIN32
7373
LeaveCriticalSection (&sMutex);
7474
# else
@@ -404,7 +404,7 @@ internal_exr_alloc_context (
404404
ret->read_fn = initializers->read_fn;
405405
ret->write_fn = initializers->write_fn;
406406

407-
#ifdef ILMTHREAD_THREADING_ENABLED
407+
#if ILMTHREAD_THREADING_ENABLED
408408
# ifdef _WIN32
409409
InitializeCriticalSection (&(ret->mutex));
410410
# else
@@ -461,7 +461,7 @@ internal_exr_destroy_context (exr_context_t ctxt)
461461
exr_attr_string_destroy (ctxt, &(ctxt->tmp_filename));
462462
exr_attr_list_destroy (ctxt, &(ctxt->custom_handlers));
463463
internal_exr_destroy_parts (ctxt);
464-
#ifdef ILMTHREAD_THREADING_ENABLED
464+
#if ILMTHREAD_THREADING_ENABLED
465465
# ifdef _WIN32
466466
DeleteCriticalSection (&(ctxt->mutex));
467467
# else

src/lib/OpenEXRCore/internal_structs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "openexr_config.h"
1010
#include "internal_attr.h"
1111

12-
#ifdef ILMTHREAD_THREADING_ENABLED
12+
#if ILMTHREAD_THREADING_ENABLED
1313
# ifdef _WIN32
1414
# include <windows.h>
1515
# include <synchapi.h>
@@ -234,7 +234,7 @@ struct _priv_exr_context_t
234234

235235
/* mostly needed for writing, but used during read to ensure
236236
* custom attribute handlers are safe */
237-
#ifdef ILMTHREAD_THREADING_ENABLED
237+
#if ILMTHREAD_THREADING_ENABLED
238238
# ifdef _WIN32
239239
CRITICAL_SECTION mutex;
240240
# else
@@ -252,7 +252,7 @@ struct _priv_exr_context_t
252252
static inline void
253253
internal_exr_lock (exr_const_context_t c)
254254
{
255-
#ifdef ILMTHREAD_THREADING_ENABLED
255+
#if ILMTHREAD_THREADING_ENABLED
256256
exr_context_t nonc = EXR_CONST_CAST (exr_context_t, c);
257257
# ifdef _WIN32
258258
EnterCriticalSection (&nonc->mutex);
@@ -265,7 +265,7 @@ internal_exr_lock (exr_const_context_t c)
265265
static inline void
266266
internal_exr_unlock (exr_const_context_t c)
267267
{
268-
#ifdef ILMTHREAD_THREADING_ENABLED
268+
#if ILMTHREAD_THREADING_ENABLED
269269
exr_context_t nonc = EXR_CONST_CAST (exr_context_t, c);
270270
# ifdef _WIN32
271271
LeaveCriticalSection (&nonc->mutex);

0 commit comments

Comments
 (0)