From nobody@FreeBSD.org  Fri Oct  5 09:17:48 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 02BA3106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  5 Oct 2012 09:17:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E21498FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  5 Oct 2012 09:17:47 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q959Hlp8048406
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 5 Oct 2012 09:17:47 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q959HlYj048405;
	Fri, 5 Oct 2012 09:17:47 GMT
	(envelope-from nobody)
Message-Id: <201210050917.q959HlYj048405@red.freebsd.org>
Date: Fri, 5 Oct 2012 09:17:47 GMT
From: Kevin Lo <kevlo@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Add __even_in_range() stub to devel/msp430-gcc
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172352
>Category:       ports
>Synopsis:       Add __even_in_range() stub to devel/msp430-gcc
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lev
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 05 09:20:04 UTC 2012
>Closed-Date:    Thu Oct 18 14:56:12 UTC 2012
>Last-Modified:  Thu Oct 18 14:56:12 UTC 2012
>Originator:     Kevin Lo
>Release:        10-current
>Organization:
>Environment:
FreeBSD 10.0-CURRENT
>Description:
Add __even_in_range() stub from upstream.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ruN msp430-gcc.orig/Makefile msp430-gcc/Makefile
--- msp430-gcc.orig/Makefile	2012-09-26 11:21:19.000000000 +0800
+++ msp430-gcc/Makefile	2012-09-26 12:38:07.000000000 +0800
@@ -7,7 +7,7 @@
 
 PORTNAME=	gcc
 PORTVERSION=	${GCCVERSION}.${LTSVERSION}
-PORTREVISION=	0
+PORTREVISION=	1
 PORTEPOCH=	2
 CATEGORIES=	devel
 MASTER_SITES=	${MASTER_SITE_SOURCEWARE} \
@@ -25,7 +25,7 @@
 PATCH_DIST_STRIP=	-p1
 
 MAINTAINER=	lev@FreeBSD.org
-COMMENT=	FSF gcc-4.5 for TI's msp430 MCUs cross-development
+COMMENT=	FSF GCC 4.x for TI's msp430 MCUs cross-development
 
 LICENSE=	GPLv3
 
@@ -88,6 +88,8 @@
 
 pre-patch:
 	@cd ${SRCDIR} && ${PATCH} -s -p1 < ../mspgcc-${LTSVERSION}/${PKGNAMEPREFIX}${PORTNAME}-${GCCVERSION}-${PATCHVERSION}.patch
+	${CP} ${SRCDIR}/gcc/config/msp430/msp430-builtins.c \
+		${SRCDIR}/gcc/config/msp430/msp430-builtins.c.orig
 
 pre-configure:
 	cd ${SRCDIR} ; contrib/gcc_update --touch
diff -ruN msp430-gcc.orig/files/patch-gcc-config-msp430-msp430-builtins.c msp430-gcc/files/patch-gcc-config-msp430-msp430-builtins.c
--- msp430-gcc.orig/files/patch-gcc-config-msp430-msp430-builtins.c	1970-01-01 08:00:00.000000000 +0800
+++ msp430-gcc/files/patch-gcc-config-msp430-msp430-builtins.c	2012-09-26 12:49:32.000000000 +0800
@@ -0,0 +1,55 @@
+--- gcc/config/msp430/msp430-builtins.c.orig	2012-09-26 12:24:42.000000000 +0800
++++ gcc/config/msp430/msp430-builtins.c	2012-09-26 12:28:31.000000000 +0800
+@@ -59,6 +59,7 @@
+   MSP430_BUILTIN_GET_WATCHDOG_CLEAR_VALUE,
+   MSP430_BUILTIN_SET_WATCHDOG_CLEAR_VALUE,
+   MSP430_BUILTIN_WATCHDOG_CLEAR,
++  MSP430_BUILTIN_EVEN_IN_RANGE,
+   MSP430_BUILTIN_last_enum
+ };
+ 
+@@ -153,6 +154,13 @@
+   add_builtin_function ("__watchdog_clear",
+ 			build_function_type_list (void_type_node, NULL_TREE),
+ 			MSP430_BUILTIN_WATCHDOG_CLEAR, BUILT_IN_MD, NULL, NULL_TREE);
++  add_builtin_function ("__even_in_range",
++			build_function_type_list (unsigned_type_node,
++						  unsigned_type_node,
++						  unsigned_type_node,
++						  NULL_TREE),
++			MSP430_BUILTIN_EVEN_IN_RANGE, BUILT_IN_MD,
++			NULL, NULL_TREE);
+ }
+ 
+ rtx
+@@ -432,6 +440,30 @@
+       emit_move_insn (retval, arg);
+       insn = gen_bswaphi1 (retval);
+       break;
++    case MSP430_BUILTIN_EVEN_IN_RANGE:
++      {
++	tree key_tree = CALL_EXPR_ARG (exp, 0);
++	tree limit_tree = CALL_EXPR_ARG (exp, 1);
++	rtx key;
++	HOST_WIDE_INT limit_val;
++	
++	need_insn = false;
++	if (!cst_and_fits_in_hwi (limit_tree)
++	    || (0 > ((limit_val = int_cst_value (limit_tree)))))
++	  {
++	    error
++	      ("__even_in_range second argument must be non-negative integer constant");
++	    break;
++	  }
++	key = expand_expr (key_tree, NULL_RTX, VOIDmode, EXPAND_NORMAL);
++	retval = gen_reg_rtx (HImode);
++	/* This is a stub.  To complete this, we need to attach notes
++	 * that assert that the value is, in fact, even and between 0
++	 * and the second argument.  No idea how to do that in a way
++	 * that gcc's tablejump will pay any attention to. */
++	emit_move_insn (retval, key);
++	break;
++      }
+     }
+ 
+   if (insn)
diff -ruN msp430-gcc.orig/pkg-descr msp430-gcc/pkg-descr
--- msp430-gcc.orig/pkg-descr	2012-09-26 11:21:19.000000000 +0800
+++ msp430-gcc/pkg-descr	2012-09-26 12:38:51.000000000 +0800
@@ -1,4 +1,4 @@
-FSF gcc-4.5 for TI's msp430 MCUs cross-development
+FSF gcc-4.x for TI's msp430 MCUs cross-development
 
 This brings the gcc compiler for the Texas Instruments MSP430 16-bit
 RISC-like family of microcontrollers.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->lev 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Oct 5 09:20:16 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172352 
State-Changed-From-To: open->closed 
State-Changed-By: lev 
State-Changed-When: Thu Oct 18 14:55:47 UTC 2012 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172352 
>Unformatted:
