From: Junio C Hamano <gitster@pobox.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Ben Walton <bdwalton@gmail.com>,
Karsten Blees <karsten.blees@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Do not make trace.c/getnanotime an inlined function
Date: Mon, 29 Sep 2014 10:48:28 -0700 [thread overview]
Message-ID: <xmqqa95iuxlf.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: CACsJy8ArOU7WF4fiy5vn8zq5y6Vm5JxgTf+Tiai_WOeMSj--Ug@mail.gmail.com
Duy Nguyen <pclouds@gmail.com> writes:
> On Sun, Sep 28, 2014 at 2:50 PM, Ben Walton <bdwalton@gmail.com> wrote:
>> Oracle Studio compilers don't allow for static variables in functions
>> that are defined to be inline. GNU C does permit this. Let's reference
>> the C99 standard though, which doesn't allow for inline functions to
>> contain modifiable static variables.
>>
>> Signed-off-by: Ben Walton <bdwalton@gmail.com>
>> ---
>> trace.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/trace.c b/trace.c
>> index b6f25a2..4778608 100644
>> --- a/trace.c
>> +++ b/trace.c
>> @@ -385,7 +385,7 @@ static inline uint64_t gettimeofday_nanos(void)
>> * Returns nanoseconds since the epoch (01/01/1970), for performance tracing
>> * (i.e. favoring high precision over wall clock time accuracy).
>> */
>> -inline uint64_t getnanotime(void)
>> +uint64_t getnanotime(void)
>> {
>> static uint64_t offset;
>
> Would moving this offset outside getnanotime() work?
I am not sure what the definition of "work" is.
The function computes the difference between the returned value from
gettimeofday(2) and a custom highres_nanos() just once and returns
the value it got from gettimeofday the first time, and then for
subsequent calls massages the returned value from highres_nanos() to
be consistent with the value returned from gettimeofday using the
offset it computed in the first call.
If we have two copies of this function, two independent probes to
these pair of underlying functions will be made to compute their
offsets. With perfect pair of clocks that may not matter, but it
just feels wrong to me.
Besides, I wonder what happens if the computed offset happen to be
1, which is used as a sentinel.
next prev parent reply other threads:[~2014-09-29 17:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-28 7:50 [PATCH] Do not make trace.c/getnanotime an inlined function Ben Walton
2014-09-28 19:15 ` Johannes Sixt
[not found] ` <CAP30j14QGtHC7huU=3t4sJT_dZ3t9V=CBWyGyJW7EjT9H5ZK9w@mail.gmail.com>
2014-09-29 20:40 ` Johannes Sixt
2014-09-29 12:44 ` Duy Nguyen
2014-09-29 17:48 ` Junio C Hamano [this message]
2014-09-30 9:25 ` Duy Nguyen
2014-09-30 15:54 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqa95iuxlf.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=bdwalton@gmail.com \
--cc=git@vger.kernel.org \
--cc=karsten.blees@gmail.com \
--cc=pclouds@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.