Wouldn't it be simpler to just have codegen/unordered_set.h
which in turn has all the odd logic? I'm definitely a tad unhappy about adding "using" in a header, but if the using goes inside the nv50_ir namespace, I'm less weirded out by it. And then effectively all 3 become nv50_ir::unordered_set, instead of the current situation with 2 ::unordered_set and 1 nv50_ir::unordered_set. By the way, I'm about to add some unordered_map usage. Is this going to explode the world for android as well? Something like https://github.com/imirkin/mesa/commit/c6dc6fd6ad19f152a53c58bac93c9aadd6958ae7 but I'm still making sure I have a full understanding of the underlying issue, so might be a little while before I push. -ilia On Fri, Jun 19, 2015 at 12:50 PM, Chih-Wei Huang <cwhu...@android-x86.org> wrote: > If build with C++11 standard, use std::unordered_set. > > Otherwise if build on old Android version with stlport, > use std::tr1::unordered_set with a wrapper class. > > Otherwise use std::tr1::unordered_set. > > Signed-off-by: Chih-Wei Huang <cwhu...@linux.org.tw> > --- > Android.common.mk | 1 + > src/gallium/auxiliary/Android.mk | 2 -- > src/gallium/drivers/nouveau/codegen/nv50_ir.h | 15 +++++++-- > .../nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 4 +-- > .../nouveau/codegen/nv50_ir_lowering_nvc0.h | 4 +-- > src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp | 5 ++- > .../drivers/nouveau/codegen/unordered_set.h | 37 > ++++++++++++++++++++++ > 7 files changed, 55 insertions(+), 13 deletions(-) > create mode 100644 src/gallium/drivers/nouveau/codegen/unordered_set.h > > diff --git a/Android.common.mk b/Android.common.mk > index d662d60..de11e52 100644 > --- a/Android.common.mk > +++ b/Android.common.mk > @@ -78,6 +78,7 @@ endif > > LOCAL_CPPFLAGS += \ > $(if $(filter true,$(MESA_LOLLIPOP_BUILD)),-D_USING_LIBCXX) \ > + -std=c++11 \ > -Wno-error=non-virtual-dtor \ > -Wno-non-virtual-dtor > > diff --git a/src/gallium/auxiliary/Android.mk > b/src/gallium/auxiliary/Android.mk > index 86430eb..dbaeef6 100644 > --- a/src/gallium/auxiliary/Android.mk > +++ b/src/gallium/auxiliary/Android.mk > @@ -40,8 +40,6 @@ ifeq ($(MESA_ENABLE_LLVM),true) > LOCAL_SRC_FILES += \ > $(GALLIVM_SOURCES) \ > $(GALLIVM_CPP_SOURCES) > - > -LOCAL_CPPFLAGS := -std=c++11 > endif > > # We need libmesa_glsl to get NIR's generated include directories. > diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h > b/src/gallium/drivers/nouveau/codegen/nv50_ir.h > index 529dcb9..a060ba3 100644 > --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h > +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h > @@ -29,7 +29,16 @@ > #include <deque> > #include <list> > #include <vector> > +#if __cplusplus >= 201103L > +#include <unordered_set> > +using std::unordered_set; > +#elif defined(ANDROID) // Android release before lollipop > +#include "codegen/unordered_set.h" > +using std::isfinite; > +#else > #include <tr1/unordered_set> > +using std::tr1::unordered_set; > +#endif > > #include "codegen/nv50_ir_util.h" > #include "codegen/nv50_ir_graph.h" > @@ -583,10 +592,10 @@ public: > > static inline Value *get(Iterator&); > > - std::tr1::unordered_set<ValueRef *> uses; > + unordered_set<ValueRef *> uses; > std::list<ValueDef *> defs; > - typedef std::tr1::unordered_set<ValueRef *>::iterator UseIterator; > - typedef std::tr1::unordered_set<ValueRef *>::const_iterator UseCIterator; > + typedef unordered_set<ValueRef *>::iterator UseIterator; > + typedef unordered_set<ValueRef *>::const_iterator UseCIterator; > typedef std::list<ValueDef *>::iterator DefIterator; > typedef std::list<ValueDef *>::const_iterator DefCIterator; > > diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp > b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp > index 7a5d1ce..eccb09c 100644 > --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp > +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp > @@ -224,7 +224,7 @@ NVC0LegalizePostRA::findFirstUses( > const Instruction *texi, > const Instruction *insn, > std::list<TexUse> &uses, > - std::tr1::unordered_set<const Instruction *>& visited) > + unordered_set<const Instruction *>& visited) > { > for (int d = 0; insn->defExists(d); ++d) { > Value *v = insn->getDef(d); > @@ -323,7 +323,7 @@ NVC0LegalizePostRA::insertTextureBarriers(Function *fn) > if (!uses) > return false; > for (size_t i = 0; i < texes.size(); ++i) { > - std::tr1::unordered_set<const Instruction *> visited; > + unordered_set<const Instruction *> visited; > findFirstUses(texes[i], texes[i], uses[i], visited); > } > > diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h > b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h > index 260e101..8c3dcbc 100644 > --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h > +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h > @@ -20,8 +20,6 @@ > * OTHER DEALINGS IN THE SOFTWARE. > */ > > -#include <tr1/unordered_set> > - > #include "codegen/nv50_ir.h" > #include "codegen/nv50_ir_build_util.h" > > @@ -73,7 +71,7 @@ private: > inline bool insnDominatedBy(const Instruction *, const Instruction *) > const; > void findFirstUses(const Instruction *tex, const Instruction *def, > std::list<TexUse>&, > - std::tr1::unordered_set<const Instruction *>&); > + unordered_set<const Instruction *>&); > void findOverwritingDefs(const Instruction *tex, Instruction *insn, > const BasicBlock *term, > std::list<TexUse>&); > diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp > b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp > index 898653c..219d5f1 100644 > --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp > +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ra.cpp > @@ -25,7 +25,6 @@ > > #include <stack> > #include <limits> > -#include <tr1/unordered_set> > > namespace nv50_ir { > > @@ -1551,7 +1550,7 @@ SpillCodeInserter::run(const std::list<ValuePair>& lst) > // Keep track of which instructions to delete later. Deleting them > // inside the loop is unsafe since a single instruction may have > // multiple destinations that all need to be spilled (like OP_SPLIT). > - std::tr1::unordered_set<Instruction *> to_del; > + unordered_set<Instruction *> to_del; > > for (Value::DefIterator d = lval->defs.begin(); d != lval->defs.end(); > ++d) { > @@ -1593,7 +1592,7 @@ SpillCodeInserter::run(const std::list<ValuePair>& lst) > } > } > > - for (std::tr1::unordered_set<Instruction *>::const_iterator it = > to_del.begin(); > + for (unordered_set<Instruction *>::const_iterator it = to_del.begin(); > it != to_del.end(); ++it) > delete_Instruction(func->getProgram(), *it); > } > diff --git a/src/gallium/drivers/nouveau/codegen/unordered_set.h > b/src/gallium/drivers/nouveau/codegen/unordered_set.h > new file mode 100644 > index 0000000..d32c787 > --- /dev/null > +++ b/src/gallium/drivers/nouveau/codegen/unordered_set.h > @@ -0,0 +1,37 @@ > +#ifndef __NV50_UNORDERED_SET_H__ > +#define __NV50_UNORDERED_SET_H__ > + > +#include <unordered_set> // from stlport > + > +namespace nv50_ir { > + > +typedef std::tr1::unordered_set<void *> voidptr_unordered_set; > + > +template <typename V> > +class unordered_set : public voidptr_unordered_set { > + public: > + typedef voidptr_unordered_set _base; > + typedef _base::iterator _biterator; > + typedef _base::const_iterator const_biterator; > + > + class iterator : public _biterator { > + public: > + iterator(const _biterator & i) : _biterator(i) {} > + V operator*() const { return > reinterpret_cast<V>(*_biterator(*this)); } > + }; > + class const_iterator : public const_biterator { > + public: > + const_iterator(const iterator & i) : const_biterator(i) {} > + const_iterator(const const_biterator & i) : const_biterator(i) {} > + const V operator*() const { return reinterpret_cast<const > V>(*const_biterator(*this)); } > + }; > + > + iterator begin() { return _base::begin(); } > + iterator end() { return _base::end(); } > + const_iterator begin() const { return _base::begin(); } > + const_iterator end() const { return _base::end(); } > +}; > + > +} // namespace nv50_ir > + > +#endif // __NV50_UNORDERED_SET_H__ > -- > 1.9.1 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev