You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SQA-Homework/gcov&lcov/func.h

42 lines
650 B

#ifndef FUNC_H
#define FUNC_H
#include <sys/time.h>
int min(int a, int b) {
return a < b ? a : b;
}
int max(int a, int b) {
return a > b ? a : b;
}
bool probability(int x, int y) {
return (rand() % y) <= (x - 1);
}
uint64_t myclock() {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
char* sformat(const char* format, ...) {
static char text[1024];
va_list ap;
va_start(ap, format);
int len = vsprintf(text, format, ap);
va_end(ap);
/*
if (len >= (int)sizeof(text)){
eprintf("buffer overflow\n");
}
*/
return text;
}
#endif