Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/platform.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/libbb/platform.c

    r3232 r3621  
    1818#endif
    1919
     20#ifndef HAVE_USLEEP
     21int FAST_FUNC usleep(unsigned usec)
     22{
     23    struct timespec ts;
     24    ts.tv_sec = usec / 1000000u;
     25    ts.tv_nsec = (usec % 1000000u) * 1000u;
     26    /*
     27     * If a signal has non-default handler, nanosleep returns early.
     28     * Our version of usleep doesn't return early
     29     * if interrupted by such signals:
     30     *
     31     */
     32    while (nanosleep(&ts, &ts) != 0)
     33        continue;
     34    return 0;
     35}
     36#endif
     37
    2038#ifndef HAVE_VASPRINTF
    2139int FAST_FUNC vasprintf(char **string_ptr, const char *format, va_list p)
     
    2947    va_end(p);
    3048
     49    /* Note: can't use xstrdup/xmalloc, they call vasprintf (us) on failure! */
     50
    3151    if (r < 128) {
    3252        va_end(p2);
    33         *string_ptr = xstrdup(buf);
    34         return r;
    35     }
    36 
    37     *string_ptr = xmalloc(r+1);
    38     r = vsnprintf(*string_ptr, r+1, format, p2);
     53        *string_ptr = strdup(buf);
     54        return (*string_ptr ? r : -1);
     55    }
     56
     57    *string_ptr = malloc(r+1);
     58    r = (*string_ptr ? vsnprintf(*string_ptr, r+1, format, p2) : -1);
    3959    va_end(p2);
    4060
     
    175195}
    176196#endif
     197
     198#ifndef HAVE_TTYNAME_R
     199int ttyname_r(int fd, char *buf, size_t buflen)
     200{
     201    int r;
     202    char path[sizeof("/proc/self/fd/%d") + sizeof(int)*3];
     203
     204    if (!isatty(fd))
     205        return errno == EINVAL ? ENOTTY : errno;
     206    sprintf(path, "/proc/self/fd/%d", fd);
     207    r = readlink(path, buf, buflen);
     208    if (r < 0)
     209        return errno;
     210    if (r >= buflen)
     211        return ERANGE;
     212    buf[r] = '\0';
     213    return 0;
     214}
     215#endif
Note: See TracChangeset for help on using the changeset viewer.