Skip to content
Extraits de code Groupes Projets
Valider 8f30ce64 rédigé par Etienne BRATEAU's avatar Etienne BRATEAU
Parcourir les fichiers

sysdev: revert changes to can retrieve microseconds, but fix compilation

The change was made in 20233596
It was just a missing header, and i changed all the code.
parent 0d62e830
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#define SYSDEVS_G #define SYSDEVS_G
#include <time.h> #include <time.h>
#include <sys/time.h>
#include <p2c/p2c.h> #include <p2c/p2c.h>
#include <p2c/sysglobals.h> #include <p2c/sysglobals.h>
...@@ -8,11 +9,11 @@ ...@@ -8,11 +9,11 @@
long sysclock() long sysclock()
{ {
time_t t = time(NULL); struct timeval tv;
struct tm *tz; struct timezone tz;
tz = localtime(&t);
return(tz->tm_sec % 86400 * 100 /*+ tz->tv_usec / 10000*/); gettimeofday(&tv, &tz);
return tv.tv_sec % 86400 * 100 + tv.tv_usec / 10000;
} }
...@@ -29,14 +30,18 @@ void sysdate(daterec *thedate) ...@@ -29,14 +30,18 @@ void sysdate(daterec *thedate)
void systime(timerec *thetime) void systime(timerec *thetime)
{ {
struct timeval tv;
struct timezone tz;
struct tm *t; struct tm *t;
time_t temp; time_t temp;
temp = time(NULL); gettimeofday(&tv, &tz);
temp = tv.tv_sec;
t = localtime(&temp); t = localtime(&temp);
thetime->hour = t->tm_hour; thetime->hour = t->tm_hour;
thetime->minute = t->tm_min; thetime->minute = t->tm_min;
thetime->centisecond = t->tm_sec*100 /*+ time.tv_usec/10000*/; thetime->centisecond = t->tm_sec * 100 + tv.tv_usec / 10000;
} }
void SETRUNLIGHT(int c) void SETRUNLIGHT(int c)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter