Insert the bellowing line into Android.mk
$(shell python $(LOCAL_PATH)/scripts/myprepare.py)
When running mm command or other command to build your apk, the script myprepare.py will be invoked.
You can copy some files or do any thing python can do. But notice: don't add any print function in your python script.
run Python script in Android.mk on Android building system Friday, September 23, 2011
Posted by Unknown at 5:20 PM 0 comments
[Refer] Empty parameter lists Thursday, September 15, 2011
C distinguishes between a function declared with an empty parameter list
and a function declared with a parameter list consisting of only
void.
The former is an unprototyped function taking an unspecified number of
arguments, while the latter is a prototyped function taking no arguments.
// C code extern int foo(); // Unspecified parameters extern int bar(void); // No parameters void baz() { foo(0); // Valid C, invalid C++ foo(1, 2); // Valid C, invalid C++ bar(); // Okay in both C and C++ bar(1); // Error in both C and C++ }C++, on the other hand, makes no distinction between the two declarations and considers them both to mean a function taking no arguments.
// C++ code extern int xyz(); extern int xyz(void); // Same as 'xyz()' in C++, // Different and invalid in CFor code that is intended to be compiled as either C or C++, the best solution to this problem is to always declare functions taking no parameters with an explicit void prototype. For example:
// Compiles as both C and C++ int bosho(void) { ... }Empty function prototypes are a deprecated feature in C99 (as they were in C89).
Refer to http://david.tribble.com/text/cdiffs.htm
Posted by Unknown at 2:18 PM 0 comments
A demo using mmap to read a file Thursday, September 8, 2011
#include
#include
#include
#include
#include
int main (int argc, char *argv[])
{
struct stat sb;
off_t len;
char *p;
int fd;
if (argc < 2) {
fprintf (stderr, "usage: %s
return 1;
}
fd = open (argv[1], O_RDONLY);
if (fd == -1) {
perror ("open");
return 1;
}
if (fstat (fd, &sb) == -1) {
perror ("fstat");
return 1;
}
if (!S_ISREG (sb.st_mode)) {
fprintf (stderr, "%s is not a file\n", argv[1]);
return 1;
}
p = mmap (0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
perror ("mmap");
return 1;
}
if (close (fd) == -1) {
perror ("close");
return 1;
}
for (len = 0; len < sb.st_size; len++)
putchar (p[len]);
if (munmap (p, sb.st_size) == -1) {
perror ("munmap");
return 1;
}
return 0;
}
Posted by Unknown at 4:38 PM 0 comments
create_singlethread_workqueue
struct workqueue_struct *create_singlethread_workqueue(const char *name);
Creates a workqueue. Each workqueue has one dedicated processes ("kernel threads"), which run functions submitted to the queue.
Posted by Unknown at 1:44 PM 0 comments
Labels: Linux