From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30274 invoked by alias); 27 Jan 2012 10:02:14 -0000 Received: (qmail 30218 invoked by uid 22791); 27 Jan 2012 10:02:11 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_SM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Jan 2012 10:01:51 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0RA1mGe020879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Jan 2012 05:01:48 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0RA1kSu027015; Fri, 27 Jan 2012 05:01:47 -0500 Message-ID: <4F22760A.2020309@redhat.com> Date: Fri, 27 Jan 2012 10:28:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: Eli Zaretskii CC: asmwarrior , gdb-patches@sourceware.org Subject: Re: fix build error on MinGW (HAVE_READLINK) undefined References: <4F2206DE.20907@gmail.com> <83k44dzejs.fsf@gnu.org> In-Reply-To: <83k44dzejs.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00940.txt.bz2 On 01/27/2012 09:21 AM, Eli Zaretskii wrote: >> Date: Fri, 27 Jan 2012 10:07:26 +0800 >> From: asmwarrior >> >> diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c >> index 34e4fa8..7575fb1 100644 >> --- a/gdb/gdbserver/hostio.c >> +++ b/gdb/gdbserver/hostio.c >> @@ -459,6 +459,7 @@ handle_unlink (char *own_buf) >> static void >> handle_readlink (char *own_buf, int *new_packet_len) >> { >> +#if defined (HAVE_READLINK) && defined (PATH_MAX) You need to teach config.h about HAVE_READLINK. Add readlink to AC_CHECK_FUNCS in gdbserver/configure.ac, and regenerate (autoconf/autoheader). >> char filename[PATH_MAX], linkname[PATH_MAX]; >> char *p; >> int ret, bytes_sent; >> @@ -485,6 +486,10 @@ handle_readlink (char *own_buf, int *new_packet_len) >> to return a partial response, but simply fail. */ >> if (bytes_sent < ret) >> sprintf (own_buf, "F-1,%x", FILEIO_ENAMETOOLONG); >> +#else >> + hostio_error (own_buf); >> + return; >> +#endif > > I think you need to set errno to EINVAL in the #else branch, because > the meaning of that error on systems that do have readlink is "the > named file is not a symbolic link". > > On second thought, perhaps a better way would be to define a readlink > for MinGW that always sets errno to EINVAL and returns -1. Then the > ugly #ifdef can go away. The corresponding native side returns ENOSYS/FILEIO_ENOSYS, indicating the function is not supported by the implementation. GDBserver should do the same. > >> static char * >> inf_child_fileio_readlink (const char *filename, int *target_errno) >> { >> /* We support readlink only on systems that also provide a compile-time >> maximum path length (MAXPATHLEN), at least for now. */ >> #if defined (HAVE_READLINK) && defined (MAXPATHLEN) >> char buf[MAXPATHLEN]; >> int len; >> char *ret; >> >> len = readlink (filename, buf, sizeof buf); > > Here too. The #else branch just below reads: #else *target_errno = FILEIO_ENOSYS; return NULL; #endif -- Pedro Alves