Generate C interface from C++ source code using Clang libtooling

I developed a concurrent user-thread library using C++, and was looking for a way to provide a C interface and make the functionality available in C. In order to achieve this goal, I started writting a C wrapper interface manually where each public method of a class is mapped to a function in C with the class name followed by the function name. Also, constructors are mapped to class name followed by _create and destructors are mapped to the class name followed by _destory....

December 6, 2016 · 22 min · 4499 words · Saman Barghi

How to wrap a system call (libc function) in Linux

For one of my research projects I had to wrap linux system calls and redirect them to another thread. In Linux system calls are not invoked directly, but rather via wrapper functions in glibc[man 2 syscalls]. The glibc wrapper is only copying arguments and unique system call number to the registers where the kernel expects them, then trapping to kernel mode and setting the errno if the system call returns an error number [man 2 intro]....

September 5, 2014 · 8 min · 1642 words · Saman Barghi

National Geographic Photo of the day Downloader for Linux

National Geographic's Photo Of the Day I am a fan of National Geographic photos on their site, and I also get bored of by my desktop background after a while. So I decided to create a script to download National Geographic photo of the day, and using it as my desktop background. I am using it over Gnome3 (I am using Fedora as I think it’s more stable than Ubuntu, and I like Gnome3 way better than Unity), but if you are a Unity user it should work for you as well....

August 29, 2012 · 2 min · 308 words · Saman Barghi

What Might My Resume look Like If I Were a Computer !?

The other day I was about to update my resume, and this crazy question came to my mind: What might my resume look like if I were a computer ? And This is the result. (Best viewed in Chrome and Firefox). Well, I am aware that I would not wake up one morning finding out I turned into a computer. Also, I am not sure if one day I turn into a computer, I would look for a job....

May 21, 2012 · 6 min · 1196 words · Saman Barghi

Mercurial on Bluehost

...

August 26, 2011 · 3 min · 514 words · Saman Barghi