#include <syscall.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

#ifndef MLOCK_ONFAULT
#define MLOCK_ONFAULT 1
#endif

#ifndef MCL_ONFAULT
#define MCL_ONFAULT (MCL_FUTURE << 1)
#endif

static int mlock2_(void *start, size_t len, int flags)
{
#ifdef __NR_mlock2
	return syscall(__NR_mlock2, start, len, flags);
#else
	errno = ENOSYS;
	return -1;
#endif
}

static FILE *seek_to_smaps_entry(unsigned long addr)
{
	FILE *file;
	char *line = NULL;
	size_t size = 0;
	unsigned long start, end;
	char perms[5];
	unsigned long offset;
	char dev[32];
	unsigned long inode;
	char path[BUFSIZ];

	file = fopen("/proc/self/smaps", "r");
	if (!file) {
		perror("fopen smaps");
		_exit(1);
	}

	while (getline(&line, &size, file) > 0) {
		if (sscanf(line, "%lx-%lx %s %lx %s %lu %s\n",
			   &start, &end, perms, &offset, dev, &inode, path) < 6)
			goto next;

		if (start <= addr && addr < end)
			goto out;

next:
		free(line);
		line = NULL;
		size = 0;
	}

	fclose(file);
	file = NULL;

out:
	free(line);
	return file;
}
ion value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=5e2ed1329ee074229d5a2f4389035be818120980'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/sound/drivers'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/sound/drivers?id=5e2ed1329ee074229d5a2f4389035be818120980'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/sound/drivers?id=5e2ed1329ee074229d5a2f4389035be818120980'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/sound/drivers?id=5e2ed1329ee074229d5a2f4389035be818120980'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/sound/drivers'>
<input type='hidden' name='id' value='5e2ed1329ee074229d5a2f4389035be818120980'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=5e2ed1329ee074229d5a2f4389035be818120980'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound?id=5e2ed1329ee074229d5a2f4389035be818120980'>sound</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/drivers?id=5e2ed1329ee074229d5a2f4389035be818120980'>drivers</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/sound/drivers?id=5e2ed1329ee074229d5a2f4389035be818120980&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
3b7b9ef24355bcba4'>pmu-events</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/pmu-events/arch?id=cd4d23c1ea9bb3769f2859b3b7b9ef24355bcba4'>arch</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/pmu-events/arch/x86?id=cd4d23c1ea9bb3769f2859b3b7b9ef24355bcba4'>x86</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/pmu-events/arch/x86/broadwell?id=cd4d23c1ea9bb3769f2859b3b7b9ef24355bcba4'>broadwell</a>/<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/pmu-events/arch/x86/broadwell/cache.json?id=cd4d23c1ea9bb3769f2859b3b7b9ef24355bcba4'>cache.json</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/tools/perf/pmu-events/arch/x86/broadwell/cache.json?id=cd4d23c1ea9bb3769f2859b3b7b9ef24355bcba4&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>