chromium/third_party/lzma_sdk/C/7zTypes.h

/* 7zTypes.h -- Basic types
2022-04-01 : Igor Pavlov : Public domain */

#ifndef __7Z_TYPES_H
#define __7Z_TYPES_H

#ifdef _WIN32
/* #include <windows.h> */
#else
#include <errno.h>
#endif

#include <stddef.h>

#ifndef EXTERN_C_BEGIN
#ifdef __cplusplus
#define EXTERN_C_BEGIN
#define EXTERN_C_END
#else
#define EXTERN_C_BEGIN
#define EXTERN_C_END
#endif
#endif

EXTERN_C_BEGIN

#define SZ_OK

#define SZ_ERROR_DATA
#define SZ_ERROR_MEM
#define SZ_ERROR_CRC
#define SZ_ERROR_UNSUPPORTED
#define SZ_ERROR_PARAM
#define SZ_ERROR_INPUT_EOF
#define SZ_ERROR_OUTPUT_EOF
#define SZ_ERROR_READ
#define SZ_ERROR_WRITE
#define SZ_ERROR_PROGRESS
#define SZ_ERROR_FAIL
#define SZ_ERROR_THREAD

#define SZ_ERROR_ARCHIVE
#define SZ_ERROR_NO_ARCHIVE

SRes;


#ifdef _MSC_VER
  #if _MSC_VER > 1200
    #define MY_ALIGN
  #else
    #define MY_ALIGN
  #endif
#else
  #define MY_ALIGN(n)
#endif


#ifdef _WIN32

/* typedef DWORD WRes; */
typedef unsigned WRes;
#define MY_SRes_HRESULT_FROM_WRes

// #define MY_HRES_ERROR__INTERNAL_ERROR  MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR)

#else // _WIN32

// #define ENV_HAVE_LSTAT
WRes;

// (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT
#define MY__FACILITY_ERRNO
#define MY__FACILITY_WIN32
#define MY__FACILITY__WRes

#define MY_HRESULT_FROM_errno_CONST_ERROR(x)

#define MY_SRes_HRESULT_FROM_WRes(x)

// we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno)
#define HRESULT_FROM_WIN32(x)

/*
#define ERROR_FILE_NOT_FOUND             2L
#define ERROR_ACCESS_DENIED              5L
#define ERROR_NO_MORE_FILES              18L
#define ERROR_LOCK_VIOLATION             33L
#define ERROR_FILE_EXISTS                80L
#define ERROR_DISK_FULL                  112L
#define ERROR_NEGATIVE_SEEK              131L
#define ERROR_ALREADY_EXISTS             183L
#define ERROR_DIRECTORY                  267L
#define ERROR_TOO_MANY_POSTS             298L

#define ERROR_INTERNAL_ERROR             1359L
#define ERROR_INVALID_REPARSE_DATA       4392L
#define ERROR_REPARSE_TAG_INVALID        4393L
#define ERROR_REPARSE_TAG_MISMATCH       4394L
*/

// we use errno equivalents for some WIN32 errors:

#define ERROR_INVALID_PARAMETER
#define ERROR_INVALID_FUNCTION
#define ERROR_ALREADY_EXISTS
#define ERROR_FILE_EXISTS
#define ERROR_PATH_NOT_FOUND
#define ERROR_FILE_NOT_FOUND
#define ERROR_DISK_FULL
// #define ERROR_INVALID_HANDLE        EBADF

// we use FACILITY_WIN32 for errors that has no errno equivalent
// Too many posts were made to a semaphore.
#define ERROR_TOO_MANY_POSTS
#define ERROR_INVALID_REPARSE_DATA
#define ERROR_REPARSE_TAG_INVALID

// if (MY__FACILITY__WRes != FACILITY_WIN32),
// we use FACILITY_WIN32 for COM errors:
#define E_OUTOFMEMORY
#define E_INVALIDARG
#define MY__E_ERROR_NEGATIVE_SEEK

/*
// we can use FACILITY_ERRNO for some COM errors, that have errno equivalents:
#define E_OUTOFMEMORY             MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM)
#define E_INVALIDARG              MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL)
#define MY__E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL)
*/

#define TEXT(quote)

#define FILE_ATTRIBUTE_READONLY
#define FILE_ATTRIBUTE_HIDDEN
#define FILE_ATTRIBUTE_SYSTEM
#define FILE_ATTRIBUTE_DIRECTORY
#define FILE_ATTRIBUTE_ARCHIVE
#define FILE_ATTRIBUTE_DEVICE
#define FILE_ATTRIBUTE_NORMAL
#define FILE_ATTRIBUTE_TEMPORARY
#define FILE_ATTRIBUTE_SPARSE_FILE
#define FILE_ATTRIBUTE_REPARSE_POINT
#define FILE_ATTRIBUTE_COMPRESSED
#define FILE_ATTRIBUTE_OFFLINE
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
#define FILE_ATTRIBUTE_ENCRYPTED

#define FILE_ATTRIBUTE_UNIX_EXTENSION

#endif


#ifndef RINOK
#define RINOK(x)
#endif

#ifndef RINOK_WRes
#define RINOK_WRes(x)
#endif

Byte;
Int16;
UInt16;

#ifdef _LZMA_UINT32_IS_ULONG
typedef long Int32;
typedef unsigned long UInt32;
#else
Int32;
UInt32;
#endif


#ifndef _WIN32

INT;
INT32;
UINT;
UINT32;
LONG;   // LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility
ULONG;

#undef DWORD
DWORD;

#define VOID

#define HRESULT

LPVOID;
// typedef void VOID;
// typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
// gcc / clang on Unix  : sizeof(long==sizeof(void*) in 32 or 64 bits)
INT_PTR;
UINT_PTR;
LONG_PTR;
DWORD_PTR;

SIZE_T;

#endif //  _WIN32


#define MY_HRES_ERROR__INTERNAL_ERROR


#ifdef _SZ_NO_INT_64

/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
   NOTES: Some code will work incorrectly in that case! */

typedef long Int64;
typedef unsigned long UInt64;

#else

#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#define UINT64_CONST
#else
Int64;
UInt64;
#define UINT64_CONST(n)
#endif

#endif

#ifdef _LZMA_NO_SYSTEM_SIZE_T
typedef UInt32 SizeT;
#else
SizeT;
#endif

BoolInt;
/* typedef BoolInt Bool; */
#define True
#define False


#ifdef _WIN32
#define MY_STD_CALL
#else
#define MY_STD_CALL
#endif

#ifdef _MSC_VER

#if _MSC_VER >= 1300
#define MY_NO_INLINE
#else
#define MY_NO_INLINE
#endif

#define MY_FORCE_INLINE

#define MY_CDECL
#define MY_FAST_CALL

#else //  _MSC_VER

#if (defined(__GNUC__) && (__GNUC__ >= 4)) \
    || (defined(__clang__) && (__clang_major__ >= 4)) \
    || defined(__INTEL_COMPILER) \
    || defined(__xlC__)
#define MY_NO_INLINE
// #define MY_FORCE_INLINE __attribute__((always_inline)) inline
#else
#define MY_NO_INLINE
#endif

#define MY_FORCE_INLINE


#define MY_CDECL

#if  defined(_M_IX86) \
  || defined(__i386__)
// #define MY_FAST_CALL __attribute__((fastcall))
// #define MY_FAST_CALL __attribute__((cdecl))
#define MY_FAST_CALL
#elif defined(MY_CPU_AMD64)
// #define MY_FAST_CALL __attribute__((ms_abi))
#define MY_FAST_CALL
#else
#define MY_FAST_CALL
#endif

#endif //  _MSC_VER


/* The following interfaces use first parameter as pointer to structure */

IByteIn;
struct IByteIn
{};
#define IByteIn_Read(p)


IByteOut;
struct IByteOut
{};
#define IByteOut_Write(p, b)


ISeqInStream;
struct ISeqInStream
{};
#define ISeqInStream_Read(p, buf, size)

/* it can return SZ_ERROR_INPUT_EOF */
SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size);
SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType);
SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf);


ISeqOutStream;
struct ISeqOutStream
{};
#define ISeqOutStream_Write(p, buf, size)

ESzSeek;


ISeekInStream;
struct ISeekInStream
{};
#define ISeekInStream_Read(p, buf, size)
#define ISeekInStream_Seek(p, pos, origin)


ILookInStream;
struct ILookInStream
{};

#define ILookInStream_Look(p, buf, size)
#define ILookInStream_Skip(p, offset)
#define ILookInStream_Read(p, buf, size)
#define ILookInStream_Seek(p, pos, origin)


SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size);
SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset);

/* reads via ILookInStream::Read */
SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType);
SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size);



CLookToRead2;

void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);

#define LookToRead2_Init(p)


CSecToLook;

void SecToLook_CreateVTable(CSecToLook *p);



CSecToRead;

void SecToRead_CreateVTable(CSecToRead *p);


ICompressProgress;

struct ICompressProgress
{};
#define ICompressProgress_Progress(p, inSize, outSize)



ISzAlloc;
ISzAllocPtr;

struct ISzAlloc
{};

#define ISzAlloc_Alloc(p, size)
#define ISzAlloc_Free(p, a)

/* deprecated */
#define IAlloc_Alloc(p, size)
#define IAlloc_Free(p, a)





#ifndef MY_offsetof
  #ifdef offsetof
    #define MY_offsetof(type, m)
    /*
    #define MY_offsetof(type, m) FIELD_OFFSET(type, m)
    */
  #else
    #define MY_offsetof
  #endif
#endif



#ifndef MY_container_of

/*
#define MY_container_of(ptr, type, m) container_of(ptr, type, m)
#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)
#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))
#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))
*/

/*
  GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"
    GCC 3.4.4 : classes with constructor
    GCC 4.8.1 : classes with non-public variable members"
*/

#define MY_container_of(ptr, type, m)

#endif

#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)

/*
#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
*/
#define CONTAINER_FROM_VTBL(ptr, type, m)

#define CONTAINER_FROM_VTBL_CLS(ptr, type, m)
/*
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)
*/


#define MY_memset_0_ARRAY(a)

#ifdef _WIN32

#define CHAR_PATH_SEPARATOR
#define WCHAR_PATH_SEPARATOR
#define STRING_PATH_SEPARATOR
#define WSTRING_PATH_SEPARATOR

#else

#define CHAR_PATH_SEPARATOR
#define WCHAR_PATH_SEPARATOR
#define STRING_PATH_SEPARATOR
#define WSTRING_PATH_SEPARATOR

#endif

#define k_PropVar_TimePrec_0
#define k_PropVar_TimePrec_Unix
#define k_PropVar_TimePrec_DOS
#define k_PropVar_TimePrec_HighPrec
#define k_PropVar_TimePrec_Base
#define k_PropVar_TimePrec_100ns
#define k_PropVar_TimePrec_1ns

EXTERN_C_END

#endif