<commit_before>// Copyright (c) 2009-2010 <NAME>
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_UTIL_H
#define BITCOIN_UTIL_H

#if defined(HAVE_CONFIG_H)
#include "bitcoin-config.h"
#endif

#include "compat.h"
#include "serialize.h"
#include "tinyformat.h"

#include <cstdio>
#include <exception>
#include <map>
#include <stdarg.h>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>

#ifndef WIN32
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#endif

#include <boost/filesystem/path.hpp>
#include <boost/thread.hpp>

class CNetAddr;
class uint256;

static const int64_t COIN = 100000000;
static const int64_t CENT = 1000000;

#define BEGIN(a)            ((char*)&(a))
#define END(a)              ((char*)&((&(a))[1]))
#define UBEGIN(a)           ((unsigned char*)&(a))
#define UEND(a)             ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array)     (sizeof(array)/sizeof((array)[0]))

/* Format characters for (s)size_t, ptrdiff_t, uint64_t.
 *
 * As the tinyformat-based formatting system is type-safe, no special format
 * characters are really needed to specify sizes. Tinyformat can support
 * (ignores) the C99 prefixes such as "ll" but chokes on MSVC's inttypes
 * defines prefixes such as "I64X".  So don't include inttypes.h and define our
 * own for compatibility.
 * If you get a warning here about a redefine of PRI?64, make sure that
 * inttypes.h is not included.
 */
#define PRIszx    "x"
#define PRIszu    "u"
#define PRIszd    "d"
#define PRIpdx    "x"
#define PRIpdu    "u"
#define PRIpdd    "d"
#define PRIx64    "x"
#define PRIu64    "u"
#define PRId64    "d"

// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2)    std::pair<t1, t2>

// Align by increasing pointer, must have extra space at end of buffer
template <size_t nBytes, typename T>
T* alignup(T* p)
{
    union
    {
        T* ptr;
        size_t n;
    } u;
    u.ptr = p;
    u.n = (u.n + (nBytes-1)) & ~(nBytes-1);
    return u.ptr;
}

#ifdef WIN32
#define MSG_DONTWAIT        0

#ifndef S_IRUSR
#define S_IRUSR             0400<commit_msg>Remove definition of PRI?64 in util.h<commit_after>// Copyright (c) 2009-2010 <NAME>
// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_UTIL_H
#define BITCOIN_UTIL_H

#if defined(HAVE_CONFIG_H)
#include "bitcoin-config.h"
#endif

#include "compat.h"
#include "serialize.h"
#include "tinyformat.h"

#include <cstdio>
#include <exception>
#include <map>
#include <stdarg.h>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>

#ifndef WIN32
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#endif

#include <boost/filesystem/path.hpp>
#include <boost/thread.hpp>

class CNetAddr;
class uint256;

static const int64_t COIN = 100000000;
static const int64_t CENT = 1000000;

#define BEGIN(a)            ((char*)&(a))
#define END(a)              ((char*)&((&(a))[1]))
#define UBEGIN(a)           ((unsigned char*)&(a))
#define UEND(a)             ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array)     (sizeof(array)/sizeof((array)[0]))

/* Format characters for (s)size_t, ptrdiff_t.
 *
 * Define these as empty as the tinyformat-based formatting system is
 * type-safe, no special format characters are needed to specify sizes.
 */
#define PRIszx    "x"
#define PRIszu    "u"
#define PRIszd    "d"
#define PRIpdx    "x"
#define PRIpdu    "u"
#define PRIpdd    "d"

// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2)    std::pair<t1, t2>

// Align by increasing pointer, must have extra space at end of buffer
template <size_t nBytes, typename T>
T* alignup(T* p)
{
    union
    {
        T* ptr;
        size_t n;
    } u;
    u.ptr = p;
    u.n = (u.n + (nBytes-1)) & ~(nBytes-1);
    return u.ptr;
}

#ifdef WIN32
#define MSG_DONTWAIT        0

#ifndef S_IRUSR
#define S_IRUSR             0400
{'fraction_non_alphanumeric': 0.1370248709526044, 'fraction_numerical': 0.0323791647114031, 'mean_word_length': 3.52067868504772, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4374808', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1546, 'n_words': 471}