Such style. (Code style unification)

This commit is contained in:
Thulinma 2014-06-18 10:39:27 +02:00
parent 57bcd8f25c
commit 8c01ec8897
57 changed files with 6548 additions and 6437 deletions

View file

@ -11,7 +11,7 @@
#include <mach/mach.h>
#define CLOCK_REALTIME CALENDAR_CLOCK
#define CLOCK_MONOTONIC SYSTEM_CLOCK
void clock_gettime(int ign, struct timespec * ts){
void clock_gettime(int ign, struct timespec * ts) {
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), ign, &cclock);
@ -23,53 +23,53 @@ void clock_gettime(int ign, struct timespec * ts){
#endif
/// Sleeps for the indicated amount of milliseconds or longer.
void Util::sleep(int ms){
if (ms < 0){
void Util::sleep(int ms) {
if (ms < 0) {
return;
}
if (ms > 100000){
if (ms > 100000) {
ms = 100000;
}
struct timespec T;
T.tv_sec = ms / 1000;
T.tv_nsec = 1000000 * (ms % 1000);
nanosleep( &T, 0);
nanosleep(&T, 0);
}
long long Util::getNTP(){
long long Util::getNTP() {
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return ((((long long int)t.tv_sec) + 2208988800) << 32) + (t.tv_nsec*4.2949);
return ((((long long int)t.tv_sec) + 2208988800) << 32) + (t.tv_nsec * 4.2949);
}
/// Gets the current time in milliseconds.
long long int Util::getMS(){
long long int Util::getMS() {
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return ((long long int)t.tv_sec) * 1000 + t.tv_nsec / 1000000;
}
long long int Util::bootSecs(){
long long int Util::bootSecs() {
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
return t.tv_sec;
}
/// Gets the current time in microseconds.
long long unsigned int Util::getMicros(){
long long unsigned int Util::getMicros() {
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return ((long long unsigned int)t.tv_sec) * 1000000 + t.tv_nsec / 1000;
}
/// Gets the time difference in microseconds.
long long unsigned int Util::getMicros(long long unsigned int previous){
long long unsigned int Util::getMicros(long long unsigned int previous) {
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return ((long long unsigned int)t.tv_sec) * 1000000 + t.tv_nsec / 1000 - previous;
}
/// Gets the amount of seconds since 01/01/1970.
long long int Util::epoch(){
long long int Util::epoch() {
return time(0);
}