3e5a623
From c8e9e15f8e51a3e0f2e690c642b6b4a4e3edc8d4 Mon Sep 17 00:00:00 2001
3e5a623
From: Larry Gritz <lg@larrygritz.com>
3e5a623
Date: Tue, 20 May 2014 12:06:25 -0700
3e5a623
Subject: [PATCH 1/4] Better handling of stdint.h and defines.
3e5a623
3e5a623
Try more ways to ensure that __STDC_LIMIT_MACROS is defined before we
3e5a623
include stdint.h. And, when we really need its defines, if they didn't
3e5a623
come through, try to give a clear error message.
3e5a623
---
3e5a623
 CMakeLists.txt                       |  2 ++
3e5a623
 src/include/OpenImageIO/fmath.h      |  5 ++++-
3e5a623
 src/include/OpenImageIO/image_view.h | 17 +++++++++++++----
3e5a623
 3 files changed, 19 insertions(+), 5 deletions(-)
3e5a623
3e5a623
diff --git a/CMakeLists.txt b/CMakeLists.txt
3e5a623
index ed4665e..8bc96a8 100644
3e5a623
--- a/CMakeLists.txt
3e5a623
+++ b/CMakeLists.txt
3e5a623
@@ -69,6 +69,8 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
3e5a623
     # CMake doesn't automatically know what do do with
3e5a623
     # include_directories(SYSTEM...) when using clang or gcc.
3e5a623
     set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
3e5a623
+    # Ensure this macro is set for stdint.h
3e5a623
+    add_definitions ("-D__STDC_LIMIT_MACROS")
3e5a623
 endif ()
3e5a623
 
3e5a623
 if (CMAKE_COMPILER_IS_CLANG)
3e5a623
diff --git a/src/include/OpenImageIO/fmath.h b/src/include/OpenImageIO/fmath.h
3e5a623
index 33b90b3..367df8a 100644
3e5a623
--- a/src/include/OpenImageIO/fmath.h
3e5a623
+++ b/src/include/OpenImageIO/fmath.h
3e5a623
@@ -61,7 +61,10 @@
3e5a623
 #  define _UINT64_T
3e5a623
 # endif
3e5a623
 #else
3e5a623
-# include <stdint.h>
3e5a623
+#  ifndef __STDC_LIMIT_MACROS
3e5a623
+#    define __STDC_LIMIT_MACROS  /* needed for some defs in stdint.h */
3e5a623
+#  endif
3e5a623
+#  include <stdint.h>
3e5a623
 #endif
3e5a623
 
3e5a623
 #if defined(__FreeBSD__)
3e5a623
diff --git a/src/include/OpenImageIO/image_view.h b/src/include/OpenImageIO/image_view.h
3e5a623
index cffa0e1..981eb52 100644
3e5a623
--- a/src/include/OpenImageIO/image_view.h
3e5a623
+++ b/src/include/OpenImageIO/image_view.h
3e5a623
@@ -32,13 +32,22 @@
3e5a623
 
3e5a623
 #pragma once
3e5a623
 
3e5a623
-#ifndef __STDC_LIMIT_MACROS
3e5a623
-# define __STDC_LIMIT_MACROS  /* needed for some defs in stdint.h */
3e5a623
-#endif
3e5a623
-
3e5a623
 #include <vector>
3e5a623
 #include <stdexcept>
3e5a623
+
3e5a623
+// We're including stdint.h to get int64_t and INT64_MIN. But on some
3e5a623
+// platforms, stdint.h only defines them if __STDC_LIMIT_MACROS is defined,
3e5a623
+// so we do so. But, oops, if user code included stdint.h before this file,
3e5a623
+// and without defining the macro, it may have had ints one and only include
3e5a623
+// and not seen the definitions we need, so at least try to make a helpful
3e5a623
+// compile-time error in that case.
3e5a623
+#ifndef __STDC_LIMIT_MACROS
3e5a623
+#  define __STDC_LIMIT_MACROS  /* needed for some defs in stdint.h */
3e5a623
+#endif
3e5a623
 #include <stdint.h>
3e5a623
+#if ! defined(INT64_MIN)
3e5a623
+#  error You must define __STDC_LIMIT_MACROS prior to including stdint.h
3e5a623
+#endif
3e5a623
 
3e5a623
 #include "oiioversion.h"
3e5a623
 #include "strided_ptr.h"
3e5a623
-- 
3e5a623
1.9.3
3e5a623
3e5a623
3e5a623
From 338f58ac9433dc2c064c4cfe840f51809abe68d3 Mon Sep 17 00:00:00 2001
3e5a623
From: Larry Gritz <lg@larrygritz.com>
3e5a623
Date: Tue, 20 May 2014 12:54:10 -0700
3e5a623
Subject: [PATCH 2/4] Improve warning suppression for recent gcc
3e5a623
3e5a623
---
3e5a623
 CMakeLists.txt | 5 ++++-
3e5a623
 1 file changed, 4 insertions(+), 1 deletion(-)
3e5a623
3e5a623
diff --git a/CMakeLists.txt b/CMakeLists.txt
3e5a623
index 8bc96a8..509e95c 100644
3e5a623
--- a/CMakeLists.txt
3e5a623
+++ b/CMakeLists.txt
3e5a623
@@ -82,11 +82,14 @@ if (CMAKE_COMPILER_IS_CLANG)
3e5a623
     add_definitions ("-Wunused-private-field")
3e5a623
     # disable warning about unused command line arguments
3e5a623
     add_definitions ("-Qunused-arguments")
3e5a623
+    # Don't warn if we ask it not to warn about warnings it doesn't know
3e5a623
+    add_definitions ("-Wunknown-warning-option")
3e5a623
 endif ()
3e5a623
 
3e5a623
-if (CMAKE_COMPILER_IS_GNUCC AND (NOT ${GCC_VERSION} VERSION_LESS 4.8))
3e5a623
+if (CMAKE_COMPILER_IS_GNUCC AND (NOT CMAKE_COMPILER_IS_CLANG) AND (NOT ${GCC_VERSION} VERSION_LESS 4.8))
3e5a623
     # suppress a warning that Boost::Python hits in g++ 4.8
3e5a623
     add_definitions ("-Wno-error=unused-local-typedefs")
3e5a623
+    add_definitions ("-Wunused-local-typedefs")
3e5a623
 endif ()
3e5a623
 
3e5a623
 if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
3e5a623
-- 
3e5a623
1.9.3
3e5a623
3e5a623
3e5a623
From 1e086bcbc491c9bd2f26cf6f260ef5696e6c1af1 Mon Sep 17 00:00:00 2001
3e5a623
From: Larry Gritz <lg@larrygritz.com>
3e5a623
Date: Tue, 20 May 2014 14:37:56 -0700
3e5a623
Subject: [PATCH 3/4] SPI compiler diddling
3e5a623
3e5a623
---
3e5a623
 site/spi/Makefile-bits-arnold | 14 ++++++++++++--
3e5a623
 1 file changed, 12 insertions(+), 2 deletions(-)
3e5a623
3e5a623
diff --git a/site/spi/Makefile-bits-arnold b/site/spi/Makefile-bits-arnold
3e5a623
index dfd70e1..422fb35 100644
3e5a623
--- a/site/spi/Makefile-bits-arnold
3e5a623
+++ b/site/spi/Makefile-bits-arnold
3e5a623
@@ -67,15 +67,25 @@ ifeq ($(SP_OS), spinux1)
3e5a623
     endif
3e5a623
 
3e5a623
     ifeq (${COMPILER}, gcc463)
3e5a623
-    MY_CMAKE_FLAGS += \
3e5a623
+      MY_CMAKE_FLAGS += \
3e5a623
          -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.6.3-test/bin/gcc \
3e5a623
          -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.6.3-test/bin/g++
3e5a623
     endif
3e5a623
     ifeq (${COMPILER}, gcc470)
3e5a623
-    MY_CMAKE_FLAGS += \
3e5a623
+      MY_CMAKE_FLAGS += \
3e5a623
          -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.0-test/bin/gcc \
3e5a623
          -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.0-test/bin/g++
3e5a623
     endif
3e5a623
+    ifeq (${COMPILER}, gcc472)
3e5a623
+      MY_CMAKE_FLAGS += \
3e5a623
+         -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/gcc \
3e5a623
+         -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/g++
3e5a623
+    endif
3e5a623
+    ifeq (${COMPILER}, gcc490)
3e5a623
+      MY_CMAKE_FLAGS += \
3e5a623
+         -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/gcc \
3e5a623
+         -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/g++
3e5a623
+    endif
3e5a623
 
3e5a623
     ifneq (,$(wildcard /usr/include/OpenEXR2))
3e5a623
         MY_CMAKE_FLAGS += \
3e5a623
-- 
3e5a623
1.9.3
3e5a623
3e5a623
3e5a623
From 39c28a09702f1726061f917be99f7ec22b12e39a Mon Sep 17 00:00:00 2001
3e5a623
From: Larry Gritz <lg@larrygritz.com>
3e5a623
Date: Tue, 20 May 2014 14:47:46 -0700
3e5a623
Subject: [PATCH 4/4] Fix confusion of stride_t vs ptrdiff_t for platforms
3e5a623
 where they're differen
3e5a623
3e5a623
---
3e5a623
 src/include/OpenImageIO/array_view.h | 12 ++++++------
3e5a623
 src/include/OpenImageIO/image_view.h | 18 +++++++++---------
3e5a623
 2 files changed, 15 insertions(+), 15 deletions(-)
3e5a623
3e5a623
diff --git a/src/include/OpenImageIO/array_view.h b/src/include/OpenImageIO/array_view.h
3e5a623
index 0b9e18c..ffa6ee9 100644
3e5a623
--- a/src/include/OpenImageIO/array_view.h
3e5a623
+++ b/src/include/OpenImageIO/array_view.h
3e5a623
@@ -223,7 +223,7 @@ class array_view_strided {
3e5a623
     array_view_strided (T *data, size_t len) { init(data,len); }
3e5a623
 
3e5a623
     /// Construct from T*, length, and stride (in bytes).
3e5a623
-    array_view_strided (T *data, size_t len, ptrdiff_t stride) {
3e5a623
+    array_view_strided (T *data, size_t len, stride_t stride) {
3e5a623
         init(data,len,stride);
3e5a623
     }
3e5a623
 
3e5a623
@@ -263,7 +263,7 @@ class array_view_strided {
3e5a623
     size_type size() const { return m_len; }
3e5a623
     size_type max_size() const { return m_len; }
3e5a623
     bool empty() const { return m_len == 0; }
3e5a623
-    ptrdiff_t stride() const { return m_stride; }
3e5a623
+    stride_t stride() const { return m_stride; }
3e5a623
 
3e5a623
     const T& operator[] (size_type pos) const { return get(pos); }
3e5a623
     const T& at (size_t pos) const {
3e5a623
@@ -310,17 +310,17 @@ class array_view_strided {
3e5a623
 private:
3e5a623
     T * m_data;
3e5a623
     size_t m_len;
3e5a623
-    ptrdiff_t m_stride;
3e5a623
+    stride_t m_stride;
3e5a623
 
3e5a623
-    void init (T *data, size_t len, ptrdiff_t stride=AutoStride) {
3e5a623
+    void init (T *data, size_t len, stride_t stride=AutoStride) {
3e5a623
         m_data = data;
3e5a623
         m_len = len;
3e5a623
         m_stride = stride == AutoStride ? sizeof(T) : stride;
3e5a623
     }
3e5a623
-    inline T* getptr (ptrdiff_t pos=0) const {
3e5a623
+    inline T* getptr (stride_t pos=0) const {
3e5a623
         return (T*)((char *)m_data + pos*m_stride);
3e5a623
     }
3e5a623
-    inline T& get (ptrdiff_t pos=0) const {
3e5a623
+    inline T& get (stride_t pos=0) const {
3e5a623
         return *getptr(pos);
3e5a623
     }
3e5a623
 
3e5a623
diff --git a/src/include/OpenImageIO/image_view.h b/src/include/OpenImageIO/image_view.h
3e5a623
index 981eb52..efdcbb2 100644
3e5a623
--- a/src/include/OpenImageIO/image_view.h
3e5a623
+++ b/src/include/OpenImageIO/image_view.h
3e5a623
@@ -83,8 +83,8 @@ class image_view {
3e5a623
     /// bytes).
3e5a623
     image_view (T *data, int nchannels,
3e5a623
               int width, int height, int depth=1,
3e5a623
-              ptrdiff_t chanstride=AutoStride, ptrdiff_t xstride=AutoStride,
3e5a623
-              ptrdiff_t ystride=AutoStride, ptrdiff_t zstride=AutoStride) {
3e5a623
+              stride_t chanstride=AutoStride, stride_t xstride=AutoStride,
3e5a623
+              stride_t ystride=AutoStride, stride_t zstride=AutoStride) {
3e5a623
         init (data, nchannels, width, height, depth,
3e5a623
               chanstride, xstride, ystride, zstride);
3e5a623
     }
3e5a623
@@ -110,10 +110,10 @@ class image_view {
3e5a623
     int height() const { return m_height; }
3e5a623
     int depth() const { return m_depth; }
3e5a623
 
3e5a623
-    ptrdiff_t chanstride() const { return m_chanstride; }
3e5a623
-    ptrdiff_t xstride() const { return m_xstride; }
3e5a623
-    ptrdiff_t ystride() const { return m_ystride; }
3e5a623
-    ptrdiff_t zstride() const { return m_zstride; }
3e5a623
+    stride_t chanstride() const { return m_chanstride; }
3e5a623
+    stride_t xstride() const { return m_xstride; }
3e5a623
+    stride_t ystride() const { return m_ystride; }
3e5a623
+    stride_t zstride() const { return m_zstride; }
3e5a623
 
3e5a623
     const T* data() const { return m_data; }
3e5a623
 
3e5a623
@@ -122,12 +122,12 @@ class image_view {
3e5a623
 private:
3e5a623
     const T * m_data;
3e5a623
     int m_nchannels, m_width, m_height, m_depth;
3e5a623
-    ptrdiff_t m_chanstride, m_xstride, m_ystride, m_zstride;
3e5a623
+    stride_t m_chanstride, m_xstride, m_ystride, m_zstride;
3e5a623
 
3e5a623
     void init (T *data, int nchannels,
3e5a623
                int width, int height, int depth=1,
3e5a623
-               ptrdiff_t chanstride=AutoStride, ptrdiff_t xstride=AutoStride,
3e5a623
-               ptrdiff_t ystride=AutoStride, ptrdiff_t zstride=AutoStride) {
3e5a623
+               stride_t chanstride=AutoStride, stride_t xstride=AutoStride,
3e5a623
+               stride_t ystride=AutoStride, stride_t zstride=AutoStride) {
3e5a623
         m_data = data;
3e5a623
         m_nchannels = nchannels;
3e5a623
         m_width = width;  m_height = height;  m_depth = depth;
3e5a623
-- 
3e5a623
1.9.3
3e5a623