Got my panda board last week after a wait of almost 3 months. Today I installed prebuild ubuntu and froyo android binaries. Board came up smoothly. Mouse movement is bit non-responsive. Screen flickers sometimes when using mouse. Now I need to think doing some meaningful project with it.
Tech bits and bytes Blog
Friday, March 4, 2011
my panda board
Got my panda board last week after a wait of almost 3 months. Today I installed prebuild ubuntu and froyo android binaries. Board came up smoothly. Mouse movement is bit non-responsive. Screen flickers sometimes when using mouse. Now I need to think doing some meaningful project with it.
Thursday, December 16, 2010
find structure pointer when you have its one field pointer
you may know it but worth recalling it.
struct my_type {
int x;
char a[20];
char b[20];
int y;
int z;
};
struct my_type *ptr;
suppose you know &(ptr->y) in your function, then can we find out the ptr value? In other words, we have a pointer of a field (say y) of the any structure. We want to find out the pointer of the structure which contain this field. We know the type of the structure (struct my_type) and the field name (y) whose pointer is given.
The trick is to find the offset of the y by referencing the same structure type at address 0. and then deduct this offset from the given address of y and you will get the container structure pointer. Linux kernel uses this technique extensively by container_of macro.
offset_of_y = (int) &((struct my_type *) 0)->y;
ptr = (struct my_type *)((char *)y_ptr - offset_of_y);
Download the sample C program demonstrating it.
struct my_type {
int x;
char a[20];
char b[20];
int y;
int z;
};
struct my_type *ptr;
suppose you know &(ptr->y) in your function, then can we find out the ptr value? In other words, we have a pointer of a field (say y) of the any structure. We want to find out the pointer of the structure which contain this field. We know the type of the structure (struct my_type) and the field name (y) whose pointer is given.
The trick is to find the offset of the y by referencing the same structure type at address 0. and then deduct this offset from the given address of y and you will get the container structure pointer. Linux kernel uses this technique extensively by container_of macro.
offset_of_y = (int) &((struct my_type *) 0)->y;
ptr = (struct my_type *)((char *)y_ptr - offset_of_y);
Download the sample C program demonstrating it.
Android IPC Binder
This is my first post. Its about Binder IPC in Android platform. This presentation I compiled from various sources and presentated to a group of software developers.
Click here to download presentation.
Click here to download presentation.
Subscribe to:
Posts (Atom)