Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/platform.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/platform.c
r3232 r3621 18 18 #endif 19 19 20 #ifndef HAVE_USLEEP 21 int 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 20 38 #ifndef HAVE_VASPRINTF 21 39 int FAST_FUNC vasprintf(char **string_ptr, const char *format, va_list p) … … 29 47 va_end(p); 30 48 49 /* Note: can't use xstrdup/xmalloc, they call vasprintf (us) on failure! */ 50 31 51 if (r < 128) { 32 52 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); 39 59 va_end(p2); 40 60 … … 175 195 } 176 196 #endif 197 198 #ifndef HAVE_TTYNAME_R 199 int 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.