From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31285 invoked by alias); 13 Oct 2014 17:39:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31128 invoked by uid 89); 13 Oct 2014 17:39:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 13 Oct 2014 17:39:09 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9DHd8IZ007903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Oct 2014 13:39:08 -0400 Received: from c64.redhat.com (vpn-234-125.phx2.redhat.com [10.3.234.125]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9DHd4lr002861; Mon, 13 Oct 2014 13:39:07 -0400 From: David Malcolm To: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 1/5] libiberty: Expose choose_tmpdir, and fix constness of return type Date: Mon, 13 Oct 2014 17:39:00 -0000 Message-Id: <1413222308-25753-2-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1413222308-25753-1-git-send-email-dmalcolm@redhat.com> References: <1413222308-25753-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg01171.txt.bz2 The jit needs to create a temporary directory, so I need to expose libiberty's choose_tmpdir as a public entrypoint. include/ChangeLog: * libiberty.h (choose_tmpdir): New prototype. libiberty/ChangeLog: * choose-temp.c (choose_tmpdir): Remove now-redundant local copy of prototype. * functions.texi: Regenerate. * make-temp-file.c (choose_tmpdir): Convert return type from char * to const char * - given that this returns a pointer to a memoized allocation, the caller must not touch it. --- include/libiberty.h | 5 +++++ libiberty/choose-temp.c | 1 - libiberty/functions.texi | 13 ++++++------- libiberty/make-temp-file.c | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/libiberty.h b/include/libiberty.h index bcc1f9a..d09c9a5 100644 --- a/include/libiberty.h +++ b/include/libiberty.h @@ -227,6 +227,11 @@ extern char *make_relative_prefix (const char *, const char *, extern char *make_relative_prefix_ignore_links (const char *, const char *, const char *) ATTRIBUTE_MALLOC; +/* Returns a pointer to a directory path suitable for creating temporary + files in. */ + +extern const char *choose_tmpdir (void) ATTRIBUTE_RETURNS_NONNULL; + /* Choose a temporary directory to use for scratch files. */ extern char *choose_temp_base (void) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL; diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c index 0a454cf..8e1e84b 100644 --- a/libiberty/choose-temp.c +++ b/libiberty/choose-temp.c @@ -34,7 +34,6 @@ Boston, MA 02110-1301, USA. */ #endif #include "libiberty.h" -extern char *choose_tmpdir (void); /* Name of temporary file. mktemp requires 6 trailing X's. */ diff --git a/libiberty/functions.texi b/libiberty/functions.texi index 9323ff9..387aee0 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -125,7 +125,7 @@ Uses @code{malloc} to allocate storage for @var{nelem} objects of @end deftypefn -@c choose-temp.c:46 +@c choose-temp.c:45 @deftypefn Extension char* choose_temp_base (void) Return a prefix for temporary file names or @code{NULL} if unable to @@ -139,7 +139,7 @@ not recommended. @end deftypefn @c make-temp-file.c:96 -@deftypefn Replacement char* choose_tmpdir () +@deftypefn Replacement const char* choose_tmpdir () Returns a pointer to a directory path suitable for creating temporary files in. @@ -160,9 +160,8 @@ number of seconds used. @dots{}, @code{NULL}) Concatenate zero or more of strings and return the result in freshly -@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is -available. The argument list is terminated by the first @code{NULL} -pointer encountered. Pointers to empty strings are ignored. +@code{xmalloc}ed memory. The argument list is terminated by the first +@code{NULL} pointer encountered. Pointers to empty strings are ignored. @end deftypefn @@ -528,7 +527,7 @@ nineteen EBCDIC varying characters is tested; exercise caution.) @end ftable @end defvr -@c hashtab.c:336 +@c hashtab.c:328 @deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size}, @ htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f}, @ htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f}, @ @@ -1163,7 +1162,7 @@ control over the state of the random number generator. @end deftypefn -@c concat.c:174 +@c concat.c:160 @deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @ @dots{}, @code{NULL}) diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c index 7b74f81..244cc23 100644 --- a/libiberty/make-temp-file.c +++ b/libiberty/make-temp-file.c @@ -93,7 +93,7 @@ static char *memoized_tmpdir; /* -@deftypefn Replacement char* choose_tmpdir () +@deftypefn Replacement const char* choose_tmpdir () Returns a pointer to a directory path suitable for creating temporary files in. @@ -102,7 +102,7 @@ files in. */ -char * +const char * choose_tmpdir (void) { if (!memoized_tmpdir) -- 1.8.5.3