void ACE_Stats::mean (ACE_Stats_Value &m, const ACE_UINT32 scale_factor) { if (number_of_samples_ > 0) { const ACE_UINT64 ACE_STATS_INTERNAL_OFFSET = ACE_UINT64_LITERAL (0x100000000); ACE_UINT64 sum = ACE_STATS_INTERNAL_OFFSET; ACE_Unbounded_Queue_Iterator<ACE_INT32> i (samples_); while (! i.done ()) { ACE_INT32 *sample; if (i.next (sample)) { sum += *sample; i.advance (); } } // sum_ was initialized with ACE_STATS_INTERNAL_OFFSET, so // subtract that off here. quotient (sum - ACE_STATS_INTERNAL_OFFSET, number_of_samples_ * scale_factor, m); } else { m.whole (0); m.fractional (0); } }
void ACE_Stats::mean (ACE_Stats_Value &m, const ACE_UINT32 scale_factor) { if (number_of_samples_ > 0) { #if defined ACE_LACKS_LONGLONG_T // If ACE_LACKS_LONGLONG_T, then ACE_UINT64 is a user-defined class. // To prevent having to construct a static of that class, declare it // on the stack, and construct it, in each function that needs it. const ACE_U_LongLong ACE_STATS_INTERNAL_OFFSET (0, 8); #else /* ! ACE_LACKS_LONGLONG_T */ const ACE_UINT64 ACE_STATS_INTERNAL_OFFSET = ACE_UINT64_LITERAL (0x100000000); #endif /* ! ACE_LACKS_LONGLONG_T */ ACE_UINT64 sum = ACE_STATS_INTERNAL_OFFSET; ACE_Unbounded_Queue_Iterator<ACE_INT32> i (samples_); while (! i.done ()) { ACE_INT32 *sample; if (i.next (sample)) { sum += *sample; i.advance (); } } // sum_ was initialized with ACE_STATS_INTERNAL_OFFSET, so // subtract that off here. quotient (sum - ACE_STATS_INTERNAL_OFFSET, number_of_samples_ * scale_factor, m); } else { m.whole (0); m.fractional (0); } }
// ---------------------------------------------------------- void LogSvcHandler::log(const LogRecord& lr) { //may need to make some changes to the message if the CORBA //logging service is down std::string message = lr.message; //if it's a trace we set the message to be "". if((lr.priority==LM_TRACE) && (message==FIELD_UNAVAILABLE)) { message = ""; } //add a newline if the logging service is unavailable if(LoggingProxy::isInit()==false) { message = message + '\n'; } LoggingProxy::File(lr.file.c_str()); LoggingProxy::Line(lr.line); //only set the logging flags if the priority is debug or trace if((lr.priority==LM_DEBUG)||(lr.priority==LM_TRACE)) { LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); } //if the field is available if(lr.method!=FIELD_UNAVAILABLE) { //set the routine name. LoggingProxy::Routine(lr.method.c_str()); } else { LoggingProxy::Routine(""); } if(lr.priority == LM_SHUTDOWN) message = " -- ERROR in the priority of this message, please check the source --" + message; //set the component/container/etc name LoggingProxy::SourceObject(sourceObjectName_m.c_str()); //figure out the time long sec_ = ACE_static_cast(CORBA::ULongLong, lr.timeStamp) / ACE_static_cast(ACE_UINT32, 10000000u) - ACE_UINT64_LITERAL(0x2D8539C80); long usec_ = (lr.timeStamp % 10000000u) / 10; ACE_Time_Value time(sec_, usec_); //create the ACE log message /** * @todo Here there was an assignment to * a local variable never used. * Why was that? * I have now commented it out * int __ace_error = ACE_Log_Msg::last_error_adapter(); */ ACE_Log_Msg::last_error_adapter(); ACE_Log_Msg *ace___ = ACE_Log_Msg::instance(); //create the ACE log record using the message ACE_Log_Record log_record_(acs2acePriority(lr.priority), time, 0); log_record_.msg_data(message.c_str()); // set private flags const int prohibitLocal = getLocalLevel() == LM_SHUTDOWN || lr.priority < getLocalLevel() ? 1 : 0; const int prohibitRemote = getRemoteLevel() == LM_SHUTDOWN ||lr.priority < getRemoteLevel() ? 2 : 0; LoggingProxy::PrivateFlags(prohibitLocal | prohibitRemote); LoggingProxy::LogLevelLocalType(getLocalLevelType()); LoggingProxy::LogLevelRemoteType(getRemoteLevelType()); ace___->log(log_record_, 0); }
void ErrorTraceHelper::toString (ACSErr::ErrorTrace * c, int level, std::ostringstream &oss){ oss << "Error Trace Level : " << level << std::endl; char ctp[21]; long sec_ = ACE_static_cast(CORBA::ULongLong, c->timeStamp) / ACE_static_cast(ACE_UINT32, 10000000u) - ACE_UINT64_LITERAL(0x2D8539C80); long usec_ = (c->timeStamp % 10000000u) / 10; time_t tt(sec_); struct tm *utc_p = ACE_OS::gmtime(&tt); ACE_OS::strftime(ctp, sizeof(ctp), "%Y-%m-%dT%H:%M:%S.", utc_p); oss << " " << ctp << std::setfill('0') << std::setw(3) << usec_/1000; oss << " in " << c->routine << " of file " << c->file << " at line " << c->lineNum << std::endl; oss << " HostName:" << c->host << ", process:" << c->process << " Thread " << c->thread << "," << std::endl; oss << " Severity=" << c->severity; oss << " type=" << c->errorType << " code=" << c->errorCode << " description:" << c->shortDescription << std::endl; for (unsigned int j=0; j<c->data.length(); j++) oss << " data[" << j << "] : " << c->data[j].name << " = " << c->data[j].value << std::endl; return; }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO::SSLIOP_Credentials::SSLIOP_Credentials (::X509 *cert, ::EVP_PKEY *evp) : x509_ (TAO::SSLIOP::OpenSSL_traits< ::X509 >::_duplicate (cert)), evp_ (TAO::SSLIOP::OpenSSL_traits< ::EVP_PKEY >::_duplicate (evp)), id_ (), creds_usage_ (SecurityLevel3::CU_Indefinite), expiry_time_ (), creds_state_ (SecurityLevel3::CS_Invalid) { ::X509 *x = cert; if (x != 0) { // We use the X.509 certificate's serial number as the // credentials Id. BIGNUM * bn = ASN1_INTEGER_to_BN (::X509_get_serialNumber (x), 0); if (BN_is_zero (bn)) this->id_ = CORBA::string_dup ("X509: 00"); else { char * id = BN_bn2hex (bn); ACE_CString s = ACE_CString ("X509: ") + ACE_CString (const_cast<const char *> (id)); this->id_ = CORBA::string_dup (s.c_str ()); #ifdef OPENSSL_free OPENSSL_free (id); #else // Older versions of OpenSSL didn't define the OpenSSL // macro. CRYPTO_free (id); #endif /* OPENSSL_free */ } BN_free (bn); // ------------------------------------------- TimeBase::UtcT & t = this->expiry_time_; const ASN1_TIME * exp = X509_get_notAfter (x); if (exp->length > ACE_SIZEOF_LONG_LONG) { // @@ Will this ever happen? // Overflow! t.time = ACE_UINT64_LITERAL (0xffffffffffffffff); } else { t.time = 0; for (int i = 0; i < exp->length; ++i) { t.time <<= 8; t.time |= (unsigned char) exp->data[i]; } } } }
int ACE_TMAIN (int, ACE_TCHAR **) { int status = 0; { Literal_Interpreter<CORBA::ULongLong> u_interp; if (!u_interp.test ("993834343433882", ACE_UINT64_LITERAL (993834343433882))) { status++; ACE_ERROR ((LM_ERROR, "ERROR: CORBA::ULongLong test failed.\n")); } Literal_Interpreter<CORBA::LongLong> interp; if (!interp.test ("-1879048193", -1879048193)) { status++; ACE_ERROR ((LM_ERROR, "ERROR: CORBA::LongLong test failed.\n")); } // Since we're comparing signed and unsigned, the signed should get // promoted to unsigned. However, it gets logically promoted, not // binarily. So, a negative value is converted into zero as an // unsigned value. if (interp.constraint () > u_interp.constraint ()) { status++; ACE_ERROR ((LM_ERROR, "ERROR: Mixed greater than test 1 failed.\n")); } } { Literal_Interpreter<CORBA::Double> u_interp; if (!u_interp.test ("993834343433882.88837719", 993834343433882.88837719)) { status++; ACE_ERROR ((LM_ERROR, "ERROR: CORBA::Double test 1 failed.\n")); } Literal_Interpreter<CORBA::Double> interp; if (!interp.test ("-993834343433882.88837719", -993834343433882.88837719)) { status++; ACE_ERROR ((LM_ERROR, "ERROR: CORBA::Double test 2 failed.\n")); } if (interp.constraint () > u_interp.constraint ()) { status++; ACE_ERROR ((LM_ERROR, "ERROR: Mixed greater than test 2 failed.\n")); } } { Literal_Interpreter<CORBA::Boolean> interp; if (!interp.test ("TRUE", true)) { status++; ACE_ERROR ((LM_ERROR, "ERROR: CORBA::Boolean test 1 failed.\n")); } } { Literal_Interpreter<CORBA::Boolean> interp; if (!interp.test ("FALSE", false)) { status++; ACE_ERROR ((LM_ERROR, "ERROR: CORBA::Boolean test 2 failed.\n")); } } { Literal_Interpreter<const char*> interp; if (!interp.test ("'This is a test'", "This is a test")) { status++; ACE_ERROR ((LM_ERROR, "ERROR: const char* test failed.\n")); } } return status; }
// $Id$ #include "orbsvcs/Time_Utilities.h" #if !defined (__ACE_INLINE__) # include "orbsvcs/Time_Utilities.inl" #endif /* __ACE_INLINE__ */ TAO_BEGIN_VERSIONED_NAMESPACE_DECL // Number of nanoseconds between CORBA and POSIX epochs. const ACE_UINT64 ORBSVCS_Time::Time_Base_Offset(ACE_UINT64_LITERAL(12219292800000000000)); TAO_END_VERSIONED_NAMESPACE_DECL
int Timer_Helper::handle_timeout (const ACE_Time_Value &, const void *) { int no_of_servers = 0; CORBA::ULongLong sum = 0; // The following are used to keep a track of the inaccuracy // in synchronization. CORBA::ULongLong lowest_time = ACE_UINT64_LITERAL (0xFFFFFFFFFFFFFFFF); CORBA::ULongLong highest_time = 0; try { IORS::TYPE* value; for (IORS::ITERATOR server_iterator (this->clerk_->server_); server_iterator.next (value) != 0; server_iterator.advance ()) { // This is a remote call. CosTime::UTO_var UTO_server = (*value)->universal_time (); if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "\nTime = %Q\nInaccuracy = %Q\nTimeDiff = %d\nstruct.time = %Q\n" "struct.inacclo = %d\nstruct.inacchi = %d\nstruct.Tdf = %d\n", UTO_server->time (), UTO_server->inaccuracy (), UTO_server->tdf (), (UTO_server->utc_time ()).time, (UTO_server->utc_time ()).inacclo, (UTO_server->utc_time ()).inacchi, (UTO_server->utc_time ()).tdf)); CORBA::ULongLong curr_server_time = UTO_server->time (); sum += curr_server_time; ++no_of_servers; // Set the highest time to the largest time seen so far. if (curr_server_time > highest_time) highest_time = curr_server_time; // Set the lowest time to the smallest time seen so far. if (curr_server_time < lowest_time) lowest_time = curr_server_time; } if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "\nUpdated time from %d servers in the network", no_of_servers)); // Return the average of the times retrieved from the various // servers. clerk_->time_ = sum / no_of_servers ; // Set the Time Displacement Factor. The TZ environment variable is // read to set the time zone. We convert the timezone value from seconds // to minutes. ACE_OS::tzset (); long arg = ACE_OS::timezone () / 60; CORBA::Short goodarg = static_cast<CORBA::Short> (arg); clerk_->time_displacement_factor (goodarg); // Set the inaccuracy. if (highest_time > lowest_time) clerk_->inaccuracy (highest_time - lowest_time); else clerk_->inaccuracy (0); const ACE_Time_Value timeofday = ACE_OS::gettimeofday (); // Record the current time in a timestamp to know when global // updation of time was done. clerk_->update_timestamp_ = static_cast<CORBA::ULongLong> (timeofday.sec ()) * static_cast<ACE_UINT32> (10000000) + static_cast<CORBA::ULongLong> (timeofday.usec () * 10); } catch (const CORBA::Exception& ex) { if (TAO_debug_level > 0) ex._tao_print_exception ("Exception in handle_timeout()\n"); return -1; } return 0; }