From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 03A1E384B835 for ; Thu, 20 Oct 2022 18:26:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03A1E384B835 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1035.google.com with SMTP id f9-20020a17090a654900b00210928389f8so4332954pjs.2 for ; Thu, 20 Oct 2022 11:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mKnW4kS3gT9rA1UAlTAosnFdYlqn4ovw3lG9e00/lk4=; b=LWBLNwWtdglteySoIqbeNr/17t3z8orCwrnBjgPcgaMDf6e7p3/XWqhb276+CvD8F1 S1/Wpdi0CYV+tqL8tQpkVTWvB1DcqFBp5SvL0eUAoB1X6v+93Aq5faBDBDaKGsu+uzH/ aXDUTxtpU/AYVFPOLL6bqKDwRwQpwgPUfyQkhkjI/UNJr6pyvN/ourC6k2WqkWwV4YTf EPQ5hiCfUN6NygJxElr8feQO8e+oN+A7VmJYLoLulfxcmp18t5iXzWqx6DdN/zK+IWnD 6PLHDKF1+yWo/0BYbOvUvHLvXb9QMim0aGK7xyzNi9qUmxmstSFeoIqs0lIg6OW97WAl ORzQ== 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=mKnW4kS3gT9rA1UAlTAosnFdYlqn4ovw3lG9e00/lk4=; b=XZ3r9S1Nxn6r2zJrLN/VJc3VId0rk6myb2vGFIOibKzjD7bkiECiGTusUM9iSFxxfY twXoqOYRbJoN9y6ZqHlpO0Gh2UcpBOZjWhvauIYP7hN0Y1qwJ+2B0wfI6fvQwuJFkg4W IxuIxTsP4GmZIeGZ5qKzhktHYDJAM13ccNk9WvdaKsPvVtabT3H9w0AbMzBuP7tCMSbn TCBxQkyoZMOtD89ztNMjPuqzoPjfx0qPoIGtI2MsBSYVK2SbpwmGppmla9nzLV52GzZu Z/5twyQVJ1oWm9gYfP8Ms7rlwc0Rh7v8JayBceLEuxRQPxJFuWnfjjRpzIorUE2T+RJp wgsQ== X-Gm-Message-State: ACrzQf2czvwSOF0LF1rW4LrWNPT0zjHDYm9/XaWE8uEv6JUaUCR+oG1G KFcSL5YKmuO4CmbmaY7X8LvbLVC4xqAkBA== X-Google-Smtp-Source: AMsMyM4rF3GPZVHR1QLveSZtPFHLRojQAeI2nULN7dk3ADohQ0xnaCMLtBDDJHCWTBzzjTVVd7UQaQ== X-Received: by 2002:a17:90b:180f:b0:20d:4e7f:5f52 with SMTP id lw15-20020a17090b180f00b0020d4e7f5f52mr54129138pjb.119.1666290417520; Thu, 20 Oct 2022 11:26:57 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id w15-20020a17090a460f00b00202fbd9c21dsm115067pjg.48.2022.10.20.11.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:26:56 -0700 (PDT) From: Yonggang Luo To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH 16/25] libeu: Move the implementation of pwrite_retry, write_retry and pread_retry from header to source Date: Fri, 21 Oct 2022 02:25:55 +0800 Message-Id: <20221020182603.815-17-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221020182603.815-1-luoyonggang@gmail.com> References: <20221020182603.815-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,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 List-Id: Signed-off-by: Yonggang Luo --- lib/Makefile.am | 2 +- lib/system.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/system.h | 59 ++++----------------------------- 3 files changed, 94 insertions(+), 54 deletions(-) create mode 100644 lib/system.c diff --git a/lib/Makefile.am b/lib/Makefile.am index 42ddf5ae..7a50085b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -35,7 +35,7 @@ noinst_LIBRARIES =3D libeu.a =20 libeu_a_SOURCES =3D xasprintf.c xstrdup.c xstrndup.c xmalloc.c next_prime.= c \ crc32.c crc32_file.c \ - color.c error.c printversion.c + color.c error.c printversion.c system.c =20 noinst_HEADERS =3D fixedsizehash.h libeu.h system.h dynamicsizehash.h list= .h \ eu-config.h color.h printversion.h bpf.h \ diff --git a/lib/system.c b/lib/system.c new file mode 100644 index 00000000..0fd28968 --- /dev/null +++ b/lib/system.c @@ -0,0 +1,87 @@ +/* Definitions for system functions.=0D + Copyright (C) 2006-2011 Red Hat, Inc.=0D + Copyright (C) 2022 Mark J. Wielaard =0D + Copyright (C) 2022 Yonggang Luo =0D + This file is part of elfutils.=0D +=0D + This file is free software; you can redistribute it and/or modify=0D + it under the terms of either=0D +=0D + * the GNU Lesser General Public License as published by the Free=0D + Software Foundation; either version 3 of the License, or (at=0D + your option) any later version=0D +=0D + or=0D +=0D + * the GNU General Public License as published by the Free=0D + Software Foundation; either version 2 of the License, or (at=0D + your option) any later version=0D +=0D + or both in parallel, as here.=0D +=0D + elfutils is distributed in the hope that it will be useful, but=0D + WITHOUT ANY WARRANTY; without even the implied warranty of=0D + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU=0D + General Public License for more details.=0D +=0D + You should have received copies of the GNU General Public License and=0D + the GNU Lesser General Public License along with this program. If=0D + not, see . */=0D +=0D +#include "system.h"=0D +=0D +ssize_t=0D +pwrite_retry(int fd, const void *buf, size_t len, off_t off)=0D +{=0D + ssize_t recvd =3D 0;=0D +=0D + do=0D + {=0D + ssize_t ret =3D TEMP_FAILURE_RETRY (pwrite (fd, ((char *)buf) + recv= d, len - recvd,=0D + off + recvd));=0D + if (ret <=3D 0)=0D + return ret < 0 ? ret : recvd;=0D +=0D + recvd +=3D ret;=0D + }=0D + while ((size_t) recvd < len);=0D +=0D + return recvd;=0D +}=0D +=0D +ssize_t=0D +write_retry(int fd, const void *buf, size_t len)=0D +{=0D + ssize_t recvd =3D 0;=0D +=0D + do=0D + {=0D + ssize_t ret =3D TEMP_FAILURE_RETRY (write (fd, ((char *)buf) + recvd= , len - recvd));=0D + if (ret <=3D 0)=0D + return ret < 0 ? ret : recvd;=0D +=0D + recvd +=3D ret;=0D + }=0D + while ((size_t) recvd < len);=0D +=0D + return recvd;=0D +}=0D +=0D +ssize_t=0D +pread_retry(int fd, void *buf, size_t len, off_t off)=0D +{=0D + ssize_t recvd =3D 0;=0D +=0D + do=0D + {=0D + ssize_t ret =3D TEMP_FAILURE_RETRY (pread (fd, ((char *)buf) + recvd= , len - recvd,=0D + off + recvd));=0D + if (ret <=3D 0)=0D + return ret < 0 ? ret : recvd;=0D +=0D + recvd +=3D ret;=0D + }=0D + while ((size_t) recvd < len);=0D +=0D + return recvd;=0D +}=0D diff --git a/lib/system.h b/lib/system.h index 264781c2..05b2d8f9 100644 --- a/lib/system.h +++ b/lib/system.h @@ -145,61 +145,14 @@ startswith (const char *str, const char *prefix) #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 06= 66 */ #endif =20 -static inline ssize_t __attribute__ ((unused)) -pwrite_retry (int fd, const void *buf, size_t len, off_t off) -{ - ssize_t recvd =3D 0; - - do - { - ssize_t ret =3D TEMP_FAILURE_RETRY (pwrite (fd, ((char *)buf) + recv= d, len - recvd, - off + recvd)); - if (ret <=3D 0) - return ret < 0 ? ret : recvd; +ssize_t +pwrite_retry (int fd, const void *buf, size_t len, off_t off); =20 - recvd +=3D ret; - } - while ((size_t) recvd < len); - - return recvd; -} +ssize_t +write_retry (int fd, const void *buf, size_t len); =20 -static inline ssize_t __attribute__ ((unused)) -write_retry (int fd, const void *buf, size_t len) -{ - ssize_t recvd =3D 0; - - do - { - ssize_t ret =3D TEMP_FAILURE_RETRY (write (fd, ((char *)buf) + recvd= , len - recvd)); - if (ret <=3D 0) - return ret < 0 ? ret : recvd; - - recvd +=3D ret; - } - while ((size_t) recvd < len); - - return recvd; -} - -static inline ssize_t __attribute__ ((unused)) -pread_retry (int fd, void *buf, size_t len, off_t off) -{ - ssize_t recvd =3D 0; - - do - { - ssize_t ret =3D TEMP_FAILURE_RETRY (pread (fd, ((char *)buf) + recvd= , len - recvd, - off + recvd)); - if (ret <=3D 0) - return ret < 0 ? ret : recvd; - - recvd +=3D ret; - } - while ((size_t) recvd < len); - - return recvd; -} +ssize_t +pread_retry (int fd, void *buf, size_t len, off_t off); =20 /* The demangler from libstdc++. */ extern char *__cxa_demangle (const char *mangled_name, char *output_buffer, --=20 2.36.1.windows.1