Milinda Pathirage’s Blog

Let the code talk for yourself!

Entries Tagged as 'c programming'

GCC Compiler Extensions Used in Linux Kernel

November 21st, 2008 · No Comments · c programming, linux

GCC and Linux are a great pair. Although they are independent pieces of software, Linux is totally dependent on GCC to enable it on new architectures. Linux further exploits features in GCC, called extensions, for greater functionality and optimization.

Read this article from IBM Developer Works to find out more…
Sphere: Related Content

[Read more →]

Tags:

inotify - Linux File System Activity Monitoring

November 10th, 2008 · No Comments · c programming, linux, linux tips, php, programming, python, ruby

inotify is a Linux kernel subsystem which monitors Linux file system operations, such as read, write, create and delete. It was included in the mainline kernel from release 2.6.13 (June 18, 2005). It is more efficient than busy polling from a corn job and it’s an extensions to Linux file system to capture the file [...]

[Read more →]

Tags:

Get You Twitter Friends Time Line Using libcurl

September 13th, 2008 · 2 Comments · c programming, personal, programming

This weekend I am doing simple project to display twitter time line on ‘Conky’ widget. For that first I need to write a simple program which will print the twitter time line of my friends. First I tried to use python-twiiter API and failed due to strange Python error. After that I started to implement [...]

[Read more →]

Tags:

Recursion, Non-Recursion and Tail Recursion Test using GCC -O2 optimization

August 20th, 2008 · 1 Comment · algorithms, c programming, programming

I got  very positive response for my previous post that published test results of Recursion algorithm efficiency testing.

Bluestorm and Alex has responsed to above post asking me to try gcc -O2 optimization level. I tried -O2 optimization and here is the results for factorial of 5 using different factorial algorithm implementations:

Here is the results for [...]

[Read more →]

Tags:

Recursion, Non-Recursion and Tail Recursion Test

August 20th, 2008 · 11 Comments · c programming, programming

Because of the responses I got from readers for previous post ‘Efficiency of Algorithms: Recursive vs Non-Recursive’, I did some test using RDTSC instruction available in Pentium class CPUs. I measure time taken to execute factorial function implemented in different ways 10000000 times. Factorial function is implemented in non-recursive, recusive and tail-recursive manner(Tail recursive version [...]

[Read more →]

Tags:

Difference between static functions and static variables in C

May 28th, 2008 · No Comments · c programming

Static Functions

Static functions are functions that are only visible to functions in the same file and they are not callable from outside. Static functions are used when we only need to call them within the single source file they are defined in. This make static functions are usable when we need to hide internal details [...]

[Read more →]

Tags:

memcpy vs memmove

May 23rd, 2008 · No Comments · c programming

These are some ideas from people who replied to this discussion.

Rishi:
Its safer to use memmove if you are not sure about the overlapping of source buffer and destination buffer. This make memmove little bit slower than memcpy which blindly copies the src into dest and will probably get nuked if they overlap. Its smarter cousin [...]

[Read more →]

Tags:

GCC 4.3 changes caused build break when use -Wall and -Werror together

May 23rd, 2008 · 1 Comment · c programming, linux tips

As they have mentioned in this document, there can be errors in code that work well with previous versions of GCC. They have mentioned that, new warnings may exist for previously warning-free code that uses -Wuninitialized, -Wstrict-aliasing,-Wunused-function, -Wunused-variable (-Wall subsumes many of these warning flags). And when we use -Wall in conjuction with -Werror it [...]

[Read more →]

Tags: