Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <argp.h>
20
21
22
23
24#define OPT_TO_THREAD 300
25#define OPT_TO_PROCESS 301
26#define OPT_SYNC_SIGNAL 302
27#define OPT_SYNC_JOIN 303
28#define OPT_TOPLEVEL 304
29
30
31static const struct argp_option test_options[] =
32 {
33 { NULL, 0, NULL, 0, "\
34This is a test for threads so we allow ther user to selection the number of \
35threads which are used at any one time. Independently the total number of \
36rounds can be selected. This is the total number of threads which will have \
37run when the process terminates:" },
38 { "threads", 't', "NUMBER", 0, "Number of threads used at once" },
39 { "starts", 's', "NUMBER", 0, "Total number of working threads" },
40 { "toplevel", OPT_TOPLEVEL, "NUMBER", 0,
41 "Number of toplevel threads which start the other threads; this \
42implies --sync-join" },
43
44 { NULL, 0, NULL, 0, "\
45Each thread can do one of two things: sleep or do work. The latter is 100% \
46CPU bound. The work load is the probability a thread does work. All values \
47from zero to 100 (inclusive) are valid. How often each thread repeats this \
48can be determined by the number of rounds. The work cost determines how long \
49each work session (not sleeping) takes. If it is zero a thread would \
50effectively nothing. By setting the number of rounds to zero the thread \
51does no work at all and pure thread creation times can be measured." },
52 { "workload", 'w', "PERCENT", 0, "Percentage of time spent working" },
53 { "workcost", 'c', "NUMBER", 0,
54 "Factor in the cost of each round of working" },
55 { "rounds", 'r', "NUMBER", 0, "Number of rounds each thread runs" },
56
57 { NULL, 0, NULL, 0, "\
58There are a number of different methods how thread creation can be \
59synchronized. Synchronization is necessary since the number of concurrently \
60running threads is limited." },
61 { "sync-signal", OPT_SYNC_SIGNAL, NULL, 0,
62 "Synchronize using a signal (default)" },
63 { "sync-join", OPT_SYNC_JOIN, NULL, 0, "Synchronize using pthread_join" },
64
65 { NULL, 0, NULL, 0, "\
66One parameter for each threads execution is the size of the stack. If this \
67parameter is not used the system's default stack size is used. If many \
68threads are used the stack size should be chosen quite small." },
69 { "stacksize", 'S', "BYTES", 0, "Size of threads stack" },
70 { "guardsize", 'g', "BYTES", 0,
71 "Size of stack guard area; must fit into the stack" },
72
73 { NULL, 0, NULL, 0, "Signal options:" },
74 { "to-thread", OPT_TO_THREAD, NULL, 0, "Send signal to main thread" },
75 { "to-process", OPT_TO_PROCESS, NULL, 0,
76 "Send signal to process (default)" },
77
78 { NULL, 0, NULL, 0, "Administrative options:" },
79 { "progress", 'p', NULL, 0, "Show signs of progress" },
80 { "timing", 'T', NULL, 0,
81 "Measure time from startup to the last thread finishing" },
82 { NULL, 0, NULL, 0, NULL }
83 };
84
85/* Prototype for option handler. */
86static error_t parse_opt (int key, char *arg, struct argp_state *state);
87
88/* Data structure to communicate with argp functions. */
89static struct argp argp =
90{
91 test_options, parse_opt
92};
93
94
95static int
96do_test (void)
97{
98 int argc = 2;
99 char *argv[3] = { (char *) "tst-argp1", (char *) "--help", NULL };
100 int remaining;
101
102 /* Parse and process arguments. */
103 argp_parse (&argp, argc, argv, 0, &remaining, NULL);
104
105 return 0;
106}
107
108
109/* Handle program arguments. */
110static error_t
111parse_opt (int key, char *arg, struct argp_state *state)
112{
113 return ARGP_ERR_UNKNOWN;
114}
115
116#define TEST_FUNCTION do_test ()
117#include "../test-skeleton.c"
118

Warning: That file was not part of the compilation database. It may have many parsing errors.