Mailing List Archive

Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer?
>
>
> > From: Tim Oborne <toborne@systems.DHL.COM>
> >
> > Thanks for the update. I'm trying to get clock ticks finer than one
> > second, is there any way other than wrappering my own version of the
> > POSIX times() ?
>
> I don't see how you can get finer granularity than your CPU supports.
> That's generally defined as _SC_CLK_TCK, found in <unistd.h> (CLK_TCK in
> <time.h>). Perl uses your OS's times() function, so it's already getting
> the best your machine can give.
>
> However now that you've made me look at it again Perl's times() function
> isn't returning everything it should return, though this doesn't affect the
> granularity you're looking for. It should return five values, not four. It
> needs to return the realtime as well as the four 'struct tms' fields. I've
> cc'd perl5-porters for this discussion.

times(2) on solaris is supposed to return ticks, but perl converts it to
seconds. I've used Tom's old itimers.pl, which lets you syscall() to the
[sg]etitimer() functions with great success. Perhaps it oughta be in the
CPAN, if times() is gonna stay the way it is.


Bill
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
> From: Tim Oborne <toborne@systems.DHL.COM>
>
> Thanks for the update. I'm trying to get clock ticks finer than one
> second, is there any way other than wrappering my own version of the
> POSIX times() ?

I don't see how you can get finer granularity than your CPU supports.
That's generally defined as _SC_CLK_TCK, found in <unistd.h> (CLK_TCK in
<time.h>). Perl uses your OS's times() function, so it's already getting
the best your machine can give.

However now that you've made me look at it again Perl's times() function
isn't returning everything it should return, though this doesn't affect the
granularity you're looking for. It should return five values, not four. It
needs to return the realtime as well as the four 'struct tms' fields. I've
cc'd perl5-porters for this discussion.


Dean
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
> From: wmiddlet@mv.us.adobe.com (Bill Middleton)

> times(2) on solaris is supposed to return ticks, but perl converts it to
> seconds. I've used Tom's old itimers.pl, which lets you syscall() to the
> [sg]etitimer() functions with great success. Perhaps it oughta be in the
> CPAN, if times() is gonna stay the way it is.

Thanks. Kinda forgot about that :)

I think we ought to adjust POSIX::times() to be an XSUB and return
everything that POSIX specifies, as POSIX specifies. I'll put a patch
together this week, while I'm adjusting the POSIX doc, if I don't see
objections.


Dean
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
I'll put itimers.pl into the scripts/date_and_time area tonight.

Bill
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
Tom Christiansen writes:
> >I'll put itimers.pl into the scripts/date_and_time area tonight.
> >
> >Bill
>
> Thanks!
>
> This should probably make it to cpan, but it's just a perl4 foo.pl
> library, not a perl5 Foo-1.0.tar.gz module. Is that a problem?
>
> --tom

It will make its to cpan, automagically.

++jhi;
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
Tom Christiansen writes:
> re: my old perl4 [sg]etitimers library
>
> I'd rather see this done as a properl XS module.
>
> It's looking like it's about time to think about whether we want to do
> something about the proliferation of infinite little potentially
> incompatible interfaces to the myriad C functions that have
> structures. (I saw the rusage stuff lately, but haven't looked at it.)
>
> I suggest that we should dust off Dean's Class::Template stuff. His
> code appears to be robust enough for the stat($file)->ino kind of thing
> as well. I haven't done extensive testing (it sure is short code!). I
> ran some simple tests for using it to replace the old SYS:: modules I
> did, and it seemed to work well.
>

Yes yes yes! Just today I wished for a proper utmp interface.

To be honest I do not remember this Class::Template stuff all that well.
Can it do all both the sys/libcall interfacing and the SYMBOLIC_CONSTANTS?
Handle possibly-nonexistent structure members? (fl_sysid, st_blocksize,
ut_type, ut_addr?) Icky bitfield structure members (st_pad:30, st_acl:1,
st_remote:1)?

Jarkko "rusage" Hietaniemi

++jhi;
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
re: my old perl4 [sg]etitimers library

I'd rather see this done as a properl XS module.

It's looking like it's about time to think about whether we want to do
something about the proliferation of infinite little potentially
incompatible interfaces to the myriad C functions that have
structures. (I saw the rusage stuff lately, but haven't looked at it.)

I suggest that we should dust off Dean's Class::Template stuff. His
code appears to be robust enough for the stat($file)->ino kind of thing
as well. I haven't done extensive testing (it sure is short code!). I
ran some simple tests for using it to replace the old SYS:: modules I
did, and it seemed to work well.

In fact, I think I should be able to simply define some additional
pack() and unpack() methods for the struct()s that he creates. Perhaps
just registering a template would work.

That way it would be easier to define struct itimers for use with the
syscalls. I haven't tried to return blessed objects from XS files
myself yet. Hm.. wonder what this does to Paul's arena?

--tom
Re: Invoking a POSIX function, times() - how do you get the return value and the modified buffer? [ In reply to ]
>I'll put itimers.pl into the scripts/date_and_time area tonight.
>
>Bill

Thanks!

This should probably make it to cpan, but it's just a perl4 foo.pl
library, not a perl5 Foo-1.0.tar.gz module. Is that a problem?

--tom