Skip to content

Tag Archives: programming

ctags

24-Oct-10

Ctags is a program that generates an index (or tag) file of names found in source and header files of various programming languages. A nice introduction to ctags and other related programs can be found here. An example of using ctags is this function counting script: 1 2 3 4 5 6 7 #!/bin/sh   [...]

Makefile template

24-Oct-10

This is not a finished example, but it contains enough information for me to use as a template most of the times. A bit of previous experience with GNU make and the places to modify are obvious. It helps me with the blank page syndrome. Some helpful links: GNU make GNU gcc GNU binutils   [...]

Porting your 32 bits application to 64 bits

28-Aug-09

The big difference: ILP32: int, long and pointers are 3 2bits.LP64: int are 32bits, long and pointers are 64 bits. Look out for: Problems with 64 bits long and pointer types: 32 bits applications usually assume int, long and pointers are the same size. int and long are not to be used interchangeably. All pointers [...]

Protecting your software

05-Jun-09

There is no way to protect your software completely. Some cracker with enough knowledge will always be able to side step the protection. What you can do is elevate the amount of knowledge required so that the amount of people with that knowledge is small, and chances are your application is not worth their time. [...]

Mutexes vs Semaphores

16-Feb-09

The Toilet Example Mutex: Is a key to a toilet. One person can have the key – occupy the toilet – at the time. When finished, the person gives (frees) the key to the next person in the queue. Officially: “Mutexes are typically used to serialise access to a section of re-entrant code that cannot [...]

Finding out the glibc/NPTL version of your Linux distro

05-Nov-08

For example for Debian etch we get, # /lib/libc.so.6 | head -1GNU C Library stable release version 2.3.6, by Roland McGrath et al. # getconf GNU_LIBPTHREAD_VERSIONNPTL 2.3.6 NPTL is a threading library (like linuxthreads before). What threading library is glibc compiled with is distribution dependant.

Programming data models

03-Oct-08

A data model is a way to represent data for different architectures. It can also be called an ABI (Application Binary Interface). In the MIPS world, ABIs are o32, n32 or n64, while for other processors the ‘LP’ (Long/Pointer) ABIs are used. LP32 ILP32 LP64 LLP64 ILP64 SILP64 short 16 16 16 16 16 64 [...]

Debugging threads in Linux

28-Aug-08

LTTng (Linux Trace Toolkit – Next Generation) This will help trace the system calls and the interaction of threads with each other and with the kernel. GDB (>= 5.2) Using the “info threads” GDB command will show you the threads that are active for the process and then you can switch to particular threads using [...]

Packet data cache alignment

04-Apr-08

When designing high performance network drivers you can achieve a performance increase if you ensure that the packet payload is cache aligned when copying it to the application buffer. Usually network hardware provide the receive buffer cache aligned, but the data we are likely to copy to the application layer is the TCP/UDP payload, and [...]

Obtaining the offset of a structure member

04-Apr-08

/* From linux/include/stddef.h */ #ifdef __compiler_offsetof #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER) #else #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif Looking at the Linux kernel code, a macro frequently used is offsetof, which returns the offset (in bytes) of a member of a structure. So offsetof(LGB,data), will return the offset of data in the structure of type LGB, [...]