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() ) 251 typedef Arch::CompatEntry CompatEntry;
254 typedef std::unordered_set<CompatEntry> Set;
255 typedef Set::iterator iterator;
256 typedef Set::const_iterator const_iterator;
259 static ArchCompatSet & instance()
261 static ArchCompatSet _instance;
268 const Arch::CompatEntry & assertDef(
const std::string & archStr_r )
269 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r ) ).first; }
271 const Arch::CompatEntry & assertDef( IdString archStr_r )
272 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r ) ).first; }
274 const_iterator begin()
const 277 const_iterator end()
const 282 int operator()(
const CompatEntry & lhs,
const CompatEntry & rhs )
const 283 {
return lhs._idBit.value() < rhs._idBit.value(); }
286 std::ostream &
dumpOn( std::ostream &
str )
const 288 str <<
"ArchCompatSet:";
290 ov.sort( DumpOnCompare() );
291 for_( it, ov.begin(), ov.end() )
293 str << endl <<
' ' << *it;
305 _compatSet.insert( Arch::CompatEntry( a_noarch(), 0 ) );
312 defCompatibleWith( a_i386(), a_noarch() );
313 defCompatibleWith( a_i486(), a_noarch(),a_i386() );
314 defCompatibleWith( a_i586(), a_noarch(),a_i386(),a_i486() );
315 defCompatibleWith( a_i686(), a_noarch(),a_i386(),a_i486(),a_i586() );
316 defCompatibleWith( a_athlon(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
317 defCompatibleWith( a_x86_64(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon() );
318 defCompatibleWith( a_x86_64_v2(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon(),a_x86_64() );
319 defCompatibleWith( a_x86_64_v3(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon(),a_x86_64(),a_x86_64_v2() );
320 defCompatibleWith( a_x86_64_v4(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon(),a_x86_64(),a_x86_64_v2(),a_x86_64_v3() );
322 defCompatibleWith( a_pentium3(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
323 defCompatibleWith( a_pentium4(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_pentium3() );
325 defCompatibleWith( a_ia64(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
327 defCompatibleWith( a_s390(), a_noarch() );
328 defCompatibleWith( a_s390x(), a_noarch(),a_s390() );
330 defCompatibleWith( a_ppc(), a_noarch() );
331 defCompatibleWith( a_ppc64(), a_noarch(),a_ppc() );
332 defCompatibleWith( a_ppc64p7(), a_noarch(),a_ppc(),a_ppc64() );
334 defCompatibleWith( a_ppc64le(), a_noarch() );
336 defCompatibleWith( a_alpha(), a_noarch() );
337 defCompatibleWith( a_alphaev5(), a_noarch(),a_alpha() );
338 defCompatibleWith( a_alphaev56(), a_noarch(),a_alpha(),a_alphaev5() );
339 defCompatibleWith( a_alphapca56(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56() );
340 defCompatibleWith( a_alphaev6(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56(),a_alphapca56() );
341 defCompatibleWith( a_alphaev67(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56(),a_alphapca56(),a_alphaev6() );
343 defCompatibleWith( a_sparc(), a_noarch() );
344 defCompatibleWith( a_sparcv8(), a_noarch(),a_sparc() );
345 defCompatibleWith( a_sparcv9(), a_noarch(),a_sparc(),a_sparcv8() );
346 defCompatibleWith( a_sparcv9v(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9() );
348 defCompatibleWith( a_sparc64(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9() );
349 defCompatibleWith( a_sparc64v(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9(),a_sparcv9v(),a_sparc64() );
351 defCompatibleWith( a_armv3l(), a_noarch() );
352 defCompatibleWith( a_armv4l(), a_noarch(),a_armv3l() );
353 defCompatibleWith( a_armv4tl(), a_noarch(),a_armv3l(),a_armv4l() );
354 defCompatibleWith( a_armv5l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl() );
355 defCompatibleWith( a_armv5tl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l() );
356 defCompatibleWith( a_armv5tel(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl() );
357 defCompatibleWith( a_armv5tejl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel() );
358 defCompatibleWith( a_armv6l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl() );
359 defCompatibleWith( a_armv7l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l() );
360 defCompatibleWith( a_armv8l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l(),a_armv7l() );
362 defCompatibleWith( a_armv6hl(), a_noarch() );
363 defCompatibleWith( a_armv7hl(), a_noarch(),a_armv6hl() );
364 defCompatibleWith( a_armv8hl(), a_noarch(),a_armv7hl() );
365 defCompatibleWith( a_armv7hnl(), a_noarch(),a_armv7hl(),a_armv6hl() );
367 defCompatibleWith( a_armv7nhl(), a_noarch(),a_armv7hnl(),a_armv7hl(),a_armv6hl() );
369 defCompatibleWith( a_armv7thl(), a_noarch(),a_armv7hl() );
370 defCompatibleWith( a_armv7tnhl(), a_noarch(),a_armv7hl(),a_armv7nhl(),a_armv7thl() );
372 defCompatibleWith( a_aarch64(), a_noarch() );
374 defCompatibleWith( a_riscv64(), a_noarch() );
376 defCompatibleWith( a_sh3(), a_noarch() );
378 defCompatibleWith( a_sh4(), a_noarch() );
379 defCompatibleWith( a_sh4a(), a_noarch(),a_sh4() );
381 defCompatibleWith( a_m68k(), a_noarch() );
383 defCompatibleWith( a_mips(), a_noarch() );
384 defCompatibleWith( a_mipsel(), a_noarch() );
385 defCompatibleWith( a_mips64(), a_noarch() );
386 defCompatibleWith( a_mips64el(), a_noarch() );
388 defCompatibleWith( a_loong64(), a_noarch() );
406 ZYPP_THROW( Exception(
"Need more bits to encode architectures.") );
415 const CompatEntry & assertCompatSetEntry( IdString archStr_r )
416 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r, nextIdBit() ) ).first; }
420 void defCompatibleWith( IdString targetArch_r,
422 IdString arch1_r = IdString(),
423 IdString arch2_r = IdString(),
424 IdString arch3_r = IdString(),
425 IdString arch4_r = IdString(),
426 IdString arch5_r = IdString(),
427 IdString arch6_r = IdString(),
428 IdString arch7_r = IdString(),
429 IdString arch8_r = IdString(),
430 IdString arch9_r = IdString() )
432 const CompatEntry & target( assertCompatSetEntry( targetArch_r ) );
433 target.addCompatBit( assertCompatSetEntry( arch0_r )._idBit );
434 #define SETARG(N) if ( arch##N##_r.empty() ) return; target.addCompatBit( assertCompatSetEntry( arch##N##_r )._idBit ) 463 : _entry( &ArchCompatSet::instance().assertDef( a_noarch() ) )
467 : _entry( &ArchCompatSet::instance().assertDef(
IdString(id_r) ) )
471 : _entry( &ArchCompatSet::instance().assertDef( idstr_r ) )
475 : _entry( &ArchCompatSet::instance().assertDef( str_r ) )
479 : _entry( &ArchCompatSet::instance().assertDef( cstr_r ) )
548 if ( cset.size() > 2 )
550 return *(++cset.rbegin());
572 for ( ArchCompatSet::const_iterator it = ArchCompatSet::instance().begin();
573 it != ArchCompatSet::instance().end(); ++it )
575 if ( it->compatibleWith( *targetArch_r.
_entry ) )
577 ret.insert(
Arch(*it) );
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
IdType id() const
Expert backdoor.
TInt value() const
Return the value.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
const Arch Arch_empty(IdString::Empty)
String related utilities and Regular expression matching.
Access to the sat-pools string space.
int compare(const Arch &rhs) const
Arch comparison.
CompatEntry(const std::string &archStr_r, CompatBits::IntT idBit_r=1)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
IdString::IdType id() const
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
const CompatEntry * _entry
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
static const IdString Empty
Empty string.
bool compatibleWith(const CompatEntry &targetEntry_r) const
Return whether this is compatible with targetEntry_r.
sat::detail::IdType IdType
std::ostream & operator<<(std::ostream &str, const Arch::CompatEntry &obj)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
static const unsigned size
bit::BitField< uint64_t > CompatBits
Bitfield for architecture IDs and compatBits relation.
std::string numstring(char n, int w=0)
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
bool operator!=(const Arch::CompatEntry &lhs, const Arch::CompatEntry &rhs)
void addCompatBit(const CompatBits &idBit_r) const
IdString idStr() const
String representation of Arch.
Arch()
Default ctor Arc_noarch.
ZYPP_DEFINE_ID_HASHABLE(zypp::Arch::CompatEntry)
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
const std::string & asString() const
bool operator==(const Arch::CompatEntry &lhs, const Arch::CompatEntry &rhs)
Easy-to use interface to the ZYPP dependency resolver.
CompatEntry(IdString archStr_r, CompatBits::IntT idBit_r=1)
int compare(const CompatEntry &rhs) const
compare by score, then archStr.
Holds an architecture ID and its compatible relation.