Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
3ba3d6fa
Commit
3ba3d6fa
authored
Nov 27, 2014
by
Hisham Muhammad
Browse files
Add uptime calculation code.
parent
1dd165c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
3ba3d6fa
...
...
@@ -43,12 +43,10 @@ endif
if
HTOP_FREEBSD
myhtopplatsources
=
freebsd/Platform.c freebsd/FreeBSDProcessList.c
\
freebsd/FreeBSDCRT.c
\
freebsd/UptimeMeter.c
freebsd/FreeBSDCRT.c
myhtopplatheaders
=
freebsd/Platform.h freebsd/FreeBSDProcessList.h
\
freebsd/FreeBSDCRT.h
\
freebsd/UptimeMeter.h
freebsd/FreeBSDCRT.h
endif
if
HTOP_UNSUPPORTED
...
...
freebsd/Platform.c
View file @
3ba3d6fa
...
...
@@ -17,6 +17,11 @@ in the source distribution for its full text.
#include "ClockMeter.h"
#include "HostnameMeter.h"
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <time.h>
/*{
#include "Action.h"
}*/
...
...
@@ -46,3 +51,16 @@ MeterClass* Platform_meterTypes[] = {
NULL
};
int
Platform_getUptime
()
{
struct
timeval
bootTime
,
currTime
;
int
mib
[
2
]
=
{
CTL_KERN
,
KERN_BOOTTIME
};
size_t
size
=
sizeof
(
bootTime
);
int
err
=
sysctl
(
mib
,
2
,
&
bootTime
,
&
size
,
NULL
,
0
);
if
(
err
)
{
return
-
1
;
}
gettimeofday
(
&
currTime
,
NULL
);
return
(
int
)
difftime
(
currTime
.
tv_sec
,
bootTime
.
tv_sec
);
}
freebsd/Platform.h
View file @
3ba3d6fa
...
...
@@ -15,5 +15,6 @@ void Platform_setBindings(Htop_Action* keys);
extern
MeterClass
*
Platform_meterTypes
[];
int
Platform_getUptime
();
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment