From patchwork Thu Aug 4 08:27:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 108369 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 ABCE7B6F6F for ; Thu, 4 Aug 2011 18:27:22 +1000 (EST) Received: (qmail 12024 invoked by alias); 4 Aug 2011 08:27:21 -0000 Received: (qmail 12014 invoked by uid 22791); 4 Aug 2011 08:27:20 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Aug 2011 08:27:07 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8D26E2BADC9; Thu, 4 Aug 2011 04:27:06 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id W2M44gLS577g; Thu, 4 Aug 2011 04:27:06 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 62EE12BADB0; Thu, 4 Aug 2011 04:27:06 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 537A992A55; Thu, 4 Aug 2011 04:27:06 -0400 (EDT) Date: Thu, 4 Aug 2011 04:27:06 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Pascal Obry Subject: [Ada] Use current process id to create temp filenames (windows) Message-ID: <20110804082706.GA15586@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 ensures unicity of temp filenames across processes under Windows. Tested on i686-pc-mingw32, committed on trunk 2011-08-04 Pascal Obry * adaint.c (__gnat_tmp_name): Use current process id to create temp filenames, this ensures unicity of filenames across processes. Index: adaint.c =================================================================== --- adaint.c (revision 177328) +++ adaint.c (working copy) @@ -1177,13 +1177,15 @@ #elif defined (__MINGW32__) { char *pname; + char prefix[25]; /* tempnam tries to create a temporary file in directory pointed to by TMP environment variable, in c:\temp if TMP is not set, and in directory specified by P_tmpdir in stdio.h if c:\temp does not exist. The filename will be created with the prefix "gnat-". */ - pname = (char *) _tempnam ("c:\\temp", "gnat-"); + sprintf (prefix, "gnat-%d-", (int)getpid()); + pname = (char *) _tempnam ("c:\\temp", prefix); /* if pname is NULL, the file was not created properly, the disk is full or there is no more free temporary files */