RE: Porting git to HP NonStop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks

There another API missing on HP NonStop and that is setitimer(), used in progress.c and build/log.c
I do have a homebrewed implementation, on top of alarm(), it goes like this:

#include "../git-compat-util.h"
#undef getitimer
#undef setitimer


int
git_getitimer(int which, struct itimerval *value)
{
        int ret = 0;

        switch (which) {
                case ITIMER_REAL:
                        value->it_value.tv_usec = 0;
                        value->it_value.tv_sec = alarm(0);
                        ret = 0; /* if alarm() fails we get a SIGLIMIT */
                        break;
                case ITIMER_VIRTUAL: /* FALLTHRU */
                case ITIMER_PROF: errno = ENOTSUP; ret = -1; break;
                default: errno = EINVAL; ret = -1;
        }
        return ret;
}

int
git_setitimer(int which, const struct itimerval *value,
                        struct itimerval *ovalue)
{
        int ret = 0;

        if (!value
                || value->it_value.tv_usec < 0
                || value->it_value.tv_usec > 1000000
                || value->it_value.tv_sec < 0) {
                errno = EINVAL;
                return -1;
        }

        else if (ovalue)
                if (!git_getitimer(which, ovalue))
                        return -1; /* errno set in git_getitimer() */

        else
        switch (which) {
                case ITIMER_REAL:
                        alarm(value->it_value.tv_sec +
                                (value->it_value.tv_usec > 0) ? 1 : 0);
                        ret = 0; /* if alarm() fails we get a SIGLIMIT */
                        break;
                case ITIMER_VIRTUAL: /* FALLTHRU */
                case ITIMER_PROF: errno = ENOTSUP; ret = -1; break;
                default: errno = EINVAL; ret = -1;
        }

        return ret;
}


Worth being added to compat/, e.g. as setitimer.c, or, as itimer.c (as a by-product, it has getitimer() too)?

Bye, Jojo

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]