From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 105A5385841D for ; Fri, 20 Aug 2021 20:24:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 105A5385841D Received: by mail-ej1-x632.google.com with SMTP id e21so6571258ejz.12 for ; Fri, 20 Aug 2021 13:24:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=48/Xx00Rmti8bCr7rq7uWFtYaZBIIE6NUsgmHRvdlaY=; b=HWYGYHyRbh5lwRvaAKETrop2OZOlyfLnxykITdy/K4/kfOZc3StVsedkij+xdWJeDA QcXmjbLrE5Nri2Z8iU6NtDVIdnqt6Bw9GaLOcFi4tCP6cSVN7h03Ng3klhqDqDrxPUHj esEpAFRD8VAsQqmgjlhpDtTL5N5iMoJ8GMFUf8wiGqPOfVph3WTxhUB55E3u1EmpW8s3 9pM6o6vzj8doUVTykLz7kejKjkxxIg5EYDph32aWRwrmk+FE43sAWv8+ZYtyOI052pFv vRF0+MEry6++Z9ogSBYvEdhTC2Dov8qxwH/bxvD7UwCLbOFIDwg15dZ7VoKVrgb9smN/ GUlg== X-Gm-Message-State: AOAM530bBxBiumHVaijHOC2MSnUs0dv1sP5pL6VANMxKeKlKISMDD+9j KS4RObDuU22CU05wCQNqI4Sq3X3/cj4YMhaKnRJsOzw5GGg= X-Google-Smtp-Source: ABdhPJzt92ZHYkmJ9d1NkdAQQMF1iUwBCQ+GnWJT41GENvFBsXcE8ccsXwhRQX8mhrjpwKxoXrryJfCtmSuSi8547oM= X-Received: by 2002:a17:906:c443:: with SMTP id ck3mr22784754ejb.195.1629491038386; Fri, 20 Aug 2021 13:23:58 -0700 (PDT) MIME-Version: 1.0 References: <20210820182300.2842423-1-abdulras@google.com> In-Reply-To: <20210820182300.2842423-1-abdulras@google.com> From: Saleem Abdulrasool Date: Fri, 20 Aug 2021 13:23:42 -0700 Message-ID: Subject: Re: [PATCH] handle libc implemntations which do not provide `error.h` To: elfutils-devel@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-27.7 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Aug 2021 20:24:10 -0000 Hi, Sorry, this change is missing a modification that I seemed to have left out accidentally. I missed the inclusion of `err.h` in the `HAVE_ERR_H` when I was staging the changes locally. I'll send out a new version of this patch. On Fri, Aug 20, 2021 at 11:23 AM Saleem Abdulrasool wrote: > > Introduce a configure time check for the presence of `error.h`. In the > case that `error.h` is not available, we can fall back to `err.h`. > Although `err.h` is not a C standard header (it is a BSD extension), > many libc implementations provide. If there are targets which do not > provide an implementation of `err.h`, it would be possible to further > extend the implementation to be more portable. > > This resolves PR21008. > > Signed-off-by: Saleem Abdulrasool > --- > configure.ac | 3 +++ > lib/system.h | 23 ++++++++++++++++++++++- > 2 files changed, 25 insertions(+), 1 deletion(-) > > diff --git a/configure.ac b/configure.ac > index 7caff2c5..177bb1a2 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -431,6 +431,9 @@ AC_CHECK_DECLS([reallocarray],[],[], > > AC_CHECK_FUNCS([process_vm_readv]) > > +AC_CHECK_HEADERS([error.h]) > +AC_CHECK_HEADERS([err.h]) > + > old_CFLAGS="$CFLAGS" > CFLAGS="$CFLAGS -D_GNU_SOURCE" > AC_FUNC_STRERROR_R() > diff --git a/lib/system.h b/lib/system.h > index 58d9deee..8adb5848 100644 > --- a/lib/system.h > +++ b/lib/system.h > @@ -29,8 +29,9 @@ > #ifndef LIB_SYSTEM_H > #define LIB_SYSTEM_H 1 > > +#include > + > #include > -#include > #include > #include > #include > @@ -40,6 +41,26 @@ > #include > #include > > +#if defined(HAVE_ERROR_H) > +#include > +#elif defined(HAVE_ERR_H) > +static int error_message_count = 0; > + > +static inline void error(int status, int errnum, const char *format, ...) { > + va_list argp; > + > + va_start(argp, format); > + verr(status, format, argp); > + va_end(argp); > + > + if (status) > + exit(status); > + ++error_message_count; > +} > +#else > +#error "err.h or error.h must be available" > +#endif > + > #if __BYTE_ORDER == __LITTLE_ENDIAN > # define LE32(n) (n) > # define LE64(n) (n) > -- > 2.33.0.rc2.250.ged5fa647cd-goog >