Lars Marowsky-Bree wrote:
> On 2006-08-15T15:41:31, Alan Robertson <[EMAIL PROTECTED]> wrote:
> 
>> Wolfgang:  Could you test this and see if it works during wraparound?
>>
>> It's not quite the same as yours, but avoids casting -1 to an unsigned.
>>  I think the effect should be the same.
> 
> Sorry, but I'm strongly biased towards this kludge. If the C library is
> at fault, it is the one which needs fixing. 
> 
> I don't want to hide errors and riddle our code with this.
> 
> I'll investigate this in more detail tomorrow, it's too late now. But
> please, don't add this ugly hack :-(

I hear what you're saying.  I find myself unconvinced by the little
you've said so far.

The times(2) system call interface is semi-broken - even in the POSIX
definition.  You can tell when you read the man page.  So, having a
cl_times() function is a good idea - for a variety of reasons.  So, a
cl_times() function is going to go in anyway (I've wanted to do this in
the past).

I'm afraid that I don't know a way to solve this widespread problem
without a kludge of some kind.

The kludge part itself is pretty mild.  I'll reproduce it below:

        int     save_errno = errno;
        errno   = 0;
        ret     = times(TIMES_PARAM);

        if (errno != 0) {
                ret = (clock_t) (-errno);
        }
        errno = save_errno;
        return (unsigned long)ret;

This is a pretty small kludge.  And, it is VERY unlikely to break on any
correctly working system.

Note that there are no documented failure returns for times(2) on Linux.
 Obviously one could fail with a bad address in TIMES_PARAM - but we
call it with either NULL or a static address of the right structure.
That leaves no documented failure return for times(2) which should occur
in this function.

Therefore any apparent failures can't be real failures.

I await your better solution of how to make this work on thousands upon
thousands of Linux systems with many dozens of kernels and versions of
glibc with great anticipation.

-- 
    Alan Robertson <[EMAIL PROTECTED]>

"Openness is the foundation and preservative of friendship...  Let me
claim from you at all times your undisguised opinions." - William
Wilberforce
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to