define nsec of file stat in Linux and FreeBSD
parent
08d3932845
commit
a8b9d024e3
|
|
@ -116,6 +116,18 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
|
||||||
#define IS_UPPER_HEX(ch) ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F'))
|
#define IS_UPPER_HEX(ch) ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F'))
|
||||||
#define STRERROR(no) (strerror(no) != NULL ? strerror(no) : "Unkown error")
|
#define STRERROR(no) (strerror(no) != NULL ? strerror(no) : "Unkown error")
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#if defined __USE_MISC || defined __USE_XOPEN2K8
|
||||||
|
#define st_atimensec st_atim.tv_nsec
|
||||||
|
#define st_mtimensec st_mtim.tv_nsec
|
||||||
|
#define st_ctimensec st_ctim.tv_nsec
|
||||||
|
#endif
|
||||||
|
#elif defined(OS_FREEBSD)
|
||||||
|
#define st_atimensec st_atimespec.tv_nsec
|
||||||
|
#define st_mtimensec st_mtimespec.tv_nsec
|
||||||
|
#define st_ctimensec st_ctimespec.tv_nsec
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "shared_func.h"
|
#include "shared_func.h"
|
||||||
#include "sched_thread.h"
|
#include "sched_thread.h"
|
||||||
|
|
@ -87,6 +89,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FastProcessInfo *processes;
|
FastProcessInfo *processes;
|
||||||
struct fast_sysinfo info;
|
struct fast_sysinfo info;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
get_processes(&processes, &count);
|
get_processes(&processes, &count);
|
||||||
printf("process count: %d\n", count);
|
printf("process count: %d\n", count);
|
||||||
|
|
@ -117,7 +120,13 @@ int main(int argc, char *argv[])
|
||||||
printf("freeswap: %ld\n", info.freeswap);
|
printf("freeswap: %ld\n", info.freeswap);
|
||||||
printf("procs: %d\n", info.procs);
|
printf("procs: %d\n", info.procs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stat("/dev/null", &st);
|
||||||
|
printf("file access time: %d.%ld\n", (int)st.st_atime, st.st_atimensec);
|
||||||
|
printf("file modify time: %d.%ld\n", (int)st.st_mtime, st.st_mtimensec);
|
||||||
|
printf("file change time: %d.%ld\n", (int)st.st_ctime, st.st_ctimensec);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((result=iniLoadFromFile(filename, &iniContext)) != 0) {
|
if ((result=iniLoadFromFile(filename, &iniContext)) != 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue