1 /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/prctl.h>
10 #include <pthread.h>
11 #include <errno.h>
12
13 // little crc-like thing, compiler won't optimize it out
do_something(int seed,unsigned int loops)14 static int do_something(int seed, unsigned int loops) {
15 int i;
16 for (i = 0; i < loops; i++) {
17 seed ^= i;
18 seed = (seed << 1) ^ (i & 0x80000000 ? 0x04C11DB7 : 0);
19 }
20 return i;
21 }
22
23
main(int argc,char * argv[])24 int main(int argc, char* argv[]) {
25 int loops;
26 char *name;
27
28 if (argc < 3) {
29 fprintf(stderr, "usage: <name> <loops>\n");
30 return 1;
31 }
32
33 name = argv[1];
34 loops = strtoul(argv[2], NULL, 10);
35
36 if (prctl(PR_SET_NAME, name) < 0) {
37 perror("prctl(PR_SET_NAME)");
38 return 1;
39 }
40 do_something(rand(), loops);
41
42 return 0;
43 }
44