10

Shorter version of question:

Which C header contains the macro that corresponds to the machine architecture of the system (e.g., __x86_64__, __ia64__, __mips__?)

Longer version of question:

I'd like to run the ganglia monitoring tools on a Tilera-based system that runs Linux.

Ganglia doesn't currently have support for Tilera. To get this to work, I ned to modify a C function called machine_type_func that returns the machine architecture. The body of this function is determined at compile-time, it looks like this:

g_val_t
machine_type_func ( void )
{
   g_val_t val;

#ifdef __i386__
   snprintf(val.str, MAX_G_STRING_SIZE, "x86");
#endif
#ifdef __x86_64__
   snprintf(val.str, MAX_G_STRING_SIZE, "x86_64");
#endif
...
   return val;
}

I need to add the appropriate line for Tilera, but I don't know the name of the macro that specifies a Tilera-based system. I'm guessing this macro is defined in one of the standard Linux headers, but I don't know which one to look in.

Lorin Hochstein
  • 8,077
  • 17
  • 50
  • 56

2 Answers2

11

No header file defines it - those macros are predefined by the compiler. To find out the full list of predefined macros do this:

echo | gcc -E -dM -

Then look through the results for likely macros.

TomH
  • 2,952
  • 1
  • 17
  • 10
2

More precisely, I think this is where the __x86_64__ is defined for example: https://github.com/gcc-mirror/gcc/blob/releases%2Fgcc-10.2.0/gcc/config/i386/i386-c.c#L688

 cpp_define (parse_in, "__x86_64__");

but I didn't have the patience to modify the source, recompile and test it out yet. A good way to search is:

git grep '"__aarch64__'