26 char *cachedir = "/tmp";
29 // =======================================================================
31 // =======================================================================
36 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
41 void Sys_Error (const char *error, ...)
46 // change stdin to non blocking
47 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
49 va_start (argptr,error);
50 vsprintf (string,error,argptr);
52 fprintf(stderr, "Error: %s\n", string);
59 void Sys_Warn (const char *warning, ...)
64 va_start (argptr,warning);
65 vsprintf (string,warning,argptr);
67 fprintf(stderr, "Warning: %s", string);
70 double Sys_DoubleTime (void)
72 static int first = true;
73 static double oldtime = 0.0, curtime = 0.0;
77 gettimeofday(&tp, NULL);
79 newtime = (double) tp.tv_sec + tp.tv_usec / 1000000.0;
87 if (newtime < oldtime)
89 // warn if it's significant
90 if (newtime - oldtime < -0.01)
91 Con_Printf("Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime);
94 curtime += newtime - oldtime;
100 // =======================================================================
101 // Sleeps for microseconds
102 // =======================================================================
104 static volatile int oktogo;
106 void alarm_handler(int x)
111 void floating_point_exception_handler(int whatever)
113 signal(SIGFPE, floating_point_exception_handler);
116 char *Sys_ConsoleInput(void)
118 static char text[256];
121 struct timeval timeout;
123 if (cls.state == ca_dedicated)
126 FD_SET(0, &fdset); // stdin
129 if (select (1, &fdset, NULL, NULL, &timeout) == -1 || !FD_ISSET(0, &fdset))
132 len = read (0, text, sizeof(text));
135 text[len-1] = 0; // rip off the /n and terminate
147 int main (int c, char **v)
149 double frameoldtime, framenewtime;
151 signal(SIGFPE, SIG_IGN);
153 memset(&host_parms, 0, sizeof(host_parms));
157 host_parms.basedir = basedir;
159 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
161 Sys_Shared_EarlyInit();
165 Sys_Shared_LateInit();
167 frameoldtime = Sys_DoubleTime () - 0.1;
170 // find time spent rendering last frame
171 framenewtime = Sys_DoubleTime ();
173 Host_Frame (framenewtime - frameoldtime);
175 frameoldtime = framenewtime;