声明:本SQLite源码剖析系列为刘兴(http://deepfuture.iteye.com/)原创,未经笔者授权,任何人和机构不能转载
/*
** Many people are failing to set -DNDEBUG=1 when compiling SQLite.
** Setting NDEBUG makes the code smaller and run faster. So the following
** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1
** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out
** feature.
*/
// NDEBUG设置能使代码更小,且运行地更快
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
# define NDEBUG 1
#endif
/*
** The testcase() macro is used to aid in coverage testing. When
** doing coverage testing, the condition inside the argument to
** testcase() must be evaluated both true and false in order to
** get full branch coverage. The testcase() macro is inserted
** to help ensure adequate test coverage in places where simple
** condition/decision coverage is inadequate. For example, testcase()
** can be used to make sure boundary values are tested. For
** bitmask tests, testcase() can be used to make sure each bit
** is significant and used at least once. On switch statements
** where multiple cases go to the same block of code, testcase()
** can insure that all cases are evaluated.
**
*/
//在覆盖测试时使用testcase()宏
#ifdef SQLITE_COVERAGE_TEST
SQLITE_PRIVATE void sqlite3Coverage(int);
# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); }
#else
# define testcase(X)
#endif
/*
** The TESTONLY macro is used to enclose variable declarations or
** other bits of code that are needed to support the arguments
** within testcase() and assert() macros.
*/
// TESTONLY将变量声明或需要使用testcase()和assert()宏
//的参数的代码片断包围
#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)
# define TESTONLY(X) X
#else
# define TESTONLY(X)
#endif
/*
** Sometimes we need a small amount of code such as a variable initialization
** to setup for a later assert() statement. We do not want this code to
** appear when assert() is disabled. The following macro is therefore
** used to contain that setup code. The "VVA" acronym stands for
** "Verification, Validation, and Accreditation". In other words, the
** code within VVA_ONLY() will only run during verification processes.
*/
//在写一段代码如变量初始化时,需要设置assert()语句进行验证,
//当assert()被禁止时,我们不希望看到这些代码
// 包括VVA_ONLY()的代码仅在验证后才运行
#ifndef NDEBUG
# define VVA_ONLY(X) X
#else
# define VVA_ONLY(X)
#endif
/*
** ALWAYS和NEVER宏环绕boolean表达式,分别为true或false,
**代码中的这些表达式能被完全忽略,但他们在少数情况下被用于提高SQLITE
**异常恢复能力,使代码自修复。
** The ALWAYS and NEVER macros surround boolean expressions which
** are intended to always be true or false, respectively. Such
** expressions could be omitted from the code completely. But they
** are included in a few cases in order to enhance the resilience
** of SQLite to unexpected behavior - to make the code "self-healing"
** or "ductile" rather than being "brittle" and crashing at the first
** hint of unplanned behavior.
** ALWAYS和NEVER可被用于防御代。当做覆盖测试时,
**ALWAYS和NEVER被硬编码为true和false,
**无法访问的代码,不能算作未经测试的代码。
** In other words, ALWAYS and NEVER are added for defensive code.
**
** When doing coverage testing ALWAYS and NEVER are hard-coded to
** be true and false so that the unreachable code then specify will
** not be counted as untested code.
*/
#if defined(SQLITE_COVERAGE_TEST)
# define ALWAYS(X) (1)
# define NEVER(X) (0)
#elif !defined(NDEBUG)
# define ALWAYS(X) ((X)?1:(assert(0),0))
# define NEVER(X) ((X)?(assert(0),1):0)
#else
# define ALWAYS(X) (X)
# define NEVER(X) (X)
#endif
/*
** The macro unlikely() is a hint that surrounds a boolean
** expression that is usually false. Macro likely() surrounds
** a boolean expression that is usually true. GCC is able to
** use these hints to generate better code, sometimes.
*/
// 对于包围的boolean表达式,unlikely()为false,likely()为true
// GCC有时可使用这些暗示产生更好的代码。
#if defined(__GNUC__) && 0
# define likely(X) __builtin_expect((X),1)
# define unlikely(X) __builtin_expect((X),0)
#else
# define likely(X) !!(X)
# define unlikely(X) !!(X)
#endif
分享到:
相关推荐
文档包含sqlite源码,源码分析,以及使用教程
SQLite源码精髓,值得学习!!SQLite源码精髓,值得学习!!SQLite源码精髓,值得学习!!
开源数据库源码sqlite 开源数据库sqlite源码 开源数据库sqlite源码
sqlite源码分析文档,sqlite源码分析文档,sqlite源码分析文档,sqlite源码分析文档,sqlite源码分析文档,sqlite源码分析文档,
SQLite是一个小型的,支持嵌入式的数据库,C语言开发,架构清晰。适合研究SQLite源码使用。
sqlite源码分析数据库高级教程,包括里面所有的代码
Android 数据库 SQLite 详细文档 以及 源代码
学习sqlite时需要用到的源码,是最新的版本,希望对你有用。
sqlite源码在自己工程中的应用,可以不依赖于其他安装程序和插件,并且纯C语言具有跨平台的特性。 工程是在Qt下的,不过代码是很简单的Demo。
这是sqlite数据库的源代码,有兴趣的可以看看是怎么实现的 方便大家学习和查阅。。。。。。。。。。。。。。
QT操作sqlite数据库源码,包括添加,删除,更新操作
这是一个安装中使用sqlite的源码,用面向对象写的,可供参考
sqlite源码库,包含多个版本的vs,可编译使用
非常好的开源C学习项目,轻量级的嵌入式...SQLite是一个开源的嵌入式关系数据库,实现自包容、零配置、支持事务的SQL数据库引擎。 其特点是高度便携、使用方便、结构紧凑、高效、可靠。足够小,大致3万行C代码,250K。
Delphi SQLite实例源码,现在SQLite的用途越来越广了,的确如此,SQLite强大易用,而且存储文件体积小,特别是一些单机程序,特别适合使用SQLite作为数据库,本源码就是一个在Delphi中使用SQLite的例子,一个上报...
sqlite3.08源码及使用指南 sqlite是嵌入式SQL数据库引擎SQLite(SQLite Embeddable SQL Database Engine)的一个扩展。 SQLite是一个实现嵌入式SQL数据库引擎小型C语言库(C library),实现了独立的,可嵌入的,零...
该示例演示C#如何连接SQLite并实现增删改查操作;演示批量操作,须要使用事务处理,才能提高效率;同时加入了SQLDapper框架,代码简练,实用,可以直接放在项目中使用;操作完成后,是完全释放了数据库资源的。该压缩...
sqlite3源码,用vs2013打开项目,可以直接编译成库使用,用于访问sqlite数据库