cregit-Linux how code gets into the kernel

Release 4.18 include/linux/poll.h

Directory: include/linux
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_POLL_H

#define _LINUX_POLL_H


#include <linux/compiler.h>
#include <linux/ktime.h>
#include <linux/wait.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/sysctl.h>
#include <linux/uaccess.h>
#include <uapi/linux/poll.h>
#include <uapi/linux/eventpoll.h>

extern struct ctl_table epoll_table[]; /* for sysctl */
/* ~832 bytes of stack space used max in sys_select/sys_poll before allocating
   additional memory. */

#define MAX_STACK_ALLOC 832

#define FRONTEND_STACK_ALLOC	256

#define SELECT_STACK_ALLOC	FRONTEND_STACK_ALLOC

#define POLL_STACK_ALLOC	FRONTEND_STACK_ALLOC

#define WQUEUES_STACK_ALLOC	(MAX_STACK_ALLOC - FRONTEND_STACK_ALLOC)

#define N_INLINE_POLL_ENTRIES	(WQUEUES_STACK_ALLOC / sizeof(struct poll_table_entry))


#define DEFAULT_POLLMASK (EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM)

struct poll_table_struct;

/* 
 * structures and helpers for f_op->poll implementations
 */

typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);

/*
 * Do not touch the structure directly, use the access functions
 * poll_does_not_wait() and poll_requested_events() instead.
 */

typedef struct poll_table_struct {
	
poll_queue_proc _qproc;
	
__poll_t _key;

} poll_table;


static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) { if (p && p->_qproc && wait_address) p->_qproc(filp, wait_address, p); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3380.49%562.50%
Hans Verkuil512.20%112.50%
Davide Libenzi24.88%112.50%
Linus Torvalds12.44%112.50%
Total41100.00%8100.00%

/* * Return true if it is guaranteed that poll will not wait. This is the case * if the poll() of another file descriptor in the set got an event, so there * is no need for waiting. */
static inline bool poll_does_not_wait(const poll_table *p) { return p == NULL || p->_qproc == NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Hans Verkuil23100.00%1100.00%
Total23100.00%1100.00%

/* * Return the set of events that the application wants to poll for. * This is useful for drivers that need to know whether a DMA transfer has * to be started implicitly on poll(). You typically only want to do that * if the application is actually polling for POLLIN and/or POLLOUT. */
static inline __poll_t poll_requested_events(const poll_table *p) { return p ? p->_key : ~(__poll_t)0; }

Contributors

PersonTokensPropCommitsCommitProp
Hans Verkuil2080.00%150.00%
Al Viro520.00%150.00%
Total25100.00%2100.00%


static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc) { pt->_qproc = qproc; pt->_key = ~(__poll_t)0; /* all events enabled */ }

Contributors

PersonTokensPropCommitsCommitProp
Davide Libenzi1754.84%233.33%
Eric Dumazet619.35%116.67%
Al Viro412.90%116.67%
Manfred Spraul26.45%116.67%
Hans Verkuil26.45%116.67%
Total31100.00%6100.00%


static inline bool file_can_poll(struct file *file) { return file->f_op->poll; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1789.47%150.00%
Linus Torvalds210.53%150.00%
Total19100.00%2100.00%


static inline __poll_t vfs_poll(struct file *file, struct poll_table_struct *pt) { if (unlikely(!file->f_op->poll)) return DEFAULT_POLLMASK; return file->f_op->poll(file, pt); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds2454.55%150.00%
Christoph Hellwig2045.45%150.00%
Total44100.00%2100.00%

struct poll_table_entry { struct file *filp; __poll_t key; wait_queue_entry_t wait; wait_queue_head_t *wait_address; }; /* * Structures and helpers for select/poll syscall */ struct poll_wqueues { poll_table pt; struct poll_table_page *table; struct task_struct *polling_task; int triggered; int error; int inline_index; struct poll_table_entry inline_entries[N_INLINE_POLL_ENTRIES]; }; extern void poll_initwait(struct poll_wqueues *pwq); extern void poll_freewait(struct poll_wqueues *pwq); extern u64 select_estimate_accuracy(struct timespec64 *tv); #define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1) extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timespec64 *end_time); extern int poll_select_set_timeout(struct timespec64 *to, time64_t sec, long nsec); #define __MAP(v, from, to) \ (from < to ? (v & from) * (to/from) : (v & from) / (from/to))
static inline __u16 mangle_poll(__poll_t val) { __u16 v = (__force __u16)val; #define M(X) __MAP(v, (__force __u16)EPOLL##X, POLL##X) return M(IN) | M(OUT) | M(PRI) | M(ERR) | M(NVAL) | M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) | M(HUP) | M(RDHUP) | M(MSG); #undef M }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro90100.00%1100.00%
Total90100.00%1100.00%


static inline __poll_t demangle_poll(u16 val) { #define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X) return M(IN) | M(OUT) | M(PRI) | M(ERR) | M(NVAL) | M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) | M(HUP) | M(RDHUP) | M(MSG); #undef M }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro81100.00%1100.00%
Total81100.00%1100.00%

#undef __MAP #endif /* _LINUX_POLL_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
Al Viro22636.81%614.29%
Linus Torvalds (pre-git)6410.42%1023.81%
Hans Verkuil558.96%12.38%
Davide Libenzi518.31%37.14%
Andi Kleen518.31%12.38%
Christoph Hellwig376.03%12.38%
Linus Torvalds284.56%37.14%
Manfred Spraul264.23%12.38%
Thomas Gleixner142.28%12.38%
Dave Young101.63%12.38%
Tejun Heo91.47%12.38%
Eric Dumazet91.47%12.38%
Alexey Dobriyan71.14%24.76%
Shawn Bohrer71.14%12.38%
Deepa Dinamani40.65%12.38%
David Woodhouse40.65%12.38%
David Howells30.49%12.38%
Andrew Morton30.49%12.38%
Arjan van de Ven20.33%12.38%
Greg Kroah-Hartman10.16%12.38%
Ingo Molnar10.16%12.38%
John Stultz10.16%12.38%
Namhyung Kim10.16%12.38%
Total614100.00%42100.00%
Directory: include/linux
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.