Exemple #1
0
/**
 * Compute the WCET for the given function.
 */
void Command::compute(String fun) {
	
	// Get the VCFG
	CFG *cfg = fw->getCFGInfo()->findCFG(fun);
	if(!cfg) {
		cerr << "ERROR: binary file does not contain the function \""
			 << fun << "\".\n";
		return;
	}
	VirtualCFG vcfg(cfg);
	//ENTRY_CFG(fw) = &vcfg;
		
	// Prepare processor configuration
	PropList props;
	ENTRY_CFG(props) = &vcfg;
	if(verbose) {
	  //	PROC_VERBOSE(props) = true;
		cerr << "verbose !\n";
	}
	if(dump_constraints)
		props.set(EXPLICIT, true);
	
	// Assign variables
	VarAssignment assign;
	assign.process(fw, props);
		
	// Compute BB time
       	LiExeGraphBBTime tbt(props);
	tbt.process(fw);
		
	// Build the system
	BasicConstraintsBuilder builder;
	builder.process(fw, props);
		
	// Load flow facts
	ipet::FlowFactLoader loader;
	loader.process(fw, props);

	// Build the object function to maximize
	BasicObjectFunctionBuilder fun_builder;
	fun_builder.process(fw, props);	
  
	// Resolve the system
	WCETComputation wcomp;
	wcomp.process(fw, props);
  
	// Get the results
	ilp::System *sys = SYSTEM(fw);
	cout << "WCET = " << WCET(fw) << "\n";
	// Dump the ILP system
	if(dump_constraints) {
	  String out_file = fun + ".lp";
		io::OutFileStream stream(&out_file);
//		if(!stream.isReady())
//			throw MessageException("cannot create file \"%s\".", &out_file);
		sys->dump(stream);
	}
}
Exemple #2
0
//--------------------------------------------------------------------------
// Function:	PropList::copyProp
///\brief	Copies a property from one list or class to another - Obsolete
///\param	dest - IN: Destination property list or class
///\param	src  - IN: Source property list or class
///\param	name - IN: Name of the property to copy - \c char pointer
///\note	This member function will be removed in the next release
///\exception	H5::PropListIException
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void PropList::copyProp( PropList& dest, PropList& src, const char *name ) const
{
   hid_t dst_id = dest.getId();
   hid_t src_id = src.getId();
   herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name);
   if( ret_value < 0 )
   {
      throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed");
   }

}
Exemple #3
0
    void ObjectBlueprint::set( void* ptr, PropList& props ){
        PropList::iterator pIT;
        Blueprint::iterator bIT;

        for( pIT = props.begin(); pIT != props.end(); pIT++ ){
            bIT = mBlueprint.find(pIT->first);

            if( (bIT != mBlueprint.end()) && bIT->second.second ){
                bIT->second.second(ptr, pIT->second);
            }
        }
    }
Exemple #4
0
	bool fromString(const QByteArray &str)
	{
		PropList list;
		int at = 0;
		while(1) {
			int n = str.indexOf('=', at);
			if(n == -1)
				break;
			QByteArray var, val;
			var = str.mid(at, n-at);
			at = n + 1;
			if(str[at] == '\"') {
				++at;
				n = str.indexOf('\"', at);
				if(n == -1)
					break;
				val = str.mid(at, n-at);
				at = n + 1;
			}
			else {
				n = str.indexOf(',', at);
				if(n != -1) {
					val = str.mid(at, n-at);
					at = n;
				}
				else {
					val = str.mid(at);
					at = str.length()-1;
				}
			}
			Prop prop;
			prop.var = var;
			prop.val = val;
			list.append(prop);

			if(str[at] != ',')
				break;
			++at;
		}

		// integrity check
		if(list.varCount("nonce") != 1)
			return false;
		if(list.varCount("algorithm") != 1)
			return false;
		*this = list;
		return true;
	}
Exemple #5
0
//--------------------------------------------------------------------------
// Function:	H5Location::p_dereference (protected)
// Purpose	Dereference a ref into an hdf5 object.
// Parameters
//		loc_id - IN: An hdf5 identifier specifying the location of the
//			 referenced object
//		ref - IN: Reference pointer
//		ref_type - IN: Reference type
//		plist - IN: Property list - default to PropList::DEFAULT
//		from_func - IN: Name of the calling function
// Exception	H5::ReferenceException
// Programmer	Binh-Minh Ribler - Oct, 2006
// Modification
//	May 2008 - BMR
//		Moved from IdComponent.
//--------------------------------------------------------------------------
hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func)
{
   hid_t plist_id;
   if (p_valid_id(plist.getId()))
	plist_id = plist.getId();
   else
	plist_id = H5P_DEFAULT;

   hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref);
   if (temp_id < 0)
   {
      throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed");
   }

   return(temp_id);
}
Exemple #6
0
//--------------------------------------------------------------------------
// Function:	PropList::operator==
///\brief	Compares this property list or class against the given list or class.
///\param	rhs - IN: Reference to the property list to compare
///\return	true if the property lists or classes are equal, and
///		false, otherwise.
///\exception	H5::PropListIException
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
bool PropList::operator==(const PropList& rhs) const
{
   htri_t ret_value = H5Pequal(id, rhs.getId());
   if( ret_value > 0 )
      return true;
   else if( ret_value == 0 )
      return false;
   else // Raise exception when H5Pequal returns a negative value
   {
      throw PropListIException(inMemFunc("operator=="), "H5Pequal failed");
   }
}
Exemple #7
0
//--------------------------------------------------------------------------
// Function:	PropList::isAClass
///\brief	Determines whether a property list is a certain class.
///\param	prop_class - IN: Property class to query
///\return	true if the property list is a member of the property list
///		class, and false, otherwise.
///\exception	H5::PropListIException
// Programmer:  Binh-Minh Ribler - April, 2004
//--------------------------------------------------------------------------
bool PropList::isAClass(const PropList& prop_class) const
{
   htri_t ret_value = H5Pisa_class(id, prop_class.getId());
   if( ret_value > 0 )
      return true;
   else if( ret_value == 0 )
      return false;
   else // Raise exception when H5Pisa_class returns a negative value
   {
      throw PropListIException(inMemFunc("isAClass"), "H5Pisa_class failed");
   }

}
Exemple #8
0
//--------------------------------------------------------------------------
// Function:	DataType::convert
///\brief	Converts data from this datatype to the specified datatypes.
///\param	dest       - IN: Destination datatype
///\param	nelmts     - IN: Size of array \a buf
///\param	buf        - IN/OUT: Array containing pre- and post-conversion
///				values
///\param	background - IN: Optional backgroud buffer
///\param	plist - IN: Property list - default to PropList::DEFAULT
///\return	Pointer to a suitable conversion function
///\exception	H5::DataTypeIException
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void DataType::convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist ) const
{
   // Get identifiers for C API
   hid_t dest_id = dest.getId();
   hid_t plist_id = plist.getId();

   // Call C routine H5Tconvert to convert the data
   herr_t ret_value;
   ret_value = H5Tconvert( id, dest_id, nelmts, buf, background, plist_id );
   if( ret_value < 0 )
   {
      throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed");
   }
}
//--------------------------------------------------------------------------
// Function:	CommonFG::mount
///\brief	Mounts the file \a child onto this group.
///\param	name  - IN: Name of the group
///\param	child - IN: File to mount
///\param	plist - IN: Property list to use
///\exception	H5::FileIException or H5::GroupIException
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void CommonFG::mount( const char* name, H5File& child, PropList& plist ) const
{
   // Obtain identifiers for C API
   hid_t plist_id = plist.getId();
   hid_t child_id = child.getId();

   // Call C routine H5Fmount to do the mouting
   herr_t ret_value = H5Fmount( getLocId(), name, child_id, plist_id );

   // Raise exception if H5Fmount returns negative value
   if( ret_value < 0 )
   {
      throwException("mount", "H5Fmount failed");
   }
}
Exemple #10
0
//--------------------------------------------------------------------------
// Function:	PropList::copy
///\brief	Makes a copy of an existing property list.
///\param	like_plist - IN: Reference to the existing property list
///\exception	H5::PropListIException
// Programmer	Binh-Minh Ribler - 2000
// Modification
//		- Replaced resetIdComponent() with decRefCount() to use C
//		library ID reference counting mechanism - BMR, Jun 1, 2004
//		- Replaced decRefCount with close() to let the C library
//		handle the reference counting - BMR, Jun 1, 2006
//--------------------------------------------------------------------------
void PropList::copy( const PropList& like_plist )
{
    // If this object is representing an hdf5 object, close it before
    // copying like_plist to it
    try {
	close();
    }
    catch (Exception close_error) {
	throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg());
    }

    // call C routine to copy the property list
    id = H5Pcopy( like_plist.getId() );
    if( id < 0 )
	throw PropListIException(inMemFunc("copy"), "H5Pcopy failed");
}
Exemple #11
0
//--------------------------------------------------------------------------
// Function:	H5Object::createAttribute
///\brief	Creates an attribute for a group, dataset, or named datatype.
///\param	name - IN: Name of the attribute
///\param	data_type - IN: Datatype for the attribute
///\param	data_space - IN: Dataspace for the attribute - only simple
///		dataspaces are allowed at this time
///\param	create_plist - IN: Creation property list - default to
///		PropList::DEFAULT
///\return	Attribute instance
///\exception	H5::AttributeIException
///\par Description
///		The attribute name specified in \a name must be unique.
///		Attempting to create an attribute with the same name as an
///		existing attribute will raise an exception, leaving the
///		pre-existing attribute intact. To overwrite an existing
///		attribute with a new attribute of the same name, first
///		delete the existing one with \c H5Object::removeAttr, then
///		recreate it with this function.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Attribute H5Object::createAttribute( const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const
{
   hid_t type_id = data_type.getId();
   hid_t space_id = data_space.getId();
   hid_t plist_id = create_plist.getId();
   hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT );

   // If the attribute id is valid, create and return the Attribute object
   if( attr_id > 0 )
   {
      Attribute attr( attr_id );
      return( attr );
   }
   else
      throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed");
}
Exemple #12
0
void Monitor::configure(const PropList& props) {

	// Process output
	out.setStream(*OUTPUT(props));
	log.setStream(*LOG(props));

	// process verbosity
	bool verbose;
	if(props.hasProp(VERBOSE))
		verbose = VERBOSE(props);
	else
		verbose = elm::sys::System::hasEnv(VERBOSE_ENV);
	if(verbose) {
		flags |= IS_VERBOSE;
		log_level = LOG_BB;
	}
	else
		flags &= ~IS_VERBOSE;

	// get the log level
	log_level_t level = LOG_LEVEL(props);
	if(level)
		log_level = level;
}
    virtual void tryAgain() {
        // All exits of the method must emit the ready signal
        // so all exits go through a goto ready;
        if(step == 0) {
            out_mech = mechanism_;

#ifdef SIMPLESASL_PLAIN
            // PLAIN
            if (out_mech == "PLAIN") {
                // First, check if we have everything
                if(need.user || need.pass) {
                    qWarning("simplesasl.cpp: Did not receive necessary auth parameters");
                    result_ = Error;
                    goto ready;
                }
                if(!have.user)
                    need.user = true;
                if(!have.pass)
                    need.pass = true;
                if(need.user || need.pass) {
                    result_ = Params;
                    goto ready;
                }

                // Continue with authentication
                QByteArray plain;
                if (!authz.isEmpty())
                    plain += authz.toUtf8();
                plain += '\0' + user.toUtf8() + '\0' + pass.toByteArray();
                out_buf.resize(plain.length());
                memcpy(out_buf.data(), plain.data(), out_buf.size());
            }
#endif
            ++step;
            if (out_mech == "PLAIN")
                result_ = Success;
            else
                result_ = Continue;
        }
        else if(step == 1) {
            // if we still need params, then the app has failed us!
            if(need.user || need.authzid || need.pass || need.realm) {
                qWarning("simplesasl.cpp: Did not receive necessary auth parameters");
                result_ = Error;
                goto ready;
            }
            // see if some params are needed
            if(!have.user)
                need.user = true;
            //if(!have.authzid)
            //	need.authzid = true;
            if(!have.pass)
                need.pass = true;
            if(need.user || need.authzid || need.pass) {
                result_ = Params;
                goto ready;
            }

            // get props
            QByteArray cs(in_buf);
            PropList in;
            if(!in.fromString(cs)) {
                authCondition_ = QCA::SASL::BadProtocol;
                result_ = Error;
                goto ready;
            }
            //qDebug() << (QString("simplesasl.cpp: IN: %1").arg(QString(in.toString())));

            // make a cnonce
            QByteArray a(32,'\0');
            for(int n = 0; n < (int)a.size(); ++n)
                a[n] = (char)(256.0*rand()/(RAND_MAX+1.0));
            QByteArray cnonce = QCA::Base64().arrayToString(a).toLatin1();

            // make other variables
            if (realm.isEmpty())
                realm = QString::fromUtf8(in.get("realm"));
            QByteArray nonce = in.get("nonce");
            QByteArray nc = "00000001";
            QByteArray uri = service.toUtf8() + '/' + host.toUtf8();
            QByteArray qop = "auth";

            // build 'response'
            QByteArray X = user.toUtf8() + ':' + realm.toUtf8() + ':' + pass.toByteArray();
            QByteArray Y = QCA::Hash("md5").hash(X).toByteArray();
            QByteArray tmp = ':' + nonce + ':' + cnonce;
            if (!authz.isEmpty())
                tmp += ':' + authz.toUtf8();
            //qDebug() << (QString(tmp));

            QByteArray A1(Y + tmp);
            QByteArray A2 = QByteArray("AUTHENTICATE:") + uri;
            QByteArray HA1 = QCA::Hash("md5").hashToString(A1).toLatin1();
            QByteArray HA2 = QCA::Hash("md5").hashToString(A2).toLatin1();
            QByteArray KD = HA1 + ':' + nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + HA2;
            QByteArray Z = QCA::Hash("md5").hashToString(KD).toLatin1();

            //qDebug() << (QString("simplesasl.cpp: A1 = %1").arg(QString(A1)).toAscii());
            //qDebug() << (QString("simplesasl.cpp: A2 = %1").arg(QString(A2)).toAscii());
            //qDebug() << (QString("simplesasl.cpp: KD = %1").arg(QString(KD)).toAscii());

            // build output
            PropList out;
            out.set("username", user.toUtf8());
            if (!realm.isEmpty())
                out.set("realm", realm.toUtf8());
            out.set("nonce", nonce);
            out.set("cnonce", cnonce);
            out.set("nc", nc);
            //out.set("serv-type", service.utf8());
            //out.set("host", host.utf8());
            out.set("digest-uri", uri);
            out.set("qop", qop);
            out.set("response", Z);
            out.set("charset", "utf-8");
            if (!authz.isEmpty())
                out.set("authzid", authz.toUtf8());
            QByteArray s(out.toString());
            //qDebug() << (QString("OUT: %1").arg(QString(out.toString())));

            // done
            out_buf.resize(s.length());
            memcpy(out_buf.data(), s.data(), out_buf.size());
            ++step;
            result_ = Continue;
        }
        /*		else if (step == 2) {
        			out_buf.resize(0);
        			result_ = Continue;
        			++step;
        		}*/
        else {
            out_buf.resize(0);
            result_ = Success;
        }
ready:
        QMetaObject::invokeMethod(this, "resultsReady", Qt::QueuedConnection);
    }
Exemple #14
0
//--------------------------------------------------------------------------
// Function:	PropList copy constructor
///\brief	Copy constructor
///\param	original - IN: The original property list to copy
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PropList::PropList(const PropList& original) : IdComponent()
{
    id = original.getId();
    incRefCount(); // increment number of references to this id
}
WindowWin32::WindowWin32(PropList& ParamList) : m_hWnd(NULL)
{
    m_iWidth  = ParamList.GetInteger("winWidth", 800);
    m_iHeight = ParamList.GetInteger("winHeight", 600);
    m_sTitle  = ParamList.GetString("winTitle", "No Title");
}
Exemple #16
0
	int clientTryAgain()
	{
		if(step == 0) {
			out_mech = "DIGEST-MD5";
			++step;
			return Continue;
		}
		else if(step == 1) {
			// if we still need params, then the app has failed us!
			if(need.user || need.authzid || need.pass || need.realm) {
				err = -1;
				return Error;
			}

			// see if some params are needed
			if(!have.user)
				need.user = true;
			if(!have.authzid)
				need.authzid = true;
			if(!have.pass)
				need.pass = true;
			if(need.user || need.authzid || need.pass)
				return NeedParams;

			// get props
			QByteArray cs(in_buf.data(), in_buf.size());
			PropList in;
			if(!in.fromString(cs)) {
				err = QCA::SASL::BadProto;
				return Error;
			}

			// make a cnonce
			QByteArray a(32, 0);
			for(int n = 0; n < (int)a.size(); ++n)
				a[n] = (char)(256.0*rand()/(RAND_MAX+1.0));
			QByteArray cnonce = Base64::arrayToString(a).toLatin1();

			// make other variables
			realm = host;
			QByteArray nonce = in.get("nonce");
			QByteArray nc = "00000001";
			QByteArray uri = service.toUtf8() + '/' + host.toUtf8();
			QByteArray qop = "auth";

			// build 'response'
			QByteArray X = user.toUtf8() + ':' + realm.toUtf8() + ':' + pass.toUtf8();
			QByteArray Y = QCA::MD5::hash(X);
			QByteArray tmp = QByteArray(":") + nonce + ':' + cnonce + ':' + authz.toUtf8();
			QByteArray A1(Y.size() + tmp.length(), 0);
			memcpy(A1.data(), Y.data(), Y.size());
			memcpy(A1.data() + Y.size(), tmp.data(), tmp.length());
			QByteArray A2 = "AUTHENTICATE:" + uri;
			QByteArray HA1 = QCA::MD5::hashToString(A1).toLatin1();
			QByteArray HA2 = QCA::MD5::hashToString(A2).toLatin1();
			QByteArray KD = HA1 + ':' + nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + HA2;
			QByteArray Z = QCA::MD5::hashToString(KD).toLatin1();

			// build output
			PropList out;
			out.set("username", user.toUtf8());
			out.set("realm", host.toUtf8());
			out.set("nonce", nonce);
			out.set("cnonce", cnonce);
			out.set("nc", nc);
			out.set("serv-type", service.toUtf8());
			out.set("host", host.toUtf8());
			out.set("digest-uri", uri);
			out.set("qop", qop);
			out.set("response", Z);
			out.set("charset", "utf-8");
			out.set("authzid", authz.toUtf8());
			QByteArray s = out.toString();

			// done
			//out_buf.resize(s.length());
			//memcpy(out_buf.data(), s.data(), out_buf.size());
			out_buf = s;
			++step;
			return Continue;
		}
		else {
			out_buf.resize(0);
			return Success;
		}
	}
 Attribute Object::openAttribute (const std::string& name, /*AttributeAccess*/PropList aapl) const {
   return Attribute (Exception::check ("H5Aopen", H5Aopen (handle (), name.c_str (), aapl.handleOrDefault ())));
 }
 Attribute Object::createAttribute (const std::string& name, const DataType& type, const DataSpace& space, AttributeCreatePropList acpl, /*AttributeAccess*/PropList aapl) const {
   return Attribute (Exception::check ("H5Acreate2", H5Acreate2 (handle (), name.c_str (), type.handle (), space.handle (), acpl.handleOrDefault (), aapl.handleOrDefault ())));
 }
    bool fromString(const QByteArray &str)
    {
        PropList list;
        int at = 0;
        while(1) {
            while (at < str.length() && (str[at] == ',' || str[at] == ' ' || str[at] == '\t'))
                ++at;
            int n = str.indexOf('=', at);
            if(n == -1)
                break;
            QByteArray var, val;
            var = str.mid(at, n-at);
            at = n + 1;
            if(str[at] == '\"') {
                ++at;
                n = str.indexOf('\"', at);
                if(n == -1)
                    break;
                val = str.mid(at, n-at);
                at = n + 1;
            }
            else {
                n = at;
                while (n < str.length() && str[n] != ',' && str[n] != ' ' && str[n] != '\t')
                    ++n;
                val = str.mid(at, n-at);
                at = n;
            }
            Prop prop;
            prop.var = var;
            if (var == "qop" || var == "cipher") {
                int a = 0;
                while (a < val.length()) {
                    while (a < val.length() && (val[a] == ',' || val[a] == ' ' || val[a] == '\t'))
                        ++a;
                    if (a == val.length())
                        break;
                    n = a+1;
                    while (n < val.length() && val[n] != ',' && val[n] != ' ' && val[n] != '\t')
                        ++n;
                    prop.val = val.mid(a, n-a);
                    list.append(prop);
                    a = n+1;
                }
            }
            else {
                prop.val = val;
                list.append(prop);
            }

            if(at >= str.size() - 1 || (str[at] != ',' && str[at] != ' ' && str[at] != '\t'))
                break;
        }

        // integrity check
        if(list.varCount("nonce") != 1)
            return false;
        if(list.varCount("algorithm") != 1)
            return false;
        *this = list;
        return true;
    }