日志存档:06, 2009
在读linux/kernel/fork.c的时候遇到了unlikely宏定义,一路追踪,最后找到了GCC内建函数__builtin_expect(),查阅GCC手册,发现其定义如下: long __builtin_expect (long exp, long c) [Built-in Function] You may use __builtin_expect to provide the compiler with branch prediction information. In general, you should prefer to use actual profile feedback for this (‘-fprofile-arcs’), as programmers ...
发表评论 »
一、介绍 继Junit CppUnit的成功后, c语言环境下也出现了开发源码的白盒测试用例CUnit。CUnit以静态库的形式提供给用户使用,用户编写程序的时候直接链接此静态库就可以了。它提供了一个简单的单元测试框架,并且为常用的数据类型提供了丰富的断言语句支持。 二、结构框架 在CUnit的主页上可以看到对他结构的简单描述 Test Registry | ------------------------------ | | Suite '1' . . . . Suite 'N' | | ...
发表评论 »
熟悉设计模式的朋友一定知道著名的Singleton吧,如果不知道的话那就先去拜读一下GoF的大作吧,我在这里就不详细介绍了。 直接给大家共享出我们的实现方法,使用的是C++的template。
// singleton.h
#ifndef _SINGLETON_H_
#define _SINGLETON_H_
template class Singleton
{
protected:
Singleton() {}
Singleton( const Singleton & ) {}
Singleton &operator = (Singleton &) {}
...
发表评论 »