Kaydet (Commit) e4b99f5d authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use BOOST_STATIC_ASSERT

Change-Id: Ib9dc2541c3bf72ddd6094331297a91352138e5af
üst de69091d
...@@ -28,6 +28,8 @@ $(eval $(call gb_Library_Library,store)) ...@@ -28,6 +28,8 @@ $(eval $(call gb_Library_Library,store))
$(eval $(call gb_Library_set_soversion_script,store,3,$(SRCDIR)/store/util/store.map)) $(eval $(call gb_Library_set_soversion_script,store,3,$(SRCDIR)/store/util/store.map))
$(eval $(call gb_Library_use_external,store,boost_headers))
$(eval $(call gb_Library_use_packages,store,\ $(eval $(call gb_Library_use_packages,store,\
store_odk_headers \ store_odk_headers \
)) ))
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#ifndef _STORE_STORBASE_HXX_ #ifndef _STORE_STORBASE_HXX_
#define _STORE_STORBASE_HXX_ #define _STORE_STORBASE_HXX_
#include "sal/config.h"
#include "boost/static_assert.hpp"
#include "sal/types.h" #include "sal/types.h"
#include "rtl/alloc.h" #include "rtl/alloc.h"
...@@ -49,22 +52,6 @@ ...@@ -49,22 +52,6 @@
#define STORE_IMPL_CONCAT2(x, y) x##y #define STORE_IMPL_CONCAT2(x, y) x##y
#endif #endif
#ifndef STORE_STATIC_ASSERT /* Compile time assertion */
namespace store
{
template< bool x > struct STATIC_ASSERTION_FAILURE;
template<> struct STATIC_ASSERTION_FAILURE< true > { enum { value = 1 }; };
template< int x > struct static_assert_test{};
} // namespace store
#define STORE_STATIC_ASSERT(pred) \
typedef \
store::static_assert_test< sizeof( store::STATIC_ASSERTION_FAILURE< (bool)(pred) > ) > \
STORE_IMPL_CONCAT(static_assert_typedef_, __LINE__)
#endif /* !STORE_STATIC_ASSERT */
namespace store namespace store
{ {
...@@ -437,7 +424,7 @@ struct PageData ...@@ -437,7 +424,7 @@ struct PageData
*/ */
static const size_t theSize = sizeof(G) + sizeof(D) + 2 * sizeof(L); static const size_t theSize = sizeof(G) + sizeof(D) + 2 * sizeof(L);
static const sal_uInt16 thePageSize = theSize; static const sal_uInt16 thePageSize = theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize);
/** location. /** location.
*/ */
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "sal/config.h"
#include "boost/static_assert.hpp"
#include "storbios.hxx" #include "storbios.hxx"
...@@ -182,7 +185,7 @@ struct SuperBlockPage ...@@ -182,7 +185,7 @@ struct SuperBlockPage
*/ */
static const size_t theSize = 2 * SuperBlock::theSize; static const size_t theSize = 2 * SuperBlock::theSize;
static const sal_uInt16 thePageSize = theSize; static const sal_uInt16 thePageSize = theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize);
/** Allocation. /** Allocation.
*/ */
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "sal/config.h"
#include "boost/static_assert.hpp"
#include "storcach.hxx" #include "storcach.hxx"
...@@ -256,7 +259,7 @@ class PageCache_Impl : ...@@ -256,7 +259,7 @@ class PageCache_Impl :
/** Representation. /** Representation.
*/ */
static size_t const theTableSize = 32; static size_t const theTableSize = 32;
STORE_STATIC_ASSERT(STORE_IMPL_ISP2(theTableSize)); BOOST_STATIC_ASSERT(STORE_IMPL_ISP2(theTableSize));
Entry ** m_hash_table; Entry ** m_hash_table;
Entry * m_hash_table_0[theTableSize]; Entry * m_hash_table_0[theTableSize];
...@@ -330,7 +333,7 @@ PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize) ...@@ -330,7 +333,7 @@ PageCache_Impl::PageCache_Impl (sal_uInt16 nPageSize)
m_nMissed (0) m_nMissed (0)
{ {
static size_t const theSize = SAL_N_ELEMENTS(m_hash_table_0); static size_t const theSize = SAL_N_ELEMENTS(m_hash_table_0);
STORE_STATIC_ASSERT(theSize == theTableSize); BOOST_STATIC_ASSERT(theSize == theTableSize);
memset(m_hash_table_0, 0, sizeof(m_hash_table_0)); memset(m_hash_table_0, 0, sizeof(m_hash_table_0));
} }
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#ifndef _STORE_STORDATA_HXX_ #ifndef _STORE_STORDATA_HXX_
#define _STORE_STORDATA_HXX_ #define _STORE_STORDATA_HXX_
#include "sal/config.h"
#include "boost/static_assert.hpp"
#include "sal/types.h" #include "sal/types.h"
#include "sal/macros.h" #include "sal/macros.h"
...@@ -55,7 +58,7 @@ struct OStoreDataPageData : public store::OStorePageData ...@@ -55,7 +58,7 @@ struct OStoreDataPageData : public store::OStorePageData
*/ */
static const size_t theSize = 0; static const size_t theSize = 0;
static const sal_uInt16 thePageSize = base::theSize + self::theSize; static const sal_uInt16 thePageSize = base::theSize + self::theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
/** capacity. /** capacity.
*/ */
...@@ -145,7 +148,7 @@ struct OStoreIndirectionPageData : public store::OStorePageData ...@@ -145,7 +148,7 @@ struct OStoreIndirectionPageData : public store::OStorePageData
*/ */
static const size_t theSize = sizeof(G); static const size_t theSize = sizeof(G);
static const sal_uInt16 thePageSize = base::theSize + self::theSize; static const sal_uInt16 thePageSize = base::theSize + self::theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
/** capacity. /** capacity.
*/ */
...@@ -570,7 +573,7 @@ struct OStoreDirectoryPageData : public store::OStorePageData ...@@ -570,7 +573,7 @@ struct OStoreDirectoryPageData : public store::OStorePageData
*/ */
static const size_t theSize = NameBlock::theSize + DataBlock::theSize; static const size_t theSize = NameBlock::theSize + DataBlock::theSize;
static const sal_uInt16 thePageSize = base::theSize + self::theSize; static const sal_uInt16 thePageSize = base::theSize + self::theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
/** capacity. /** capacity.
*/ */
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#ifndef _STORE_STORTREE_HXX #ifndef _STORE_STORTREE_HXX
#define _STORE_STORTREE_HXX #define _STORE_STORTREE_HXX
#include "sal/config.h"
#include "boost/static_assert.hpp"
#include "sal/types.h" #include "sal/types.h"
#include "store/types.h" #include "store/types.h"
...@@ -120,7 +123,7 @@ struct OStoreBTreeNodeData : public store::OStorePageData ...@@ -120,7 +123,7 @@ struct OStoreBTreeNodeData : public store::OStorePageData
*/ */
static const size_t theSize = sizeof(G); static const size_t theSize = sizeof(G);
static const sal_uInt16 thePageSize = base::theSize + self::theSize; static const sal_uInt16 thePageSize = base::theSize + self::theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= self::thePageSize);
/** capacity. /** capacity.
*/ */
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "sal/config.h"
#include "boost/static_assert.hpp"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "rtl/alloc.h" #include "rtl/alloc.h"
#include "rtl/ref.hxx" #include "rtl/ref.hxx"
...@@ -156,7 +159,7 @@ struct PageData ...@@ -156,7 +159,7 @@ struct PageData
*/ */
static const size_t theSize = sizeof(G) + sizeof(D) + 2 * sizeof(L); static const size_t theSize = sizeof(G) + sizeof(D) + 2 * sizeof(L);
static const sal_uInt16 thePageSize = theSize; static const sal_uInt16 thePageSize = theSize;
STORE_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize); BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize);
/** type. /** type.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment