Skip to content

Commit 1e8b2d4

Browse files
committed
api: Versioned namespace to preserve ABI compatibility between minor releases (#4869)
This is a backported version of PR #4869 to minimize the textual differences between 3.1 and 3.2 branches. In 3.1, the main OIIO_NAMESPACE and the OIIO_3_1_NAMESPACE are the same. --- This patch implements the new scheme that we hope will preserve ABI compatibility across minor (yearly) releases. Brief summary: * We will strive to have annual minor releases (e.g., 3.1.x -> 3.2.x) be ABI/link backwards-compatible, as strongly as monthly patch releases (3.1.5 -> 3.1.6) always have been. Every-several-years major releases (3.x -> 4.x) are still a potential full compatibility break. * Consumers of OpenImageIO don't need to change their code, and can just continue to refer to `OIIO::Foo` or `OIIO::Bar()` as always. * Internally, all items in the public OIIO APIs will be in a versioned inner namespace, and will continue to live in the versioned namespace where they were first introduced, forever. (Well, until the next first-digit-changing major release, at which point we will clean up the old cruft and version everything up.) If anything needs to change in an ABI-breaking way, it will be *duplicated* in the newer namespaces, so the old version continues to be available in the old namespace. * The new header nsversions.h contains a long and detailed comment explaining how all the new declarations work. --- Detailed explanation: "Major" or "first digit" releases, which only happen once every several years for us, are full ABI+API breaks. Previously, "minor" or "second digit" releases, which are annual, have fully incompatible ABIs, with separate namespaces to enforce it. Here, we are striving to allow our annual/minor releases to no longer break ABI, to make upgrading easier for downstream users. The basics are that once a symbol is introduced, it will forever live in the namespace of that release. Subsequent release years will have their own namespaces, but will either alias or duplicate the original symbols. This is enabled by our recent (in the lead-up to 3.1) introduction of a split 2-part namespacing scheme. So 3.2 is the first release that has the potential to perserve compatibility with 3.1 in this way. In this PR, I have done this for the whole codebase. It works! -- as measured by being able to have our automated ABI checker show 100% back compatibility with 3.1. So currently, even though this is the nascent 3.2 tree, everything in the public APIs live in the 3.1 ABI namespace. And so they will remain, except for changes that cannot be done without breaking ABI back-compatibility, which will then end up with multiple versions in different versioned namespaces. Let's look this over and decide if we like it. It does involve our developers to do some hoop jumping and take extra care as we develop, to keep things associated with the right namespaces. Users of OpenImageIO shouldn't need to change anything on their end, nor to be aware of this at all. Signed-off-by: Larry Gritz <[email protected]>
1 parent 353e119 commit 1e8b2d4

File tree

113 files changed

+1189
-1050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1189
-1050
lines changed

.github/workflows/build-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ jobs:
203203
time make sphinx
204204
- name: Upload testsuite debugging artifacts
205205
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
206-
if: ${{ failure() || inputs.build_docs == '1' || inputs.benchmark == '1' }}
206+
if: ${{ failure() || inputs.build_docs == '1' || inputs.benchmark == '1' || inputs.abi_check != '' }}
207207
with:
208208
name: oiio-${{github.job}}-${{inputs.nametag}}
209209
path: |

src/build-scripts/ci-abicheck.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ for lib in $LIBS ; do
4141
fgrep "Binary compatibility:" ${lib}-abi-results.txt
4242
echo -e "\x1b[33;0m"
4343
done
44+
cp -r compat_reports ${BUILDDIR_NEW}/compat_reports || true
4445

4546
#
4647
# If the "Binary compatibility" summary results say anything other than 100%,
4748
# we fail!
4849
#
4950
for lib in $LIBS ; do
5051
if [[ `fgrep "Binary compatibility:" ${lib}-abi-results.txt | grep -v 100\%` != "" ]] ; then
51-
cp -r compat_reports ${BUILDDIR_NEW}/compat_reports
5252
exit 1
5353
fi
5454
done

src/doc/Doxyfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,8 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \
21892189
OIIO_NAMESPACE_3_0_END="}" \
21902190
OIIO_NAMESPACE_3_1_BEGIN="namespace OIIO {" \
21912191
OIIO_NAMESPACE_3_1_END="}" \
2192+
OIIO_NAMESPACE_3_2_BEGIN="namespace OIIO {" \
2193+
OIIO_NAMESPACE_3_2_END="}" \
21922194
OIIO_NS_BEGIN="namespace OIIO {" \
21932195
OIIO_NS_END="}" \
21942196
OIIO_CONSTEXPR17=constexpr \

src/include/OpenImageIO/argparse.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
#include <OpenImageIO/paramlist.h>
2121
#include <OpenImageIO/strutil.h>
2222

23+
// Define symbols that let client applications determine if newly added
24+
// features are supported.
25+
#define OIIO_ARGPARSE_SUPPORTS_BRIEFUSAGE 1
26+
#define OIIO_ARGPARSE_SUPPORTS_HUMAN_PARAMNAME 1
2327

24-
OIIO_NAMESPACE_BEGIN
28+
OIIO_NAMESPACE_3_1_BEGIN
2529

2630

2731
/////////////////////////////////////////////////////////////////////////////
@@ -173,7 +177,7 @@ OIIO_NAMESPACE_BEGIN
173177

174178
class OIIO_UTIL_API ArgParse {
175179
public:
176-
class Arg; // Forward declarion of Arg
180+
class Arg; // Forward declaration of Arg
177181

178182
// ------------------------------------------------------------------
179183
/// @defgroup Setting up an ArgParse
@@ -782,11 +786,4 @@ class OIIO_UTIL_API ArgParse {
782786
void usage() const { print_help(); }
783787
};
784788

785-
786-
787-
// Define symbols that let client applications determine if newly added
788-
// features are supported.
789-
#define OIIO_ARGPARSE_SUPPORTS_BRIEFUSAGE 1
790-
#define OIIO_ARGPARSE_SUPPORTS_HUMAN_PARAMNAME 1
791-
792-
OIIO_NAMESPACE_END
789+
OIIO_NAMESPACE_3_1_END

src/include/OpenImageIO/atomic.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020

2121

22-
OIIO_NAMESPACE_BEGIN
22+
OIIO_NAMESPACE_3_1_BEGIN
2323

2424
using std::atomic;
25-
typedef atomic<int> atomic_int;
26-
typedef atomic<long long> atomic_ll;
25+
using atomic_int = atomic<int>;
26+
using atomic_ll = atomic<long long>;
2727

2828

2929

@@ -79,5 +79,4 @@ atomic_fetch_add(atomic<double>& a, double f)
7979
} while (true);
8080
}
8181

82-
83-
OIIO_NAMESPACE_END
82+
OIIO_NAMESPACE_3_1_END

src/include/OpenImageIO/attrdelegate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <OpenImageIO/ustring.h>
1515

1616

17-
OIIO_NAMESPACE_BEGIN
17+
OIIO_NAMESPACE_3_1_BEGIN
1818

1919

2020
namespace pvt {
@@ -229,4 +229,4 @@ template<class C> class AttrDelegate {
229229
};
230230

231231

232-
OIIO_NAMESPACE_END
232+
OIIO_NAMESPACE_3_1_END

src/include/OpenImageIO/benchmark.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#endif
2525

2626

27-
OIIO_NAMESPACE_BEGIN
27+
OIIO_NAMESPACE_3_1_BEGIN
2828

2929
/// DoNotOptimize(val) is a helper function for timing benchmarks that fools
3030
/// the compiler into thinking the the location 'val' is used and will not
@@ -470,6 +470,7 @@ OIIO_FORCEINLINE void clobber_all_memory() { }
470470

471471
#endif
472472

473+
OIIO_UTIL_API std::ostream& operator<<(std::ostream& out,
474+
const Benchmarker& bench);
473475

474-
475-
OIIO_NAMESPACE_END
476+
OIIO_NAMESPACE_3_1_END

src/include/OpenImageIO/bit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <OpenImageIO/platform.h>
1111

1212

13-
OIIO_NAMESPACE_BEGIN
13+
OIIO_NAMESPACE_3_1_BEGIN
1414

1515

1616
/// Standards-compliant bit cast of two equally sized types. This is used
@@ -273,4 +273,4 @@ rotl64(uint64_t x, int k)
273273

274274

275275

276-
OIIO_NAMESPACE_END
276+
OIIO_NAMESPACE_3_1_END

src/include/OpenImageIO/color.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <OpenImageIO/typedesc.h>
1313
#include <OpenImageIO/ustring.h>
1414

15+
// Preprocessor symbol to allow conditional compilation depending on
16+
// whether the ColorProcessor class is exposed (it was not prior to OIIO 1.9).
17+
#define OIIO_HAS_COLORPROCESSOR 1
1518

1619
//
1720
// Some general color management information materials to have handy:
@@ -23,7 +26,12 @@
2326
//
2427

2528

26-
OIIO_NAMESPACE_BEGIN
29+
// Preprocessor symbol to allow conditional compilation depending on
30+
// whether the ColorConfig returns ColorProcessor shared pointers or raw.
31+
#define OIIO_COLORCONFIG_USES_SHARED_PTR 1
32+
33+
34+
OIIO_NAMESPACE_3_1_BEGIN
2735

2836
/// The ColorProcessor encapsulates a baked color transformation, suitable for
2937
/// application to raw pixels, or ImageBuf(s). These are generated using
@@ -50,17 +58,9 @@ class OIIO_API ColorProcessor {
5058
}
5159
};
5260

53-
// Preprocessor symbol to allow conditional compilation depending on
54-
// whether the ColorProcessor class is exposed (it was not prior to OIIO 1.9).
55-
#define OIIO_HAS_COLORPROCESSOR 1
56-
5761

5862

59-
typedef std::shared_ptr<ColorProcessor> ColorProcessorHandle;
60-
61-
// Preprocessor symbol to allow conditional compilation depending on
62-
// whether the ColorConfig returns ColorProcessor shared pointers or raw.
63-
#define OIIO_COLORCONFIG_USES_SHARED_PTR 1
63+
using ColorProcessorHandle = std::shared_ptr<ColorProcessor>;
6464

6565

6666

@@ -515,4 +515,4 @@ linear_to_Rec709(float x)
515515
}
516516

517517

518-
OIIO_NAMESPACE_END
518+
OIIO_NAMESPACE_3_1_END

src/include/OpenImageIO/deepdata.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
#include <OpenImageIO/span.h>
1111
#include <OpenImageIO/string_view.h>
1212

13-
OIIO_NAMESPACE_BEGIN
14-
15-
16-
struct TypeDesc;
17-
class ImageSpec;
18-
13+
OIIO_NAMESPACE_3_1_BEGIN
1914

2015

2116
/// A `DeepData` holds the contents of an image of ``deep'' pixels (multiple
@@ -209,4 +204,4 @@ class OIIO_API DeepData {
209204
};
210205

211206

212-
OIIO_NAMESPACE_END
207+
OIIO_NAMESPACE_3_1_END

0 commit comments

Comments
 (0)