2015-06-18 14:39:38 -05:00
|
|
|
/*
|
2016-03-30 14:44:27 -05:00
|
|
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
2015-06-18 14:39:38 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "classfile/stringTable.hpp"
|
|
|
|
#include "classfile/symbolTable.hpp"
|
|
|
|
#include "gc/shared/referenceProcessor.hpp"
|
|
|
|
#include "runtime/arguments.hpp"
|
|
|
|
#include "runtime/commandLineFlagConstraintList.hpp"
|
|
|
|
#include "runtime/commandLineFlagConstraintsCompiler.hpp"
|
|
|
|
#include "runtime/commandLineFlagConstraintsGC.hpp"
|
|
|
|
#include "runtime/commandLineFlagConstraintsRuntime.hpp"
|
|
|
|
#include "runtime/os.hpp"
|
|
|
|
#include "utilities/macros.hpp"
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_bool : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_bool _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_bool(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_bool func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_bool(bool value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_int : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_int _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_int(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_int func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_int(int value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_intx : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_intx _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_intx(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_intx func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_intx(intx value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_uint : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_uint _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_uint(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_uint func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_uint(uint value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_uintx : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_uintx _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_uintx(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_uintx func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_uintx(uintx value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_uint64_t : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_uint64_t _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_uint64_t(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_uint64_t func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_uint64_t(uint64_t value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_size_t : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_size_t _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_size_t(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_size_t func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_size_t(size_t value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandLineFlagConstraint_double : public CommandLineFlagConstraint {
|
|
|
|
CommandLineFlagConstraintFunc_double _constraint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// the "name" argument must be a string literal
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint_double(const char* name,
|
|
|
|
CommandLineFlagConstraintFunc_double func,
|
|
|
|
ConstraintType type) : CommandLineFlagConstraint(name, type) {
|
2015-06-18 14:39:38 -05:00
|
|
|
_constraint=func;
|
|
|
|
}
|
|
|
|
|
2015-08-13 17:17:56 -05:00
|
|
|
Flag::Error apply_double(double value, bool verbose) {
|
|
|
|
return _constraint(value, verbose);
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// No constraint emitting
|
|
|
|
void emit_constraint_no(...) { /* NOP */ }
|
|
|
|
|
|
|
|
// No constraint emitting if function argument is NOT provided
|
|
|
|
void emit_constraint_bool(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_ccstr(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_ccstrlist(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_int(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_intx(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_uint(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_uintx(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_uint64_t(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_size_t(const char* /*name*/) { /* NOP */ }
|
|
|
|
void emit_constraint_double(const char* /*name*/) { /* NOP */ }
|
|
|
|
|
|
|
|
// CommandLineFlagConstraint emitting code functions if function argument is provided
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_bool(const char* name, CommandLineFlagConstraintFunc_bool func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_bool(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_int(const char* name, CommandLineFlagConstraintFunc_int func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_int(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_intx(const char* name, CommandLineFlagConstraintFunc_intx func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_intx(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_uint(const char* name, CommandLineFlagConstraintFunc_uint func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_uintx(const char* name, CommandLineFlagConstraintFunc_uintx func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uintx(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_uint64_t(const char* name, CommandLineFlagConstraintFunc_uint64_t func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_uint64_t(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_size_t(const char* name, CommandLineFlagConstraintFunc_size_t func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_size_t(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
void emit_constraint_double(const char* name, CommandLineFlagConstraintFunc_double func, CommandLineFlagConstraint::ConstraintType type) {
|
|
|
|
CommandLineFlagConstraintList::add(new CommandLineFlagConstraint_double(name, func, type));
|
2015-06-18 14:39:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate code to call emit_constraint_xxx function
|
|
|
|
#define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_COMMERCIAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_MANAGEABLE_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_PD_PRODUCT_FLAG(type, name, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_DEVELOPER_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_PD_DEVELOPER_FLAG(type, name, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
#define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name
|
|
|
|
|
|
|
|
// Generate func argument to pass into emit_constraint_xxx functions
|
2015-07-27 13:56:26 -07:00
|
|
|
#define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type
|
2015-06-18 14:39:38 -05:00
|
|
|
|
|
|
|
// the "name" argument must be a string literal
|
2015-12-04 15:24:14 -08:00
|
|
|
#define INITIAL_CONSTRAINTS_SIZE 72
|
2015-06-18 14:39:38 -05:00
|
|
|
GrowableArray<CommandLineFlagConstraint*>* CommandLineFlagConstraintList::_constraints = NULL;
|
2015-07-27 13:56:26 -07:00
|
|
|
CommandLineFlagConstraint::ConstraintType CommandLineFlagConstraintList::_validating_type = CommandLineFlagConstraint::AtParse;
|
2015-06-18 14:39:38 -05:00
|
|
|
|
|
|
|
// Check the ranges of all flags that have them or print them out and exit if requested
|
|
|
|
void CommandLineFlagConstraintList::init(void) {
|
2015-07-27 13:56:26 -07:00
|
|
|
_constraints = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<CommandLineFlagConstraint*>(INITIAL_CONSTRAINTS_SIZE, true);
|
2015-06-18 14:39:38 -05:00
|
|
|
|
|
|
|
emit_constraint_no(NULL RUNTIME_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
|
|
|
|
EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
|
|
|
|
EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_MANAGEABLE_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
|
|
|
|
EMIT_CONSTRAINT_LP64_PRODUCT_FLAG,
|
|
|
|
IGNORE_RANGE,
|
|
|
|
EMIT_CONSTRAINT_CHECK));
|
|
|
|
|
|
|
|
EMIT_CONSTRAINTS_FOR_GLOBALS_EXT
|
|
|
|
|
|
|
|
emit_constraint_no(NULL ARCH_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
|
|
|
|
EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
|
|
|
|
EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
|
|
|
|
IGNORE_RANGE,
|
|
|
|
EMIT_CONSTRAINT_CHECK));
|
|
|
|
|
2015-10-08 12:49:30 -10:00
|
|
|
|
2015-06-18 14:39:38 -05:00
|
|
|
#ifdef COMPILER1
|
|
|
|
emit_constraint_no(NULL C1_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
|
|
|
|
EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
|
|
|
|
IGNORE_RANGE,
|
|
|
|
EMIT_CONSTRAINT_CHECK));
|
|
|
|
#endif // COMPILER1
|
|
|
|
|
|
|
|
#ifdef COMPILER2
|
|
|
|
emit_constraint_no(NULL C2_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
|
|
|
|
EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
|
|
|
|
EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
|
|
|
|
IGNORE_RANGE,
|
|
|
|
EMIT_CONSTRAINT_CHECK));
|
|
|
|
#endif // COMPILER2
|
|
|
|
|
2015-10-05 14:56:19 -07:00
|
|
|
#if INCLUDE_ALL_GCS
|
2015-06-18 14:39:38 -05:00
|
|
|
emit_constraint_no(NULL G1_FLAGS(EMIT_CONSTRAINT_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_DEVELOPER_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PD_PRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_DIAGNOSTIC_FLAG,
|
|
|
|
EMIT_CONSTRAINT_EXPERIMENTAL_FLAG,
|
|
|
|
EMIT_CONSTRAINT_NOTPRODUCT_FLAG,
|
|
|
|
EMIT_CONSTRAINT_MANAGEABLE_FLAG,
|
|
|
|
EMIT_CONSTRAINT_PRODUCT_RW_FLAG,
|
|
|
|
IGNORE_RANGE,
|
|
|
|
EMIT_CONSTRAINT_CHECK));
|
|
|
|
#endif // INCLUDE_ALL_GCS
|
|
|
|
}
|
|
|
|
|
2016-03-30 14:44:27 -05:00
|
|
|
CommandLineFlagConstraint* CommandLineFlagConstraintList::find(const char* name) {
|
2015-06-18 14:39:38 -05:00
|
|
|
CommandLineFlagConstraint* found = NULL;
|
|
|
|
for (int i=0; i<length(); i++) {
|
|
|
|
CommandLineFlagConstraint* constraint = at(i);
|
2016-03-30 14:44:27 -05:00
|
|
|
if (strcmp(constraint->name(), name) == 0) {
|
2015-06-18 14:39:38 -05:00
|
|
|
found = constraint;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
2015-07-27 13:56:26 -07:00
|
|
|
|
2016-03-30 14:44:27 -05:00
|
|
|
// Find constraints by name and return only if found constraint's type is equal or lower than current validating type.
|
|
|
|
CommandLineFlagConstraint* CommandLineFlagConstraintList::find_if_needs_check(const char* name) {
|
|
|
|
CommandLineFlagConstraint* found = NULL;
|
|
|
|
CommandLineFlagConstraint* constraint = find(name);
|
|
|
|
if (constraint && (constraint->type() <= _validating_type)) {
|
|
|
|
found = constraint;
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2015-07-27 13:56:26 -07:00
|
|
|
// Check constraints for specific constraint type.
|
|
|
|
bool CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::ConstraintType type) {
|
2015-10-05 14:56:19 -07:00
|
|
|
guarantee(type > _validating_type, "Constraint check is out of order.");
|
2015-07-27 13:56:26 -07:00
|
|
|
_validating_type = type;
|
|
|
|
|
|
|
|
bool status = true;
|
|
|
|
for (int i=0; i<length(); i++) {
|
|
|
|
CommandLineFlagConstraint* constraint = at(i);
|
|
|
|
if (type != constraint->type()) continue;
|
2015-08-13 17:17:56 -05:00
|
|
|
const char* name = constraint->name();
|
2015-07-27 13:56:26 -07:00
|
|
|
Flag* flag = Flag::find_flag(name, strlen(name), true, true);
|
2015-08-13 17:17:56 -05:00
|
|
|
// We must check for NULL here as lp64_product flags on 32 bit architecture
|
|
|
|
// can generate constraint check (despite that they are declared as constants),
|
|
|
|
// but they will not be returned by Flag::find_flag()
|
2015-07-27 13:56:26 -07:00
|
|
|
if (flag != NULL) {
|
|
|
|
if (flag->is_bool()) {
|
|
|
|
bool value = flag->get_bool();
|
2015-08-13 17:17:56 -05:00
|
|
|
if (constraint->apply_bool(value, true) != Flag::SUCCESS) status = false;
|
|
|
|
} else if (flag->is_int()) {
|
|
|
|
int value = flag->get_int();
|
|
|
|
if (constraint->apply_int(value, true) != Flag::SUCCESS) status = false;
|
|
|
|
} else if (flag->is_uint()) {
|
|
|
|
uint value = flag->get_uint();
|
|
|
|
if (constraint->apply_uint(value, true) != Flag::SUCCESS) status = false;
|
2015-07-27 13:56:26 -07:00
|
|
|
} else if (flag->is_intx()) {
|
|
|
|
intx value = flag->get_intx();
|
2015-08-13 17:17:56 -05:00
|
|
|
if (constraint->apply_intx(value, true) != Flag::SUCCESS) status = false;
|
2015-07-27 13:56:26 -07:00
|
|
|
} else if (flag->is_uintx()) {
|
|
|
|
uintx value = flag->get_uintx();
|
2015-08-13 17:17:56 -05:00
|
|
|
if (constraint->apply_uintx(value, true) != Flag::SUCCESS) status = false;
|
2015-07-27 13:56:26 -07:00
|
|
|
} else if (flag->is_uint64_t()) {
|
|
|
|
uint64_t value = flag->get_uint64_t();
|
2015-08-13 17:17:56 -05:00
|
|
|
if (constraint->apply_uint64_t(value, true) != Flag::SUCCESS) status = false;
|
2015-07-27 13:56:26 -07:00
|
|
|
} else if (flag->is_size_t()) {
|
|
|
|
size_t value = flag->get_size_t();
|
2015-08-13 17:17:56 -05:00
|
|
|
if (constraint->apply_size_t(value, true) != Flag::SUCCESS) status = false;
|
2015-07-27 13:56:26 -07:00
|
|
|
} else if (flag->is_double()) {
|
|
|
|
double value = flag->get_double();
|
2015-08-13 17:17:56 -05:00
|
|
|
if (constraint->apply_double(value, true) != Flag::SUCCESS) status = false;
|
2015-07-27 13:56:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|