VirtualBox

source: vbox/trunk/src/libs/liblzma-5.4.1/vbox/sysdefs.h@ 98737

Last change on this file since 98737 was 98737, checked in by vboxsync, 2 years ago

lobs/liblzma-5.4.1: Windows build fixes, bugref:10254

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: sysdefs.h 98737 2023-02-25 20:51:38Z vboxsync $ */
2/** @file
3 * sysdefs.h - System definitions using IPRT.
4 */
5
6/*
7 * Copyright (C) 2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef LZMA_SYSDEFS_H
29#define LZMA_SYSDEFS_H
30
31//////////////
32// Includes //
33//////////////
34
35#include <iprt/nocrt/limits.h>
36
37#include <iprt/cdefs.h>
38#include <iprt/stdint.h>
39#include <iprt/assert.h>
40#include <iprt/mem.h>
41#include <iprt/mp.h>
42#include <iprt/system.h>
43
44#define TUKLIB_DECLS_BEGIN RT_C_DECLS_BEGIN
45#define TUKLIB_DECLS_END RT_C_DECLS_END
46
47// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by
48// the tuklib modules. If you use a tuklib module in a library,
49// you should use TUKLIB_SYMBOL_PREFIX to make sure that there
50// are no symbol conflicts in case someone links your library
51// into application that also uses the same tuklib module.
52#ifndef TUKLIB_SYMBOL_PREFIX
53# define TUKLIB_SYMBOL_PREFIX
54#endif
55
56#ifndef TUKLIB_SYMBOL
57# define TUKLIB_SYMBOL(a_Sym) RT_CONCAT(TUKLIB_SYMBOL_PREFIX, a_Sym)
58#endif
59
60#define TUKLIB_GNUC_REQ(major, minor) RT_GNUC_PREREQ(major, minor)
61#define assert(expr) Assert(expr)
62
63#if 0
64// The code currently assumes that size_t is either 32-bit or 64-bit.
65#ifndef SIZE_MAX
66# if SIZEOF_SIZE_T == 4
67# define SIZE_MAX UINT32_MAX
68# elif SIZEOF_SIZE_T == 8
69# define SIZE_MAX UINT64_MAX
70# else
71# error size_t is not 32-bit or 64-bit
72# endif
73#endif
74#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX
75# error size_t is not 32-bit or 64-bit
76#endif
77
78#include <stdlib.h>
79#include <assert.h>
80
81// Pre-C99 systems lack stdbool.h. All the code in XZ Utils must be written
82// so that it works with fake bool type, for example:
83//
84// bool foo = (flags & 0x100) != 0;
85// bool bar = !!(flags & 0x100);
86//
87// This works with the real C99 bool but breaks with fake bool:
88//
89// bool baz = (flags & 0x100);
90//
91#ifdef HAVE_STDBOOL_H
92# include <stdbool.h>
93#else
94# if ! HAVE__BOOL
95typedef unsigned char _Bool;
96# endif
97# define bool _Bool
98# define false 0
99# define true 1
100# define __bool_true_false_are_defined 1
101#endif
102
103#include <string.h>
104
105// As of MSVC 2013, inline and restrict are supported with
106// non-standard keywords.
107#if defined(_WIN32) && defined(_MSC_VER)
108# ifndef inline
109# define inline __inline
110# endif
111# ifndef restrict
112# define restrict __restrict
113# endif
114#endif
115
116#endif
117
118////////////
119// Macros //
120////////////
121
122#undef memzero
123#define memzero(s, n) memset(s, 0, n)
124#define my_min(x, y) RT_MIN(x, y)
125#define my_max(x, y) RT_MAX(x, y)
126
127#ifndef ARRAY_SIZE
128# define ARRAY_SIZE(array) RT_ELEMENTS(array)
129#endif
130
131#if defined(__GNUC__) \
132 && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4)
133# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x)))
134#else
135# define lzma_attr_alloc_size(x)
136#endif
137
138#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette