sysdefs.h (207842) | sysdefs.h (213700) |
---|---|
1/////////////////////////////////////////////////////////////////////////////// 2// 3/// \file sysdefs.h 4/// \brief Common includes, definitions, system-specific things etc. 5/// 6/// This file is used also by the lzma command line tool, that's why this 7/// file is separate from common.h. 8// --- 88 unchanged lines hidden (view full) --- 97 98// The code currently assumes that size_t is either 32-bit or 64-bit. 99#ifndef SIZE_MAX 100# if SIZEOF_SIZE_T == 4 101# define SIZE_MAX UINT32_MAX 102# elif SIZEOF_SIZE_T == 8 103# define SIZE_MAX UINT64_MAX 104# else | 1/////////////////////////////////////////////////////////////////////////////// 2// 3/// \file sysdefs.h 4/// \brief Common includes, definitions, system-specific things etc. 5/// 6/// This file is used also by the lzma command line tool, that's why this 7/// file is separate from common.h. 8// --- 88 unchanged lines hidden (view full) --- 97 98// The code currently assumes that size_t is either 32-bit or 64-bit. 99#ifndef SIZE_MAX 100# if SIZEOF_SIZE_T == 4 101# define SIZE_MAX UINT32_MAX 102# elif SIZEOF_SIZE_T == 8 103# define SIZE_MAX UINT64_MAX 104# else |
105# error sizeof(size_t) is not 32-bit or 64-bit | 105# error size_t is not 32-bit or 64-bit |
106# endif 107#endif 108#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX | 106# endif 107#endif 108#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX |
109# error sizeof(size_t) is not 32-bit or 64-bit | 109# error size_t is not 32-bit or 64-bit |
110#endif 111 112#include <stdlib.h> 113#include <assert.h> 114 115// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written 116// so that it works with fake bool type, for example: 117// --- 33 unchanged lines hidden (view full) --- 151 152//////////// 153// Macros // 154//////////// 155 156#undef memzero 157#define memzero(s, n) memset(s, 0, n) 158 | 110#endif 111 112#include <stdlib.h> 113#include <assert.h> 114 115// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written 116// so that it works with fake bool type, for example: 117// --- 33 unchanged lines hidden (view full) --- 151 152//////////// 153// Macros // 154//////////// 155 156#undef memzero 157#define memzero(s, n) memset(s, 0, n) 158 |
159#ifndef MIN 160# define MIN(x, y) ((x) < (y) ? (x) : (y)) 161#endif | 159// NOTE: Avoid using MIN() and MAX(), because even conditionally defining 160// those macros can cause some portability trouble, since on some systems 161// the system headers insist defining their own versions. 162#define my_min(x, y) ((x) < (y) ? (x) : (y)) 163#define my_max(x, y) ((x) > (y) ? (x) : (y)) |
162 | 164 |
163#ifndef MAX 164# define MAX(x, y) ((x) > (y) ? (x) : (y)) 165#endif 166 | |
167#ifndef ARRAY_SIZE 168# define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) 169#endif 170 171#endif | 165#ifndef ARRAY_SIZE 166# define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) 167#endif 168 169#endif |