diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-04-14 14:46:47 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-04-14 14:46:47 +0400 |
commit | bfca79a6577c7e4ab3d0dcae585abcf2a17fe710 (patch) | |
tree | 00804e29d009c81406892159233d372aee12e500 /extern | |
parent | 69ee17f0b6121ab63f0a7712c9563295eda88d39 (diff) | |
parent | 9a79bd38ade00fc663c27ffda9892629ef5ca755 (diff) |
Merging r44227 through r45619 from trunk into soc-2011-tomato
Diffstat (limited to 'extern')
73 files changed, 2661 insertions, 1486 deletions
diff --git a/extern/carve/CMakeLists.txt b/extern/carve/CMakeLists.txt index cbf92ee293e..660538998a1 100644 --- a/extern/carve/CMakeLists.txt +++ b/extern/carve/CMakeLists.txt @@ -35,115 +35,115 @@ set(INC_SYS ) set(SRC - lib/carve.cpp - lib/mesh.cpp - lib/intersect_group.cpp - lib/intersect_classify_edge.cpp - lib/intersect_classify_group.cpp + lib/intersection.cpp + lib/intersect.cpp + lib/triangulator.cpp + lib/convex_hull.cpp lib/polyhedron.cpp - lib/geom3d.cpp lib/polyline.cpp - lib/csg_collector.cpp - lib/triangulator.cpp - lib/intersect_face_division.cpp - lib/intersect_half_classify_group.cpp - lib/edge.cpp - lib/math.cpp + lib/pointset.cpp lib/geom2d.cpp + lib/math.cpp + lib/intersect_half_classify_group.cpp + lib/intersect_face_division.cpp lib/tag.cpp - lib/intersection.cpp - lib/convex_hull.cpp + lib/aabb.cpp + lib/intersect_classify_group.cpp + lib/mesh.cpp + lib/timing.cpp + lib/geom3d.cpp + lib/intersect_group.cpp + lib/carve.cpp + lib/intersect_classify_edge.cpp lib/csg.cpp - lib/intersect.cpp lib/face.cpp - lib/pointset.cpp - lib/timing.cpp - lib/octree.cpp - lib/aabb.cpp + lib/csg_collector.cpp lib/intersect_debug.cpp + lib/edge.cpp + lib/octree.cpp - lib/intersect_classify_common.hpp - lib/csg_data.hpp + lib/intersect_debug.hpp lib/csg_collector.hpp + lib/csg_data.hpp + lib/intersect_classify_common.hpp lib/intersect_common.hpp - lib/intersect_classify_common_impl.hpp lib/csg_detail.hpp - lib/intersect_debug.hpp + lib/intersect_classify_common_impl.hpp - include/carve/polyhedron_decl.hpp - include/carve/geom2d.hpp - include/carve/exact.hpp - include/carve/triangulator_impl.hpp - include/carve/collection.hpp - include/carve/pointset.hpp - include/carve/djset.hpp - include/carve/kd_node.hpp - include/carve/polyline.hpp - include/carve/polyline_iter.hpp - include/carve/geom3d.hpp - include/carve/edge_decl.hpp - include/carve/face_decl.hpp + include/carve/vertex_impl.hpp include/carve/aabb_impl.hpp - include/carve/colour.hpp + include/carve/csg.hpp include/carve/pointset_iter.hpp - include/carve/polyline_decl.hpp - include/carve/rescale.hpp - include/carve/mesh_impl.hpp - include/carve/classification.hpp - include/carve/util.hpp - include/carve/triangulator.hpp - include/carve/polyhedron_base.hpp - include/carve/rtree.hpp - include/carve/math.hpp - include/carve/math_constants.hpp - include/carve/octree_decl.hpp - include/carve/input.hpp - include/carve/mesh_ops.hpp include/carve/debug_hooks.hpp - include/carve/mesh_simplify.hpp - include/carve/interpolator.hpp - include/carve/poly_decl.hpp - include/carve/csg.hpp include/carve/mesh.hpp - include/carve/carve.hpp - include/carve/gnu_cxx.h - include/carve/polyhedron_impl.hpp - include/carve/poly_impl.hpp - include/carve/aabb.hpp + include/carve/triangulator_impl.hpp + include/carve/edge_decl.hpp + include/carve/collection/unordered.hpp + include/carve/collection/unordered/tr1_impl.hpp + include/carve/collection/unordered/fallback_impl.hpp + include/carve/collection/unordered/std_impl.hpp + include/carve/collection/unordered/vcpp_impl.hpp + include/carve/collection/unordered/libstdcpp_impl.hpp + include/carve/collection/unordered/boost_impl.hpp include/carve/convex_hull.hpp - include/carve/vertex_decl.hpp + include/carve/geom.hpp + include/carve/collection_types.hpp + include/carve/cbrt.h + include/carve/util.hpp + include/carve/iobj.hpp + include/carve/polyline_decl.hpp + include/carve/polyline_impl.hpp include/carve/win32.h include/carve/edge_impl.hpp - include/carve/tag.hpp - include/carve/tree.hpp - include/carve/heap.hpp + include/carve/carve.hpp + include/carve/polyline.hpp + include/carve/face_decl.hpp include/carve/matrix.hpp - include/carve/poly.hpp - include/carve/vector.hpp - include/carve/intersection.hpp - include/carve/faceloop.hpp + include/carve/classification.hpp include/carve/geom_impl.hpp - include/carve/octree_impl.hpp - include/carve/spacetree.hpp - include/carve/collection/unordered/std_impl.hpp - include/carve/collection/unordered/tr1_impl.hpp - include/carve/collection/unordered/libstdcpp_impl.hpp - include/carve/collection/unordered/boost_impl.hpp - include/carve/collection/unordered/vcpp_impl.hpp - include/carve/collection/unordered/fallback_impl.hpp - include/carve/collection/unordered.hpp + include/carve/faceloop.hpp + include/carve/mesh_ops.hpp + include/carve/tree.hpp + include/carve/geom2d.hpp include/carve/face_impl.hpp + include/carve/polyhedron_decl.hpp + include/carve/interpolator.hpp + include/carve/poly_decl.hpp + include/carve/mesh_impl.hpp + include/carve/gnu_cxx.h + include/carve/mesh_simplify.hpp + include/carve/triangulator.hpp include/carve/pointset_impl.hpp - include/carve/cbrt.h + include/carve/rtree.hpp + include/carve/math_constants.hpp + include/carve/vector.hpp + include/carve/octree_impl.hpp + include/carve/pointset.hpp + include/carve/math.hpp + include/carve/intersection.hpp + include/carve/colour.hpp + include/carve/kd_node.hpp + include/carve/input.hpp + include/carve/geom3d.hpp + include/carve/exact.hpp + include/carve/rescale.hpp + include/carve/polyhedron_base.hpp + include/carve/heap.hpp + include/carve/spacetree.hpp + include/carve/polyhedron_impl.hpp include/carve/vcpp_config.h - include/carve/geom.hpp - include/carve/vertex_impl.hpp - include/carve/polyline_impl.hpp - include/carve/pointset_decl.hpp - include/carve/timing.hpp + include/carve/aabb.hpp + include/carve/polyline_iter.hpp + include/carve/djset.hpp + include/carve/vertex_decl.hpp include/carve/csg_triangulator.hpp - include/carve/iobj.hpp - include/carve/collection_types.hpp + include/carve/poly.hpp + include/carve/timing.hpp + include/carve/octree_decl.hpp + include/carve/pointset_decl.hpp + include/carve/tag.hpp + include/carve/collection.hpp + include/carve/poly_impl.hpp ) if(WITH_BOOST) diff --git a/extern/carve/bundle.sh b/extern/carve/bundle.sh index bc719ae5ba8..e68b2c7e90e 100755 --- a/extern/carve/bundle.sh +++ b/extern/carve/bundle.sh @@ -47,7 +47,7 @@ cat > CMakeLists.txt << EOF # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2006, Blender Foundation # All rights reserved. diff --git a/extern/carve/include/carve/exact.hpp b/extern/carve/include/carve/exact.hpp index afb491211fd..0d674e66ef7 100644 --- a/extern/carve/include/carve/exact.hpp +++ b/extern/carve/include/carve/exact.hpp @@ -639,9 +639,11 @@ namespace carve { } - // XXX: not implemented yet - //exact_t operator+(const exact_t &a, const exact_t &b) { - //} + exact_t operator+(const exact_t &a, const exact_t &b) { + exact_t r; + sum_zeroelim(a, b, r); + return r; + } diff --git a/extern/carve/include/carve/kd_node.hpp b/extern/carve/include/carve/kd_node.hpp index f62584d50c2..45e0ac85739 100644 --- a/extern/carve/include/carve/kd_node.hpp +++ b/extern/carve/include/carve/kd_node.hpp @@ -230,7 +230,7 @@ namespace carve { } // distance_t must provide: - // double operator()(kd_node::data_t, vector<ndim>); + // double operator()(data_t, vector<ndim>); // double operator()(axis_pos, vector<ndim>); template<typename distance_t> struct near_point_query { @@ -238,7 +238,7 @@ namespace carve { // q_t - the priority queue value type. // q_t.first: distance from object to query point. // q_t.second: pointer to object - typedef std::pair<double, const typename kd_node::data_t *> q_t; + typedef std::pair<double, const data_t *> q_t; // the queue priority should sort from smallest distance to largest, and on equal distance, by object pointer. struct pcmp { @@ -266,7 +266,7 @@ namespace carve { } } - const typename kd_node::data_t *next() { + const data_t *next() { while (1) { if (pq.size()) { q_t t = pq.top(); diff --git a/extern/carve/include/carve/mesh_impl.hpp b/extern/carve/include/carve/mesh_impl.hpp index 23b0a436573..d55df8c8130 100644 --- a/extern/carve/include/carve/mesh_impl.hpp +++ b/extern/carve/include/carve/mesh_impl.hpp @@ -624,8 +624,7 @@ namespace carve { CARVE_ASSERT(e->rev != NULL); e = e->rev->next; CARVE_ASSERT(e->v1() == emin->v1()); - CARVE_ASSERT(e->v1()->v < e->v2()->v); - CARVE_ASSERT(e->v1()->v.x <= e->v2()->v.x); + CARVE_ASSERT(e->v1()->v <= e->v2()->v); } while (e != emin); double max_abs_x = 0.0; diff --git a/extern/carve/include/carve/polyhedron_impl.hpp b/extern/carve/include/carve/polyhedron_impl.hpp index 06d841c7192..de61324140d 100644 --- a/extern/carve/include/carve/polyhedron_impl.hpp +++ b/extern/carve/include/carve/polyhedron_impl.hpp @@ -88,9 +88,9 @@ namespace carve { *(*result)++ = f; int r = 1; - for (size_t i = 0; i < f->edges.size(); ++i) { - const std::vector<const face_t *> &edge_faces = connectivity.edge_to_face[edgeToIndex_fast(f->edges[i])]; - const face_t *f2 = connectedFace(f, f->edges[i]); + for (size_t i = 0; i < f->nEdges(); ++i) { + const std::vector<const face_t *> &edge_faces = connectivity.edge_to_face[edgeToIndex_fast(f->edge(i))]; + const face_t *f2 = connectedFace(f, f->edge(i)); if (f2) { r += _faceNeighbourhood(f2, depth - 1, (*result)); } @@ -116,7 +116,7 @@ namespace carve { int r = 0; const std::vector<const face_t *> &edge_faces = connectivity.edge_to_face[edgeToIndex_fast(e)]; for (size_t i = 0; i < edge_faces.size(); ++i) { - face_t *f = edge_faces[i]; + const face_t *f = edge_faces[i]; if (f && f->manifold_id == m_id) { r += _faceNeighbourhood(f, depth, &result); } } return r; @@ -131,7 +131,7 @@ namespace carve { int r = 0; const std::vector<const face_t *> &vertex_faces = connectivity.vertex_to_face[vertexToIndex_fast(v)]; for (size_t i = 0; i < vertex_faces.size(); ++i) { - face_t *f = vertex_faces[i]; + const face_t *f = vertex_faces[i]; if (f && f->manifold_id == m_id) { r += _faceNeighbourhood(f, depth, &result); } } return r; @@ -142,7 +142,7 @@ namespace carve { // accessing connectivity information. template<typename T> int Geometry<3>::vertexToEdges(const vertex_t *v, T result) const { - std::vector<const edge_t *> &e = connectivity.vertex_to_edge[vertexToIndex_fast(v)]; + const std::vector<const edge_t *> &e = connectivity.vertex_to_edge[vertexToIndex_fast(v)]; std::copy(e.begin(), e.end(), result); return e.size(); } diff --git a/extern/carve/patches/strict_flags.patch b/extern/carve/patches/strict_flags.patch index 5e4b867ba26..5c7e8967d39 100644 --- a/extern/carve/patches/strict_flags.patch +++ b/extern/carve/patches/strict_flags.patch @@ -9,30 +9,6 @@ diff -r 47dfdaff1dd5 include/carve/csg_triangulator.hpp } carve::mesh::MeshSet<3>::face_t *mergeQuad(edge_map_t::iterator i, edge_map_t &edge_map) { -diff -r 47dfdaff1dd5 include/carve/exact.hpp ---- a/include/carve/exact.hpp Thu Jan 12 15:49:04 2012 -0500 -+++ b/include/carve/exact.hpp Fri Jan 13 03:13:32 2012 +0600 -@@ -379,7 +379,7 @@ - prod_2_1(b, a, r); - } - -- static inline double prod_4_1(const double *a, const double *b, double *r) { -+ static inline void prod_4_1(const double *a, const double *b, double *r) { - double b_sp[2]; split(b[0], b_sp); - double t1[2]; prod_1_1s(a+0, b, b_sp, t1); - r[0] = t1[0]; -@@ -639,8 +639,9 @@ - } - - -- exact_t operator+(const exact_t &a, const exact_t &b) { -- } -+ // XXX: not implemented yet -+ //exact_t operator+(const exact_t &a, const exact_t &b) { -+ //} - - - diff -r 47dfdaff1dd5 src/selfintersect.cpp --- a/src/selfintersect.cpp Thu Jan 12 15:49:04 2012 -0500 +++ b/src/selfintersect.cpp Fri Jan 13 03:13:32 2012 +0600 diff --git a/extern/libmv/CMakeLists.txt b/extern/libmv/CMakeLists.txt index 73c2baa0207..02723b64b62 100644 --- a/extern/libmv/CMakeLists.txt +++ b/extern/libmv/CMakeLists.txt @@ -39,6 +39,19 @@ set(INC_SYS ${ZLIB_INCLUDE_DIRS} ) + +# XXX - FIXME +# this is a momentary hack to find unwind.h in 10.6.sdk +if(APPLE) + if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.6") + list(APPEND INC_SYS + ${CMAKE_OSX_SYSROOT}/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include + ) + endif() +endif() +# XXX - END + + set(SRC libmv-capi.cpp libmv/image/array_nd.cc @@ -59,6 +72,7 @@ set(SRC libmv/simple_pipeline/pipeline.cc libmv/simple_pipeline/reconstruction.cc libmv/simple_pipeline/resect.cc + libmv/simple_pipeline/rigid_registration.cc libmv/simple_pipeline/tracks.cc libmv/tracking/brute_region_tracker.cc libmv/tracking/esm_region_tracker.cc @@ -67,7 +81,6 @@ set(SRC libmv/tracking/lmicklt_region_tracker.cc libmv/tracking/pyramid_region_tracker.cc libmv/tracking/retrack_region_tracker.cc - libmv/tracking/sad.cc libmv/tracking/trklt_region_tracker.cc third_party/fast/fast_10.c @@ -90,6 +103,7 @@ set(SRC libmv/base/vector_utils.h libmv/image/array_nd.h libmv/image/convolve.h + libmv/image/correlation.h libmv/image/image.h libmv/image/sample.h libmv/image/tuple.h @@ -115,6 +129,7 @@ set(SRC libmv/simple_pipeline/pipeline.h libmv/simple_pipeline/reconstruction.h libmv/simple_pipeline/resect.h + libmv/simple_pipeline/rigid_registration.h libmv/simple_pipeline/tracks.h libmv/tracking/brute_region_tracker.h libmv/tracking/esm_region_tracker.h @@ -124,14 +139,15 @@ set(SRC libmv/tracking/pyramid_region_tracker.h libmv/tracking/region_tracker.h libmv/tracking/retrack_region_tracker.h - libmv/tracking/sad.h libmv/tracking/trklt_region_tracker.h third_party/fast/fast.h third_party/gflags/config.h - third_party/gflags/gflags_completions.h - third_party/gflags/gflags.h + third_party/gflags/gflags/gflags_completions.h + third_party/gflags/gflags/gflags_declare.h + third_party/gflags/gflags/gflags.h third_party/gflags/mutex.h + third_party/gflags/util.h third_party/ldl/Include/ldl.h third_party/msinttypes/inttypes.h third_party/msinttypes/stdint.h @@ -203,6 +219,7 @@ else() third_party/glog/src/base/mutex.h third_party/glog/src/config_freebsd.h third_party/glog/src/config.h + third_party/glog/src/config_hurd.h third_party/glog/src/config_linux.h third_party/glog/src/config_mac.h third_party/glog/src/demangle.h diff --git a/extern/libmv/ChangeLog b/extern/libmv/ChangeLog index f49a07de350..33068bddf90 100644 --- a/extern/libmv/ChangeLog +++ b/extern/libmv/ChangeLog @@ -1,3 +1,128 @@ +commit fa3842e472e3b9c789e47bf6d8f592aa40a84f16 +Author: Sergey Sharybin <sergey.vfx@gmail.com> +Date: Thu Apr 12 12:32:48 2012 +0600 + + implementation of some basic algorithms for point cloud orientation: + + - Implementation of rigid registration algorithm which searches transformation + form one point cloud to another assuming that points in this clouds are + already paired (points with the same index in different clouds belongs to + the same pair) which minimizes average distance between points in pairs. + + Algorithm uses Levenberg-Marquardt solver to find such transformation. + + Supports registration of rotation-scale-transform (which is probably most + common usage) and rotation only (which might be useful for basic modal + tripod solver). + + - Implementation of Iterative-Point-Clouds algorithm which searches + transformation from one arbitrary point cloud to another making + points as closest to each other as possible. + + This algorithm doesn't require points be initially paired, but for + good result clouds should have rough initial orientation. If they're + arbitrary oriented from the very beginning, algorithm might fail + producing good resold. + + Iteration is based on building pairs of closest to each other points + and registering rigid transformation between them which incrementally + constructs final result. + + TODO: building pairs might be speedup a lot using data structures like + AABB trees, K-D trees or so. + +commit 9618d9a1d48bb3c28da605d9027f57a74f462785 +Author: Sergey Sharybin <sergey.vfx@gmail.com> +Date: Wed Apr 11 14:17:14 2012 +0600 + + Added configuration file for glog to compile smooth on Hurd platform. + + Patch by Pino Toscano <pino@debian.org>, thanks! + +commit 63b2bd20237c8599fa73ce42556e4fb99b9f7cca +Author: Sergey Sharybin <sergey.vfx@gmail.com> +Date: Thu Mar 22 17:03:34 2012 +0600 + + Trackers refactoring: + - Deduplicate pattern sampling used in esm and lmicklt trackers + and move SamplePattern to image/sample.h + - Move computation of Pearson product-moment correlation into + own function in new file image/correlation.h so all trackers + can use it to check final correlation. + - Remove SAD tracker. It's almost the same as brute tracker, + with only two differences: + 1. It does brute search of affine transformation which in some cases + helps to track rotating features + 2. It didn't use common tracker api which probably gave some speed + advantage, but lead to a real headache to use it together with + other trackers leading to duplicated code in 3d-party software. + +commit 9fe49c32e990f28c83f2bbb1d18057aed8879af7 +Author: Sergey Sharybin <sergey.vfx@gmail.com> +Date: Mon Mar 12 09:36:15 2012 +0600 + + Code cleanup: convert line endings to Unix style (native on my platform) so it + wouldn't confuse other versioning systems used for project where libmv is bundled to, + + Also change mode to +x for glog's windows-related script. + +commit fe74ae2b53769389b0ed9d7e604c8e60be81077d +Author: Sergey I. Sharybin <g.ulairi@gmail.com> +Date: Sun Mar 11 20:34:15 2012 +0600 + + Replace "third_party/glog/src/glog/logging.h" with <glog/logging.h> + + It was needed because of how build systems is setup in Blender but think + this will be helpful change for other applications too because it makes + it's easier to move libraries around and even use libraries installed + on the operation system. + +commit 37fc726701479f2d321d6af878fa93f3176278d5 +Author: Sergey I. Sharybin <g.ulairi@gmail.com> +Date: Sun Mar 11 19:27:41 2012 +0600 + + Upgrade gflags and glog libraries - stage 2 (final) + + Changes to upstream code which are needed to make libmv compile smooth on all platforms + + * Replace <gflags/gflags.h> with "third_party/gflags/gflags/gflags.h" which is easier + to setup things in libmv and also helps with setting up building libmv into + external applications. + * Replace "glog/logging.h" and "glog/logging.h" with <glog/logging.h> and <glog/logging.h> + which is needed on Windows platform because otherwise files like logging.cc will be using + relative path which points to headers used by linux instead of headers need to be used + on Windows. + * Replace _asm int 3 with __debugbreak(). Such assembler code is obsolete and doesn't work + with 64bit versions of MSVC compilers. + * Do not use stacktrace for MinGW and FreeBSD because it leads into issues accessing + some specific data on this platforms. + * Define HAVE_LIB_GFLAGS for Windows builds. + * Do not define __declspec(dllimport) for MinGW platforms. + * Setup proper includes and datatypes for int32, uint32, int64 and uint64 for MinGW + * Do not define va_copy for MinGW platforms (it's already defined there). + * Patch localtime_r to be working fine with MinGW, disable strerror_r for MinGW because + of lack of needed functions. + +commit 8ed07abfa49d1e0511752021c972e0715e5a1383 +Author: Sergey I. Sharybin <g.ulairi@gmail.com> +Date: Sun Mar 11 19:06:33 2012 +0600 + + Upgrade gflags and glog libraries - stage 1 + + This commit copies sources from latest original release of gflags and glog + over currently bundled versions of this libraries without any modifications. + + This revision can't b compiled, all needed changes to make new libraries working + fine will be done with next commit to make it clear which changes were necessary + for easier bundling further newer version and extract patches and put them to + gflags/glog upstream repo. + + Such upgrade of libraries is needed to make it able to compile libmv + with clang compilers. Currently used versions: + + - gflags is version 2.0 + - glog is version 0.3.2 + commit 75b9af405964ff2c7d3f0a44500e27e63b37c91b Author: Sergey Sharybin <sergey.vfx@gmail.com> Date: Fri Feb 17 23:29:11 2012 +0600 @@ -401,49 +526,3 @@ Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> Date: Fri Aug 19 14:59:24 2011 +0200 Expose regularization parameters (areaPenalty and conditionPenalty) in API. - -commit 3e84ae5fbac10451d4935418f6281a90cedace11 -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Fri Aug 19 14:19:27 2011 +0200 - - Add LaplaceFilter. - Add regularization in affine SAD Tracker (keep constant area and good condition number). - UI: Better track display (+enable line antialiasing). - -commit 6d26d9a8ccc4ce009fbf253898fea8864dd5001a -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Fri Aug 19 10:25:26 2011 +0200 - - Add optimization for integer pixel search. - Allows more agressive settings for affine coordinate descent. - -commit 70ceae81c0ab561b07e640ecb9933f0a902b57cd -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Fri Aug 19 00:02:12 2011 +0200 - - Document coordinate descent method in affine SAD matcher. - Add heuristic to prevent high distortions. - -commit 75520f4bc4ccbb272a1b4149d3b8d05a90f7f896 -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Thu Aug 18 23:14:17 2011 +0200 - - Fix affine iteration. - -commit 4e8e0aa6018e3eb2fbebdad7f1cbd6c909d26e79 -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Thu Aug 18 23:03:26 2011 +0200 - - Handle rotations. - -commit 3ce41cf3c1b5c136a61d8f4c63ccae3cafbdb8da -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Thu Aug 18 22:24:47 2011 +0200 - - Slow brute-force affine diamond search implementation. - -commit 1c4acd03e030c1c50dc6fc36c419c72ea69a0713 -Author: Matthias Fauconneau <matthias.fauconneau@gmail.com> -Date: Thu Aug 18 20:51:43 2011 +0200 - - Fix detect.cc. diff --git a/extern/libmv/bundle.sh b/extern/libmv/bundle.sh index f259635035e..a34e45a38b0 100755 --- a/extern/libmv/bundle.sh +++ b/extern/libmv/bundle.sh @@ -131,6 +131,19 @@ set(INC_SYS \${ZLIB_INCLUDE_DIRS} ) + +# XXX - FIXME +# this is a momentary hack to find unwind.h in 10.6.sdk +if(APPLE) + if(\${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.6") + list(APPEND INC_SYS + \${CMAKE_OSX_SYSROOT}/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/include + ) + endif() +endif() +# XXX - END + + set(SRC libmv-capi.cpp ${sources} diff --git a/extern/libmv/files.txt b/extern/libmv/files.txt index 96dfd89828e..1e564d3a2f2 100644 --- a/extern/libmv/files.txt +++ b/extern/libmv/files.txt @@ -6,6 +6,7 @@ libmv/image/array_nd.cc libmv/image/array_nd.h libmv/image/convolve.cc libmv/image/convolve.h +libmv/image/correlation.h libmv/image/image.h libmv/image/sample.h libmv/image/tuple.h @@ -47,6 +48,8 @@ libmv/simple_pipeline/reconstruction.cc libmv/simple_pipeline/reconstruction.h libmv/simple_pipeline/resect.cc libmv/simple_pipeline/resect.h +libmv/simple_pipeline/rigid_registration.cc +libmv/simple_pipeline/rigid_registration.h libmv/simple_pipeline/tracks.cc libmv/simple_pipeline/tracks.h libmv/tracking/brute_region_tracker.cc @@ -64,8 +67,6 @@ libmv/tracking/pyramid_region_tracker.h libmv/tracking/region_tracker.h libmv/tracking/retrack_region_tracker.cc libmv/tracking/retrack_region_tracker.h -libmv/tracking/sad.cc -libmv/tracking/sad.h libmv/tracking/trklt_region_tracker.cc libmv/tracking/trklt_region_tracker.h third_party/fast/fast_10.c @@ -78,14 +79,20 @@ third_party/fast/LICENSE third_party/fast/nonmax.c third_party/fast/README third_party/fast/README.libmv +third_party/gflags/AUTHORS +third_party/gflags/ChangeLog third_party/gflags/config.h +third_party/gflags/COPYING third_party/gflags/gflags.cc third_party/gflags/gflags_completions.cc -third_party/gflags/gflags_completions.h -third_party/gflags/gflags.h +third_party/gflags/gflags/gflags_completions.h +third_party/gflags/gflags/gflags_declare.h +third_party/gflags/gflags/gflags.h third_party/gflags/gflags_reporting.cc third_party/gflags/mutex.h +third_party/gflags/NEWS third_party/gflags/README.libmv +third_party/gflags/util.h third_party/glog/AUTHORS third_party/glog/ChangeLog third_party/glog/COPYING @@ -97,6 +104,7 @@ third_party/glog/src/base/googleinit.h third_party/glog/src/base/mutex.h third_party/glog/src/config_freebsd.h third_party/glog/src/config.h +third_party/glog/src/config_hurd.h third_party/glog/src/config_linux.h third_party/glog/src/config_mac.h third_party/glog/src/demangle.cc diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index 1835c53b53f..e4708e5907d 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -30,11 +30,14 @@ #include "libmv-capi.h" +#include "third_party/gflags/gflags/gflags.h" #include "glog/logging.h" #include "libmv/logging/logging.h" #include "Math/v3d_optimization.h" +#include "libmv/numeric/numeric.h" + #include "libmv/tracking/esm_region_tracker.h" #include "libmv/tracking/brute_region_tracker.h" #include "libmv/tracking/hybrid_region_tracker.h" @@ -43,8 +46,6 @@ #include "libmv/tracking/lmicklt_region_tracker.h" #include "libmv/tracking/pyramid_region_tracker.h" -#include "libmv/tracking/sad.h" - #include "libmv/simple_pipeline/callbacks.h" #include "libmv/simple_pipeline/tracks.h" #include "libmv/simple_pipeline/initialize_reconstruction.h" @@ -52,6 +53,7 @@ #include "libmv/simple_pipeline/detect.h" #include "libmv/simple_pipeline/pipeline.h" #include "libmv/simple_pipeline/camera_intrinsics.h" +#include "libmv/simple_pipeline/rigid_registration.h" #include <stdlib.h> #include <assert.h> @@ -136,12 +138,25 @@ libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_w libmv::BruteRegionTracker *brute_region_tracker = new libmv::BruteRegionTracker; brute_region_tracker->half_window_size = half_window_size; + /* do not use correlation check for brute checker itself, + * this check will happen in esm tracker */ + brute_region_tracker->minimum_correlation = 0.0; + libmv::HybridRegionTracker *hybrid_region_tracker = new libmv::HybridRegionTracker(brute_region_tracker, esm_region_tracker); return (libmv_RegionTracker *)hybrid_region_tracker; } +libmv_RegionTracker *libmv_bruteRegionTrackerNew(int half_window_size, double minimum_correlation) +{ + libmv::BruteRegionTracker *brute_region_tracker = new libmv::BruteRegionTracker; + brute_region_tracker->half_window_size = half_window_size; + brute_region_tracker->minimum_correlation = minimum_correlation; + + return (libmv_RegionTracker *)brute_region_tracker; +} + static void floatBufToImage(const float *buf, int width, int height, libmv::FloatImage *image) { int x, y, a = 0; @@ -315,33 +330,6 @@ void libmv_regionTrackerDestroy(libmv_RegionTracker *libmv_tracker) /* ************ Tracks ************ */ -void libmv_SADSamplePattern(unsigned char *image, int stride, - float warp[3][2], unsigned char *pattern, int pattern_size) -{ - libmv::mat32 mat32; - - memcpy(mat32.data, warp, sizeof(float)*3*2); - - libmv::SamplePattern(image, stride, mat32, pattern, pattern_size); -} - -float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, int pattern_size, unsigned char *image, int stride, - int width, int height, float warp[3][2]) -{ - float result; - libmv::mat32 mat32; - - memcpy(mat32.data, warp, sizeof(float)*3*2); - - result = libmv::Track(pattern, warped, pattern_size, image, stride, width, height, &mat32, 16, 16); - - memcpy(warp, mat32.data, sizeof(float)*3*2); - - return result; -} - -/* ************ Tracks ************ */ - libmv_Tracks *libmv_tracksNew(void) { libmv::Tracks *libmv_tracks = new libmv::Tracks(); @@ -853,3 +841,56 @@ void libmv_InvertIntrinsics(double focal_length, double principal_x, double prin intrinsics.InvertIntrinsics(x, y, x1, y1); } } + +/* ************ point clouds ************ */ + +void libmvTransformToMat4(libmv::Mat3 &R, libmv::Vec3 &S, libmv::Vec3 &t, double M[4][4]) +{ + for (int j = 0; j < 3; ++j) + for (int k = 0; k < 3; ++k) + M[j][k] = R(k, j) * S(j); + + for (int i = 0; i < 3; ++i) { + M[3][0] = t(0); + M[3][1] = t(1); + M[3][2] = t(2); + + M[0][3] = M[1][3] = M[2][3] = 0; + } + + M[3][3] = 1.0; +} + +void libmv_rigidRegistration(float (*reference_points)[3], float (*points)[3], int total_points, + int use_scale, int use_translation, double M[4][4]) +{ + libmv::Mat3 R; + libmv::Vec3 S; + libmv::Vec3 t; + libmv::vector<libmv::Vec3> reference_points_vector, points_vector; + + for (int i = 0; i < total_points; i++) { + reference_points_vector.push_back(libmv::Vec3(reference_points[i][0], + reference_points[i][1], + reference_points[i][2])); + + points_vector.push_back(libmv::Vec3(points[i][0], + points[i][1], + points[i][2])); + } + + if (use_scale && use_translation) { + libmv::RigidRegistration(reference_points_vector, points_vector, R, S, t); + } + else if (use_translation) { + S = libmv::Vec3(1.0, 1.0, 1.0); + libmv::RigidRegistration(reference_points_vector, points_vector, R, t); + } + else { + S = libmv::Vec3(1.0, 1.0, 1.0); + t = libmv::Vec3::Zero(); + libmv::RigidRegistration(reference_points_vector, points_vector, R); + } + + libmvTransformToMat4(R, S, t, M); +} diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index e10d4ef842a..01019832374 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -45,16 +45,11 @@ void libmv_setLoggingVerbosity(int verbosity); /* RegionTracker */ struct libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyramid_level, int half_window_size, double minimum_correlation); struct libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_window_size, double minimum_correlation); +struct libmv_RegionTracker *libmv_bruteRegionTrackerNew(int half_window_size, double minimum_correlation); int libmv_regionTrackerTrack(struct libmv_RegionTracker *libmv_tracker, const float *ima1, const float *ima2, int width, int height, double x1, double y1, double *x2, double *y2); void libmv_regionTrackerDestroy(struct libmv_RegionTracker *libmv_tracker); -/* SAD Tracker */ -void libmv_SADSamplePattern(unsigned char *image, int stride, - float warp[3][2], unsigned char *pattern, int pattern_size); -float libmv_SADTrackerTrack(unsigned char *pattern, unsigned char *warped, int pattern_size, unsigned char *image, - int stride, int width, int height, float warp[3][2]); - /* Tracks */ struct libmv_Tracks *libmv_tracksNew(void); void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y); @@ -134,6 +129,10 @@ void libmv_applyCameraIntrinsics(double focal_length, double principal_x, double void libmv_InvertIntrinsics(double focal_length, double principal_x, double principal_y, double k1, double k2, double k3, double x, double y, double *x1, double *y1); +/* point clouds */ +void libmv_rigidRegistration(float (*reference_points)[3], float (*points)[3], int total_points, + int use_scale, int use_translation, double M[4][4]); + #ifdef __cplusplus } #endif diff --git a/extern/libmv/libmv/image/correlation.h b/extern/libmv/libmv/image/correlation.h new file mode 100644 index 00000000000..9d6aceecceb --- /dev/null +++ b/extern/libmv/libmv/image/correlation.h @@ -0,0 +1,51 @@ +// Copyright (c) 2012 libmv authors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +#ifndef LIBMV_IMAGE_CORRELATION_H +#define LIBMV_IMAGE_CORRELATION_H + +#include "libmv/image/image.h" + +namespace libmv { + +inline double PearsonProductMomentCorrelation(Array3Df image_and_gradient1_sampled, + Array3Df image_and_gradient2_sampled, + int width) { + double sX=0,sY=0,sXX=0,sYY=0,sXY=0; + for (int r = 0; r < width; ++r) { + for (int c = 0; c < width; ++c) { + double x = image_and_gradient1_sampled(r, c, 0); + double y = image_and_gradient2_sampled(r, c, 0); + sX += x; + sY += y; + sXX += x*x; + sYY += y*y; + sXY += x*y; + } + } + double N = width*width; + sX /= N, sY /= N, sXX /= N, sYY /= N, sXY /= N; + double correlation = (sXY-sX*sY)/sqrt(double((sXX-sX*sX)*(sYY-sY*sY))); + return correlation; +} + +} // namespace libmv + +#endif // LIBMV_IMAGE_IMAGE_CORRELATION_H diff --git a/extern/libmv/libmv/image/sample.h b/extern/libmv/libmv/image/sample.h index cd361231b58..ea86edf117d 100644 --- a/extern/libmv/libmv/image/sample.h +++ b/extern/libmv/libmv/image/sample.h @@ -98,6 +98,24 @@ inline void DownsampleChannelsBy2(const Array3Df &in, Array3Df *out) { } +// Sample a region centered at x,y in image with size extending by half_width +// from x,y. Channels specifies the number of channels to sample from. +inline void SamplePattern(const FloatImage &image, + double x, double y, + int half_width, + int channels, + FloatImage *sampled) { + sampled->Resize(2 * half_width + 1, 2 * half_width + 1, channels); + for (int r = -half_width; r <= half_width; ++r) { + for (int c = -half_width; c <= half_width; ++c) { + for (int i = 0; i < channels; ++i) { + (*sampled)(r + half_width, c + half_width, i) = + SampleLinear(image, y + r, x + c, i); + } + } + } +} + } // namespace libmv #endif // LIBMV_IMAGE_SAMPLE_H_ diff --git a/extern/libmv/libmv/logging/logging.h b/extern/libmv/libmv/logging/logging.h index af86c4baa42..776d9d52f7a 100644 --- a/extern/libmv/libmv/logging/logging.h +++ b/extern/libmv/libmv/logging/logging.h @@ -21,7 +21,7 @@ #ifndef LIBMV_LOGGING_LOGGING_H #define LIBMV_LOGGING_LOGGING_H -#include "glog/logging.h" +#include <glog/logging.h> #define LG LOG(INFO) #define V0 LOG(INFO) diff --git a/extern/libmv/libmv/numeric/numeric.h b/extern/libmv/libmv/numeric/numeric.h index bb7f9b364ef..ad707fb76f2 100644 --- a/extern/libmv/libmv/numeric/numeric.h +++ b/extern/libmv/libmv/numeric/numeric.h @@ -474,6 +474,17 @@ inline Mat23 SkewMatMinimal(const Vec2 &x) { 1, 0, -x(0); return skew; } + +/// Returns the rotaiton matrix built from given vector of euler angles +inline Mat3 RotationFromEulerVector(Vec3 euler_vector) { + double theta = euler_vector.norm(); + if (theta == 0.0) { + return Mat3::Identity(); + } + Vec3 w = euler_vector / theta; + Mat3 w_hat = CrossProductMatrix(w); + return Mat3::Identity() + w_hat*sin(theta) + w_hat*w_hat*(1 - cos(theta)); +} } // namespace libmv #endif // LIBMV_NUMERIC_NUMERIC_H diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc index 2e4e5a6491d..2459d059114 100644 --- a/extern/libmv/libmv/simple_pipeline/pipeline.cc +++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc @@ -280,6 +280,25 @@ double InternalReprojectionError(const Tracks &image_tracks, double ex = reprojected_marker.x - markers[i].x; double ey = reprojected_marker.y - markers[i].y; + const int N = 100; + char line[N]; + snprintf(line, N, + "image %-3d track %-3d " + "x %7.1f y %7.1f " + "rx %7.1f ry %7.1f " + "ex %7.1f ey %7.1f" + " e %7.1f", + markers[i].image, + markers[i].track, + markers[i].x, + markers[i].y, + reprojected_marker.x, + reprojected_marker.y, + ex, + ey, + sqrt(ex*ex + ey*ey)); + LG << line; + total_error += sqrt(ex*ex + ey*ey); } LG << "Skipped " << num_skipped << " markers."; diff --git a/extern/libmv/libmv/simple_pipeline/resect.cc b/extern/libmv/libmv/simple_pipeline/resect.cc index 6e71c3c7206..b30d959b512 100644 --- a/extern/libmv/libmv/simple_pipeline/resect.cc +++ b/extern/libmv/libmv/simple_pipeline/resect.cc @@ -42,16 +42,6 @@ Mat2X PointMatrixFromMarkers(const vector<Marker> &markers) { return points; } -Mat3 RotationFromEulerVector(Vec3 euler_vector) { - double theta = euler_vector.norm(); - if (theta == 0.0) { - return Mat3::Identity(); - } - Vec3 w = euler_vector / theta; - Mat3 w_hat = CrossProductMatrix(w); - return Mat3::Identity() + w_hat*sin(theta) + w_hat*w_hat*(1 - cos(theta)); -} - // Uses an incremental rotation: // // x = R' * R * X + t; diff --git a/extern/libmv/libmv/simple_pipeline/rigid_registration.cc b/extern/libmv/libmv/simple_pipeline/rigid_registration.cc new file mode 100644 index 00000000000..f7cb1e66e7d --- /dev/null +++ b/extern/libmv/libmv/simple_pipeline/rigid_registration.cc @@ -0,0 +1,182 @@ +// Copyright (c) 2012 libmv authors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +#include "libmv/simple_pipeline/rigid_registration.h" +#include "libmv/numeric/levenberg_marquardt.h" + +namespace libmv { + +template<class RigidTransformation> +struct RigidRegistrationCostFunction { + public: + typedef Vec FMatrixType; + typedef RigidTransformation XMatrixType; + + RigidRegistrationCostFunction(const vector<Vec3> &reference_points, + const vector<Vec3> &points): + reference_points_(reference_points), + points_(points) {} + + Vec CalculateResiduals(const Mat3 &R, + const Vec3 &S, + const Vec3 &t) const { + Vec residuals(points_.size()); + residuals.setZero(); + + // Convert scale vector to matrix + Mat3 SMat = Mat3::Identity(); + SMat(0, 0) *= S(0); + SMat(1, 1) *= S(1); + SMat(2, 2) *= S(2); + + for (int i = 0; i < points_.size(); i++) { + Vec3 transformed_point = R * SMat * points_[i] + t; + + double norm = (transformed_point - reference_points_[i]).norm(); + + residuals(i) = norm * norm; + } + + return residuals; + } + + Vec operator()(const Vec9 &RSt) const { + Mat3 R = RotationFromEulerVector(RSt.head<3>()); + Vec3 S = RSt.segment<3>(3); + Vec3 t = RSt.tail<3>(); + + return CalculateResiduals(R, S, t); + } + + Vec operator()(const Vec3 &euler) const { + Mat3 R = RotationFromEulerVector(euler); + + return CalculateResiduals(R, Vec3(1.0, 1.0, 1.0), Vec3::Zero()); + } + + Vec operator()(const Vec6 &Rt) const { + Mat3 R = RotationFromEulerVector(Rt.head<3>()); + Vec3 t = Rt.tail<3>(); + + return CalculateResiduals(R, Vec3(1.0, 1.0, 1.0), t); + } + + private: + vector<Vec3> reference_points_; + vector<Vec3> points_; +}; + +static double RigidRegistrationError(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + const Mat3 &R, + const Vec3 &S, + const Vec3 &t) { + double error = 0.0; + + Mat3 SMat = Mat3::Identity(); + SMat(0, 0) *= S(0); + SMat(1, 1) *= S(1); + SMat(2, 2) *= S(2); + + for (int i = 0; i < points.size(); i++) { + Vec3 new_point = R * SMat * points[i] + t; + + double norm = (new_point - reference_points[i]).norm(); + error += norm * norm; + } + error /= points.size(); + + return error; +} + +double RigidRegistration(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + Mat3 &R, + Vec3 &S, + Vec3 &t) { + typedef LevenbergMarquardt<RigidRegistrationCostFunction <Vec9> > Solver; + + RigidRegistrationCostFunction<Vec9> rigidregistration_cost(reference_points, points); + Solver solver(rigidregistration_cost); + + Vec9 RSt = Vec9::Zero(); + + RSt(3) = RSt(4) = RSt(5) = 1.0; + + Solver::SolverParameters params; + /*Solver::Results results = */ solver.minimize(params, &RSt); + /* TODO(sergey): better error handling here */ + + LG << "Rigid registration completed, rotation is:" << RSt.head<3>().transpose() + << ", scale is " << RSt.segment<3>(3).transpose() + << ", translation is " << RSt.tail<3>().transpose(); + + // Decompose individual rotation and translation + R = RotationFromEulerVector(RSt.head<3>()); + S = RSt.segment<3>(3); + t = RSt.tail<3>(); + + return RigidRegistrationError(reference_points, points, R, S, t); +} + +double RigidRegistration(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + Mat3 &R, + Vec3 &t) { + typedef LevenbergMarquardt<RigidRegistrationCostFunction <Vec6> > Solver; + + RigidRegistrationCostFunction<Vec6> rigidregistration_cost(reference_points, points); + Solver solver(rigidregistration_cost); + + Vec6 Rt = Vec6::Zero(); + Solver::SolverParameters params; + /*Solver::Results results = */solver.minimize(params, &Rt); + /* TODO(sergey): better error handling here */ + + LG << "Rigid registration completed, rotation is:" << Rt.head<3>().transpose() + << ", translation is " << Rt.tail<3>().transpose(); + + R = RotationFromEulerVector(Rt.head<3>()); + t = Rt.tail<3>(); + + return RigidRegistrationError(reference_points, points, R, Vec3(1.0, 1.0, 1.0), t); +} + +double RigidRegistration(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + Mat3 &R) { + typedef LevenbergMarquardt<RigidRegistrationCostFunction <Vec3> > Solver; + + RigidRegistrationCostFunction<Vec3> rigidregistration_cost(reference_points, points); + Solver solver(rigidregistration_cost); + + Vec3 euler = Vec3::Zero(); + Solver::SolverParameters params; + /*Solver::Results results = */solver.minimize(params, &euler); + /* TODO(sergey): better error handling here */ + + LG << "Rigid registration completed, rotation is:" << euler.transpose(); + + R = RotationFromEulerVector(euler); + + return RigidRegistrationError(reference_points, points, R, Vec3(1.0, 1.0, 1.0), Vec3::Zero()); +} + +} // namespace libmv diff --git a/extern/libmv/libmv/simple_pipeline/rigid_registration.h b/extern/libmv/libmv/simple_pipeline/rigid_registration.h new file mode 100644 index 00000000000..21ea57af507 --- /dev/null +++ b/extern/libmv/libmv/simple_pipeline/rigid_registration.h @@ -0,0 +1,68 @@ +// Copyright (c) 2012 libmv authors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +#ifndef LIBMV_SIMPLE_PIPELINE_RIGID_REGISTRATION_H_ +#define LIBMV_SIMPLE_PIPELINE_RIGID_REGISTRATION_H_ + +#include "libmv/base/vector.h" +#include "libmv/numeric/numeric.h" + +namespace libmv { + +/*! + Searched for an affine transformation of rigid 3D object defined by it's + vertices positions from it's current state called points to it's desired + state called reference points. + + Returns rotation matrix, per-component scale vector and translation which + transforms points to the mot close state to reference_points. + + Return value is an average squared distance between reference state + and transformed one. + + Minimzation of distance between point pairs is used to register such a + rigid transformation and algorithm assumes that pairs of points are + defined by point's index in a vector, so points with the same index + belongs to the same pair. + */ +double RigidRegistration(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + Mat3 &R, + Vec3 &S, + Vec3 &t); + +/*! + * Same as RigidRegistration but provides registration of rotation and translation only + */ +double RigidRegistration(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + Mat3 &R, + Vec3 &t); + +/*! + * Same as RigidRegistration but provides registration of rotation only + */ +double RigidRegistration(const vector<Vec3> &reference_points, + const vector<Vec3> &points, + Mat3 &R); + +} // namespace libmv + +#endif // LIBMV_SIMPLE_PIPELINE_RIGID_REGISTRATION_H_ diff --git a/extern/libmv/libmv/tracking/brute_region_tracker.cc b/extern/libmv/libmv/tracking/brute_region_tracker.cc index a416710ad2b..af7f673472e 100644 --- a/extern/libmv/libmv/tracking/brute_region_tracker.cc +++ b/extern/libmv/libmv/tracking/brute_region_tracker.cc @@ -44,6 +44,7 @@ #include "libmv/image/image.h" #include "libmv/image/convolve.h" +#include "libmv/image/correlation.h" #include "libmv/image/sample.h" #include "libmv/logging/logging.h" @@ -332,6 +333,29 @@ bool BruteRegionTracker::Track(const FloatImage &image1, if (best_sad != INT_MAX) { *x2 = best_j + half_window_size; *y2 = best_i + half_window_size; + + if (minimum_correlation > 0) { + Array3Df image_and_gradient1_sampled, image_and_gradient2_sampled; + + SamplePattern(image_and_gradient1, x1, y1, half_window_size, 3, + &image_and_gradient1_sampled); + SamplePattern(image_and_gradient2, *x2, *y2, half_window_size, 3, + &image_and_gradient2_sampled); + + // Compute the Pearson product-moment correlation coefficient to check + // for sanity. + double correlation = PearsonProductMomentCorrelation(image_and_gradient1_sampled, + image_and_gradient2_sampled, + pattern_width); + LG << "Final correlation: " << correlation; + + if (correlation < minimum_correlation) { + LG << "Correlation " << correlation << " greater than " + << minimum_correlation << "; bailing."; + return false; + } + } + return true; } return false; diff --git a/extern/libmv/libmv/tracking/brute_region_tracker.h b/extern/libmv/libmv/tracking/brute_region_tracker.h index 7a9b06d8a31..8ff0c1b7965 100644 --- a/extern/libmv/libmv/tracking/brute_region_tracker.h +++ b/extern/libmv/libmv/tracking/brute_region_tracker.h @@ -27,7 +27,9 @@ namespace libmv { struct BruteRegionTracker : public RegionTracker { - BruteRegionTracker() : half_window_size(4) {} + BruteRegionTracker() + : half_window_size(4), + minimum_correlation(0.78) {} virtual ~BruteRegionTracker() {} @@ -39,6 +41,7 @@ struct BruteRegionTracker : public RegionTracker { // No point in creating getters or setters. int half_window_size; + double minimum_correlation; }; } // namespace libmv diff --git a/extern/libmv/libmv/tracking/esm_region_tracker.cc b/extern/libmv/libmv/tracking/esm_region_tracker.cc index df9c89a46d4..e0b85f19943 100644 --- a/extern/libmv/libmv/tracking/esm_region_tracker.cc +++ b/extern/libmv/libmv/tracking/esm_region_tracker.cc @@ -26,6 +26,7 @@ #include "libmv/logging/logging.h" #include "libmv/image/image.h" #include "libmv/image/convolve.h" +#include "libmv/image/correlation.h" #include "libmv/image/sample.h" #include "libmv/numeric/numeric.h" @@ -55,24 +56,6 @@ static bool RegionIsInBounds(const FloatImage &image1, return true; } -// Sample a region centered at x,y in image with size extending by half_width -// from x,y. Channels specifies the number of channels to sample from. -static void SamplePattern(const FloatImage &image, - double x, double y, - int half_width, - int channels, - FloatImage *sampled) { - sampled->Resize(2 * half_width + 1, 2 * half_width + 1, channels); - for (int r = -half_width; r <= half_width; ++r) { - for (int c = -half_width; c <= half_width; ++c) { - for (int i = 0; i < channels; ++i) { - (*sampled)(r + half_width, c + half_width, i) = - SampleLinear(image, y + r, x + c, i); - } - } - } -} - // Estimate "reasonable" error by computing autocorrelation for a small shift. // TODO(keir): Add a facility for static double EstimateReasonableError(const FloatImage &image, @@ -276,22 +259,9 @@ bool EsmRegionTracker::Track(const FloatImage &image1, if (d.squaredNorm() < min_update_squared_distance) { // Compute the Pearson product-moment correlation coefficient to check // for sanity. - // TODO(keir): Put this somewhere smarter. - double sX=0,sY=0,sXX=0,sYY=0,sXY=0; - for (int r = 0; r < width; ++r) { - for (int c = 0; c < width; ++c) { - double x = image_and_gradient1_sampled(r, c, 0); - double y = image_and_gradient2_sampled[new_image](r, c, 0); - sX += x; - sY += y; - sXX += x*x; - sYY += y*y; - sXY += x*y; - } - } - double N = width*width; - sX /= N, sY /= N, sXX /= N, sYY /= N, sXY /= N; - double correlation = (sXY-sX*sY)/sqrt(double((sXX-sX*sX)*(sYY-sY*sY))); + double correlation = PearsonProductMomentCorrelation(image_and_gradient1_sampled, + image_and_gradient2_sampled[new_image], + width); LG << "Final correlation: " << correlation; if (correlation < minimum_correlation) { diff --git a/extern/libmv/libmv/tracking/lmicklt_region_tracker.cc b/extern/libmv/libmv/tracking/lmicklt_region_tracker.cc index c06a1d3302c..581e984b569 100644 --- a/extern/libmv/libmv/tracking/lmicklt_region_tracker.cc +++ b/extern/libmv/libmv/tracking/lmicklt_region_tracker.cc @@ -52,24 +52,6 @@ static bool RegionIsInBounds(const FloatImage &image1, return true; } -// Sample a region centered at x,y in image with size extending by half_width -// from x,y. Channels specifies the number of channels to sample from. -static void SamplePattern(const FloatImage &image, - double x, double y, - int half_width, - int channels, - FloatImage *sampled) { - sampled->Resize(2 * half_width + 1, 2 * half_width + 1, channels); - for (int r = -half_width; r <= half_width; ++r) { - for (int c = -half_width; c <= half_width; ++c) { - for (int i = 0; i < channels; ++i) { - (*sampled)(r + half_width, c + half_width, i) = - SampleLinear(image, y + r, x + c, i); - } - } - } -} - // Estimate "reasonable" error by computing autocorrelation for a small shift. static double EstimateReasonableError(const FloatImage &image, double x, double y, diff --git a/extern/libmv/libmv/tracking/sad.cc b/extern/libmv/libmv/tracking/sad.cc deleted file mode 100644 index 0876ef2fe73..00000000000 --- a/extern/libmv/libmv/tracking/sad.cc +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2011 libmv authors. -** -** Permission is hereby granted, free of charge, to any person obtaining a copy -** of this software and associated documentation files (the "Software"), to -** deal in the Software without restriction, including without limitation the -** rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -** sell copies of the Software, and to permit persons to whom the Software is -** furnished to do so, subject to the following conditions: -** -** The above copyright notice and this permission notice shall be included in -** all copies or substantial portions of the Software. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -** IN THE SOFTWARE. -** -****************************************************************************/ - -#include "libmv/tracking/sad.h" -#include <stdlib.h> -#include <math.h> -#include <stdio.h> - -namespace libmv { - -void LaplaceFilter(ubyte* src, ubyte* dst, int width, int height, int strength) { - for(int y=1; y<height-1; y++) for(int x=1; x<width-1; x++) { - const ubyte* s = &src[y*width+x]; - int l = 128 + - s[-width-1] + s[-width] + s[-width+1] + - s[1] - 8*s[0] + s[1] + - s[ width-1] + s[ width] + s[ width+1] ; - int d = ((256-strength)*s[0] + strength*l) / 256; - if(d < 0) d=0; - if(d > 255) d=255; - dst[y*width+x] = d; - } -} - -struct vec2 { - float x,y; - inline vec2(float x, float y):x(x),y(y){} -}; -inline vec2 operator*(mat32 m, vec2 v) { - return vec2(v.x*m(0,0)+v.y*m(0,1)+m(0,2),v.x*m(1,0)+v.y*m(1,1)+m(1,2)); -} - -//! fixed point bilinear sample with precision k -template <int k> inline int sample(const ubyte* image,int stride, int x, int y, int u, int v) { - const ubyte* s = &image[y*stride+x]; - return ((s[ 0] * (k-u) + s[ 1] * u) * (k-v) - + (s[stride] * (k-u) + s[stride+1] * u) * ( v) ) / (k*k); -} - -#ifdef __SSE__ -#include <xmmintrin.h> -int lround(float x) { return _mm_cvtss_si32(_mm_set_ss(x)); } -#elif defined(_MSC_VER) -int lround(float x) { return x+0.5; } -#endif - -//TODO(MatthiasF): SSE optimization -void SamplePattern(ubyte* image, int stride, mat32 warp, ubyte* pattern, int size) { - const int k = 256; - for (int i = 0; i < size; i++) for (int j = 0; j < size; j++) { - vec2 p = warp*vec2(j-size/2,i-size/2); - int fx = lround(p.x*k), fy = lround(p.y*k); - int ix = fx/k, iy = fy/k; - int u = fx%k, v = fy%k; - pattern[i*size+j] = sample<k>(image,stride,ix,iy,u,v); - } -} - -#ifdef __SSE2__ -#include <emmintrin.h> - static uint SAD(/*const*/ ubyte* pattern, /*const*/ ubyte* image, int stride, int size) { - uint sad = 0; - __m128i a = _mm_setzero_si128(); - - for(int i = 0; i < size; i++) { - int j = 0; - - for(j = 0; j < size/16; j++) { - if((i*size/16+j) % 32 == 0) { - sad += _mm_extract_epi16(a,0) + _mm_extract_epi16(a,4); - a = _mm_setzero_si128(); - } - - a = _mm_adds_epu16(a, _mm_sad_epu8( _mm_loadu_si128((__m128i*)(pattern+i*size+j*16)), - _mm_loadu_si128((__m128i*)(image+i*stride+j*16)))); - } - - for(j = j*16; j < size; j++) { - sad += abs((int)pattern[i*size+j] - image[i*stride+j]); - } - } - - sad += _mm_extract_epi16(a,0) + _mm_extract_epi16(a,4); - - return sad; -} -#else -static uint SAD(const ubyte* pattern, const ubyte* image, int stride, int size) { - uint sad=0; - for(int i = 0; i < size; i++) { - for(int j = 0; j < size; j++) { - sad += abs((int)pattern[i*size+j] - image[i*stride+j]); - } - } - return sad; -} -#endif - -float sq(float x) { return x*x; } -float Track(ubyte* reference, ubyte* warped, int size, ubyte* image, int stride, int w, int h, mat32* warp, float areaPenalty, float conditionPenalty) { - mat32 m=*warp; - uint min=-1; - - // exhaustive search integer pixel translation - int ix = m(0,2), iy = m(1,2); - for(int y = size/2; y < h-size/2; y++) { - for(int x = size/2; x < w-size/2; x++) { - m(0,2) = x, m(1,2) = y; - uint sad = SAD(warped,&image[(y-size/2)*stride+(x-size/2)],stride,size); - // TODO: using chroma could help disambiguate some cases - if(sad < min) { - min = sad; - ix = x, iy = y; - } - } - } - m(0,2) = ix, m(1,2) = iy; - min=-1; //reset score since direct warped search match too well (but the wrong pattern). - - // 6D coordinate descent to find affine transform - ubyte* match = new ubyte[size*size]; - float step = 0.5; - for(int p = 0; p < 8; p++) { //foreach precision level - for(int i = 0; i < 2; i++) { // iterate twice per precision level - //TODO: other sweep pattern might converge better - for(int d=0; d < 6; d++) { // iterate dimension sequentially (cyclic descent) - for(float e = -step; e <= step; e+=step) { //solve subproblem (evaluate only along one coordinate) - mat32 t = m; - t.data[d] += e; - //TODO: better performance would also allow a more exhaustive search - SamplePattern(image,stride,t,match,size); - uint sad = SAD(reference,match,size,size); - // regularization: keep constant area and good condition - float area = t(0,0)*t(1,1)-t(0,1)*t(1,0); - float x = sq(t(0,0))+sq(t(0,1)), y = sq(t(1,0))+sq(t(1,1)); - float condition = x>y ? x/y : y/x; - sad += size*size*( areaPenalty*sq(area-1) + conditionPenalty*sq(condition-1) ); - if(sad < min) { - min = sad; - m = t; - } - } - } - } - step /= 2; - } - *warp = m; - - // Compute Pearson product-moment correlation coefficient - uint sX=0,sY=0,sXX=0,sYY=0,sXY=0; - SamplePattern(image,stride,m,match,size); - SAD(reference,match,size,size); - for(int i = 0; i < size; i++) { - for(int j = 0; j < size; j++) { - int x = reference[i*size+j]; - int y = match[i*size+j]; - sX += x; - sY += y; - sXX += x*x; - sYY += y*y; - sXY += x*y; - } - } - delete[] match; - const int N = size*size; - sX /= N, sY /= N, sXX /= N, sYY /= N, sXY /= N; - return (sXY-sX*sY)/sqrt(double((sXX-sX*sX)*(sYY-sY*sY))); -} - -} // namespace libmv diff --git a/extern/libmv/libmv/tracking/sad.h b/extern/libmv/libmv/tracking/sad.h deleted file mode 100644 index 9fe323b74c4..00000000000 --- a/extern/libmv/libmv/tracking/sad.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (c) 2011 libmv authors. -** -** Permission is hereby granted, free of charge, to any person obtaining a copy -** of this software and associated documentation files (the "Software"), to -** deal in the Software without restriction, including without limitation the -** rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -** sell copies of the Software, and to permit persons to whom the Software is -** furnished to do so, subject to the following conditions: -** -** The above copyright notice and this permission notice shall be included in -** all copies or substantial portions of the Software. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -** IN THE SOFTWARE. -** -****************************************************************************/ - -#ifndef LIBMV_TRACKING_SAD_H_ -#define LIBMV_TRACKING_SAD_H_ - -#ifdef __cplusplus -namespace libmv { -#endif - -typedef unsigned char ubyte; -typedef unsigned int uint; - -/*! - Convolve \a src into \a dst with the discrete laplacian operator. - - \a src and \a dst should be \a width x \a height images. - \a strength is an interpolation coefficient (0-256) between original image and the laplacian. - - \note Make sure the search region is filtered with the same strength as the pattern. -*/ -void LaplaceFilter(ubyte* src, ubyte* dst, int width, int height, int strength); - -/// Affine transformation matrix in column major order. -struct mat32 { - float data[3*2]; -#ifdef __cplusplus - inline mat32(int d=1) { for(int i=0;i<3*2;i++) data[i]=0; if(d!=0) for(int i=0;i<2;i++) m(i,i)=d; } - inline float m(int i, int j) const { return data[j*2+i]; } - inline float& m(int i, int j) { return data[j*2+i]; } - inline float operator()(int i, int j) const { return m(i,j); } - inline float& operator()(int i, int j) { return m(i,j); } - inline operator bool() const { for (int i=0; i<3*2; i++) if(data[i]!=0) return true; return false; } -#endif -}; - -/*! - Sample \a pattern from \a image. - - \a warp is the transformation to apply to \a image when sampling the \a pattern. -*/ -void SamplePattern(ubyte* image, int stride, mat32 warp, ubyte* pattern, int size); - -/*! - Track \a pattern in \a image. - - This template matcher computes the - \link http://en.wikipedia.org/wiki/Sum_of_absolute_differences Sum of Absolute Differences (SAD) \endlink - for each integer pixel position in the search region and then iteratively - refine subpixel position using a square search. - A similar method is used for motion estimation in video encoders. - - \a reference is the pattern to track. - \a warped is a warped version of reference for fast unsampled integer search. - Best is to directly extract an already warped pattern from previous frame. - The \a size of the patterns should be aligned to 16. - \a image is a reference to the region to search. - \a stride is size of \a image lines. - - On input, \a warp is the predicted affine transformation (e.g from previous frame) - On return, \a warp is the affine transformation which best match the reference \a pattern - - \a areaPenalty and conditionPenalty control the regularization and need to be tweaked depending on the motion. - Setting them to 0 will allow any transformation (including unrealistic distortions and scaling). - Good values are between 0-32. 16 can be used as a realistic default. - areaPenalty control scaling (decrease to allow pull/zoom, increase to allow only 2D rotation). - a large conditionPenalty avoid a large ratio between the largest and smallest axices. - It need to be decreased for non-2D rotation (when pattern appears to scale along an axis). - - \return Pearson product-moment correlation coefficient between reference and matched pattern. - This measure of the linear dependence between the patterns - ranges from −1 (negative correlation) to 1 (positive correlation). - A value of 0 implies that there is no linear correlation between the variables. - - \note To track affine features: - - Sample reference pattern using estimated (e.g previous frame) warp. - - - \note \a stride allow you to reference your search region instead of copying. - \note For a 16x speedup, compile this tracker with SSE2 support. -*/ -float Track(ubyte* reference, ubyte* warped, int size, ubyte* image, int stride, int width, int height, mat32* warp, - float areaPenalty, float conditionPenalty); - -#ifdef __cplusplus -} // namespace libmv -#endif - -#endif // LIBMV_TRACKING_SAD_H_ diff --git a/extern/libmv/patches/bundle_tweaks.patch b/extern/libmv/patches/bundle_tweaks.patch deleted file mode 100644 index aebc257f7f9..00000000000 --- a/extern/libmv/patches/bundle_tweaks.patch +++ /dev/null @@ -1,152 +0,0 @@ -diff --git a/src/libmv/logging/logging.h b/src/libmv/logging/logging.h -index 067da52..af86c4b 100644 ---- a/src/libmv/logging/logging.h -+++ b/src/libmv/logging/logging.h -@@ -21,7 +21,7 @@ - #ifndef LIBMV_LOGGING_LOGGING_H - #define LIBMV_LOGGING_LOGGING_H - --#include "third_party/glog/src/glog/logging.h" -+#include "glog/logging.h" - - #define LG LOG(INFO) - #define V0 LOG(INFO) -diff --git a/src/libmv/simple_pipeline/pipeline.cc b/src/libmv/simple_pipeline/pipeline.cc -index 2459d05..2e4e5a6 100644 ---- a/src/libmv/simple_pipeline/pipeline.cc -+++ b/src/libmv/simple_pipeline/pipeline.cc -@@ -280,25 +280,6 @@ double InternalReprojectionError(const Tracks &image_tracks, - double ex = reprojected_marker.x - markers[i].x; - double ey = reprojected_marker.y - markers[i].y; - -- const int N = 100; -- char line[N]; -- snprintf(line, N, -- "image %-3d track %-3d " -- "x %7.1f y %7.1f " -- "rx %7.1f ry %7.1f " -- "ex %7.1f ey %7.1f" -- " e %7.1f", -- markers[i].image, -- markers[i].track, -- markers[i].x, -- markers[i].y, -- reprojected_marker.x, -- reprojected_marker.y, -- ex, -- ey, -- sqrt(ex*ex + ey*ey)); -- LG << line; -- - total_error += sqrt(ex*ex + ey*ey); - } - LG << "Skipped " << num_skipped << " markers."; -diff --git a/src/third_party/glog/src/glog/logging.h b/src/third_party/glog/src/glog/logging.h -index 57615ef..a58d478 100644 ---- a/src/third_party/glog/src/glog/logging.h -+++ b/src/third_party/glog/src/glog/logging.h -@@ -33,6 +33,7 @@ - // Pretty much everybody needs to #include this file so that they can - // log various happenings. - // -+ - #ifndef _LOGGING_H_ - #define _LOGGING_H_ - -diff --git a/src/third_party/glog/src/logging.cc b/src/third_party/glog/src/logging.cc -index 868898f..1bb3867 100644 ---- a/src/third_party/glog/src/logging.cc -+++ b/src/third_party/glog/src/logging.cc -@@ -58,8 +58,8 @@ - #include <errno.h> // for errno - #include <sstream> - #include "base/commandlineflags.h" // to get the program name --#include "glog/logging.h" --#include "glog/raw_logging.h" -+#include <glog/logging.h> -+#include <glog/raw_logging.h> - #include "base/googleinit.h" - - #ifdef HAVE_STACKTRACE -@@ -1232,7 +1232,9 @@ void LogMessage::RecordCrashReason( - } - - static void logging_fail() { --#if defined(_DEBUG) && defined(_MSC_VER) -+// #if defined(_DEBUG) && defined(_MSC_VER) -+// doesn't work for my laptop (sergey) -+#if 0 - // When debugging on windows, avoid the obnoxious dialog and make - // it possible to continue past a LOG(FATAL) in the debugger - _asm int 3 -diff --git a/src/third_party/glog/src/raw_logging.cc b/src/third_party/glog/src/raw_logging.cc -index 50c6a71..b179a1e 100644 ---- a/src/third_party/glog/src/raw_logging.cc -+++ b/src/third_party/glog/src/raw_logging.cc -@@ -42,8 +42,8 @@ - #include <fcntl.h> // for open() - #include <time.h> - #include "config.h" --#include "glog/logging.h" // To pick up flag settings etc. --#include "glog/raw_logging.h" -+#include <glog/logging.h> // To pick up flag settings etc. -+#include <glog/raw_logging.h> - #include "base/commandlineflags.h" - - #ifdef HAVE_STACKTRACE -diff --git a/src/third_party/glog/src/utilities.h b/src/third_party/glog/src/utilities.h -index c4ae256..5c841a0 100644 ---- a/src/third_party/glog/src/utilities.h -+++ b/src/third_party/glog/src/utilities.h -@@ -79,7 +79,7 @@ - #endif - - #include "config.h" --#include "glog/logging.h" -+#include <glog/logging.h> - - // There are three different ways we can try to get the stack trace: - // -diff --git a/src/third_party/glog/src/vlog_is_on.cc b/src/third_party/glog/src/vlog_is_on.cc -index ee0e412..ed88514 100644 ---- a/src/third_party/glog/src/vlog_is_on.cc -+++ b/src/third_party/glog/src/vlog_is_on.cc -@@ -40,8 +40,8 @@ - #include <cstdio> - #include <string> - #include "base/commandlineflags.h" --#include "glog/logging.h" --#include "glog/raw_logging.h" -+#include <glog/logging.h> -+#include <glog/raw_logging.h> - #include "base/googleinit.h" - - // glog doesn't have annotation -diff --git a/src/third_party/glog/src/windows/config.h b/src/third_party/glog/src/windows/config.h -index 114762e..682a1b9 100755 ---- a/src/third_party/glog/src/windows/config.h -+++ b/src/third_party/glog/src/windows/config.h -@@ -19,7 +19,7 @@ - #undef HAVE_LIBUNWIND_H - - /* define if you have google gflags library */ --#undef HAVE_LIB_GFLAGS -+#define HAVE_LIB_GFLAGS 1 - - /* define if you have libunwind */ - #undef HAVE_LIB_UNWIND -diff --git a/src/third_party/glog/src/windows/glog/logging.h b/src/third_party/glog/src/windows/glog/logging.h -index 4257375..2f41681 100755 ---- a/src/third_party/glog/src/windows/glog/logging.h -+++ b/src/third_party/glog/src/windows/glog/logging.h -@@ -82,8 +82,8 @@ - #include <inttypes.h> // a third place for uint16_t or u_int16_t - #endif - --#if 0 --#include <gflags/gflags.h> -+#if 1 -+#include "third_party/gflags/gflags.h" - #endif - - #ifdef __MINGW32__ diff --git a/extern/libmv/patches/series b/extern/libmv/patches/series index ca671122a61..1db7983fdd0 100644 --- a/extern/libmv/patches/series +++ b/extern/libmv/patches/series @@ -1,2 +1 @@ v3d_verbosity.patch -bundle_tweaks.patch diff --git a/extern/libmv/third_party/gflags/AUTHORS b/extern/libmv/third_party/gflags/AUTHORS new file mode 100644 index 00000000000..887918bd00e --- /dev/null +++ b/extern/libmv/third_party/gflags/AUTHORS @@ -0,0 +1,2 @@ +google-gflags@googlegroups.com + diff --git a/extern/libmv/third_party/gflags/COPYING b/extern/libmv/third_party/gflags/COPYING new file mode 100644 index 00000000000..d15b0c24134 --- /dev/null +++ b/extern/libmv/third_party/gflags/COPYING @@ -0,0 +1,28 @@ +Copyright (c) 2006, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/extern/libmv/third_party/gflags/ChangeLog b/extern/libmv/third_party/gflags/ChangeLog new file mode 100644 index 00000000000..f9ef9350984 --- /dev/null +++ b/extern/libmv/third_party/gflags/ChangeLog @@ -0,0 +1,195 @@ +Wed Jan 25 15:09:14 2012 Google Inc. <google-gflags@googlegroups.com> + + * gflags: version 2.0 + * Changed the 'official' gflags email in setup.py/etc + * Renamed google-gflags.sln to gflags.sln + * Changed copyright text to reflect Google's relinquished ownership + +Tue Dec 20 19:48:57 2011 Google Inc. <opensource@google.com> + + * google-gflags: version 1.7 + * Add CommandLineFlagInfo::flag_ptr pointing to current storage (musji) + * PORTING: flush after writing to stderr, needed on cygwin + * PORTING: Clean up the GFLAGS_DLL_DECL stuff better + * Fix a bug in StringPrintf() that affected large strings (csilvers) + * Die at configure-time when g++ isn't installed + +Fri Jul 29 19:05:21 2011 Google Inc. <opensource@google.com> + + * google-gflags: version 1.6 + * BUGFIX: Fix a bug where we were leaving out a required $(top_srcdir) + * Fix definition of clstring (jyrki) + * Split up flag declares into its own file (jyrki) + * Add --version support (csilvers) + * Update the README for gflags with static libs + * Update acx_pthread.m4 for nostdlib + * Change ReparseCommandLineFlags to return void (csilvers) + * Some doc typofixes and example augmentation (various) + +Mon Jan 24 16:11:35 2011 Google Inc. <opensource@google.com> + + * google-gflags: version 1.5 + * Better reporting of current vs default value (handler) + * Add API for cleaning up of memory at program-exit (jmarantz) + * Fix macros to work inside namespaces (csilvers) + * Use our own string typedef in case string is redefined (csilvers) + * Updated to autoconf 2.65 + +Wed Oct 13 17:40:12 2010 Google Inc. <opensource@google.com> + + * google-gflags: version 1.4 + * Add a check to prevent passing 0 to DEFINE_string (jorg) + * Reduce compile (.o) size (jyrki) + * Some small changes to quiet debug compiles (alexk) + * PORTING: better support static linking on windows (csilvers) + * DOCUMENTATION: change default values, use validators, etc. + * Update the NEWS file to be non-empty + * Add pkg-config (.pc) files for libgflags and libgflags_nothreads + +Mon Jan 4 18:09:30 2010 Google Inc. <opensource@google.com> + + * google-gflags: version 1.3 + * PORTABILITY: can now build and run tests under MSVC (csilvers) + * Remove the python gflags code, which is now its own package (tansell) + * Clarify that "last flag wins" in the docs (csilvers) + * Comment danger of using GetAllFlags in validators (wojtekm) + * PORTABILITY: Some fixes necessary for c++0x (mboerger) + * Makefile fix: $(srcdir) -> $(top_srcdir) in one place (csilvres) + * INSTALL: autotools to autoconf v2.64 + automake v1.11 (csilvers) + +Thu Sep 10 12:53:04 2009 Google Inc. <opensource@google.com> + + * google-gflags: version 1.2 + * PORTABILITY: can now build and run tests under mingw (csilvers) + * Using a string arg for a bool flag is a compile-time error (rbayardo) + * Add --helpxml to gflags.py (salcianu) + * Protect against a hypothetical global d'tor mutex problem (csilvers) + * BUGFIX: can now define a flag after 'using namespace google' (hamaji) + +Tue Apr 14 12:35:25 2009 Google Inc. <opensource@google.com> + + * google-gflags: version 1.1 + * Add both foo and nofoo for boolean flags, with --undefok (andychu) + * Better document how validators work (wojtekm) + * Improve binary-detection for bash-completion (mtamsky) + * Python: Add a concept of "key flags", used with --help (salcianu) + * Python: Robustify flag_values (salcianu) + * Python: Add a new DEFINE_bool alias (keir, andrewliu) + * Python: Do module introspection based on module name (dsturtevant) + * Fix autoconf a bit better, especially on windows and solaris (ajenjo) + * BUG FIX: gflags_nothreads was linking against the wrong lib (ajenjo) + * BUG FIX: threads-detection failed on FreeBSD; replace it (ajenjo) + * PORTABILITY: Quiet an internal compiler error with SUSE 10 (csilvers) + * PORTABILITY: Update deb.sh for more recenty debuilds (csilvers) + * PORTABILITY: #include more headers to satify new gcc's (csilvers) + * INSTALL: Updated to autoconf 2.61 and libtool 1.5.26 (csilvers) + +Fri Oct 3 15:16:46 2008 Google Inc. <opensource@google.com> + + * google-gflags: version 1.0 + * Add a missing newline to an error string (bcmills) + * (otherwise exactly the same as gflags 1.0rc2) + +Thu Sep 18 12:58:05 2008 Google Inc. <opensource@google.com> + + * google-gflags: version 1.0rc2 + * Report current flag values in --helpxml (hdn) + * Fix compilation troubles with gcc 4.3.3 (simonb) + * BUG FIX: I was missing a std:: in DECLARE_string (csilvers) + * BUG FIX: Clarify in docs how to specify --bool flags (csilvers) + * BUG FIX: Fix --helpshort for source files not in a subdir (csilvers) + * BUG FIX: Fix python unittest for 64-bit builds (bcmills) + +Tue Aug 19 16:15:48 2008 + + * google-gflags: version 1.0rc1 + * Move #include files from google/ to gflags/ (csilvers) + * Small optimizations to reduce binary (library) size (jyrki) + * BUGFIX: forgot a std:: in one of the .h files (csilvers) + * Speed up locking by making sure calls are inlined (ajenjo) + * 64-BIT COMPATIBILITY: Use %PRId64 instead of %lld (csilvers) + * PORTABILITY: fix Makefile to work with Cygwin (ajenjo) + * PORTABILITY: fix code to compile under Visual Studio (ajenjo) + * PORTABILITY: fix code to compile under Solaris 10 with CC (csilvers) + +Mon Jul 21 23:01:38 2008 Google Inc. <opensource@google.com> + + * google-gflags: version 0.9 + * Add the ability to validate a command-line flag (csilvers) + * Add completion support for commandline flags in bash (daven) + * Add -W compile flags to Makefile, when using gcc (csilvers) + * Allow helpstring to be NULL (cristianoc) + * Improved documentation of classes in the .cc file (csilvers) + * Fix python bug with AppendFlagValues + shortnames (jjtswan) + * Use bool instead of int for boolean flags in gflags.py (bcmills) + * Simplify the way we declare flags, now more foolproof (csilvers) + * Better error messages when bool flags collide (colohan) + * Only evaluate DEFINE_foo macro args once (csilvers) + +Wed Mar 26 15:20:18 2008 Google Inc. <opensource@google.com> + + * google-gflags: version 0.8 + * Export DescribeOneFlag() in the API + * Add support for automatic line wrapping at 80 cols for gflags.py + * Bugfix: do not treat an isolated "-" the same as an isolated "--" + * Update rpm spec to point to Google Code rather than sourceforge (!) + * Improve documentation (including documenting thread-safety) + * Improve #include hygiene + * Improve testing + +Thu Oct 18 11:33:20 2007 Google Inc. <opensource@google.com> + + * google-gflags: version 0.7 + * Deal even more correctly with libpthread not linked in (csilvers) + * Add STRIP_LOG, an improved DO_NOT_SHOW_COMMANDLINE_HELP (sioffe) + * Be more accurate printing default flag values in --help (dsturtevant) + * Reduce .o file size a bit by using shorter namespace names (jeff) + * Use relative install path, so 'setup.py --home' works (csilvers) + * Notice when a boolean flag has a non-boolean default (bnmouli) + * Broaden --helpshort to match foo-main.cc and foo_main.cc (hendrie) + * Fix "no modules match" message for --helpshort, etc (hendrie) + +Wed Aug 15 07:35:51 2007 Google Inc. <opensource@google.com> + + * google-gflags: version 0.6 + * Deal correctly with case that libpthread is not linked in (csilvers) + * Update Makefile/tests so we pass "make distcheck" (csilvers) + * Document and test that last assignment to a flag wins (wan) + +Tue Jun 12 15:23:42 2007 Google Inc. <opensource@google.com> + + * google-gflags: version 0.5 + * Include all m4 macros in the distribution (csilvers) + * Python: Fix broken data_files field in setup.py (sidlon) + * Python: better string serliaizing and unparsing (abo, csimmons) + * Fix checks for NaN and inf to work with Mac OS X (csilvers) + +Thu Apr 19 15:15:07 2007 Google Inc. <opensource@google.com> + + * google-gflags: version 0.4 + * Remove is_default from GetCommandLineFlagInfo (csilvers) + * Portability fixes: includes, strtoll, gcc4.3 errors (csilvers) + * A few doc typo cleanups (csilvers) + +Wed Mar 28 12:15:56 2007 Google Inc. <opensource@google.com> + + * google-gflags: version 0.3 + * python portability fix: use popen instead of subprocess (csilvers) + * Add is_default to CommandLineFlagInfo (pchien) + * Make docs a bit prettier (csilvers) + * Actually include the python files in the distribution! :-/ (csilvers) + +Mon Jan 22 15:33:06 2007 Google Inc. <opensource@google.com> + + * google-gflags: version 0.2 + * added support for python commandlineflags, as well as c++ + * gflags2man, a script to turn flags into a man page (dchristian) + +Wed Dec 13 12:37:19 2006 Google Inc. <opensource@google.com> + + * google-gflags: initial release: + The gflags package contains a library that implements commandline + flags processing. As such it's a replacement for getopt(). It + has increased flexibility, including built-in support for C++ + types like string, and the ability to define flags in the source + file in which they're used. diff --git a/extern/libmv/third_party/gflags/NEWS b/extern/libmv/third_party/gflags/NEWS new file mode 100644 index 00000000000..ffc0127d91e --- /dev/null +++ b/extern/libmv/third_party/gflags/NEWS @@ -0,0 +1,158 @@ +== 25 January 2012 == + +I've just released gflags 2.0. + +The `google-gflags` project has been renamed to `gflags`. I +(csilvers) am stepping down as maintainer, to be replaced by Andreas +Schuh. Welcome to the team, Andreas! I've seen the energy you have +around gflags and the ideas you have for the project going forward, +and look forward to having you on the team. + +I bumped the major version number up to 2 to reflect the new community +ownership of the project. All the +[http://gflags.googlecode.com/svn/tags/gflags-2.0/ChangeLog changes] +are related to the renaming. There are no functional changes from +gflags 1.7. In particular, I've kept the code in the namespace +`google`, though in a future version it should be renamed to `gflags`. +I've also kept the `/usr/local/include/google/` subdirectory as +synonym of `/usr/local/include/gflags/`, though the former name has +been obsolete for some time now. + + +=== 18 January 2011 === + +The `google-gflags` Google Code page has been renamed to +`gflags`, in preparation for the project being renamed to +`gflags`. In the coming weeks, I'll be stepping down as +maintainer for the gflags project, and as part of that Google is +relinquishing ownership of the project; it will now be entirely +community run. The name change reflects that shift. + + +=== 20 December 2011 === + +I've just released gflags 1.7. This is a minor release; the major +change is that `CommandLineFlagInfo` now exports the address in memory +where the flag is located. There has also been a bugfix involving +very long --help strings, and some other minor +[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.7/ChangeLog changes]. + +=== 29 July 2011 === + +I've just released gflags 1.6. The major new feature in this release +is support for setting version info, so that --version does something +useful. + +One minor change has required bumping the library number: +`ReparseCommandlineFlags` now returns `void` instead of `int` (the int +return value was always meaningless). Though I doubt anyone ever used +this (meaningless) return value, technically it's a change to the ABI +that requires a version bump. A bit sad. + +There's also a procedural change with this release: I've changed the +internal tools used to integrate Google-supplied patches for gflags +into the opensource release. These new tools should result in more +frequent updates with better change descriptions. They will also +result in future `ChangeLog` entries being much more verbose (for better +or for worse). + +See the +[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.6/ChangeLog ChangeLog] +for a full list of changes for this release. + +=== 24 January 2011 === + +I've just released gflags 1.5. This release has only minor changes +from 1.4, including some slightly better reporting in --help, and +an new memory-cleanup function that can help when running gflags-using +libraries under valgrind. The major change is to fix up the macros +(`DEFINE_bool` and the like) to work more reliably inside namespaces. + +If you have not had a problem with these macros, and don't need any of +the other changes described, there is no need to upgrade. See the +[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.5/ChangeLog ChangeLog] +for a full list of changes for this release. + +=== 11 October 2010 === + +I've just released gflags 1.4. This release has only minor changes +from 1.3, including some documentation tweaks and some work to make +the library smaller. If 1.3 is working well for you, there's no +particular reason to upgrade. + +=== 4 January 2010 === + +I've just released gflags 1.3. gflags now compiles under MSVC, and +all tests pass. I *really* never thought non-unix-y Windows folks +would want gflags, but at least some of them do. + +The major news, though, is that I've separated out the python package +into its own library, [http://code.google.com/p/python-gflags python-gflags]. +If you're interested in the Python version of gflags, that's the place to +get it now. + +=== 10 September 2009 == + +I've just released gflags 1.2. The major change from gflags 1.1 is it +now compiles under MinGW (as well as cygwin), and all tests pass. I +never thought Windows folks would want unix-style command-line flags, +since they're so different from the Windows style, but I guess I was +wrong! + +The other changes are minor, such as support for --htmlxml in the +python version of gflags. + +=== 15 April 2009 === + +I've just released gflags 1.1. It has only minor changes fdrom gflags +1.0 (see the +[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.1/ChangeLog ChangeLog] +for details). The major change is that I moved to a new +system for creating .deb and .rpm files. This allows me to create +x86_64 deb and rpm files. + +In the process of moving to this new system, I noticed an +inconsistency: the tar.gz and .rpm files created libraries named +libgflags.so, but the deb file created libgoogle-gflags.so. I have +fixed the deb file to create libraries like the others. I'm no expert +in debian packaging, but I believe this has caused the package name to +change as well. Please let me know (at +[mailto:google-gflags@googlegroups.com +google-gflags@googlegroups.com]) if this causes problems for you -- +especially if you know of a fix! I would be happy to change the deb +packages to add symlinks from the old library name to the new +(libgoogle-gflags.so -> libgflags.so), but that is beyond my knowledge +of how to make .debs. + +If you've tried to install a .rpm or .deb and it doesn't work for you, +let me know. I'm excited to finally have 64-bit package files, but +there may still be some wrinkles in the new system to iron out. + +===1 October 2008=== + +gflags 1.0rc2 was out for a few weeks without any issues, so gflags +1.0 is now released. This is much like gflags 0.9. The major change +is that the .h files have been moved from `/usr/include/google` to +`/usr/include/gflags`. While I have backwards-compatibility +forwarding headeds in place, please rewrite existing code to say +{{{ + #include <gflags/gflags.h> +}}} +instead of +{{{ + #include <google/gflags.h> +}}} + +I've kept the default namespace to google. You can still change with +with the appropriate flag to the configure script (`./configure +--help` to see the flags). If you have feedback as to whether the +default namespace should change to gflags, which would be a +non-backwards-compatible change, send mail to +`google-gflags@googlegroups.com`! + +Version 1.0 also has some neat new features, like support for bash +commandline-completion of help flags. See the +[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.0rc2/ChangeLog +ChangeLog] for more details. + +If I don't hear any bad news for a few weeks, I'll release 1.0-final. diff --git a/extern/libmv/third_party/gflags/README.libmv b/extern/libmv/third_party/gflags/README.libmv index f2bdef6563e..673099ce618 100644 --- a/extern/libmv/third_party/gflags/README.libmv +++ b/extern/libmv/third_party/gflags/README.libmv @@ -1,7 +1,7 @@ Project: Google Flags URL: http://code.google.com/p/google-gflags/ License: New BSD -Upstream version: 1.5 +Upstream version: 2.0 Local modifications: - Flattened the tree and only included files needed for libmv. This involved diff --git a/extern/libmv/third_party/gflags/config.h b/extern/libmv/third_party/gflags/config.h index ca2c1276c44..03ed03ca99b 100644 --- a/extern/libmv/third_party/gflags/config.h +++ b/extern/libmv/third_party/gflags/config.h @@ -15,7 +15,7 @@ #define HAVE_DLFCN_H 1 /* Define to 1 if you have the <fnmatch.h> header file. */ -#undef HAVE_FNMATCH_H +/* #ubdef HAVE_FNMATCH_H 1 */ /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 @@ -29,12 +29,6 @@ /* Define if you have POSIX threads libraries and header files. */ #define HAVE_PTHREAD 1 -/* Define to 1 if you have the `putenv' function. */ -#define HAVE_PUTENV 1 - -/* Define to 1 if you have the `setenv' function. */ -#define HAVE_SETENV 1 - /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 @@ -73,22 +67,19 @@ #define PACKAGE "gflags" /* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "opensource@google.com" +#define PACKAGE_BUGREPORT "google-gflags@googlegroups.com" /* Define to the full name of this package. */ #define PACKAGE_NAME "gflags" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "gflags 1.5" +#define PACKAGE_STRING "gflags 2.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "gflags" -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.5" +#define PACKAGE_VERSION "2.0" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ @@ -101,7 +92,7 @@ #define STL_NAMESPACE std /* Version number of package */ -#define VERSION "1.5" +#define VERSION "2.0" /* Stops putting the code inside the Google namespace */ #define _END_GOOGLE_NAMESPACE_ } diff --git a/extern/libmv/third_party/gflags/gflags.cc b/extern/libmv/third_party/gflags/gflags.cc index 34fe95dac59..4ba2b6f393c 100644 --- a/extern/libmv/third_party/gflags/gflags.cc +++ b/extern/libmv/third_party/gflags/gflags.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Google Inc. +// Copyright (c) 1999, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -28,7 +28,6 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // --- -// Author: Ray Sidney // Revamped and reorganized by Craig Silverstein // // This file contains the implementation of all our command line flags @@ -88,76 +87,35 @@ // other hand, hooks into CommandLineFlagParser. Other API functions // are, similarly, mostly hooks into the functionality described above. -#include "config.h" // This comes first to ensure we define __STDC_FORMAT_MACROS in time. -#ifdef HAVE_INTTYPES_H -#ifndef __STDC_FORMAT_MACROS +#include "config.h" +#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS) # define __STDC_FORMAT_MACROS 1 // gcc requires this to get PRId64, etc. #endif -#include <inttypes.h> -#endif // HAVE_INTTYPES_H -#include <stdio.h> // for snprintf + +#include "gflags/gflags.h" +#include <assert.h> #include <ctype.h> #include <errno.h> -#include <stdio.h> +#ifdef HAVE_FNMATCH_H +# include <fnmatch.h> +#endif #include <stdarg.h> // For va_list and related operations +#include <stdio.h> #include <string.h> -#include <assert.h> -#ifdef HAVE_FNMATCH_H -#include <fnmatch.h> -#endif // HAVE_FNMATCH_H -#include <string> + +#include <algorithm> #include <map> -#include <vector> +#include <string> #include <utility> // for pair<> -#include <algorithm> -#include "gflags.h" +#include <vector> #include "mutex.h" +#include "util.h" #ifndef PATH_SEPARATOR #define PATH_SEPARATOR '/' #endif -// Work properly if either strtoll or strtoq is on this system -#ifdef HAVE_STRTOLL -# define strtoint64 strtoll -# define strtouint64 strtoull -#elif HAVE_STRTOQ -# define strtoint64 strtoq -# define strtouint64 strtouq -#else -// Neither strtoll nor strtoq are defined. I hope strtol works! -# define strtoint64 strtol -# define strtouint64 strtoul -#endif - -// If we have inttypes.h, it will have defined PRId32/etc for us. If -// not, take our best guess. -#ifndef PRId32 -# define PRId32 "d" -#endif -#ifndef PRId64 -# define PRId64 "lld" -#endif -#ifndef PRIu64 -# define PRIu64 "llu" -#endif - -// Windows is missing random bits like strcasecmp, strtoll, strtoull, and -// snprintf in the usual locations. Put them somewhere sensible. -// -// TODO(keir): Get the upstream Windows port and use that instead. -#ifdef _MSC_VER -# define snprintf _snprintf -# undef strtoint64 -# define strtoint64 _strtoi64 -# undef strtouint64 -# define strtouint64 _strtoui64 -# define strcasecmp _stricmp -#endif - -typedef signed char int8; -typedef unsigned char uint8; // Special flags, type 1: the 'recursive' flags. They set another flag's val. DEFINE_string(flagfile, "", @@ -183,20 +141,21 @@ using std::sort; using std::string; using std::vector; +// This is used by the unittest to test error-exit code +void GFLAGS_DLL_DECL (*gflags_exitfunc)(int) = &exit; // from stdlib.h + + // The help message indicating that the commandline flag has been // 'stripped'. It will not show up when doing "-help" and its // variants. The flag is stripped if STRIP_FLAG_HELP is set to 1 -// before including gflags/gflags.h. +// before including base/gflags.h -// This is used by this file, and also in commandlineflags_reporting.cc +// This is used by this file, and also in gflags_reporting.cc const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001"; -// This is used by the unittest to test error-exit code -void GFLAGS_DLL_DECL (*commandlineflags_exitfunc)(int) = &exit; // from stdlib.h - namespace { -// There are also 'reporting' flags, in commandlineflags_reporting.cc. +// There are also 'reporting' flags, in gflags_reporting.cc. static const char kError[] = "ERROR: "; @@ -218,12 +177,14 @@ enum DieWhenReporting { DIE, DO_NOT_DIE }; // Report Error and exit if requested. static void ReportError(DieWhenReporting should_die, const char* format, ...) { + char error_message[255]; va_list ap; va_start(ap, format); - vfprintf(stderr, format, ap); + vsnprintf(error_message, sizeof(error_message), format, ap); va_end(ap); - if (should_die == DIE) - commandlineflags_exitfunc(1); // almost certainly exit() + fprintf(stderr, "%s", error_message); + fflush(stderr); // should be unnecessary, but cygwin's rxvt buffers stderr + if (should_die == DIE) gflags_exitfunc(1); } @@ -317,6 +278,7 @@ bool FlagValue::ParseFrom(const char* value) { if (type_ == FV_BOOL) { const char* kTrue[] = { "1", "t", "true", "y", "yes" }; const char* kFalse[] = { "0", "f", "false", "n", "no" }; + COMPILE_ASSERT(sizeof(kTrue) == sizeof(kFalse), true_false_equal); for (size_t i = 0; i < sizeof(kTrue)/sizeof(*kTrue); ++i) { if (strcasecmp(value, kTrue[i]) == 0) { SET_VALUE_AS(bool, true); @@ -346,7 +308,7 @@ bool FlagValue::ParseFrom(const char* value) { switch (type_) { case FV_INT32: { - const int64 r = strtoint64(value, &end, base); + const int64 r = strto64(value, &end, base); if (errno || end != value + strlen(value)) return false; // bad parse if (static_cast<int32>(r) != r) // worked, but number out of range return false; @@ -354,7 +316,7 @@ bool FlagValue::ParseFrom(const char* value) { return true; } case FV_INT64: { - const int64 r = strtoint64(value, &end, base); + const int64 r = strto64(value, &end, base); if (errno || end != value + strlen(value)) return false; // bad parse SET_VALUE_AS(int64, r); return true; @@ -362,7 +324,7 @@ bool FlagValue::ParseFrom(const char* value) { case FV_UINT64: { while (*value == ' ') value++; if (*value == '-') return false; // negative number - const uint64 r = strtouint64(value, &end, base); + const uint64 r = strtou64(value, &end, base); if (errno || end != value + strlen(value)) return false; // bad parse SET_VALUE_AS(uint64, r); return true; @@ -531,6 +493,7 @@ class CommandLineFlag { string default_value() const { return defvalue_->ToString(); } const char* type_name() const { return defvalue_->TypeName(); } ValidateFnProto validate_function() const { return validate_fn_proto_; } + const void* flag_ptr() const { return current_->value_buffer_; } void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result); @@ -583,7 +546,6 @@ const char* CommandLineFlag::CleanFileName() const { // search full path backwards. // Stop going backwards at kRootDir; and skip by the first slash. static const char kRootDir[] = ""; // can set this to root directory, - // e.g. "myproject" if (sizeof(kRootDir)-1 == 0) // no prefix to strip return filename(); @@ -592,8 +554,7 @@ const char* CommandLineFlag::CleanFileName() const { while ( clean_name > filename() ) { if (*clean_name == PATH_SEPARATOR) { if (strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) { - // ".../myproject/base/logging.cc" ==> "base/logging.cc" - clean_name += sizeof(kRootDir)-1; // past "/myproject/" + clean_name += sizeof(kRootDir)-1; // past root-dir break; } } @@ -614,6 +575,7 @@ void CommandLineFlag::FillCommandLineFlagInfo( UpdateModifiedBit(); result->is_default = !modified_; result->has_validator_fn = validate_function() != NULL; + result->flag_ptr = flag_ptr(); } void CommandLineFlag::UpdateModifiedBit() { @@ -634,6 +596,7 @@ void CommandLineFlag::CopyFrom(const CommandLineFlag& src) { } bool CommandLineFlag::Validate(const FlagValue& value) const { + if (validate_function() == NULL) return true; else @@ -657,10 +620,14 @@ struct StringCmp { // Used by the FlagRegistry map class to compare char*'s } }; + class FlagRegistry { public: - FlagRegistry() { } + FlagRegistry() { + } ~FlagRegistry() { + // Not using STLDeleteElements as that resides in util and this + // class is base. for (FlagMap::iterator p = flags_.begin(), e = flags_.end(); p != e; ++p) { CommandLineFlag* flag = p->second; delete flag; @@ -672,12 +639,12 @@ class FlagRegistry { global_registry_ = NULL; } - void Lock() { lock_.Lock(); } - void Unlock() { lock_.Unlock(); } - // Store a flag in this registry. Takes ownership of the given pointer. void RegisterFlag(CommandLineFlag* flag); + void Lock() { lock_.Lock(); } + void Unlock() { lock_.Unlock(); } + // Returns the flag object for the specified name, or NULL if not found. CommandLineFlag* FindFlagLocked(const char* name); @@ -718,26 +685,26 @@ class FlagRegistry { typedef map<const void*, CommandLineFlag*> FlagPtrMap; FlagPtrMap flags_by_ptr_; + static FlagRegistry* global_registry_; // a singleton registry + Mutex lock_; + static Mutex global_registry_lock_; - static FlagRegistry* global_registry_; // a singleton registry - static Mutex global_registry_lock_; // guards creation of global_registry_ + static void InitGlobalRegistry(); // Disallow FlagRegistry(const FlagRegistry&); FlagRegistry& operator=(const FlagRegistry&); }; -FlagRegistry* FlagRegistry::global_registry_ = NULL; -Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED); +class FlagRegistryLock { + public: + explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); } + ~FlagRegistryLock() { fr_->Unlock(); } + private: + FlagRegistry *const fr_; +}; -FlagRegistry* FlagRegistry::GlobalRegistry() { - MutexLock acquire_lock(&global_registry_lock_); - if (!global_registry_) { - global_registry_ = new FlagRegistry; - } - return global_registry_; -} void FlagRegistry::RegisterFlag(CommandLineFlag* flag) { Lock(); @@ -807,22 +774,22 @@ CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg, // In that case, we want to return flag 'x'. if (!(flag_name[0] == 'n' && flag_name[1] == 'o')) { // flag-name is not 'nox', so we're not in the exception case. - *error_message = (string(kError) + - "unknown command line flag '" + *key + "'\n"); + *error_message = StringPrintf("%sunknown command line flag '%s'\n", + kError, key->c_str()); return NULL; } flag = FindFlagLocked(flag_name+2); if (flag == NULL) { // No flag named 'x' exists, so we're not in the exception case. - *error_message = (string(kError) + - "unknown command line flag '" + *key + "'\n"); + *error_message = StringPrintf("%sunknown command line flag '%s'\n", + kError, key->c_str()); return NULL; } if (strcmp(flag->type_name(), "bool") != 0) { // 'x' exists but is not boolean, so we're not in the exception case. - *error_message = (string(kError) + - "boolean value (" + *key + ") specified for " + - flag->type_name() + " command line flag\n"); + *error_message = StringPrintf( + "%sboolean value (%s) specified for %s command line flag\n", + kError, key->c_str(), flag->type_name()); return NULL; } // We're in the exception case! @@ -845,25 +812,27 @@ bool TryParseLocked(const CommandLineFlag* flag, FlagValue* flag_value, FlagValue* tentative_value = flag_value->New(); if (!tentative_value->ParseFrom(value)) { if (msg) { - *msg += (string(kError) + "illegal value '" + value + - + "' specified for " + flag->type_name() + " flag '" - + flag->name() + "'\n"); + StringAppendF(msg, + "%sillegal value '%s' specified for %s flag '%s'\n", + kError, value, + flag->type_name(), flag->name()); } delete tentative_value; return false; } else if (!flag->Validate(*tentative_value)) { if (msg) { - *msg += (string(kError) + "failed validation of new value " - + "'" + tentative_value->ToString() + "' for flag '" + - + flag->name() + "'\n"); + StringAppendF(msg, + "%sfailed validation of new value '%s' for flag '%s'\n", + kError, tentative_value->ToString().c_str(), + flag->name()); } delete tentative_value; return false; } else { flag_value->CopyFrom(*tentative_value); if (msg) { - *msg += (string(flag->name()) + " set to " + flag_value->ToString() - + "\n"); + StringAppendF(msg, "%s set to %s\n", + flag->name(), flag_value->ToString().c_str()); } delete tentative_value; return true; @@ -890,7 +859,8 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag, return false; flag->modified_ = true; } else { - *msg = string(flag->name()) + " set to " + flag->current_value(); + *msg = StringPrintf("%s set to %s", + flag->name(), flag->current_value().c_str()); } break; } @@ -914,13 +884,17 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag, return true; } -class FlagRegistryLock { - public: - explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); } - ~FlagRegistryLock() { fr_->Unlock(); } - private: - FlagRegistry *const fr_; -}; +// Get the singleton FlagRegistry object +FlagRegistry* FlagRegistry::global_registry_ = NULL; +Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED); + +FlagRegistry* FlagRegistry::GlobalRegistry() { + MutexLock acquire_lock(&global_registry_lock_); + if (!global_registry_) { + global_registry_ = new FlagRegistry; + } + return global_registry_; +} // -------------------------------------------------------------------- // CommandLineFlagParser @@ -1002,12 +976,12 @@ class CommandLineFlagParser { static void ParseFlagList(const char* value, vector<string>* flags) { for (const char *p = value; p && *p; value = p) { p = strchr(value, ','); - int len; + size_t len; if (p) { - len = static_cast<int>(p - value); + len = p - value; p++; } else { - len = static_cast<int>(strlen(value)); + len = strlen(value); } if (len == 0) @@ -1023,7 +997,7 @@ static void ParseFlagList(const char* value, vector<string>* flags) { // can do all the I/O in one place and not worry about it everywhere. // Plus, it's convenient to have the whole file contents at hand. // Adds a newline at the end of the file. -#define PFATAL(s) do { perror(s); commandlineflags_exitfunc(1); } while (0) +#define PFATAL(s) do { perror(s); gflags_exitfunc(1); } while (0) static string ReadFileIntoString(const char* filename) { const int kBufSize = 8092; @@ -1112,9 +1086,9 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv, && strcmp(flag->type_name(), "string") == 0 && (strstr(flag->help(), "true") || strstr(flag->help(), "false"))) { - fprintf(stderr, "Did you really mean to set flag '%s'" - " to the value '%s'?\n", - flag->name(), value); + LOG(WARNING) << "Did you really mean to set flag '" + << flag->name() << "' to the value '" + << value << "'?"; } } } @@ -1165,9 +1139,10 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval, const char* flagname = flaglist[i].c_str(); CommandLineFlag* flag = registry_->FindFlagLocked(flagname); if (flag == NULL) { - error_flags_[flagname] = (string(kError) + "unknown command line flag" - + " '" + flagname + "'" - + " (via --fromenv or --tryfromenv)\n"); + error_flags_[flagname] = + StringPrintf("%sunknown command line flag '%s' " + "(via --fromenv or --tryfromenv)\n", + kError, flagname); undefined_names_[flagname] = ""; continue; } @@ -1185,8 +1160,9 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval, // Avoid infinite recursion. if ((strcmp(envval, "fromenv") == 0) || (strcmp(envval, "tryfromenv") == 0)) { - error_flags_[flagname] = (string(kError) + "infinite recursion on " + - "environment flag '" + envval + "'\n"); + error_flags_[flagname] = + StringPrintf("%sinfinite recursion on environment flag '%s'\n", + kError, envval); continue; } @@ -1289,7 +1265,7 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( while (*flagfile_contents && isspace(*flagfile_contents)) ++flagfile_contents; line_end = strchr(flagfile_contents, '\n'); - size_t len = line_end ? static_cast<size_t>(line_end - flagfile_contents) + size_t len = line_end ? line_end - flagfile_contents : strlen(flagfile_contents); string line(flagfile_contents, len); @@ -1340,17 +1316,17 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( space = word + strlen(word); const string glob(word, space - word); // We try matching both against the full argv0 and basename(argv0) + if (glob == ProgramInvocationName() // small optimization + || glob == ProgramInvocationShortName() #ifdef HAVE_FNMATCH_H - if (fnmatch(glob.c_str(), - ProgramInvocationName(), - FNM_PATHNAME) == 0 || - fnmatch(glob.c_str(), - ProgramInvocationShortName(), - FNM_PATHNAME) == 0) { -#else // !HAVE_FNMATCH_H - if ((glob == ProgramInvocationName()) || - (glob == ProgramInvocationShortName())) { -#endif // HAVE_FNMATCH_H + || fnmatch(glob.c_str(), + ProgramInvocationName(), + FNM_PATHNAME) == 0 + || fnmatch(glob.c_str(), + ProgramInvocationShortName(), + FNM_PATHNAME) == 0 +#endif + ) { flags_are_relevant = true; } } @@ -1391,14 +1367,14 @@ bool AddFlagValidator(const void* flag_ptr, ValidateFnProto validate_fn_proto) { // This is the CommandLineFlag whose current_->value_buffer_ == flag CommandLineFlag* flag = registry->FindFlagViaPtrLocked(flag_ptr); if (!flag) { - // WARNING << "Ignoring RegisterValidateFunction() for flag pointer " - // << flag_ptr << ": no flag found at that address"; + LOG(WARNING) << "Ignoring RegisterValidateFunction() for flag pointer " + << flag_ptr << ": no flag found at that address"; return false; } else if (validate_fn_proto == flag->validate_function()) { return true; // ok to register the same function over and over again } else if (validate_fn_proto != NULL && flag->validate_function() != NULL) { - // WARNING << "Ignoring RegisterValidateFunction() for flag '" - // << flag->name() << "': validate-fn already registered"; + LOG(WARNING) << "Ignoring RegisterValidateFunction() for flag '" + << flag->name() << "': validate-fn already registered"; return false; } else { flag->validate_fn_proto_ = validate_fn_proto; @@ -1549,6 +1525,24 @@ const char* ProgramUsage() { } // -------------------------------------------------------------------- +// SetVersionString() +// VersionString() +// -------------------------------------------------------------------- + +static const char* version_string = NULL; + +void SetVersionString(const string& version) { + if (version_string != NULL) + ReportError(DIE, "ERROR: SetVersionString() called twice\n"); + version_string = strdup(version.c_str()); // small memory leak +} + +const char* VersionString() { + return version_string ? version_string : ""; +} + + +// -------------------------------------------------------------------- // GetCommandLineOption() // GetCommandLineFlagInfo() // GetCommandLineFlagInfoOrDie() @@ -1601,7 +1595,7 @@ CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name) { CommandLineFlagInfo info; if (!GetCommandLineFlagInfo(name, &info)) { fprintf(stderr, "FATAL ERROR: flag name '%s' doesn't exist\n", name); - commandlineflags_exitfunc(1); // almost certainly exit() + gflags_exitfunc(1); // almost certainly gflags_exitfunc() } return info; } @@ -1616,10 +1610,7 @@ string SetCommandLineOptionWithMode(const char* name, const char* value, CommandLineFlagParser parser(registry); result = parser.ProcessSingleOptionLocked(flag, value, set_mode); if (!result.empty()) { // in the error case, we've already logged - // You could consider logging this change, if you wanted to know it: - //fprintf(stderr, "%sFLAGS_%s\n", - // (set_mode == SET_FLAGS_DEFAULT ? "default value of " : ""), - // result); + // Could consider logging this change } } // The API of this function is that we return empty string on error @@ -1765,7 +1756,7 @@ bool ReadFlagsFromString(const string& flagfilecontents, if (parser.ReportErrors()) { // Error. Restore all global flags to their previous values. if (errors_are_fatal) - commandlineflags_exitfunc(1); // almost certainly exit() + gflags_exitfunc(1); saved_states.RestoreToRegistry(); return false; } @@ -1917,7 +1908,7 @@ static uint32 ParseCommandLineFlagsInternal(int* argc, char*** argv, parser.ValidateAllFlags(); if (parser.ReportErrors()) // may cause us to exit on illegal flags - commandlineflags_exitfunc(1); // almost certainly exit() + gflags_exitfunc(1); return r; } @@ -1947,7 +1938,7 @@ void AllowCommandLineReparsing() { allow_command_line_reparsing = true; } -uint32 ReparseCommandLineNonHelpFlags() { +void ReparseCommandLineNonHelpFlags() { // We make a copy of argc and argv to pass in const vector<string>& argvs = GetArgvs(); int tmp_argc = static_cast<int>(argvs.size()); @@ -1955,13 +1946,11 @@ uint32 ReparseCommandLineNonHelpFlags() { for (int i = 0; i < tmp_argc; ++i) tmp_argv[i] = strdup(argvs[i].c_str()); // TODO(csilvers): don't dup - const int retval = ParseCommandLineNonHelpFlags(&tmp_argc, &tmp_argv, false); + ParseCommandLineNonHelpFlags(&tmp_argc, &tmp_argv, false); for (int i = 0; i < tmp_argc; ++i) free(tmp_argv[i]); delete[] tmp_argv; - - return retval; } void ShutDownCommandLineFlags() { diff --git a/extern/libmv/third_party/gflags/gflags.h b/extern/libmv/third_party/gflags/gflags/gflags.h index cefbd62ae51..e69812c8c38 100644 --- a/extern/libmv/third_party/gflags/gflags.h +++ b/extern/libmv/third_party/gflags/gflags/gflags.h @@ -28,7 +28,6 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // --- -// Author: Ray Sidney // Revamped and reorganized by Craig Silverstein // // This is the file that should be included by any file which declares @@ -52,8 +51,8 @@ // if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end); // } // -// Then, at the command-line: -// ./foo --noverbose --start=5 --end=100 +// Then, at the command-line: +// ./foo --noverbose --start=5 --end=100 // // For more details, see // doc/gflags.html @@ -76,48 +75,22 @@ // other thread is writing to the variable or calling non-const // methods of this class. -#ifndef GOOGLE_GFLAGS_H_ -#define GOOGLE_GFLAGS_H_ +#ifndef BASE_COMMANDLINEFLAGS_H_ +#define BASE_COMMANDLINEFLAGS_H_ #include <string> #include <vector> - -// We care a lot about number of bits things take up. Unfortunately, -// systems define their bit-specific ints in a lot of different ways. -// We use our own way, and have a typedef to get there. -// Note: these commands below may look like "#if 1" or "#if 0", but -// that's because they were constructed that way at ./configure time. -// Look at gflags.h.in to see how they're calculated (based on your config). -#if 1 -#include <stdint.h> // the normal place uint16_t is defined -#endif -#if 1 -#include <sys/types.h> // the normal place u_int16_t is defined -#endif -#if 1 -#include <inttypes.h> // a third place for uint16_t or u_int16_t -#endif - +#include "gflags_declare.h" // IWYU pragma: export namespace google { -#if 1 // the C99 format -typedef int32_t int32; -typedef uint32_t uint32; -typedef int64_t int64; -typedef uint64_t uint64; -#elif 1 // the BSD format -typedef int32_t int32; -typedef u_int32_t uint32; -typedef int64_t int64; -typedef u_int64_t uint64; -#elif 0 // the windows (vc7) format -typedef __int32 int32; -typedef unsigned __int32 uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; -#else -#error Do not know how to define a 32-bit integer quantity on your system -#endif +// +// NOTE: all functions below MUST have an explicit 'extern' before +// them. Our automated opensourcing tools use this as a signal to do +// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL. +// +#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */ +#define GFLAGS_DLL_DEFINE_FLAG /* rewritten to be non-empty in windows dir */ + // -------------------------------------------------------------------- // To actually define a flag in a file, use DEFINE_bool, @@ -148,18 +121,19 @@ typedef unsigned __int64 uint64; // Returns true if successfully registered, false if not (because the // first argument doesn't point to a command-line flag, or because a // validator is already registered for this flag). -bool RegisterFlagValidator(const bool* flag, - bool (*validate_fn)(const char*, bool)); -bool RegisterFlagValidator(const int32* flag, - bool (*validate_fn)(const char*, int32)); -bool RegisterFlagValidator(const int64* flag, - bool (*validate_fn)(const char*, int64)); -bool RegisterFlagValidator(const uint64* flag, - bool (*validate_fn)(const char*, uint64)); -bool RegisterFlagValidator(const double* flag, - bool (*validate_fn)(const char*, double)); -bool RegisterFlagValidator(const std::string* flag, - bool (*validate_fn)(const char*, const std::string&)); +extern bool RegisterFlagValidator(const bool* flag, + bool (*validate_fn)(const char*, bool)); +extern bool RegisterFlagValidator(const int32* flag, + bool (*validate_fn)(const char*, int32)); +extern bool RegisterFlagValidator(const int64* flag, + bool (*validate_fn)(const char*, int64)); +extern bool RegisterFlagValidator(const uint64* flag, + bool (*validate_fn)(const char*, uint64)); +extern bool RegisterFlagValidator(const double* flag, + bool (*validate_fn)(const char*, double)); +extern bool RegisterFlagValidator(const std::string* flag, + bool (*validate_fn)(const char*, + const std::string&)); // -------------------------------------------------------------------- @@ -173,26 +147,27 @@ bool RegisterFlagValidator(const std::string* flag, // name) and argv (the entire commandline), which we sock away a copy of. // These variables are static, so you should only set them once. -struct CommandLineFlagInfo { - std::string name; // the name of the flag - std::string type; // the type of the flag: int32, etc - std::string description; // the "help text" associated with the flag - std::string current_value; // the current value, as a string - std::string default_value; // the default value, as a string - std::string filename; // 'cleaned' version of filename holding the flag - bool has_validator_fn; // true if RegisterFlagValidator called on flag - bool is_default; // true if the flag has the default value and - // has not been set explicitly from the cmdline - // or via SetCommandLineOption +struct GFLAGS_DLL_DECL CommandLineFlagInfo { + std::string name; // the name of the flag + std::string type; // the type of the flag: int32, etc + std::string description; // the "help text" associated with the flag + std::string current_value; // the current value, as a string + std::string default_value; // the default value, as a string + std::string filename; // 'cleaned' version of filename holding the flag + bool has_validator_fn; // true if RegisterFlagValidator called on this flag + bool is_default; // true if the flag has the default value and + // has not been set explicitly from the cmdline + // or via SetCommandLineOption + const void* flag_ptr; // pointer to the flag's current value (i.e. FLAGS_foo) }; // Using this inside of a validator is a recipe for a deadlock. -// TODO(wojtekm) Fix locking when validators are running, to make it safe to +// TODO(user) Fix locking when validators are running, to make it safe to // call validators during ParseAllFlags. // Also make sure then to uncomment the corresponding unit test in -// commandlineflags_unittest.sh +// gflags_unittest.sh extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT); -// These two are actually defined in commandlineflags_reporting.cc. +// These two are actually defined in gflags_reporting.cc. extern void ShowUsageWithFlags(const char *argv0); // what --help does extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict); @@ -202,17 +177,24 @@ extern std::string DescribeOneFlag(const CommandLineFlagInfo& flag); // Thread-hostile; meant to be called before any threads are spawned. extern void SetArgv(int argc, const char** argv); + // The following functions are thread-safe as long as SetArgv() is // only called before any threads start. -extern const std::vector<std::string>& GetArgvs(); // all of argv as a vector -extern const char* GetArgv(); // all of argv as a string -extern const char* GetArgv0(); // only argv0 -extern uint32 GetArgvSum(); // simple checksum of argv -extern const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set +extern const std::vector<std::string>& GetArgvs(); +extern const char* GetArgv(); // all of argv as a string +extern const char* GetArgv0(); // only argv0 +extern uint32 GetArgvSum(); // simple checksum of argv +extern const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set extern const char* ProgramInvocationShortName(); // basename(argv0) + // ProgramUsage() is thread-safe as long as SetUsageMessage() is only // called before any threads start. -extern const char* ProgramUsage(); // string set by SetUsageMessage() +extern const char* ProgramUsage(); // string set by SetUsageMessage() + +// VersionString() is thread-safe as long as SetVersionString() is only +// called before any threads start. +extern const char* VersionString(); // string set by SetVersionString() + // -------------------------------------------------------------------- @@ -237,7 +219,7 @@ extern bool GetCommandLineFlagInfo(const char* name, // if (GetCommandLineFlagInfoOrDie("foo").is_default) ... extern CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name); -enum FlagSettingMode { +enum GFLAGS_DLL_DECL FlagSettingMode { // update the flag's value (can call this multiple times). SET_FLAGS_VALUE, // update the flag's value, but *only if* it has not yet been updated @@ -259,7 +241,7 @@ enum FlagSettingMode { // SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case) extern std::string SetCommandLineOption(const char* name, const char* value); extern std::string SetCommandLineOptionWithMode(const char* name, const char* value, - FlagSettingMode set_mode); + FlagSettingMode set_mode); // -------------------------------------------------------------------- @@ -280,14 +262,17 @@ extern std::string SetCommandLineOptionWithMode(const char* name, const char* va // // without worrying about restoring the FLAG values. // } // -// Note: This class is marked with __attribute__((unused)) because all the +// Note: This class is marked with ATTRIBUTE_UNUSED because all the // work is done in the constructor and destructor, so in the standard // usage example above, the compiler would complain that it's an // unused variable. // -// This class is thread-safe. +// This class is thread-safe. However, its destructor writes to +// exactly the set of flags that have changed value during its +// lifetime, so concurrent _direct_ access to those flags +// (i.e. FLAGS_foo instead of {Get,Set}CommandLineOption()) is unsafe. -class FlagSaver { +class GFLAGS_DLL_DECL FlagSaver { public: FlagSaver(); ~FlagSaver(); @@ -311,12 +296,11 @@ extern std::string CommandlineFlagsIntoString(); // Usually where this is used, a FlagSaver should be used instead. extern bool ReadFlagsFromString(const std::string& flagfilecontents, const char* prog_name, - bool errors_are_fatal); // uses SET_FLAGS_VALUE + bool errors_are_fatal); // uses SET_FLAGS_VALUE // These let you manually implement --flagfile functionality. // DEPRECATED. extern bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name); -extern bool SaveCommandFlags(); // actually defined in google.cc ! extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name, bool errors_are_fatal); // uses SET_FLAGS_VALUE @@ -338,7 +322,7 @@ extern const char *StringFromEnv(const char *varname, const char *defval); // -------------------------------------------------------------------- -// The next two functions parse commandlineflags from main(): +// The next two functions parse gflags from main(): // Set the "usage" message for this program. For example: // string usage("This program does nothing. Sample usage:\n"); @@ -348,6 +332,12 @@ extern const char *StringFromEnv(const char *varname, const char *defval); // Thread-hostile; meant to be called before any threads are spawned. extern void SetUsageMessage(const std::string& usage); +// Sets the version string, which is emitted with --version. +// For instance: SetVersionString("1.3"); +// Thread-hostile; meant to be called before any threads are spawned. +extern void SetVersionString(const std::string& version); + + // Looks for flags in argv and parses them. Rearranges argv to put // flags first, or removes them entirely if remove_flags is true. // If a flag is defined more than once in the command line or flag @@ -355,8 +345,7 @@ extern void SetUsageMessage(const std::string& usage); // of the first non-flag argument. // See top-of-file for more details on this function. #ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead. -extern uint32 ParseCommandLineFlags(int *argc, char*** argv, - bool remove_flags); +extern uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags); #endif @@ -372,10 +361,10 @@ extern uint32 ParseCommandLineFlags(int *argc, char*** argv, // non-flag argument. (If remove_flags is true, will always return 1.) extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv, bool remove_flags); -// This is actually defined in commandlineflags_reporting.cc. +// This is actually defined in gflags_reporting.cc. // This function is misnamed (it also handles --version, etc.), but // it's too late to change that now. :-( -extern void HandleCommandLineHelpFlags(); // in commandlineflags_reporting.cc +extern void HandleCommandLineHelpFlags(); // in gflags_reporting.cc // Allow command line reparsing. Disables the error normally // generated when an unknown flag is found, since it may be found in a @@ -389,18 +378,17 @@ extern void AllowCommandLineReparsing(); // separate command line argument that follows the flag argument. // Intended for handling flags from dynamically loaded libraries, // since their flags are not registered until they are loaded. -// Returns the index (into the original argv) of the first non-flag -// argument. (If remove_flags is true, will always return 1.) -extern uint32 ReparseCommandLineNonHelpFlags(); +extern void ReparseCommandLineNonHelpFlags(); // Clean up memory allocated by flags. This is only needed to reduce // the quantity of "potentially leaked" reports emitted by memory // debugging tools such as valgrind. It is not required for normal -// operation, or for the perftools heap-checker. It must only be called -// when the process is about to exit, and all threads that might -// access flags are quiescent. Referencing flags after this is called -// will have unexpected consequences. This is not safe to run when -// multiple threads might be running: the function is thread-hostile. +// operation, or for the google perftools heap-checker. It must only +// be called when the process is about to exit, and all threads that +// might access flags are quiescent. Referencing flags after this is +// called will have unexpected consequences. This is not safe to run +// when multiple threads might be running: the function is +// thread-hostile. extern void ShutDownCommandLineFlags(); @@ -441,15 +429,13 @@ extern void ShutDownCommandLineFlags(); // people can't DECLARE_int32 something that they DEFINE_bool'd // elsewhere. -class FlagRegisterer { +class GFLAGS_DLL_DECL FlagRegisterer { public: FlagRegisterer(const char* name, const char* type, const char* help, const char* filename, void* current_storage, void* defvalue_storage); }; -extern bool FlagsTypeWarn(const char *name); - // If your application #defines STRIP_FLAG_HELP to a non-zero value // before #including this file, we remove the help message from the // binary file. This can reduce the size of the resulting binary @@ -463,7 +449,8 @@ extern const char kStrippedFlagHelp[]; #if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0 // Need this construct to avoid the 'defined but not used' warning. -#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : ::google::kStrippedFlagHelp) +#define MAYBE_STRIPPED_HELP(txt) \ + (false ? (txt) : ::google::kStrippedFlagHelp) #else #define MAYBE_STRIPPED_HELP(txt) txt #endif @@ -479,21 +466,16 @@ extern const char kStrippedFlagHelp[]; // FLAGS_no<name>. This serves the second purpose of assuring a // compile error if someone tries to define a flag named no<name> // which is illegal (--foo and --nofoo both affect the "foo" flag). -#define DEFINE_VARIABLE(type, shorttype, name, value, help) \ - namespace fL##shorttype { \ - static const type FLAGS_nono##name = value; \ - type FLAGS_##name = FLAGS_nono##name; \ - type FLAGS_no##name = FLAGS_nono##name; \ - static ::google::FlagRegisterer o_##name( \ - #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \ - &FLAGS_##name, &FLAGS_no##name); \ - } \ - using fL##shorttype::FLAGS_##name - -#define DECLARE_VARIABLE(type, shorttype, name) \ - namespace fL##shorttype { \ - extern type FLAGS_##name; \ - } \ +#define DEFINE_VARIABLE(type, shorttype, name, value, help) \ + namespace fL##shorttype { \ + static const type FLAGS_nono##name = value; \ + /* We always want to export defined variables, dll or no */ \ + GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \ + type FLAGS_no##name = FLAGS_nono##name; \ + static ::google::FlagRegisterer o_##name( \ + #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \ + &FLAGS_##name, &FLAGS_no##name); \ + } \ using fL##shorttype::FLAGS_##name // For DEFINE_bool, we want to do the extra check that the passed-in @@ -503,34 +485,39 @@ extern const char kStrippedFlagHelp[]; // We'll use 'sizeof(IsBool(val))' to distinguish. This code requires // that the compiler have different sizes for bool & double. Since // this is not guaranteed by the standard, we check it with a -// compile-time assert (msg[-1] will give a compile-time error). +// COMPILE_ASSERT. namespace fLB { struct CompileAssert {}; typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[ (sizeof(double) != sizeof(bool)) ? 1 : -1]; -template<typename From> double IsBoolFlag(const From& from); -bool IsBoolFlag(bool from); +template<typename From> double GFLAGS_DLL_DECL IsBoolFlag(const From& from); +GFLAGS_DLL_DECL bool IsBoolFlag(bool from); } // namespace fLB -#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name) -#define DEFINE_bool(name, val, txt) \ - namespace fLB { \ - typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \ +// Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros +// are in a separate include, gflags_declare.h, for reducing +// the physical transitive size for DECLARE use. +#define DEFINE_bool(name, val, txt) \ + namespace fLB { \ + typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \ (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \ - } \ + } \ DEFINE_VARIABLE(bool, B, name, val, txt) -#define DECLARE_int32(name) DECLARE_VARIABLE(::google::int32, I, name) -#define DEFINE_int32(name,val,txt) DEFINE_VARIABLE(::google::int32, I, name, val, txt) +#define DEFINE_int32(name, val, txt) \ + DEFINE_VARIABLE(::google::int32, I, \ + name, val, txt) -#define DECLARE_int64(name) DECLARE_VARIABLE(::google::int64, I64, name) -#define DEFINE_int64(name,val,txt) DEFINE_VARIABLE(::google::int64, I64, name, val, txt) +#define DEFINE_int64(name, val, txt) \ + DEFINE_VARIABLE(::google::int64, I64, \ + name, val, txt) -#define DECLARE_uint64(name) DECLARE_VARIABLE(::google::uint64, U64, name) -#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(::google::uint64, U64, name, val, txt) +#define DEFINE_uint64(name,val, txt) \ + DEFINE_VARIABLE(::google::uint64, U64, \ + name, val, txt) -#define DECLARE_double(name) DECLARE_VARIABLE(double, D, name) -#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt) +#define DEFINE_double(name, val, txt) \ + DEFINE_VARIABLE(double, D, name, val, txt) // Strings are trickier, because they're not a POD, so we can't // construct them at static-initialization time (instead they get @@ -540,11 +527,6 @@ bool IsBoolFlag(bool from); // into it later. It's not perfect, but the best we can do. namespace fLS { -// The meaning of "string" might be different between now and when the -// macros below get invoked (e.g., if someone is experimenting with -// other string implementations that get defined after this file is -// included). Save the current meaning now and use it in the macros. -typedef std::string clstring; inline clstring* dont_pass0toDEFINE_string(char *stringspot, const char *value) { @@ -558,9 +540,6 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot, int value); } // namespace fLS -#define DECLARE_string(name) namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \ - using fLS::FLAGS_##name - // We need to define a var named FLAGS_no##name so people don't define // --string and --nostring. And we need a temporary place to put val // so we don't have to evaluate it twice. Two great needs that go @@ -575,10 +554,10 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot, clstring* const FLAGS_no##name = ::fLS:: \ dont_pass0toDEFINE_string(s_##name[0].s, \ val); \ - static ::google::FlagRegisterer o_##name( \ + static ::google::FlagRegisterer o_##name( \ #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \ s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \ - extern clstring& FLAGS_##name; \ + extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \ using fLS::FLAGS_##name; \ clstring& FLAGS_##name = *FLAGS_no##name; \ } \ @@ -586,4 +565,4 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot, #endif // SWIG -#endif // GOOGLE_GFLAGS_H_ +#endif // BASE_COMMANDLINEFLAGS_H_ diff --git a/extern/libmv/third_party/gflags/gflags_completions.h b/extern/libmv/third_party/gflags/gflags/gflags_completions.h index 9d9ce7a5f75..37f5b0ec2cf 100644 --- a/extern/libmv/third_party/gflags/gflags_completions.h +++ b/extern/libmv/third_party/gflags/gflags/gflags_completions.h @@ -28,7 +28,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // --- -// Author: Dave Nicponski + // // Implement helpful bash-style command line flag completions // @@ -88,8 +88,8 @@ // file would be (your path to gflags_completions.sh file may differ): /* -$ complete -o bashdefault -o default -o nospace -C \ - '/usr/local/bin/gflags_completions.sh --tab_completion_columns $COLUMNS' \ +$ complete -o bashdefault -o default -o nospace -C \ + '/home/build/eng/bash/bash_completions.sh --tab_completion_columns $COLUMNS' \ time env binary_name another_binary [...] */ @@ -109,13 +109,22 @@ $ complete -o bashdefault -o default -o nospace -C \ // produce the expected completion output. -#ifndef GOOGLE_GFLAGS_COMPLETIONS_H_ -#define GOOGLE_GFLAGS_COMPLETIONS_H_ +#ifndef BASE_COMMANDLINEFLAGS_COMPLETIONS_H_ +#define BASE_COMMANDLINEFLAGS_COMPLETIONS_H_ + +// Annoying stuff for windows -- makes sure clients can import these functions +// +// NOTE: all functions below MUST have an explicit 'extern' before +// them. Our automated opensourcing tools use this as a signal to do +// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL. +// +#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */ + namespace google { -void HandleCommandLineCompletions(void); +extern void HandleCommandLineCompletions(void); } -#endif // GOOGLE_GFLAGS_COMPLETIONS_H_ +#endif // BASE_COMMANDLINEFLAGS_COMPLETIONS_H_ diff --git a/extern/libmv/third_party/gflags/gflags/gflags_declare.h b/extern/libmv/third_party/gflags/gflags/gflags_declare.h new file mode 100644 index 00000000000..e3013826d53 --- /dev/null +++ b/extern/libmv/third_party/gflags/gflags/gflags_declare.h @@ -0,0 +1,112 @@ +// Copyright (c) 1999, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- +// +// Revamped and reorganized by Craig Silverstein +// +// This is the file that should be included by any file which declares +// command line flag. + +#ifndef BASE_COMMANDLINEFLAGS_DECLARE_H_ +#define BASE_COMMANDLINEFLAGS_DECLARE_H_ + +#include <string> +#if 1 +#include <stdint.h> // the normal place uint16_t is defined +#endif +#if 1 +#include <sys/types.h> // the normal place u_int16_t is defined +#endif +#if 1 +#include <inttypes.h> // a third place for uint16_t or u_int16_t +#endif + +namespace google { +#if 1 // the C99 format +typedef int32_t int32; +typedef uint32_t uint32; +typedef int64_t int64; +typedef uint64_t uint64; +#elif 1 // the BSD format +typedef int32_t int32; +typedef u_int32_t uint32; +typedef int64_t int64; +typedef u_int64_t uint64; +#elif 0 // the windows (vc7) format +typedef __int32 int32; +typedef unsigned __int32 uint32; +typedef __int64 int64; +typedef unsigned __int64 uint64; +#else +#error Do not know how to define a 32-bit integer quantity on your system +#endif +} + + +#define GFLAGS_DLL_DECLARE_FLAG /* rewritten to be non-empty in windows dir */ + +namespace fLS { + +// The meaning of "string" might be different between now and when the +// macros below get invoked (e.g., if someone is experimenting with +// other string implementations that get defined after this file is +// included). Save the current meaning now and use it in the macros. +typedef std::string clstring; + +} + +#define DECLARE_VARIABLE(type, shorttype, name) \ + /* We always want to import declared variables, dll or no */ \ + namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \ + using fL##shorttype::FLAGS_##name + +#define DECLARE_bool(name) \ + DECLARE_VARIABLE(bool, B, name) + +#define DECLARE_int32(name) \ + DECLARE_VARIABLE(::google::int32, I, name) + +#define DECLARE_int64(name) \ + DECLARE_VARIABLE(::google::int64, I64, name) + +#define DECLARE_uint64(name) \ + DECLARE_VARIABLE(::google::uint64, U64, name) + +#define DECLARE_double(name) \ + DECLARE_VARIABLE(double, D, name) + +#define DECLARE_string(name) \ + namespace fLS { \ + using ::fLS::clstring; \ + extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \ + } \ + using fLS::FLAGS_##name + +#endif // BASE_COMMANDLINEFLAGS_DECLARE_H_ diff --git a/extern/libmv/third_party/gflags/gflags_completions.cc b/extern/libmv/third_party/gflags/gflags_completions.cc index a129611d8a1..75e9236ef63 100644 --- a/extern/libmv/third_party/gflags/gflags_completions.cc +++ b/extern/libmv/third_party/gflags/gflags_completions.cc @@ -28,8 +28,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // --- -// Author: Dave Nicponski -// + // Bash-style command line flag completion for C++ binaries // // This module implements bash-style completions. It achieves this @@ -58,7 +57,12 @@ #include <utility> #include <vector> -#include "gflags.h" +#include "gflags/gflags.h" +#include "util.h" + +using std::set; +using std::string; +using std::vector; #ifndef PATH_SEPARATOR #define PATH_SEPARATOR '/' @@ -74,11 +78,6 @@ DEFINE_int32(tab_completion_columns, 80, _START_GOOGLE_NAMESPACE_ namespace { - -using std::set; -using std::string; -using std::vector; - // Function prototypes and Type forward declarations. Code may be // more easily understood if it is roughly ordered according to // control flow, rather than by C's "declare before use" ordering @@ -210,12 +209,12 @@ static void PrintFlagCompletionInfo(void) { &canonical_token, &options); - //VLOG(1) << "Identified canonical_token: '" << canonical_token << "'"; + DVLOG(1) << "Identified canonical_token: '" << canonical_token << "'"; vector<CommandLineFlagInfo> all_flags; set<const CommandLineFlagInfo *> matching_flags; GetAllFlags(&all_flags); - //VLOG(2) << "Found " << all_flags.size() << " flags overall"; + DVLOG(2) << "Found " << all_flags.size() << " flags overall"; string longest_common_prefix; FindMatchingFlags( @@ -224,28 +223,28 @@ static void PrintFlagCompletionInfo(void) { canonical_token, &matching_flags, &longest_common_prefix); - //VLOG(1) << "Identified " << matching_flags.size() << " matching flags"; - //VLOG(1) << "Identified " << longest_common_prefix - // << " as longest common prefix."; + DVLOG(1) << "Identified " << matching_flags.size() << " matching flags"; + DVLOG(1) << "Identified " << longest_common_prefix + << " as longest common prefix."; if (longest_common_prefix.size() > canonical_token.size()) { // There's actually a shared common prefix to all matching flags, // so may as well output that and quit quickly. - //VLOG(1) << "The common prefix '" << longest_common_prefix - // << "' was longer than the token '" << canonical_token - // << "'. Returning just this prefix for completion."; + DVLOG(1) << "The common prefix '" << longest_common_prefix + << "' was longer than the token '" << canonical_token + << "'. Returning just this prefix for completion."; fprintf(stdout, "--%s", longest_common_prefix.c_str()); return; } if (matching_flags.empty()) { - //VLOG(1) << "There were no matching flags, returning nothing."; + VLOG(1) << "There were no matching flags, returning nothing."; return; } string module; string package_dir; TryFindModuleAndPackageDir(all_flags, &module, &package_dir); - //VLOG(1) << "Identified module: '" << module << "'"; - //VLOG(1) << "Identified package_dir: '" << package_dir << "'"; + DVLOG(1) << "Identified module: '" << module << "'"; + DVLOG(1) << "Identified package_dir: '" << package_dir << "'"; NotableFlags notable_flags; CategorizeAllMatchingFlags( @@ -254,12 +253,12 @@ static void PrintFlagCompletionInfo(void) { module, package_dir, ¬able_flags); - //VLOG(2) << "Categorized matching flags:"; - //VLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size(); - //VLOG(2) << " module: " << notable_flags.module_flags.size(); - //VLOG(2) << " package: " << notable_flags.package_flags.size(); - //VLOG(2) << " most common: " << notable_flags.most_common_flags.size(); - //VLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size(); + DVLOG(2) << "Categorized matching flags:"; + DVLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size(); + DVLOG(2) << " module: " << notable_flags.module_flags.size(); + DVLOG(2) << " package: " << notable_flags.package_flags.size(); + DVLOG(2) << " most common: " << notable_flags.most_common_flags.size(); + DVLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size(); vector<string> completions; FinalizeCompletionOutput( @@ -271,13 +270,13 @@ static void PrintFlagCompletionInfo(void) { if (options.force_no_update) completions.push_back("~"); - //VLOG(1) << "Finalized with " << completions.size() - // << " chosen completions"; + DVLOG(1) << "Finalized with " << completions.size() + << " chosen completions"; for (vector<string>::const_iterator it = completions.begin(); it != completions.end(); ++it) { - //VLOG(9) << " Completion entry: '" << *it << "'"; + DVLOG(9) << " Completion entry: '" << *it << "'"; fprintf(stdout, "%s\n", it->c_str()); } } @@ -397,7 +396,7 @@ static bool DoesSingleFlagMatch( flag.filename.find(match_token) != string::npos) return true; - // TODO(daven): All searches should probably be case-insensitive + // TODO(user): All searches should probably be case-insensitive // (especially this one...) if (options.flag_description_substring_search && flag.description.find(match_token) != string::npos) @@ -426,8 +425,8 @@ static void CategorizeAllMatchingFlags( all_matches.begin(); it != all_matches.end(); ++it) { - //VLOG(2) << "Examining match '" << (*it)->name << "'"; - //VLOG(7) << " filename: '" << (*it)->filename << "'"; + DVLOG(2) << "Examining match '" << (*it)->name << "'"; + DVLOG(7) << " filename: '" << (*it)->filename << "'"; string::size_type pos = string::npos; if (!package_dir.empty()) pos = (*it)->filename.find(package_dir); @@ -440,36 +439,34 @@ static void CategorizeAllMatchingFlags( if ((*it)->name == search_token) { // Exact match on some flag's name notable_flags->perfect_match_flag.insert(*it); - //VLOG(3) << "Result: perfect match"; + DVLOG(3) << "Result: perfect match"; } else if (!module.empty() && (*it)->filename == module) { // Exact match on module filename notable_flags->module_flags.insert(*it); - //VLOG(3) << "Result: module match"; + DVLOG(3) << "Result: module match"; } else if (!package_dir.empty() && pos != string::npos && slash == string::npos) { // In the package, since there was no slash after the package portion notable_flags->package_flags.insert(*it); - //VLOG(3) << "Result: package match"; + DVLOG(3) << "Result: package match"; } else if (false) { // In the list of the XXX most commonly supplied flags overall - // TODO(daven): Compile this list. - //VLOG(3) << "Result: most-common match"; + // TODO(user): Compile this list. + DVLOG(3) << "Result: most-common match"; } else if (!package_dir.empty() && pos != string::npos && slash != string::npos) { // In a subdirectory of the package notable_flags->subpackage_flags.insert(*it); - //VLOG(3) << "Result: subpackage match"; + DVLOG(3) << "Result: subpackage match"; } - //VLOG(3) << "Result: not special match"; + DVLOG(3) << "Result: not special match"; } } static void PushNameWithSuffix(vector<string>* suffixes, const char* suffix) { - string s("/"); - s += ProgramInvocationShortName(); - s += suffix; - suffixes->push_back(s); + suffixes->push_back( + StringPrintf("/%s%s", ProgramInvocationShortName(), suffix)); } static void TryFindModuleAndPackageDir( @@ -480,7 +477,7 @@ static void TryFindModuleAndPackageDir( package_dir->clear(); vector<string> suffixes; - // TODO(daven): There's some inherant ambiguity here - multiple directories + // TODO(user): There's some inherant ambiguity here - multiple directories // could share the same trailing folder and file structure (and even worse, // same file names), causing us to be unsure as to which of the two is the // actual package for this binary. In this case, we'll arbitrarily choose. @@ -499,7 +496,7 @@ static void TryFindModuleAndPackageDir( for (vector<string>::const_iterator suffix = suffixes.begin(); suffix != suffixes.end(); ++suffix) { - // TODO(daven): Make sure the match is near the end of the string + // TODO(user): Make sure the match is near the end of the string if (it->filename.find(*suffix) != string::npos) { *module = it->filename; string::size_type sep = it->filename.rfind(PATH_SEPARATOR); @@ -696,12 +693,14 @@ static void OutputSingleGroupWithLimit( static string GetShortFlagLine( const string &line_indentation, const CommandLineFlagInfo &info) { - string prefix = - line_indentation + "--" + info.name + " [" + - (info.type == "string" ? - ("'" + info.default_value + "'") : - info.default_value) - + "] "; + string prefix; + bool is_string = (info.type == "string"); + SStringPrintf(&prefix, "%s--%s [%s%s%s] ", + line_indentation.c_str(), + info.name.c_str(), + (is_string ? "'" : ""), + info.default_value.c_str(), + (is_string ? "'" : "")); int remainder = FLAGS_tab_completion_columns - static_cast<int>(prefix.size()); string suffix; @@ -731,8 +730,12 @@ static string GetLongFlagLine( static const char kNewlineWithIndent[] = "\n "; output.replace(output.find(" type:"), 1, string(kNewlineWithIndent)); output.replace(output.find(" default:"), 1, string(kNewlineWithIndent)); - output = line_indentation + " Details for '--" + info.name + "':\n" + - output + " defined: " + info.filename; + output = StringPrintf("%s Details for '--%s':\n" + "%s defined: %s", + line_indentation.c_str(), + info.name.c_str(), + output.c_str(), + info.filename.c_str()); // Eliminate any doubled newlines that crept in. Specifically, if // DescribeOneFlag() decided to break the line just before "type" @@ -759,7 +762,7 @@ static string GetLongFlagLine( void HandleCommandLineCompletions(void) { if (FLAGS_tab_completion_word.empty()) return; PrintFlagCompletionInfo(); - exit(0); + gflags_exitfunc(0); } _END_GOOGLE_NAMESPACE_ diff --git a/extern/libmv/third_party/gflags/gflags_reporting.cc b/extern/libmv/third_party/gflags/gflags_reporting.cc index fa3024d974e..c74bcc8d762 100644 --- a/extern/libmv/third_party/gflags/gflags_reporting.cc +++ b/extern/libmv/third_party/gflags/gflags_reporting.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006, Google Inc. +// Copyright (c) 1999, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -28,7 +28,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // --- -// Author: Ray Sidney +// // Revamped and reorganized by Craig Silverstein // // This file contains code for handling the 'reporting' flags. These @@ -40,7 +40,7 @@ // HandleCommandLineHelpFlags(). (Well, actually, ShowUsageWithFlags(), // ShowUsageWithFlagsRestrict(), and DescribeOneFlag() can be called // externally too, but there's little need for it.) These are all -// declared in the main commandlineflags.h header file. +// declared in the main gflags.h header file. // // HandleCommandLineHelpFlags() will check what 'reporting' flags have // been defined, if any -- the "help" part of the function name is a @@ -55,14 +55,15 @@ #include <assert.h> #include <string> #include <vector> -#include "gflags.h" -#include "gflags_completions.h" +#include "gflags/gflags.h" +#include "gflags/gflags_completions.h" +#include "util.h" #ifndef PATH_SEPARATOR #define PATH_SEPARATOR '/' #endif -// The 'reporting' flags. They all call exit(). +// The 'reporting' flags. They all call gflags_exitfunc(). DEFINE_bool(help, false, "show help on all flags [tip: all flags can have two dashes]"); DEFINE_bool(helpfull, false, @@ -85,11 +86,12 @@ _START_GOOGLE_NAMESPACE_ using std::string; using std::vector; + // -------------------------------------------------------------------- // DescribeOneFlag() // DescribeOneFlagInXML() // Routines that pretty-print info about a flag. These use -// a CommandLineFlagInfo, which is the way the commandlineflags +// a CommandLineFlagInfo, which is the way the gflags // API exposes static info about a flag. // -------------------------------------------------------------------- @@ -114,17 +116,19 @@ static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag, const char* c_string = (current ? flag.current_value.c_str() : flag.default_value.c_str()); if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings - return text + ": \"" + c_string + "\""; + return StringPrintf("%s: \"%s\"", text.c_str(), c_string); } else { - return text + ": " + c_string; + return StringPrintf("%s: %s", text.c_str(), c_string); } } // Create a descriptive string for a flag. // Goes to some trouble to make pretty line breaks. string DescribeOneFlag(const CommandLineFlagInfo& flag) { - string main_part = (string(" -") + flag.name + - " (" + flag.description + ')'); + string main_part; + SStringPrintf(&main_part, " -%s (%s)", + flag.name.c_str(), + flag.description.c_str()); const char* c_string = main_part.c_str(); int chars_left = static_cast<int>(main_part.length()); string final_string = ""; @@ -164,7 +168,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { } if (*c_string == '\0') break; - final_string += "\n "; + StringAppendF(&final_string, "\n "); chars_in_line = 6; } @@ -173,7 +177,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { // The listed default value will be the actual default from the flag // definition in the originating source file, unless the value has // subsequently been modified using SetCommandLineOptionWithMode() with mode - // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before initializing. + // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before ParseCommandLineFlags(). AddString(PrintStringFlagsWithQuotes(flag, "default", false), &final_string, &chars_in_line); if (!flag.is_default) { @@ -181,7 +185,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { &final_string, &chars_in_line); } - final_string += '\n'; + StringAppendF(&final_string, "\n"); return final_string; } @@ -196,15 +200,10 @@ static string XMLText(const string& txt) { } static void AddXMLTag(string* r, const char* tag, const string& txt) { - *r += ('<'); - *r += (tag); - *r += ('>'); - *r += (XMLText(txt)); - *r += ("</"); - *r += (tag); - *r += ('>'); + StringAppendF(r, "<%s>%s</%s>", tag, XMLText(txt).c_str(), tag); } + static string DescribeOneFlagInXML(const CommandLineFlagInfo& flag) { // The file and flagname could have been attributes, but default // and meaning need to avoid attribute normalization. This way it @@ -265,9 +264,9 @@ static bool FileMatchesSubstring(const string& filename, // Show help for every filename which matches any of the target substrings. // If substrings is empty, shows help for every file. If a flag's help message -// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' before -// including gflags/gflags.h), then this flag will not be displayed by -// '--help' and its variants. +// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' +// before including gflags/gflags.h), then this flag will not be displayed +// by '--help' and its variants. static void ShowUsageWithFlagsMatching(const char *argv0, const vector<string> &substrings) { fprintf(stdout, "%s: %s\n", Basename(argv0), ProgramUsage()); @@ -347,10 +346,13 @@ static void ShowXMLOfFlags(const char *prog_name) { // -------------------------------------------------------------------- static void ShowVersion() { - fprintf(stdout, "%s\n", ProgramInvocationShortName()); - // TODO: add other stuff, like a timestamp, who built it, what - // target they built, etc. - + const char* version_string = VersionString(); + if (version_string && *version_string) { + fprintf(stdout, "%s version %s\n", + ProgramInvocationShortName(), version_string); + } else { + fprintf(stdout, "%s\n", ProgramInvocationShortName()); + } # if !defined(NDEBUG) fprintf(stdout, "Debug build (NDEBUG not #defined)\n"); # endif @@ -375,7 +377,6 @@ static void AppendPrognameStrings(vector<string>* substrings, void HandleCommandLineHelpFlags() { const char* progname = ProgramInvocationShortName(); - extern void (*commandlineflags_exitfunc)(int); // in gflags.cc HandleCommandLineCompletions(); @@ -386,21 +387,21 @@ void HandleCommandLineHelpFlags() { // show only flags related to this binary: // E.g. for fileutil.cc, want flags containing ... "/fileutil." cc ShowUsageWithFlagsMatching(progname, substrings); - commandlineflags_exitfunc(1); // almost certainly exit() + gflags_exitfunc(1); } else if (FLAGS_help || FLAGS_helpfull) { // show all options ShowUsageWithFlagsRestrict(progname, ""); // empty restrict - commandlineflags_exitfunc(1); + gflags_exitfunc(1); } else if (!FLAGS_helpon.empty()) { string restrict = "/" + FLAGS_helpon + "."; ShowUsageWithFlagsRestrict(progname, restrict.c_str()); - commandlineflags_exitfunc(1); + gflags_exitfunc(1); } else if (!FLAGS_helpmatch.empty()) { ShowUsageWithFlagsRestrict(progname, FLAGS_helpmatch.c_str()); - commandlineflags_exitfunc(1); + gflags_exitfunc(1); } else if (FLAGS_helppackage) { // Shows help for all files in the same directory as main(). We @@ -419,27 +420,27 @@ void HandleCommandLineHelpFlags() { const string package = Dirname(flag->filename) + "/"; if (package != last_package) { ShowUsageWithFlagsRestrict(progname, package.c_str()); + VLOG(7) << "Found package: " << package; if (!last_package.empty()) { // means this isn't our first pkg - fprintf(stderr, "WARNING: Multiple packages contain a file=%s\n", - progname); + LOG(WARNING) << "Multiple packages contain a file=" << progname; } last_package = package; } } if (last_package.empty()) { // never found a package to print - fprintf(stderr, "WARNING: Unable to find a package for file=%s\n", - progname); + LOG(WARNING) << "Unable to find a package for file=" << progname; } - commandlineflags_exitfunc(1); + gflags_exitfunc(1); } else if (FLAGS_helpxml) { ShowXMLOfFlags(progname); - commandlineflags_exitfunc(1); + gflags_exitfunc(1); } else if (FLAGS_version) { ShowVersion(); // Unlike help, we may be asking for version in a script, so return 0 - commandlineflags_exitfunc(0); + gflags_exitfunc(0); + } } diff --git a/extern/libmv/third_party/gflags/mutex.h b/extern/libmv/third_party/gflags/mutex.h index 6e1e8976b6d..7c3c060a043 100644 --- a/extern/libmv/third_party/gflags/mutex.h +++ b/extern/libmv/third_party/gflags/mutex.h @@ -28,7 +28,6 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // --- -// Author: Craig Silverstein. // // A simple mutex wrapper, supporting locks and read-write locks. // You should assume the locks are *not* re-entrant. @@ -117,7 +116,12 @@ #if defined(NO_THREADS) typedef int MutexType; // to keep a lock-count #elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__) -# define WIN32_LEAN_AND_MEAN // We only need minimal includes +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN // We only need minimal includes +# endif +# ifndef NOMINMAX +# define NOMINMAX // Don't want windows to override min()/max() +# endif # ifdef GMUTEX_TRYLOCK // We need Windows NT or later for TryEnterCriticalSection(). If you // don't need that functionality, you can remove these _WIN32_WINNT @@ -134,7 +138,10 @@ // *does* cause problems for FreeBSD, or MacOSX, but isn't needed // for locking there.) # ifdef __linux__ -# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls +# if _XOPEN_SOURCE < 500 // including not being defined at all +# undef _XOPEN_SOURCE +# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls +# endif # endif # include <pthread.h> typedef pthread_rwlock_t MutexType; diff --git a/extern/libmv/third_party/gflags/util.h b/extern/libmv/third_party/gflags/util.h new file mode 100644 index 00000000000..8e2b1b89525 --- /dev/null +++ b/extern/libmv/third_party/gflags/util.h @@ -0,0 +1,339 @@ +// Copyright (c) 2011, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// --- +// +// Some generically useful utility routines that in google-land would +// be their own projects. We make a shortened version here. + +#ifndef GFLAGS_UTIL_H_ +#define GFLAGS_UTIL_H_ + +#include <assert.h> +#include "config.h" +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#include <stdarg.h> // for va_* +#include <stdlib.h> +#include <stdio.h> +#include <iostream> +#include <string> +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif // for mkdir() + +_START_GOOGLE_NAMESPACE_ + +// This is used for unittests for death-testing. It is defined in gflags.cc. +extern GFLAGS_DLL_DECL void (*gflags_exitfunc)(int); + +// Work properly if either strtoll or strtoq is on this system +#ifdef HAVE_STRTOLL +# define strto64 strtoll +# define strtou64 strtoull +#elif HAVE_STRTOQ +# define strto64 strtoq +# define strtou64 strtouq +#else +// Neither strtoll nor strtoq are defined. I hope strtol works! +# define strto64 strtol +# define strtou64 strtoul +#endif + +// If we have inttypes.h, it will have defined PRId32/etc for us. If +// not, take our best guess. +#ifndef PRId32 +# define PRId32 "d" +#endif +#ifndef PRId64 +# define PRId64 "lld" +#endif +#ifndef PRIu64 +# define PRIu64 "llu" +#endif + +typedef signed char int8; +typedef unsigned char uint8; + +// -- utility macros --------------------------------------------------------- + +template <bool> struct CompileAssert {}; +#define COMPILE_ASSERT(expr, msg) \ + typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] + +// Returns the number of elements in an array. +#define arraysize(arr) (sizeof(arr)/sizeof(*(arr))) + + +// -- logging and testing --------------------------------------------------- + +// For now, we ignore the level for logging, and don't show *VLOG's at +// all, except by hand-editing the lines below +#define LOG(level) std::cerr +#define VLOG(level) if (true) {} else std::cerr +#define DVLOG(level) if (true) {} else std::cerr + +// CHECK dies with a fatal error if condition is not true. It is *not* +// controlled by NDEBUG, so the check will be executed regardless of +// compilation mode. Therefore, it is safe to do things like: +// CHECK(fp->Write(x) == 4) +// We allow stream-like objects after this for debugging, but they're ignored. +#define EXPECT_TRUE(condition) \ + if (true) { \ + if (!(condition)) { \ + fprintf(stderr, "Check failed: %s\n", #condition); \ + exit(1); \ + } \ + } else std::cerr << "" + +#define EXPECT_OP(op, val1, val2) \ + if (true) { \ + if (!((val1) op (val2))) { \ + fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \ + exit(1); \ + } \ + } else std::cerr << "" + +#define EXPECT_EQ(val1, val2) EXPECT_OP(==, val1, val2) +#define EXPECT_NE(val1, val2) EXPECT_OP(!=, val1, val2) +#define EXPECT_LE(val1, val2) EXPECT_OP(<=, val1, val2) +#define EXPECT_LT(val1, val2) EXPECT_OP(< , val1, val2) +#define EXPECT_GE(val1, val2) EXPECT_OP(>=, val1, val2) +#define EXPECT_GT(val1, val2) EXPECT_OP(> , val1, val2) +#define EXPECT_FALSE(cond) EXPECT_TRUE(!(cond)) + +// C99 declares isnan and isinf should be macros, so the #ifdef test +// should be reliable everywhere. Of course, it's not, but these +// are testing pertty marginal functionality anyway, so it's ok to +// not-run them even in situations they might, with effort, be made to work. +#ifdef isnan // Some compilers, like sun's for Solaris 10, don't define this +#define EXPECT_NAN(arg) \ + do { \ + if (!isnan(arg)) { \ + fprintf(stderr, "Check failed: isnan(%s)\n", #arg); \ + exit(1); \ + } \ + } while (0) +#else +#define EXPECT_NAN(arg) +#endif + +#ifdef isinf // Some compilers, like sun's for Solaris 10, don't define this +#define EXPECT_INF(arg) \ + do { \ + if (!isinf(arg)) { \ + fprintf(stderr, "Check failed: isinf(%s)\n", #arg); \ + exit(1); \ + } \ + } while (0) +#else +#define EXPECT_INF(arg) +#endif + +#define EXPECT_DOUBLE_EQ(val1, val2) \ + do { \ + if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) { \ + fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2); \ + exit(1); \ + } \ + } while (0) + +#define EXPECT_STREQ(val1, val2) \ + do { \ + if (strcmp((val1), (val2)) != 0) { \ + fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2); \ + exit(1); \ + } \ + } while (0) + +// Call this in a .cc file where you will later call RUN_ALL_TESTS in main(). +#define TEST_INIT \ + static std::vector<void (*)()> g_testlist; /* the tests to run */ \ + static int RUN_ALL_TESTS() { \ + std::vector<void (*)()>::const_iterator it; \ + for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { \ + (*it)(); /* The test will error-exit if there's a problem. */ \ + } \ + fprintf(stderr, "\nPassed %d tests\n\nPASS\n", \ + static_cast<int>(g_testlist.size())); \ + return 0; \ + } + +// Note that this macro uses a FlagSaver to keep tests isolated. +#define TEST(a, b) \ + struct Test_##a##_##b { \ + Test_##a##_##b() { g_testlist.push_back(&Run); } \ + static void Run() { \ + FlagSaver fs; \ + fprintf(stderr, "Running test %s/%s\n", #a, #b); \ + RunTest(); \ + } \ + static void RunTest(); \ + }; \ + static Test_##a##_##b g_test_##a##_##b; \ + void Test_##a##_##b::RunTest() + +// This is a dummy class that eases the google->opensource transition. +namespace testing { +class Test {}; +} + +// Call this in a .cc file where you will later call EXPECT_DEATH +#define EXPECT_DEATH_INIT \ + static bool g_called_exit; \ + static void CalledExit(int) { g_called_exit = true; } + +#define EXPECT_DEATH(fn, msg) \ + do { \ + g_called_exit = false; \ + gflags_exitfunc = &CalledExit; \ + fn; \ + gflags_exitfunc = &exit; /* set back to its default */ \ + if (!g_called_exit) { \ + fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn); \ + exit(1); \ + } \ + } while (0) + +#define GTEST_HAS_DEATH_TEST 1 + +// -- path routines ---------------------------------------------------------- + +// Tries to create the directory path as a temp-dir. If it fails, +// changes path to some directory it *can* create. +#if defined(__MINGW32__) +#include <io.h> +inline void MakeTmpdir(std::string* path) { + // I had trouble creating a directory in /tmp from mingw + *path = "./gflags_unittest_testdir"; + mkdir(path->c_str()); // mingw has a weird one-arg mkdir +} +#elif defined(_MSC_VER) +#include <direct.h> +#include <windows.h> +inline void MakeTmpdir(std::string* path) { + char tmppath_buffer[1024]; + int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer); + assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer)); + assert(tmppath_buffer[tmppath_len - 1] == '\\'); // API guarantees it + *path = std::string(tmppath_buffer) + "gflags_unittest_testdir"; + _mkdir(path->c_str()); +} +// Windows is missing random bits like strcasecmp, strtoll, strtoull, and +// snprintf in the usual locations. Put them somewhere sensible. +// +// TODO(keir): Get the upstream Windows port and use that instead. +#define snprintf _snprintf +#undef strtoint64 +#define strtoint64 _strtoi64 +#undef strtouint64 +#define strtouint64 _strtoui64 +#define strcasecmp _stricmp +#define va_copy(dst, src) ((dst) = (src)) +#define strto64 _strtoi64 +#define strtou64 _strtoui64 +#else +inline void MakeTmpdir(std::string* path) { + mkdir(path->c_str(), 0755); +} +#endif + +// -- string routines -------------------------------------------------------- + +inline void InternalStringPrintf(std::string* output, const char* format, + va_list ap) { + char space[128]; // try a small buffer and hope it fits + + // It's possible for methods that use a va_list to invalidate + // the data in it upon use. The fix is to make a copy + // of the structure before using it and use that copy instead. + va_list backup_ap; + va_copy(backup_ap, ap); + int bytes_written = vsnprintf(space, sizeof(space), format, backup_ap); + va_end(backup_ap); + + if ((bytes_written >= 0) && (bytes_written < sizeof(space))) { + output->append(space, bytes_written); + return; + } + + // Repeatedly increase buffer size until it fits. + int length = sizeof(space); + while (true) { + if (bytes_written < 0) { + // Older snprintf() behavior. :-( Just try doubling the buffer size + length *= 2; + } else { + // We need exactly "bytes_written+1" characters + length = bytes_written+1; + } + char* buf = new char[length]; + + // Restore the va_list before we use it again + va_copy(backup_ap, ap); + bytes_written = vsnprintf(buf, length, format, backup_ap); + va_end(backup_ap); + + if ((bytes_written >= 0) && (bytes_written < length)) { + output->append(buf, bytes_written); + delete[] buf; + return; + } + delete[] buf; + } +} + +// Clears output before writing to it. +inline void SStringPrintf(std::string* output, const char* format, ...) { + va_list ap; + va_start(ap, format); + output->clear(); + InternalStringPrintf(output, format, ap); + va_end(ap); +} + +inline void StringAppendF(std::string* output, const char* format, ...) { + va_list ap; + va_start(ap, format); + InternalStringPrintf(output, format, ap); + va_end(ap); +} + +inline std::string StringPrintf(const char* format, ...) { + va_list ap; + va_start(ap, format); + std::string output; + InternalStringPrintf(&output, format, ap); + va_end(ap); + return output; +} + +_END_GOOGLE_NAMESPACE_ + +#endif // GFLAGS_UTIL_H_ diff --git a/extern/libmv/third_party/glog/ChangeLog b/extern/libmv/third_party/glog/ChangeLog index 350fee921e3..6ac0b0f0575 100644 --- a/extern/libmv/third_party/glog/ChangeLog +++ b/extern/libmv/third_party/glog/ChangeLog @@ -1,3 +1,13 @@ +2012-01-12 Google Inc. <opensource@google.com> + + * google-glog: version 0.3.2 + * Clang support. + * Demangler and stacktrace improvement for newer GCCs. + * Now fork(2) doesn't mess up log files. + * Make valgrind happier. + * Reduce warnings for more -W options. + * Provide a workaround for ERROR defined by windows.h. + 2010-06-15 Google Inc. <opensource@google.com> * google-glog: version 0.3.1 diff --git a/extern/libmv/third_party/glog/README.libmv b/extern/libmv/third_party/glog/README.libmv index 8f1243b2430..025a70b76a5 100644 --- a/extern/libmv/third_party/glog/README.libmv +++ b/extern/libmv/third_party/glog/README.libmv @@ -1,38 +1,24 @@ Project: Google Logging URL: http://code.google.com/p/google-glog/ License: New BSD -Upstream version: 0.3.1 +Upstream version: 0.3.2 Local modifications: Upgrading Notes -* Had to change #include <gflags/gflags.h> to #include "gflags/gflags.h" -* Make sure to copy over a config_YOUR_PLATFORM.h and put it in config.h - -Old changes which got obsoleted (maybe?) by 0.3.1 merge: -* The config_linux.h is generated by configure on Keir's Ubuntu 9.04 desktop. -* Commented out some struct ::tm weirdness causing compile failures on - ubuntu 8.10 and 9.04. -* Switched several initializers to memset instead of = {}. -* Changed some includes pointing to gflags. Not sure why the regular inclusion - didn't work. -* Added some compile flags to silence various warnings, allowing us to keep the - differences between upstream small. -* Don't redefine _XOPEN_SOURCE. -* Added "google::" to GetReferenceableValue in CHECK_OP_LOG. -* Add virtual destructor to Thread in googletest.h. -* Update windows/glog/log_severity to build with QT library that include WinGDI - (It cause a double definition of ERROR variable). - -Old changes which got obsoleted (maybe?) by 0.2.1 merge: -* Added #ifndef / def REG_EIP; not sure what that is. -* Added (void) arg stuff to prevent unused variable warnings. -* Added google:: namespace prefix to GetReferencableValue -* Added assignments for several functions marked with no_ignore_return, where - the return value was ignored. -* Commented out the unused function DumpPCAndSymbol() in utilities.cc to silent - gcc on the mac - -TODO(keir): Remove any obsoleted changes above if they are not necessary after -testing on more platforms. - -WARNING: Mac port not updated for 0.2.1 +* Replace <gflags/gflags.h> with "third_party/gflags/gflags/gflags.h" which is easier + to setup things in libmv and also helps with setting up building libmv into + external applications. +* Replace "glog/logging.h" and "glog/logging.h" with <glog/logging.h> and <glog/logging.h> + which is needed on Windows platform because otherwise files like logging.cc will be using + relative path which points to headers used by linux instead of headers need to be used + on Windows. +* Replace _asm int 3 with __debugbreak(). Such assembler code is obsolete and doesn't work + with 64bit versions of MSVC compilers. +* Do not use stacktrace for MinGW and FreeBSD because it leads into issues accessing + some specific data on this platforms. +* Define HAVE_LIB_GFLAGS for Windows builds. +* Do not define __declspec(dllimport) for MinGW platforms. +* Setup proper includes and datatypes for int32, uint32, int64 and uint64 for MinGW +* Do not define va_copy for MinGW platforms (it's already defined there). +* Patch localtime_r to be working fine with MinGW, disable strerror_r for MinGW because + of lack of needed functions. diff --git a/extern/libmv/third_party/glog/src/base/commandlineflags.h b/extern/libmv/third_party/glog/src/base/commandlineflags.h index 6c529ccd847..483a96ee80b 100644 --- a/extern/libmv/third_party/glog/src/base/commandlineflags.h +++ b/extern/libmv/third_party/glog/src/base/commandlineflags.h @@ -55,11 +55,11 @@ #ifdef HAVE_LIB_GFLAGS -#include "third_party/gflags/gflags.h" +#include "third_party/gflags/gflags/gflags.h" #else -#include "glog/logging.h" +#include <glog/logging.h> #define DECLARE_VARIABLE(type, name, tn) \ namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead { \ diff --git a/extern/libmv/third_party/glog/src/base/googleinit.h b/extern/libmv/third_party/glog/src/base/googleinit.h index c907308e852..5a8b515cd60 100644 --- a/extern/libmv/third_party/glog/src/base/googleinit.h +++ b/extern/libmv/third_party/glog/src/base/googleinit.h @@ -36,7 +36,7 @@ class GoogleInitializer { public: typedef void (*void_function)(void); - GoogleInitializer(const char* name, void_function f) { + GoogleInitializer(const char*, void_function f) { f(); } }; diff --git a/extern/libmv/third_party/glog/src/config.h b/extern/libmv/third_party/glog/src/config.h index 102bf9e4034..f5c9c0b0a7b 100644 --- a/extern/libmv/third_party/glog/src/config.h +++ b/extern/libmv/third_party/glog/src/config.h @@ -12,4 +12,6 @@ #include "config_linux.h" #elif defined(_MSC_VER) #include "windows/config.h" +#elif defined(__GNU__) + #include "config_hurd.h" #endif diff --git a/extern/libmv/third_party/glog/src/config_freebsd.h b/extern/libmv/third_party/glog/src/config_freebsd.h index 28fa1f1c78b..a671a0080b3 100644 --- a/extern/libmv/third_party/glog/src/config_freebsd.h +++ b/extern/libmv/third_party/glog/src/config_freebsd.h @@ -122,13 +122,13 @@ #define PACKAGE_NAME "glog" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "glog 0.3.1" +#define PACKAGE_STRING "glog 0.3.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "glog" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.3.1" +#define PACKAGE_VERSION "0.3.2" /* How to access the PC from a struct ucontext */ /* #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP] */ @@ -151,7 +151,7 @@ #define TEST_SRC_DIR "." /* Version number of package */ -#define VERSION "0.3.1" +#define VERSION "0.3.2" /* Stops putting the code inside the Google namespace */ #define _END_GOOGLE_NAMESPACE_ } @@ -159,3 +159,8 @@ /* Puts following code inside the Google namespace */ #define _START_GOOGLE_NAMESPACE_ namespace google { +/* isn't getting defined by configure script when clang compilers are used + and cuases compilation errors in stactrace/unwind modules */ +#ifdef __clang__ +# define NO_FRAME_POINTER +#endif diff --git a/extern/libmv/third_party/glog/src/config_hurd.h b/extern/libmv/third_party/glog/src/config_hurd.h new file mode 100644 index 00000000000..47aefa423d6 --- /dev/null +++ b/extern/libmv/third_party/glog/src/config_hurd.h @@ -0,0 +1,166 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Namespace for Google classes */ +#define GOOGLE_NAMESPACE google + +/* Define if you have the `dladdr' function */ +/* #undef HAVE_DLADDR */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <execinfo.h> header file. */ +#define HAVE_EXECINFO_H 1 + +/* Define if you have the `fcntl' function */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the <glob.h> header file. */ +#define HAVE_GLOB_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#define HAVE_LIBPTHREAD 1 + +/* Define to 1 if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* define if you have google gflags library */ +#define HAVE_LIB_GFLAGS 1 + +/* define if you have google gmock library */ +/* #undef HAVE_LIB_GMOCK */ + +/* define if you have google gtest library */ +/* #undef HAVE_LIB_GTEST */ + +/* define if you have libunwind */ +/* #undef HAVE_LIB_UNWIND */ + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* define if the compiler implements namespaces */ +#define HAVE_NAMESPACES 1 + +/* Define if you have POSIX threads libraries and header files. */ +#define HAVE_PTHREAD 1 + +/* Define to 1 if you have the <pwd.h> header file. */ +#define HAVE_PWD_H 1 + +/* define if the compiler implements pthread_rwlock_* */ +#define HAVE_RWLOCK 1 + +/* Define if you have the `sigaltstack' function */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <syscall.h> header file. */ +/* #undef HAVE_SYSCALL_H */ + +/* Define to 1 if you have the <syslog.h> header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/syscall.h> header file. */ +/* #undef HAVE_SYS_SYSCALL_H */ + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/ucontext.h> header file. */ +#define HAVE_SYS_UCONTEXT_H 1 + +/* Define to 1 if you have the <sys/utsname.h> header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the <ucontext.h> header file. */ +#define HAVE_UCONTEXT_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* define if the compiler supports using expression for operator */ +#define HAVE_USING_OPERATOR 1 + +/* define if your compiler has __attribute__ */ +#define HAVE___ATTRIBUTE__ 1 + +/* define if your compiler has __builtin_expect */ +#define HAVE___BUILTIN_EXPECT 1 + +/* define if your compiler has __sync_val_compare_and_swap */ +/* #undef HAVE___SYNC_VAL_COMPARE_AND_SWAP */ + +/* Name of package */ +#define PACKAGE "glog" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "opensource@google.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "glog" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "glog 0.3.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "glog" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.3.1" + +/* How to access the PC from a struct ucontext */ +#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) + #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP] +#elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) + #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_EIP] +#else + #undef PC_FROM_UCONTEXT +#endif + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* Define to 1 if you have the ANSI C header files. */ +/* #undef STDC_HEADERS */ + +#define STDC_HEADERS 1 +/* the namespace where STL code like vector<> is defined */ +#define STL_NAMESPACE std + +/* location of source code */ +#define TEST_SRC_DIR "." + +/* Version number of package */ +#define VERSION "0.3.1" + +/* Stops putting the code inside the Google namespace */ +#define _END_GOOGLE_NAMESPACE_ } + +/* Puts following code inside the Google namespace */ +#define _START_GOOGLE_NAMESPACE_ namespace google { diff --git a/extern/libmv/third_party/glog/src/config_linux.h b/extern/libmv/third_party/glog/src/config_linux.h index faf032949bb..5877029882a 100644 --- a/extern/libmv/third_party/glog/src/config_linux.h +++ b/extern/libmv/third_party/glog/src/config_linux.h @@ -112,6 +112,10 @@ /* define if your compiler has __sync_val_compare_and_swap */ /* #undef HAVE___SYNC_VAL_COMPARE_AND_SWAP */ +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + /* Name of package */ #define PACKAGE "glog" @@ -122,13 +126,16 @@ #define PACKAGE_NAME "glog" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "glog 0.3.1" +#define PACKAGE_STRING "glog 0.3.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "glog" +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.3.1" +#define PACKAGE_VERSION "0.3.2" /* How to access the PC from a struct ucontext */ #if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) @@ -157,10 +164,16 @@ #define TEST_SRC_DIR "." /* Version number of package */ -#define VERSION "0.3.1" +#define VERSION "0.3.2" /* Stops putting the code inside the Google namespace */ #define _END_GOOGLE_NAMESPACE_ } /* Puts following code inside the Google namespace */ #define _START_GOOGLE_NAMESPACE_ namespace google { + +/* isn't getting defined by configure script when clang compilers are used + and cuases compilation errors in stactrace/unwind modules */ +#ifdef __clang__ +# define NO_FRAME_POINTER +#endif diff --git a/extern/libmv/third_party/glog/src/config_mac.h b/extern/libmv/third_party/glog/src/config_mac.h index 5f953d17ba9..9756fde22f3 100644 --- a/extern/libmv/third_party/glog/src/config_mac.h +++ b/extern/libmv/third_party/glog/src/config_mac.h @@ -122,13 +122,13 @@ #define PACKAGE_NAME "glog" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "glog 0.3.1" +#define PACKAGE_STRING "glog 0.3.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "glog" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.3.1" +#define PACKAGE_VERSION "0.3.2" /* How to access the PC from a struct ucontext */ #undef PC_FROM_UCONTEXT @@ -150,10 +150,16 @@ #define TEST_SRC_DIR "." /* Version number of package */ -#define VERSION "0.3.1" +#define VERSION "0.3.2" /* Stops putting the code inside the Google namespace */ #define _END_GOOGLE_NAMESPACE_ } /* Puts following code inside the Google namespace */ #define _START_GOOGLE_NAMESPACE_ namespace google { + +/* isn't getting defined by configure script when clang compilers are used + and cuases compilation errors in stactrace/unwind modules */ +#ifdef __clang__ +# define NO_FRAME_POINTER +#endif diff --git a/extern/libmv/third_party/glog/src/demangle.cc b/extern/libmv/third_party/glog/src/demangle.cc index 46556bf3c13..0daf30893b3 100644 --- a/extern/libmv/third_party/glog/src/demangle.cc +++ b/extern/libmv/third_party/glog/src/demangle.cc @@ -28,6 +28,11 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Author: Satoru Takabayashi +// +// For reference check out: +// http://www.codesourcery.com/public/cxx-abi/abi.html#mangling +// +// Note that we only have partial C++0x support yet. #include <stdio.h> // for NULL #include "demangle.h" @@ -138,14 +143,12 @@ static const AbbrevPair kSubstitutionList[] = { // State needed for demangling. typedef struct { const char *mangled_cur; // Cursor of mangled name. - const char *mangled_end; // End of mangled name. char *out_cur; // Cursor of output string. const char *out_begin; // Beginning of output string. const char *out_end; // End of output string. const char *prev_name; // For constructors/destructors. int prev_name_length; // For constructors/destructors. - int nest_level; // For nested names. - int number; // Remember the previous number. + short nest_level; // For nested names. bool append; // Append flag. bool overflowed; // True if output gets overflowed. } State; @@ -161,6 +164,16 @@ static size_t StrLen(const char *str) { return len; } +// Returns true if "str" has at least "n" characters remaining. +static bool AtLeastNumCharsRemaining(const char *str, int n) { + for (int i = 0; i < n; ++i) { + if (str == '\0') { + return false; + } + } + return true; +} + // Returns true if "str" has "prefix" as a prefix. static bool StrPrefix(const char *str, const char *prefix) { size_t i = 0; @@ -174,39 +187,33 @@ static bool StrPrefix(const char *str, const char *prefix) { static void InitState(State *state, const char *mangled, char *out, int out_size) { state->mangled_cur = mangled; - state->mangled_end = mangled + StrLen(mangled); state->out_cur = out; state->out_begin = out; state->out_end = out + out_size; state->prev_name = NULL; state->prev_name_length = -1; state->nest_level = -1; - state->number = -1; state->append = true; state->overflowed = false; } -// Calculates the remaining length of the mangled name. -static int RemainingLength(State *state) { - return state->mangled_end - state->mangled_cur; -} - -// Returns true and advances "mangled_cur" if we find "c" at -// "mangled_cur" position. -static bool ParseChar(State *state, const char c) { - if (RemainingLength(state) >= 1 && *state->mangled_cur == c) { +// Returns true and advances "mangled_cur" if we find "one_char_token" +// at "mangled_cur" position. It is assumed that "one_char_token" does +// not contain '\0'. +static bool ParseOneCharToken(State *state, const char one_char_token) { + if (state->mangled_cur[0] == one_char_token) { ++state->mangled_cur; return true; } return false; } -// Returns true and advances "mangled_cur" if we find "two_chars" at -// "mangled_cur" position. -static bool ParseTwoChar(State *state, const char *two_chars) { - if (RemainingLength(state) >= 2 && - state->mangled_cur[0] == two_chars[0] && - state->mangled_cur[1] == two_chars[1]) { +// Returns true and advances "mangled_cur" if we find "two_char_token" +// at "mangled_cur" position. It is assumed that "two_char_token" does +// not contain '\0'. +static bool ParseTwoCharToken(State *state, const char *two_char_token) { + if (state->mangled_cur[0] == two_char_token[0] && + state->mangled_cur[1] == two_char_token[1]) { state->mangled_cur += 2; return true; } @@ -216,13 +223,13 @@ static bool ParseTwoChar(State *state, const char *two_chars) { // Returns true and advances "mangled_cur" if we find any character in // "char_class" at "mangled_cur" position. static bool ParseCharClass(State *state, const char *char_class) { - if (state->mangled_cur == state->mangled_end) { + if (state->mangled_cur == '\0') { return false; } const char *p = char_class; for (; *p != '\0'; ++p) { - if (*state->mangled_cur == *p) { - state->mangled_cur += 1; + if (state->mangled_cur[0] == *p) { + ++state->mangled_cur; return true; } } @@ -230,7 +237,7 @@ static bool ParseCharClass(State *state, const char *char_class) { } // This function is used for handling an optional non-terminal. -static bool Optional(bool status) { +static bool Optional(bool) { return true; } @@ -245,6 +252,16 @@ static bool OneOrMore(ParseFunc parse_func, State *state) { return false; } +// This function is used for handling <non-terminal>* syntax. The function +// always returns true and must be followed by a termination token or a +// terminating sequence not handled by parse_func (e.g. +// ParseOneCharToken(state, 'E')). +static bool ZeroOrMore(ParseFunc parse_func, State *state) { + while (parse_func(state)) { + } + return true; +} + // Append "str" at "out_cur". If there is an overflow, "overflowed" // is set to true for later use. The output string is ensured to // always terminate with '\0' as long as there is no overflow. @@ -270,7 +287,37 @@ static bool IsLower(char c) { } static bool IsAlpha(char c) { - return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +static bool IsDigit(char c) { + return c >= '0' && c <= '9'; +} + +// Returns true if "str" is a function clone suffix. These suffixes are used +// by GCC 4.5.x and later versions to indicate functions which have been +// cloned during optimization. We treat any sequence (.<alpha>+.<digit>+)+ as +// a function clone suffix. +static bool IsFunctionCloneSuffix(const char *str) { + size_t i = 0; + while (str[i] != '\0') { + // Consume a single .<alpha>+.<digit>+ sequence. + if (str[i] != '.' || !IsAlpha(str[i + 1])) { + return false; + } + i += 2; + while (IsAlpha(str[i])) { + ++i; + } + if (str[i] != '.' || !IsDigit(str[i + 1])) { + return false; + } + i += 2; + while (IsDigit(str[i])) { + ++i; + } + } + return true; // Consumed everything in "str". } // Append "str" with some tweaks, iff "append" state is true. @@ -309,7 +356,7 @@ static bool EnterNestedName(State *state) { } // This function is used for handling nested names. -static bool LeaveNestedName(State *state, int prev_value) { +static bool LeaveNestedName(State *state, short prev_value) { state->nest_level = prev_value; return true; } @@ -349,11 +396,11 @@ static void MaybeCancelLastSeparator(State *state) { } } -// Returns true if identifier pointed by "mangled_cur" is anonymous -// namespace. -static bool IdentifierIsAnonymousNamespace(State *state) { - const char anon_prefix[] = "_GLOBAL__N_"; - return (state->number > sizeof(anon_prefix) - 1 && // Should be longer. +// Returns true if the identifier of the given length pointed to by +// "mangled_cur" is anonymous namespace. +static bool IdentifierIsAnonymousNamespace(State *state, int length) { + static const char anon_prefix[] = "_GLOBAL__N_"; + return (length > (int)sizeof(anon_prefix) - 1 && // Should be longer. StrPrefix(state->mangled_cur, anon_prefix)); } @@ -368,10 +415,10 @@ static bool ParsePrefix(State *state); static bool ParseUnqualifiedName(State *state); static bool ParseSourceName(State *state); static bool ParseLocalSourceName(State *state); -static bool ParseNumber(State *state); +static bool ParseNumber(State *state, int *number_out); static bool ParseFloatNumber(State *state); static bool ParseSeqId(State *state); -static bool ParseIdentifier(State *state); +static bool ParseIdentifier(State *state, int length); static bool ParseOperatorName(State *state); static bool ParseSpecialName(State *state); static bool ParseCallOffset(State *state); @@ -428,17 +475,7 @@ static bool ParseSubstitution(State *state); // <mangled-name> ::= _Z <encoding> static bool ParseMangledName(State *state) { - if (ParseTwoChar(state, "_Z") && ParseEncoding(state)) { - // Append trailing version suffix if any. - // ex. _Z3foo@@GLIBCXX_3.4 - if (state->mangled_cur < state->mangled_end && - state->mangled_cur[0] == '@') { - MaybeAppend(state, state->mangled_cur); - state->mangled_cur = state->mangled_end; - } - return true; - } - return false; + return ParseTwoCharToken(state, "_Z") && ParseEncoding(state); } // <encoding> ::= <(function) name> <bare-function-type> @@ -488,7 +525,7 @@ static bool ParseUnscopedName(State *state) { } State copy = *state; - if (ParseTwoChar(state, "St") && + if (ParseTwoCharToken(state, "St") && MaybeAppend(state, "std::") && ParseUnqualifiedName(state)) { return true; @@ -507,12 +544,12 @@ static bool ParseUnscopedTemplateName(State *state) { // ::= N [<CV-qualifiers>] <template-prefix> <template-args> E static bool ParseNestedName(State *state) { State copy = *state; - if (ParseChar(state, 'N') && + if (ParseOneCharToken(state, 'N') && EnterNestedName(state) && Optional(ParseCVQualifiers(state)) && ParsePrefix(state) && LeaveNestedName(state, copy.nest_level) && - ParseChar(state, 'E')) { + ParseOneCharToken(state, 'E')) { return true; } *state = copy; @@ -565,7 +602,8 @@ static bool ParseUnqualifiedName(State *state) { // <source-name> ::= <positive length number> <identifier> static bool ParseSourceName(State *state) { State copy = *state; - if (ParseNumber(state) && ParseIdentifier(state)) { + int length = -1; + if (ParseNumber(state, &length) && ParseIdentifier(state, length)) { return true; } *state = copy; @@ -579,7 +617,7 @@ static bool ParseSourceName(State *state) { // http://gcc.gnu.org/viewcvs?view=rev&revision=124467 static bool ParseLocalSourceName(State *state) { State copy = *state; - if (ParseChar(state, 'L') && ParseSourceName(state) && + if (ParseOneCharToken(state, 'L') && ParseSourceName(state) && Optional(ParseDiscriminator(state))) { return true; } @@ -588,15 +626,17 @@ static bool ParseLocalSourceName(State *state) { } // <number> ::= [n] <non-negative decimal integer> -static bool ParseNumber(State *state) { +// If "number_out" is non-null, then *number_out is set to the value of the +// parsed number on success. +static bool ParseNumber(State *state, int *number_out) { int sign = 1; - if (ParseChar(state, 'n')) { + if (ParseOneCharToken(state, 'n')) { sign = -1; } const char *p = state->mangled_cur; int number = 0; - for (;p < state->mangled_end; ++p) { - if ((*p >= '0' && *p <= '9')) { + for (;*p != '\0'; ++p) { + if (IsDigit(*p)) { number = number * 10 + (*p - '0'); } else { break; @@ -604,7 +644,9 @@ static bool ParseNumber(State *state) { } if (p != state->mangled_cur) { // Conversion succeeded. state->mangled_cur = p; - state->number = number * sign; + if (number_out != NULL) { + *number_out = number * sign; + } return true; } return false; @@ -614,19 +656,13 @@ static bool ParseNumber(State *state) { // hexadecimal string. static bool ParseFloatNumber(State *state) { const char *p = state->mangled_cur; - int number = 0; - for (;p < state->mangled_end; ++p) { - if ((*p >= '0' && *p <= '9')) { - number = number * 16 + (*p - '0'); - } else if (*p >= 'a' && *p <= 'f') { - number = number * 16 + (*p - 'a' + 10); - } else { + for (;*p != '\0'; ++p) { + if (!IsDigit(*p) && !(*p >= 'a' && *p <= 'f')) { break; } } if (p != state->mangled_cur) { // Conversion succeeded. state->mangled_cur = p; - state->number = number; return true; } return false; @@ -636,37 +672,30 @@ static bool ParseFloatNumber(State *state) { // using digits and upper case letters static bool ParseSeqId(State *state) { const char *p = state->mangled_cur; - int number = 0; - for (;p < state->mangled_end; ++p) { - if ((*p >= '0' && *p <= '9')) { - number = number * 36 + (*p - '0'); - } else if (*p >= 'A' && *p <= 'Z') { - number = number * 36 + (*p - 'A' + 10); - } else { + for (;*p != '\0'; ++p) { + if (!IsDigit(*p) && !(*p >= 'A' && *p <= 'Z')) { break; } } if (p != state->mangled_cur) { // Conversion succeeded. state->mangled_cur = p; - state->number = number; return true; } return false; } -// <identifier> ::= <unqualified source code identifier> -static bool ParseIdentifier(State *state) { - if (state->number == -1 || - RemainingLength(state) < state->number) { +// <identifier> ::= <unqualified source code identifier> (of given length) +static bool ParseIdentifier(State *state, int length) { + if (length == -1 || + !AtLeastNumCharsRemaining(state->mangled_cur, length)) { return false; } - if (IdentifierIsAnonymousNamespace(state)) { + if (IdentifierIsAnonymousNamespace(state, length)) { MaybeAppend(state, "(anonymous namespace)"); } else { - MaybeAppendWithLength(state, state->mangled_cur, state->number); + MaybeAppendWithLength(state, state->mangled_cur, length); } - state->mangled_cur += state->number; - state->number = -1; // Reset the number. + state->mangled_cur += length; return true; } @@ -674,12 +703,12 @@ static bool ParseIdentifier(State *state) { // ::= cv <type> # (cast) // ::= v <digit> <source-name> # vendor extended operator static bool ParseOperatorName(State *state) { - if (RemainingLength(state) < 2) { + if (!AtLeastNumCharsRemaining(state->mangled_cur, 2)) { return false; } // First check with "cv" (cast) case. State copy = *state; - if (ParseTwoChar(state, "cv") && + if (ParseTwoCharToken(state, "cv") && MaybeAppend(state, "operator ") && EnterNestedName(state) && ParseType(state) && @@ -689,7 +718,7 @@ static bool ParseOperatorName(State *state) { *state = copy; // Then vendor extended operators. - if (ParseChar(state, 'v') && ParseCharClass(state, "0123456789") && + if (ParseOneCharToken(state, 'v') && ParseCharClass(state, "0123456789") && ParseSourceName(state)) { return true; } @@ -738,34 +767,34 @@ static bool ParseOperatorName(State *state) { // stack traces. The are special data. static bool ParseSpecialName(State *state) { State copy = *state; - if (ParseChar(state, 'T') && + if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "VTIS") && ParseType(state)) { return true; } *state = copy; - if (ParseTwoChar(state, "Tc") && ParseCallOffset(state) && + if (ParseTwoCharToken(state, "Tc") && ParseCallOffset(state) && ParseCallOffset(state) && ParseEncoding(state)) { return true; } *state = copy; - if (ParseTwoChar(state, "GV") && + if (ParseTwoCharToken(state, "GV") && ParseName(state)) { return true; } *state = copy; - if (ParseChar(state, 'T') && ParseCallOffset(state) && + if (ParseOneCharToken(state, 'T') && ParseCallOffset(state) && ParseEncoding(state)) { return true; } *state = copy; // G++ extensions - if (ParseTwoChar(state, "TC") && ParseType(state) && - ParseNumber(state) && ParseChar(state, '_') && + if (ParseTwoCharToken(state, "TC") && ParseType(state) && + ParseNumber(state, NULL) && ParseOneCharToken(state, '_') && DisableAppend(state) && ParseType(state)) { RestoreAppend(state, copy.append); @@ -773,23 +802,23 @@ static bool ParseSpecialName(State *state) { } *state = copy; - if (ParseChar(state, 'T') && ParseCharClass(state, "FJ") && + if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "FJ") && ParseType(state)) { return true; } *state = copy; - if (ParseTwoChar(state, "GR") && ParseName(state)) { + if (ParseTwoCharToken(state, "GR") && ParseName(state)) { return true; } *state = copy; - if (ParseTwoChar(state, "GA") && ParseEncoding(state)) { + if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) { return true; } *state = copy; - if (ParseChar(state, 'T') && ParseCharClass(state, "hv") && + if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "hv") && ParseCallOffset(state) && ParseEncoding(state)) { return true; } @@ -801,14 +830,14 @@ static bool ParseSpecialName(State *state) { // ::= v <v-offset> _ static bool ParseCallOffset(State *state) { State copy = *state; - if (ParseChar(state, 'h') && - ParseNVOffset(state) && ParseChar(state, '_')) { + if (ParseOneCharToken(state, 'h') && + ParseNVOffset(state) && ParseOneCharToken(state, '_')) { return true; } *state = copy; - if (ParseChar(state, 'v') && - ParseVOffset(state) && ParseChar(state, '_')) { + if (ParseOneCharToken(state, 'v') && + ParseVOffset(state) && ParseOneCharToken(state, '_')) { return true; } *state = copy; @@ -818,14 +847,14 @@ static bool ParseCallOffset(State *state) { // <nv-offset> ::= <(offset) number> static bool ParseNVOffset(State *state) { - return ParseNumber(state); + return ParseNumber(state, NULL); } // <v-offset> ::= <(offset) number> _ <(virtual offset) number> static bool ParseVOffset(State *state) { State copy = *state; - if (ParseNumber(state) && ParseChar(state, '_') && - ParseNumber(state)) { + if (ParseNumber(state, NULL) && ParseOneCharToken(state, '_') && + ParseNumber(state, NULL)) { return true; } *state = copy; @@ -836,7 +865,7 @@ static bool ParseVOffset(State *state) { // ::= D0 | D1 | D2 static bool ParseCtorDtorName(State *state) { State copy = *state; - if (ParseChar(state, 'C') && + if (ParseOneCharToken(state, 'C') && ParseCharClass(state, "123")) { const char * const prev_name = state->prev_name; const int prev_name_length = state->prev_name_length; @@ -845,7 +874,7 @@ static bool ParseCtorDtorName(State *state) { } *state = copy; - if (ParseChar(state, 'D') && + if (ParseOneCharToken(state, 'D') && ParseCharClass(state, "012")) { const char * const prev_name = state->prev_name; const int prev_name_length = state->prev_name_length; @@ -858,11 +887,12 @@ static bool ParseCtorDtorName(State *state) { } // <type> ::= <CV-qualifiers> <type> -// ::= P <type> -// ::= R <type> -// ::= C <type> -// ::= G <type> -// ::= U <source-name> <type> +// ::= P <type> # pointer-to +// ::= R <type> # reference-to +// ::= O <type> # rvalue reference-to (C++0x) +// ::= C <type> # complex pair (C 2000) +// ::= G <type> # imaginary (C 2000) +// ::= U <source-name> <type> # vendor extended type qualifier // ::= <builtin-type> // ::= <function-type> // ::= <class-enum-type> @@ -871,6 +901,11 @@ static bool ParseCtorDtorName(State *state) { // ::= <template-template-param> <template-args> // ::= <template-param> // ::= <substitution> +// ::= Dp <type> # pack expansion of (C++0x) +// ::= Dt <expression> E # decltype of an id-expression or class +// # member access (C++0x) +// ::= DT <expression> E # decltype of an expression (C++0x) +// static bool ParseType(State *state) { // We should check CV-qualifers, and PRGC things first. State copy = *state; @@ -879,12 +914,23 @@ static bool ParseType(State *state) { } *state = copy; - if (ParseCharClass(state, "PRCG") && ParseType(state)) { + if (ParseCharClass(state, "OPRCG") && ParseType(state)) { + return true; + } + *state = copy; + + if (ParseTwoCharToken(state, "Dp") && ParseType(state)) { return true; } *state = copy; - if (ParseChar(state, 'U') && ParseSourceName(state) && + if (ParseOneCharToken(state, 'D') && ParseCharClass(state, "tT") && + ParseExpression(state) && ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + + if (ParseOneCharToken(state, 'U') && ParseSourceName(state) && ParseType(state)) { return true; } @@ -918,9 +964,9 @@ static bool ParseType(State *state) { // ParseType(). static bool ParseCVQualifiers(State *state) { int num_cv_qualifiers = 0; - num_cv_qualifiers += ParseChar(state, 'r'); - num_cv_qualifiers += ParseChar(state, 'V'); - num_cv_qualifiers += ParseChar(state, 'K'); + num_cv_qualifiers += ParseOneCharToken(state, 'r'); + num_cv_qualifiers += ParseOneCharToken(state, 'V'); + num_cv_qualifiers += ParseOneCharToken(state, 'K'); return num_cv_qualifiers > 0; } @@ -937,7 +983,7 @@ static bool ParseBuiltinType(State *state) { } State copy = *state; - if (ParseChar(state, 'u') && ParseSourceName(state)) { + if (ParseOneCharToken(state, 'u') && ParseSourceName(state)) { return true; } *state = copy; @@ -947,8 +993,9 @@ static bool ParseBuiltinType(State *state) { // <function-type> ::= F [Y] <bare-function-type> E static bool ParseFunctionType(State *state) { State copy = *state; - if (ParseChar(state, 'F') && Optional(ParseChar(state, 'Y')) && - ParseBareFunctionType(state) && ParseChar(state, 'E')) { + if (ParseOneCharToken(state, 'F') && + Optional(ParseOneCharToken(state, 'Y')) && + ParseBareFunctionType(state) && ParseOneCharToken(state, 'E')) { return true; } *state = copy; @@ -977,14 +1024,14 @@ static bool ParseClassEnumType(State *state) { // ::= A [<(dimension) expression>] _ <(element) type> static bool ParseArrayType(State *state) { State copy = *state; - if (ParseChar(state, 'A') && ParseNumber(state) && - ParseChar(state, '_') && ParseType(state)) { + if (ParseOneCharToken(state, 'A') && ParseNumber(state, NULL) && + ParseOneCharToken(state, '_') && ParseType(state)) { return true; } *state = copy; - if (ParseChar(state, 'A') && Optional(ParseExpression(state)) && - ParseChar(state, '_') && ParseType(state)) { + if (ParseOneCharToken(state, 'A') && Optional(ParseExpression(state)) && + ParseOneCharToken(state, '_') && ParseType(state)) { return true; } *state = copy; @@ -994,7 +1041,7 @@ static bool ParseArrayType(State *state) { // <pointer-to-member-type> ::= M <(class) type> <(member) type> static bool ParsePointerToMemberType(State *state) { State copy = *state; - if (ParseChar(state, 'M') && ParseType(state) && + if (ParseOneCharToken(state, 'M') && ParseType(state) && ParseType(state)) { return true; } @@ -1005,14 +1052,14 @@ static bool ParsePointerToMemberType(State *state) { // <template-param> ::= T_ // ::= T <parameter-2 non-negative number> _ static bool ParseTemplateParam(State *state) { - if (ParseTwoChar(state, "T_")) { + if (ParseTwoCharToken(state, "T_")) { MaybeAppend(state, "?"); // We don't support template substitutions. return true; } State copy = *state; - if (ParseChar(state, 'T') && ParseNumber(state) && - ParseChar(state, '_')) { + if (ParseOneCharToken(state, 'T') && ParseNumber(state, NULL) && + ParseOneCharToken(state, '_')) { MaybeAppend(state, "?"); // We don't support template substitutions. return true; } @@ -1032,9 +1079,9 @@ static bool ParseTemplateTemplateParam(State *state) { static bool ParseTemplateArgs(State *state) { State copy = *state; DisableAppend(state); - if (ParseChar(state, 'I') && + if (ParseOneCharToken(state, 'I') && OneOrMore(ParseTemplateArg, state) && - ParseChar(state, 'E')) { + ParseOneCharToken(state, 'E')) { RestoreAppend(state, copy.append); MaybeAppend(state, "<>"); return true; @@ -1045,16 +1092,25 @@ static bool ParseTemplateArgs(State *state) { // <template-arg> ::= <type> // ::= <expr-primary> +// ::= I <template-arg>* E # argument pack // ::= X <expression> E static bool ParseTemplateArg(State *state) { + State copy = *state; + if (ParseOneCharToken(state, 'I') && + ZeroOrMore(ParseTemplateArg, state) && + ParseOneCharToken(state, 'E')) { + return true; + } + *state = copy; + if (ParseType(state) || ParseExprPrimary(state)) { return true; } + *state = copy; - State copy = *state; - if (ParseChar(state, 'X') && ParseExpression(state) && - ParseChar(state, 'E')) { + if (ParseOneCharToken(state, 'X') && ParseExpression(state) && + ParseOneCharToken(state, 'E')) { return true; } *state = copy; @@ -1097,19 +1153,19 @@ static bool ParseExpression(State *state) { } *state = copy; - if (ParseTwoChar(state, "st") && ParseType(state)) { + if (ParseTwoCharToken(state, "st") && ParseType(state)) { return true; } *state = copy; - if (ParseTwoChar(state, "sr") && ParseType(state) && + if (ParseTwoCharToken(state, "sr") && ParseType(state) && ParseUnqualifiedName(state) && ParseTemplateArgs(state)) { return true; } *state = copy; - if (ParseTwoChar(state, "sr") && ParseType(state) && + if (ParseTwoCharToken(state, "sr") && ParseType(state) && ParseUnqualifiedName(state)) { return true; } @@ -1124,28 +1180,28 @@ static bool ParseExpression(State *state) { // ::= LZ <encoding> E static bool ParseExprPrimary(State *state) { State copy = *state; - if (ParseChar(state, 'L') && ParseType(state) && - ParseNumber(state) && - ParseChar(state, 'E')) { + if (ParseOneCharToken(state, 'L') && ParseType(state) && + ParseNumber(state, NULL) && + ParseOneCharToken(state, 'E')) { return true; } *state = copy; - if (ParseChar(state, 'L') && ParseType(state) && + if (ParseOneCharToken(state, 'L') && ParseType(state) && ParseFloatNumber(state) && - ParseChar(state, 'E')) { + ParseOneCharToken(state, 'E')) { return true; } *state = copy; - if (ParseChar(state, 'L') && ParseMangledName(state) && - ParseChar(state, 'E')) { + if (ParseOneCharToken(state, 'L') && ParseMangledName(state) && + ParseOneCharToken(state, 'E')) { return true; } *state = copy; - if (ParseTwoChar(state, "LZ") && ParseEncoding(state) && - ParseChar(state, 'E')) { + if (ParseTwoCharToken(state, "LZ") && ParseEncoding(state) && + ParseOneCharToken(state, 'E')) { return true; } *state = copy; @@ -1158,15 +1214,15 @@ static bool ParseExprPrimary(State *state) { // := Z <(function) encoding> E s [<discriminator>] static bool ParseLocalName(State *state) { State copy = *state; - if (ParseChar(state, 'Z') && ParseEncoding(state) && - ParseChar(state, 'E') && MaybeAppend(state, "::") && + if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) && + ParseOneCharToken(state, 'E') && MaybeAppend(state, "::") && ParseName(state) && Optional(ParseDiscriminator(state))) { return true; } *state = copy; - if (ParseChar(state, 'Z') && ParseEncoding(state) && - ParseTwoChar(state, "Es") && Optional(ParseDiscriminator(state))) { + if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) && + ParseTwoCharToken(state, "Es") && Optional(ParseDiscriminator(state))) { return true; } *state = copy; @@ -1176,7 +1232,7 @@ static bool ParseLocalName(State *state) { // <discriminator> := _ <(non-negative) number> static bool ParseDiscriminator(State *state) { State copy = *state; - if (ParseChar(state, '_') && ParseNumber(state)) { + if (ParseOneCharToken(state, '_') && ParseNumber(state, NULL)) { return true; } *state = copy; @@ -1187,21 +1243,21 @@ static bool ParseDiscriminator(State *state) { // ::= S <seq-id> _ // ::= St, etc. static bool ParseSubstitution(State *state) { - if (ParseTwoChar(state, "S_")) { + if (ParseTwoCharToken(state, "S_")) { MaybeAppend(state, "?"); // We don't support substitutions. return true; } State copy = *state; - if (ParseChar(state, 'S') && ParseSeqId(state) && - ParseChar(state, '_')) { + if (ParseOneCharToken(state, 'S') && ParseSeqId(state) && + ParseOneCharToken(state, '_')) { MaybeAppend(state, "?"); // We don't support substitutions. return true; } *state = copy; // Expand abbreviations like "St" => "std". - if (ParseChar(state, 'S')) { + if (ParseOneCharToken(state, 'S')) { const AbbrevPair *p; for (p = kSubstitutionList; p->abbrev != NULL; ++p) { if (state->mangled_cur[0] == p->abbrev[1]) { @@ -1210,7 +1266,7 @@ static bool ParseSubstitution(State *state) { MaybeAppend(state, "::"); MaybeAppend(state, p->real_name); } - state->mangled_cur += 1; + ++state->mangled_cur; return true; } } @@ -1219,13 +1275,33 @@ static bool ParseSubstitution(State *state) { return false; } +// Parse <mangled-name>, optionally followed by either a function-clone suffix +// or version suffix. Returns true only if all of "mangled_cur" was consumed. +static bool ParseTopLevelMangledName(State *state) { + if (ParseMangledName(state)) { + if (state->mangled_cur[0] != '\0') { + // Drop trailing function clone suffix, if any. + if (IsFunctionCloneSuffix(state->mangled_cur)) { + return true; + } + // Append trailing version suffix if any. + // ex. _Z3foo@@GLIBCXX_3.4 + if (state->mangled_cur[0] == '@') { + MaybeAppend(state, state->mangled_cur); + return true; + } + return false; // Unconsumed suffix. + } + return true; + } + return false; +} + // The demangler entry point. bool Demangle(const char *mangled, char *out, int out_size) { State state; InitState(&state, mangled, out, out_size); - return (ParseMangledName(&state) && - state.overflowed == false && - RemainingLength(&state) == 0); + return ParseTopLevelMangledName(&state) && !state.overflowed; } _END_GOOGLE_NAMESPACE_ diff --git a/extern/libmv/third_party/glog/src/glog/log_severity.h b/extern/libmv/third_party/glog/src/glog/log_severity.h index 17805fbadd4..99945a426da 100644 --- a/extern/libmv/third_party/glog/src/glog/log_severity.h +++ b/extern/libmv/third_party/glog/src/glog/log_severity.h @@ -44,7 +44,15 @@ // you ever need to change their values or add a new severity. typedef int LogSeverity; -const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4; +const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3, + NUM_SEVERITIES = 4; +#ifndef GLOG_NO_ABBREVIATED_SEVERITIES +# ifdef ERROR +# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. +# endif +const int INFO = GLOG_INFO, WARNING = GLOG_WARNING, + ERROR = GLOG_ERROR, FATAL = GLOG_FATAL; +#endif // DFATAL is FATAL in debug mode, ERROR in normal mode #ifdef NDEBUG diff --git a/extern/libmv/third_party/glog/src/glog/logging.h b/extern/libmv/third_party/glog/src/glog/logging.h index a58d478ab17..005649c17c2 100644 --- a/extern/libmv/third_party/glog/src/glog/logging.h +++ b/extern/libmv/third_party/glog/src/glog/logging.h @@ -33,7 +33,6 @@ // Pretty much everybody needs to #include this file so that they can // log various happenings. // - #ifndef _LOGGING_H_ #define _LOGGING_H_ @@ -80,7 +79,7 @@ #endif #if 1 -#include "third_party/gflags/gflags.h" +#include "third_party/gflags/gflags/gflags.h" #endif namespace google { @@ -153,21 +152,21 @@ typedef unsigned __int64 uint64; // You can also do occasional logging (log every n'th occurrence of an // event): // -// LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie"; +// LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; // // The above will cause log messages to be output on the 1st, 11th, 21st, ... -// times it is executed. Note that the special COUNTER value is used to -// identify which repetition is happening. +// times it is executed. Note that the special google::COUNTER value is used +// to identify which repetition is happening. // // You can also do occasional conditional logging (log every n'th // occurrence of an event, when condition is satisfied): // -// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER +// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER // << "th big cookie"; // // You can log messages the first N times your code executes a line. E.g. // -// LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie"; +// LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie"; // // Outputs log messages for the first 20 times it is executed. // @@ -184,7 +183,7 @@ typedef unsigned __int64 uint64; // // DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; // -// DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie"; +// DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; // // All "debug mode" logging is compiled away to nothing for non-debug mode // compiles. @@ -228,11 +227,11 @@ typedef unsigned __int64 uint64; // "program with --v=1 or more"; // VLOG_EVERY_N(1, 10) // << "I'm printed every 10th occurrence, and when you run the program " -// "with --v=1 or more. Present occurence is " << COUNTER; +// "with --v=1 or more. Present occurence is " << google::COUNTER; // VLOG_IF_EVERY_N(1, (size > 1024), 10) // << "I'm printed on every 10th occurence of case when size is more " // " than 1024, when you run the program with --v=1 or more. "; -// "Present occurence is " << COUNTER; +// "Present occurence is " << google::COUNTER; // // The supported severity levels for macros that allow you to specify one // are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. @@ -369,7 +368,7 @@ DECLARE_bool(stop_logging_if_full_disk); #define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \ __FILE__, __LINE__) #define LOG_TO_STRING_INFO(message) google::LogMessage( \ - __FILE__, __LINE__, google::INFO, message) + __FILE__, __LINE__, google::GLOG_INFO, message) #else #define COMPACT_GOOGLE_LOG_INFO google::NullStream() #define LOG_TO_STRING_INFO(message) google::NullStream() @@ -377,9 +376,9 @@ DECLARE_bool(stop_logging_if_full_disk); #if GOOGLE_STRIP_LOG <= 1 #define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \ - __FILE__, __LINE__, google::WARNING) + __FILE__, __LINE__, google::GLOG_WARNING) #define LOG_TO_STRING_WARNING(message) google::LogMessage( \ - __FILE__, __LINE__, google::WARNING, message) + __FILE__, __LINE__, google::GLOG_WARNING, message) #else #define COMPACT_GOOGLE_LOG_WARNING google::NullStream() #define LOG_TO_STRING_WARNING(message) google::NullStream() @@ -387,9 +386,9 @@ DECLARE_bool(stop_logging_if_full_disk); #if GOOGLE_STRIP_LOG <= 2 #define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \ - __FILE__, __LINE__, google::ERROR) + __FILE__, __LINE__, google::GLOG_ERROR) #define LOG_TO_STRING_ERROR(message) google::LogMessage( \ - __FILE__, __LINE__, google::ERROR, message) + __FILE__, __LINE__, google::GLOG_ERROR, message) #else #define COMPACT_GOOGLE_LOG_ERROR google::NullStream() #define LOG_TO_STRING_ERROR(message) google::NullStream() @@ -399,7 +398,7 @@ DECLARE_bool(stop_logging_if_full_disk); #define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \ __FILE__, __LINE__) #define LOG_TO_STRING_FATAL(message) google::LogMessage( \ - __FILE__, __LINE__, google::FATAL, message) + __FILE__, __LINE__, google::GLOG_FATAL, message) #else #define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal() #define LOG_TO_STRING_FATAL(message) google::NullStreamFatal() @@ -411,32 +410,32 @@ DECLARE_bool(stop_logging_if_full_disk); #define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR #elif GOOGLE_STRIP_LOG <= 3 #define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \ - __FILE__, __LINE__, google::FATAL) + __FILE__, __LINE__, google::GLOG_FATAL) #else #define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal() #endif -#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog) +#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog) #define SYSLOG_INFO(counter) \ - google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_WARNING(counter) \ - google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \ &google::LogMessage::SendToLog) #define SYSLOG_WARNING(counter) \ - google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_ERROR(counter) \ - google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \ &google::LogMessage::SendToLog) #define SYSLOG_ERROR(counter) \ - google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_FATAL(counter) \ - google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \ &google::LogMessage::SendToLog) #define SYSLOG_FATAL(counter) \ - google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_DFATAL(counter) \ google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \ @@ -455,7 +454,7 @@ DECLARE_bool(stop_logging_if_full_disk); FORMAT_MESSAGE_FROM_SYSTEM, \ 0, result, 0, msg, 100, NULL); \ if (message_length > 0) { \ - google::LogMessage(__FILE__, __LINE__, ERROR, 0, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \ &google::LogMessage::SendToLog).stream() << message; \ LocalFree(message); \ } \ @@ -502,12 +501,12 @@ class LogSink; // defined below #define LOG_TO_SINK(sink, severity) \ google::LogMessage( \ __FILE__, __LINE__, \ - google::severity, \ + google::GLOG_ ## severity, \ static_cast<google::LogSink*>(sink), true).stream() #define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \ google::LogMessage( \ __FILE__, __LINE__, \ - google::severity, \ + google::GLOG_ ## severity, \ static_cast<google::LogSink*>(sink), false).stream() // If a non-NULL string pointer is given, we write this message to that string. @@ -772,7 +771,7 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false) #define GOOGLE_PLOG(severity, counter) \ google::ErrnoLogMessage( \ - __FILE__, __LINE__, google::severity, counter, \ + __FILE__, __LINE__, google::GLOG_ ## severity, counter, \ &google::LogMessage::SendToLog) #define PLOG_IF(severity, condition) \ @@ -811,7 +810,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \ if (LOG_OCCURRENCES_MOD_N == 1) \ google::LogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() #define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \ @@ -820,7 +819,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ if (condition && \ ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \ google::LogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() #define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \ @@ -829,7 +828,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \ if (LOG_OCCURRENCES_MOD_N == 1) \ google::ErrnoLogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() #define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \ @@ -838,7 +837,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ ++LOG_OCCURRENCES; \ if (LOG_OCCURRENCES <= n) \ google::LogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() namespace glog_internal_namespace_ { @@ -852,7 +851,7 @@ struct CrashReason; typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] #define LOG_EVERY_N(severity, n) \ - GOOGLE_GLOG_COMPILE_ASSERT(google::severity < \ + GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \ google::NUM_SEVERITIES, \ INVALID_REQUESTED_LOG_SEVERITY); \ SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog) @@ -872,6 +871,27 @@ struct CrashReason; // We want the special COUNTER value available for LOG_EVERY_X()'ed messages enum PRIVATE_Counter {COUNTER}; +#ifdef GLOG_NO_ABBREVIATED_SEVERITIES +// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets +// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us +// to keep using this syntax, we define this macro to do the same thing +// as COMPACT_GOOGLE_LOG_ERROR. +#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR +#define SYSLOG_0 SYSLOG_ERROR +#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR +// Needed for LOG_IS_ON(ERROR). +const LogSeverity GLOG_0 = GLOG_ERROR; +#else +// Users may include windows.h after logging.h without +// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN. +// For this case, we cannot detect if ERROR is defined before users +// actually use ERROR. Let's make an undefined symbol to warn users. +# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail +# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG +# define SYSLOG_0 GLOG_ERROR_MSG +# define LOG_TO_STRING_0 GLOG_ERROR_MSG +# define GLOG_0 GLOG_ERROR_MSG +#endif // Plus some debug-logging macros that get compiled to nothing for production @@ -1016,14 +1036,14 @@ public: # pragma warning(default: 4275) #endif public: - LogStream(char *buf, int len, int ctr) + LogStream(char *buf, int len, int ctr_in) : ostrstream(buf, len), - ctr_(ctr) { + ctr_(ctr_in) { self_ = this; } int ctr() const { return ctr_; } - void set_ctr(int ctr) { ctr_ = ctr; } + void set_ctr(int ctr_in) { ctr_ = ctr_in; } LogStream* self() const { return self_; } private: @@ -1465,7 +1485,7 @@ class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream { // converted to LogStream and the message will be computed and then // quietly discarded. template<class T> -inline NullStream& operator<<(NullStream &str, const T &value) { return str; } +inline NullStream& operator<<(NullStream &str, const T &) { return str; } // Similar to NullStream, but aborts the program (without stack // trace), like LogMessageFatal. diff --git a/extern/libmv/third_party/glog/src/glog/raw_logging.h b/extern/libmv/third_party/glog/src/glog/raw_logging.h index 9e9b3772f3b..65278f62803 100644 --- a/extern/libmv/third_party/glog/src/glog/raw_logging.h +++ b/extern/libmv/third_party/glog/src/glog/raw_logging.h @@ -68,7 +68,7 @@ namespace google { // I0821 211317 file.cc:142] RAW: status is 20 #define RAW_LOG(severity, ...) \ do { \ - switch (google::severity) { \ + switch (google::GLOG_ ## severity) { \ case 0: \ RAW_LOG_INFO(__VA_ARGS__); \ break; \ @@ -100,28 +100,28 @@ namespace google { #endif // STRIP_LOG == 0 #if STRIP_LOG == 0 -#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \ +#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__) #endif // STRIP_LOG == 0 #if STRIP_LOG <= 1 -#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING, \ +#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__) #endif // STRIP_LOG <= 1 #if STRIP_LOG <= 2 -#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR, \ +#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__) #endif // STRIP_LOG <= 2 #if STRIP_LOG <= 3 -#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL, \ +#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_FATAL(...) \ @@ -162,7 +162,7 @@ namespace google { // Stub log function used to work around for unused variable warnings when // building with STRIP_LOG > 0. -static inline void RawLogStub__(int ignored, ...) { +static inline void RawLogStub__(int /* ignored */, ...) { } // Helper function to implement RAW_LOG and RAW_VLOG diff --git a/extern/libmv/third_party/glog/src/logging.cc b/extern/libmv/third_party/glog/src/logging.cc index 1bb3867aa10..bf4d85be5b3 100644 --- a/extern/libmv/third_party/glog/src/logging.cc +++ b/extern/libmv/third_party/glog/src/logging.cc @@ -111,7 +111,7 @@ _END_GOOGLE_NAMESPACE_ // The default is ERROR instead of FATAL so that users can see problems // when they run a program without having to look in another file. DEFINE_int32(stderrthreshold, - GOOGLE_NAMESPACE::ERROR, + GOOGLE_NAMESPACE::GLOG_ERROR, "log messages at or above this level are copied to stderr in " "addition to logfiles. This flag obsoletes --alsologtostderr."); @@ -311,8 +311,10 @@ class LogDestination { static const int kNetworkBytes = 1400; static const string& hostname(); - private: + static void DeleteLogDestinations(); + + private: LogDestination(LogSeverity severity, const char* base_filename); ~LogDestination() { } @@ -503,7 +505,7 @@ inline void LogDestination::SetEmailLogging(LogSeverity min_severity, static void WriteToStderr(const char* message, size_t len) { // Avoid using cerr from this module since we may get called during // exit code, and cerr may be partially or fully destroyed by then. - write(STDERR_FILENO, message, len); + fwrite(message, len, 1, stderr); } inline void LogDestination::MaybeLogToStderr(LogSeverity severity, @@ -607,6 +609,13 @@ inline LogDestination* LogDestination::log_destination(LogSeverity severity) { return log_destinations_[severity]; } +void LogDestination::DeleteLogDestinations() { + for (int severity = 0; severity < NUM_SEVERITIES; ++severity) { + delete log_destinations_[severity]; + log_destinations_[severity] = NULL; + } +} + namespace { LogFileObject::LogFileObject(LogSeverity severity, @@ -719,14 +728,18 @@ bool LogFileObject::CreateLogfile(const char* time_pid_string) { // Make the symlink be relative (in the same dir) so that if the // entire log directory gets relocated the link is still valid. const char *linkdest = slash ? (slash + 1) : filename; - symlink(linkdest, linkpath.c_str()); // silently ignore failures + if (symlink(linkdest, linkpath.c_str()) != 0) { + // silently ignore failures + } // Make an additional link to the log file in a place specified by // FLAGS_log_link, if indicated if (!FLAGS_log_link.empty()) { linkpath = FLAGS_log_link + "/" + linkname; unlink(linkpath.c_str()); // delete old one if it exists - symlink(filename, linkpath.c_str()); // silently ignore failures + if (symlink(filename, linkpath.c_str()) != 0) { + // silently ignore failures + } } #endif } @@ -745,7 +758,8 @@ void LogFileObject::Write(bool force_flush, return; } - if (static_cast<int>(file_length_ >> 20) >= MaxLogSize()) { + if (static_cast<int>(file_length_ >> 20) >= MaxLogSize() || + PidHasChanged()) { if (file_ != NULL) fclose(file_); file_ = NULL; file_length_ = bytes_since_flush_ = 0; @@ -936,12 +950,12 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity, LogMessage::LogMessage(const char* file, int line, const CheckOpString& result) { - Init(file, line, FATAL, &LogMessage::SendToLog); + Init(file, line, GLOG_FATAL, &LogMessage::SendToLog); stream() << "Check failed: " << (*result.str_) << " "; } LogMessage::LogMessage(const char* file, int line) { - Init(file, line, INFO, &LogMessage::SendToLog); + Init(file, line, GLOG_INFO, &LogMessage::SendToLog); } LogMessage::LogMessage(const char* file, int line, LogSeverity severity) { @@ -972,7 +986,7 @@ void LogMessage::Init(const char* file, LogSeverity severity, void (LogMessage::*send_method)()) { allocated_ = NULL; - if (severity != FATAL || !exit_on_dfatal) { + if (severity != GLOG_FATAL || !exit_on_dfatal) { allocated_ = new LogMessageData(); data_ = allocated_; data_->buf_ = new char[kMaxLogMessageLen+1]; @@ -1123,7 +1137,7 @@ void ReprintFatalMessage() { // Also write to stderr WriteToStderr(fatal_message, n); } - LogDestination::LogToAllLogfiles(ERROR, fatal_time, fatal_message, n); + LogDestination::LogToAllLogfiles(GLOG_ERROR, fatal_time, fatal_message, n); } } @@ -1181,7 +1195,7 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { // If we log a FATAL message, flush all the log destinations, then toss // a signal for others to catch. We leave the logs in a state that // someone else can use them (as long as they flush afterwards) - if (data_->severity_ == FATAL && exit_on_dfatal) { + if (data_->severity_ == GLOG_FATAL && exit_on_dfatal) { if (data_->first_fatal_) { // Store crash information so that it is accessible from within signal // handlers that may be invoked later. @@ -1212,7 +1226,9 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) { LogDestination::WaitForSinks(data_); const char* message = "*** Check failure stack trace: ***\n"; - write(STDERR_FILENO, message, strlen(message)); + if (write(STDERR_FILENO, message, strlen(message)) < 0) { + // Ignore errors. + } Fail(); } } @@ -1231,27 +1247,31 @@ void LogMessage::RecordCrashReason( #endif } +#ifdef HAVE___ATTRIBUTE__ +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) +#else +# define ATTRIBUTE_NORETURN +#endif + +static void logging_fail() ATTRIBUTE_NORETURN; + static void logging_fail() { -// #if defined(_DEBUG) && defined(_MSC_VER) -// doesn't work for my laptop (sergey) -#if 0 +#if defined(_DEBUG) && defined(_MSC_VER) // When debugging on windows, avoid the obnoxious dialog and make // it possible to continue past a LOG(FATAL) in the debugger - _asm int 3 + __debugbreak(); #else abort(); #endif } -#ifdef HAVE___ATTRIBUTE__ +typedef void (*logging_fail_func_t)() ATTRIBUTE_NORETURN; + GOOGLE_GLOG_DLL_DECL -void (*g_logging_fail_func)() __attribute__((noreturn)) = &logging_fail; -#else -GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)() = &logging_fail; -#endif +logging_fail_func_t g_logging_fail_func = &logging_fail; void InstallFailureFunction(void (*fail_func)()) { - g_logging_fail_func = fail_func; + g_logging_fail_func = (logging_fail_func_t)fail_func; } void LogMessage::Fail() { @@ -1544,7 +1564,7 @@ static void GetTempDirectories(vector<string>* list) { "/tmp", }; - for (int i = 0; i < ARRAYSIZE(candidates); i++) { + for (size_t i = 0; i < ARRAYSIZE(candidates); i++) { const char *d = candidates[i]; if (!d) continue; // Empty env var @@ -1631,9 +1651,9 @@ void TruncateLogFile(const char *path, int64 limit, int64 keep) { // rather scary. // Instead just truncate the file to something we can manage if (truncate(path, 0) == -1) { - PLOG(ERROR) << "Unable to truncate " << path; + PLOG(ERROR) << "Unable to truncate " << path; } else { - LOG(ERROR) << "Truncated " << path << " due to EFBIG error"; + LOG(ERROR) << "Truncated " << path << " due to EFBIG error"; } } else { PLOG(ERROR) << "Unable to open " << path; @@ -1769,7 +1789,7 @@ int posix_strerror_r(int err, char *buf, size_t len) { } LogMessageFatal::LogMessageFatal(const char* file, int line) : - LogMessage(file, line, FATAL) {} + LogMessage(file, line, GLOG_FATAL) {} LogMessageFatal::LogMessageFatal(const char* file, int line, const CheckOpString& result) : @@ -1780,4 +1800,15 @@ LogMessageFatal::~LogMessageFatal() { LogMessage::Fail(); } +void InitGoogleLogging(const char* argv0) { + glog_internal_namespace_::InitGoogleLoggingUtilities(argv0); +} + +void ShutdownGoogleLogging() { + glog_internal_namespace_::ShutdownGoogleLoggingUtilities(); + LogDestination::DeleteLogDestinations(); + delete logging_directories_list; + logging_directories_list = NULL; +} + _END_GOOGLE_NAMESPACE_ diff --git a/extern/libmv/third_party/glog/src/raw_logging.cc b/extern/libmv/third_party/glog/src/raw_logging.cc index b179a1eded4..42676cba5de 100644 --- a/extern/libmv/third_party/glog/src/raw_logging.cc +++ b/extern/libmv/third_party/glog/src/raw_logging.cc @@ -151,7 +151,7 @@ void RawLog__(LogSeverity severity, const char* file, int line, // libc (to side-step any libc interception). // We write just once to avoid races with other invocations of RawLog__. safe_write(STDERR_FILENO, buffer, strlen(buffer)); - if (severity == FATAL) { + if (severity == GLOG_FATAL) { if (!sync_val_compare_and_swap(&crashed, false, true)) { crash_reason.filename = file; crash_reason.line_number = line; diff --git a/extern/libmv/third_party/glog/src/signalhandler.cc b/extern/libmv/third_party/glog/src/signalhandler.cc index 9fc91b3390d..e95e9e97274 100644 --- a/extern/libmv/third_party/glog/src/signalhandler.cc +++ b/extern/libmv/third_party/glog/src/signalhandler.cc @@ -34,7 +34,7 @@ #include "utilities.h" #include "stacktrace.h" #include "symbolize.h" -#include "glog/logging.h" +#include <glog/logging.h> #include <signal.h> #include <time.h> @@ -142,7 +142,9 @@ class MinimalFormatter { // Writes the given data with the size to the standard error. void WriteToStderr(const char* data, int size) { - write(STDERR_FILENO, data, size); + if (write(STDERR_FILENO, data, size) < 0) { + // Ignore errors. + } } // The writer function can be changed by InstallFailureWriter(). @@ -167,7 +169,7 @@ void DumpTimeInfo() { void DumpSignalInfo(int signal_number, siginfo_t *siginfo) { // Get the signal name. const char* signal_name = NULL; - for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { + for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { if (signal_number == kFailureSignals[i].number) { signal_name = kFailureSignals[i].name; } @@ -336,7 +338,7 @@ void InstallFailureSignalHandler() { sig_action.sa_flags |= SA_SIGINFO; sig_action.sa_sigaction = &FailureSignalHandler; - for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { + for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) { CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL)); } } diff --git a/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h b/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h index 0dc14c6506e..46002c1b019 100644 --- a/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h +++ b/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h @@ -37,7 +37,7 @@ extern "C" { #define UNW_LOCAL_ONLY #include <libunwind.h> } -#include "glog/raw_logging.h" +#include <glog/raw_logging.h> #include "stacktrace.h" _START_GOOGLE_NAMESPACE_ diff --git a/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h b/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h index e3729e1fd39..f7d1dca85bc 100644 --- a/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h +++ b/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h @@ -33,10 +33,6 @@ extern "C" { #include <stdlib.h> // for NULL -#if defined(__FreeBSD__) -/* devel/libunwind only includes _Unwind_Backtrace if this is set */ -#define _GNU_SOURCE 1 -#endif #include <unwind.h> // ABI defined unwinder } #include "stacktrace.h" diff --git a/extern/libmv/third_party/glog/src/symbolize.cc b/extern/libmv/third_party/glog/src/symbolize.cc index 3465de6c6fe..d1831e4ea79 100644 --- a/extern/libmv/third_party/glog/src/symbolize.cc +++ b/extern/libmv/third_party/glog/src/symbolize.cc @@ -82,8 +82,8 @@ static ATTRIBUTE_NOINLINE void DemangleInplace(char *out, int out_size) { char demangled[256]; // Big enough for sane demangled symbols. if (Demangle(out, demangled, sizeof(demangled))) { // Demangling succeeded. Copy to out if the space allows. - int len = strlen(demangled); - if (len + 1 <= out_size) { // +1 for '\0'. + size_t len = strlen(demangled); + if (len + 1 <= (size_t)out_size) { // +1 for '\0'. SAFE_ASSERT(len < sizeof(demangled)); memmove(out, demangled, len + 1); } @@ -111,7 +111,7 @@ _END_GOOGLE_NAMESPACE_ #include "symbolize.h" #include "config.h" -#include "glog/raw_logging.h" +#include <glog/raw_logging.h> // Re-runs fn until it doesn't cause EINTR. #define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR) @@ -637,7 +637,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out, int out_size) { Dl_info info; if (dladdr(pc, &info)) { - if (strlen(info.dli_sname) < out_size) { + if ((int)strlen(info.dli_sname) < out_size) { strcpy(out, info.dli_sname); // Symbolization succeeded. Now we try to demangle the symbol. DemangleInplace(out, out_size); diff --git a/extern/libmv/third_party/glog/src/symbolize.h b/extern/libmv/third_party/glog/src/symbolize.h index 1ebe4dd94a2..04e482bc315 100644 --- a/extern/libmv/third_party/glog/src/symbolize.h +++ b/extern/libmv/third_party/glog/src/symbolize.h @@ -56,7 +56,7 @@ #include "utilities.h" #include "config.h" -#include "glog/logging.h" +#include <glog/logging.h> #ifdef HAVE_SYMBOLIZE diff --git a/extern/libmv/third_party/glog/src/utilities.cc b/extern/libmv/third_party/glog/src/utilities.cc index 6d64b923703..c9db2b7f7cd 100644 --- a/extern/libmv/third_party/glog/src/utilities.cc +++ b/extern/libmv/third_party/glog/src/utilities.cc @@ -77,9 +77,11 @@ typedef void DebugWriter(const char*, void*); // For some environments, add two extra bytes for the leading "0x". static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*); -static void DebugWriteToStderr(const char* data, void *unused) { +static void DebugWriteToStderr(const char* data, void *) { // This one is signal-safe. - write(STDERR_FILENO, data, strlen(data)); + if (write(STDERR_FILENO, data, strlen(data)) < 0) { + // Ignore errors. + } } void DebugWriteToString(const char* data, void *arg) { @@ -221,8 +223,17 @@ int32 GetMainThreadPid() { return g_main_thread_pid; } +bool PidHasChanged() { + int32 pid = getpid(); + if (g_main_thread_pid == pid) { + return false; + } + g_main_thread_pid = pid; + return true; +} + pid_t GetTID() { - // On Linux and FreeBSD, we try to use gettid(). + // On Linux and MACOSX , we try to use gettid(). #if defined OS_LINUX || defined OS_MACOSX #ifndef __NR_gettid #ifdef OS_MACOSX @@ -245,7 +256,7 @@ pid_t GetTID() { // the value change to "true". lacks_gettid = true; } -#endif // OS_LINUX || OS_FREEBSD +#endif // OS_LINUX || OS_MACOSX // If gettid() could not be used, we use one of the following. #if defined OS_LINUX @@ -302,9 +313,7 @@ void SetCrashReason(const CrashReason* r) { r); } -} // namespace glog_internal_namespace_ - -void InitGoogleLogging(const char* argv0) { +void InitGoogleLoggingUtilities(const char* argv0) { CHECK(!IsGoogleLoggingInitialized()) << "You called InitGoogleLogging() twice!"; const char* slash = strrchr(argv0, '/'); @@ -319,14 +328,16 @@ void InitGoogleLogging(const char* argv0) { #endif } -void ShutdownGoogleLogging() { +void ShutdownGoogleLoggingUtilities() { CHECK(IsGoogleLoggingInitialized()) - << "You called ShutdownGoogleLogging() without InitGoogleLogging() first!"; + << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!"; #ifdef HAVE_SYSLOG_H closelog(); #endif } +} // namespace glog_internal_namespace_ + _END_GOOGLE_NAMESPACE_ // Make an implementation of stacktrace compiled. diff --git a/extern/libmv/third_party/glog/src/utilities.h b/extern/libmv/third_party/glog/src/utilities.h index bbb0eb0746c..c8215b73f33 100644 --- a/extern/libmv/third_party/glog/src/utilities.h +++ b/extern/libmv/third_party/glog/src/utilities.h @@ -161,6 +161,7 @@ typedef double WallTime; WallTime WallTime_Now(); int32 GetMainThreadPid(); +bool PidHasChanged(); pid_t GetTID(); @@ -215,6 +216,9 @@ struct CrashReason { void SetCrashReason(const CrashReason* r); +void InitGoogleLoggingUtilities(const char* argv0); +void ShutdownGoogleLoggingUtilities(); + } // namespace glog_internal_namespace_ _END_GOOGLE_NAMESPACE_ diff --git a/extern/libmv/third_party/glog/src/vlog_is_on.cc b/extern/libmv/third_party/glog/src/vlog_is_on.cc index ed88514dce5..5eefc96324a 100644 --- a/extern/libmv/third_party/glog/src/vlog_is_on.cc +++ b/extern/libmv/third_party/glog/src/vlog_is_on.cc @@ -70,8 +70,8 @@ GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern, size_t patt_len, const char* str, size_t str_len) { - int p = 0; - int s = 0; + size_t p = 0; + size_t s = 0; while (1) { if (p == patt_len && s == str_len) return true; if (p == patt_len) return false; @@ -211,7 +211,7 @@ bool InitVLOG3__(int32** site_flag, int32* site_default, const char* base = strrchr(fname, '/'); base = base ? (base+1) : fname; const char* base_end = strchr(base, '.'); - size_t base_length = base_end ? (base_end - base) : strlen(base); + size_t base_length = base_end ? size_t(base_end - base) : strlen(base); // Trim out trailing "-inl" if any if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) { diff --git a/extern/libmv/third_party/glog/src/windows/glog/log_severity.h b/extern/libmv/third_party/glog/src/windows/glog/log_severity.h index 5e7d09effb2..22a4191ab8b 100644 --- a/extern/libmv/third_party/glog/src/windows/glog/log_severity.h +++ b/extern/libmv/third_party/glog/src/windows/glog/log_severity.h @@ -48,7 +48,15 @@ // you ever need to change their values or add a new severity. typedef int LogSeverity; -const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4; +const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3, + NUM_SEVERITIES = 4; +#ifndef GLOG_NO_ABBREVIATED_SEVERITIES +# ifdef ERROR +# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. +# endif +const int INFO = GLOG_INFO, WARNING = GLOG_WARNING, + ERROR = GLOG_ERROR, FATAL = GLOG_FATAL; +#endif // DFATAL is FATAL in debug mode, ERROR in normal mode #ifdef NDEBUG diff --git a/extern/libmv/third_party/glog/src/windows/glog/logging.h b/extern/libmv/third_party/glog/src/windows/glog/logging.h index 2f41681edbe..f623cd9e793 100644 --- a/extern/libmv/third_party/glog/src/windows/glog/logging.h +++ b/extern/libmv/third_party/glog/src/windows/glog/logging.h @@ -83,7 +83,7 @@ #endif #if 1 -#include "third_party/gflags/gflags.h" +#include "third_party/gflags/gflags/gflags.h" #endif #ifdef __MINGW32__ @@ -170,21 +170,21 @@ typedef uint64_t uint64; // You can also do occasional logging (log every n'th occurrence of an // event): // -// LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie"; +// LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; // // The above will cause log messages to be output on the 1st, 11th, 21st, ... -// times it is executed. Note that the special COUNTER value is used to -// identify which repetition is happening. +// times it is executed. Note that the special google::COUNTER value is used +// to identify which repetition is happening. // // You can also do occasional conditional logging (log every n'th // occurrence of an event, when condition is satisfied): // -// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER +// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER // << "th big cookie"; // // You can log messages the first N times your code executes a line. E.g. // -// LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie"; +// LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie"; // // Outputs log messages for the first 20 times it is executed. // @@ -201,7 +201,7 @@ typedef uint64_t uint64; // // DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; // -// DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie"; +// DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie"; // // All "debug mode" logging is compiled away to nothing for non-debug mode // compiles. @@ -245,11 +245,11 @@ typedef uint64_t uint64; // "program with --v=1 or more"; // VLOG_EVERY_N(1, 10) // << "I'm printed every 10th occurrence, and when you run the program " -// "with --v=1 or more. Present occurence is " << COUNTER; +// "with --v=1 or more. Present occurence is " << google::COUNTER; // VLOG_IF_EVERY_N(1, (size > 1024), 10) // << "I'm printed on every 10th occurence of case when size is more " // " than 1024, when you run the program with --v=1 or more. "; -// "Present occurence is " << COUNTER; +// "Present occurence is " << google::COUNTER; // // The supported severity levels for macros that allow you to specify one // are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. @@ -386,7 +386,7 @@ DECLARE_bool(stop_logging_if_full_disk); #define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \ __FILE__, __LINE__) #define LOG_TO_STRING_INFO(message) google::LogMessage( \ - __FILE__, __LINE__, google::INFO, message) + __FILE__, __LINE__, google::GLOG_INFO, message) #else #define COMPACT_GOOGLE_LOG_INFO google::NullStream() #define LOG_TO_STRING_INFO(message) google::NullStream() @@ -394,9 +394,9 @@ DECLARE_bool(stop_logging_if_full_disk); #if GOOGLE_STRIP_LOG <= 1 #define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \ - __FILE__, __LINE__, google::WARNING) + __FILE__, __LINE__, google::GLOG_WARNING) #define LOG_TO_STRING_WARNING(message) google::LogMessage( \ - __FILE__, __LINE__, google::WARNING, message) + __FILE__, __LINE__, google::GLOG_WARNING, message) #else #define COMPACT_GOOGLE_LOG_WARNING google::NullStream() #define LOG_TO_STRING_WARNING(message) google::NullStream() @@ -404,9 +404,9 @@ DECLARE_bool(stop_logging_if_full_disk); #if GOOGLE_STRIP_LOG <= 2 #define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \ - __FILE__, __LINE__, google::ERROR) + __FILE__, __LINE__, google::GLOG_ERROR) #define LOG_TO_STRING_ERROR(message) google::LogMessage( \ - __FILE__, __LINE__, google::ERROR, message) + __FILE__, __LINE__, google::GLOG_ERROR, message) #else #define COMPACT_GOOGLE_LOG_ERROR google::NullStream() #define LOG_TO_STRING_ERROR(message) google::NullStream() @@ -416,7 +416,7 @@ DECLARE_bool(stop_logging_if_full_disk); #define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \ __FILE__, __LINE__) #define LOG_TO_STRING_FATAL(message) google::LogMessage( \ - __FILE__, __LINE__, google::FATAL, message) + __FILE__, __LINE__, google::GLOG_FATAL, message) #else #define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal() #define LOG_TO_STRING_FATAL(message) google::NullStreamFatal() @@ -428,32 +428,32 @@ DECLARE_bool(stop_logging_if_full_disk); #define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR #elif GOOGLE_STRIP_LOG <= 3 #define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \ - __FILE__, __LINE__, google::FATAL) + __FILE__, __LINE__, google::GLOG_FATAL) #else #define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal() #endif -#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog) +#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog) #define SYSLOG_INFO(counter) \ - google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_WARNING(counter) \ - google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \ &google::LogMessage::SendToLog) #define SYSLOG_WARNING(counter) \ - google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_ERROR(counter) \ - google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \ &google::LogMessage::SendToLog) #define SYSLOG_ERROR(counter) \ - google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_FATAL(counter) \ - google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \ &google::LogMessage::SendToLog) #define SYSLOG_FATAL(counter) \ - google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \ &google::LogMessage::SendToSyslogAndLog) #define GOOGLE_LOG_DFATAL(counter) \ google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \ @@ -472,7 +472,7 @@ DECLARE_bool(stop_logging_if_full_disk); FORMAT_MESSAGE_FROM_SYSTEM, \ 0, result, 0, msg, 100, NULL); \ if (message_length > 0) { \ - google::LogMessage(__FILE__, __LINE__, ERROR, 0, \ + google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \ &google::LogMessage::SendToLog).stream() << message; \ LocalFree(message); \ } \ @@ -519,12 +519,12 @@ class LogSink; // defined below #define LOG_TO_SINK(sink, severity) \ google::LogMessage( \ __FILE__, __LINE__, \ - google::severity, \ + google::GLOG_ ## severity, \ static_cast<google::LogSink*>(sink), true).stream() #define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \ google::LogMessage( \ __FILE__, __LINE__, \ - google::severity, \ + google::GLOG_ ## severity, \ static_cast<google::LogSink*>(sink), false).stream() // If a non-NULL string pointer is given, we write this message to that string. @@ -789,7 +789,7 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false) #define GOOGLE_PLOG(severity, counter) \ google::ErrnoLogMessage( \ - __FILE__, __LINE__, google::severity, counter, \ + __FILE__, __LINE__, google::GLOG_ ## severity, counter, \ &google::LogMessage::SendToLog) #define PLOG_IF(severity, condition) \ @@ -828,7 +828,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \ if (LOG_OCCURRENCES_MOD_N == 1) \ google::LogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() #define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \ @@ -837,7 +837,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ if (condition && \ ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \ google::LogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() #define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \ @@ -846,7 +846,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \ if (LOG_OCCURRENCES_MOD_N == 1) \ google::ErrnoLogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() #define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \ @@ -855,7 +855,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \ ++LOG_OCCURRENCES; \ if (LOG_OCCURRENCES <= n) \ google::LogMessage( \ - __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \ + __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \ &what_to_do).stream() namespace glog_internal_namespace_ { @@ -869,7 +869,7 @@ struct CrashReason; typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] #define LOG_EVERY_N(severity, n) \ - GOOGLE_GLOG_COMPILE_ASSERT(google::severity < \ + GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \ google::NUM_SEVERITIES, \ INVALID_REQUESTED_LOG_SEVERITY); \ SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog) @@ -889,6 +889,27 @@ struct CrashReason; // We want the special COUNTER value available for LOG_EVERY_X()'ed messages enum PRIVATE_Counter {COUNTER}; +#ifdef GLOG_NO_ABBREVIATED_SEVERITIES +// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets +// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us +// to keep using this syntax, we define this macro to do the same thing +// as COMPACT_GOOGLE_LOG_ERROR. +#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR +#define SYSLOG_0 SYSLOG_ERROR +#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR +// Needed for LOG_IS_ON(ERROR). +const LogSeverity GLOG_0 = GLOG_ERROR; +#else +// Users may include windows.h after logging.h without +// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN. +// For this case, we cannot detect if ERROR is defined before users +// actually use ERROR. Let's make an undefined symbol to warn users. +# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail +# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG +# define SYSLOG_0 GLOG_ERROR_MSG +# define LOG_TO_STRING_0 GLOG_ERROR_MSG +# define GLOG_0 GLOG_ERROR_MSG +#endif // Plus some debug-logging macros that get compiled to nothing for production @@ -1033,14 +1054,14 @@ public: # pragma warning(default: 4275) #endif public: - LogStream(char *buf, int len, int ctr) + LogStream(char *buf, int len, int ctr_in) : ostrstream(buf, len), - ctr_(ctr) { + ctr_(ctr_in) { self_ = this; } int ctr() const { return ctr_; } - void set_ctr(int ctr) { ctr_ = ctr; } + void set_ctr(int ctr_in) { ctr_ = ctr_in; } LogStream* self() const { return self_; } private: @@ -1482,7 +1503,7 @@ class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream { // converted to LogStream and the message will be computed and then // quietly discarded. template<class T> -inline NullStream& operator<<(NullStream &str, const T &value) { return str; } +inline NullStream& operator<<(NullStream &str, const T &) { return str; } // Similar to NullStream, but aborts the program (without stack // trace), like LogMessageFatal. diff --git a/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h b/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h index c81e67bf99c..4757a719db7 100644 --- a/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h +++ b/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h @@ -72,7 +72,7 @@ namespace google { // I0821 211317 file.cc:142] RAW: status is 20 #define RAW_LOG(severity, ...) \ do { \ - switch (google::severity) { \ + switch (google::GLOG_ ## severity) { \ case 0: \ RAW_LOG_INFO(__VA_ARGS__); \ break; \ @@ -104,28 +104,28 @@ namespace google { #endif // STRIP_LOG == 0 #if STRIP_LOG == 0 -#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \ +#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__) #endif // STRIP_LOG == 0 #if STRIP_LOG <= 1 -#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING, \ +#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__) #endif // STRIP_LOG <= 1 #if STRIP_LOG <= 2 -#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR, \ +#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__) #endif // STRIP_LOG <= 2 #if STRIP_LOG <= 3 -#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL, \ +#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \ __FILE__, __LINE__, __VA_ARGS__) #else #define RAW_LOG_FATAL(...) \ @@ -166,7 +166,7 @@ namespace google { // Stub log function used to work around for unused variable warnings when // building with STRIP_LOG > 0. -static inline void RawLogStub__(int ignored, ...) { +static inline void RawLogStub__(int /* ignored */, ...) { } // Helper function to implement RAW_LOG and RAW_VLOG diff --git a/extern/libmv/third_party/glog/src/windows/port.h b/extern/libmv/third_party/glog/src/windows/port.h index d5078120009..abfcf65384c 100644 --- a/extern/libmv/third_party/glog/src/windows/port.h +++ b/extern/libmv/third_party/glog/src/windows/port.h @@ -59,16 +59,14 @@ * used by both C and C++ code, so we put all the C++ together. */ -#if _MSC_VER - /* 4244: otherwise we get problems when substracting two size_t's to an int - * 4251: it's complaining about a private struct I've chosen not to dllexport - * 4355: we use this in a constructor, but we do it safely - * 4715: for some reason VC++ stopped realizing you can't return after abort() - * 4800: we know we're casting ints/char*'s to bools, and we're ok with that - * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror() - */ -# pragma warning(disable:4244 4251 4355 4715 4800 4996) -#endif +/* 4244: otherwise we get problems when substracting two size_t's to an int + * 4251: it's complaining about a private struct I've chosen not to dllexport + * 4355: we use this in a constructor, but we do it safely + * 4715: for some reason VC++ stopped realizing you can't return after abort() + * 4800: we know we're casting ints/char*'s to bools, and we're ok with that + * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror() + */ +#pragma warning(disable:4244 4251 4355 4715 4800 4996) /* file I/O */ #define PATH_MAX 1024 diff --git a/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp b/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp index bf59cd89dda..a02211816a2 100644 --- a/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp +++ b/extern/recastnavigation/Detour/Source/DetourStatNavMesh.cpp @@ -465,7 +465,7 @@ int dtStatNavMesh::raycast(dtStatPolyRef centerRef, const float* startPos, const if (!m_header) return 0; if (!centerRef) return 0; - dtStatPolyRef prevRef = centerRef; + /* dtStatPolyRef prevRef = centerRef; */ /* UNUSED */ dtStatPolyRef curRef = centerRef; t = 0; @@ -506,7 +506,7 @@ int dtStatNavMesh::raycast(dtStatPolyRef centerRef, const float* startPos, const } // No hit, advance to neighbour polygon. - prevRef = curRef; + /* prevRef = curRef; */ /* UNUSED */ curRef = nextRef; } @@ -566,7 +566,7 @@ float dtStatNavMesh::findDistanceToWall(dtStatPolyRef centerRef, const float* ce hitPos[2] = vj[2] + (vi[2] - vj[2])*tseg; } - // Check to see if teh circle expands to one of the neighbours and expand. + // Check to see if the circle expands to one of the neighbours and expand. for (int i = 0, j = (int)poly->nv-1; i < (int)poly->nv; j = i++) { // Skip solid edges. diff --git a/extern/recastnavigation/Recast/Source/RecastLayers.cpp b/extern/recastnavigation/Recast/Source/RecastLayers.cpp index 617cf45fe66..2d9658b2bed 100644 --- a/extern/recastnavigation/Recast/Source/RecastLayers.cpp +++ b/extern/recastnavigation/Recast/Source/RecastLayers.cpp @@ -368,7 +368,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, rcLayerRegion& rj = regs[j]; if (!rj.base) continue; - // Skip if teh regions are not close to each other. + // Skip if the regions are not close to each other. if (!overlapRange(ri.ymin,ri.ymax+mergeHeight, rj.ymin,rj.ymax+mergeHeight)) continue; // Skip if the height range would become too large. diff --git a/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp b/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp index 126529e9779..3922c864eba 100644 --- a/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp +++ b/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp @@ -70,7 +70,7 @@ static bool circumCircle(const float* p1, const float* p2, const float* p3, const float cp = vcross2(p1, p2, p3); if (fabsf(cp) > EPS) - { + { const float p1Sq = vdot2(p1,p1); const float p2Sq = vdot2(p2,p2); const float p3Sq = vdot2(p3,p3); @@ -78,7 +78,7 @@ static bool circumCircle(const float* p1, const float* p2, const float* p3, c[2] = (p1Sq*(p3[0]-p2[0]) + p2Sq*(p1[0]-p3[0]) + p3Sq*(p2[0]-p1[0])) / (2*cp); r = vdist2(c, p1); return true; - } + } c[0] = p1[0]; c[2] = p1[2]; |