1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
From 21142a1d3354b5d4e97a2e160221ae391362e8c1 Mon Sep 17 00:00:00 2001
From: Jan Schlamelcher <dicom@offis.de>
Date: Fri, 4 Jul 2014 12:02:51 +0200
Subject: [PATCH] Fixed OFoptional by introducing OFalign?
--- a/CMake/osconfig.h.in
+++ b/CMake/osconfig.h.in
@@ -1180,4 +1180,7 @@
/* Define if we are supposed to use STL's system_error */
#cmakedefine HAVE_STL_SYSTEM_ERROR @HAVE_STL_SYSTEM_ERROR@
+/* Define if the compiler supports __declspec(align) */
+#cmakedefine HAVE_DECLSPEC_ALIGN
+
#endif /* !OSCONFIG_H*/
--- a/config/aclocal.m4
+++ b/config/aclocal.m4
@@ -1971,6 +1971,47 @@
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
--- a/config/configure
+++ b/config/configure
@@ -16924,6 +16924,66 @@
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { $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"
--- a/ofstd/tests/toption.cc
+++ b/ofstd/tests/toption.cc
@@ -38,6 +38,11 @@
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 );
|