bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Jay K <jayk123@hotmail.com>, Larkin Nickle <me@larbob.org>
Subject: Re: getprocname Tru64
Date: Tue, 29 Jun 2021 17:04:23 +0200	[thread overview]
Message-ID: <10419687.R7EI6JQ4AT@omega> (raw)
In-Reply-To: <MWHPR1401MB1951D63EFD26D7743712729EE6029@MWHPR1401MB1951.namprd14.prod.outlook.com>

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



  reply	other threads:[~2021-06-29 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29  8:17 Makefile operator -ot generate-parse-datetime tru64 Jay K
2021-06-29  8:24 ` getprocname Tru64 Jay K
2021-06-29 15:04   ` Bruno Haible [this message]
2021-07-06 11:25     ` Jay K
2021-06-29 14:52 ` Makefile operator -ot generate-parse-datetime tru64 Bruno Haible
2021-07-01 17:41 ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10419687.R7EI6JQ4AT@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=jayk123@hotmail.com \
    --cc=me@larbob.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).