X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Futil.h;h=6575f5681199108799b54dfa5fb5059538dce9b8;hp=cfb54939cd5d21730b4adcc3cf96a915a9dd58d8;hb=31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7;hpb=6606089752df90f3eeb4924af109046f1c73554c
diff --git a/src/shared/util.h b/src/shared/util.h
index cfb54939c..6575f5681 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -21,6 +21,7 @@
along with systemd; If not, see .
***/
+#include
#include
#include
#include
@@ -696,3 +697,12 @@ int unlink_noerrno(const char *path);
strcpy(stpcpy(_c_, _a_), _b_); \
_c_; \
})
+
+#define procfs_file_alloca(pid, field) \
+ ({ \
+ pid_t _pid_ = (pid); \
+ char *_r_; \
+ _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
+ sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \
+ _r_; \
+ })