X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Futil.h;h=cb47c7a0739726719ed7c0594d48edc15edc9f57;hb=99ffae46d38f05b6c8bc09fe29e50a507ae8b79b;hp=241031242121c21f46232c375269c248dd431e78;hpb=a838e6a17a40df902b50a9ce5b2e944dfc5a7e08;p=elogind.git diff --git a/src/util.h b/src/util.h index 241031242..cb47c7a07 100644 --- a/src/util.h +++ b/src/util.h @@ -29,15 +29,16 @@ #include #include #include +#include #include "macro.h" typedef uint64_t usec_t; -typedef struct timestamp { +typedef struct dual_timestamp { usec_t realtime; usec_t monotonic; -} timestamp; +} dual_timestamp; #define MSEC_PER_SEC 1000ULL #define USEC_PER_SEC 1000000ULL @@ -58,9 +59,12 @@ typedef struct timestamp { #define FORMAT_TIMESTAMP_MAX 64 #define FORMAT_TIMESPAN_MAX 64 +#define ANSI_HIGHLIGHT_ON "\x1B[1;31m" +#define ANSI_HIGHLIGHT_OFF "\x1B[0m" + usec_t now(clockid_t clock); -timestamp* timestamp_get(timestamp *ts); +dual_timestamp* dual_timestamp_get(dual_timestamp *ts); usec_t timespec_load(const struct timespec *ts); struct timespec *timespec_store(struct timespec *ts, usec_t u); @@ -179,6 +183,7 @@ int mkdir_p(const char *path, mode_t mode); int rmdir_parents(const char *path, const char *stop); int get_process_name(pid_t pid, char **name); +int get_process_cmdline(pid_t pid, size_t max_length, char **line); char hexchar(int x); int unhexchar(char c); @@ -226,7 +231,8 @@ unsigned long long random_ull(void); unsigned u = 0; \ assert(s); \ for (i = 0; i < (type)ELEMENTSOF(name##_table); i++) \ - if (streq(name##_table[i], s)) \ + if (name##_table[i] && \ + streq(name##_table[i], s)) \ return i; \ if (safe_atou(s, &u) >= 0 && \ u < ELEMENTSOF(name##_table)) \ @@ -283,6 +289,8 @@ int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); int rm_rf(const char *path, bool only_dirs, bool delete_root); +cpu_set_t* cpu_set_malloc(unsigned *ncpus); + const char *ioprio_class_to_string(int i); int ioprio_class_from_string(const char *s); @@ -301,4 +309,7 @@ int sched_policy_from_string(const char *s); const char *rlimit_to_string(int i); int rlimit_from_string(const char *s); +const char *ip_tos_to_string(int i); +int ip_tos_from_string(const char *s); + #endif