mirror of
https://github.com/fltk/fltk.git
synced 2026-06-06 00:22:42 +08:00
Add to Fl_System_Driver support for measuring time with split second resolution.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12187 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
// A base class for platform specific system calls
|
// A base class for platform specific system calls
|
||||||
// for the Fast Light Tool Kit (FLTK).
|
// for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 2010-2016 by Bill Spitzak and others.
|
// Copyright 2010-2017 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
class Fl_File_Icon;
|
class Fl_File_Icon;
|
||||||
class Fl_File_Browser;
|
class Fl_File_Browser;
|
||||||
@@ -210,6 +211,8 @@ public:
|
|||||||
virtual void remove_fd(int);
|
virtual void remove_fd(int);
|
||||||
// the default implementation of open_callback() may be enough
|
// the default implementation of open_callback() may be enough
|
||||||
virtual void open_callback(void (*)(const char *));
|
virtual void open_callback(void (*)(const char *));
|
||||||
|
// get elapsed time since Jan 1st, 1970
|
||||||
|
virtual void gettime(time_t *sec, int *usec) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FL_SYSTEM_DRIVER_H
|
#endif // FL_SYSTEM_DRIVER_H
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// Definition of Posix system driver
|
// Definition of Posix system driver
|
||||||
// for the Fast Light Tool Kit (FLTK).
|
// for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 2010-2016 by Bill Spitzak and others.
|
// Copyright 2010-2017 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -74,6 +74,7 @@ public:
|
|||||||
virtual int file_type(const char *filename);
|
virtual int file_type(const char *filename);
|
||||||
virtual const char *home_directory_name() { return ::getenv("HOME"); }
|
virtual const char *home_directory_name() { return ::getenv("HOME"); }
|
||||||
virtual int dot_file_hidden() {return 1;}
|
virtual int dot_file_hidden() {return 1;}
|
||||||
|
virtual void gettime(time_t *sec, int *usec);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FL_POSIX_SYSTEM_DRIVER_H
|
#endif // FL_POSIX_SYSTEM_DRIVER_H
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// Definition of Apple Darwin system driver.
|
// Definition of Apple Darwin system driver.
|
||||||
//
|
//
|
||||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
// Copyright 1998-2017 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -90,6 +91,14 @@ const char *Fl_Posix_System_Driver::getpwnam(const char *login) {
|
|||||||
return pwd ? pwd->pw_dir : NULL;
|
return pwd ? pwd->pw_dir : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Fl_Posix_System_Driver::gettime(time_t *sec, int *usec) {
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
*sec = tv.tv_sec;
|
||||||
|
*usec = tv.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id$".
|
// End of "$Id$".
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// Definition of MSWindows system driver
|
// Definition of MSWindows system driver
|
||||||
// for the Fast Light Tool Kit (FLTK).
|
// for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 2010-2016 by Bill Spitzak and others.
|
// Copyright 2010-2017 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -116,6 +116,7 @@ public:
|
|||||||
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
|
virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
|
||||||
virtual void remove_fd(int, int when);
|
virtual void remove_fd(int, int when);
|
||||||
virtual void remove_fd(int);
|
virtual void remove_fd(int);
|
||||||
|
virtual void gettime(time_t *sec, int *usec);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FL_WINAPI_SYSTEM_DRIVER_H
|
#endif // FL_WINAPI_SYSTEM_DRIVER_H
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// Definition of Apple Darwin system driver.
|
// Definition of Apple Darwin system driver.
|
||||||
//
|
//
|
||||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
// Copyright 1998-2017 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <rpc.h>
|
#include <rpc.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/timeb.h>
|
||||||
// function pointer for the UuidCreate Function
|
// function pointer for the UuidCreate Function
|
||||||
// RPC_STATUS RPC_ENTRY UuidCreate(UUID __RPC_FAR *Uuid);
|
// RPC_STATUS RPC_ENTRY UuidCreate(UUID __RPC_FAR *Uuid);
|
||||||
typedef RPC_STATUS (WINAPI* uuid_func)(UUID __RPC_FAR *Uuid);
|
typedef RPC_STATUS (WINAPI* uuid_func)(UUID __RPC_FAR *Uuid);
|
||||||
@@ -902,6 +903,13 @@ const char *Fl_WinAPI_System_Driver::home_directory_name()
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Fl_WinAPI_System_Driver::gettime(time_t *sec, int *usec) {
|
||||||
|
struct _timeb t;
|
||||||
|
_ftime(&t);
|
||||||
|
*sec = t.time;
|
||||||
|
*usec = t.millitm * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id$".
|
// End of "$Id$".
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user