[v2,15/16] libelf: F_GETFD may not predefined with msvc/mingw, guard the usage of it
Message ID | 20221217165213.152-16-luoyonggang@gmail.com |
---|---|
State | Dropped |
Headers |
Return-Path: <elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C14BB3AA9422 for <patchwork@sourceware.org>; Sat, 17 Dec 2022 16:54:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C14BB3AA9422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296081; bh=kdvUToojEJX7qPBoy/cOVqvj/5wfErbx540v6xtDHyA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=WJFEAKS3k/1SkkSuq8ao5yh50jWzRrEZTfsvA/XR9kmoM0mEg3BjDcl8hCxBwMcfn mKhfRoA319/p32XXk+fEryOKB1k/QaxxS7kuHLh4tSlE12iQ4GJ+9J9nqXb4f7ZgoM O41bTKbDqvFJNO5yLDuynslm0oO8Wn3+P6MXs19s= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 664263AA9828 for <elfutils-devel@sourceware.org>; Sat, 17 Dec 2022 16:53:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 664263AA9828 Received: by mail-pl1-x629.google.com with SMTP id d15so5199732pls.6 for <elfutils-devel@sourceware.org>; Sat, 17 Dec 2022 08:53:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kdvUToojEJX7qPBoy/cOVqvj/5wfErbx540v6xtDHyA=; b=HkE0LtLhEXOZ04Zhw9RHe1KeBoaPRNZBlVFgmFUUpe4QFCCng2JIEf1T0HGnd8jrSC DPQHOED24TIbeX4AInx58dRuG5rq1rPmHiMmcUS91l4wE5wQ8/ryBYHQ+bF3Y9hWx0NX Q2/FrPn/JJvxUs3yb0rmqlTSKkMi8VjQ55NIto2JyQQjIxEadew9Celsrx4fE3fdCLz1 PcC/CqELmgKc2rDs69iEEEH+9PamkdkCtv/4qLrm2prPK1jKXvta3k/IIEy0PmrH586z s8hnCxDonNoLiFNkFzCOcKCjARtPUsw9mbK/Y7NrZ3BcfOh9KierKuxOKqAA6rysyAQ7 xMqQ== X-Gm-Message-State: ANoB5pnhm5H1KrgvZuTG8uzxcEM1jSMCjH5zSKYllv/yX5oKienPwhll cjrPFhFQV+t/NIqEH0OGP+2abUpEmNw= X-Google-Smtp-Source: AA0mqf47IGEPdC+P2r2dogYJ9l4PrbBDMJPX53BcdQBk6V+FXWtqjMnAeQaf8UVFTLSSyWEU11Ocxw== X-Received: by 2002:a17:90a:eb88:b0:219:986d:696f with SMTP id o8-20020a17090aeb8800b00219986d696fmr37668364pjy.22.1671295981155; Sat, 17 Dec 2022 08:53:01 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:53:00 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo <luoyonggang@gmail.com> Subject: [PATCH v2 15/16] libelf: F_GETFD may not predefined with msvc/mingw, guard the usage of it Date: Sun, 18 Dec 2022 00:52:12 +0800 Message-Id: <20221217165213.152-16-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> From: Yonggang Luo via Elfutils-devel <elfutils-devel@sourceware.org> Reply-To: Yonggang Luo <luoyonggang@gmail.com> Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" <elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Patches for building with mingw/gcc msvc/clang-cl
|
|
Commit Message
Yonggang Luo
Dec. 17, 2022, 4:52 p.m. UTC
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
libelf/elf_begin.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
Hi, On Sun, Dec 18, 2022 at 12:52:12AM +0800, Yonggang Luo via Elfutils-devel wrote: > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> > --- > libelf/elf_begin.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c > index 6d31882e..3d324694 100644 > --- a/libelf/elf_begin.c > +++ b/libelf/elf_begin.c > @@ -1163,12 +1163,19 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref) > if (ref != NULL) > /* Make sure the descriptor is not suddenly going away. */ > rwlock_rdlock (ref->lock); > +#if defined(F_GETFD) > else if (unlikely (fcntl (fildes, F_GETFD) == -1 && errno == EBADF)) > { > /* We cannot do anything productive without a file descriptor. */ > __libelf_seterrno (ELF_E_INVALID_FILE); > return NULL; > } > +#else > + else if (fildes < 0) > + { > + return NULL; > + } > +#endif That new return NULL is missing a __libelf_seterrno. Cheers, Mark
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c index 6d31882e..3d324694 100644 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -1163,12 +1163,19 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref) if (ref != NULL) /* Make sure the descriptor is not suddenly going away. */ rwlock_rdlock (ref->lock); +#if defined(F_GETFD) else if (unlikely (fcntl (fildes, F_GETFD) == -1 && errno == EBADF)) { /* We cannot do anything productive without a file descriptor. */ __libelf_seterrno (ELF_E_INVALID_FILE); return NULL; } +#else + else if (fildes < 0) + { + return NULL; + } +#endif switch (cmd) {