From patchwork Tue Sep 18 18:06:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 184792 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]) by ozlabs.org (Postfix) with SMTP id BB5CE2C0084 for ; Wed, 19 Sep 2012 04:07:02 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1348596423; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=GZMwraUrYvg9BzlLPtwY+0lz0K4=; b=mYyeWlNexhWNnlj vBmPsv33fbnpdSBaT7OqBm5oWR+Qgi+izWzPQAWtvhtWpeopYFAedtNFI0VBFhtR kw5zalbfdXN6Zpqx6HAf4hgpIGqE5crH+ceIy0Ie0iGPc4BrEfsCLePnOItMOXrG q8Y4kiZ4/iMoyJvO39FINH0GOxHw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=R0GCPdhEND3gh7mMJ50lPLNg00IVtBEyuCsR5TOMlixQjpzRNhiQpy9ruV/qzM m6BY3QbZn4ew0ZZrj6xdKNBNBOEFdtRLawUNoknHi5H5t355rsBi39m1a7ikezUj hdGZXFs2M/vA7Hma3TV+TkhyR8e//Ca5L+11j0229hP8s=; Received: (qmail 19953 invoked by alias); 18 Sep 2012 18:06:56 -0000 Received: (qmail 19941 invoked by uid 22791); 18 Sep 2012 18:06:54 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_FC, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Sep 2012 18:06:36 +0000 Received: by pbcwy7 with SMTP id wy7so552371pbc.20 for ; Tue, 18 Sep 2012 11:06:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=tJG/Fujnqb72f5qEkbDIUb4XNK68DiUtTgBED90XGJE=; b=e8XYHELs5pCxkN6Tllot1Qegq1rDTToHWliH3FzTLRBwkAqDQgfS/nNQvJ+LKC02WS qDk6enFUqD7+Zkgd8aaKB950UMq8+NiEhQ2Qx1r/6z/LVyKOF9ADKkzdLU3JqjEiCYdH AqQheCJc6eHrLqs1EwERw0zp7qH5jub1GmNzBJWsorZ3cHx+9/xmqvcLmowgMQeOryq7 OmokR/k2kD0xjiDWAALf1ERfFdV0muHKfBPSxL8kBbc+vNWRrvcxGVg6LVSjpVmFN2tV mvlKcIXV+vkWYpLv1nY/nioIQ2IN8oUySADqsyRp0BrvvxSiwvKGnrrLLt8o0qZgocZq f4Zg== Received: by 10.68.138.133 with SMTP id qq5mr915272pbb.86.1347991595678; Tue, 18 Sep 2012 11:06:35 -0700 (PDT) Received: by 10.68.138.133 with SMTP id qq5mr915256pbb.86.1347991595450; Tue, 18 Sep 2012 11:06:35 -0700 (PDT) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id pn4sm326274pbb.50.2012.09.18.11.06.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Sep 2012 11:06:32 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: libbacktrace patch committed: Add some mingw support Date: Tue, 18 Sep 2012 11:06:31 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQk0C9u19iKEGMgSR4SS/m44H4xe1uSrF3Dl8IsH4UMD4al3B07ECI0bf3T3HnCKn3CA9qUksahwHzCJ/tUUkLeyO9oqQNZY0P48dWKwh8xb5iz+HNJ7TWhwi1Q9JiwdNTem4llTifPdNHGt2ve8WYBS7pRaHUcnmacUYoAN3cd5rRPqaskeUBi8W6o0U1npHB0TlTORLFoToYpmfoRovSrsHbDcUQ== X-IsSubscribed: yes 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 This patch to libbacktrace adds some support for mingw. The executable is opened with O_BINARY. The fcntl function is not called. Bootstrapped and ran libbacktrace testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian 2012-09-18 Ian Lance Taylor * posix.c (O_BINARY): Define if not defined. (backtrace_open): Pass O_BINARY to open. Only call fcntl if HAVE_FCNTL is defined. * configure.ac: Test for the fcntl function. * configure, config.h.in: Rebuild. Index: posix.c =================================================================== --- posix.c (revision 191432) +++ posix.c (working copy) @@ -41,6 +41,10 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "backtrace.h" #include "internal.h" +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif @@ -57,18 +61,20 @@ backtrace_open (const char *filename, ba { int descriptor; - descriptor = open (filename, O_RDONLY | O_CLOEXEC); + descriptor = open (filename, O_RDONLY | O_BINARY | O_CLOEXEC); if (descriptor < 0) { error_callback (data, filename, errno); return -1; } +#ifdef HAVE_FCNTL /* Set FD_CLOEXEC just in case the kernel does not support O_CLOEXEC. It doesn't matter if this fails for some reason. FIXME: At some point it should be safe to only do this if O_CLOEXEC == 0. */ fcntl (descriptor, F_SETFD, FD_CLOEXEC); +#endif return descriptor; } Index: configure.ac =================================================================== --- configure.ac (revision 191435) +++ configure.ac (working copy) @@ -201,6 +201,20 @@ if test "$ALLOC_FILE" = "alloc.lo"; then fi AC_SUBST(BACKTRACE_USES_MALLOC) +# Check for the fcntl function. +if test -n "${with_target_subdir}"; then + case "${host}" in + *-*-mingw*) have_fcntl=no ;; + *) have_fcntl=yes ;; + esac +else + AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) +fi +if test "$have_fcntl" = "yes"; then + AC_DEFINE([HAVE_FCNTL], 1, + [Define to 1 if you have the fcntl function]) +fi + AC_CHECK_DECLS(strnlen) AC_CACHE_CHECK([whether tests can run],