Hacker News new | past | comments | ask | show | jobs | submit login

Could you please elaborate?



(fitting user name, sir or madam!)

I'm guessing he's referring to declaring a global structure or collection of function pointers, and then using #ifdef's and compiler flags to actually assign those function pointers to things that make optimal sense for the architecture.

Or, at runtime (but hopefully before usage!) setting those global function pointers to point at routines optimal for the situation the program is running under--say, setting them to point at an optimized SSE3 vector routine if the CPU supports it.

Maybe that's it?


Just the other day I was looking at some embedded SoC which had some data structures for setting up various GPIOs and pins and such, it was something like:

   struct gpio_config {
       uint8_t func;
       uint8_t options;
       uint32_t *loc;
   };

   struct gpio_alloc {
      struct gpio_config pins[4];
      struct gpio_alloc *next;
   };

   struct gpio_alloc fsmc_1 = {
              ...
   };
All the pre-initialization stuff (which was being stored in flash so it was really read-only data) was code I realized not a lot of people wrote in C these days.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: