chromium/third_party/sentencepiece/src/src/common.h

// Copyright 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.!

#ifndef COMMON_H_
#define COMMON_H_

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "absl/strings/string_view.h"

#if defined(_WIN32) && !defined(__CYGWIN__)
#define OS_WIN
#else
#define OS_UNIX
#endif

#ifdef OS_WIN
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#endif

int8;
int16;
int32;
int64;
uint8;
uint16;
char32;
uint32;
uint64;

static constexpr uint32 kUnicodeError =;

template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];

#ifndef _MSC_VER
template <typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif  // !_MSC_VER

#define arraysize(array)

#if defined(_FREEBSD)
#include <sys/endian.h>
#endif
#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_FREEBSD)
#include <endian.h>
#if BYTE_ORDER == __BIG_ENDIAN
#define IS_BIG_ENDIAN
#endif
#endif

namespace sentencepiece {

#ifdef IS_BIG_ENDIAN
namespace util {
inline uint32 Swap32(uint32 x) {
  return __builtin_bswap32(x);
}
}  // namespace util
#endif

namespace error {

void Abort();
void Exit(int code);
void SetTestCounter(int c);
void ResetTestMode();
bool GetTestCounter();

class Die {};
}  // namespace error

namespace logging {
enum LogSeverity {};

int GetMinLogLevel();
void SetMinLogLevel(int v);

inline const char* BaseName(const char* path) {}
}  // namespace logging
}  // namespace sentencepiece

#define LOG(severity)

#define CHECK(condition)

#define CHECK_STREQ(a, b)
#define CHECK_EQ(a, b)
#define CHECK_NE(a, b)
#define CHECK_GE(a, b)
#define CHECK_LE(a, b)
#define CHECK_GT(a, b)
#define CHECK_LT(a, b)

#define FRIEND_TEST(a, b)

#define CHECK_OK(expr)

#define CHECK_NOT_OK(expr)

#define RETURN_IF_ERROR(expr)

#endif  // COMMON_H_