mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 14:31:36 +07:00
2b43834706
Add a 'ptr' field to fdarray->priv array. This feature will be used by following commits, which introduce muiltiple 'struct perf_mmap' arrays for different types of mapping. Because of this, during fdarray__filter(), a simple 'idx' is not enough. Add a pointer cookie that allows to directly associate a 'struct perf_mmap' pointer to an fdarray entry. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: He Kuang <hekuang@huawei.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nilay Vaish <nilayvaish@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1468485287-33422-3-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
#ifndef __API_FD_ARRAY__
|
|
#define __API_FD_ARRAY__
|
|
|
|
#include <stdio.h>
|
|
|
|
struct pollfd;
|
|
|
|
/**
|
|
* struct fdarray: Array of file descriptors
|
|
*
|
|
* @priv: Per array entry priv area, users should access just its contents,
|
|
* not set it to anything, as it is kept in synch with @entries, being
|
|
* realloc'ed, * for instance, in fdarray__{grow,filter}.
|
|
*
|
|
* I.e. using 'fda->priv[N].idx = * value' where N < fda->nr is ok,
|
|
* but doing 'fda->priv = malloc(M)' is not allowed.
|
|
*/
|
|
struct fdarray {
|
|
int nr;
|
|
int nr_alloc;
|
|
int nr_autogrow;
|
|
struct pollfd *entries;
|
|
union {
|
|
int idx;
|
|
void *ptr;
|
|
} *priv;
|
|
};
|
|
|
|
void fdarray__init(struct fdarray *fda, int nr_autogrow);
|
|
void fdarray__exit(struct fdarray *fda);
|
|
|
|
struct fdarray *fdarray__new(int nr_alloc, int nr_autogrow);
|
|
void fdarray__delete(struct fdarray *fda);
|
|
|
|
int fdarray__add(struct fdarray *fda, int fd, short revents);
|
|
int fdarray__poll(struct fdarray *fda, int timeout);
|
|
int fdarray__filter(struct fdarray *fda, short revents,
|
|
void (*entry_destructor)(struct fdarray *fda, int fd, void *arg),
|
|
void *arg);
|
|
int fdarray__grow(struct fdarray *fda, int extra);
|
|
int fdarray__fprintf(struct fdarray *fda, FILE *fp);
|
|
|
|
static inline int fdarray__available_entries(struct fdarray *fda)
|
|
{
|
|
return fda->nr_alloc - fda->nr;
|
|
}
|
|
|
|
#endif /* __API_FD_ARRAY__ */
|