16#include <zypp/base/Logger.h>
17#include <zypp/base/Exception.h>
18#include <zypp/base/NonCopyable.h>
19#include <zypp/base/Hash.h>
128 {
return ! ( lhs == rhs ); }
152 #define DEF_BUILTIN(A) \
153 namespace { static inline const IdString & a_##A () { static IdString _str(#A); return _str; } } \
154 const Arch Arch_##A( a_##A() )
249 typedef std::unordered_set<CompatEntry> Set;
250 typedef Set::iterator iterator;
251 typedef Set::const_iterator const_iterator;
254 static ArchCompatSet & instance()
256 static ArchCompatSet _instance;
263 const Arch::CompatEntry & assertDef(
const std::string & archStr_r )
264 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r ) ).first; }
266 const Arch::CompatEntry & assertDef( IdString archStr_r )
267 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r ) ).first; }
269 const_iterator begin()
const
272 const_iterator end()
const
277 int operator()(
const CompatEntry & lhs,
const CompatEntry & rhs )
const
278 {
return lhs._idBit.value() < rhs._idBit.value(); }
281 std::ostream &
dumpOn( std::ostream &
str )
const
283 str <<
"ArchCompatSet:";
285 ov.sort( DumpOnCompare() );
286 for_( it, ov.begin(), ov.end() )
288 str << endl <<
' ' << *it;
300 _compatSet.insert( Arch::CompatEntry( a_noarch(), 0 ) );
307 defCompatibleWith( a_i386(), a_noarch() );
308 defCompatibleWith( a_i486(), a_noarch(),a_i386() );
309 defCompatibleWith( a_i586(), a_noarch(),a_i386(),a_i486() );
310 defCompatibleWith( a_i686(), a_noarch(),a_i386(),a_i486(),a_i586() );
311 defCompatibleWith( a_athlon(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
312 defCompatibleWith( a_x86_64(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon() );
314 defCompatibleWith( a_pentium3(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
315 defCompatibleWith( a_pentium4(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_pentium3() );
317 defCompatibleWith( a_ia64(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
319 defCompatibleWith( a_s390(), a_noarch() );
320 defCompatibleWith( a_s390x(), a_noarch(),a_s390() );
322 defCompatibleWith( a_ppc(), a_noarch() );
323 defCompatibleWith( a_ppc64(), a_noarch(),a_ppc() );
324 defCompatibleWith( a_ppc64p7(), a_noarch(),a_ppc(),a_ppc64() );
326 defCompatibleWith( a_ppc64le(), a_noarch() );
328 defCompatibleWith( a_alpha(), a_noarch() );
329 defCompatibleWith( a_alphaev5(), a_noarch(),a_alpha() );
330 defCompatibleWith( a_alphaev56(), a_noarch(),a_alpha(),a_alphaev5() );
331 defCompatibleWith( a_alphapca56(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56() );
332 defCompatibleWith( a_alphaev6(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56(),a_alphapca56() );
333 defCompatibleWith( a_alphaev67(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56(),a_alphapca56(),a_alphaev6() );
335 defCompatibleWith( a_sparc(), a_noarch() );
336 defCompatibleWith( a_sparcv8(), a_noarch(),a_sparc() );
337 defCompatibleWith( a_sparcv9(), a_noarch(),a_sparc(),a_sparcv8() );
338 defCompatibleWith( a_sparcv9v(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9() );
340 defCompatibleWith( a_sparc64(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9() );
341 defCompatibleWith( a_sparc64v(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9(),a_sparcv9v(),a_sparc64() );
343 defCompatibleWith( a_armv3l(), a_noarch() );
344 defCompatibleWith( a_armv4l(), a_noarch(),a_armv3l() );
345 defCompatibleWith( a_armv4tl(), a_noarch(),a_armv3l(),a_armv4l() );
346 defCompatibleWith( a_armv5l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl() );
347 defCompatibleWith( a_armv5tl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l() );
348 defCompatibleWith( a_armv5tel(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl() );
349 defCompatibleWith( a_armv5tejl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel() );
350 defCompatibleWith( a_armv6l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl() );
351 defCompatibleWith( a_armv7l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l() );
352 defCompatibleWith( a_armv8l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l(),a_armv7l() );
354 defCompatibleWith( a_armv6hl(), a_noarch() );
355 defCompatibleWith( a_armv7hl(), a_noarch(),a_armv6hl() );
356 defCompatibleWith( a_armv8hl(), a_noarch(),a_armv7hl() );
357 defCompatibleWith( a_armv7hnl(), a_noarch(),a_armv7hl(),a_armv6hl() );
359 defCompatibleWith( a_armv7nhl(), a_noarch(),a_armv7hnl(),a_armv7hl(),a_armv6hl() );
361 defCompatibleWith( a_armv7thl(), a_noarch(),a_armv7hl() );
362 defCompatibleWith( a_armv7tnhl(), a_noarch(),a_armv7hl(),a_armv7nhl(),a_armv7thl() );
364 defCompatibleWith( a_aarch64(), a_noarch() );
366 defCompatibleWith( a_riscv64(), a_noarch() );
368 defCompatibleWith( a_sh3(), a_noarch() );
370 defCompatibleWith( a_sh4(), a_noarch() );
371 defCompatibleWith( a_sh4a(), a_noarch(),a_sh4() );
373 defCompatibleWith( a_m68k(), a_noarch() );
375 defCompatibleWith( a_mips(), a_noarch() );
376 defCompatibleWith( a_mipsel(), a_noarch() );
377 defCompatibleWith( a_mips64(), a_noarch() );
378 defCompatibleWith( a_mips64el(), a_noarch() );
396 ZYPP_THROW( Exception(
"Need more bits to encode architectures.") );
405 const CompatEntry & assertCompatSetEntry( IdString archStr_r )
406 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r, nextIdBit() ) ).first; }
410 void defCompatibleWith( IdString targetArch_r,
412 IdString arch1_r = IdString(),
413 IdString arch2_r = IdString(),
414 IdString arch3_r = IdString(),
415 IdString arch4_r = IdString(),
416 IdString arch5_r = IdString(),
417 IdString arch6_r = IdString(),
418 IdString arch7_r = IdString(),
419 IdString arch8_r = IdString(),
420 IdString arch9_r = IdString() )
422 const CompatEntry & target( assertCompatSetEntry( targetArch_r ) );
423 target.addCompatBit( assertCompatSetEntry( arch0_r )._idBit );
424#define SETARG(N) if ( arch##N##_r.empty() ) return; target.addCompatBit( assertCompatSetEntry( arch##N##_r )._idBit )
453 : _entry( &ArchCompatSet::instance().assertDef( a_noarch() ) )
457 : _entry( &ArchCompatSet::instance().assertDef(
IdString(id_r) ) )
461 : _entry( &ArchCompatSet::instance().assertDef( idstr_r ) )
465 : _entry( &ArchCompatSet::instance().assertDef( str_r ) )
469 : _entry( &ArchCompatSet::instance().assertDef( cstr_r ) )
538 if ( cset.size() > 2 )
540 return *(++cset.rbegin());
562 for ( ArchCompatSet::const_iterator it = ArchCompatSet::instance().begin();
563 it != ArchCompatSet::instance().end(); ++it )
565 if ( it->compatibleWith( *targetArch_r.
_entry ) )
567 ret.insert(
Arch(*it) );
ZYPP_DEFINE_ID_HASHABLE(zypp::Arch::CompatEntry)
const CompatEntry * _entry
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
int compare(const Arch &rhs) const
Arch comparison.
Arch()
Default ctor Arc_noarch.
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
IdString idStr() const
String representation of Arch.
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Access to the sat-pools string space.
sat::detail::IdType IdType
IdType id() const
Expert backdoor.
static const IdString Empty
Empty string.
TInt value() const
Return the value.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string numstring(char n, int w=0)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
const Arch Arch_empty(IdString::Empty)
Holds an architecture ID and its compatible relation.
void addCompatBit(const CompatBits &idBit_r) const
std::ostream & operator<<(std::ostream &str, const Arch::CompatEntry &obj)
Stream output.
bool compatibleWith(const CompatEntry &targetEntry_r) const
Return whether this is compatible with targetEntry_r.
int compare(const CompatEntry &rhs) const
compare by score, then archStr.
bool operator==(const Arch::CompatEntry &lhs, const Arch::CompatEntry &rhs)
IdString::IdType id() const
bool operator!=(const Arch::CompatEntry &lhs, const Arch::CompatEntry &rhs)
bit::BitField< uint64_t > CompatBits
Bitfield for architecture IDs and compatBits relation.
CompatEntry(IdString archStr_r, CompatBits::IntT idBit_r=1)
CompatEntry(const std::string &archStr_r, CompatBits::IntT idBit_r=1)
static const unsigned size
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.