[PATCH] Fixed OFoptional by introducing OFalign?
authorJan Schlamelcher <dicom@offis.de>
Fri, 4 Jul 2014 10:02:51 +0000 (12:02 +0200)
committerGert Wollny <gewo@debian.org>
Tue, 10 Nov 2020 14:08:59 +0000 (15:08 +0100)
Gbp-Pq: Name 04_Fixed-OFoptional-by-introducing-OFalign.patch

CMake/osconfig.h.in
config/aclocal.m4
config/configure
ofstd/tests/toption.cc

index 3918adc161c7fba231321b10dbfcc21c7c475ffb..bbc49c62c2f80c2622b929b2331cf50410719e4e 100644 (file)
@@ -1223,4 +1223,7 @@ DCMTK was configured to use C++17 features, but your compiler does not or was no
 /* Define if the input iterator category is supported */
 #cmakedefine HAVE_CONTIGUOUS_ITERATOR_CATEGORY @HAVE_CONTIGUOUS_ITERATOR_CATEGORY@
 
+/* Define if the compiler supports __declspec(align) */
+#cmakedefine HAVE_DECLSPEC_ALIGN
+
 #endif /* !OSCONFIG_H*/
index 4641a4c0279452c75e7f6aba0796b605593a1f90..0c4e0af7d7b8c28ee74869b6086291c27f082510 100644 (file)
@@ -1985,6 +1985,47 @@ AC_DEFUN([AC_CHECK_DEFAULT_CONSTRUCTOR_DETECTION_VIA_SFINAE],
     fi
 ])
 
+AC_DEFUN([AC_CHECK_ALIGNOF],
+[
+    AC_MSG_CHECKING([for __alignof__])
+    AC_LINK_IFELSE(
+    [
+        AC_LANG_SOURCE(
+        [
+            int main(){char c[__alignof__(int)];return 0;}
+        ])
+    ],
+    [dcmtk_have_alignof=[yes]],
+    [dcmtk_have_alignof=[no]]
+    )
+    if test "$dcmtk_have_alignof" = yes; then
+        AC_MSG_RESULT([yes])
+        AC_DEFINE($1,[1],[Define if __alignof__ is available])
+    else
+        AC_MSG_RESULT([no])
+    fi
+])
+
+AC_DEFUN([AC_CHECK_ATTRIBUTE_ALIGNED],
+[
+    AC_MSG_CHECKING([for __attribute__((aligned))])
+    AC_LINK_IFELSE(
+    [
+        AC_LANG_SOURCE(
+        [
+            int main(){__attribute__((aligned(4))) char c[16];return 0;}
+        ])
+    ],
+    [dcmtk_have_attribute_aligned=[yes]],
+    [dcmtk_have_attribute_aligned=[no]]
+    )
+    if test "$dcmtk_have_attribute_aligned" = yes; then
+        AC_MSG_RESULT([yes])
+        AC_DEFINE($1,[1],[Define if __attribute__((aligned)) is available])
+    else
+        AC_MSG_RESULT([no])
+    fi
+])
 
 dnl
 dnl This macro checks if a given preprocessor symbol exists and is a string
index 4c04502fd5a6600935cc376fe99a250cc3a62e89..ca43dfe14b0dc17c0ef8327f82cd939e754a3b49 100755 (executable)
@@ -17103,6 +17103,66 @@ $as_echo "no" >&6; }
 
 
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __alignof__" >&5
+$as_echo_n "checking for __alignof__... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+            int main(){char c__alignof__(int);return 0;}
+
+
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  dcmtk_have_alignof=yes
+else
+  dcmtk_have_alignof=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    if test "$dcmtk_have_alignof" = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GNU_ALIGNOF 1" >>confdefs.h
+
+    else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((aligned))" >&5
+$as_echo_n "checking for __attribute__((aligned))... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+            int main(){__attribute__((aligned(4))) char c16;return 0;}
+
+
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  dcmtk_have_attribute_aligned=yes
+else
+  dcmtk_have_attribute_aligned=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    if test "$dcmtk_have_attribute_aligned" = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_ATTRIBUTE_ALIGNED 1" >>confdefs.h
+
+    else
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+
+
 CFLAGS="$DEBUGCFLAGS $CFLAGS"
 CXXFLAGS="$DEBUGCXXFLAGS $CXXFLAGS"
 
index 7e907ea29a73039a19c8bbc8e07963905ee0dab3..ea317246ac36989cfee1d351fdd7f97f831d1b66 100644 (file)
@@ -38,6 +38,11 @@ OFTEST(ofstd_optional)
 
     OFoptional<int> o0( 3 ), o1, o2( OFnullopt );
 
+    COUT << OFalignof(OFoptional<char>) << ' ' << sizeof(OFoptional<char>) << OFendl;
+    COUT << OFalignof(OFoptional<short>) << ' ' << sizeof(OFoptional<short>) << OFendl;
+    COUT << OFalignof(OFoptional<float>) << ' ' << sizeof(OFoptional<float>) << OFendl;
+    COUT << OFalignof(long) << ' ' << sizeof(long) << ' ' << OFalignof(OFoptional<long>) << ' ' << sizeof(OFoptional<long>) << OFendl;
+
     OFCHECK( o0 && *o0 == 3 );
 
     OFCHECK( !o1 && !o2 );