<commit_before>//---------------------------------------------------------------------------------------------------------------------------------
// File: xplat.h
//
// Contents: include for definition of Windows types for non-Windows platforms
//
// Microsoft Drivers 4.0 for PHP for SQL Server
// Copyright(c) Microsoft Corporation
// All rights reserved.
// MIT License
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), 
//  to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//  and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
//  IN THE SOFTWARE.
//---------------------------------------------------------------------------------------------------------------------------------

#ifndef __XPLAT_H__
#define __XPLAT_H__

#ifndef _WCHART_DEFINED
#define _WCHART_DEFINED 
#endif

#include <iostream>
#include <string>
#include <errno.h>
#include <sql.h>
#include <sqlext.h>
#include <stdarg.h>
#include <cstdlib>
#include <cstdio>
#include <assert.h>
#include <string.h>

#if defined(_MSC_VER)
// Turned on all warnings in WwoWH projects
// These warnings need to be disabled to be build warning free
// Note that some of these should be enabled and the code fixed
#pragma warning( disable : 4668 ) // preprocessor macro not defined
#pragma warning( disable : 4820 ) // padding after data member
#pragma warning( disable : 4201 ) // nonstandard: nameless union
#pragma warning( disable : 4100 ) // unreferenced formal parameter
#pragma warning( disable : 4514 ) // unreferenced inline function
#pragma warning( disable : 4505 ) // unreferenced inline function
#pragma warning( disable : 4710 ) // function not inlined
#pragma warning( disable : 4191 ) // unsafe conversion
#pragma warning( disable : 4365 ) // signed/unsigned argument conversion
#pragma warning( disable : 4245 ) // signed/unsigned assignment conversion
#pragma warning( disable : 4389 ) // signed/unsigned ==
#pragma warning( disable : 4987 ) // nonstandard: throw(...)
#pragma warning( disable : 4510 ) // default ctor could not be generated
#pragma warning( disable : 4512 ) // operator= could not be generated
#pragma warning( disable : 4626 ) // operator= could not be generated
#pragma warning( disable : 4625 ) // copy ctor could not be generated or accessed
#pragma warning( disable : 4189 ) // unused initialized local variable
#pragma warning( disable : 4127 ) // constant conditional test
#pragma warning( disable : 4061 ) // Unused enum values in switch
#pragma warning( disable : 4062 ) // Unused enum values in switch
#pragma warning( disable : 4706 ) // assignment within conditional
#pragma warning( disable : 4610 ) // can never be instantiated
#pragma warning( disable : 4244 ) // possible loss of data in conversion
#pragma warning( disable : 4701 ) // possible use of uninitialized variable
#pragma warning( disable : 4918 ) // invalid pragma optimization parameter
#pragma warning( disable : 4702 ) // unreachable code
#pragma warning( disable : 4265 ) // class with virtual fxns has non-virtual dtor
#pragma warning( disable : 4238 ) // nonstandard: class rvalue used as lvalue
#pragma warning( disable : 4310 ) // cast truncates constant value
#pragma warning( disable : 4946 ) // reinterpret_cast between related classes
#pragma warning( disable : 4264 ) // no matching override, hides base fxn
#pragma warning( disable : 4242 ) // conversion: possible loss of data
#pragma warning( disable : 4820 ) // added padding bytes
#endif

// Compiler specific items
#define _cdecl
#define __cdecl
#define __fastcall
#define _inline inline
#define __inline inline
#define __forceinline inline
#define __stdcall

#if !defined(_MSC_VER)
#define __declspec__noinline __attribute__((noinline))
#define __declspec__selectany
#define __declspec(a) __declspec__##a
#define __FUNCTION__ __func__

#define __int8 char
#define __int32 int

// __int64
// This type must be defined in a way that allows "unsigned __int64" as a valid type declaration.
// That precludes using the obvious "int64_t" from stdint.h, because "unsigned int64_t" is not allowed
// (one should use "uint64_t" for unsigned 64-bit integers). As a result, we must use compiler-specific
// types such as GCC's "long long" instead
#if defined(_LP64)
#define __int64 long
#elif defined(__GNUC__)
#define __int64 long long
#else
#error "Compiler-specific definition required for __int64 in 32-bit builds"
#endif
#endif

// GCC-specific definitions
#if defined(__GNUC__)
#define MPLAT_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif // defined(__GNUC__)

// For compilers that don't support cross-module inlining (part of whole-program/link-time
// optimization), such as the current MPLAT compilers (GCC 4.1.2 for RHEL5 and GCC 4.4 for RHEL6),
// we must force the generation of out-of-line definitions for functions that otherwise
// are only defined inline when those functions are called from other translation units.
// There are a handful of instances of these in SNI code as well as ODBC code.
//
// To force the compiler to emit an out-of-line definition for a function, just add an otherwise
// unused global (external linkage) non-const pointer pointing to the function:
//
// #if defined(MPLAT_NO_LTO)
// void (* g_pfnMyFunctionUnused)(MyFunctionArguments *) = MyFunction;
// #endif // defined(MPLAT_NO_LTO)
//
// This works because, absent whole-program optimization, the compiler cannot determine that the
// pointers are never called through, and the out-of-line definition cannot be optimized out,
// giving calling translation units something to link to.
//
// GCC adds LTO as of version 4.5
//JL - TODO: this version check doesn't work in Ubuntu
//#if defined(__GNUC__) && MPLAT_GCC_VERSION < 40500
#define MPLAT_NO_LTO
//#endif

#ifdef MPLAT_UNIX

// Needed to use the standard library min and max
#include <algorithm>
using std::min;
using std::max;

#elif MPLAT_WWOWH

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

#endif // MPLAT_WWOWH

// Deal with differences between Windows and *nix interpretations of the C/C++ 'long' data type.
//
// On 64-bit Windows, 'long' is 32 bits. On 64-bit Linux, 'long' is 64 bits. Assuming the Windows code
// depends on it being 32 bits, use a definition that provides a guaranteed 32-bit type definition.
//
// Similarly, because 'long long' (and its cousin 'unsigned long long') are not portable across
// Linux/UNIX platforms and compilers, provide common definitions for 64-bit types as well.
//
// These types are used in this file primarily to define common Windows types (DWORD, LONG, etc.)
// Cross-platform code should use either the Windows types or appropriate types from <stdint.h>.
#if defined(_MSC_VER) // WwoWH
typedef long windowsLong_t;
typedef unsigned long windowsULong_t;
typedef __int64 windowsLongLong_t;
typedef unsigned __int64 windowsULongLong_t;
#else // *nix (!WwoWH)
#include <stdint.h> // Use standard bit-specific types (signed/unsigned integrated)
typedef int32_t windowsLong_t;
typedef uint32_t windowsULong_t;
typedef int64_t windowsLongLong_t;
typedef uint64_t windowsULongLong_t;
#endif
typedef windowsLong_t LONG, *PLONG, *LPLONG;
typedef windowsLongLong_t LONGLONG;
typedef windowsULongLong_t ULONGLONG;

#include <assert.h>
#include <stdlib.h>
#include <intsafe.h><commit_msg>renamed <intsafe> in xplat.h to xplat_intsafe<commit_after>//---------------------------------------------------------------------------------------------------------------------------------
// File: xplat.h
//
// Contents: include for definition of Windows types for non-Windows platforms
//
// Microsoft Drivers 4.0 for PHP for SQL Server
// Copyright(c) Microsoft Corporation
// All rights reserved.
// MIT License
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the ""Software""), 
//  to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//  and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
//  IN THE SOFTWARE.
//---------------------------------------------------------------------------------------------------------------------------------

#ifndef __XPLAT_H__
#define __XPLAT_H__

#ifndef _WCHART_DEFINED
#define _WCHART_DEFINED 
#endif

#include <iostream>
#include <string>
#include <errno.h>
#include <sql.h>
#include <sqlext.h>
#include <stdarg.h>
#include <cstdlib>
#include <cstdio>
#include <assert.h>
#include <string.h>

#if defined(_MSC_VER)
// Turned on all warnings in WwoWH projects
// These warnings need to be disabled to be build warning free
// Note that some of these should be enabled and the code fixed
#pragma warning( disable : 4668 ) // preprocessor macro not defined
#pragma warning( disable : 4820 ) // padding after data member
#pragma warning( disable : 4201 ) // nonstandard: nameless union
#pragma warning( disable : 4100 ) // unreferenced formal parameter
#pragma warning( disable : 4514 ) // unreferenced inline function
#pragma warning( disable : 4505 ) // unreferenced inline function
#pragma warning( disable : 4710 ) // function not inlined
#pragma warning( disable : 4191 ) // unsafe conversion
#pragma warning( disable : 4365 ) // signed/unsigned argument conversion
#pragma warning( disable : 4245 ) // signed/unsigned assignment conversion
#pragma warning( disable : 4389 ) // signed/unsigned ==
#pragma warning( disable : 4987 ) // nonstandard: throw(...)
#pragma warning( disable : 4510 ) // default ctor could not be generated
#pragma warning( disable : 4512 ) // operator= could not be generated
#pragma warning( disable : 4626 ) // operator= could not be generated
#pragma warning( disable : 4625 ) // copy ctor could not be generated or accessed
#pragma warning( disable : 4189 ) // unused initialized local variable
#pragma warning( disable : 4127 ) // constant conditional test
#pragma warning( disable : 4061 ) // Unused enum values in switch
#pragma warning( disable : 4062 ) // Unused enum values in switch
#pragma warning( disable : 4706 ) // assignment within conditional
#pragma warning( disable : 4610 ) // can never be instantiated
#pragma warning( disable : 4244 ) // possible loss of data in conversion
#pragma warning( disable : 4701 ) // possible use of uninitialized variable
#pragma warning( disable : 4918 ) // invalid pragma optimization parameter
#pragma warning( disable : 4702 ) // unreachable code
#pragma warning( disable : 4265 ) // class with virtual fxns has non-virtual dtor
#pragma warning( disable : 4238 ) // nonstandard: class rvalue used as lvalue
#pragma warning( disable : 4310 ) // cast truncates constant value
#pragma warning( disable : 4946 ) // reinterpret_cast between related classes
#pragma warning( disable : 4264 ) // no matching override, hides base fxn
#pragma warning( disable : 4242 ) // conversion: possible loss of data
#pragma warning( disable : 4820 ) // added padding bytes
#endif

// Compiler specific items
#define _cdecl
#define __cdecl
#define __fastcall
#define _inline inline
#define __inline inline
#define __forceinline inline
#define __stdcall

#if !defined(_MSC_VER)
#define __declspec__noinline __attribute__((noinline))
#define __declspec__selectany
#define __declspec(a) __declspec__##a
#define __FUNCTION__ __func__

#define __int8 char
#define __int32 int

// __int64
// This type must be defined in a way that allows "unsigned __int64" as a valid type declaration.
// That precludes using the obvious "int64_t" from stdint.h, because "unsigned int64_t" is not allowed
// (one should use "uint64_t" for unsigned 64-bit integers). As a result, we must use compiler-specific
// types such as GCC's "long long" instead
#if defined(_LP64)
#define __int64 long
#elif defined(__GNUC__)
#define __int64 long long
#else
#error "Compiler-specific definition required for __int64 in 32-bit builds"
#endif
#endif

// GCC-specific definitions
#if defined(__GNUC__)
#define MPLAT_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif // defined(__GNUC__)

// For compilers that don't support cross-module inlining (part of whole-program/link-time
// optimization), such as the current MPLAT compilers (GCC 4.1.2 for RHEL5 and GCC 4.4 for RHEL6),
// we must force the generation of out-of-line definitions for functions that otherwise
// are only defined inline when those functions are called from other translation units.
// There are a handful of instances of these in SNI code as well as ODBC code.
//
// To force the compiler to emit an out-of-line definition for a function, just add an otherwise
// unused global (external linkage) non-const pointer pointing to the function:
//
// #if defined(MPLAT_NO_LTO)
// void (* g_pfnMyFunctionUnused)(MyFunctionArguments *) = MyFunction;
// #endif // defined(MPLAT_NO_LTO)
//
// This works because, absent whole-program optimization, the compiler cannot determine that the
// pointers are never called through, and the out-of-line definition cannot be optimized out,
// giving calling translation units something to link to.
//
// GCC adds LTO as of version 4.5
//JL - TODO: this version check doesn't work in Ubuntu
//#if defined(__GNUC__) && MPLAT_GCC_VERSION < 40500
#define MPLAT_NO_LTO
//#endif

#ifdef MPLAT_UNIX

// Needed to use the standard library min and max
#include <algorithm>
using std::min;
using std::max;

#elif MPLAT_WWOWH

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

#endif // MPLAT_WWOWH

// Deal with differences between Windows and *nix interpretations of the C/C++ 'long' data type.
//
// On 64-bit Windows, 'long' is 32 bits. On 64-bit Linux, 'long' is 64 bits. Assuming the Windows code
// depends on it being 32 bits, use a definition that provides a guaranteed 32-bit type definition.
//
// Similarly, because 'long long' (and its cousin 'unsigned long long') are not portable across
// Linux/UNIX platforms and compilers, provide common definitions for 64-bit types as well.
//
// These types are used in this file primarily to define common Windows types (DWORD, LONG, etc.)
// Cross-platform code should use either the Windows types or appropriate types from <stdint.h>.
#if defined(_MSC_VER) // WwoWH
typedef long windowsLong_t;
typedef unsigned long windowsULong_t;
typedef __int64 windowsLongLong_t;
typedef unsigned __int64 windowsULongLong_t;
#else // *nix (!WwoWH)
#include <stdint.h> // Use standard bit-specific types (signed/unsigned integrated)
typedef int32_t windowsLong_t;
typedef uint32_t windowsULong_t;
typedef int64_t windowsLongLong_t;
typedef uint64_t windowsULongLong_t;
#endif
typedef windowsLong_t LONG, *PLONG, *LPLONG;
typedef windowsLongLong_t LONGLONG;
typedef windowsULongLong_t ULONGLONG;

#include <assert.h>
#include <stdlib.h>
#include "xplat_intsafe.h"
{'fraction_non_alphanumeric': 0.11784327996118389, 'fraction_numerical': 0.025109170305676855, 'mean_word_length': 3.680386034629577, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4401461', 'n_tokens_mistral': 4902, 'n_tokens_neox': 4431, 'n_words': 2014}