Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/camdd/camdd.c
Show First 20 Lines • Show All 423 Lines • ▼ Show 20 Lines | |||||
static sig_atomic_t need_exit = 0; | static sig_atomic_t need_exit = 0; | ||||
static sig_atomic_t error_exit = 0; | static sig_atomic_t error_exit = 0; | ||||
static sig_atomic_t need_status = 0; | static sig_atomic_t need_status = 0; | ||||
#ifndef min | #ifndef min | ||||
#define min(a, b) (a < b) ? a : b | #define min(a, b) (a < b) ? a : b | ||||
#endif | #endif | ||||
/* | |||||
* XXX KDM private copy of timespecsub(). This is normally defined in | |||||
* sys/time.h, but is only enabled in the kernel. If that definition is | |||||
* enabled in userland, it breaks the build of libnetbsd. | |||||
*/ | |||||
#ifndef timespecsub | |||||
#define timespecsub(vvp, uvp) \ | |||||
do { \ | |||||
(vvp)->tv_sec -= (uvp)->tv_sec; \ | |||||
(vvp)->tv_nsec -= (uvp)->tv_nsec; \ | |||||
if ((vvp)->tv_nsec < 0) { \ | |||||
(vvp)->tv_sec--; \ | |||||
(vvp)->tv_nsec += 1000000000; \ | |||||
} \ | |||||
} while (0) | |||||
#endif | |||||
/* Generically useful offsets into the peripheral private area */ | /* Generically useful offsets into the peripheral private area */ | ||||
#define ppriv_ptr0 periph_priv.entries[0].ptr | #define ppriv_ptr0 periph_priv.entries[0].ptr | ||||
#define ppriv_ptr1 periph_priv.entries[1].ptr | #define ppriv_ptr1 periph_priv.entries[1].ptr | ||||
#define ppriv_field0 periph_priv.entries[0].field | #define ppriv_field0 periph_priv.entries[0].field | ||||
#define ppriv_field1 periph_priv.entries[1].field | #define ppriv_field1 periph_priv.entries[1].field | ||||
#define ccb_buf ppriv_ptr0 | #define ccb_buf ppriv_ptr0 | ||||
▲ Show 20 Lines • Show All 2,606 Lines • ▼ Show 20 Lines | camdd_print_status(struct camdd_dev *camdd_dev, struct camdd_dev *other_dev, | ||||
int error = 0; | int error = 0; | ||||
error = clock_gettime(CLOCK_MONOTONIC_PRECISE, &done_time); | error = clock_gettime(CLOCK_MONOTONIC_PRECISE, &done_time); | ||||
if (error != 0) { | if (error != 0) { | ||||
warn("Unable to get done time"); | warn("Unable to get done time"); | ||||
return; | return; | ||||
} | } | ||||
timespecsub(&done_time, start_time); | timespecsub(&done_time, start_time, &done_time); | ||||
total_ns = done_time.tv_nsec + (done_time.tv_sec * 1000000000); | total_ns = done_time.tv_nsec + (done_time.tv_sec * 1000000000); | ||||
total_sec = total_ns; | total_sec = total_ns; | ||||
total_sec /= 1000000000; | total_sec /= 1000000000; | ||||
fprintf(stderr, "%ju bytes %s %s\n%ju bytes %s %s\n" | fprintf(stderr, "%ju bytes %s %s\n%ju bytes %s %s\n" | ||||
"%.4Lf seconds elapsed\n", | "%.4Lf seconds elapsed\n", | ||||
(uintmax_t)camdd_dev->bytes_transferred, | (uintmax_t)camdd_dev->bytes_transferred, | ||||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |