Fix linter path and lint code (#170)

* chage syntax checker path

* fix syntax
This commit is contained in:
coreglitch 2020-10-11 17:03:05 +06:00 committed by GitHub
parent 176e608c6d
commit 469dbf58ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 437 additions and 396 deletions

View File

@ -105,7 +105,6 @@ void fatfs_list(void* p) {
while(1) {
if(xQueueReceive(event_queue, (void*)&event, portMAX_DELAY)) {
// process buttons event
if(event.type == EventTypeKey) {
// button pressed

View File

@ -34,7 +34,8 @@
#define __func__ __FUNCTION__
#endif
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
#elif defined(__unix__) || defined(__unix) || defined(unix) || \
(defined(__APPLE__) && defined(__MACH__))
/* Change POSIX C SOURCE version for pure c99 compilers */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
@ -82,30 +83,26 @@ static void (*minunit_teardown)(void) = NULL;
#define MU_TEST(method_name) static void method_name(void)
#define MU_TEST_SUITE(suite_name) static void suite_name(void)
#define MU__SAFE_BLOCK(block) do {\
#define MU__SAFE_BLOCK(block) \
do { \
block \
} while(0)
/* Run test suite and unset setup and teardown functions */
#define MU_RUN_SUITE(suite_name) MU__SAFE_BLOCK(\
suite_name();\
minunit_setup = NULL;\
minunit_teardown = NULL;\
)
#define MU_RUN_SUITE(suite_name) \
MU__SAFE_BLOCK(suite_name(); minunit_setup = NULL; minunit_teardown = NULL;)
/* Configure setup and teardown functions */
#define MU_SUITE_CONFIGURE(setup_fun, teardown_fun) MU__SAFE_BLOCK(\
minunit_setup = setup_fun;\
minunit_teardown = teardown_fun;\
)
#define MU_SUITE_CONFIGURE(setup_fun, teardown_fun) \
MU__SAFE_BLOCK(minunit_setup = setup_fun; minunit_teardown = teardown_fun;)
/* Test runner */
#define MU_RUN_TEST(test) MU__SAFE_BLOCK(\
#define MU_RUN_TEST(test) \
MU__SAFE_BLOCK( \
if(minunit_real_timer == 0 && minunit_proc_timer == 0) { \
minunit_real_timer = mu_timer_real(); \
minunit_proc_timer = mu_timer_cpu(); \
}\
if (minunit_setup) (*minunit_setup)();\
} if(minunit_setup) (*minunit_setup)(); \
minunit_status = 0; \
test(); \
minunit_run++; \
@ -113,142 +110,165 @@ static void (*minunit_teardown)(void) = NULL;
minunit_fail++; \
printf("F"); \
printf("\n%s\n", minunit_last_message); \
}\
fflush(stdout);\
if (minunit_teardown) (*minunit_teardown)();\
)
} fflush(stdout); \
if(minunit_teardown)(*minunit_teardown)();)
/* Report */
#define MU_REPORT() MU__SAFE_BLOCK(\
double minunit_end_real_timer;\
double minunit_end_proc_timer;\
printf("\n\n%d tests, %d assertions, %d failures\n", minunit_run, minunit_assert, minunit_fail);\
#define MU_REPORT() \
MU__SAFE_BLOCK(double minunit_end_real_timer; double minunit_end_proc_timer; printf( \
"\n\n%d tests, %d assertions, %d failures\n", \
minunit_run, \
minunit_assert, \
minunit_fail); \
minunit_end_real_timer = mu_timer_real(); \
minunit_end_proc_timer = mu_timer_cpu(); \
printf("\nFinished in %.8f seconds (real) %.8f seconds (proc)\n\n",\
printf( \
"\nFinished in %.8f seconds (real) %.8f seconds (proc)\n\n", \
minunit_end_real_timer - minunit_real_timer, \
minunit_end_proc_timer - minunit_proc_timer);\
)
minunit_end_proc_timer - minunit_proc_timer);)
#define MU_EXIT_CODE minunit_fail
/* Assertions */
#define mu_check(test) MU__SAFE_BLOCK(\
minunit_assert++;\
if (!(test)) {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, #test);\
#define mu_check(test) \
MU__SAFE_BLOCK( \
minunit_assert++; if(!(test)) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %s", \
__func__, \
__FILE__, \
__LINE__, \
#test); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_fail(message) MU__SAFE_BLOCK(\
minunit_assert++;\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, message);\
#define mu_fail(message) \
MU__SAFE_BLOCK(minunit_assert++; snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %s", \
__func__, \
__FILE__, \
__LINE__, \
message); \
minunit_status = 1; \
return;)
#define mu_assert(test, message) \
MU__SAFE_BLOCK( \
minunit_assert++; if(!(test)) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %s", \
__func__, \
__FILE__, \
__LINE__, \
message); \
minunit_status = 1; \
return; \
)
} else { printf("."); })
#define mu_assert(test, message) MU__SAFE_BLOCK(\
minunit_assert++;\
if (!(test)) {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, message);\
minunit_status = 1;\
return;\
} else {\
printf(".");\
}\
)
#define mu_assert_int_eq(expected, result) MU__SAFE_BLOCK(\
int minunit_tmp_e;\
int minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (expected);\
#define mu_assert_int_eq(expected, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_tmp_r = (result); \
if(minunit_tmp_e != minunit_tmp_r) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d expected but was %d", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d expected but was %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_int_not_eq(expected, result) MU__SAFE_BLOCK(\
int minunit_tmp_e;\
int minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (expected);\
#define mu_assert_int_not_eq(expected, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_tmp_r = (result); \
if(minunit_tmp_e == minunit_tmp_r) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: expected different results but both were %d", __func__, __FILE__, __LINE__, minunit_tmp_e);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: expected different results but both were %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_int_greater_than(val, result) MU__SAFE_BLOCK(\
int minunit_tmp_e;\
int minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (val);\
#define mu_assert_int_greater_than(val, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val >= minunit_tmp_r) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d <= %d", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d <= %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_int_less_than(val, result) MU__SAFE_BLOCK(\
int minunit_tmp_e;\
int minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (val);\
#define mu_assert_int_less_than(val, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val <= minunit_tmp_r) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d >= %d", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d >= %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_int_between(expected_lower, expected_upper, result) MU__SAFE_BLOCK(\
int minunit_tmp_e;\
int minunit_tmp_m;\
int minunit_tmp_r;\
minunit_assert++;\
#define mu_assert_int_between(expected_lower, expected_upper, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_e; int minunit_tmp_m; int minunit_tmp_r; minunit_assert++; \
minunit_tmp_e = (expected_lower); \
minunit_tmp_m = (expected_upper); \
minunit_tmp_r = (result); \
if(result < minunit_tmp_e || result > minunit_tmp_m) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d was not between (inclusive) %d and %d", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r, minunit_tmp_m);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %d was not between (inclusive) %d and %d", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r, \
minunit_tmp_m); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_int_in(expected, array_length, result) MU__SAFE_BLOCK(\
int minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_r = (result);\
int t = 0;\
int i;\
#define mu_assert_int_in(expected, array_length, result) \
MU__SAFE_BLOCK( \
int minunit_tmp_r; minunit_assert++; minunit_tmp_r = (result); int t = 0; int i; \
for(i = 0; i < array_length; i++) { \
if (expected[i] == minunit_tmp_r)\
t = 1;\
}\
if (t == 0) {\
if(expected[i] == minunit_tmp_r) t = 1; \
} if(t == 0) { \
char tmp[500] = {0}; \
tmp[0] = '['; \
for(i = 0; i < array_length; i++) { \
@ -257,139 +277,172 @@ static void (*minunit_teardown)(void) = NULL;
int len = strlen(tmp); \
tmp[len - 2] = ']'; \
tmp[len - 1] = '\0'; \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: expected to be one of %s but was %d", __func__, __FILE__, __LINE__, tmp, minunit_tmp_r);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: expected to be one of %s but was %d", \
__func__, \
__FILE__, \
__LINE__, \
tmp, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_double_eq(expected, result) MU__SAFE_BLOCK(\
double minunit_tmp_e;\
double minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (expected);\
#define mu_assert_double_eq(expected, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_tmp_r = (result); \
if(fabs(minunit_tmp_e - minunit_tmp_r) > MINUNIT_EPSILON) { \
int minunit_significant_figures = 1 - log10(MINUNIT_EPSILON); \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %.*g expected but was %.*g", __func__, __FILE__, __LINE__, minunit_significant_figures, minunit_tmp_e, minunit_significant_figures, minunit_tmp_r);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %.*g expected but was %.*g", \
__func__, \
__FILE__, \
__LINE__, \
minunit_significant_figures, \
minunit_tmp_e, \
minunit_significant_figures, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_double_greater_than(val, result) MU__SAFE_BLOCK(\
double minunit_tmp_e;\
double minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (val);\
#define mu_assert_double_greater_than(val, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val >= minunit_tmp_r) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %f <= %f", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %f <= %f", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_double_less_than(val, result) MU__SAFE_BLOCK(\
double minunit_tmp_e;\
double minunit_tmp_r;\
minunit_assert++;\
minunit_tmp_e = (val);\
#define mu_assert_double_less_than(val, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_tmp_r = (result); \
if(val <= minunit_tmp_r) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %f >= %f", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %f >= %f", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_r, \
minunit_tmp_e); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_double_between(expected_lower, expected_upper, result) MU__SAFE_BLOCK(\
double minunit_tmp_e;\
double minunit_tmp_m;\
double minunit_tmp_r;\
minunit_assert++;\
#define mu_assert_double_between(expected_lower, expected_upper, result) \
MU__SAFE_BLOCK( \
double minunit_tmp_e; double minunit_tmp_m; double minunit_tmp_r; minunit_assert++; \
minunit_tmp_e = (expected_lower); \
minunit_tmp_m = (expected_upper); \
minunit_tmp_r = (result); \
if(result < minunit_tmp_e || result > minunit_tmp_m) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %f was not between (inclusive) %f and %f", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r, minunit_tmp_m);\
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: %f was not between (inclusive) %f and %f", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r, \
minunit_tmp_m); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_string_eq(expected, result) MU__SAFE_BLOCK(\
const char* minunit_tmp_e = expected;\
const char* minunit_tmp_r = result;\
#define mu_assert_string_eq(expected, result) \
MU__SAFE_BLOCK( \
const char* minunit_tmp_e = expected; const char* minunit_tmp_r = result; \
minunit_assert++; \
if (!minunit_tmp_e) {\
minunit_tmp_e = "<null pointer>";\
}\
if (!minunit_tmp_r) {\
if(!minunit_tmp_e) { minunit_tmp_e = "<null pointer>"; } if(!minunit_tmp_r) { \
minunit_tmp_r = "<null pointer>"; \
}\
if(strcmp(minunit_tmp_e, minunit_tmp_r)) {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: '%s' expected but was '%s'", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r);\
} if(strcmp(minunit_tmp_e, minunit_tmp_r)) { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: '%s' expected but was '%s'", \
__func__, \
__FILE__, \
__LINE__, \
minunit_tmp_e, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else {\
printf(".");\
}\
)
} else { printf("."); })
#define mu_assert_null(result) MU__SAFE_BLOCK(\
minunit_assert++;\
if (result == NULL) {\
printf(".");\
} else {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected result was not NULL", __func__, __FILE__, __LINE__);\
#define mu_assert_null(result) \
MU__SAFE_BLOCK( \
minunit_assert++; if(result == NULL) { printf("."); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected result was not NULL", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
}\
)
})
#define mu_assert_not_null(result) MU__SAFE_BLOCK(\
minunit_assert++;\
if (result != NULL) {\
printf(".");\
} else {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected result was not NULL", __func__, __FILE__, __LINE__);\
#define mu_assert_not_null(result) \
MU__SAFE_BLOCK( \
minunit_assert++; if(result != NULL) { printf("."); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected result was not NULL", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
}\
)
})
#define mu_assert_pointers_eq(pointer1, pointer2) MU__SAFE_BLOCK(\
minunit_assert++;\
if (pointer1 == pointer2) {\
printf(".");\
} else {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", __func__, __FILE__, __LINE__);\
#define mu_assert_pointers_eq(pointer1, pointer2) \
MU__SAFE_BLOCK( \
minunit_assert++; if(pointer1 == pointer2) { printf("."); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
}\
)
})
#define mu_assert_pointers_not_eq(pointer1, pointer2) MU__SAFE_BLOCK(\
minunit_assert++;\
if (pointer1 != pointer2) {\
printf(".");\
} else {\
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", __func__, __FILE__, __LINE__);\
#define mu_assert_pointers_not_eq(pointer1, pointer2) \
MU__SAFE_BLOCK( \
minunit_assert++; if(pointer1 != pointer2) { printf("."); } else { \
snprintf( \
minunit_last_message, \
MINUNIT_MESSAGE_LEN, \
"%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
__func__, \
__FILE__, \
__LINE__); \
minunit_status = 1; \
return; \
}\
)
})
/*
* The following two functions were written by David Robert Nadeau
@ -404,8 +457,7 @@ static void (*minunit_teardown)(void) = NULL;
* The returned real time is only useful for computing an elapsed time
* between two calls to this function.
*/
static double mu_timer_real(void)
{
static double mu_timer_real(void) {
#if defined(_WIN32)
/* Windows 2000 and later. ---------------------------------- */
LARGE_INTEGER Time;
@ -419,20 +471,19 @@ static double mu_timer_real(void)
return (double)Time.QuadPart / 1000000.0;
#elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__)))
#elif(defined(__hpux) || defined(hpux)) || \
((defined(__sun__) || defined(__sun) || defined(sun)) && \
(defined(__SVR4) || defined(__svr4__)))
/* HP-UX, Solaris. ------------------------------------------ */
return (double)gethrtime() / 1000000000.0;
#elif defined(__MACH__) && defined(__APPLE__)
/* OSX. ----------------------------------------------------- */
static double timeConvert = 0.0;
if ( timeConvert == 0.0 )
{
if(timeConvert == 0.0) {
mach_timebase_info_data_t timeBase;
(void)mach_timebase_info(&timeBase);
timeConvert = (double)timeBase.numer /
(double)timeBase.denom /
1000000000.0;
timeConvert = (double)timeBase.numer / (double)timeBase.denom / 1000000000.0;
}
return (double)mach_absolute_time() * timeConvert;
@ -461,8 +512,7 @@ static double mu_timer_real(void)
const clockid_t id = (clockid_t)-1; /* Unknown. */
#endif /* CLOCK_* */
if(id != (clockid_t)-1 && clock_gettime(id, &ts) != -1)
return (double)ts.tv_sec +
(double)ts.tv_nsec / 1000000000.0;
return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
/* Fall thru. */
}
#endif /* _POSIX_TIMERS */
@ -479,8 +529,7 @@ static double mu_timer_real(void)
* Returns the amount of CPU time used by the current process,
* in seconds, or -1.0 if an error occurred.
*/
static double mu_timer_cpu(void)
{
static double mu_timer_cpu(void) {
#if defined(_WIN32)
/* Windows -------------------------------------------------- */
FILETIME createTime;
@ -489,15 +538,14 @@ static double mu_timer_cpu(void)
FILETIME userTime;
/* This approach has a resolution of 1/64 second. Unfortunately, Windows' API does not offer better */
if ( GetProcessTimes( GetCurrentProcess( ),
&createTime, &exitTime, &kernelTime, &userTime ) != 0 )
{
if(GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime) != 0) {
ULARGE_INTEGER userSystemTime;
memcpy(&userSystemTime, &userTime, sizeof(ULARGE_INTEGER));
return (double)userSystemTime.QuadPart / 10000000.0;
}
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
#elif defined(__unix__) || defined(__unix) || defined(unix) || \
(defined(__APPLE__) && defined(__MACH__))
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, and Solaris --------- */
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
@ -519,8 +567,7 @@ static double mu_timer_cpu(void)
id = (clockid_t)-1;
#endif
if(id != (clockid_t)-1 && clock_gettime(id, &ts) != -1)
return (double)ts.tv_sec +
(double)ts.tv_nsec / 1000000000.0;
return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
}
#endif
@ -528,8 +575,7 @@ static double mu_timer_cpu(void)
{
struct rusage rusage;
if(getrusage(RUSAGE_SELF, &rusage) != -1)
return (double)rusage.ru_utime.tv_sec +
(double)rusage.ru_utime.tv_usec / 1000000.0;
return (double)rusage.ru_utime.tv_sec + (double)rusage.ru_utime.tv_usec / 1000000.0;
}
#endif
@ -537,16 +583,14 @@ static double mu_timer_cpu(void)
{
const double ticks = (double)sysconf(_SC_CLK_TCK);
struct tms tms;
if ( times( &tms ) != (clock_t)-1 )
return (double)tms.tms_utime / ticks;
if(times(&tms) != (clock_t)-1) return (double)tms.tms_utime / ticks;
}
#endif
#if defined(CLOCKS_PER_SEC)
{
clock_t cl = clock();
if ( cl != (clock_t)-1 )
return (double)cl / (double)CLOCKS_PER_SEC;
if(cl != (clock_t)-1) return (double)cl / (double)CLOCKS_PER_SEC;
}
#endif

View File

@ -11,10 +11,8 @@ cd $PROJECT_DIR
echo "RUN C\C++ SYNTAX CHECK"
C_FILES=$(find . \
-not \( -path './target_*/Middlewares' -prune \) \
-not \( -path './target_*/Drivers' -prune \) \
-not \( -path './target_*/build' -prune \) \
-not \( -path './target_*/Inc' -prune \) \
-not \( -path './firmware/.obj' -prune \) \
-not \( -path './firmware/targets' -prune \) \
-not \( -path ./lib -prune \) \
-name *.c -o -name *.h -o -name *.cpp)