apacheapr:Apache APR可移植运行库介绍(1)

工作通常被局限于内部修改或者是API内部或者是APR内部变化任何对API增加、修改、删除都是不允许
1.2.2.1次版本号策略
任何新新变量以及新常量引入以及任何现有废除都将可能导致次版本号变化:
1)、新引入
An application coded against an older minor release will still have all of its functions available with their original signatures. _disibledevent=>It is tempting to say that roducing functions might create incompatibility across minor releases. If an application takes advantage of an API that was roduced in version 2.3 of a library, then it is not going to work against version 2.2. However, we have stated that an any application built against version 2.2 will continue to work for all 2.x releases. Thus, an application that states "requires 2.3 or later" is perfectly acceptable -- the user or administrator simply upgrades the ed library to 2.3. This is a safe operation and will not any other application that was using the 2.2 library.
In other words, yes an incompatibility arises by mandating that a specic version needs to be ed. But in practice, this will not be a problem since upgrading to er versions is always safe.
2)、新常量引入
Similar to functions, all of the original (old) constants will be available to an application. An application can then choose to use constants to pick up semantics and features.
3)、替换
This gets a bit trickier. The original functionmustre available at the link-level so that an application compiled against a minor version will continue to work with later minor versions. Further, an application isdesignedto work with an earlier minor version, then we don't want to suddenly change the requirements for that application. This means that the headers cannot silently map an old function o a er function, as that would turn an application, say, based _disibledevent=>This means that functions cannot truly be replaced. The , alternate function can be made available in the header and applications can choose to use it (and become dependent upon the minor release where the function appears).
It is possible to design a of headers where a macro will always refer to the "latest" function available. Of course, an application chooses to use this macro, then the resulting compiled-binary will be dependent upon whatever version it was compiled against. This strategy adds the functionality for applications, yet retains the necessary source and binary compatibility for applications designed or built against previous minor releases.
Constants (enumerated values and preprocessor macros) arenotallowed to change since an older application will still be using them. Similarly, function signatures at the link-level may not change, so that support for older, compiled applications is tained.
4)、作废
随着APR升级APR中些API可能将作废不再使用但是这些API并不能从APR库中移除旦API被移除向后兼容性将被破坏因此我们能够做仅仅是宣布其作废
If you deprecate a function in APR, please mark it as such in the function documentation, using the doxygen "\deprecated" tag. Deprecated functions can _disibledevent=>A deprecated function should re availablethroughthe original header. The function prototype should re in the same header, or moved to a "deprecated functions" header, then the alternate header should be d by the original header. This requirement is to ensure that source compatibility is retained.
 
Finally, you are deprecating a function so that you can change the name of the function, please use the method described above under "Replacing functions", so that projects which use APR can retain binary compatibility.
Note that all deprecated functions will be removed at the next major version bump.
1.2.2.3主版本号策略
下面任何种变化都将可能导致主版本号变化:
1)、常量移除或者更改
2)、移除或者作为
3)、fold together macro-ized function replacements
1.2.3版本检查
由于APR严格版本控制策略使得应用在使用APR库的前必须能够检测使用APR库版本号APR允许在编译以及使用APR时候检测它版本号
1.2.3.1 编译时版本检查
Libraries should make their version number available as compile-time constants. For example:
# FOO_MAJOR_VERSION 1
# FOO_MINOR_VERSION 4
# FOO_PATCH_VERSION 0
The above symbols are the minimum required for this specication.
An application that desires, at compile-time, to decide _disibledevent=>If the feature changes across minor versions are source compatible, but are (say) simply dferent choices of values to pass o the library, then an application can support a wider variety of ed libraries it avoids compile-time checks.
1.2.3.2 执行时版本检查
A library meeting this specication should support a way for an application to determine the library's version atrun-time. This will usually be emboded as a simple function which s the MAJOR, MINOR, and PATCH triplet in some form.
Run-time checks are preferable in all s. This type of check enables an application to run against a wider variety of minor releases of a library (the application is "less coupled" to a particular library release). Of course, an application requires a function that was roduced in a later, minor release, then the application will require that, at least, that release is ed _disibledevent=>Run-time checks are particurly important the application is trying to determine the library has a particular bug that may need to be worked around, but has been fixed in a later release. If the bug is fixed in a patch release, then the _disibledevent=>1.2.3.3 版本API
和前面版本规则定义APR中定义了数据结构apr_version_t来描述版本规则:
typedef struct {
    major;      /**< major number */
    minor;      /**< minor number */
    patch;      /**< patch number */
    is_dev;     /**< is development (1 or 0) */
} apr_version_t;
major是当前APR版本主版本号minor则是次版本号patch对应则是APR补丁号es_dev则描述了当前APR库状态:开发版还是发行版分别对应1和0
旦定义了apr_version_t结构APR就将使用它作为基本版本控制单位APR中提供了apr_version和apr_version_分别设置和返回APR版本
APR_DECLARE(void) apr_version(apr_version_t *pvsn)
{
    pvsn->major = APR_MAJOR_VERSION;
    pvsn->minor = APR_MINOR_VERSION;
    pvsn->patch = APR_PATCH_VERSION;
#def APR_IS_DEV_VERSION
    pvsn->is_dev = 1;
#
    pvsn->is_dev = 0;
#end
}
apr_version仅仅就是设置apr_version_t结构中各个成员对于每个APR版本APR都会将当前版本号分别用 3个常量定义在version.h中比如如果版本号是2.2.0则常量定义应该如下:
# APR_MAJOR_VERSION       2
# APR_MINOR_VERSION       2
# APR_PATCH_VERSION       0
apr_version_仅仅是返回APR_VERSION_STRING宏该宏定义为:
# APR_VERSION_STRING \
     APR_STRINGIFY(APR_MAJOR_VERSION) "." \
     APR_STRINGIFY(APR_MINOR_VERSION) "." \
     APR_STRINGIFY(APR_PATCH_VERSION) \
     APR_IS_DEV_STRING
APR_STRINGIFY用于将给定数值转换为因此APR_VERSION_STRING宏就是无非将APR_MAJOR_VERSIONAPR_MINOR_VERSIONAPR_PATCH_VERSION分别转换为再用"."连接起来最后形式应该为“2.2.0”
尽管般情况下APR版本号是“x.x.x”格式不过在Window资源文件.rc中通常是“x,x,x”格式因此APR中也提供了APR_VERSION_STRING_CSV来提供这种格式版本号:
# APR_VERSION_STRING_CSVAPR_MAJOR_VERSION ##, \
                             ##APR_MINOR_VERSION##, \
                             ##APR_PATCH_VERSION
##宏用于将变量和特定进行连接形成新在后面部分我们会不断看到它使用方法
些情况下应用需要使用APR版本达到版本号为此APR中提供了APR_VERSION_AT_LEAST宏用以检测给定APR库是否达到给定版本要求:
# APR_VERSION_AT_LEAST(major,minor,patch)                    \
(((major) < APR_MAJOR_VERSION)                                     \
 || ((major) APR_MAJOR_VERSION && (minor) < APR_MINOR_VERSION) \
 || ((major) APR_MAJOR_VERSION && (minor) APR_MINOR_VERSION && (patch) <= APR_PATCH_VERSION))
如果我们希望当前使用APR库版本不低于”1.2.0”那么我们就使用使用APR_VERSION_AT_LEAST(1,2,0)对当前APR库版本进行检查


有关作者
张中庆目前主要研究方向是嵌入式浏览器移动中间件以及大规模服务器设计目前正在进行Apache源代码分析计划出版Apache源代码全景分析上下册Apache系列文章为本书草案部分对Apache感兴趣朋友可以通过flydish1234 at sina.com.cn和的联系!



Tags:  vb运行库 dx.netvc运行库 vc运行库 apacheapr

延伸阅读

最新评论

发表评论