chromium/third_party/pdfium/core/fxcrt/fx_system.h

// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FXCRT_FX_SYSTEM_H_
#define CORE_FXCRT_FX_SYSTEM_H_

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>

#include "build/build_config.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_types.h"

#if defined(_MSC_VER) && _MSC_VER < 1900
#error Sorry, VC++ 2015 or later is required to compile PDFium.
#endif  // defined(_MSC_VER) && _MSC_VER < 1900

#if defined(__wasm__) && defined(PDF_ENABLE_V8)
#error Cannot compile v8 with wasm.
#endif  // PDF_ENABLE_V8

#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif  // BUILDFLAG(IS_WIN)

#ifdef __cplusplus
extern "C" {
#endif  // __cplusplus

#define FXSYS_IsFloatZero(f)
#define FXSYS_IsFloatBigger(fa, fb)
#define FXSYS_IsFloatSmaller(fa, fb)
#define FXSYS_IsFloatEqual(fa, fb)

// M_PI not universally present on all platforms.
#define FXSYS_PI
#define FXSYS_BEZIER

// NOTE: prevent use of the return value from snprintf() since some platforms
// have different return values.
#define FXSYS_snprintf
#define FXSYS_vsnprintf
#define FXSYS_sprintf
#define FXSYS_vsprintf

#if BUILDFLAG(IS_WIN)
#define FXSYS_itoa
#define FXSYS_strlwr
#define FXSYS_strupr
#define FXSYS_wcslwr
#define FXSYS_wcsupr
#define FXSYS_SetLastError
#define FXSYS_GetLastError
UNSAFE_BUFFER_USAGE size_t FXSYS_wcsftime(wchar_t* strDest,
                                          size_t maxsize,
                                          const wchar_t* format,
                                          const struct tm* timeptr);
#else  // BUILDFLAG(IS_WIN)
char* FXSYS_itoa(int value, char* str, int radix);
char* FXSYS_strlwr(char* str);
char* FXSYS_strupr(char* str);
wchar_t* FXSYS_wcslwr(wchar_t* str);
wchar_t* FXSYS_wcsupr(wchar_t* str);
void FXSYS_SetLastError(uint32_t err);
uint32_t FXSYS_GetLastError();
#define FXSYS_wcsftime
#endif  // BUILDFLAG(IS_WIN)

const char* FXSYS_i64toa(int64_t value, char* str, int radix);
int FXSYS_roundf(float f);
int FXSYS_round(double d);
float FXSYS_sqrt2(float a, float b);

#ifdef __cplusplus
}  // extern "C"

// C++-only section to allow future use of TerminatedPtr<>.
int FXSYS_stricmp(const char* str1, const char* str2);
int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2);
int32_t FXSYS_atoi(const char* str);
int32_t FXSYS_wtoi(const wchar_t* str);
uint32_t FXSYS_atoui(const char* str);
int64_t FXSYS_atoi64(const char* str);

#endif  // __cplusplus

#endif  // CORE_FXCRT_FX_SYSTEM_H_