From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 97AD01F8C6 for ; Tue, 29 Jun 2021 15:06:35 +0000 (UTC) Received: from localhost ([::1]:33872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyFJq-0005pm-By for normalperson@yhbt.net; Tue, 29 Jun 2021 11:06:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyFHz-00040H-Cd for bug-gnulib@gnu.org; Tue, 29 Jun 2021 11:04:39 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.160]:19762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyFHw-0006ec-On for bug-gnulib@gnu.org; Tue, 29 Jun 2021 11:04:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1624979064; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=zCWuwvYBwt800qYnGWloIiLHwIKFdyWrUrRkSRECAfw=; b=N/1x0hLIqeascTAQXAUUS+IVhExzWQLB7ucuMmmSa3Oi6PLdl2YKt0Xo+qUXE+DcfV XO7Zxn1HKqikiQNpgfSHm9O9dGDelJDO3wlZLA5B87xp8K4zJig77x6O7T15goCHGY3a a/vWoX8UJFqi6hmRc7e6vTYaHOKG6Ln22sdtwbWyD+zzak5N0BIksKp+Kg79YJrYobCS /mb/YDDHbArScuyP109qSLq0XlkfgQKiF5uvkaEu6yWfhp6PYSBhclvH1nTQIIb/eaHU WgxaOiHs1UDM+fbAwW/RxYAjxmRrVA8viTSio+qpZgrleTRPhL0+Y17NLZgarx1oL+V4 j0dA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf9yfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.27.5 DYNA|AUTH) with ESMTPSA id a03c9ax5TF4OSse (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Tue, 29 Jun 2021 17:04:24 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: getprocname Tru64 Date: Tue, 29 Jun 2021 17:04:23 +0200 Message-ID: <10419687.R7EI6JQ4AT@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.160; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jay K , Larkin Nickle Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Jay K wrote: > I see I lost the race here, but here is my rendition of getprogname for Tru64, much more efficient. > > > diff -c getprogname.c.orig getprogname.c > *** getprogname.c.orig Tue Jun 29 03:46:44 2021 > --- getprogname.c Tue Jun 29 03:48:55 2021 > *************** > *** 283,288 **** > --- 283,291 ---- > close (fd); > } > return "?"; > + # elif defined __osf__ > + extern char** __Argv; > + return last_component (__Argv[0]); > # else But it seems that the use '__Argv' can cause link-time errors on Tru64. [1] > I came to this by: > 1: Looked in old gcc to find: > #define MD_STARTFILE_PREFIX "/usr/lib/cmplrs/cc/" > > 2: grep/nm/dis there. > > I had hoped to step through the startup but haven't learned this dbx yet. In other words, it's undocumented. In Gnulib, we avoid to rely on undocumented stuff when possible. In some cases it is unavoidable, but here we already have an implementation of getprogname() for OSF/1. > There is also maybe "auxv" stuff. That's not good. The result would not only depend on which executable is running, but on how it was invoked (shell, emulator, valgrind, etc.). > I find the proc file system kinda gross and inefficient but yeah. If it's inefficient, you can add caching via a 'static' variable. Like we already do in the implementations for AIX and HP-UX. Bruno [1] https://stat.ethz.ch/pipermail/r-help//2004-January/044699.html