Getting nanoseconds in a process

R

Richard

Nelu said:
Thank you.

I know about the double negatives and about "not either" but I wasn't
sure it applied here.

But why are you not taking this to a language group where your question
is on topic and you will get a CORRECT response. Do you know what a sock
puppet it?
 
R

Richard

Keith Thompson said:
CBFalconer said:
Nate said:
... snip ...

I see no specification for time_t, other than arithmetic type,
so that conversion is probably accurate. However, there is no
specification whatsoever for suseconds_t.

The documentation for the Unix gettimeofday function says that
it is a signed integer type capable of representing the range
[-1,1000000], and the tv_usec member returned from gettimeofday
will have a value in that range. Given which, a cast to `long
int' should be good enough. (Just using %ld isn't enough,
though, because suseconds_t could also be a type smaller than
`long int'.)

While I assume you are quite correct for Unix, that discussion
belongs on comp.unix.programmer, not here.

Suppose you have a type defined (in your program, in a library, or
wherever) that's documented to be a signed integer type capable of
representing the range [-1,1000000], and a function that returns a
value of that type in that range. How can you portably print that
value? Answer: cast to long int and use "%ld". That's a perfectly
portable answer to a topical question. The fact that the type happens
to be defined by Unix doesn't make it any less so.

Which extends to what most of us are saying about ANY question which
involves an API where the question is not strictly about what the
function does rather than about how to call it and use the response in
C.
 
N

Nelu

Han said:
Hook. Line. Sinker.

Unfortunately, you were the only one who commented. I would
have preferred if certain other people did.

I advise you to go look at chapter 4 of "C Unleashed", where
you'll find the same lack of error checking on the part of
Lawrence Kirby for those two functions.

Why do you waste my time?

Check out page 115, listing 4.2 (deals with (time_t)(-1))
Also, check out page 117, listing 4.3 (deals with NULL returned by gmtime).
He clearly specifies how do to things right but then there's no point to
repeat that to get the point through.
On the other hand, you don't even bother, troll!
So all you've really done is insult Lawrence Kirby. Maybe
Heathfield ought to update his errata? Don't hold your breath.
Wrong.


It's pretty obvious from the code comment on strftime() that
I wasn't placing a premium on error checking.

Too bad, then you shouldn't give advice or learn how to do it.
Damn you people really do try hard, but one day you'll learn
I'm always ten steps ahead with a plan X, a plan Y, and a
plan Z.

Hmmm, you actually may be slow.
Look up the definition of "presumably".

You don't get the idea. You're giving advice on assumptions, which you
shouldn't. Clarify it with the OP first before launching into rants and
help him find the right channel for his question based on your own
rules. You should probably continue to be a regular troll without rules
than to just make an ass of yourself by even breaking your own.
 
R

Richard

Han from China - Master Troll said:
Oh, I found one of your most recent contributions to this
newsgroup, sockpuppet:

---------------------------------------------------------------
From: Nelu
Subject: Re: Complex numbers and printf
Date: 29 Feb 2008 16:08:59 GMT

----------------------------------------------------------------

Hah!

This sockpuppet is clearly vippstar, who appears to have left in
disgrace and then come back for a revenge mission.

real(m) ... imag(m) ... yeah, you tell 'em, vippy!

Yours,
Han from China

A couple of posters (well me) had vippstar's number from the first day
he started trying to peg himself to Heathfield's skirts.
 
N

Nelu

Han said:
You replied to me with your idiocy. If your time is so valuable,
get off comp.lang.c and go for a sail in your boat or something.

You're wasting my time by pointing me to read stuff that you can't seem
to read properly and in the right order.
Oh, I find it amusing that you didn't look at Listing 4.4. In that
we see the following:

timeval = time(NULL);
tmptr = localtime(&timeval);

So it's OK for others to cut a few corners on error returns for
the purpose of demonstration, but I'm not allowed to do so, even
though my code makes it clear I'm not checking error returns?

Again, read my post. You can cut corners after you expose the correct
functionality to the user. You haven't.
What you're saying is that if a person does "int main(void)" in
a couple of code listings, you'd be content if they wrote
"void main()" in the next few, since they've already specified
how to do things right?

No, it's one thing to write correct code without safeguards and another
thing to write incorrect standard C code. You don't seem to understand a
lot of things for someone who assumes a lot.
I took 15 minutes to give the OP the best help I could. I even
put enough there to placate the ISO crowd. Did you bother trying
to help the OP in this thread? No. You've just contributed off-
topic English garbage and uncalled-for insults.

Yes, I corrected your post. No need to re-write the things you got right.
You're simply proving my point that people insult and attack me
*first* on this newsgroup. What have I ever said to you?


Defensive, are we?

If you look back at my older posts you will see that I have a preference
for <time.h>. Do you have any problems with that? You don't have to say
anything to me. Prepare to be corrected when you're wrong. This is what
peer review is all about and you seem to advertise that in your own rules.

That's
right: Nothing. Crawl back under the rock from where you came,
you stupid sockpuppet. You haven't posted to this newsgroup
for a year and suddenly you're back in full swing just to attack
me?

.... and on the attack...

Oh... at some point you said that you haven't posted here in years and
all of the sudden you're attacking everybody. It seems I can come
whenever I want and write whatever I want. I'm just following your
principles.
 
N

Nelu

Han said:
Oh, I found one of your most recent contributions to this
newsgroup, sockpuppet:

I don't see what's wrong with that suggestion?
This sockpuppet is clearly vippstar, who appears to have left in
disgrace and then come back for a revenge mission.

Oh, my. Revenge on whom?

real(m) ... imag(m) ... yeah, you tell 'em, vippy!

I was trying to make a point to Jacob, I believe. I think he was the OP
and he is a regular here. If you're thinking about creal and cimag.
Anyway, why don't you show both posts. They are consecutive and I was
correcting myself.

Here, for your reading pleasure (you're really bad at reading):

First:
------

Is it worth doing this? I mean is there a good reason to make the
programmer remember an extra formatting option that's non standard
instead of allowing him to use what he already knows? I mean doing printf
("%f+%f*I\n",real(m),imag(m)) is not that big of an effort, is it?
However, if you really want to have this formatting option it's probably
a good idea to talk to the guys in comp.std.c and see if they are
considering something like that and whether or not your implementation
may be affected by the standard in the future.


Immediately after:
------------------

On Fri, 29 Feb 2008 16:08:59 +0000, Nelu wrote:

printf ("%f+%f*I\n",real(m),imag(m)) is not that big of an effort, is

That's probably creal and cimag. I think the real/imag forms are only
available in C++.




Isn't being a liar a bigger disgrace?
 
N

Nelu

Richard wrote:
A couple of posters (well me) had vippstar's number from the first day
he started trying to peg himself to Heathfield's skirts.

You probably missed a few posts... Who cares.
 
N

Nelu

Han said:
What the hell are you on about?

Why do I care about shutting off redirection? I don't redirect OPs or
kick them off to another newsgroup, and I don't have any intention of
doing so.

But if you don't, and the OP is not aware of other groups then how can
he get the best, peer reviewed answer? You seem to be a native english
speaker but your logic is a little shaky.
 
D

Default User

Nate said:
That's all that ISO C guarantees, true.

Which is what this group is about, and your statement certainly sounded
like you were referencing the Standard.




Brian
 
N

Nelu

Han said:
Then why would you correct it? I don't care whether you answer
that.

Because I realized that the code was bad. The suggestion was still good.
Look, vippstar, believe it or not, I too am sick of these back-and-
forth flamewars.
Good.

If you want to post "hey, and add an error check
for time() and localtime()", that's fine with me.

Even better.
You may even
find I reply with "yes, that's a good idea".
Great!

Just cut out
the other crap, and you may find I cut it out too.

Very good.
 
K

Keith Thompson

Nelu said:
Han from China - Master Troll wrote: [SNIP]

Why do you waste my time?
[...]

He's a troll; it's what he does, along with abuse, lies, and
forgeries. Arguing with him is equally a waste of your time, and
of everyone else's. Personally, I've found that the best way to
deal with him is by killfiling him.
 
N

Nelu

Han said:
Do you think he has a Heathfield shrine that he kneels by while playing
Bette Midler's "Wind Beneath My Wings" and chanting an "indeed" mantra?

Finding strength in numbers, are we?

This is so childish.
 
N

Nelu

Han said:
You must be a total dumbass if the best you can come up with is
to point out error returns in code that made it clear that error
returns weren't being handled. Talk about taking the low-hanging
fruit.

We're really out of sync here, aren't we?

It didn't make it clear to the OP.
Here's some peer review for you, idiot:

There's no real() or imag() function in my copy of the standard.

Uh, uh... you didn't get to read the message... You're excused.
Stick to your time.h error returns, because if you try anything else,
you're going to make an ass out of yourself.

The same way you are?
 
N

Nelu

Han said:
My posts sometimes get delayed and arrive out of order.
Feel free to toss some insults back if you want, but I'm done.
If you're not the person known as vippstar, that post
shouldn't trouble you too much anyway.

I don't know what vippstar means or who he is.
 
K

Keith Thompson

Anthony Fremont said:
CBFalconer said:
The word 'timespec' does not appear in the C standard. Thus no
such thing exists in the standard C language, and intimating that
it does is a pure falsity.

Where exactly did I say anything about The C Standard? Among the
very first words I wrote in this thread were, "Try this if your
using Linux:". My example code included <sys/time.h> and that's
[quite obviously IMO] the file I was referring to.
[...]

It wasn't obvious at all given the context of the article to which
Chuck was replying. Leaving topicality issues aside for the moment,
if you're going to discuss something system-specific, it's best to
identify the system in the article itself (you didn't quote the that
referred to <sys/time.h>). At the very least, ISO standard C is and
should be the default assumption here.
 
R

Richard

Default User said:
Which is what this group is about, and your statement certainly sounded
like you were referencing the Standard.




Brian

Incorrect Bwian (and please put your sig below a standard sig marker so
it can get snipped.

This group is comp.lang.c

It is for discussion of C and C related issues.
 
K

Keith Thompson

Richard Heathfield said:
Keith Thompson said:



Not so. If that were true, !!x would be equal to x in all cases, but
in fact that is only the case where x is either 0 or 1. If, for
example, x is 2, then !!x is not 2, but 1.

I think you meant to use the ~ operator in your example.

<snip>

Your correction is not unhelpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top