cppthread 1.1.16
C++ Thread Library
has_vdso.cpp
Go to the documentation of this file.
1// Copyright (c) 2020-2025 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/cppthread
4// contact@m2osw.com
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
17// with this program; if not, write to the Free Software Foundation, Inc.,
18// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
45// cppthread
46//
47#include <cppthread/thread.h>
48
49
50// libexcept
51//
52#include <libexcept/file_inheritance.h>
53
54
55// C++
56//
57#include <iostream>
58
59
60// C
61//
62#include <string.h>
63
64
65// last include
66//
67#include <snapdev/poison.h>
68
69
70void usage(char * progname)
71{
72 std::cout << "Usage: " << progname << " [-v] [-q] [-h|--help]\n";
73 std::cout << "where options are:\n";
74 std::cout << " -v be more verbose\n";
75 std::cout << " -q be quiet\n";
76 std::cout << " -h | --help print out this help screen\n";
77}
78
79
80int main(int argc, char * argv[])
81{
82 libexcept::verify_inherited_files();
83
84 bool verbose(false);
85 bool quiet(false);
86 for(int i(1); i < argc; ++i)
87 {
88 if(strcmp(argv[i], "-v") == 0)
89 {
90 verbose = true;
91 }
92 else if(strcmp(argv[i], "-q") == 0)
93 {
94 quiet = true;
95 }
96 else if(strcmp(argv[i], "-h") == 0
97 || strcmp(argv[i], "--help") == 0)
98 {
99 usage(argv[0]);
100 return 1;
101 }
102 else
103 {
104 std::cerr << "error: unsupported command line option \""
105 << argv[i]
106 << "\"."
107 << std::endl;
108 return 1;
109 }
110 }
111
112 if(cppthread::is_using_vdso())
113 {
114 if(verbose)
115 {
116 std::cout << "the vDSO is active" << std::endl;
117 }
118 else if(!quiet)
119 {
120 std::cout << "true" << std::endl;
121 }
122 return 0;
123 }
124 else
125 {
126 if(verbose)
127 {
128 std::cout << "no vDSO was detected" << std::endl;
129 }
130 else if(!quiet)
131 {
132 std::cout << "false" << std::endl;
133 }
134 return 1;
135 }
136}
137
138// vim: ts=4 sw=4 et
Thread Runner and Managers.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.