macro: introduce new PID_TO_PTR macros and make use of them
This adds a new PID_TO_PTR() macro, plus PTR_TO_PID() and makes use of it wherever we maintain processes in a hash table. Previously we sometimes used LONG_TO_PTR() and other times ULONG_TO_PTR() for that, hence let's make this more explicit and clean up things.
This commit is contained in:
@@ -187,7 +187,7 @@ int cg_kill(const char *controller, const char *path, int sig, bool sigcont, boo
|
||||
if (ignore_self && pid == my_pid)
|
||||
continue;
|
||||
|
||||
if (set_get(s, LONG_TO_PTR(pid)) == LONG_TO_PTR(pid))
|
||||
if (set_get(s, PID_TO_PTR(pid)) == PID_TO_PTR(pid))
|
||||
continue;
|
||||
|
||||
/* If we haven't killed this process yet, kill
|
||||
@@ -205,7 +205,7 @@ int cg_kill(const char *controller, const char *path, int sig, bool sigcont, boo
|
||||
|
||||
done = false;
|
||||
|
||||
r = set_put(s, LONG_TO_PTR(pid));
|
||||
r = set_put(s, PID_TO_PTR(pid));
|
||||
if (r < 0) {
|
||||
if (ret >= 0)
|
||||
return r;
|
||||
@@ -318,7 +318,7 @@ int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char
|
||||
if (ignore_self && pid == my_pid)
|
||||
continue;
|
||||
|
||||
if (set_get(s, LONG_TO_PTR(pid)) == LONG_TO_PTR(pid))
|
||||
if (set_get(s, PID_TO_PTR(pid)) == PID_TO_PTR(pid))
|
||||
continue;
|
||||
|
||||
/* Ignore kernel threads. Since they can only
|
||||
@@ -338,7 +338,7 @@ int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char
|
||||
|
||||
done = false;
|
||||
|
||||
r = set_put(s, LONG_TO_PTR(pid));
|
||||
r = set_put(s, PID_TO_PTR(pid));
|
||||
if (r < 0) {
|
||||
if (ret >= 0)
|
||||
return r;
|
||||
@@ -1898,7 +1898,7 @@ int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids,
|
||||
int r = 0;
|
||||
|
||||
SET_FOREACH(pidp, pids, i) {
|
||||
pid_t pid = PTR_TO_LONG(pidp);
|
||||
pid_t pid = PTR_TO_PID(pidp);
|
||||
int q;
|
||||
|
||||
q = cg_attach_everywhere(supported, path, pid, path_callback, userdata);
|
||||
|
||||
@@ -298,6 +298,9 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
|
||||
#define PTR_TO_GID(p) ((gid_t) (((uintptr_t) (p))-1))
|
||||
#define GID_TO_PTR(u) ((void*) (((uintptr_t) (u))+1))
|
||||
|
||||
#define PTR_TO_PID(p) ((pid_t) ((uintptr_t) p))
|
||||
#define PID_TO_PTR(p) ((void*) ((uintptr_t) p))
|
||||
|
||||
#define memzero(x,l) (memset((x), 0, (l)))
|
||||
#define zero(x) (memzero(&(x), sizeof(x)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user