what is the meaning of restrict in the function signature?

It’s something introduced in C99 which lets the compiler know that the pointer passed in there isn’t pointing to the same place as any other pointers in the arguments. If you give this hint to the compiler, it can do some more aggressive optimizations without breaking code. As an example, consider this function: int add(int … Read more

How to forward typedef’d struct in .h

Move the typedef struct Preprocessor Prepro; to the header the file and the definition in the c file along with the Prepro_init definition. This is will forward declare it for you with no issues. Preprocessor.h #ifndef _PREPROCESSOR_H_ #define _PREPROCESSOR_H_ #define MAX_FILES 15 typedef struct Preprocessor Prepro; void Prepro_init(Prepro* p); #endif Preprocessor.c #include “Preprocessor.h” #include <stdio.h> … Read more

Sending data with PACKET_MMAP and PACKET_TX_RING is slower than “normal” (without)

Many interfaces to the linux kernel are not well documented. Or even if they seem well documented, they can be pretty complex and that can make it hard to understanding what the functional or, often even harder, nonfunctional properties of the interface are. For this reason, my advice to anyone wanting a solid understanding of … Read more

Is it valid to have multiple signal handlers for same signal?

As said by others, only one signal handler can be set, which is the last one. You would then have to manage calling two functions yourself. The sigaction function can return the previously installed signal handler which you can call yourself. Something like this (untested code): /* other signal handlers */ static void (*lib1_sighandler)(int) = … Read more

bind socket to network interface

You can bind to a specific interface by setting SO_BINDTODEVICE socket option. struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), “eth0”); if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) < 0) { … error handling … } Warning: You have to be root or have the CAP_NET_RAW capability in order to use this option. The second … Read more

How to measure program execution time in ARM Cortex-A8 processor?

Accessing the performance counters isn’t difficult, but you have to enable them from kernel-mode. By default the counters are disabled. In a nutshell you have to execute the following two lines inside the kernel. Either as a loadable module or just adding the two lines somewhere in the board-init will do: /* enable user-mode access … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)