From patchwork Wed Jul 23 08:04:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 372839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8EAF914019D for ; Wed, 23 Jul 2014 18:06:40 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=QETL47BFo+lqkSl68OLzEc1FrDCeD/f1sxUdbFJ5HNJckceWzR /EKS+uyhLp6hZQOHimGHFgf3VX3BKYEYsasfhYwbaxUGhk1LoBODlT0jB5/wJH0Y PsQIJxS5e46pmZ06AKCc4n4b0JdpL0hk/M5YoqRBEr+jVCep5x6vz7lL0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=Ma48n7/FPviDv4pR3DaqHL9aW+o=; b=vp8E+YR6DHEOrAex4Yxi KmprrcVtlAUaed3lGhtGuywiVNbzK92DzKml2B9ev7ktV9tku8Ia/l1K57wrk+lk i7xOWuzsUE7w5rOD4p9b2g2TT+lSCxllKUGl4N/2TVo6RBMYhVQGv+P2VJtcJbgS 13qdBCMUyR51fPyl3NsNFCE= Received: (qmail 32258 invoked by alias); 23 Jul 2014 08:06:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32232 invoked by uid 89); 23 Jul 2014 08:06:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_50, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: SJOEDG01.corp.atmel.com Received: from nasmtp02.atmel.com (HELO SJOEDG01.corp.atmel.com) (204.2.163.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 23 Jul 2014 08:06:20 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by sjoedg01.corp.atmel.com (10.64.253.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Wed, 23 Jul 2014 01:07:17 -0700 Received: from PENCHT01.corp.atmel.com (10.168.5.161) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server (TLS) id 14.2.347.0; Wed, 23 Jul 2014 16:06:00 +0800 Received: from atmel.com (10.168.5.13) by cas-ap.atmel.com (10.168.5.161) with Microsoft SMTP Server (TLS) id 14.2.342.3; Wed, 23 Jul 2014 16:04:34 +0800 Date: Wed, 23 Jul 2014 13:34:41 +0530 From: Senthil Kumar Selvaraj To: CC: , Subject: [Patch, avr] Add device name to cpp_builtins Message-ID: <20140723080440.GA28575@atmel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes 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 * 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__");