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