1328653Shselasky/*- 2328653Shselasky * Copyright (c) 2017 Mellanox Technologies, Ltd. 3328653Shselasky * All rights reserved. 4328653Shselasky * 5328653Shselasky * Redistribution and use in source and binary forms, with or without 6328653Shselasky * modification, are permitted provided that the following conditions 7328653Shselasky * are met: 8328653Shselasky * 1. Redistributions of source code must retain the above copyright 9328653Shselasky * notice unmodified, this list of conditions, and the following 10328653Shselasky * disclaimer. 11328653Shselasky * 2. Redistributions in binary form must reproduce the above copyright 12328653Shselasky * notice, this list of conditions and the following disclaimer in the 13328653Shselasky * documentation and/or other materials provided with the distribution. 14328653Shselasky * 15328653Shselasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16328653Shselasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17328653Shselasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18328653Shselasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19328653Shselasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20328653Shselasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21328653Shselasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22328653Shselasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23328653Shselasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24328653Shselasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25328653Shselasky * 26328653Shselasky * $FreeBSD: stable/11/sys/compat/linuxkpi/common/include/linux/pid.h 329963 2018-02-25 10:28:06Z hselasky $ 27328653Shselasky */ 28328653Shselasky 29328653Shselasky#ifndef _LINUX_PID_H_ 30328653Shselasky#define _LINUX_PID_H_ 31328653Shselasky 32328653Shselasky#include <sys/param.h> 33328653Shselasky#include <sys/systm.h> 34328653Shselasky#include <sys/proc.h> 35328653Shselasky 36328653Shselaskyenum pid_type { 37328653Shselasky PIDTYPE_PID, 38328653Shselasky PIDTYPE_PGID, 39328653Shselasky PIDTYPE_SID, 40328653Shselasky PIDTYPE_MAX 41328653Shselasky}; 42328653Shselasky 43328653Shselasky#define pid_nr(n) (n) 44328653Shselasky#define pid_vnr(n) (n) 45328653Shselasky#define from_kuid_munged(a, uid) (uid) 46328653Shselasky 47328653Shselasky#define pid_task(pid, type) ({ \ 48328653Shselasky struct task_struct *__ts; \ 49328653Shselasky CTASSERT((type) == PIDTYPE_PID); \ 50328653Shselasky __ts = linux_pid_task(pid); \ 51328653Shselasky __ts; \ 52328653Shselasky}) 53328653Shselasky 54328653Shselasky#define get_pid_task(pid, type) ({ \ 55328653Shselasky struct task_struct *__ts; \ 56328653Shselasky CTASSERT((type) == PIDTYPE_PID); \ 57328653Shselasky __ts = linux_get_pid_task(pid); \ 58328653Shselasky __ts; \ 59328653Shselasky}) 60328653Shselasky 61329963Shselasky#define get_task_pid(task, type) ({ \ 62329963Shselasky CTASSERT((type) == PIDTYPE_PID); \ 63329963Shselasky (task)->task_thread->td_tid; \ 64329963Shselasky}) 65329963Shselasky 66328653Shselaskystruct task_struct; 67328653Shselaskyextern struct task_struct *linux_pid_task(pid_t); 68328653Shselaskyextern struct task_struct *linux_get_pid_task(pid_t); 69328653Shselasky 70328653Shselasky#endif /* _LINUX_PID_H_ */ 71