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 | |
| 1 | 2 | ||
| 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) | |
| 6 | 9 | ||
| 7 | - | #include <sys/types.h> | |
| 10 | + | builtin cat | |
| 8 | - | #include <sys/stat.h> | |
| 11 | + | builtin wc | |
| 9 | - | #include <fcntl.h> | |
| 12 | + | #builtin rm | |
| 18 | 13 | ||
| 14 | + | set -o nounset | |
| 19 | 15 | ||
| 20 | - | #ifndef CLOCK_INVALID | |
| 16 | + | function enumerate_clock_sources | |
| 17 | + | { | |
| 23 | 21 | ||
| 24 | - | #define NSEC_PER_SEC (1000000000LL) | |
| 22 | + | s="$( clang -E -dM -m32 -include time.h - < '/dev/null' | \ | |
| 23 | + | egrep \ | |
| 25 | 26 | ||
| 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 | |
| 31 | 37 | ||
| 32 | - | return (((unsigned int) ~fd) << 3) | CLOCKFD; | |
| 38 | + | return 0 | |
| 33 | 39 | } | |
| 34 | 40 | ||
| 41 | + | function generate_test_code | |
| 35 | 44 | ||
| 36 | - | static | |
| 45 | + | set -o errexit | |
| 41 | 46 | ||
| 42 | - | for(cycles = 0UL ; cycles < num_cycles ; cycles++) | |
| 47 | + | printf $"## Generating test code...\n" | |
| 48 | 48 | ||
| 49 | + | rm -f \ | |
| 49 | 52 | ||
| 51 | 53 | { | |
| 52 | - | const char *clockname = av[1]; | |
| 54 | + | cat <<EOF | |
| 53 | 55 | ||
| 54 | - | (void)puts("# start."); | |
| 56 | + | /* | |
| 57 | + | * count_timer_syscalls.c - runs timer NUM_TESTRUNS times, | |
| 55 | 64 | ||
| 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> | |
| 60 | 76 | ||
| 65 | 77 | ||
| 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 | |
| 70 | 81 | ||
| 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) | |
| 82 | 85 | ||
| 83 | 86 | ||
| 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.
rovema.kpaste.net RSS