watch_arg: greater_flag -> above_threshold
This commit is contained in:
@@ -42,3 +42,17 @@ int cancel_watch() {
|
||||
file_desc = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_watch_arg(watch_arg *wg, char *name, void *ptr,
|
||||
int length_byte, long long threshold,
|
||||
unsigned char unsigned_flag,
|
||||
unsigned char above_threshold, unsigned long time_ns){
|
||||
wg->task_id = getpid();
|
||||
strncpy(wg->name, name, (MAX_NAME_LEN + 1));
|
||||
wg->ptr = ptr;
|
||||
wg->length_byte = length_byte;
|
||||
wg->threshold = threshold;
|
||||
wg->unsigned_flag = unsigned_flag;
|
||||
wg->above_threshold = above_threshold;
|
||||
wg->time_ns = time_ns;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#ifndef UAPI_MONITOR_H
|
||||
#define UAPI_MONITOR_H
|
||||
// monitor_interface.h
|
||||
#include "monitor_user_sw.h"
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_NAME_LEN (15) // max name length
|
||||
|
||||
typedef struct {
|
||||
pid_t task_id; // current process id
|
||||
char name[MAX_NAME_LEN + 1]; // name
|
||||
@@ -9,12 +15,18 @@ typedef struct {
|
||||
int length_byte; // byte
|
||||
long long threshold; // threshold value
|
||||
unsigned char unsigned_flag; // unsigned flag (true: unsigned, false: signed)
|
||||
unsigned char greater_flag; // reverse flag (true: >, false: <)
|
||||
unsigned char above_threshold; // reverse flag (true: >, false: <)
|
||||
unsigned long time_ns; // timer interval (ns)
|
||||
} watch_arg;
|
||||
|
||||
void init_watch_arg(watch_arg *wg, char *name, void *ptr, int length_byte,
|
||||
long long threshold, unsigned char unsigned_flag,
|
||||
unsigned char above_threshold, unsigned long time_ns);
|
||||
|
||||
// start watch
|
||||
int start_watch(watch_arg w_arg);
|
||||
|
||||
// cancel watch
|
||||
int cancel_watch(void);
|
||||
int cancel_watch(void);
|
||||
|
||||
#endif
|
||||
165
source/uapi/monitor_user_sw.h
Normal file
165
source/uapi/monitor_user_sw.h
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef UAPI_MONITOR_SW_H
|
||||
#define UAPI_MONITOR_SW_H
|
||||
|
||||
#define SWATCH_CHAR(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(char); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 0; \
|
||||
w_arg.above_threshold = 0; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_CHAR_LESS(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(char); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 0; \
|
||||
w_arg.above_threshold = 1; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_UCHAR(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(unsigned char); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 1; \
|
||||
w_arg.above_threshold = 0; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_UCHAR_LESS(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(unsigned char); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 1; \
|
||||
w_arg.above_threshold = 1; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_INT(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg = {0}; \
|
||||
init_watch_arg(&w_arg, name, ptr, sizeof(int), threshold, 0, 1, 0); \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_INT_LESS(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(int); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 0; \
|
||||
w_arg.above_threshold = 1; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_UINT(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(unsigned int); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 1; \
|
||||
w_arg.above_threshold = 0; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_UINT_LESS(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(unsigned int); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 1; \
|
||||
w_arg.above_threshold = 1; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_LONG(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(long); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 0; \
|
||||
w_arg.above_threshold = 0; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_LONG_LESS(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(long); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 0; \
|
||||
w_arg.above_threshold = 1; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_ULONG(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(unsigned long); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 1; \
|
||||
w_arg.above_threshold = 0; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#define SWATCH_ULONG_LESS(name, ptr, threshold) \
|
||||
do { \
|
||||
watch_arg w_arg; \
|
||||
w_arg.task_id = getpid(); \
|
||||
strncpy(w_arg.name, name, MAX_NAME_LEN); \
|
||||
w_arg.ptr = ptr; \
|
||||
w_arg.length_byte = sizeof(unsigned long); \
|
||||
w_arg.threshold = threshold; \
|
||||
w_arg.unsigned_flag = 1; \
|
||||
w_arg.above_threshold = 1; \
|
||||
w_arg.time_ns = 0; \
|
||||
start_watch(w_arg); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user