This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, avr] Add device name to cpp_builtins


The below patch adds a new preprocessor define for the device name
(__AVR_DEVICE_NAME__) that was passed to the compiler.

While the device name macro (say __AVR_ATmega128__) can be used to 
check for a specific device, there is no way right now for code 
to get the device name it is being compiled against (without checking
for every possible device).

This patch is groundwork for embedding device information in a note
section (see binutils ml discussion
https://www.sourceware.org/ml/binutils/2014-07/msg00146.html), so that
utilities that operate on the ELF file do not have to hardcode
device information themselves.

If ok, could someone apply please? I don't have commit access.

Regards
Senthil

2014-07-23  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	* config/avr/avr-c.c (avr_cpu_cpp_builtins): Add __AVR_DEVICE_NAME__.

diff --git gcc/config/avr/avr-c.c gcc/config/avr/avr-c.c
index c6a2f1f..7c9f758 100644
--- gcc/config/avr/avr-c.c
+++ gcc/config/avr/avr-c.c
@@ -299,7 +299,10 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
   if (avr_current_arch->macro)
     cpp_define_formatted (pfile, "__AVR_ARCH__=%s", avr_current_arch->macro);
   if (avr_current_device->macro)
-    cpp_define (pfile, avr_current_device->macro);
+    {
+      cpp_define (pfile, avr_current_device->macro);
+      cpp_define_formatted (pfile, "__AVR_DEVICE_NAME__=%s", avr_current_device->name);
+    }
   if (AVR_HAVE_RAMPD)    cpp_define (pfile, "__AVR_HAVE_RAMPD__");
   if (AVR_HAVE_RAMPX)    cpp_define (pfile, "__AVR_HAVE_RAMPX__");
   if (AVR_HAVE_RAMPY)    cpp_define (pfile, "__AVR_HAVE_RAMPY__");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]