Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci_steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ on:
type: string
OPENEXR_FORCE_INTERNAL_OPENJPH:
type: string
OPENEXR_CORE_USE_NAMESPACE:
type: string
CMAKE_OSX_ARCHITECTURES:
type: string
BUILD_TESTING:
Expand Down Expand Up @@ -222,6 +224,7 @@ jobs:
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_DEFLATE=${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }}")
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_OPENJPH=${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }}")
cmake_args+=("-DBUILD_TESTING=${{ inputs.BUILD_TESTING }}")
cmake_args+=("-DOPENEXR_CORE_USE_NAMESPACE=${{ inputs.OPENEXR_CORE_USE_NAMESPACE }}")
cmake_args+=("-DOPENEXR_RUN_FUZZ_TESTS=OFF")
cmake_args+=("-DCMAKE_VERBOSE_MAKEFILE=ON")
if [ -n "${{ inputs.namespace }}" ]; then
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
OPENEXR_CORE_USE_NAMESPACE: ${{ matrix.OPENEXR_CORE_USE_NAMESPACE || 'OFF' }}
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
RUN_TESTING: ${{ matrix.RUN_TESTING || 'ON' }}
namespace: ${{ matrix.namespace }}
Expand Down Expand Up @@ -147,6 +148,11 @@ jobs:
RUN_TESTING: OFF
validate_install: OFF

- build: 12
label: OPENEXR_CORE_USE_NAMESPACE
OPENEXR_CORE_USE_NAMESPACE: ON
validate_install: OFF

macOS:
name: 'macOS.${{ matrix.build}}: ${{ matrix.label }}'
uses: ./.github/workflows/ci_steps.yml
Expand All @@ -169,6 +175,7 @@ jobs:
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
OPENEXR_CORE_USE_NAMESPACE: ${{ matrix.OPENEXR_CORE_USE_NAMESPACE || 'OFF' }}
CMAKE_OSX_ARCHITECTURES: ${{ matrix.CMAKE_OSX_ARCHITECTURES }}
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
RUN_TESTING: ${{ matrix.RUN_TESTING || 'ON' }}
Expand Down Expand Up @@ -231,6 +238,11 @@ jobs:
RUN_TESTING: OFF
validate_install: OFF

- build: 11
label: OPENEXR_CORE_USE_NAMESPACE
OPENEXR_CORE_USE_NAMESPACE: ON
validate_install: OFF

windows:
name: 'Windows.${{ matrix.build}}: ${{ matrix.label }}'
uses: ./.github/workflows/ci_steps.yml
Expand All @@ -251,6 +263,7 @@ jobs:
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
OPENEXR_CORE_USE_NAMESPACE: ${{ matrix.OPENEXR_CORE_USE_NAMESPACE || 'OFF' }}
msystem: ${{ matrix.msystem }}
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
RUN_TESTING: ${{ matrix.RUN_TESTING || 'ON' }}
Expand Down Expand Up @@ -317,3 +330,7 @@ jobs:
RUN_TESTING: OFF
validate_install: OFF

- build: 12
label: OPENEXR_CORE_USE_NAMESPACE
OPENEXR_CORE_USE_NAMESPACE: ON
validate_install: OFF
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ expand_template(
"@OPENEXR_VERSION_PATCH@": "0",
"#cmakedefine OPENEXR_ENABLE_API_VISIBILITY": "#define OPENEXR_ENABLE_API_VISIBILITY",
"#cmakedefine OPENEXR_HAVE_LARGE_STACK 1": "/* #undef OPENEXR_HAVE_LARGE_STACK */",
"#cmakedefine OPENEXR_CORE_USE_NAMESPACE @OPENEXR_CORE_USE_NAMESPACE@": "/* #undef OPENEXR_CORE_USE_NAMESPACE */",
},
template = "cmake/OpenEXRConfig.h.in",
)
Expand Down
27 changes: 27 additions & 0 deletions cmake/OpenEXRConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@
#define OPENEXR_IMF_NAMESPACE_CUSTOM @OPENEXR_NAMESPACE_CUSTOM@
#define OPENEXR_IMF_NAMESPACE @OPENEXR_IMF_NAMESPACE@

//
// Option to build OpenEXRCore in a namespace using C++ instead of C
//
// All code in OpenEXRCore is bracketed by ENTER/EXIT pairs. Some of the code
// needs 'extern "C" {' directives, but when compiling with C++, this must
// revert to 'namespace OPENEXR_IMF_INTERNAL_NAMESPACE {'. In C, the NAMESPACE
// ENTER/EXIT pairs degenerate to no-ops.
//
#cmakedefine OPENEXR_CORE_USE_NAMESPACE @OPENEXR_CORE_USE_NAMESPACE@
#if __cplusplus
# ifdef OPENEXR_CORE_USE_NAMESPACE
# define OPENEXR_CORE_NAMESPACE_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
# define OPENEXR_CORE_NAMESPACE_EXIT }
# define OPENEXR_CORE_EXTERN_C_ENTER namespace OPENEXR_IMF_INTERNAL_NAMESPACE {
# else
# define OPENEXR_CORE_NAMESPACE_ENTER
# define OPENEXR_CORE_NAMESPACE_EXIT
# define OPENEXR_CORE_EXTERN_C_ENTER extern "C" {
# endif
# define OPENEXR_CORE_EXTERN_C_EXIT }
#else
# define OPENEXR_CORE_NAMESPACE_ENTER
# define OPENEXR_CORE_NAMESPACE_EXIT
# define OPENEXR_CORE_EXTERN_C_ENTER
# define OPENEXR_CORE_EXTERN_C_EXIT
#endif

//
// Version string for runtime access
//
Expand Down
2 changes: 2 additions & 0 deletions cmake/OpenEXRSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ option(OPENEXR_BUILD_EXAMPLES "Build and install OpenEXR examples" ON)

option(OPENEXR_BUILD_PYTHON "Build python bindings" OFF)

option(OPENEXR_CORE_USE_NAMESPACE "Build the OpenEXRCore library using C++ in a namespace" OFF)

option(OPENEXR_BUILD_OSS_FUZZ "Build the oss-fuzz fuzzers" OFF)
if (OPENEXR_BUILD_OSS_FUZZ)
# If building the oss-fuzz fuzzers, accept the comiler/options from
Expand Down
2 changes: 1 addition & 1 deletion external/deflate/lib/adler32.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ libdeflate_adler32(u32 adler, const void *buffer, size_t len)
{
if (buffer == NULL) /* Return initial value. */
return 1;
return adler32_impl(adler, buffer, len);
return adler32_impl(adler, (const u8*) buffer, len);
}
4 changes: 2 additions & 2 deletions external/deflate/lib/decompress_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ FUNCNAME(struct libdeflate_decompressor * restrict d,
void * restrict out, size_t out_nbytes_avail,
size_t *actual_in_nbytes_ret, size_t *actual_out_nbytes_ret)
{
u8 *out_next = out;
u8 *out_next = (u8*) out;
u8 * const out_end = out_next + out_nbytes_avail;
u8 * const out_fastloop_end =
out_end - MIN(out_nbytes_avail, FASTLOOP_MAX_BYTES_WRITTEN);

/* Input bitstream state; see deflate_decompress.c for documentation */
const u8 *in_next = in;
const u8 *in_next = (const u8*) in;
const u8 * const in_end = in_next + in_nbytes;
const u8 * const in_fastloop_end =
in_end - MIN(in_nbytes, FASTLOOP_MAX_BYTES_READ);
Expand Down
45 changes: 33 additions & 12 deletions external/deflate/lib/deflate_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -2988,7 +2988,10 @@ static const struct {
u8 len_sym_cost;
} default_litlen_costs[] = {
{ /* match_prob = 0.25 */
.used_lits_to_lit_cost = {
#ifndef __cplusplus
.used_lits_to_lit_cost =
#endif
{
6, 6, 22, 32, 38, 43, 48, 51,
54, 57, 59, 61, 64, 65, 67, 69,
70, 72, 73, 74, 75, 76, 77, 79,
Expand Down Expand Up @@ -3023,9 +3026,15 @@ static const struct {
133, 134, 134, 134, 134, 134, 134, 134,
134,
},
.len_sym_cost = 109,
#ifndef __cplusplus
.len_sym_cost =
#endif
109,
}, { /* match_prob = 0.5 */
.used_lits_to_lit_cost = {
#ifndef __cplusplus
.used_lits_to_lit_cost =
#endif
{
16, 16, 32, 41, 48, 53, 57, 60,
64, 66, 69, 71, 73, 75, 76, 78,
80, 81, 82, 83, 85, 86, 87, 88,
Expand Down Expand Up @@ -3060,9 +3069,15 @@ static const struct {
143, 143, 143, 143, 143, 143, 143, 143,
144,
},
.len_sym_cost = 93,
#ifndef __cplusplus
.len_sym_cost =
#endif
93,
}, { /* match_prob = 0.75 */
.used_lits_to_lit_cost = {
#ifndef __cplusplus
.used_lits_to_lit_cost =
#endif
{
32, 32, 48, 57, 64, 69, 73, 76,
80, 82, 85, 87, 89, 91, 92, 94,
96, 97, 98, 99, 101, 102, 103, 104,
Expand Down Expand Up @@ -3097,7 +3112,10 @@ static const struct {
159, 159, 159, 159, 159, 159, 159, 159,
160,
},
.len_sym_cost = 84,
#ifndef __cplusplus
.len_sym_cost =
#endif
84,
},
};

Expand Down Expand Up @@ -3900,7 +3918,7 @@ libdeflate_alloc_compressor_ex(int compression_level,
size += sizeof(c->p.f);
}

c = libdeflate_aligned_malloc(options->malloc_func ?
c = (struct libdeflate_compressor *) libdeflate_aligned_malloc(options->malloc_func ?
options->malloc_func :
libdeflate_default_malloc_func,
MATCHFINDER_MEM_ALIGNMENT, size);
Expand Down Expand Up @@ -4015,7 +4033,10 @@ LIBDEFLATEAPI struct libdeflate_compressor *
libdeflate_alloc_compressor(int compression_level)
{
static const struct libdeflate_options defaults = {
.sizeof_options = sizeof(defaults),
#ifndef __cplusplus
.sizeof_options =
#endif
sizeof(defaults), NULL, NULL
};
return libdeflate_alloc_compressor_ex(compression_level, &defaults);
}
Expand All @@ -4032,18 +4053,18 @@ libdeflate_deflate_compress(struct libdeflate_compressor *c,
* uncompressed blocks.
*/
if (unlikely(in_nbytes <= c->max_passthrough_size))
return deflate_compress_none(in, in_nbytes,
out, out_nbytes_avail);
return deflate_compress_none((const u8*) in, in_nbytes,
(u8*) out, out_nbytes_avail);

/* Initialize the output bitstream structure. */
os.bitbuf = 0;
os.bitcount = 0;
os.next = out;
os.next = (u8*) out;
os.end = os.next + out_nbytes_avail;
os.overflow = false;

/* Call the actual compression function. */
(*c->impl)(c, in, in_nbytes, &os);
(*c->impl)(c, (u8*) in, in_nbytes, &os);

/* Return 0 if the output buffer is too small. */
if (os.overflow)
Expand Down
6 changes: 4 additions & 2 deletions external/deflate/lib/deflate_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ libdeflate_alloc_decompressor_ex(const struct libdeflate_options *options)
if (options->sizeof_options != sizeof(*options))
return NULL;

d = (options->malloc_func ? options->malloc_func :
d = (struct libdeflate_decompressor *) (options->malloc_func ? options->malloc_func :
libdeflate_default_malloc_func)(sizeof(*d));
if (d == NULL)
return NULL;
Expand Down Expand Up @@ -1195,7 +1195,9 @@ LIBDEFLATEAPI struct libdeflate_decompressor *
libdeflate_alloc_decompressor(void)
{
static const struct libdeflate_options defaults = {
.sizeof_options = sizeof(defaults),
sizeof(struct libdeflate_options),
NULL,
NULL
};
return libdeflate_alloc_decompressor_ex(&defaults);
}
Expand Down
12 changes: 6 additions & 6 deletions external/deflate/lib/x86/adler32_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
# else
# define VDPBUSD(a, b, c) _mm_dpbusd_avx_epi32((a), (b), (c))
# endif
# define VLOAD(p) _mm_load_si128((const void *)(p))
# define VLOADU(p) _mm_loadu_si128((const void *)(p))
# define VLOAD(p) _mm_load_si128((const __m128i *)(p))
# define VLOADU(p) _mm_loadu_si128((const __m128i *)(p))
# define VMADD16(a, b) _mm_madd_epi16((a), (b))
# define VMASKZ_LOADU(mask, p) _mm_maskz_loadu_epi8((mask), (p))
# define VMULLO32(a, b) _mm_mullo_epi32((a), (b))
Expand All @@ -87,8 +87,8 @@
# else
# define VDPBUSD(a, b, c) _mm256_dpbusd_avx_epi32((a), (b), (c))
# endif
# define VLOAD(p) _mm256_load_si256((const void *)(p))
# define VLOADU(p) _mm256_loadu_si256((const void *)(p))
# define VLOAD(p) _mm256_load_si256((const __m256i *)(p))
# define VLOADU(p) _mm256_loadu_si256((const __m256i *)(p))
# define VMADD16(a, b) _mm256_madd_epi16((a), (b))
# define VMASKZ_LOADU(mask, p) _mm256_maskz_loadu_epi8((mask), (p))
# define VMULLO32(a, b) _mm256_mullo_epi32((a), (b))
Expand All @@ -107,8 +107,8 @@
# define VADD16(a, b) _mm512_add_epi16((a), (b))
# define VADD32(a, b) _mm512_add_epi32((a), (b))
# define VDPBUSD(a, b, c) _mm512_dpbusd_epi32((a), (b), (c))
# define VLOAD(p) _mm512_load_si512((const void *)(p))
# define VLOADU(p) _mm512_loadu_si512((const void *)(p))
# define VLOAD(p) _mm512_load_si512((const __m512i *)(p))
# define VLOADU(p) _mm512_loadu_si512((const __m512i *)(p))
# define VMADD16(a, b) _mm512_madd_epi16((a), (b))
# define VMASKZ_LOADU(mask, p) _mm512_maskz_loadu_epi8((mask), (p))
# define VMULLO32(a, b) _mm512_mullo_epi32((a), (b))
Expand Down
2 changes: 1 addition & 1 deletion external/deflate/lib/zlib_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ libdeflate_zlib_compress(struct libdeflate_compressor *c,
const void *in, size_t in_nbytes,
void *out, size_t out_nbytes_avail)
{
u8 *out_next = out;
u8 *out_next = (u8*) out;
u16 hdr;
unsigned compression_level;
unsigned level_hint;
Expand Down
2 changes: 1 addition & 1 deletion external/deflate/lib/zlib_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ libdeflate_zlib_decompress_ex(struct libdeflate_decompressor *d,
size_t *actual_in_nbytes_ret,
size_t *actual_out_nbytes_ret)
{
const u8 *in_next = in;
const u8 *in_next = (const u8*) in;
const u8 * const in_end = in_next + in_nbytes;
u16 hdr;
size_t actual_in_nbytes;
Expand Down
4 changes: 4 additions & 0 deletions src/bin/exrinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
# Copyright Contributors to the OpenEXR Project.

add_openexr_bin_program(exrinfo SOURCES main.c)

if (OPENEXR_CORE_USE_NAMESPACE)
set_source_files_properties(main.c PROPERTIES LANGUAGE CXX)
endif()
4 changes: 4 additions & 0 deletions src/bin/exrinfo/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#include <stdlib.h>

#if __cplusplus
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
#endif

static void
usage (FILE* stream, const char* argv0, int verbose)
{
Expand Down
20 changes: 20 additions & 0 deletions src/lib/OpenEXRCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ openexr_define_library(OpenEXRCore
Imath::Imath
)

if (OPENEXR_CORE_USE_NAMESPACE)
message(STATUS "Building OpenEXRCore as C++")
get_target_property(OPENEXR_CORE_SOURCES OpenEXRCore SOURCES)
list(FILTER OPENEXR_CORE_SOURCES INCLUDE REGEX "\\.c$")

# clang++ defaults to interpreting .c files as c code, for force
# language to c++
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(core_compile_options "/TP")
else()
set(core_compile_options "-xc++")
endif()
set_source_files_properties(${OPENEXR_CORE_SOURCES} PROPERTIES
LANGUAGE CXX
COMPILE_OPTIONS ${core_compile_options}
)
else()
message(STATUS "Building OpenEXRCore as C")
endif()

if (DEFINED EXR_DEFLATE_LIB)
if (BUILD_SHARED_LIBS)
target_link_libraries(OpenEXRCore PRIVATE ${EXR_DEFLATE_LIB})
Expand Down
6 changes: 6 additions & 0 deletions src/lib/OpenEXRCore/attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
** Copyright Contributors to the OpenEXR Project.
*/

#include "OpenEXRConfig.h"
#include "internal_attr.h"

#include "internal_constants.h"
#include "internal_structs.h"

#include <string.h>

OPENEXR_CORE_NAMESPACE_ENTER

struct _internal_exr_attr_map
{
const char* name;
Expand Down Expand Up @@ -1131,3 +1134,6 @@ exr_attr_list_remove (

return attr_destroy (ctxt, attr);
}

OPENEXR_CORE_NAMESPACE_EXIT

Loading
Loading