CMake 101

(From When writing CMake scripts there is a lot you need to know about the syntax and how to use variables in CMake. The Syntax Strings using set(): set(MyString “Some Text”) set(MyStringWithVar “Some other Text: ${MyString}”) set(MyStringWithQuot “Some quote: \”${MyStringWithVar}\””) Or with string(): string(APPEND MyStringWithContent ” ${MyString}”) Lists using set(): set(MyList “a” “b” “c”) set(MyList ${MyList} “d”) Or अतिरिक्त Read More

Android NDK console print C/C++ – Chirag Patel

When your Android app has C/C++ code using NDK tools and you want printing output to serial port console, here’s the solution. // change sharing first chmod(“/dev/console”, S_IRWXG | S_IRWXO | S_IRWXU); // open file int serialFd = open(“/dev/console”, O_RDWR | O_NONBLOCK | O_NDELAY | O_NOCTTY | O_APPEND); __android_log_print(ANDROID_LOG_DEBUG, “Serial”, “Serial console fd=%d errno=%d(%s)”, serialFd, अतिरिक्त Read More

Memory Thrashing compiled by Chirag Patel December 27, 2008

Memory Thrashing compiled by Chirag Patel December 27, 2008 (Ref: Embedded Systems Design June 2008) Memory threshing is a typical problem that goes unnotices while programming time-critical systems. Translation Look-aside Buffers (TLB) are used for data and instruction cache. There are two main cache-replacement schemes: 1) Least Frequently Used (LFU) and 2) Least Recently Used अतिरिक्त Read More

double precision comparison in c++ – chirag patel

Checking double precision value for limits is tricky. Say, double x = 1.0; if ( x == 1.0 ) do_something();   This comparison can fail as double precision value when converted to hexadecimal (what computer can do only) representation, looses some least significant bits or positions beyond double precision digits. So, in above example if अतिरिक्त Read More

double precision rounding – chirag patel

Uses my_double_greater_check from double my_double_round( double val, int multiplier ) {          double val_adj = val * multiplier;          if ( my_double_greater_check( val_adj floor( val_adj ), 0.0 ) > 0 )                       val = round( val_adj ) / multiplier; अतिरिक्त Read More