Thursday 13 March 2014

about fossil(1)

fossil is another software I am studying on. This is a distributed version control system, bug tracking system and wiki software server for use in software development. It is like the Git. 

For now I just want to build it on my x86_64 machine first.

after downloading it and generate source code, I take a look at the whold directory.
configure file again! That makes life easy! But let me take a look at the BUILD.txt.
nothing special, lets begin building.

  mkdir build
  cd build
  ../configure

 then make, but I got error because of the sqlite3.c missing.
I check the official website and say it is included in the src, but I don't see it. So I just download another one.





Now it is built.


fossil study(1) is done.

Hua

about cxxtools(1)

This days I spend some time taking a look at the cxxtools library. It is a library written in C++, and provides classes for serialization, unicode text, multi threading, networking, rpc, http client and server, xml, logging and many more. What I will do is trying to build and test this library. And If I port the codes to aarch64, do I need to modify some codes. My environment is Fedora linux and the CPU is X86_64.

The first step is downloading the source code.  the cmd is 
          fedpkg clone -a cxxtools

Waiting for finishing downloading, then go to the cxxtools directory, and 
          fedpkg prep

Next, go to the cxxtools-2.2.1 directory, and try to find the something about the asembly codes for the first look.(to see if it needs to be modified for porting to arrch64)

Under the src directory, I find many cpp file for atomicity functions, and they all codes in asembly language, I think maybe that is what I should focus on.

All the codes using asembly,

 Leave it for now. I want build it first on the x86_64 machine.

I red the README file and INSTALL file, and know that this library's author uses the automake and autoconfig for development. He provides configure file which can be used to config and build. Then I run ./configure and then make, and it start to build:

After 10 min(so long..), it is done. and now I have a built cxxtools on my x86_64 machine.

I will continue studying about it.

Hua

Monday 10 March 2014

What is the meaning of do{...} while(0)

    Sometimes we see some codes in C using this pattern: do{...} while(0). It looks it doesn't do anything else but just simply running everything in the braces. When I saw these codes the first time, I also felt weird. Then I did some research and post it. I hope it can help you.

    This pattern is only used in C or C++’s conditional compilation and when you want to use #define to represent multiple statements. A simple sample is like this:

#define function(x)  do { a(x); b(x); }while (0)

so, we can use it like this:

if(some condition){
    function(x);
}

else 
      blah blah....

     Why we have to use this pattern? When you want to use #define to represent multiple statements, 
this statement wouldn't work:
#define function(x)  foo(x); bar(x)   //cause syntax error in the if statement

this statement still won't work:
#define FOO(x) { foo(x); bar(x); } // doesn't work
 
only in this pattern:
#define function(x)  do { a(x); b(x); }while (0)
It work well in the if statement.

That is my study about this thing. I hope I can help you.

Hua