X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=b246996fcc69bc0ba6844cda91742499039bcf4a;hp=a26c1d9d0613e1f100c8c1bfe17548cd8074a338;hb=2c21044f05e32ec483b6ab13e175278779e9ebe3;hpb=0f0dbc46ccf5aaaf3131446d0a4d78bc97a37295 diff --git a/src/shared/util.h b/src/shared/util.h index a26c1d9d0..b246996fc 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -59,6 +59,17 @@ typedef struct dual_timestamp { #define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC) #define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC) +/* + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + /* What is interpreted as whitespace? */ #define WHITESPACE " \t\n\r" #define NEWLINE "\n\r" @@ -449,8 +460,6 @@ int symlink_or_copy_atomic(const char *from, const char *to); int fchmod_umask(int fd, mode_t mode); -int conf_files_list(char ***strv, const char *suffix, const char *dir, ...); - int hwclock_is_localtime(void); int hwclock_apply_localtime_delta(int *min); int hwclock_reset_localtime_delta(void); @@ -540,4 +549,6 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa int setrlimit_closest(int resource, const struct rlimit *rlim); +int getenv_for_pid(pid_t pid, const char *field, char **_value); + #endif