More removal of stuff that used long longs

This commit is contained in:
Stephen Heumann 2014-10-27 19:45:38 -05:00
parent 6c2c9d8865
commit b7676499be
6 changed files with 27 additions and 169 deletions

View File

@ -1,5 +1,5 @@
/*
* Automatically generated C config: don't edit
* Automatically generated, but now edited manually
* Busybox version: 1.22.1
*/
#define AUTOCONF_TIMESTAMP "2014-10-26 09:24:54 CDT"
@ -280,14 +280,10 @@
#define ENABLE_FEATURE_SHARED_BUSYBOX 0
#define IF_FEATURE_SHARED_BUSYBOX(...)
#define IF_NOT_FEATURE_SHARED_BUSYBOX(...) __VA_ARGS__
#define CONFIG_LFS 1
#define ENABLE_LFS 1
#ifdef MAKE_SUID
# define IF_LFS(...) __VA_ARGS__ "CONFIG_LFS"
#else
# define IF_LFS(...) __VA_ARGS__
#endif
#define IF_NOT_LFS(...)
#undef CONFIG_LFS
#define ENABLE_LFS 0
#define IF_LFS(...)
#define IF_NOT_LFS(...) __VA_ARGS__
#define CONFIG_CROSS_COMPILER_PREFIX ""
#define ENABLE_CROSS_COMPILER_PREFIX 1
#ifdef MAKE_SUID
@ -900,15 +896,15 @@
#else
# define IF_SH_MATH_SUPPORT(...) __VA_ARGS__
#endif
#define IF_NOT_SH_MATH_SUPPORT(...)
#define CONFIG_SH_MATH_SUPPORT_64 1
#define ENABLE_SH_MATH_SUPPORT_64 1
#define IF_NOT_SH_MATH_SUPPORT(...)
#undef CONFIG_SH_MATH_SUPPORT_64
#define ENABLE_SH_MATH_SUPPORT_64 0
#ifdef MAKE_SUID
# define IF_SH_MATH_SUPPORT_64(...) __VA_ARGS__ "CONFIG_SH_MATH_SUPPORT_64"
# define IF_SH_MATH_SUPPORT_64(...)
#else
# define IF_SH_MATH_SUPPORT_64(...) __VA_ARGS__
# define IF_SH_MATH_SUPPORT_64(...)
#endif
#define IF_NOT_SH_MATH_SUPPORT_64(...)
#define IF_NOT_SH_MATH_SUPPORT_64(...) __VA_ARGS__
#define CONFIG_FEATURE_SH_EXTRA_QUIET 1
#define ENABLE_FEATURE_SH_EXTRA_QUIET 1
#ifdef MAKE_SUID

View File

@ -303,10 +303,7 @@ extern int *const bb_errno;
uint64_t bb_bswap_64(uint64_t x) FAST_FUNC;
#endif
unsigned long long monotonic_ns(void) FAST_FUNC;
unsigned long long monotonic_us(void) FAST_FUNC;
unsigned long long monotonic_ms(void) FAST_FUNC;
unsigned monotonic_sec(void) FAST_FUNC;
unsigned long monotonic_sec(void) FAST_FUNC;
extern void chomp(char *s) FAST_FUNC;
extern void trim(char *s) FAST_FUNC;
@ -832,18 +829,12 @@ char *itoa(int n) FAST_FUNC;
/* Returns a pointer past the formatted number, does NOT null-terminate */
char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC;
char *itoa_to_buf(int n, char *buf, unsigned buflen) FAST_FUNC;
/* Intelligent formatters of bignums */
char *smart_ulltoa4(unsigned long long ul, char buf[4], const char *scale) FAST_FUNC;
char *smart_ulltoa5(unsigned long long ul, char buf[5], const char *scale) FAST_FUNC;
/* If block_size == 0, display size without fractional part,
* else display (size * block_size) with one decimal digit.
* If display_unit == 0, show value no bigger than 1024 with suffix (K,M,G...),
* else divide by display_unit and do not use suffix. */
#define HUMAN_READABLE_MAX_WIDTH 7 /* "1024.0G" */
#define HUMAN_READABLE_MAX_WIDTH_STR "7"
//TODO: provide pointer to buf (avoid statics)?
const char *make_human_readable_str(unsigned long long size,
unsigned long block_size, unsigned long display_unit) FAST_FUNC;
/* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */
char *bin2hex(char *dst, const char *src, int count) FAST_FUNC;
/* Reverse */
@ -1205,10 +1196,6 @@ extern int get_linux_version_code(void) FAST_FUNC;
extern char *query_loop(const char *device) FAST_FUNC;
extern int del_loop(const char *device) FAST_FUNC;
/* If *devname is not NULL, use that name, otherwise try to find free one,
* malloc and return it in *devname.
* return value: 1: read-only loopdev was setup, 0: rw, < 0: error */
extern int set_loop(char **devname, const char *file, unsigned long long offset, int ro) FAST_FUNC;
/* Like bb_ask below, but asks on stdin with no timeout. */
char *bb_ask_stdin(const char * prompt) FAST_FUNC;

View File

@ -229,70 +229,7 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp)
return strftime_fmt(buf, len, tp, "%Y-%m-%d %H:%M:%S");
}
#if ENABLE_MONOTONIC_SYSCALL
#include <sys/syscall.h>
/* Old glibc (< 2.3.4) does not provide this constant. We use syscall
* directly so this definition is safe. */
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC 1
#endif
/* libc has incredibly messy way of doing this,
* typically requiring -lrt. We just skip all this mess */
static void get_mono(struct timespec *ts)
{
if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
}
unsigned long long FAST_FUNC monotonic_ns(void)
{
struct timespec ts;
get_mono(&ts);
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
}
unsigned long long FAST_FUNC monotonic_us(void)
{
struct timespec ts;
get_mono(&ts);
return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000;
}
unsigned long long FAST_FUNC monotonic_ms(void)
{
struct timespec ts;
get_mono(&ts);
return ts.tv_sec * 1000ULL + ts.tv_nsec/1000000;
}
unsigned FAST_FUNC monotonic_sec(void)
{
struct timespec ts;
get_mono(&ts);
return ts.tv_sec;
}
#else
unsigned long long FAST_FUNC monotonic_ns(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000;
}
unsigned long long FAST_FUNC monotonic_us(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000ULL + tv.tv_usec;
}
unsigned long long FAST_FUNC monotonic_ms(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000ULL + tv.tv_usec / 1000;
}
unsigned FAST_FUNC monotonic_sec(void)
unsigned long FAST_FUNC monotonic_sec(void)
{
return time(NULL);
}
#endif

View File

@ -575,69 +575,6 @@ char* FAST_FUNC xmalloc_ttyname(int fd)
return xstrdup(buf);
}
void FAST_FUNC generate_uuid(uint8_t *buf)
{
/* http://www.ietf.org/rfc/rfc4122.txt
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | time_low |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | time_mid | time_hi_and_version |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |clk_seq_and_variant | node (0-1) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | node (2-5) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* IOW, uuid has this layout:
* uint32_t time_low (big endian)
* uint16_t time_mid (big endian)
* uint16_t time_hi_and_version (big endian)
* version is a 4-bit field:
* 1 Time-based
* 2 DCE Security, with embedded POSIX UIDs
* 3 Name-based (MD5)
* 4 Randomly generated
* 5 Name-based (SHA-1)
* uint16_t clk_seq_and_variant (big endian)
* variant is a 3-bit field:
* 0xx Reserved, NCS backward compatibility
* 10x The variant specified in rfc4122
* 110 Reserved, Microsoft backward compatibility
* 111 Reserved for future definition
* uint8_t node[6]
*
* For version 4, these bits are set/cleared:
* time_hi_and_version & 0x0fff | 0x4000
* clk_seq_and_variant & 0x3fff | 0x8000
*/
pid_t pid;
int i;
i = open("/dev/urandom", O_RDONLY);
if (i >= 0) {
read(i, buf, 16);
close(i);
}
/* Paranoia. /dev/urandom may be missing.
* rand() is guaranteed to generate at least [0, 2^15) range,
* but lowest bits in some libc are not so "random". */
srand(monotonic_us()); /* pulls in printf */
pid = getpid();
while (1) {
for (i = 0; i < 16; i++)
buf[i] ^= rand() >> 5;
if (pid == 0)
break;
srand(pid);
pid = 0;
}
/* version = 4 */
buf[4 + 2 ] = (buf[4 + 2 ] & 0x0f) | 0x40;
/* variant = 10x */
buf[4 + 2 + 2] = (buf[4 + 2 + 2] & 0x3f) | 0x80;
}
#if BB_MMU
pid_t FAST_FUNC xfork(void)
{

View File

@ -27,7 +27,6 @@
# define FAST_FUNC /* nothing */
# define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN /* nothing */
# define POP_SAVED_FUNCTION_VISIBILITY /* nothing */
# define monotonic_us() time(NULL)
# include "random.h"
# define RAND_BASH_MASK 0xffffffff /* off */
#endif
@ -58,7 +57,7 @@ next_random(random_t *rnd)
/* Can use monotonic_ns() for better randomness but for now
* it is not used anywhere else in busybox... so avoid bloat
*/
INIT_RANDOM_T(rnd, getpid(), monotonic_us());
INIT_RANDOM_T(rnd, getpid(), time(NULL));
}
/* LCG: period of 2^32, but quite weak:

View File

@ -57,7 +57,7 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
)
{
unsigned err;
unsigned end_ms; /* -t TIMEOUT */
unsigned long end_sec; /* -t TIMEOUT */
int fd; /* -u FD */
int nchars; /* -n NUM */
char **pp;
@ -87,12 +87,11 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
return "invalid count";
/* note: "-n 0": off (bash 3.2 does this too) */
}
end_ms = 0;
end_sec = 0;
if (opt_t) {
end_ms = bb_strtou(opt_t, NULL, 10);
if (errno || end_ms > UINT_MAX / 2048)
end_sec = bb_strtoul(opt_t, NULL, 10);
if (errno || end_sec > ULONG_MAX / 2048)
return "invalid timeout";
end_ms *= 1000;
#if 0 /* even bash has no -t N.NNN support */
ts.tv_sec = bb_strtou(opt_t, &p, 10);
ts.tv_usec = 0;
@ -160,21 +159,24 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
retval = (const char *)(uintptr_t)0;
startword = 1;
backslash = 0;
if (end_ms) /* NB: end_ms stays nonzero: */
end_ms = ((unsigned)monotonic_ms() + end_ms) | 1;
if (end_sec) { /* NB: end_sec stays nonzero: */
end_sec = (unsigned long)monotonic_sec() + end_sec;
if (end_sec == 0)
end_sec = 1;
}
buffer = NULL;
bufpos = 0;
do {
char c;
struct pollfd pfd[1];
int timeout;
long timeout;
if ((bufpos & 0xff) == 0)
buffer = xrealloc(buffer, bufpos + 0x101);
timeout = -1;
if (end_ms) {
timeout = end_ms - (unsigned)monotonic_ms();
if (end_sec) {
timeout = end_sec - (unsigned long)monotonic_sec();
if (timeout <= 0) { /* already late? */
retval = (const char *)(uintptr_t)1;
goto ret;
@ -188,7 +190,7 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
errno = 0;
pfd[0].fd = fd;
pfd[0].events = POLLIN;
if (poll(pfd, 1, timeout) != 1) {
if (poll(pfd, 1, timeout * 1000) != 1) {
/* timed out, or EINTR */
err = errno;
retval = (const char *)(uintptr_t)1;