1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef THIRD_PARTY_SQLITE_SQLITE3_SHIM_FIXUPS_H_
6 #define THIRD_PARTY_SQLITE_SQLITE3_SHIM_FIXUPS_H_
8 // This file contains various fixups for the amalgamated SQLite code.
9 // It is intended to be included in sqlite3_shim.c only.
11 #if defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
12 // When SQLITE_OMIT_COMPILEOPTION_DIAGS is defined, sqlite3.h emits macros
13 // instead of declarations for sqlite3_compileoption_{get,used}().
15 // In order to avoid a macro redefinition warning, we must undo the #define in
17 #if defined(sqlite3_compileoption_get)
18 #undef sqlite3_compileoption_get
20 #error "This workaround is no longer needed."
21 #endif // !defined(sqlite3_compileoption_get)
22 #if defined(sqlite3_compileoption_used)
23 #undef sqlite3_compileoption_used
25 #error "This workaround is no longer needed."
26 #endif // !defined(sqlite3_compileoption_used)
27 #endif // defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
29 // Linux-specific configuration fixups.
30 #if defined(__linux__)
32 // features.h, included below, indirectly includes sys/mman.h. The latter header
33 // only defines mremap if _GNU_SOURCE is defined. Depending on the order of the
34 // files in the amalgamation, removing the define below may result in a build
36 #if defined(__GNUC__) && !defined(_GNU_SOURCE)
41 // SQLite wants to track malloc sizes. On OSX it uses malloc_size(), on Windows
42 // _msize(), elsewhere it handles it manually by enlarging the malloc and
43 // injecting a field. Enable malloc_usable_size() for Linux.
45 // malloc_usable_size() is not exported by the Android NDK. It is not
46 // implemented by uclibc.
47 #if !defined(__UCLIBC__) && !defined(__ANDROID__)
48 #define HAVE_MALLOC_H 1
49 #define HAVE_MALLOC_USABLE_SIZE 1
52 #endif // defined(__linux__)
54 // For unfortunately complex reasons, Chrome has release builds where
55 // DCHECK_IS_ON() (so we want SQLITE_DEBUG to be on) but NDEBUG is also defined.
56 // This causes declarations for mutex-checking functions used by SQLITE_DEBUG
57 // code (sqlite3_mutex_held, sqlite3_mutex_notheld) to be omitted, resulting in
60 // The easiest solution for now is to undefine NDEBUG when SQLITE_DEBUG is
61 // defined. The #undef only takes effect for the SQLite implementation (included
62 // below), and does not impact any dependency.
63 #if defined(SQLITE_DEBUG) && defined(NDEBUG)
65 #endif // defined(SQLITE_DEBUG) && defined(NDEBUG)
67 #endif // THIRD_PARTY_SQLITE_SQLITE3_SHIM_FIXUPS_H_