From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110204 invoked by alias); 9 Jul 2015 20:36:22 -0000 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 Received: (qmail 110187 invoked by uid 89); 9 Jul 2015 20:36:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: e33.co.us.ibm.com Received: from e33.co.us.ibm.com (HELO e33.co.us.ibm.com) (32.97.110.151) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 09 Jul 2015 20:36:20 +0000 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Jul 2015 14:36:18 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Jul 2015 14:36:16 -0600 X-MailFrom: bergner@vnet.ibm.com X-RcptTo: gdb-patches@sourceware.org Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 0A2B51FF0042 for ; Thu, 9 Jul 2015 14:27:26 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t69KZUdi56164422 for ; Thu, 9 Jul 2015 13:35:30 -0700 Received: from d03av02.boulder.ibm.com (localhost [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t69KaFZu024476 for ; Thu, 9 Jul 2015 14:36:15 -0600 Received: from [9.65.235.64] (sig-9-65-235-64.ibm.com [9.65.235.64]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t69KaEUY024392; Thu, 9 Jul 2015 14:36:14 -0600 Subject: [PATCH] Fix build issue due to Introduce nat/linux-namespaces.[ch] patch From: Peter Bergner To: "gdb-patches@sourceware.org" Cc: Gary Benson Content-Type: text/plain; charset="UTF-8" Date: Thu, 09 Jul 2015 20:36:00 -0000 Message-ID: <1436474110.5367.27.camel@otta> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15070920-0009-0000-0000-00000C58770D X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00306.txt.bz2 I have a toolchain that dies building gdb with the following error: /home/bergner/binutils/binutils-gdb/gdb/nat/linux-namespaces.c:39:1: error: static declaration of ‘setns’ follows non-static declaration setns (int fd, int nstype) ^ In file included from /opt/at7.0/include/sched.h:41:0, from /home/bergner/binutils/binutils-gdb/gdb/nat/linux-namespaces.c:30: /opt/at7.0/include/bits/sched.h:91:12: note: previous declaration of ‘setns’ was here extern int setns (int __fd, int __nstype) __THROW; ^ make[2]: *** [linux-namespaces.o] Error 1 My configure doesn't define HAVE_SETNS because my glibc defines __stub_setns, so nat/linux-namespaces.c defines its own setns routine. However, my glibc also has its sched.h with a extern prototype for setns, which conflicts with this static version linux-namespaces.c is creating, so we get the error above. How about the following patch to work around the error? I can confirm that it fixes the problem on my multiple systems that do and do not have setns. Ok for trunk? Peter * nat/linux-namespaces.c (setns): Rename from this ... (do_setns): ... to this. Support calling setns if it exists. (mnsh_handle_setns): Call do_setns. diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c index a7a3e4d..c2f0d2e 100644 --- a/gdb/nat/linux-namespaces.c +++ b/gdb/nat/linux-namespaces.c @@ -34,18 +34,20 @@ int debug_linux_namespaces; /* Handle systems without setns. */ -#ifndef HAVE_SETNS -static int -setns (int fd, int nstype) +static inline int +do_setns (int fd, int nstype) { -#ifdef __NR_setns - return syscall (__NR_setns, fd, nstype); +#ifdef HAVE_SETNS + return setns (fd, nstype); #else +# ifdef __NR_setns + return syscall (__NR_setns, fd, nstype); +# else errno = ENOSYS; return -1; +# endif #endif } -#endif /* Handle systems without MSG_CMSG_CLOEXEC. */ @@ -495,7 +497,7 @@ mnsh_recv_message (int sock, enum mnsh_msg_type *type, static ssize_t mnsh_handle_setns (int sock, int fd, int nstype) { - int result = setns (fd, nstype); + int result = do_setns (fd, nstype); return mnsh_return_int (sock, result, errno); }