/usr/include/stxxl/bits/common/utils.h is in libstxxl-dev 1.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | /***************************************************************************
* include/stxxl/bits/common/utils.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2002-2006 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2007-2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
* Copyright (C) 2008 Johannes Singler <singler@ira.uka.de>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_UTILS_HEADER
#define STXXL_UTILS_HEADER
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
#ifdef STXXL_BOOST_CONFIG
#include <boost/config.hpp>
#endif
#include <stxxl/bits/namespace.h>
#include <stxxl/bits/common/types.h>
#include <stxxl/bits/compat/type_traits.h>
#include <stxxl/bits/msvc_compatibility.h>
__STXXL_BEGIN_NAMESPACE
////////////////////////////////////////////////////////////////////////////
#if defined(__GXX_EXPERIMENTAL_CXX0X__)
#define STXXL_STATIC_ASSERT(x) static_assert(x, #x)
#else
#define STXXL_STATIC_ASSERT(x) { typedef int static_assert_dummy_type[(x) ? 1 : -1]; }
#endif
////////////////////////////////////////////////////////////////////////////
inline std::vector<std::string>
split(const std::string & str, const std::string & sep)
{
std::vector<std::string> result;
if (str.empty())
return result;
std::string::size_type CurPos(0), LastPos(0);
while (1)
{
CurPos = str.find(sep, LastPos);
if (CurPos == std::string::npos)
break;
std::string sub =
str.substr(LastPos,
std::string::size_type(CurPos -
LastPos));
if (sub.size())
result.push_back(sub);
LastPos = CurPos + sep.size();
}
std::string sub = str.substr(LastPos);
if (sub.size())
result.push_back(sub);
return result;
}
////////////////////////////////////////////////////////////////////////////
inline stxxl::int64 atoint64(const char * s)
{
#ifdef BOOST_MSVC
return _atoi64(s);
#else
return atoll(s);
#endif
}
////////////////////////////////////////////////////////////////////////////
template <typename Tp>
inline const Tp &
STXXL_MIN(const Tp & a, const Tp & b)
{
return std::min<Tp>(a, b);
}
template <typename Tp>
inline const Tp &
STXXL_MAX(const Tp & a, const Tp & b)
{
return std::max<Tp>(a, b);
}
////////////////////////////////////////////////////////////////////////////
template <typename Integral>
inline Integral log2_ceil(Integral i)
{
return Integral(ceil(log2(i)));
}
template <typename Integral>
inline Integral log2_floor(Integral i)
{
return Integral(log2(i));
}
////////////////////////////////////////////////////////////////////////////
template <typename Integral, typename Integral2>
inline
typename compat::remove_const<Integral>::type
div_ceil(Integral __n, Integral2 __d)
{
#if 0 // ambiguous overload for std::div(unsigned_anything, unsigned_anything)
typedef __typeof__(std::div(__n, __d)) div_type;
div_type result = std::div(__n, __d);
return result.quot + (result.rem != 0);
#else
return __n / __d + ((__n % __d) != 0);
#endif
}
////////////////////////////////////////////////////////////////////////////
#ifdef __GNUC__
#define HAVE_BUILTIN_EXPECT
#endif
#ifdef HAVE_BUILTIN_EXPECT
#define LIKELY(c) __builtin_expect((c), 1)
#else
#define LIKELY(c) c
#endif
#ifdef HAVE_BUILTIN_EXPECT
#define UNLIKELY(c) __builtin_expect((c), 0)
#else
#define UNLIKELY(c) c
#endif
////////////////////////////////////////////////////////////////////////////
inline uint64 longhash1(uint64 key_)
{
key_ += ~(key_ << 32);
key_ ^= (key_ >> 22);
key_ += ~(key_ << 13);
key_ ^= (key_ >> 8);
key_ += (key_ << 3);
key_ ^= (key_ >> 15);
key_ += ~(key_ << 27);
key_ ^= (key_ >> 31);
return key_;
}
////////////////////////////////////////////////////////////////////////////
template <class T>
inline void swap_1D_arrays(T * a, T * b, unsigned_type size)
{
for (unsigned_type i = 0; i < size; ++i)
std::swap(a[i], b[i]);
}
////////////////////////////////////////////////////////////////////////////
__STXXL_END_NAMESPACE
#endif // !STXXL_UTILS_HEADER
// vim: et:ts=4:sw=4
|