pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post c9be by Anonymous on Sat 17th Sep 2022 15:20
original post 78a by Anonymous on Wed 14th Sep 2022 19:02
Download diff
Show old version | new version | both versions

    
1+
#!/usr/bin/ksh93
12
2-
/*
3+
#
3-
 * count_timer_syscalls.c - runs timer 1000 times, strace can count syscalls
4+
# Count timer syscalls
4-
 *
5+
#
5-
 */
6+
# Tests whether clock_gettime() is implemented via traditional
7+
# syscalls or uses a shortcut (e.g. via shared memory/Linux VDSO)
69
7-
#include <sys/types.h>
10+
builtin cat
8-
#include <sys/stat.h>
11+
builtin wc
9-
#include <fcntl.h>
12+
#builtin rm
1813
14+
set -o nounset
1915
20-
#ifndef CLOCK_INVALID
16+
function enumerate_clock_sources
17+
{
2321
24-
#define NSEC_PER_SEC (1000000000LL)
22+
	s="$( clang -E -dM -m32 -include time.h - < '/dev/null' | \
23+
		egrep \
2526
26-
27+
	while read dummy aname avalue ; do
27-
static
28+
		if [[ \
28-
clockid_t get_clockid(int fd)
29+
			"${aname}" != ~(El)CLOCK_ || \
29-
{
30+
			"${avalue}" != ~(Elr)[[:digit:]]+ ]] ; then
30-
	const int CLOCKFD = 3;
31+
			continue
32+
		fi
3137
32-
        return (((unsigned int) ~fd) << 3) | CLOCKFD;
38+
	return 0
3339
}
3440
41+
function generate_test_code
3544
36-
static
45+
	set -o errexit
4146
42-
	for(cycles = 0UL ; cycles < num_cycles ; cycles++)
47+
	printf $"## Generating test code...\n"
4848
49+
	rm -f \
4952
5153
{
52-
	const char *clockname = av[1];
54+
		cat <<EOF
5355
54-
	(void)puts("# start.");
56+
/*
57+
 * count_timer_syscalls.c - runs timer NUM_TESTRUNS times,
5564
56-
	if ((ac != 2) || (!clockname)) {
65+
#include <sys/types.h>
57-
		(void)fprintf(stderr, "%s: Missing clockname argument\n", av[0]);
66+
#include <sys/stat.h>
58-
		return EXIT_FAILURE;
67+
#include <fcntl.h>
59-
	}
68+
#include <unistd.h>
69+
#include <time.h>
6076
6577
66-
/*
78+
#ifndef CLOCK_INVALID
67-
 * count_timer_syscalls.c - runs timer 1000 times, strace can count syscalls
79+
#define CLOCK_INVALID -1
68-
 *
80+
#endif
7081
71-
#include <sys/types.h>
82+
#define NSEC_PER_SEC (1000000000LL)
72-
#include <sys/stat.h>
83+
73-
#include <fcntl.h>
84+
#define NUM_TESTRUNS (32000UL)
8285
8386
84-
#ifndef CLOCK_INVALID
85-
#define CLOCK_INVALID -1
86-
#endif
87-
88-
#define NSEC_PER_SEC (1000000000LL)
89-
90-
87+
static

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at