summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 23:41:36 +0200
committerGitHub <noreply@github.com>2017-08-18 23:41:36 +0200
commit1013aba3cd5dd8b4e5ef051b1a160e1d3137f49d (patch)
tree6de911b96f2ff0ce1709cf58f6891e80a011916b
parent8c7c676d39f802fb6e4a03c3efdfeb1bfb040797 (diff)
parentbe621ff4d3124c54fe86577a672f73522fd3323c (diff)
Merge pull request #3145 from vespa-engine/balder/reduce-includes-and-visibility
Balder/reduce includes and visibility
-rw-r--r--config/src/apps/vespa-get-config/getconfig.cpp2
-rw-r--r--config/src/tests/configgen/value_converter.cpp1
-rw-r--r--config/src/tests/frtconnectionpool/frtconnectionpool.cpp1
-rw-r--r--config/src/tests/functiontest/functiontest.cpp4
-rw-r--r--config/src/tests/misc/configsystem.cpp1
-rw-r--r--config/src/tests/print/print.cpp1
-rw-r--r--config/src/vespa/config/common/configvalue.h11
-rw-r--r--config/src/vespa/config/frt/frtconfigagent.cpp8
-rw-r--r--config/src/vespa/config/subscription/configsubscriptionset.cpp4
-rw-r--r--configd/src/apps/sentinel/config-handler.cpp2
-rw-r--r--configd/src/apps/sentinel/sentinel.cpp2
-rw-r--r--configd/src/apps/sentinel/service.cpp2
-rw-r--r--configutil/src/lib/modelinspect.cpp1
-rw-r--r--document/src/tests/bucketselectortest.cpp2
-rw-r--r--document/src/tests/documenttestcase.cpp1
-rw-r--r--document/src/tests/documentupdatetestcase.cpp2
-rw-r--r--document/src/tests/fieldpathupdatetestcase.cpp2
-rw-r--r--document/src/tests/fieldsettest.cpp6
-rw-r--r--document/src/tests/heapdebuggerlinux.cpp2
-rw-r--r--document/src/tests/predicate/predicate_test.cpp7
-rw-r--r--document/src/tests/primitivefieldvaluetest.cpp1
-rw-r--r--document/src/tests/serialization/annotationserializer_test.cpp1
-rw-r--r--document/src/vespa/document/base/idstring.cpp1
-rw-r--r--document/src/vespa/document/bucket/bucketid.cpp1
-rw-r--r--document/src/vespa/document/bucket/bucketidfactory.cpp6
-rw-r--r--document/src/vespa/document/bucket/bucketselector.cpp1
-rw-r--r--document/src/vespa/document/fieldvalue/document.cpp1
-rw-r--r--document/src/vespa/document/fieldvalue/mapfieldvalue.cpp1
-rw-r--r--document/src/vespa/document/fieldvalue/serializablearray.cpp1
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp1
-rw-r--r--document/src/vespa/document/predicate/predicate.cpp1
-rw-r--r--document/src/vespa/document/select/valuenodes.cpp1
-rw-r--r--documentapi/src/tests/messages/messages50test.h2
-rw-r--r--documentapi/src/tests/messages/messages51test.h2
-rw-r--r--documentapi/src/tests/messages/testbase.cpp4
-rw-r--r--documentapi/src/tests/priority/priority.cpp1
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp1
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp1
-rw-r--r--eval/src/vespa/eval/eval/basic_nodes.h104
-rw-r--r--eval/src/vespa/eval/eval/test/eval_spec.cpp9
-rw-r--r--eval/src/vespa/eval/eval/value_type.cpp7
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_builder.cpp10
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_reduce.hpp9
-rw-r--r--eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp8
-rw-r--r--eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.cpp8
-rw-r--r--eval/src/vespa/eval/tensor/tensor_mapper.cpp12
-rw-r--r--fastlib/src/vespa/fastlib/io/bufferedfile.cpp2
-rw-r--r--fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp1
-rw-r--r--fastlib/src/vespa/fastlib/net/httpserver.cpp1
-rw-r--r--fastlib/src/vespa/fastlib/text/normwordfolder.cpp1
-rw-r--r--fastlib/src/vespa/fastlib/util/tests/base64test.cpp1
-rw-r--r--fastos/src/tests/backtracetest.cpp4
-rw-r--r--fastos/src/tests/coretest.cpp8
-rw-r--r--fastos/src/tests/coretest2.cpp8
-rw-r--r--fastos/src/tests/filetest.cpp6
-rw-r--r--fastos/src/tests/job.h18
-rw-r--r--fastos/src/tests/performancetest.cpp4
-rw-r--r--fastos/src/tests/prefetchtest.cpp4
-rw-r--r--fastos/src/tests/processtest.cpp28
-rw-r--r--fastos/src/tests/sockettest.cpp43
-rw-r--r--fastos/src/tests/tests.h1
-rw-r--r--fastos/src/tests/thread_bounce_test.cpp2
-rw-r--r--fastos/src/tests/thread_joinwait_test.cpp6
-rw-r--r--fastos/src/tests/thread_mutex_test.cpp14
-rw-r--r--fastos/src/tests/thread_sleep_test.cpp6
-rw-r--r--fastos/src/tests/thread_stats_test.cpp2
-rw-r--r--fastos/src/tests/thread_test_base.hpp8
-rw-r--r--fastos/src/tests/threadtest.cpp42
-rw-r--r--fastos/src/tests/timetest.cpp2
-rw-r--r--fastos/src/tests/typetest.cpp38
-rw-r--r--fastos/src/tests/usecputest.cpp2
-rw-r--r--fastos/src/vespa/fastos/CMakeLists.txt1
-rw-r--r--fastos/src/vespa/fastos/app.cpp42
-rw-r--r--fastos/src/vespa/fastos/cond.h4
-rw-r--r--fastos/src/vespa/fastos/dynamiclibrary.h4
-rw-r--r--fastos/src/vespa/fastos/file.cpp44
-rw-r--r--fastos/src/vespa/fastos/file.h52
-rw-r--r--fastos/src/vespa/fastos/linux_file.cpp14
-rw-r--r--fastos/src/vespa/fastos/linux_file.h5
-rw-r--r--fastos/src/vespa/fastos/mutex.h13
-rw-r--r--fastos/src/vespa/fastos/process.cpp26
-rw-r--r--fastos/src/vespa/fastos/process.h35
-rw-r--r--fastos/src/vespa/fastos/serversocket.cpp86
-rw-r--r--fastos/src/vespa/fastos/serversocket.h30
-rw-r--r--fastos/src/vespa/fastos/socket.cpp48
-rw-r--r--fastos/src/vespa/fastos/socket.h21
-rw-r--r--fastos/src/vespa/fastos/socketevent.cpp39
-rw-r--r--fastos/src/vespa/fastos/socketevent.h14
-rw-r--r--fastos/src/vespa/fastos/thread.cpp48
-rw-r--r--fastos/src/vespa/fastos/thread.h22
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp6
-rw-r--r--fastos/src/vespa/fastos/types.h107
-rw-r--r--fastos/src/vespa/fastos/unix_app.cpp65
-rw-r--r--fastos/src/vespa/fastos/unix_app.h34
-rw-r--r--fastos/src/vespa/fastos/unix_cond.cpp9
-rw-r--r--fastos/src/vespa/fastos/unix_dynamiclibrary.cpp16
-rw-r--r--fastos/src/vespa/fastos/unix_dynamiclibrary.h6
-rw-r--r--fastos/src/vespa/fastos/unix_file.cpp21
-rw-r--r--fastos/src/vespa/fastos/unix_file.h18
-rw-r--r--fastos/src/vespa/fastos/unix_ipc.cpp50
-rw-r--r--fastos/src/vespa/fastos/unix_mutex.cpp5
-rw-r--r--fastos/src/vespa/fastos/unix_mutex.h4
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp188
-rw-r--r--fastos/src/vespa/fastos/unix_process.h91
-rw-r--r--fastos/src/vespa/fastos/unix_socket.cpp10
-rw-r--r--fastos/src/vespa/fastos/unix_socket.h10
-rw-r--r--fastos/src/vespa/fastos/unix_thread.cpp28
-rw-r--r--fastos/src/vespa/fastos/unix_thread.h18
-rw-r--r--fastos/src/vespa/fastos/unix_time.cpp4
-rw-r--r--fbench/src/fbench/client.cpp6
-rw-r--r--fbench/src/fbench/client.h12
-rw-r--r--fbench/src/fbench/fbench.cpp7
-rw-r--r--fbench/src/filterfile/filterfile.cpp2
-rw-r--r--fbench/src/httpclient/httpclient.cpp2
-rw-r--r--fbench/src/test/clientstatus.cpp3
-rw-r--r--fbench/src/test/filereader.cpp2
-rw-r--r--fbench/src/test/httpclient.cpp2
-rw-r--r--fbench/src/test/httpclient_splitstring.cpp1
-rw-r--r--fnet/src/tests/examples/examples_test.cpp1
-rw-r--r--fnet/src/vespa/fnet/iocomponent.cpp3
-rw-r--r--fnet/src/vespa/fnet/packetqueue.cpp1
-rw-r--r--fnet/src/vespa/fnet/transport_thread.cpp1
-rw-r--r--fsa/src/libfsa/automaton-alternate.h2
-rw-r--r--fsa/src/vespa/fsa/automaton.h2
-rw-r--r--fsa/src/vespa/fsa/conceptnet.h2
-rw-r--r--fsa/src/vespa/fsa/unicode.cpp2
-rw-r--r--fsa/src/vespa/fsamanagers/mutex.cpp2
-rw-r--r--fsa/src/vespa/fsamanagers/rwlock.cpp2
-rw-r--r--juniper/src/vespa/juniper/hashbase.h2
-rw-r--r--logd/src/apps/logd/main.cpp20
-rw-r--r--logd/src/logd/service.cpp2
-rw-r--r--logd/src/logd/watch.cpp9
-rw-r--r--logd/src/tests/forward/forward.cpp2
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp6
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/device.cpp9
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp1
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp1
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h10
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/locationreadplanner.cpp7
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_verifier.cpp1
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp2
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecompactor.cpp13
-rw-r--r--memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp10
-rw-r--r--metrics/src/vespa/metrics/jsonwriter.cpp11
-rw-r--r--metrics/src/vespa/metrics/loadmetric.hpp1
-rw-r--r--metrics/src/vespa/metrics/metric.cpp2
-rw-r--r--metrics/src/vespa/metrics/metric.h1
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp1
-rw-r--r--metrics/src/vespa/metrics/metricset.cpp11
-rw-r--r--metrics/src/vespa/metrics/metricset.h10
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.cpp4
-rw-r--r--metrics/src/vespa/metrics/summetric.hpp5
-rw-r--r--metrics/src/vespa/metrics/valuemetricvalues.h1
-rw-r--r--persistence/src/vespa/persistence/conformancetest/conformancetest.cpp9
-rw-r--r--persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp1
-rw-r--r--persistence/src/vespa/persistence/dummyimpl/dummypersistence.h1
-rw-r--r--persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp2
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h8
-rw-r--r--searchcore/src/apps/fdispatch/fdispatch.cpp1
-rw-r--r--searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp3
-rw-r--r--searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp4
-rw-r--r--searchcore/src/tests/proton/attribute/attributeflush_test.cpp5
-rw-r--r--searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp8
-rw-r--r--searchcore/src/tests/proton/index/diskindexcleaner_test.cpp3
-rw-r--r--searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/search_path.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/config_hash.hpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flush_all_strategy.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/prepare_restart_flush_strategy.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_registrator.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp20
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp9
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/frozenbuckets.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/bucketdocuments.h11
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp7
-rw-r--r--searchlib/src/apps/docstore/benchmarkdatastore.cpp1
-rw-r--r--searchlib/src/apps/uniform/uniform.cpp1
-rw-r--r--searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp3
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp3
-rw-r--r--searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp6
-rw-r--r--searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp14
-rw-r--r--searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp14
-rw-r--r--searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp2
-rw-r--r--searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp36
-rw-r--r--searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp7
-rw-r--r--searchlib/src/tests/postinglistbm/andstress.cpp9
-rw-r--r--searchlib/src/tests/postinglistbm/andstress.h19
-rw-r--r--searchlib/src/tests/postinglistbm/postinglistbm.cpp2
-rw-r--r--searchlib/src/tests/query/query-old-large.cpp2
-rw-r--r--searchlib/src/tests/sort/uca.cpp9
-rw-r--r--searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp1
-rw-r--r--searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp11
-rw-r--r--searchlib/src/tests/util/statefile/statefile_test.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/btree/btreetraits.h12
-rw-r--r--searchlib/src/vespa/searchlib/common/address_space.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/common/allocatedbitvector.h2
-rw-r--r--searchlib/src/vespa/searchlib/common/bitvectorcache.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/common/indexmetainfo.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/common/location.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/common/partialbitvector.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/common/partialbitvector.h2
-rw-r--r--searchlib/src/vespa/searchlib/common/rankedhit.h4
-rw-r--r--searchlib/src/vespa/searchlib/common/resultset.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/common/tunefileinfo.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/common/tunefileinfo.h24
-rw-r--r--searchlib/src/vespa/searchlib/common/tunefileinfo.hpp35
-rw-r--r--searchlib/src/vespa/searchlib/datastore/array_store.hpp1
-rw-r--r--searchlib/src/vespa/searchlib/datastore/buffer_type.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/datastore/buffer_type.h8
-rw-r--r--searchlib/src/vespa/searchlib/datastore/datastorebase.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/fileheader.cpp55
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/diskindex/wordnummapper.h1
-rw-r--r--searchlib/src/vespa/searchlib/docstore/storebybucket.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/docstore/visitcache.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/features/array_parser.h6
-rw-r--r--searchlib/src/vespa/searchlib/features/array_parser.hpp7
-rw-r--r--searchlib/src/vespa/searchlib/features/utils.h1
-rw-r--r--searchlib/src/vespa/searchlib/fef/indexproperties.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/fef/rank_program.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/fef/simpletermdata.h2
-rw-r--r--searchlib/src/vespa/searchlib/fef/termfieldmatchdata.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/index/dictionaryfile.h1
-rw-r--r--searchlib/src/vespa/searchlib/predicate/simple_index.hpp8
-rw-r--r--searchlib/src/vespa/searchlib/query/queryterm.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/unpackinfo.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/test/initrange.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/util/comprbuffer.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/util/dirtraverse.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/util/filealign.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/util/fileutil.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/util/rawbuf.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/util/stringenum.cpp1
-rw-r--r--slobrok/src/apps/slobrok/slobrok.cpp1
-rw-r--r--staging_vespalib/src/tests/array/allocinarray_benchmark.cpp2
-rw-r--r--staging_vespalib/src/tests/array/sort_benchmark.cpp3
-rw-r--r--staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp2
-rw-r--r--staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp3
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp13
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/shutdownguard.h10
-rw-r--r--storage/src/tests/distributor/bucketdatabasetest.cpp5
-rw-r--r--storage/src/tests/distributor/simplemaintenancescannertest.cpp6
-rw-r--r--storage/src/tests/persistence/splitbitdetectortest.cpp1
-rw-r--r--storage/src/tests/storageserver/documentapiconvertertest.cpp1
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketinfo.cpp1
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/visitororder.h6
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergelimiter.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/operationtargetresolverimpl.h7
-rw-r--r--storage/src/vespa/storage/distributor/pendingclusterstate.cpp1
-rw-r--r--storage/src/vespa/storage/frameworkimpl/memory/memorystatusviewer.cpp2
-rw-r--r--storage/src/vespa/storage/persistence/bucketprocessor.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.cpp3
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/splitbitdetector.cpp1
-rw-r--r--storage/src/vespa/storage/storageserver/distributornode.h6
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/servicelayernode.h4
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.cpp27
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.h53
-rw-r--r--storage/src/vespa/storage/storageutil/resumeguard.h4
-rw-r--r--storage/src/vespa/storage/tools/generatedistributionbits.cpp1
-rw-r--r--storage/src/vespa/storage/tools/throttlingsim.cpp1
-rw-r--r--storage/src/vespa/storage/visiting/visitormessagesessionfactory.h2
-rw-r--r--storageapi/src/vespa/storageapi/message/batch.cpp1
-rw-r--r--storageapi/src/vespa/storageapi/message/bucketsplitting.cpp8
-rw-r--r--storageapi/src/vespa/storageapi/message/visitor.cpp7
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h11
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp10
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp10
-rw-r--r--storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp6
-rw-r--r--storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h18
-rw-r--r--storageserver/src/apps/storaged/storage.cpp2
-rw-r--r--storageserver/src/tests/storageservertest.cpp2
-rw-r--r--storageserver/src/vespa/storageserver/app/distributorprocess.cpp17
-rw-r--r--storageserver/src/vespa/storageserver/app/process.cpp11
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/hitcollector.cpp1
-rw-r--r--vdslib/src/tests/container/documentlisttest.cpp2
-rw-r--r--vdslib/src/vespa/vdslib/container/documentlist.cpp1
-rw-r--r--vdslib/src/vespa/vdslib/container/documentsummary.cpp1
-rw-r--r--vdslib/src/vespa/vdslib/container/searchresult.cpp1
-rw-r--r--vdslib/src/vespa/vdslib/distribution/group.cpp1
-rw-r--r--vdslib/src/vespa/vdslib/thread/taskscheduler.cpp1
-rw-r--r--vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp2
-rw-r--r--vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp1
-rw-r--r--vespalib/src/tests/alloc/allocate_and_core.cpp2
-rw-r--r--vespalib/src/tests/exception_classes/mmap.cpp2
-rw-r--r--vespalib/src/tests/executor/stress_test.cpp5
-rw-r--r--vespalib/src/tests/guard/guard_test.cpp3
-rw-r--r--vespalib/src/tests/net/selector/selector_test.cpp1
-rw-r--r--vespalib/src/tests/net/socket/socket_test.cpp2
-rw-r--r--vespalib/src/tests/signalhandler/signalhandler_test.cpp7
-rw-r--r--vespalib/src/tests/stllike/hash_test.cpp1
-rw-r--r--vespalib/src/tests/stllike/string_test.cpp1
-rw-r--r--vespalib/src/tests/text/utf8/utf8_test.cpp8
-rw-r--r--vespalib/src/tests/zcurve/zcurve_test.cpp40
-rw-r--r--vespalib/src/vespa/vespalib/data/slime/inspector.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/data/slime/strfmt.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp9
-rw-r--r--vespalib/src/vespa/vespalib/io/fileutil.cpp3
-rw-r--r--vespalib/src/vespa/vespalib/net/socket_handle.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp1
-rw-r--r--vespalib/src/vespa/vespalib/test/socket_options_verifier.h11
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_kit.h1
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_master.cpp1
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.cpp1
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.h8
-rw-r--r--vespalib/src/vespa/vespalib/util/array.h7
-rw-r--r--vespalib/src/vespa/vespalib/util/array.hpp5
-rw-r--r--vespalib/src/vespa/vespalib/util/arrayqueue.hpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/backtrace.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/compress.h11
-rw-r--r--vespalib/src/vespa/vespalib/util/generationhandler.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/linkedptr.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/signalhandler.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/slaveproc.cpp1
-rw-r--r--vespalib/src/vespa/vespalib/util/stringfmt.h1
-rw-r--r--vespalib/src/vespa/vespalib/util/sync.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp28
-rw-r--r--vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h36
-rw-r--r--vespalib/src/vespa/vespalib/util/valgrind.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/websocket/request.cpp7
-rw-r--r--vespalog/src/logger/runserver.cpp2
-rw-r--r--vespalog/src/test/logtest.cpp2
-rw-r--r--vespalog/src/test/simple/logtest.cpp2
-rw-r--r--vespalog/src/test/threads/testthreads.cpp3
-rw-r--r--vespalog/src/vespa-logfmt/logfilter.c2
-rw-r--r--vespalog/src/vespa/log/log.cpp4
-rw-r--r--vespalog/src/vespa/log/log.h6
-rw-r--r--vespamalloc/src/tests/doubledelete/expectsignal.cpp1
-rw-r--r--vespamalloc/src/tests/overwrite/expectsignal.cpp1
-rw-r--r--vespamalloc/src/tests/test.cpp2
-rw-r--r--vespamalloc/src/tests/thread/racemanythreads.cpp1
-rw-r--r--vespamalloc/src/tests/thread/thread.cpp1
-rw-r--r--vespamalloc/src/vespamalloc/malloc/memorywatcher.h2
-rw-r--r--vespamalloc/src/vespamalloc/util/traceutil.h4
360 files changed, 1524 insertions, 1504 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp
index 2a8a66f41d9..342b2b497bb 100644
--- a/config/src/apps/vespa-get-config/getconfig.cpp
+++ b/config/src/apps/vespa-get-config/getconfig.cpp
@@ -239,7 +239,7 @@ GetConfig::Main()
printf("configID %s\n", rKey.getConfigId().c_str());
printf("configMD5 %s\n", rState.md5.c_str());
- printf("generation %" PRId64 "\n", rState.generation);
+ printf("generation %ld\n", rState.generation);
printf("trace %s\n", response->getTrace().toString().c_str());
} else if (traceLevel > 0) {
printf("trace %s\n", response->getTrace().toString().c_str());
diff --git a/config/src/tests/configgen/value_converter.cpp b/config/src/tests/configgen/value_converter.cpp
index 1034d0821fd..8c969b77271 100644
--- a/config/src/tests/configgen/value_converter.cpp
+++ b/config/src/tests/configgen/value_converter.cpp
@@ -3,6 +3,7 @@
#include <vespa/config/configgen/value_converter.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/data/slime/slime.h>
+#include <climits>
using namespace config;
using namespace config::internal;
diff --git a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
index c14cdbbbc23..79ec1ee42f4 100644
--- a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
+++ b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
@@ -5,6 +5,7 @@
#include <vespa/fnet/frt/error.h>
#include <sstream>
#include <set>
+#include <unistd.h>
using namespace config;
diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp
index 7fe87775f74..257e131534b 100644
--- a/config/src/tests/functiontest/functiontest.cpp
+++ b/config/src/tests/functiontest/functiontest.cpp
@@ -37,8 +37,8 @@ checkVariableAccess(const FunctionTestConfig & config)
EXPECT_EQUAL(1u, config.boolarr.size());
EXPECT_EQUAL(0u, config.intarr.size());
EXPECT_EQUAL(2u, config.longarr.size());
- LOG(error, "0: %" PRId64, config.longarr[0]);
- LOG(error, "1: %" PRId64, config.longarr[1]);
+ LOG(error, "0: %ld", config.longarr[0]);
+ LOG(error, "1: %ld", config.longarr[1]);
EXPECT_EQUAL(std::numeric_limits<int64_t>::max(), config.longarr[0]);
EXPECT_EQUAL(std::numeric_limits<int64_t>::min(), config.longarr[1]);
EXPECT_EQUAL(2u, config.doublearr.size());
diff --git a/config/src/tests/misc/configsystem.cpp b/config/src/tests/misc/configsystem.cpp
index f0f526265ca..9574d9d274a 100644
--- a/config/src/tests/misc/configsystem.cpp
+++ b/config/src/tests/misc/configsystem.cpp
@@ -3,6 +3,7 @@
#include <vespa/config/common/configsystem.h>
#include <vespa/defaults.h>
#include <vespa/fastos/file.h>
+#include <unistd.h>
using namespace config;
diff --git a/config/src/tests/print/print.cpp b/config/src/tests/print/print.cpp
index e058b91822e..9df4bcf4914 100644
--- a/config/src/tests/print/print.cpp
+++ b/config/src/tests/print/print.cpp
@@ -8,6 +8,7 @@
#include <vespa/config/helper/configgetter.hpp>
#include "config-my.h"
#include "config-motd.h"
+#include <sys/stat.h>
using namespace config;
diff --git a/config/src/vespa/config/common/configvalue.h b/config/src/vespa/config/common/configvalue.h
index 53780dce533..7bbd48df258 100644
--- a/config/src/vespa/config/common/configvalue.h
+++ b/config/src/vespa/config/common/configvalue.h
@@ -1,17 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/config/frt/protocol.h>
+#include <vespa/config/configgen/configpayload.h>
#include <vespa/vespalib/stllike/string.h>
#include <vector>
#include <memory>
-#include <vespa/config/frt/protocol.h>
-#include <vespa/config/configgen/configpayload.h>
+#include <climits>
-namespace vespalib {
- namespace slime {
- class Cursor;
- }
-}
+namespace vespalib::slime { class Cursor; }
namespace config {
diff --git a/config/src/vespa/config/frt/frtconfigagent.cpp b/config/src/vespa/config/frt/frtconfigagent.cpp
index d5c662d1bda..ff16ef77a1b 100644
--- a/config/src/vespa/config/frt/frtconfigagent.cpp
+++ b/config/src/vespa/config/frt/frtconfigagent.cpp
@@ -26,7 +26,7 @@ FRTConfigAgent::handleResponse(const ConfigRequest & request, ConfigResponse::UP
{
if (LOG_WOULD_LOG(spam)) {
const ConfigKey & key(request.getKey());
- LOG(spam, "current state for %s: generation %" PRId64 " md5 %s", key.toString().c_str(), _configState.generation, _configState.md5.c_str());
+ LOG(spam, "current state for %s: generation %ld md5 %s", key.toString().c_str(), _configState.generation, _configState.md5.c_str());
}
if (response->validateResponse() && !response->isError()) {
handleOKResponse(std::move(response));
@@ -57,7 +57,7 @@ void
FRTConfigAgent::handleUpdatedGeneration(const ConfigKey & key, const ConfigState & newState, const ConfigValue & configValue)
{
if (LOG_WOULD_LOG(spam)) {
- LOG(spam, "new generation %" PRId64 " for key %s", newState.generation, key.toString().c_str());
+ LOG(spam, "new generation %ld for key %s", newState.generation, key.toString().c_str());
}
_configState.generation = newState.generation;
bool hasDifferentPayload = newState.hasDifferentPayloadFrom(_configState);
@@ -84,7 +84,7 @@ FRTConfigAgent::handleErrorResponse(const ConfigRequest & request, ConfigRespons
setWaitTime(_numConfigured > 0 ? _timingValues.configuredErrorDelay : _timingValues.unconfiguredDelay, multiplier);
_nextTimeout = _timingValues.errorTimeout;
const ConfigKey & key(request.getKey());
- LOG(info, "Error response or no response from config server (key: %s) (errcode=%d, validresponse:%d), trying again in %" PRId64 " milliseconds", key.toString().c_str(), response->errorCode(), response->hasValidResponse() ? 1 : 0, _waitTime);
+ LOG(info, "Error response or no response from config server (key: %s) (errcode=%d, validresponse:%d), trying again in %ld milliseconds", key.toString().c_str(), response->errorCode(), response->hasValidResponse() ? 1 : 0, _waitTime);
}
void
@@ -92,7 +92,7 @@ FRTConfigAgent::setWaitTime(uint64_t delay, int multiplier)
{
uint64_t prevWait = _waitTime;
_waitTime = _timingValues.fixedDelay + (multiplier * delay);
- LOG(spam, "Adjusting waittime from %" PRId64 " to %" PRId64, prevWait, _waitTime);
+ LOG(spam, "Adjusting waittime from %ld to %ld", prevWait, _waitTime);
}
uint64_t FRTConfigAgent::getTimeout() const { return _nextTimeout; }
diff --git a/config/src/vespa/config/subscription/configsubscriptionset.cpp b/config/src/vespa/config/subscription/configsubscriptionset.cpp
index 170bacf104d..51c29823664 100644
--- a/config/src/vespa/config/subscription/configsubscriptionset.cpp
+++ b/config/src/vespa/config/subscription/configsubscriptionset.cpp
@@ -67,7 +67,7 @@ ConfigSubscriptionSet::acquireSnapshot(uint64_t timeoutInMillis, bool ignoreChan
} else {
LOG(spam, "Config subscription did not change, id(%s), defname(%s)", key.getConfigId().c_str(), key.getDefName().c_str());
}
- LOG(spam, "Previous generation is %" PRId64 ", updates is %" PRId64, generation, subscription->getGeneration());
+ LOG(spam, "Previous generation is %ld, updates is %ld", generation, subscription->getGeneration());
if (isGenerationNewer(subscription->getGeneration(), _currentGeneration)) {
numGenerationChanged++;
}
@@ -88,7 +88,7 @@ ConfigSubscriptionSet::acquireSnapshot(uint64_t timeoutInMillis, bool ignoreChan
bool updated = inSync && isGenerationNewer(lastGeneration, _currentGeneration);
if (updated) {
- LOG(spam, "Config was updated from %" PRId64 " to %" PRId64, _currentGeneration, lastGeneration);
+ LOG(spam, "Config was updated from %ld to %ld", _currentGeneration, lastGeneration);
_currentGeneration = lastGeneration;
_state = CONFIGURED;
for (SubscriptionList::iterator it(_subscriptionList.begin()), mt(_subscriptionList.end());
diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp
index de03f34c5ed..1075bc4d7ce 100644
--- a/configd/src/apps/sentinel/config-handler.cpp
+++ b/configd/src/apps/sentinel/config-handler.cpp
@@ -6,6 +6,8 @@
#include <vespa/vespalib/net/simple_metric_snapshot.h>
#include <vespa/vespalib/net/socket_address.h>
+#include <fcntl.h>
+#include <sys/wait.h>
#include <vespa/log/log.h>
LOG_SETUP(".config-handler");
diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp
index 61aec8b3376..45bbbe19cf3 100644
--- a/configd/src/apps/sentinel/sentinel.cpp
+++ b/configd/src/apps/sentinel/sentinel.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/config/common/exceptions.h>
-#include <signal.h>
+#include <csignal>
#include <unistd.h>
#include <sys/time.h>
#include <vespa/defaults.h>
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index 492616c2db4..fc1f768f989 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -4,7 +4,7 @@
#include "output-connection.h"
#include <vespa/vespalib/util/stringfmt.h>
-#include <signal.h>
+#include <csignal>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
diff --git a/configutil/src/lib/modelinspect.cpp b/configutil/src/lib/modelinspect.cpp
index de21a0f4388..bf0536a9d4c 100644
--- a/configutil/src/lib/modelinspect.cpp
+++ b/configutil/src/lib/modelinspect.cpp
@@ -5,6 +5,7 @@
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/config/common/exceptions.h>
#include <iostream>
+#include <algorithm>
using configdefinitions::tagsContain;
using configdefinitions::upcase;
diff --git a/document/src/tests/bucketselectortest.cpp b/document/src/tests/bucketselectortest.cpp
index d2a66737d19..0f8520745f1 100644
--- a/document/src/tests/bucketselectortest.cpp
+++ b/document/src/tests/bucketselectortest.cpp
@@ -6,7 +6,7 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/document/select/parser.h>
#include <vespa/document/base/testdocrepo.h>
-#include <memory>
+#include <algorithm>
using document::select::Node;
using document::select::Parser;
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp
index 32503ac0bd0..44cff2c80de 100644
--- a/document/src/tests/documenttestcase.cpp
+++ b/document/src/tests/documenttestcase.cpp
@@ -13,6 +13,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/document/util/serializableexceptions.h>
#include <vespa/document/util/bytebuffer.h>
+#include <fcntl.h>
using vespalib::nbostream;
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index 2324d21cd24..b6aca1ec8be 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -25,6 +25,8 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exception.h>
+#include <fcntl.h>
+#include <unistd.h>
using namespace document::config_builder;
using vespalib::tensor::Tensor;
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp
index fc94c5e63eb..70f16eccfe1 100644
--- a/document/src/tests/fieldpathupdatetestcase.cpp
+++ b/document/src/tests/fieldpathupdatetestcase.cpp
@@ -13,7 +13,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/document/serialization/vespadocumentserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
-
+#include <fcntl.h>
using vespalib::Identifiable;
using namespace document::config_builder;
diff --git a/document/src/tests/fieldsettest.cpp b/document/src/tests/fieldsettest.cpp
index 0599ce723a6..3711ff05535 100644
--- a/document/src/tests/fieldsettest.cpp
+++ b/document/src/tests/fieldsettest.cpp
@@ -2,17 +2,13 @@
#include <vespa/document/base/testdocman.h>
#include <vespa/document/fieldset/fieldsetrepo.h>
-#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vdstestlib/cppunit/macros.h>
-#include <vespa/document/annotation/spantree.h>
-#include <vespa/document/config/config-documenttypes.h>
#include <vespa/document/datatype/annotationreferencedatatype.h>
#include <vespa/document/repo/configbuilder.h>
-#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <fstream>
+#include <algorithm>
using vespalib::nbostream;
diff --git a/document/src/tests/heapdebuggerlinux.cpp b/document/src/tests/heapdebuggerlinux.cpp
index 125bb2cce24..1b9b2e48e1a 100644
--- a/document/src/tests/heapdebuggerlinux.cpp
+++ b/document/src/tests/heapdebuggerlinux.cpp
@@ -22,7 +22,7 @@
#include <iostream>
#include <pthread.h>
-#include <signal.h>
+#include <csignal>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
diff --git a/document/src/tests/predicate/predicate_test.cpp b/document/src/tests/predicate/predicate_test.cpp
index e8db197fdad..6da866cb154 100644
--- a/document/src/tests/predicate/predicate_test.cpp
+++ b/document/src/tests/predicate/predicate_test.cpp
@@ -1,15 +1,16 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Unit tests for predicate.
-#include <vespa/log/log.h>
-LOG_SETUP("predicate_test");
-
#include <vespa/document/predicate/predicate.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/document/predicate/predicate_slime_builder.h>
#include <string>
+#include <climits>
+
+#include <vespa/log/log.h>
+LOG_SETUP("predicate_test");
using std::string;
using std::vector;
diff --git a/document/src/tests/primitivefieldvaluetest.cpp b/document/src/tests/primitivefieldvaluetest.cpp
index 39abba58e6f..3d74c9e539b 100644
--- a/document/src/tests/primitivefieldvaluetest.cpp
+++ b/document/src/tests/primitivefieldvaluetest.cpp
@@ -5,6 +5,7 @@
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/document/util/bytebuffer.h>
+#include <limits>
using vespalib::nbostream;
diff --git a/document/src/tests/serialization/annotationserializer_test.cpp b/document/src/tests/serialization/annotationserializer_test.cpp
index 9f045980f92..317b090c671 100644
--- a/document/src/tests/serialization/annotationserializer_test.cpp
+++ b/document/src/tests/serialization/annotationserializer_test.cpp
@@ -13,6 +13,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/fastos/file.h>
#include <fstream>
+#include <algorithm>
using document::DocumenttypesConfig;
diff --git a/document/src/vespa/document/base/idstring.cpp b/document/src/vespa/document/base/idstring.cpp
index 4118ccb88af..9c64ac6a648 100644
--- a/document/src/vespa/document/base/idstring.cpp
+++ b/document/src/vespa/document/base/idstring.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/bucket/bucketid.h>
#include <vespa/vespalib/util/md5.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <limits>
using vespalib::string;
using vespalib::stringref;
diff --git a/document/src/vespa/document/bucket/bucketid.cpp b/document/src/vespa/document/bucket/bucketid.cpp
index c9572e43eb4..ddea0d4ba85 100644
--- a/document/src/vespa/document/bucket/bucketid.cpp
+++ b/document/src/vespa/document/bucket/bucketid.cpp
@@ -7,6 +7,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/hash_set.hpp>
#include <vespa/vespalib/util/stringfmt.h>
+#include <limits>
using vespalib::nbostream;
using vespalib::asciistream;
diff --git a/document/src/vespa/document/bucket/bucketidfactory.cpp b/document/src/vespa/document/bucket/bucketidfactory.cpp
index fe8acf24e18..0d7ad9da71e 100644
--- a/document/src/vespa/document/bucket/bucketidfactory.cpp
+++ b/document/src/vespa/document/bucket/bucketidfactory.cpp
@@ -1,11 +1,11 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/document/bucket/bucketidfactory.h>
-
-#include <vespa/document/bucket/bucketid.h>
+#include "bucketidfactory.h"
+#include "bucketid.h"
#include <vespa/document/base/documentid.h>
#include <ostream>
#include <cassert>
+#include <limits>
namespace document {
diff --git a/document/src/vespa/document/bucket/bucketselector.cpp b/document/src/vespa/document/bucket/bucketselector.cpp
index 5589efa1a5f..5ded691269a 100644
--- a/document/src/vespa/document/bucket/bucketselector.cpp
+++ b/document/src/vespa/document/bucket/bucketselector.cpp
@@ -9,6 +9,7 @@
#include <vespa/document/select/branch.h>
#include <vespa/document/select/compare.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <algorithm>
namespace document {
diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp
index ddb3e66af23..acbb2e800cb 100644
--- a/document/src/vespa/document/fieldvalue/document.cpp
+++ b/document/src/vespa/document/fieldvalue/document.cpp
@@ -12,6 +12,7 @@
#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/util/xmlstream.h>
#include <sstream>
+#include <limits>
using vespalib::nbostream;
using vespalib::make_string;
diff --git a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp
index 081d0325a6e..8e5a641ab6e 100644
--- a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp
@@ -8,6 +8,7 @@
#include <vespa/vespalib/util/xmlstream.h>
#include <vespa/vespalib/stllike/hash_set.hpp>
#include <cassert>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".document.fieldvalue.map");
diff --git a/document/src/vespa/document/fieldvalue/serializablearray.cpp b/document/src/vespa/document/fieldvalue/serializablearray.cpp
index ac1cabc82c0..76216d75f1b 100644
--- a/document/src/vespa/document/fieldvalue/serializablearray.cpp
+++ b/document/src/vespa/document/fieldvalue/serializablearray.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/util/compressor.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/data/databuffer.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".document.serializable-array");
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index adb6fb9fa4e..c0ae342fd34 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -12,6 +12,7 @@
#include <vespa/document/base/exceptions.h>
#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/util/xmlstream.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".document.structfieldvalue");
diff --git a/document/src/vespa/document/predicate/predicate.cpp b/document/src/vespa/document/predicate/predicate.cpp
index 3e44cd649b7..df4128246a9 100644
--- a/document/src/vespa/document/predicate/predicate.cpp
+++ b/document/src/vespa/document/predicate/predicate.cpp
@@ -3,6 +3,7 @@
#include "predicate.h"
#include <vespa/vespalib/data/slime/slime.h>
#include <set>
+#include <climits>
using std::mismatch;
using std::pair;
diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp
index cc5ec08dc73..479896f9124 100644
--- a/document/src/vespa/document/select/valuenodes.cpp
+++ b/document/src/vespa/document/select/valuenodes.cpp
@@ -13,6 +13,7 @@
#include <vespa/vespalib/text/lowercase.h>
#include <regex>
#include <iomanip>
+#include <sys/time.h>
#include <vespa/log/log.h>
diff --git a/documentapi/src/tests/messages/messages50test.h b/documentapi/src/tests/messages/messages50test.h
index 642dad8d734..8711264ee7a 100644
--- a/documentapi/src/tests/messages/messages50test.h
+++ b/documentapi/src/tests/messages/messages50test.h
@@ -6,7 +6,7 @@
class Messages50Test : public TestBase {
protected:
const vespalib::Version getVersion() const override { return vespalib::Version(5, 0); }
- bool shouldTestCoverage() const override { return FALSE; }
+ bool shouldTestCoverage() const override { return false; }
bool tryDocumentReply(const string &filename, uint32_t type);
bool tryVisitorReply(const string &filename, uint32_t type);
diff --git a/documentapi/src/tests/messages/messages51test.h b/documentapi/src/tests/messages/messages51test.h
index 6ad1573f4f5..897491af892 100644
--- a/documentapi/src/tests/messages/messages51test.h
+++ b/documentapi/src/tests/messages/messages51test.h
@@ -6,7 +6,7 @@
class Messages51Test : public Messages50Test {
protected:
const vespalib::Version getVersion() const override { return vespalib::Version(5, 1); }
- bool shouldTestCoverage() const override { return TRUE; }
+ bool shouldTestCoverage() const override { return true; }
public:
Messages51Test();
diff --git a/documentapi/src/tests/messages/testbase.cpp b/documentapi/src/tests/messages/testbase.cpp
index c36faa251ab..8f2729964a6 100644
--- a/documentapi/src/tests/messages/testbase.cpp
+++ b/documentapi/src/tests/messages/testbase.cpp
@@ -3,6 +3,10 @@
#include "testbase.h"
#include <vespa/document/base/testdocrepo.h>
#include <vespa/vespalib/util/exception.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <algorithm>
+
#include <vespa/log/log.h>
LOG_SETUP(".testbase");
diff --git a/documentapi/src/tests/priority/priority.cpp b/documentapi/src/tests/priority/priority.cpp
index 1a363dfff31..bc255215813 100644
--- a/documentapi/src/tests/priority/priority.cpp
+++ b/documentapi/src/tests/priority/priority.cpp
@@ -3,6 +3,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/documentapi/messagebus/priority.h>
#include <fstream>
+#include <algorithm>
using namespace documentapi;
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp
index ca698f4ae3a..b3e6ac422eb 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "visitor.h"
+#include <climits>
namespace documentapi {
diff --git a/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp b/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp
index 03562553fc0..ce83a2cd638 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/routablerepository.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/util/stringutil.h>
#include <vespa/vespalib/util/exceptions.h>
#include <sstream>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".routablerepository");
diff --git a/eval/src/vespa/eval/eval/basic_nodes.h b/eval/src/vespa/eval/eval/basic_nodes.h
index 027d6c28d78..c76a43468db 100644
--- a/eval/src/vespa/eval/eval/basic_nodes.h
+++ b/eval/src/vespa/eval/eval/basic_nodes.h
@@ -9,9 +9,9 @@
#include <map>
#include <vector>
#include <cassert>
+#include <limits>
-namespace vespalib {
-namespace eval {
+namespace vespalib::eval {
namespace nodes { class Node; }
@@ -24,6 +24,7 @@ struct NodeVisitor;
**/
struct NodeHandler {
virtual void handle(std::unique_ptr<nodes::Node> node) = 0;
+
virtual ~NodeHandler() {}
};
@@ -35,9 +36,10 @@ namespace nodes {
**/
struct DumpContext {
const std::vector<vespalib::string> &param_names;
- std::vector<vespalib::string> let_names;
+ std::vector<vespalib::string> let_names;
+
DumpContext(const std::vector<vespalib::string> &param_names_in)
- : param_names(param_names_in), let_names() {}
+ : param_names(param_names_in), let_names() {}
};
/**
@@ -46,19 +48,32 @@ struct DumpContext {
**/
struct Node {
virtual bool is_forest() const { return false; }
+
virtual bool is_tree() const { return false; }
+
virtual bool is_const() const { return false; }
+
virtual bool is_param() const { return false; }
+
virtual double get_const_value() const;
+
void traverse(NodeTraverser &traverser) const;
+
virtual vespalib::string dump(DumpContext &ctx) const = 0;
+
virtual void accept(NodeVisitor &visitor) const = 0;
+
virtual size_t num_children() const = 0;
+
virtual const Node &get_child(size_t idx) const = 0;
+
virtual void detach_children(NodeHandler &handler) = 0;
+
bool is_leaf() const { return (num_children() == 0); }
+
virtual ~Node() {}
};
+
typedef std::unique_ptr<Node> Node_UP;
/**
@@ -70,7 +85,7 @@ typedef std::unique_ptr<Node> Node_UP;
* }
* </pre>
**/
-template <typename T>
+template<typename T>
const T *as(const Node &node) { return dynamic_cast<const T *>(&node); }
/**
@@ -79,9 +94,11 @@ const T *as(const Node &node) { return dynamic_cast<const T *>(&node); }
**/
struct Leaf : public Node {
size_t num_children() const override { return 0; }
+
const Node &get_child(size_t) const override {
abort();
}
+
void detach_children(NodeHandler &) override {}
};
@@ -91,7 +108,9 @@ struct Leaf : public Node {
**/
struct CommaTracker {
bool first;
+
CommaTracker() : first(true) {}
+
void maybe_comma(vespalib::string &dst) {
if (first) {
first = false;
@@ -106,12 +125,17 @@ private:
double _value;
public:
Number(double value_in) : _value(value_in) {}
+
virtual bool is_const() const override { return true; }
+
virtual double get_const_value() const override { return value(); }
+
double value() const { return _value; }
+
vespalib::string dump(DumpContext &) const override {
return make_string("%g", _value);
}
+
void accept(NodeVisitor &visitor) const override;
};
@@ -120,11 +144,15 @@ private:
int _id;
public:
static const int UNDEF = std::numeric_limits<int>::max();
+
explicit Symbol(int id_in) : _id(id_in) {}
+
int id() const { return _id; }
+
bool is_param() const override {
return (_id >= 0);
}
+
vespalib::string dump(DumpContext &ctx) const override {
if (_id >= 0) { // param value
assert(size_t(_id) < ctx.param_names.size());
@@ -135,6 +163,7 @@ public:
return ctx.let_names[let_offset];
}
}
+
void accept(NodeVisitor &visitor) const override;
};
@@ -143,11 +172,17 @@ private:
vespalib::string _value;
public:
String(const vespalib::string &value_in) : _value(value_in) {}
+
bool is_const() const override { return true; }
+
double get_const_value() const override { return hash(); }
+
const vespalib::string value() const { return _value; }
+
uint32_t hash() const { return hash_code(_value.data(), _value.size()); }
+
vespalib::string dump(DumpContext &ctx) const override;
+
void accept(NodeVisitor &visitor) const override;
};
@@ -157,17 +192,24 @@ private:
bool _is_const;
public:
Array() : _nodes(), _is_const(false) {}
+
bool is_const() const override { return _is_const; }
+
size_t size() const { return _nodes.size(); }
+
const Node &get(size_t i) const { return *_nodes[i]; }
+
size_t num_children() const override { return size(); }
+
const Node &get_child(size_t idx) const override { return get(idx); }
+
void detach_children(NodeHandler &handler) override {
for (size_t i = 0; i < _nodes.size(); ++i) {
handler.handle(std::move(_nodes[i]));
}
_nodes.clear();
}
+
void add(Node_UP node) {
if (_nodes.empty()) {
_is_const = node->is_const();
@@ -176,6 +218,7 @@ public:
}
_nodes.push_back(std::move(node));
}
+
vespalib::string dump(DumpContext &ctx) const override {
vespalib::string str;
str += "[";
@@ -187,6 +230,7 @@ public:
str += "]";
return str;
}
+
void accept(NodeVisitor &visitor) const override;
};
@@ -196,17 +240,23 @@ private:
bool _is_const;
public:
Neg(Node_UP child_in) : _child(std::move(child_in)), _is_const(_child->is_const()) {}
+
bool is_const() const override { return _is_const; }
+
const Node &child() const { return *_child; }
+
size_t num_children() const override { return _child ? 1 : 0; }
+
const Node &get_child(size_t idx) const override {
(void) idx;
assert(idx == 0);
return child();
}
+
void detach_children(NodeHandler &handler) override {
handler.handle(std::move(_child));
}
+
vespalib::string dump(DumpContext &ctx) const override {
vespalib::string str;
str += "(-";
@@ -214,6 +264,7 @@ public:
str += ")";
return str;
}
+
void accept(NodeVisitor &visitor) const override;
};
@@ -223,17 +274,23 @@ private:
bool _is_const;
public:
Not(Node_UP child_in) : _child(std::move(child_in)), _is_const(_child->is_const()) {}
+
bool is_const() const override { return _is_const; }
+
const Node &child() const { return *_child; }
+
size_t num_children() const override { return _child ? 1 : 0; }
+
const Node &get_child(size_t idx) const override {
(void) idx;
assert(idx == 0);
return child();
}
+
void detach_children(NodeHandler &handler) override {
handler.handle(std::move(_child));
}
+
vespalib::string dump(DumpContext &ctx) const override {
vespalib::string str;
str += "(!";
@@ -241,6 +298,7 @@ public:
str += ")";
return str;
}
+
void accept(NodeVisitor &visitor) const override;
};
@@ -249,18 +307,25 @@ private:
Node_UP _cond;
Node_UP _true_expr;
Node_UP _false_expr;
- double _p_true;
- bool _is_tree;
+ double _p_true;
+ bool _is_tree;
public:
If(Node_UP cond_in, Node_UP true_expr_in, Node_UP false_expr_in, double p_true_in);
+
const Node &cond() const { return *_cond; }
+
const Node &true_expr() const { return *_true_expr; }
+
const Node &false_expr() const { return *_false_expr; }
+
double p_true() const { return _p_true; }
+
bool is_tree() const override { return _is_tree; }
+
size_t num_children() const override {
return (_cond && _true_expr && _false_expr) ? 3 : 0;
}
+
const Node &get_child(size_t idx) const override {
assert(idx < 3);
if (idx == 0) {
@@ -271,11 +336,13 @@ public:
return false_expr();
}
}
+
void detach_children(NodeHandler &handler) override {
handler.handle(std::move(_cond));
handler.handle(std::move(_true_expr));
handler.handle(std::move(_false_expr));
}
+
vespalib::string dump(DumpContext &ctx) const override {
vespalib::string str;
str += "if(";
@@ -290,29 +357,37 @@ public:
str += ")";
return str;
}
+
void accept(NodeVisitor &visitor) const override;
};
class Let : public Node {
private:
vespalib::string _name;
- Node_UP _value;
- Node_UP _expr;
+ Node_UP _value;
+ Node_UP _expr;
public:
Let(const vespalib::string &name_in, Node_UP value_in, Node_UP expr_in)
- : _name(name_in), _value(std::move(value_in)), _expr(std::move(expr_in)) {}
+ : _name(name_in), _value(std::move(value_in)), _expr(std::move(expr_in)) {}
+
const vespalib::string &name() const { return _name; }
+
const Node &value() const { return *_value; }
+
const Node &expr() const { return *_expr; }
+
size_t num_children() const override { return (_value && _expr) ? 2 : 0; }
+
const Node &get_child(size_t idx) const override {
assert(idx < 2);
return (idx == 0) ? value() : expr();
}
+
void detach_children(NodeHandler &handler) override {
handler.handle(std::move(_value));
handler.handle(std::move(_expr));
}
+
vespalib::string dump(DumpContext &ctx) const override {
vespalib::string str;
str += "let(";
@@ -326,6 +401,7 @@ public:
str += ")";
return str;
}
+
void accept(NodeVisitor &visitor) const override;
};
@@ -334,11 +410,13 @@ private:
vespalib::string _message;
public:
Error(const vespalib::string &message_in) : _message(message_in) {}
+
const vespalib::string &message() const { return _message; }
+
vespalib::string dump(DumpContext &) const override { return _message; }
+
void accept(NodeVisitor &visitor) const override;
};
-} // namespace vespalib::eval::nodes
-} // namespace vespalib::eval
-} // namespace vespalib
+}
+}
diff --git a/eval/src/vespa/eval/eval/test/eval_spec.cpp b/eval/src/vespa/eval/eval/test/eval_spec.cpp
index c4f349c614e..f9c36c9eb93 100644
--- a/eval/src/vespa/eval/eval/test/eval_spec.cpp
+++ b/eval/src/vespa/eval/eval/test/eval_spec.cpp
@@ -4,10 +4,9 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/string_hash.h>
#include <cmath>
+#include <limits>
-namespace vespalib {
-namespace eval {
-namespace test {
+namespace vespalib::eval::test {
constexpr double my_nan = std::numeric_limits<double>::quiet_NaN();
constexpr double my_inf = std::numeric_limits<double>::infinity();
@@ -414,6 +413,4 @@ EvalSpec::add_complex_cases() {
[](double a)->double{ return -double(!bool(a)); });
}
-} // namespace vespalib::eval::test
-} // namespace vespalib::eval
-} // namespace vespalib
+}
diff --git a/eval/src/vespa/eval/eval/value_type.cpp b/eval/src/vespa/eval/eval/value_type.cpp
index 1553c6e064e..03e6d2bbcdf 100644
--- a/eval/src/vespa/eval/eval/value_type.cpp
+++ b/eval/src/vespa/eval/eval/value_type.cpp
@@ -2,9 +2,9 @@
#include "value_type.h"
#include "value_type_spec.h"
+#include <algorithm>
-namespace vespalib {
-namespace eval {
+namespace vespalib::eval {
namespace {
@@ -270,5 +270,4 @@ operator<<(std::ostream &os, const ValueType &type) {
return os << type.to_spec();
}
-} // namespace vespalib::eval
-} // namespace vespalib
+}
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_builder.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_builder.cpp
index caf42c9ae60..0b66dd51206 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_builder.cpp
+++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_builder.cpp
@@ -2,14 +2,15 @@
#include "dense_tensor_builder.h"
#include <vespa/vespalib/util/exceptions.h>
-#include <vespa/vespalib/util/stringfmt.h>
#include <cassert>
+#include <limits>
+#include <algorithm>
+
using vespalib::IllegalArgumentException;
using vespalib::make_string;
-namespace vespalib {
-namespace tensor {
+namespace vespalib::tensor {
namespace {
@@ -169,5 +170,4 @@ DenseTensorBuilder::build()
return result;
}
-} // namespace vespalib::tensor
-} // namespace vespalib
+}
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_reduce.hpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_reduce.hpp
index 24e12f83b24..c6fc04bb27b 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_reduce.hpp
+++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_reduce.hpp
@@ -2,10 +2,9 @@
#include "dense_tensor_reduce.h"
#include <cassert>
+#include <algorithm>
-namespace vespalib {
-namespace tensor {
-namespace dense {
+namespace vespalib::tensor::dense {
using Cells = DenseTensorView::Cells;
using CellsRef = DenseTensorView::CellsRef;
@@ -120,6 +119,4 @@ reduce(const DenseTensorView &tensor, const std::vector<vespalib::string> &dimen
}
}
-} // namespace dense
-} // namespace tensor
-} // namespace vespalib
+}
diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp
index 4a6cb4dedd5..92f0b40e259 100644
--- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp
+++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp
@@ -13,11 +13,11 @@
#include <vespa/vespalib/stllike/hash_map_equal.hpp>
#include <vespa/vespalib/util/array_equal.hpp>
#include <sstream>
+#include <algorithm>
using vespalib::eval::TensorSpec;
-namespace vespalib {
-namespace tensor {
+namespace vespalib::tensor {
namespace {
@@ -307,8 +307,6 @@ SparseTensor::reduce(const eval::BinaryOperation &op,
{ return op.eval(lhsValue, rhsValue); });
}
-} // namespace vespalib::tensor
-
-} // namespace vespalib
+}
VESPALIB_HASH_MAP_INSTANTIATE(vespalib::tensor::SparseTensorAddressRef, double);
diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.cpp b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.cpp
index 1ca32aad6be..1e112cbaa6e 100644
--- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.cpp
+++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_unsorted_address_builder.cpp
@@ -4,9 +4,9 @@
#include "sparse_tensor_address_builder.h"
#include <vespa/eval/eval/value_type.h>
#include <cassert>
+#include <algorithm>
-namespace vespalib {
-namespace tensor {
+namespace vespalib::tensor {
SparseTensorUnsortedAddressBuilder::SparseTensorUnsortedAddressBuilder()
: _elementStrings(),
@@ -46,6 +46,4 @@ SparseTensorUnsortedAddressBuilder::buildTo(SparseTensorAddressBuilder &
}
}
-
-} // namespace vespalib::tensor
-} // namespace vespalib
+}
diff --git a/eval/src/vespa/eval/tensor/tensor_mapper.cpp b/eval/src/vespa/eval/tensor/tensor_mapper.cpp
index c15494ed7fe..7c2c72abd46 100644
--- a/eval/src/vespa/eval/tensor/tensor_mapper.cpp
+++ b/eval/src/vespa/eval/tensor/tensor_mapper.cpp
@@ -3,18 +3,17 @@
#include "tensor_mapper.h"
#include "tensor.h"
#include "tensor_visitor.h"
-#include <vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h>
-#include <vespa/eval/tensor/dense/dense_tensor.h>
-#include <vespa/eval/eval/simple_tensor.h>
#include "tensor_address_element_iterator.h"
#include "default_tensor.h"
#include "wrapped_simple_tensor.h"
+#include <vespa/eval/tensor/sparse/direct_sparse_tensor_builder.h>
+#include <vespa/eval/tensor/dense/dense_tensor.h>
+#include <limits>
using vespalib::eval::ValueType;
using vespalib::eval::TensorSpec;
-namespace vespalib {
-namespace tensor {
+namespace vespalib::tensor {
namespace {
@@ -422,5 +421,4 @@ std::unique_ptr<Tensor>
TensorMapper::mapToSparse<SparseTensor>(const Tensor &tensor,
const ValueType &type);
-} // namespace vespalib::tensor
-} // namespace vespalib
+}
diff --git a/fastlib/src/vespa/fastlib/io/bufferedfile.cpp b/fastlib/src/vespa/fastlib/io/bufferedfile.cpp
index 26c75cc1fb1..6a50cfe2259 100644
--- a/fastlib/src/vespa/fastlib/io/bufferedfile.cpp
+++ b/fastlib/src/vespa/fastlib/io/bufferedfile.cpp
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "bufferedfile.h"
+#include <cassert>
+#include <cstring>
namespace {
diff --git a/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp b/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp
index c67a513c67b..f9957d96288 100644
--- a/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp
+++ b/fastlib/src/vespa/fastlib/io/tests/bufferedstreamtest.cpp
@@ -2,6 +2,7 @@
#include <cassert>
#include <ctime>
#include <iostream>
+#include <cstring>
using namespace std;
diff --git a/fastlib/src/vespa/fastlib/net/httpserver.cpp b/fastlib/src/vespa/fastlib/net/httpserver.cpp
index cd3b7705cff..807b169323d 100644
--- a/fastlib/src/vespa/fastlib/net/httpserver.cpp
+++ b/fastlib/src/vespa/fastlib/net/httpserver.cpp
@@ -10,6 +10,7 @@
#include <vespa/fastlib/util/base64.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/fastos/file.h>
+#include <cassert>
/**
* Helper class for hiding the details of HTTP entity encodings and
diff --git a/fastlib/src/vespa/fastlib/text/normwordfolder.cpp b/fastlib/src/vespa/fastlib/text/normwordfolder.cpp
index 208bf9c8cb1..767431e5531 100644
--- a/fastlib/src/vespa/fastlib/text/normwordfolder.cpp
+++ b/fastlib/src/vespa/fastlib/text/normwordfolder.cpp
@@ -3,6 +3,7 @@
#include <vespa/fastlib/text/unicodeutil.h>
#include <vespa/fastlib/text/normwordfolder.h>
#include <vespa/fastos/mutex.h>
+#include <cstring>
bool Fast_NormalizeWordFolder::_isInitialized = false;
FastOS_Mutex _initMutex;
diff --git a/fastlib/src/vespa/fastlib/util/tests/base64test.cpp b/fastlib/src/vespa/fastlib/util/tests/base64test.cpp
index accf7fc87b3..16bb3ccd9ad 100644
--- a/fastlib/src/vespa/fastlib/util/tests/base64test.cpp
+++ b/fastlib/src/vespa/fastlib/util/tests/base64test.cpp
@@ -3,6 +3,7 @@
#include <vespa/fastos/file.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/fastlib/util/base64.h>
+#include <cassert>
class Base64Test : public FastOS_Application {
public:
diff --git a/fastos/src/tests/backtracetest.cpp b/fastos/src/tests/backtracetest.cpp
index 48935e4b6a3..6c68765c1ee 100644
--- a/fastos/src/tests/backtracetest.cpp
+++ b/fastos/src/tests/backtracetest.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/backtrace.h>
-#include <assert.h>
+#include <cassert>
#include <string.h>
#include "tests.h"
@@ -116,7 +116,7 @@ int main (int argc, char **argv)
{
BackTraceTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/coretest.cpp b/fastos/src/tests/coretest.cpp
index 2337c392730..a53eaf9d2a4 100644
--- a/fastos/src/tests/coretest.cpp
+++ b/fastos/src/tests/coretest.cpp
@@ -8,7 +8,7 @@ bomb(void)
{
char *p;
- p = NULL;
+ p = nullptr;
*p = 4;
}
@@ -29,8 +29,8 @@ bombMain(void)
FastS_Bomber bomber;
FastOS_ThreadInterface *thread;
- thread = pool->NewThread(&bomber, NULL);
- if (thread != NULL)
+ thread = pool->NewThread(&bomber, nullptr);
+ if (thread != nullptr)
thread->Join();
pool->Close();
@@ -60,7 +60,7 @@ int
main(int argc, char **argv)
{
FastS_CoreTestApp app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
if (argc == 1)
return app.Entry(argc, argv);
else
diff --git a/fastos/src/tests/coretest2.cpp b/fastos/src/tests/coretest2.cpp
index a8c416f2de4..e11d334e65e 100644
--- a/fastos/src/tests/coretest2.cpp
+++ b/fastos/src/tests/coretest2.cpp
@@ -8,7 +8,7 @@ bomb(void)
{
char *p;
- p = NULL;
+ p = nullptr;
*p = 4;
}
@@ -16,7 +16,7 @@ void *BomberRun(void *arg)
{
(void) arg;
bomb();
- return NULL;
+ return nullptr;
};
static int
@@ -25,8 +25,8 @@ bombMain(void)
pthread_t thread;
void *ret;
- (void) pthread_create(&thread, NULL, BomberRun, NULL);
- ret = NULL;
+ (void) pthread_create(&thread, nullptr, BomberRun, nullptr);
+ ret = nullptr;
(void) pthread_join(thread, &ret);
return (0);
}
diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp
index 92fd5558590..e063ccbc89d 100644
--- a/fastos/src/tests/filetest.cpp
+++ b/fastos/src/tests/filetest.cpp
@@ -3,6 +3,8 @@
#include "tests.h"
#include <vespa/fastos/file.h>
#include <memory>
+#include <cassert>
+#include <sys/mman.h>
namespace {
@@ -276,7 +278,7 @@ public:
Progress(rc, "Opening file 'generated/memorymaptest' read-only");
if (rc) {
bool mmapEnabled;
- char *mmapBuffer = NULL;
+ char *mmapBuffer = nullptr;
mmapEnabled = file.IsMemoryMapped();
mmapBuffer = static_cast<char *>(file.MemoryMapPtr(0));
@@ -830,6 +832,6 @@ int main (int argc, char **argv)
{
FileTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/job.h b/fastos/src/tests/job.h
index 5199169409d..a5b84fa0f9c 100644
--- a/fastos/src/tests/job.h
+++ b/fastos/src/tests/job.h
@@ -42,17 +42,17 @@ public:
Job()
: code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
+ message(nullptr),
+ mutex(nullptr),
+ condition(nullptr),
+ boolcondition(nullptr),
+ otherThread(nullptr),
+ ownThread(nullptr),
+ timebuf(nullptr),
average(0.0),
result(-1),
_threadId(),
- otherjob(NULL),
+ otherjob(nullptr),
bouncewakeupcnt(0),
bouncewakeup(false)
{
@@ -60,7 +60,7 @@ public:
~Job()
{
- if(message != NULL)
+ if(message != nullptr)
free(message);
}
};
diff --git a/fastos/src/tests/performancetest.cpp b/fastos/src/tests/performancetest.cpp
index 1465ee3d223..55174fcc4e3 100644
--- a/fastos/src/tests/performancetest.cpp
+++ b/fastos/src/tests/performancetest.cpp
@@ -12,14 +12,14 @@ int main (int argc, char **argv)
void (*test)(char *buffer) = PerformanceTest;
- test(NULL);
+ test(nullptr);
return 0;
}
void PerformanceTest (char *buffer)
{
// Cause exception
- *static_cast<char *>(NULL) = 'e';
+ *static_cast<char *>(nullptr) = 'e';
#if 1
FastOS_File file("test.txt");
diff --git a/fastos/src/tests/prefetchtest.cpp b/fastos/src/tests/prefetchtest.cpp
index 26ab67251b3..38d3eed837c 100644
--- a/fastos/src/tests/prefetchtest.cpp
+++ b/fastos/src/tests/prefetchtest.cpp
@@ -35,7 +35,7 @@ public:
size = 32;
size *= 1024*1024/sizeof(*a);
- if ((a = static_cast<int *>(calloc(size, sizeof(*a)))) != NULL)
+ if ((a = static_cast<int *>(calloc(size, sizeof(*a)))) != nullptr)
{
// Standard loop
start.SetNow();
@@ -155,6 +155,6 @@ public:
int main (int argc, char **argv)
{
PrefetchTestApp app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/processtest.cpp b/fastos/src/tests/processtest.cpp
index 5036676a504..11e1307027d 100644
--- a/fastos/src/tests/processtest.cpp
+++ b/fastos/src/tests/processtest.cpp
@@ -47,7 +47,7 @@ public:
void OnReceiveData (const void *data, size_t length) override
{
_receivedBytes += length;
- if(data != NULL)
+ if(data != nullptr)
{
#if 0
printf("[%s] received %u bytes of data:\n%s\n",
@@ -62,7 +62,7 @@ public:
int MyListener::_allocCount = 0;
int MyListener::_successCount = 0;
int MyListener::_failCount = 0;
-FastOS_Mutex *MyListener::_counterLock = NULL;
+FastOS_Mutex *MyListener::_counterLock = nullptr;
class ThreadRunJob : public FastOS_Runnable
@@ -128,7 +128,7 @@ public:
ProcessTest ()
: _gotMessage(false),
_receivedMessages(0),
- _counterLock(NULL),
+ _counterLock(nullptr),
_isChild(true)
{
}
@@ -154,7 +154,7 @@ public:
_gotMessage = true;
// We only have the counter lock if we are the parent process.
- if(_counterLock != NULL)
+ if(_counterLock != nullptr)
{
_counterLock->Lock();
_receivedMessages++;
@@ -197,7 +197,7 @@ public:
if(i == 5)
{
// Make sort quit
- xproc->WriteStdin(NULL, 0);
+ xproc->WriteStdin(nullptr, 0);
}
FastOS_Thread::Sleep(1000);
@@ -257,7 +257,7 @@ public:
if(!waitKill && stdinPre)
{
xproc->WriteStdin(str, strlen(str));
- xproc->WriteStdin(NULL, 0);
+ xproc->WriteStdin(nullptr, 0);
}
if(doKill)
@@ -269,7 +269,7 @@ public:
if(!waitKill && !stdinPre)
{
xproc->WriteStdin(str, strlen(str));
- xproc->WriteStdin(NULL, 0);
+ xproc->WriteStdin(nullptr, 0);
}
}
else
@@ -277,7 +277,7 @@ public:
Progress(false, "Process.CreateWithShell failure %d",
GetLastError());
delete xproc;
- xproc = NULL;
+ xproc = nullptr;
}
procs[j] = xproc;
}
@@ -285,7 +285,7 @@ public:
for(j=0; j<numEachTime; j++)
{
FastOS_ProcessInterface *xproc = procs[j];
- if(xproc == NULL)
+ if(xproc == nullptr)
continue;
int timeOut = -1;
@@ -347,7 +347,7 @@ public:
}
delete MyListener::_counterLock;
- MyListener::_counterLock = NULL;
+ MyListener::_counterLock = nullptr;
PrintSeparator();
}
@@ -412,7 +412,7 @@ public:
"Received %d messages", _receivedMessages);
delete _counterLock;
- _counterLock = NULL;
+ _counterLock = nullptr;
PrintSeparator();
}
@@ -427,8 +427,8 @@ public:
void *inheritData = FastOS_Process::PrefopenNoInherit();
FILE *fp = fopen(filename, "w");
int numProc = FastOS_Process::PostfopenNoInherit(inheritData);
- Progress(fp != NULL, "Open file");
- if(fp != NULL)
+ Progress(fp != nullptr, "Open file");
+ if(fp != nullptr)
{
Progress(numProc > 0, "Number of files processed = %d\n",
numProc);
@@ -469,6 +469,6 @@ public:
int main (int argc, char **argv)
{
ProcessTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/sockettest.cpp b/fastos/src/tests/sockettest.cpp
index 3a62fdbf6eb..29dcb1b089e 100644
--- a/fastos/src/tests/sockettest.cpp
+++ b/fastos/src/tests/sockettest.cpp
@@ -3,7 +3,8 @@
#include "tests.h"
#include <vespa/fastos/file.h>
#include <vespa/fastos/serversocket.h>
-
+#include <cassert>
+#include <arpa/inet.h>
#define MAZE_FILE_OFFSET 1078
@@ -149,7 +150,7 @@ public:
BaseTest *_app;
MazeServer(BaseTest *app)
- : _serverSocket(NULL),
+ : _serverSocket(nullptr),
_app(app)
{
}
@@ -184,7 +185,7 @@ public:
{
int serverPort = 18334;
_serverSocket = new FastOS_ServerSocket(serverPort);
- _app->Progress(_serverSocket != NULL,
+ _app->Progress(_serverSocket != nullptr,
"Creating ServerSocket instance");
_app->Progress(_serverSocket->SetSoBlocking(false),
@@ -223,12 +224,12 @@ public:
{
FastOS_Socket *connSocket = _serverSocket->AcceptPlain();
- _app->Progress(connSocket != NULL, "Accepting socket (%p)",
+ _app->Progress(connSocket != nullptr, "Accepting socket (%p)",
connSocket);
for(i=0; i<MAX_CONNECTIONS; i++)
{
- if(connections[i] == NULL)
+ if(connections[i] == nullptr)
{
// Found a free positions for the new connection
break;
@@ -236,11 +237,11 @@ public:
}
if(i < MAX_CONNECTIONS)
{
- if(connSocket != NULL)
+ if(connSocket != nullptr)
{
connections[i] = new MazeServerConnection(this, connSocket);
- assert(connections[i] != NULL);
+ assert(connections[i] != nullptr);
connSocket->SetSocketEvent(&socketEvent);
connSocket->EnableReadEvent(true);
@@ -255,7 +256,7 @@ public:
for(i=0; i<MAX_CONNECTIONS; i++)
{
- if((conn = connections[i]) != NULL)
+ if((conn = connections[i]) != nullptr)
{
if(socketEvent.QueryReadEvent(conn->_socket))
{
@@ -272,7 +273,7 @@ public:
if(conn->_shouldFree)
{
delete(conn);
- connections[i] = NULL;
+ connections[i] = nullptr;
}
}
}
@@ -437,7 +438,7 @@ public:
#if 0
void PrintOut()
{
- if(_server != NULL)
+ if(_server != nullptr)
{
for(int y=0; y<MAZE_HEIGHT; y++)
{
@@ -459,7 +460,7 @@ public:
#if 0
void MarkPath (int x, int y, int direction, int length)
{
- if(_server != NULL)
+ if(_server != nullptr)
{
int dx, dy;
SetDirection(dx, dy, direction);
@@ -656,9 +657,9 @@ public:
std::string strictBindHost("localhost");
FastOS_ServerSocket *serverSocket =
- new FastOS_ServerSocket(18333, 5, NULL, strictBindHost.c_str());
+ new FastOS_ServerSocket(18333, 5, nullptr, strictBindHost.c_str());
- Progress(serverSocket != NULL, "Allocating serversocket instance");
+ Progress(serverSocket != nullptr, "Allocating serversocket instance");
rc = serverSocket->GetValidAddressFlag();
Progress(rc, "Address Valid Flag check");
@@ -683,7 +684,7 @@ public:
TestHeader("HTTP Client Test");
FastOS_Socket *sock = new FastOS_Socket();
- Progress(sock != NULL, "Allocating socket instance");
+ Progress(sock != nullptr, "Allocating socket instance");
char hostAddress[] = "www.vg.no";
@@ -713,7 +714,7 @@ public:
int readLength = strlen(expectedResult);
char *readBuffer = new char[readLength+1];
- if(readBuffer != NULL)
+ if(readBuffer != nullptr)
{
memset(readBuffer, 0, readLength+1);
@@ -755,7 +756,7 @@ public:
TestHeader("Client/Server Test");
FastOS_ServerSocket *serverSocket = new FastOS_ServerSocket(18333);
- Progress(serverSocket != NULL, "Allocating serversocket instance");
+ Progress(serverSocket != nullptr, "Allocating serversocket instance");
Progress(rc = serverSocket->Listen(), "Bind socket to port %d. Listen for incoming connections.", 18333);
assert(rc);
@@ -774,7 +775,7 @@ public:
bool rc;
FastOS_Socket *sock = new FastOS_Socket();
- Progress(rc = (sock != NULL), "Allocating socket instance");
+ Progress(rc = (sock != nullptr), "Allocating socket instance");
if(rc)
{
sock->SetAddress(8001, serverAddress);
@@ -785,7 +786,7 @@ public:
{
MazeClient *client = new MazeClient(this, sock);
- Progress(rc = (client != NULL), "Allocating MazeClient instance");
+ Progress(rc = (client != nullptr), "Allocating MazeClient instance");
if(rc)
{
client->Run();
@@ -817,7 +818,7 @@ public:
#if DO_MAZE_SERVER
DoMazeServer();
#else
- char *mazeServerAddress = NULL;
+ char *mazeServerAddress = nullptr;
if(_argc == 3)
{
@@ -831,7 +832,7 @@ public:
ClientServerTest();
StrictBindTest();
- if(mazeServerAddress != NULL)
+ if(mazeServerAddress != nullptr)
MazeTest(mazeServerAddress);
#endif
@@ -849,6 +850,6 @@ int main (int argc, char **argv)
{
SocketTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/tests.h b/fastos/src/tests/tests.h
index 94062c04e54..62a873f8a54 100644
--- a/fastos/src/tests/tests.h
+++ b/fastos/src/tests/tests.h
@@ -3,6 +3,7 @@
#include <vespa/fastos/app.h>
#include <vespa/fastos/socket.h>
#include <vespa/fastos/thread.h>
+#include <cstring>
class BaseTest : public FastOS_Application
{
diff --git a/fastos/src/tests/thread_bounce_test.cpp b/fastos/src/tests/thread_bounce_test.cpp
index 729c16fab5f..bf94f3e1aab 100644
--- a/fastos/src/tests/thread_bounce_test.cpp
+++ b/fastos/src/tests/thread_bounce_test.cpp
@@ -89,6 +89,6 @@ int Thread_Bounce_Test::Main ()
int main (int argc, char **argv)
{
Thread_Bounce_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_joinwait_test.cpp b/fastos/src/tests/thread_joinwait_test.cpp
index 98e0a1ac467..05ab1627334 100644
--- a/fastos/src/tests/thread_joinwait_test.cpp
+++ b/fastos/src/tests/thread_joinwait_test.cpp
@@ -38,7 +38,7 @@ class Thread_JoinWait_Test : public ThreadTestBase
jobs[i].ownThread = pool.NewThread(this,
static_cast<void *>(&jobs[i]));
- rc = (jobs[i].ownThread != NULL);
+ rc = (jobs[i].ownThread != nullptr);
Progress(rc, "Creating Thread %d", i+1);
if(!rc)
@@ -56,7 +56,7 @@ class Thread_JoinWait_Test : public ThreadTestBase
static_cast<void *>
(&jobs[lastThreadNum]));
- rc = (lastThread != NULL);
+ rc = (lastThread != nullptr);
Progress(rc, "Creating last thread");
if(rc)
@@ -115,6 +115,6 @@ int Thread_JoinWait_Test::Main ()
int main (int argc, char **argv)
{
Thread_JoinWait_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_mutex_test.cpp b/fastos/src/tests/thread_mutex_test.cpp
index 602d89c0b05..b8ac575038b 100644
--- a/fastos/src/tests/thread_mutex_test.cpp
+++ b/fastos/src/tests/thread_mutex_test.cpp
@@ -21,11 +21,11 @@ class Thread_Mutex_Test : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, MAX_THREADS);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
int i;
Job jobs[MUTEX_TEST_THREADS];
- FastOS_Mutex *myMutex=NULL;
+ FastOS_Mutex *myMutex=nullptr;
if(usingMutex)
myMutex = new FastOS_Mutex();
@@ -40,7 +40,7 @@ class Thread_Mutex_Test : public ThreadTestBase
for(i=0; i<MUTEX_TEST_THREADS; i++)
{
- bool rc = (NULL != pool->NewThread(this,
+ bool rc = (nullptr != pool->NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread with%s mutex", (usingMutex ? "" : "out"));
};
@@ -99,7 +99,7 @@ class Thread_Mutex_Test : public ThreadTestBase
}
}
- if(myMutex != NULL)
+ if(myMutex != nullptr)
delete(myMutex);
Progress(true, "Closing threadpool...");
@@ -125,9 +125,9 @@ class Thread_Mutex_Test : public ThreadTestBase
job.ownThread = pool.NewThread(this,
static_cast<void *>(&job));
- Progress(job.ownThread !=NULL, "Creating thread");
+ Progress(job.ownThread !=nullptr, "Creating thread");
- if(job.ownThread != NULL)
+ if(job.ownThread != nullptr)
{
bool lockrc;
@@ -188,6 +188,6 @@ int Thread_Mutex_Test::Main ()
int main (int argc, char **argv)
{
Thread_Mutex_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_sleep_test.cpp b/fastos/src/tests/thread_sleep_test.cpp
index 914438cdd83..7fd3412b7c3 100644
--- a/fastos/src/tests/thread_sleep_test.cpp
+++ b/fastos/src/tests/thread_sleep_test.cpp
@@ -14,9 +14,9 @@ class Thread_Sleep_Test : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
- bool rc = (NULL != pool->NewThread(this, NULL));
+ bool rc = (nullptr != pool->NewThread(this, nullptr));
Progress(rc, "Creating Thread");
Progress(true, "Sleeping 3 seconds");
@@ -47,6 +47,6 @@ int Thread_Sleep_Test::Main ()
int main (int argc, char **argv)
{
Thread_Sleep_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_stats_test.cpp b/fastos/src/tests/thread_stats_test.cpp
index 3ac4b0a52d6..3633c12bcaa 100644
--- a/fastos/src/tests/thread_stats_test.cpp
+++ b/fastos/src/tests/thread_stats_test.cpp
@@ -131,6 +131,6 @@ int Thread_Stats_Test::Main ()
int main (int argc, char **argv)
{
Thread_Stats_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_test_base.hpp b/fastos/src/tests/thread_test_base.hpp
index 3cd16065726..5305b132d3c 100644
--- a/fastos/src/tests/thread_test_base.hpp
+++ b/fastos/src/tests/thread_test_base.hpp
@@ -57,7 +57,7 @@ public:
void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
{
- if(arg == NULL)
+ if(arg == nullptr)
return;
Job *job = static_cast<Job *>(arg);
@@ -93,7 +93,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
{
int result;
- if(job->mutex != NULL)
+ if(job->mutex != nullptr)
job->mutex->Lock();
result = static_cast<int>(number);
@@ -107,7 +107,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
FastOS_Thread::Sleep(1000);
}
- if(job->mutex != NULL)
+ if(job->mutex != nullptr)
job->mutex->Unlock();
job->result = result; // This marks the end of the thread
@@ -135,7 +135,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
if(job->mutex)
job->mutex->Lock();
- if(job->otherThread != NULL)
+ if(job->otherThread != nullptr)
job->otherThread->Join();
if(job->mutex)
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index 57e60d9413b..81ea234fb97 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -54,7 +54,7 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, MAX_THREADS);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
int i;
Job jobs[MAX_THREADS];
@@ -70,13 +70,13 @@ class ThreadTest : public ThreadTestBase
{
if(i==MAX_THREADS)
{
- bool rc = (NULL == pool->NewThread(this,
+ bool rc = (nullptr == pool->NewThread(this,
static_cast<void *>(&jobs[0])));
Progress(rc, "Creating too many threads should fail.");
}
else
{
- bool rc = (NULL != pool->NewThread(this,
+ bool rc = (nullptr != pool->NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread");
}
@@ -110,7 +110,7 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, HOW_MAX_THREADS);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
int i;
Job jobs[HOW_MAX_THREADS];
@@ -126,13 +126,13 @@ class ThreadTest : public ThreadTestBase
{
if(i==HOW_MAX_THREADS)
{
- bool rc = (NULL == pool->NewThread(this,
+ bool rc = (nullptr == pool->NewThread(this,
static_cast<void *>(&jobs[0])));
Progress(rc, "Creating too many threads should fail.");
}
else
{
- bool rc = (NULL != pool->NewThread(this,
+ bool rc = (nullptr != pool->NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread");
}
@@ -164,14 +164,14 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
Job job;
job.code = NOP;
job.result = -1;
- bool rc = (NULL != pool->NewThread(this, &job));
+ bool rc = (nullptr != pool->NewThread(this, &job));
Progress(rc, "Creating Thread");
WaitForThreadsToFinish(&job, 1);
@@ -201,8 +201,8 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128 * 1024);
if (!silent)
- Progress(pool != NULL, "Allocating ThreadPool");
- if (pool != NULL) {
+ Progress(pool != nullptr, "Allocating ThreadPool");
+ if (pool != nullptr) {
Job *jobs = new Job[count];
threadsok = 0;
@@ -210,23 +210,23 @@ class ThreadTest : public ThreadTestBase
for (i = 0; i < count; i++) {
jobs[i].code = SILENTNOP;
jobs[i].ownThread = pool->NewThread(this, &jobs[i]);
- rc = (jobs[i].ownThread != NULL);
+ rc = (jobs[i].ownThread != nullptr);
if (rc)
threadsok++;
}
for (j = 0; j < outercount; j++) {
for (i = 0; i < count; i++) {
- if (jobs[i].ownThread != NULL)
+ if (jobs[i].ownThread != nullptr)
jobs[i].ownThread->Join();
jobs[i].ownThread = pool->NewThread(this, &jobs[i]);
- rc = (jobs[i].ownThread != NULL);
+ rc = (jobs[i].ownThread != nullptr);
if (rc)
threadsok++;
}
}
for (i = 0; i < count; i++) {
- if (jobs[i].ownThread != NULL)
+ if (jobs[i].ownThread != nullptr)
jobs[i].ownThread->Join();
}
endtime.SetNow();
@@ -286,7 +286,7 @@ class ThreadTest : public ThreadTestBase
{
jobs[i].code = INCREASE_NUMBER;
- bool rc = (NULL != pool.NewThread(this,
+ bool rc = (nullptr != pool.NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread %d", i+1);
}
@@ -311,7 +311,7 @@ class ThreadTest : public ThreadTestBase
{
jobs[i].code = WAIT_FOR_BREAK_FLAG;
- bool rc = (NULL != pool.NewThread(this,
+ bool rc = (nullptr != pool.NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread %d", i+1);
}
@@ -333,7 +333,7 @@ class ThreadTest : public ThreadTestBase
jobs[i].ownThread = pool->NewThread(this,
static_cast<void *>(&jobs[i]));
- bool rc=(jobs[i].ownThread != NULL);
+ bool rc=(jobs[i].ownThread != nullptr);
Progress(rc, "CreatingThread %d", i+1);
}
@@ -412,7 +412,7 @@ class ThreadTest : public ThreadTestBase
jobs[i].mutex = &slowStartMutex;
jobs[i].ownThread = pool.NewThread(this,
static_cast<void *>(&jobs[i]));
- bool rc=(jobs[i].ownThread != NULL);
+ bool rc=(jobs[i].ownThread != nullptr);
if(rc)
jobs[i]._threadId = jobs[i].ownThread->GetThreadId();
Progress(rc, "CreatingThread %d id:%lu", i+1,
@@ -457,9 +457,9 @@ class ThreadTest : public ThreadTestBase
job.ownThread = pool.NewThread(this,
static_cast<void *>(&job));
- Progress(job.ownThread !=NULL, "Creating thread");
+ Progress(job.ownThread !=nullptr, "Creating thread");
- if(job.ownThread != NULL)
+ if(job.ownThread != nullptr)
{
condition.Lock();
bool gotCond = condition.TimedWait(500);
@@ -597,6 +597,6 @@ int ThreadTest::Main ()
int main (int argc, char **argv)
{
ThreadTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/timetest.cpp b/fastos/src/tests/timetest.cpp
index fa9ef71ba9c..0618e28bcd0 100644
--- a/fastos/src/tests/timetest.cpp
+++ b/fastos/src/tests/timetest.cpp
@@ -290,7 +290,7 @@ int main (int argc, char **argv)
{
TimeTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp
index e0399b56ba5..209af305501 100644
--- a/fastos/src/tests/typetest.cpp
+++ b/fastos/src/tests/typetest.cpp
@@ -2,6 +2,7 @@
#include "tests.h"
#include <vespa/fastos/file.h>
+#include <vespa/fastos/time.h>
#include <vespa/fastos/serversocket.h>
#include <cstdlib>
@@ -9,40 +10,6 @@
class TypeTest : public BaseTest
{
private:
- void PrintfSpecifiersTest ()
- {
- char testBuf[200];
- const char *correct;
-
- TestHeader("64-bit printf-specifiers test");
-
- sprintf(testBuf, "%" PRId64, int64_t(-1000)*1000*1000*1000*1000);
- correct = "-1000000000000000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIu64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "1000000000000000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIo64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "34327724461500000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIx64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "38d7ea4c68000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- sprintf(testBuf, "%" PRIX64, uint64_t(1000)*1000*1000*1000*1000);
- correct = "38D7EA4C68000";
- Progress(strcmp(testBuf, correct) == 0,
- "Generated=[%s], Correct=[%s]", testBuf, correct);
-
- PrintSeparator();
- }
void ObjectSizeTest ()
{
@@ -73,7 +40,6 @@ public:
{
printf("grep for the string '%s' to detect failures.\n\n", failString);
- PrintfSpecifiersTest();
ObjectSizeTest();
PrintSeparator();
@@ -86,7 +52,7 @@ public:
int main (int argc, char **argv)
{
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
TypeTest app;
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/usecputest.cpp b/fastos/src/tests/usecputest.cpp
index 930b1fb305f..9812ed7575d 100644
--- a/fastos/src/tests/usecputest.cpp
+++ b/fastos/src/tests/usecputest.cpp
@@ -63,7 +63,7 @@ void UseSomeCpu (int i, ThreadRunJob *threadRunJob)
int main (int argc, char **argv)
{
UseCpuTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/vespa/fastos/CMakeLists.txt b/fastos/src/vespa/fastos/CMakeLists.txt
index 661dd1c6547..2a0ff2d370a 100644
--- a/fastos/src/vespa/fastos/CMakeLists.txt
+++ b/fastos/src/vespa/fastos/CMakeLists.txt
@@ -5,6 +5,7 @@ vespa_add_library(fastos_objects OBJECT
backtrace.c
file.cpp
linux_file.cpp
+ process.cpp
serversocket.cpp
socket.cpp
socketevent.cpp
diff --git a/fastos/src/vespa/fastos/app.cpp b/fastos/src/vespa/fastos/app.cpp
index a76cd64d197..824d009591f 100644
--- a/fastos/src/vespa/fastos/app.cpp
+++ b/fastos/src/vespa/fastos/app.cpp
@@ -6,12 +6,14 @@
* @author Div, Oivind H. Danielsen
*/
-#include <vespa/fastos/app.h>
-#include <vespa/fastos/socket.h>
-#include <vespa/fastos/file.h>
+#include "app.h"
+#include "socket.h"
+#include "file.h"
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/thread.h>
+#include "process.h"
+#include "thread.h"
+#include <cstring>
+#include <fcntl.h>
FastOS_ApplicationInterface *FastOS_ProcessInterface::_app;
FastOS_ThreadPool *FastOS_ProcessInterface::GetThreadPool ()
@@ -25,16 +27,16 @@ FastOS_ThreadPool *FastOS_ApplicationInterface::GetThreadPool ()
}
FastOS_ApplicationInterface::FastOS_ApplicationInterface() :
- _threadPool(NULL),
- _processList(NULL),
- _processListMutex(NULL),
+ _threadPool(nullptr),
+ _processList(nullptr),
+ _processListMutex(nullptr),
_disableLeakReporting(false),
_argc(0),
- _argv(NULL)
+ _argv(nullptr)
{
FastOS_ProcessInterface::_app = this;
char * fadvise = getenv("VESPA_FADVISE_OPTIONS");
- if (fadvise != NULL) {
+ if (fadvise != nullptr) {
int fadviseOptions(0);
if (strstr(fadvise, "SEQUENTIAL")) { fadviseOptions |= POSIX_FADV_SEQUENTIAL; }
if (strstr(fadvise, "RANDOM")) { fadviseOptions |= POSIX_FADV_RANDOM; }
@@ -61,7 +63,7 @@ bool FastOS_ApplicationInterface::Init ()
{
const char *errorMsg = FastOS_Socket::InitializeServices();
- if(errorMsg == NULL)
+ if(errorMsg == nullptr)
{
_processListMutex = new FastOS_Mutex();
_threadPool = new FastOS_ThreadPool(128 * 1024);
@@ -89,19 +91,19 @@ bool FastOS_ApplicationInterface::Init ()
void FastOS_ApplicationInterface::Cleanup ()
{
- if(_threadPool != NULL)
+ if(_threadPool != nullptr)
{
// printf("Closing threadpool...\n");
_threadPool->Close();
// printf("Deleting threadpool...\n");
delete _threadPool;
- _threadPool = NULL;
+ _threadPool = nullptr;
}
- if(_processListMutex != NULL)
+ if(_processListMutex != nullptr)
{
delete _processListMutex;
- _processListMutex = NULL;
+ _processListMutex = nullptr;
}
FastOS_Socket::CleanupServices();
@@ -137,10 +139,10 @@ OnReceivedIPCMessage (const void *data, size_t length)
void FastOS_ApplicationInterface::
AddChildProcess (FastOS_ProcessInterface *node)
{
- node->_prev = NULL;
+ node->_prev = nullptr;
node->_next = _processList;
- if(_processList != NULL)
+ if(_processList != nullptr)
_processList->_prev = node;
_processList = node;
@@ -157,11 +159,11 @@ RemoveChildProcess (FastOS_ProcessInterface *node)
if(node->_next)
{
node->_next->_prev = node->_prev;
- node->_next = NULL;
+ node->_next = nullptr;
}
- if(node->_prev != NULL)
- node->_prev = NULL;
+ if(node->_prev != nullptr)
+ node->_prev = nullptr;
}
bool
diff --git a/fastos/src/vespa/fastos/cond.h b/fastos/src/vespa/fastos/cond.h
index 457abe666d4..c9405728223 100644
--- a/fastos/src/vespa/fastos/cond.h
+++ b/fastos/src/vespa/fastos/cond.h
@@ -9,9 +9,7 @@
#pragma once
-
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
+#include "mutex.h"
/**
diff --git a/fastos/src/vespa/fastos/dynamiclibrary.h b/fastos/src/vespa/fastos/dynamiclibrary.h
index b0bf5730405..15cc28fa130 100644
--- a/fastos/src/vespa/fastos/dynamiclibrary.h
+++ b/fastos/src/vespa/fastos/dynamiclibrary.h
@@ -34,7 +34,7 @@ public:
* @param libname the name of the library to open
* @return Boolean success/failure
*/
- virtual bool Open(const char *libname = NULL) = 0;
+ virtual bool Open(const char *libname = nullptr) = 0;
/**
* Close (unload) the library.
@@ -45,7 +45,7 @@ public:
/**
* Find the address of a symbol in the library.
* @param symbol Name of symbol to find
- * @return Address of the symbol, or NULL if an error has occurred
+ * @return Address of the symbol, or nullptr if an error has occurred
*/
virtual void * GetSymbol(const char *symbol) const = 0;
diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp
index cf17b672bd5..5c4d7ce9445 100644
--- a/fastos/src/vespa/fastos/file.cpp
+++ b/fastos/src/vespa/fastos/file.cpp
@@ -6,9 +6,10 @@
* @author Div, Oivind H. Danielsen
*/
-#include <vespa/fastos/file.h>
+#include "file.h"
#include <sstream>
-
+#include <cstring>
+#include <fcntl.h>
DirectIOException::DirectIOException(const char * fileName, const void * buffer, size_t length, int64_t offset) :
std::exception(),
@@ -26,7 +27,7 @@ DirectIOException::DirectIOException(const char * fileName, const void * buffer,
DirectIOException::~DirectIOException() {}
-FastOS_FileInterface::FailedHandler FastOS_FileInterface::_failedHandler = NULL;
+FastOS_FileInterface::FailedHandler FastOS_FileInterface::_failedHandler = nullptr;
int FastOS_FileInterface::_defaultFAdviseOptions = POSIX_FADV_NORMAL;
static const size_t MAX_WRITE_CHUNK_SIZE = 0x4000000; // 64 MB
@@ -34,12 +35,12 @@ static const size_t MAX_WRITE_CHUNK_SIZE = 0x4000000; // 64 MB
FastOS_FileInterface::FastOS_FileInterface(const char *filename)
: _fAdviseOptions(_defaultFAdviseOptions),
_writeChunkSize(MAX_WRITE_CHUNK_SIZE),
- _filename(NULL),
+ _filename(nullptr),
_openFlags(0),
_directIOEnabled(false),
_syncWritesEnabled(false)
{
- if (filename != NULL)
+ if (filename != nullptr)
SetFileName(filename);
}
@@ -199,7 +200,7 @@ FastOS_FileInterface::MemoryMapPtr(int64_t position) const
{
// Only subclases with support for memory mapping do something here.
(void) position;
- return NULL;
+ return nullptr;
}
@@ -217,8 +218,8 @@ FastOS_FileInterface::CopyFile( const char *src, const char *dst )
FastOS_StatInfo statInfo;
bool success = false;
- if ( src != NULL &&
- dst != NULL &&
+ if ( src != nullptr &&
+ dst != nullptr &&
strcmp(src, dst) != 0 &&
FastOS_File::Stat( src, &statInfo )) {
@@ -232,7 +233,7 @@ FastOS_FileInterface::CopyFile( const char *src, const char *dst )
bufSize = static_cast<unsigned int>(bufSizeBound);
char *tmpBuf = new char[ bufSize ];
- if ( tmpBuf != NULL ) {
+ if ( tmpBuf != nullptr ) {
int64_t copied = 0;
success = true;
do {
@@ -277,7 +278,7 @@ FastOS_FileInterface::MoveFile(const char* src, const char* dst)
void
FastOS_FileInterface::EmptyDirectory( const char *dir,
- const char *keepFile /* = NULL */ )
+ const char *keepFile /* = nullptr */ )
{
FastOS_StatInfo statInfo;
if (!FastOS_File::Stat(dir, &statInfo))
@@ -287,7 +288,7 @@ FastOS_FileInterface::EmptyDirectory( const char *dir,
while (dirScan.ReadNext()) {
if (strcmp(dirScan.GetName(), ".") != 0 &&
strcmp(dirScan.GetName(), "..") != 0 &&
- (keepFile == NULL || strcmp(dirScan.GetName(), keepFile) != 0))
+ (keepFile == nullptr || strcmp(dirScan.GetName(), keepFile) != 0))
{
std::string name = dir;
name += GetPathSeparator();
@@ -346,7 +347,7 @@ FastOS_FileInterface::MakeDirIfNotPresentOrExit(const char *name)
void
FastOS_FileInterface::SetFileName(const char *filename)
{
- if (_filename != NULL) {
+ if (_filename != nullptr) {
free(_filename);
}
@@ -357,7 +358,7 @@ FastOS_FileInterface::SetFileName(const char *filename)
const char *
FastOS_FileInterface::GetFileName() const
{
- return (_filename != NULL) ? _filename : "";
+ return (_filename != nullptr) ? _filename : "";
}
@@ -461,13 +462,6 @@ FastOS_FileInterface::OpenWriteOnly(const char *filename)
return Open(FASTOS_FILE_OPEN_WRITE, filename);
}
-
-bool
-FastOS_FileInterface::OpenStdin()
-{
- return Open(FASTOS_FILE_OPEN_STDIN);
-}
-
FastOS_File::Error
FastOS_FileInterface::GetLastError()
{
@@ -495,3 +489,13 @@ bool FastOS_FileInterface::Rename (const char *newFileName)
void FastOS_FileInterface::dropFromCache() const
{
}
+
+FastOS_DirectoryScanInterface::FastOS_DirectoryScanInterface(const char *path)
+ : _searchPath(strdup(path))
+{
+}
+
+FastOS_DirectoryScanInterface::~FastOS_DirectoryScanInterface()
+{
+ free(_searchPath);
+} \ No newline at end of file
diff --git a/fastos/src/vespa/fastos/file.h b/fastos/src/vespa/fastos/file.h
index 8a9de224259..a9be683d395 100644
--- a/fastos/src/vespa/fastos/file.h
+++ b/fastos/src/vespa/fastos/file.h
@@ -10,12 +10,7 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
-#include <vespa/fastos/time.h>
-
-#include <vespa/fastos/thread.h>
-
+#include "types.h"
#include <string>
const int FASTOS_FILE_OPEN_READ = (1<<0);
@@ -23,12 +18,10 @@ const int FASTOS_FILE_OPEN_WRITE = (1<<1);
const int FASTOS_FILE_OPEN_EXISTING = (1<<2);
const int FASTOS_FILE_OPEN_CREATE = (1<<3);
const int FASTOS_FILE_OPEN_TRUNCATE = (1<<4);
-const int FASTOS_FILE_OPEN_STDIN = (1<<5); // Use 2 bits here
const int FASTOS_FILE_OPEN_STDOUT = (2<<5);
const int FASTOS_FILE_OPEN_STDERR = (3<<5);
const int FASTOS_FILE_OPEN_STDFLAGS = (3<<5);
const int FASTOS_FILE_OPEN_DIRECTIO = (1<<7);
-const int FASTOS_FILE_OPEN_SHAREREAD = (1<<8);
const int FASTOS_FILE_OPEN_SYNCWRITES = (1<<9); // synchronous writes
/**
@@ -115,13 +108,6 @@ public:
int getFAdviseOptions() const { return _fAdviseOptions; }
void setFAdviseOptions(int options) { _fAdviseOptions = options; }
- char *ToString () {
- const char dummy[]="FastOS_File::ToString() deprecated";
- char *str = new char [strlen(dummy) + 1];
- strcpy(str, dummy);
- return str;
- }
-
/**
* Initialize the file class. This is invoked by
* @ref FastOS_Application::Init().
@@ -188,7 +174,7 @@ public:
* @param keepFile a 'const char *' value. If supplied, leave files with
* this name alone.
*/
- static void EmptyDirectory( const char *dir, const char *keepFile = NULL);
+ static void EmptyDirectory( const char *dir, const char *keepFile = nullptr);
/**
* Make a directory (special compatibility version)
@@ -212,7 +198,7 @@ public:
* later using @ref SetFileName() or @ref Open().
* @param filename a filename (optional)
*/
- FastOS_FileInterface(const char *filename=NULL);
+ FastOS_FileInterface(const char *filename=nullptr);
/**
* Destructor. If the current file is open, the destructor will close
@@ -250,7 +236,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- virtual bool Open(unsigned int openFlags, const char *filename=NULL) = 0;
+ virtual bool Open(unsigned int openFlags, const char *filename=nullptr) = 0;
/**
* Open a file for read/write access. The file will be created if it does
@@ -261,7 +247,7 @@ public:
* @ref SetFileName() or a previous call to @ref Open().
* @return Boolean success/failure
*/
- bool OpenReadWrite(const char *filename=NULL);
+ bool OpenReadWrite(const char *filename=nullptr);
/**
* Open a file for read/write access. This method fails if the file does
@@ -274,7 +260,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenExisting(bool abortIfNotExist=false, const char *filename=NULL);
+ bool OpenExisting(bool abortIfNotExist=false, const char *filename=nullptr);
/**
* Open a file for read access. This method fails if the file does
@@ -287,7 +273,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenReadOnlyExisting (bool abortIfNotExist=false, const char *filename=NULL);
+ bool OpenReadOnlyExisting (bool abortIfNotExist=false, const char *filename=nullptr);
/**
* Open a file for write access. If the file does not exist, it is created.
@@ -299,7 +285,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenWriteOnlyTruncate(const char *filename=NULL);
+ bool OpenWriteOnlyTruncate(const char *filename=nullptr);
/**
* Open a file for write access. This method fails if the file does
@@ -312,7 +298,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenWriteOnlyExisting (bool abortIfNotExist=false, const char *filename=NULL);
+ bool OpenWriteOnlyExisting (bool abortIfNotExist=false, const char *filename=nullptr);
/**
* Open a file for read-access only. This method fails if the file does
@@ -323,7 +309,7 @@ public:
* @ref SetFileName() or a previous call to @ref Open().
* @return Boolean success/failure
*/
- bool OpenReadOnly(const char *filename=NULL);
+ bool OpenReadOnly(const char *filename=nullptr);
/**
* Open a file for write-access only. The file will be created if it does
@@ -334,9 +320,7 @@ public:
* @ref SetFileName() or a previous call to @ref Open().
* @return Boolean success/failure
*/
- bool OpenWriteOnly(const char *filename=NULL);
-
- bool OpenStdin();
+ bool OpenWriteOnly(const char *filename=nullptr);
/**
* Close the file. The call will successfully do nothing if the file
@@ -574,7 +558,7 @@ public:
* from malloc will be saved. Use free() with
* this pointer to deallocate the buffer.
* This value is always set.
- * @return Alligned pointer value or NULL if out of memory
+ * @return Alligned pointer value or nullptr if out of memory
*/
virtual void *AllocateDirectIOBuffer(size_t byteSize, void *&realPtr);
@@ -588,7 +572,7 @@ public:
/**
* Inquiry about where in memory file data is located.
* @return location of file data in memory. If the file is not mapped,
- * NULL is returned.
+ * nullptr is returned.
*/
virtual void *MemoryMapPtr(int64_t position) const;
@@ -752,20 +736,14 @@ public:
* @param path Path of the directory to be scanned. The path string
* is copied internally.
*/
- FastOS_DirectoryScanInterface(const char *path)
- : _searchPath(strdup(path))
- {
- }
+ FastOS_DirectoryScanInterface(const char *path);
/**
* Destructor.
*
* Frees operating system resources related to the directory scan.
*/
- virtual ~FastOS_DirectoryScanInterface()
- {
- free(_searchPath);
- }
+ virtual ~FastOS_DirectoryScanInterface();
/**
* Get search path.
diff --git a/fastos/src/vespa/fastos/linux_file.cpp b/fastos/src/vespa/fastos/linux_file.cpp
index 1b9556569e2..6af3bd207a0 100644
--- a/fastos/src/vespa/fastos/linux_file.cpp
+++ b/fastos/src/vespa/fastos/linux_file.cpp
@@ -7,13 +7,13 @@
* Implementation of FastOS_Linux_File methods.
*****************************************************************************/
-#include <vespa/fastos/file.h>
+#include "file.h"
#include <sstream>
-#include <stdexcept>
+#include <unistd.h>
+#include <fcntl.h>
const size_t FastOS_Linux_File::_directIOFileAlign = 4096;
const size_t FastOS_Linux_File::_directIOMemAlign = 4096;
-const size_t FastOS_Linux_File::_pageSize = 4096;
FastOS_Linux_File::FastOS_Linux_File(const char *filename)
: FastOS_UNIX_File(filename),
@@ -31,7 +31,7 @@ ssize_t
FastOS_Linux_File::readInternal(int fh, void *buffer, size_t length, int64_t readOffset)
{
ssize_t readResult = ::pread(fh, buffer, length, readOffset);
- if (readResult < 0 && _failedHandler != NULL) {
+ if (readResult < 0 && _failedHandler != nullptr) {
int error = errno;
const char *fileName = GetFileName();
_failedHandler("read", fileName, error, readOffset, length, readResult);
@@ -45,7 +45,7 @@ ssize_t
FastOS_Linux_File::readInternal(int fh, void *buffer, size_t length)
{
ssize_t readResult = ::read(fh, buffer, length);
- if (readResult < 0 && _failedHandler != NULL) {
+ if (readResult < 0 && _failedHandler != nullptr) {
int error = errno;
int64_t readOffset = GetPosition();
const char *fileName = GetFileName();
@@ -60,7 +60,7 @@ ssize_t
FastOS_Linux_File::writeInternal(int fh, const void *buffer, size_t length, int64_t writeOffset)
{
ssize_t writeRes = ::pwrite(fh, buffer, length, writeOffset);
- if (writeRes < 0 && _failedHandler != NULL) {
+ if (writeRes < 0 && _failedHandler != nullptr) {
int error = errno;
const char *fileName = GetFileName();
_failedHandler("write", fileName, error, writeOffset, length, writeRes);
@@ -73,7 +73,7 @@ ssize_t
FastOS_Linux_File::writeInternal(int fh, const void *buffer, size_t length)
{
ssize_t writeRes = ::write(fh, buffer, length);
- if (writeRes < 0 && _failedHandler != NULL) {
+ if (writeRes < 0 && _failedHandler != nullptr) {
int error = errno;
int64_t writeOffset = GetPosition();
const char *fileName = GetFileName();
diff --git a/fastos/src/vespa/fastos/linux_file.h b/fastos/src/vespa/fastos/linux_file.h
index 95f2b935958..e304b6f0ce8 100644
--- a/fastos/src/vespa/fastos/linux_file.h
+++ b/fastos/src/vespa/fastos/linux_file.h
@@ -9,7 +9,7 @@
#pragma once
-#include <vespa/fastos/unix_file.h>
+#include "unix_file.h"
/**
* This is the Linux implementation of @ref FastOS_File. Most
@@ -24,7 +24,7 @@ protected:
int64_t _filePointer; // Only maintained/used in directio mode
public:
- FastOS_Linux_File (const char *filename = NULL);
+ FastOS_Linux_File (const char *filename = nullptr);
~FastOS_Linux_File () {
Close();
}
@@ -57,5 +57,4 @@ private:
static const size_t _directIOFileAlign;
static const size_t _directIOMemAlign;
- static const size_t _pageSize;
};
diff --git a/fastos/src/vespa/fastos/mutex.h b/fastos/src/vespa/fastos/mutex.h
index 011340b46ca..530e8d007bc 100644
--- a/fastos/src/vespa/fastos/mutex.h
+++ b/fastos/src/vespa/fastos/mutex.h
@@ -9,8 +9,7 @@
#pragma once
-#include <vespa/fastos/types.h>
-
+#include "types.h"
/**
* This class defines a mutual-exclusion object.
@@ -31,7 +30,7 @@ public:
/**
* Destructor
*/
- virtual ~FastOS_MutexInterface () {};
+ virtual ~FastOS_MutexInterface () {}
/**
* Obtain an exclusive lock on the mutex. The result of a recursive lock
@@ -42,7 +41,7 @@ public:
*
* Use @ref Unlock() to unlock the mutex when done.
*/
- virtual void Lock (void)=0;
+ virtual void Lock ()=0;
/**
* Try to obtain an exclusive lock on the mutex. If a lock cannot be
@@ -51,15 +50,15 @@ public:
* the mutex was locked in the attempt, true is returned.
* @return Boolean success/failure
*/
- virtual bool TryLock (void)=0;
+ virtual bool TryLock ()=0;
/**
* Unlock a locked mutex. The result of unlocking a mutex not already
* locked by the calling thread is undefined.
*/
- virtual void Unlock (void)=0;
+ virtual void Unlock ()=0;
};
-#include <vespa/fastos/unix_mutex.h>
+#include "unix_mutex.h"
typedef FastOS_UNIX_Mutex FASTOS_PREFIX(Mutex);
diff --git a/fastos/src/vespa/fastos/process.cpp b/fastos/src/vespa/fastos/process.cpp
new file mode 100644
index 00000000000..cac491de1e1
--- /dev/null
+++ b/fastos/src/vespa/fastos/process.cpp
@@ -0,0 +1,26 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "process.h"
+#include <string.h>
+
+FastOS_ProcessInterface::FastOS_ProcessInterface (const char *cmdLine,
+ bool pipeStdin,
+ FastOS_ProcessRedirectListener *stdoutListener,
+ FastOS_ProcessRedirectListener *stderrListener,
+ int bufferSize) :
+ _extradoublehackforalignment(0.0),
+ _cmdLine(nullptr),
+ _pipeStdin(pipeStdin),
+ _stdoutListener(stdoutListener),
+ _stderrListener(stderrListener),
+ _bufferSize(bufferSize),
+ _next(nullptr),
+ _prev(nullptr)
+{
+ _cmdLine = strdup(cmdLine);
+}
+
+FastOS_ProcessInterface::~FastOS_ProcessInterface ()
+{
+ free (_cmdLine);
+}
diff --git a/fastos/src/vespa/fastos/process.h b/fastos/src/vespa/fastos/process.h
index 62578f97e44..f0c1fcaa2a9 100644
--- a/fastos/src/vespa/fastos/process.h
+++ b/fastos/src/vespa/fastos/process.h
@@ -10,7 +10,8 @@
#pragma once
-#include <vespa/fastos/types.h>
+#include "types.h"
+#include <cstddef>
/**
* This class serves as a sink for redirected (piped) output from
@@ -25,7 +26,7 @@ public:
* You should assume that any thread can invoke this method.
* For convenience the data buffer is always zero- terminated
* (static_cast<uint8_t>(data[length]) = '\\0').
- * When the pipe closes, the method is invoked with data = NULL
+ * When the pipe closes, the method is invoked with data = nullptr
* and length = 0.
* @param data Pointer to data
* @param length Length of data block in bytes
@@ -75,7 +76,7 @@ public:
* of PrefopenNoInherit.
* @return Internal data needed to cancel object inheritance.
*/
- static void *PrefopenNoInherit (void) {return NULL;}
+ static void *PrefopenNoInherit (void) {return nullptr;}
/**
* Call this after opening files with fopen to avoid having
@@ -104,35 +105,21 @@ public:
* @ref CreateWithShell to actually start the process.
* @param cmdLine Command line
* @param pipeStdin set to true in order to redirect stdin
- * @param stdoutListener non-NULL to redirect stdout
- * @param stderrListener non-NULL to redirect stderr
+ * @param stdoutListener non-nullptr to redirect stdout
+ * @param stderrListener non-nullptr to redirect stderr
* @param bufferSize Size of redirect buffers
*/
FastOS_ProcessInterface (const char *cmdLine,
bool pipeStdin = false,
- FastOS_ProcessRedirectListener *stdoutListener = NULL,
- FastOS_ProcessRedirectListener *stderrListener = NULL,
- int bufferSize = 65535) :
- _extradoublehackforalignment(0.0),
- _cmdLine(NULL),
- _pipeStdin(pipeStdin),
- _stdoutListener(stdoutListener),
- _stderrListener(stderrListener),
- _bufferSize(bufferSize),
- _next(NULL),
- _prev(NULL)
- {
- _cmdLine = strdup(cmdLine);
- }
+ FastOS_ProcessRedirectListener *stdoutListener = nullptr,
+ FastOS_ProcessRedirectListener *stderrListener = nullptr,
+ int bufferSize = 65535);
/**
* Destructor.
* If @ref Wait has not been called yet, it is called here.
*/
- virtual ~FastOS_ProcessInterface ()
- {
- free (_cmdLine);
- };
+ virtual ~FastOS_ProcessInterface ();
/**
* Create and start the process. If your command line includes
@@ -167,7 +154,7 @@ public:
/**
* If you are redirecting the standard input stream of the process,
* use this method to write data. To close the input stream,
- * invoke @ref WriteStdin with data=NULL. If the input stream
+ * invoke @ref WriteStdin with data=nullptr. If the input stream
* is not redirected, @ref WriteStdin will fail.
* @param data Pointer to data
* @param length Length of data block in bytes
diff --git a/fastos/src/vespa/fastos/serversocket.cpp b/fastos/src/vespa/fastos/serversocket.cpp
index 335c34a29b4..a79e163db17 100644
--- a/fastos/src/vespa/fastos/serversocket.cpp
+++ b/fastos/src/vespa/fastos/serversocket.cpp
@@ -1,12 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-//************************************************************************
-/**
- * Implementation of FastOS_ServerSocket methods.
- *
- * @author Div, Oivind H. Danielsen
- */
-#include <vespa/fastos/serversocket.h>
+#include "serversocket.h"
+#include <netinet/in.h>
+#include <cstring>
/**
@@ -22,77 +18,69 @@ void FastOS_ServerSocket::SetSocketFactory(FastOS_SocketFactory *socketFactory)
FastOS_SocketInterface *FastOS_ServerSocket::CreateHandlerSocket(void)
{
- FastOS_SocketInterface *newSocket = NULL;
-
- if (_socketFactory != NULL)
- {
- newSocket = _socketFactory->CreateSocket();
- }
- else
- {
- newSocket = new FastOS_Socket();
- }
- return newSocket;
+ return (_socketFactory != nullptr)
+ ? _socketFactory->CreateSocket()
+ : (FastOS_SocketInterface *)new FastOS_Socket();
}
FastOS_SocketInterface *FastOS_ServerSocket::Accept()
{
- FastOS_SocketInterface *handlerSocket = NULL;
- int handlerSocketHandle;
struct sockaddr_storage clientAddress;
socklen_t clientAddressLength = sizeof(clientAddress);
memset(&clientAddress, 0, sizeof(clientAddress));
- handlerSocketHandle = accept(_socketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress),
- &clientAddressLength);
+ int handlerSocketHandle = accept(_socketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress),
+ &clientAddressLength);
- if (handlerSocketHandle >= 0)
- {
- handlerSocket = CreateHandlerSocket();
+ if (handlerSocketHandle >= 0) {
+ FastOS_SocketInterface *handlerSocket = CreateHandlerSocket();
- if (handlerSocket != NULL)
- {
- handlerSocket->SetUp(handlerSocketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress));
+ if (handlerSocket != nullptr) {
+ handlerSocket->SetUp(handlerSocketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress));
}
+ return handlerSocket;
}
- return handlerSocket;
+ return nullptr;
}
FastOS_Socket *FastOS_ServerSocket::AcceptPlain()
{
- FastOS_Socket *handlerSocket = NULL;
- int handlerSocketHandle;
struct sockaddr_storage clientAddress;
socklen_t clientAddressLength = sizeof(clientAddress);
memset(&clientAddress, 0, sizeof(clientAddress));
- handlerSocketHandle = accept(_socketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress),
- &clientAddressLength);
+ int handlerSocketHandle = accept(_socketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress),
+ &clientAddressLength);
- if (handlerSocketHandle >= 0)
- {
- handlerSocket = new FastOS_Socket();
+ if (handlerSocketHandle >= 0) {
+ FastOS_Socket *handlerSocket = new FastOS_Socket();
- if (handlerSocket != NULL)
- {
- handlerSocket->SetUp(handlerSocketHandle,
- reinterpret_cast<struct sockaddr *>(&clientAddress));
+ if (handlerSocket != nullptr) {
+ handlerSocket->SetUp(handlerSocketHandle, reinterpret_cast<struct sockaddr *>(&clientAddress));
}
+ return handlerSocket;
}
- return handlerSocket;
+ return nullptr;
}
+FastOS_ServerSocket::FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory)
+ : _portNumber(-1),
+ _backLog(-1),
+ _socketFactory(socketFactory),
+ _validAddress(false)
+{
+ _socketHandle = socketHandle;
+ memset(&_address, 0, sizeof(_address));
+ _validAddress = true;
+}
bool FastOS_ServerSocket::Listen ()
{
@@ -106,8 +94,7 @@ bool FastOS_ServerSocket::Listen ()
(_address.ss_family == AF_INET6 &&
reinterpret_cast<const sockaddr_in6 &>(_address).sin6_port != 0))
reuseAddr = true;
- if (SetSoReuseAddr(reuseAddr))
- {
+ if (SetSoReuseAddr(reuseAddr)) {
size_t socketAddrLen;
switch (_address.ss_family)
{
@@ -124,11 +111,8 @@ bool FastOS_ServerSocket::Listen ()
default:
socketAddrLen = sizeof(sockaddr_storage);
}
- if(bind(_socketHandle, reinterpret_cast<struct sockaddr *>(&_address),
- socketAddrLen) >= 0)
- {
- if(listen(_socketHandle, _backLog) >= 0)
- {
+ if(bind(_socketHandle, reinterpret_cast<struct sockaddr *>(&_address), socketAddrLen) >= 0) {
+ if(listen(_socketHandle, _backLog) >= 0) {
rc = true;
}
}
diff --git a/fastos/src/vespa/fastos/serversocket.h b/fastos/src/vespa/fastos/serversocket.h
index 77e7beee55a..2e0690ffc3b 100644
--- a/fastos/src/vespa/fastos/serversocket.h
+++ b/fastos/src/vespa/fastos/serversocket.h
@@ -10,7 +10,7 @@
#pragma once
-#include <vespa/fastos/socket.h>
+#include "socket.h"
/**
@@ -74,14 +74,14 @@ protected:
/**
* The socket factory to use for incoming connections.
- * If this is NULL, the default action is to create an
+ * If this is nullptr, the default action is to create an
* instance of the regular @ref FastOS_Socket.
*/
FastOS_SocketFactory *_socketFactory;
/**
* Create socket for handling an incoming connection
- * @return Returns pointer to newly created socket, or NULL on
+ * @return Returns pointer to newly created socket, or nullptr on
* failure.
*/
FastOS_SocketInterface *CreateHandlerSocket();
@@ -98,8 +98,8 @@ public:
* @param strictBindHostName IP address or hostname for strict binding
*/
FastOS_ServerSocket (int portnum, int backLog=5,
- FastOS_SocketFactory *socketFactory=NULL,
- const char *strictBindHostName=NULL)
+ FastOS_SocketFactory *socketFactory=nullptr,
+ const char *strictBindHostName=nullptr)
: _portNumber(portnum),
_backLog(backLog),
_socketFactory(socketFactory),
@@ -118,17 +118,7 @@ public:
* @param socketHandle OS handle of supplied socket.
* @param socketFactory See @ref SetSocketFactory().
*/
- FastOS_ServerSocket(int socketHandle,
- FastOS_SocketFactory *socketFactory)
- : _portNumber(-1),
- _backLog(-1),
- _socketFactory(socketFactory),
- _validAddress(false)
- {
- _socketHandle = socketHandle;
- memset(&_address, 0, sizeof(_address));
- _validAddress = true;
- }
+ FastOS_ServerSocket(int socketHandle, FastOS_SocketFactory *socketFactory);
/**
* Create a listening socket. This involves creating an OS
@@ -136,7 +126,7 @@ public:
* start to listen for incoming connections. You should
* call @ref Listen() if you have supplied a pre-created listening
* socket handle trough the constructor
- * @ref FastOS_ServerSocket(int listenSocketHandle, FastOS_SocketFactory *socketFactory=NULL).
+ * @ref FastOS_ServerSocket(int listenSocketHandle, FastOS_SocketFactory *socketFactory=nullptr).
* @return Boolean success/failure
*/
bool Listen ();
@@ -147,7 +137,7 @@ public:
* Make sure you have a listening socket (see @ref Listen()) before
* calling @ref Accept().
* @return Returns pointer to newly created socket object for the
- * connection that was accepted, or NULL on failure.
+ * connection that was accepted, or nullptr on failure.
*/
FastOS_SocketInterface *Accept ();
@@ -157,7 +147,7 @@ public:
* Make sure you have a listening socket (see @ref Listen()) before
* calling @ref AcceptPlain().
* @return Returns pointer to newly created socket object for the
- * connection that was accepted, or NULL on failure.
+ * connection that was accepted, or nullptr on failure.
*/
FastOS_Socket *AcceptPlain ();
@@ -167,7 +157,7 @@ public:
* factory will be called to create a new socket object for the
* connection.
*
- * SetSocketFactory(NULL) will enable the default socket factory
+ * SetSocketFactory(nullptr) will enable the default socket factory
* mechanism which will create regular @ref FastOS_Socket instances
* on accepted connections.
*/
diff --git a/fastos/src/vespa/fastos/socket.cpp b/fastos/src/vespa/fastos/socket.cpp
index 522d39c4b32..c274f42bc68 100644
--- a/fastos/src/vespa/fastos/socket.cpp
+++ b/fastos/src/vespa/fastos/socket.cpp
@@ -1,7 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/socket.h>
+#include "socket.h"
#include <sstream>
+#include <cassert>
+#include <cstring>
+#include <netinet/tcp.h>
+#include <netinet/in.h>
+#include <netdb.h>
FastOS_SocketInterface::FastOS_SocketInterface()
: _readEventEnabled(false),
@@ -9,8 +14,8 @@ FastOS_SocketInterface::FastOS_SocketInterface()
_readPossible(false),
_writePossible(false),
_epolled(false),
- _socketEvent(NULL),
- _eventAttribute(NULL),
+ _socketEvent(nullptr),
+ _eventAttribute(nullptr),
_socketEventArrayPos(-1),
_address(),
_socketHandle(-1),
@@ -25,8 +30,8 @@ FastOS_SocketInterface::FastOS_SocketInterface(int socketHandle, struct sockaddr
_readPossible(false),
_writePossible(false),
_epolled(false),
- _socketEvent(NULL),
- _eventAttribute(NULL),
+ _socketEvent(nullptr),
+ _eventAttribute(nullptr),
_socketEventArrayPos(-1),
_address(),
_socketHandle(-1),
@@ -140,10 +145,10 @@ void FastOS_SocketInterface::ConstructorWork ()
{
_socketHandle = -1;
_epolled = false;
- _socketEvent = NULL;
+ _socketEvent = nullptr;
_readEventEnabled = false;
_writeEventEnabled = false;
- _eventAttribute = NULL;
+ _eventAttribute = nullptr;
_socketEventArrayPos = -1;
}
@@ -229,10 +234,10 @@ bool FastOS_SocketInterface::GetSoIntOpt(int option, int &value)
void FastOS_SocketInterface::CleanupEvents ()
{
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
_socketEvent->Detach(this);
assert(!_epolled);
- _socketEvent = NULL;
+ _socketEvent = nullptr;
}
}
@@ -261,6 +266,19 @@ int FastOS_SocketInterface::GetLocalPort ()
return result;
}
+unsigned short
+FastOS_SocketInterface::GetPort () const
+{
+ switch (_address.ss_family) {
+ case AF_INET:
+ return reinterpret_cast<const sockaddr_in &>(_address).sin_port;
+ case AF_INET6:
+ return reinterpret_cast<const sockaddr_in6 &>(_address).sin6_port;
+ default:
+ return 0;
+ }
+}
+
std::string
FastOS_SocketInterface::getLastErrorString(void) {
return FastOS_Socket::getErrorString(FastOS_Socket::GetLastError());
@@ -269,7 +287,7 @@ FastOS_SocketInterface::getLastErrorString(void) {
const char *
FastOS_SocketInterface::InitializeServices(void) {
FastOS_SocketEventObjects::InitializeClass();
- return NULL;
+ return nullptr;
}
void FastOS_SocketInterface::CleanupServices () {
@@ -283,14 +301,14 @@ bool FastOS_SocketInterface::SetSocketEvent (FastOS_SocketEvent *event, void *at
if (CreateIfNoSocketYet()) {
if (_socketEvent != event) {
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
// Disable events for this socket on the old SocketEvent
_socketEvent->Detach(this);
assert(!_epolled);
- _socketEvent = NULL;
+ _socketEvent = nullptr;
}
- if (event != NULL) {
+ if (event != nullptr) {
event->Attach(this, _readEventEnabled, _writeEventEnabled);
_socketEvent = event;
}
@@ -304,7 +322,7 @@ bool FastOS_SocketInterface::SetSocketEvent (FastOS_SocketEvent *event, void *at
void FastOS_SocketInterface::EnableReadEvent (bool enabled) {
if (_readEventEnabled == enabled) { return; }
_readEventEnabled = enabled;
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
_socketEvent->EnableEvent(this, _readEventEnabled, _writeEventEnabled);
}
}
@@ -319,7 +337,7 @@ void FastOS_SocketInterface::EnableReadEvent (bool enabled) {
void FastOS_SocketInterface::EnableWriteEvent (bool enabled) {
if (_writeEventEnabled == enabled) { return; }
_writeEventEnabled = enabled;
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
_socketEvent->EnableEvent(this, _readEventEnabled, _writeEventEnabled);
}
}
diff --git a/fastos/src/vespa/fastos/socket.h b/fastos/src/vespa/fastos/socket.h
index 1d4bf31bf52..31b8903a4e4 100644
--- a/fastos/src/vespa/fastos/socket.h
+++ b/fastos/src/vespa/fastos/socket.h
@@ -3,9 +3,8 @@
#pragma once
#include <vespa/fastos/types.h>
-
#include <string>
-#include <vector>
+#include <sys/socket.h>
class FastOS_SocketInterface;
class FastOS_ServerSocket;
@@ -64,7 +63,7 @@ public:
* Convenience method. Does GetErrorString(GetLastError())
* @return Error string
*/
- static std::string getLastErrorString(void);
+ static std::string getLastErrorString();
static const char *InitializeServices ();
static void CleanupServices ();
@@ -245,11 +244,11 @@ public:
* @param attribute Event attribute pointer
* @return Boolean success/failure.
*/
- bool SetSocketEvent (FastOS_SocketEvent *event, void *attribute=NULL);
+ bool SetSocketEvent (FastOS_SocketEvent *event, void *attribute=nullptr);
/**
* Get socket event object
- * @return Associated socket event object or NULL
+ * @return Associated socket event object or nullptr
*/
FastOS_SocketEvent *GetSocketEvent () { return _socketEvent; }
@@ -282,17 +281,7 @@ public:
/**
* Return socket port.
*/
- unsigned short GetPort () const
- {
- switch (_address.ss_family) {
- case AF_INET:
- return reinterpret_cast<const sockaddr_in &>(_address).sin_port;
- case AF_INET6:
- return reinterpret_cast<const sockaddr_in6 &>(_address).sin6_port;
- default:
- return 0;
- }
- }
+ unsigned short GetPort () const;
/**
* Tune the socket for transport use.
diff --git a/fastos/src/vespa/fastos/socketevent.cpp b/fastos/src/vespa/fastos/socketevent.cpp
index 7e5164d2247..a80cb015782 100644
--- a/fastos/src/vespa/fastos/socketevent.cpp
+++ b/fastos/src/vespa/fastos/socketevent.cpp
@@ -1,9 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/socketevent.h>
-#include <vespa/fastos/socket.h>
+#include "socketevent.h"
+#include "socket.h"
+#include <cassert>
+#include <unistd.h>
-FastOS_SocketEventObjects *FastOS_SocketEventObjects::_objects = NULL;
+
+FastOS_SocketEventObjects *FastOS_SocketEventObjects::_objects = nullptr;
FastOS_Mutex FastOS_SocketEventObjects::_listMutex;
int FastOS_SocketEventObjects::_objectCount = 0;
bool FastOS_SocketEventObjects::_initialized = false;
@@ -14,12 +17,12 @@ FastOS_SocketEvent::FastOS_SocketEvent () :
_socketsInArray(0),
_getEventsIndex(0),
_wokeUp(false),
- _objs(NULL)
+ _objs(nullptr)
{
_objs = FastOS_SocketEventObjects::ObtainObject(this);
- if(_objs != NULL) {
+ if(_objs != nullptr) {
if(_objs->_initOk) {
}
}
@@ -54,19 +57,19 @@ FastOS_SocketEventObjects *FastOS_SocketEventObjects::ObtainObject (FastOS_Socke
FastOS_SocketEventObjects *node;
_listMutex.Lock();
- if(_objects == NULL)
+ if(_objects == nullptr)
{
_objectCount++;
_listMutex.Unlock();
node = new FastOS_SocketEventObjects(event);
- node->_next = NULL;
+ node->_next = nullptr;
}
else
{
node = _objects;
_objects = node->_next;
- node->_next = NULL;
+ node->_next = nullptr;
_listMutex.Unlock();
}
@@ -76,7 +79,7 @@ FastOS_SocketEventObjects *FastOS_SocketEventObjects::ObtainObject (FastOS_Socke
void FastOS_SocketEventObjects::ReleaseObject (FastOS_SocketEventObjects *node)
{
- if (node != NULL)
+ if (node != nullptr)
node->ReleasedCleanup();
_listMutex.Lock();
@@ -96,7 +99,7 @@ bool
FastOS_SocketEvent::epollInit()
{
_epollfd = epoll_create(4093);
- if (_epollfd != -1 && _objs != NULL && _objs->_initOk) {
+ if (_epollfd != -1 && _objs != nullptr && _objs->_initOk) {
epoll_event evt;
evt.events = EPOLLIN;
evt.data.ptr = 0;
@@ -150,7 +153,7 @@ FastOS_SocketEvent::epollWait(bool &error, int msTimeout)
for (int i = 0; i < res; ++i) {
const epoll_event &evt = _epollEvents[i];
FastOS_SocketInterface *sock = (FastOS_SocketInterface *) evt.data.ptr;
- if (sock == NULL) {
+ if (sock == nullptr) {
HandleWakeUp();
} else {
sock->_readPossible = sock->_readEventEnabled &&
@@ -179,7 +182,7 @@ FastOS_SocketEvent::epollGetEvents(bool *wakeUp, int msTimeout,
const epoll_event &evt = _epollEvents[i];
FastOS_IOEvent &appEvt = events[idx];
FastOS_SocketInterface *sock = (FastOS_SocketInterface *) evt.data.ptr;
- if (sock == NULL) {
+ if (sock == nullptr) {
HandleWakeUp(); // sets _wokeUp
} else {
appEvt._readOccurred = sock->_readEventEnabled &&
@@ -224,7 +227,7 @@ void FastOS_SocketEventObjects::ClassCleanup(void)
{
FastOS_SocketEventObjects *node = _objects;
- if(node == NULL)
+ if(node == nullptr)
break;
else
{
@@ -238,11 +241,11 @@ void FastOS_SocketEventObjects::ClassCleanup(void)
FastOS_SocketEventObjects::FastOS_SocketEventObjects(FastOS_SocketEvent *event)
- : _next(NULL),
+ : _next(nullptr),
_initOk(false),
- _socketArray(NULL),
+ _socketArray(nullptr),
_socketArrayAllocSize(0u),
- _pollfds(NULL),
+ _pollfds(nullptr),
_pollfdsAllocSize(0)
{
// Connect ourselves to the socketevent object.
@@ -256,12 +259,12 @@ FastOS_SocketEventObjects::ReleasedCleanup(void)
{
if (_socketArrayAllocSize > 16) {
delete [] _socketArray;
- _socketArray = NULL;
+ _socketArray = nullptr;
_socketArrayAllocSize = 0;
}
if (_pollfdsAllocSize > 16) {
free(_pollfds);
- _pollfds = NULL;
+ _pollfds = nullptr;
_pollfdsAllocSize = 0;
}
}
diff --git a/fastos/src/vespa/fastos/socketevent.h b/fastos/src/vespa/fastos/socketevent.h
index 5a1e09b1765..5e457908ace 100644
--- a/fastos/src/vespa/fastos/socketevent.h
+++ b/fastos/src/vespa/fastos/socketevent.h
@@ -2,8 +2,8 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
+#include "types.h"
+#include "mutex.h"
#include <poll.h>
#include <sys/epoll.h>
@@ -47,8 +47,8 @@ public:
static FastOS_SocketEventObjects *_objects;
static FastOS_SocketEventObjects *ObtainObject (FastOS_SocketEvent *event);
static void ReleaseObject (FastOS_SocketEventObjects *node);
- static void ClassCleanup(void);
- static void InitializeClass(void);
+ static void ClassCleanup();
+ static void InitializeClass();
};
@@ -87,7 +87,7 @@ public:
* FastOS_SocketEvent socketEvent;
*
* // Walk through single-linked list of connections
- * for(conn=connections; conn!=NULL; conn = conn->_next)
+ * for(conn=connections; conn!=nullptr; conn = conn->_next)
* {
* // Associate each socket with socketEvent
* conn->_socket->SetSocketEvent(&socketEvent);
@@ -105,7 +105,7 @@ public:
* if(socketEvent.Wait(200))
* {
* // Walk through list of connections
- * for(conn=connections; conn!=NULL; conn = conn->_next)
+ * for(conn=connections; conn!=nullptr; conn = conn->_next)
* {
* // For each socket, check for read event
* if(socketEvent.QueryReadEvent(conn->_socket))
@@ -172,7 +172,7 @@ public:
if (_epollfd == -1) {
return false;
}
- return (_objs != NULL) ? _objs->_initOk : false;
+ return (_objs != nullptr) ? _objs->_initOk : false;
}
/**
diff --git a/fastos/src/vespa/fastos/thread.cpp b/fastos/src/vespa/fastos/thread.cpp
index ccf9b544e77..3cd3bb4b85b 100644
--- a/fastos/src/vespa/fastos/thread.cpp
+++ b/fastos/src/vespa/fastos/thread.cpp
@@ -6,7 +6,9 @@
* @author Oivind H. Danielsen
*/
-#include <vespa/fastos/thread.h>
+#include "thread.h"
+#include <cstdio>
+#include <cassert>
// ----------------------------------------------------------------------
// FastOS_ThreadPool
@@ -19,8 +21,8 @@ FastOS_ThreadPool::FastOS_ThreadPool(int stackSize, int maxThreads)
_closeCalledFlag(false),
_freeMutex(),
_liveCond(),
- _freeThreads(NULL),
- _activeThreads(NULL),
+ _freeThreads(nullptr),
+ _activeThreads(nullptr),
_numFree(0),
_numActive(0),
_numTerminated(0),
@@ -69,9 +71,9 @@ void FastOS_ThreadPool::FreeThread (FastOS_ThreadInterface *thread)
void FastOS_ThreadPool::LinkOutThread (FastOS_ThreadInterface *thread, FastOS_ThreadInterface **listHead)
{
- if (thread->_prev != NULL)
+ if (thread->_prev != nullptr)
thread->_prev->_next = thread->_next;
- if (thread->_next != NULL)
+ if (thread->_next != nullptr)
thread->_next->_prev = thread->_prev;
if (thread == *listHead)
@@ -80,10 +82,10 @@ void FastOS_ThreadPool::LinkOutThread (FastOS_ThreadInterface *thread, FastOS_Th
void FastOS_ThreadPool::LinkInThread (FastOS_ThreadInterface *thread, FastOS_ThreadInterface **listHead)
{
- thread->_prev = NULL;
+ thread->_prev = nullptr;
thread->_next = *listHead;
- if (*listHead != NULL)
+ if (*listHead != nullptr)
(*listHead)->_prev = thread;
*listHead = thread;
@@ -106,12 +108,12 @@ void FastOS_ThreadPool::ActivateThread (FastOS_ThreadInterface *thread)
// make this thread call parameter fcn when it becomes active.
FastOS_ThreadInterface *FastOS_ThreadPool::NewThread (FastOS_Runnable *owner, void *arg)
{
- FastOS_ThreadInterface *thread=NULL;
+ FastOS_ThreadInterface *thread=nullptr;
_freeMutex.Lock();
if (!isClosed()) {
- if ((thread = _freeThreads) != NULL) {
+ if ((thread = _freeThreads) != nullptr) {
// Reusing thread entry
_freeThreads = thread->_next;
_numFree--;
@@ -132,7 +134,7 @@ FastOS_ThreadInterface *FastOS_ThreadPool::NewThread (FastOS_Runnable *owner, vo
thread = FastOS_Thread::CreateThread(this);
- if (thread == NULL) {
+ if (thread == nullptr) {
_liveCond.Lock();
_numLive--;
if (_numLive == 0) {
@@ -143,14 +145,14 @@ FastOS_ThreadInterface *FastOS_ThreadPool::NewThread (FastOS_Runnable *owner, vo
_freeMutex.Lock();
- if(thread != NULL)
+ if(thread != nullptr)
ActivateThread(thread);
}
}
}
_freeMutex.Unlock();
- if(thread != NULL) {
+ if(thread != nullptr) {
_liveCond.Lock();
thread->Dispatch(owner, arg);
_liveCond.Unlock();
@@ -167,12 +169,12 @@ void FastOS_ThreadPool::BreakThreads ()
_freeMutex.Lock();
// Notice all active threads that they should quit
- for(thread=_activeThreads; thread != NULL; thread=thread->_next) {
+ for(thread=_activeThreads; thread != nullptr; thread=thread->_next) {
thread->SetBreakFlag();
}
// Notice all free threads that they should quit
- for(thread=_freeThreads; thread != NULL; thread=thread->_next) {
+ for(thread=_freeThreads; thread != nullptr; thread=thread->_next) {
thread->SetBreakFlag();
}
@@ -199,7 +201,7 @@ void FastOS_ThreadPool::DeleteThreads ()
assert(_numActive == 0);
assert(_numLive == 0);
- while((thread = _freeThreads) != NULL) {
+ while((thread = _freeThreads) != nullptr) {
LinkOutThread(thread, &_freeThreads);
_numFree--;
// printf("deleting thread %p\n", thread);
@@ -241,7 +243,7 @@ void *FastOS_ThreadHook (void *arg)
FastOS_ThreadInterface *thread = static_cast<FastOS_ThreadInterface *>(arg);
thread->Hook();
- return NULL;
+ return nullptr;
}
};
@@ -262,7 +264,7 @@ void FastOS_ThreadInterface::Hook ()
_dispatched.Lock(); // BEGIN lock
- while (_owner == NULL && !(finished = _pool->isClosed())) {
+ while (_owner == nullptr && !(finished = _pool->isClosed())) {
_dispatched.Wait();
}
@@ -278,8 +280,8 @@ void FastOS_ThreadInterface::Hook ()
if (deleteOnCompletion) {
delete _owner;
}
- _owner = NULL;
- _startArg = NULL;
+ _owner = nullptr;
+ _startArg = nullptr;
_breakFlag = false;
finished = _pool->isClosed();
@@ -341,7 +343,7 @@ FastOS_ThreadInterface *FastOS_ThreadInterface::CreateThread(FastOS_ThreadPool *
if(!thread->Initialize(pool->GetStackSize(), pool->GetStackGuardSize())) {
delete(thread);
- thread = NULL;
+ thread = nullptr;
}
return thread;
@@ -358,16 +360,16 @@ void FastOS_ThreadInterface::Join ()
// ----------------------------------------------------------------------
FastOS_Runnable::FastOS_Runnable(void)
- : _thread(NULL)
+ : _thread(nullptr)
{
}
FastOS_Runnable::~FastOS_Runnable(void)
{
- // assert(_thread == NULL);
+ // assert(_thread == nullptr);
}
void FastOS_Runnable::Detach(void)
{
- _thread = NULL;
+ _thread = nullptr;
}
diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h
index 24a4b1768fc..eb43fc6b664 100644
--- a/fastos/src/vespa/fastos/thread.h
+++ b/fastos/src/vespa/fastos/thread.h
@@ -11,9 +11,9 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/mutex.h>
-#include <vespa/fastos/cond.h>
+#include "types.h"
+#include "mutex.h"
+#include "cond.h"
typedef pthread_t FastOS_ThreadId;
@@ -158,9 +158,9 @@ public:
* @param owner Instance to be invoked by new thread.
* @param arg Arguments to be passed to new thread.
*
- * @return Pointer to newly created thread or NULL on failure.
+ * @return Pointer to newly created thread or nullptr on failure.
*/
- FastOS_ThreadInterface *NewThread (FastOS_Runnable *owner, void *arg=NULL);
+ FastOS_ThreadInterface *NewThread (FastOS_Runnable *owner, void *arg=nullptr);
/**
* Get the stack size used for threads in this pool.
@@ -285,7 +285,7 @@ protected:
* Create an operating system thread. In most cases you would want
* to create threads using @ref FastOS_ThreadPool::NewThread() instead.
* @param pool The threadpool which is about to contain the new thread.
- * @return A new @ref FastOS_Thread or NULL on failure.
+ * @return A new @ref FastOS_Thread or nullptr on failure.
*/
static FastOS_ThreadInterface *CreateThread(FastOS_ThreadPool *pool);
@@ -325,11 +325,11 @@ public:
*/
FastOS_ThreadInterface (FastOS_ThreadPool *pool)
: _dispatched(),
- _next(NULL),
- _prev(NULL),
- _owner(NULL),
+ _next(nullptr),
+ _prev(nullptr),
+ _owner(nullptr),
_pool(pool),
- _startArg(NULL),
+ _startArg(nullptr),
_breakFlag(false),
_active(false),
_runningCond()
@@ -492,7 +492,7 @@ public:
FastOS_ThreadInterface *GetThread(void) { return _thread; }
const FastOS_ThreadInterface *GetThread(void) const { return _thread; }
- bool HasThread(void) const { return _thread != NULL; }
+ bool HasThread(void) const { return _thread != nullptr; }
void Detach(void);
};
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index c671b71de8c..f967ea5aade 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/timestamp.h>
-#include <vespa/fastos/mutex.h>
+#include "timestamp.h"
#include <cmath>
+#include <sys/time.h>
namespace fastos {
@@ -32,7 +32,7 @@ TimeStamp::asString(double timeInSeconds)
int64_t ClockSystem::now()
{
struct timeval timeNow;
- gettimeofday(&timeNow, NULL);
+ gettimeofday(&timeNow, nullptr);
int64_t ns = timeNow.tv_sec;
ns *= TimeStamp::NANO;
ns += timeNow.tv_usec*1000;
diff --git a/fastos/src/vespa/fastos/types.h b/fastos/src/vespa/fastos/types.h
index 08ad40ac8be..c474558cdcc 100644
--- a/fastos/src/vespa/fastos/types.h
+++ b/fastos/src/vespa/fastos/types.h
@@ -1,113 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-//****************************************************************************
-/**
- * @file
- * Type definitions used in FastOS.
- * @author Oivind H. Danielsen
- * @date Creation date: 2000-01-18
- *****************************************************************************/
-
#pragma once
-/**
- * @def __STDC_LIMIT_MACROS
- * According to C99, C++ implementations will only define UINT64_MAX
- * etc when __STDC_LIMIT_MACROS is defined when including stdint.h.
- * UINT64_C etc will only be defined when __STDC_CONSTANT_MACROS is
- * defined. Since this file can be included from any of the files
- * below, we define the behaviour here.
- */
-#ifndef __STDC_LIMIT_MACROS
- #define __STDC_LIMIT_MACROS 1
-#endif
-#ifndef __STDC_CONSTANT_MACROS
- #define __STDC_CONSTANT_MACROS 1
-#endif
-#ifndef __STDC_FORMAT_MACROS
- #define __STDC_FORMAT_MACROS
-#endif
-
-#include <assert.h>
-
-#include <pthread.h>
-#include <sys/mman.h>
-
-#ifdef __TYPES_H_PTHREAD_U98
-#undef __USE_UNIX98
-#endif
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/utsname.h>
-#include <rpc/types.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-#ifndef __USE_UNIX98
-#define __TYPES_H_UNISTD_U98
-#define __USE_UNIX98
-#endif
-#include <unistd.h>
-#ifdef __TYPES_H_UNISTD_U98
-#undef __USE_UNIX98
-#endif
-
-#include <dirent.h>
-
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include <sys/resource.h>
-#include <signal.h>
-
-#include <sys/time.h>
-#include <time.h>
-
-#ifndef __USE_GNU
-#define __USE_GNU /* for O_DIRECT define */
-#define __TYPES_H_DIRECTIO_GNU
-#endif
-
-#include <fcntl.h>
-
-#ifdef __TYPES_H_DIRECTIO_GNU
-#undef __USE_GNU /* for O_DIRECT define */
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <float.h>
-#include <netinet/tcp.h>
-#include <inttypes.h>
-#include <getopt.h>
-
-#if (__WORDSIZE == 64)
-
-#else
- #error "Only LP 64 environments are supported."
-#endif
-
#define FASTOS_PREFIX(a) FastOS_##a
-#define FASTOS_EMFILE_VERIFIED (-1)
-#ifdef EMFILE
-#undef FASTOS_EMFILE_VERIFIED
-#define FASTOS_EMFILE_VERIFIED EMFILE
-#endif
-
-#define FASTOS_ENFILE_VERIFIED (-1)
-#ifdef ENFILE
-#undef FASTOS_ENFILE_VERIFIED
-#define FASTOS_ENFILE_VERIFIED ENFILE
-#endif
diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp
index d52813ceb76..7682b2d5b8f 100644
--- a/fastos/src/vespa/fastos/unix_app.cpp
+++ b/fastos/src/vespa/fastos/unix_app.cpp
@@ -7,15 +7,18 @@
* Implementation of FastOS_UNIX_Application methods.
*****************************************************************************/
-#include <vespa/fastos/app.h>
-#include <vespa/fastos/time.h>
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/unix_ipc.h>
+#include "app.h"
+#include "time.h"
+#include "process.h"
+#include "unix_ipc.h"
+#include <unistd.h>
+#include <csignal>
+#include <getopt.h>
FastOS_UNIX_Application::FastOS_UNIX_Application ()
- : _processStarter(NULL),
- _ipcHelper(NULL)
+ : _processStarter(nullptr),
+ _ipcHelper(nullptr)
{
}
@@ -33,12 +36,42 @@ unsigned int FastOS_UNIX_Application::GetCurrentProcessId ()
return static_cast<unsigned int>(getpid());
}
+int
+FastOS_UNIX_Application::GetOpt (const char *optionsString,
+ const char* &optionArgument,
+ int &optionIndex)
+{
+ optind = optionIndex;
+
+ int rc = getopt(_argc, _argv, optionsString);
+ optionArgument = optarg;
+ optionIndex = optind;
+ return rc;
+}
+
+int
+FastOS_UNIX_Application::GetOptLong(const char *optionsString,
+ const char* &optionArgument,
+ int &optionIndex,
+ const struct option *longopts,
+ int *longindex)
+{
+ optind = optionIndex;
+
+ int rc = getopt_long(_argc, _argv, optionsString,
+ longopts,
+ longindex);
+
+ optionArgument = optarg;
+ optionIndex = optind;
+ return rc;
+}
bool FastOS_UNIX_Application::
SendIPCMessage (FastOS_UNIX_Process *xproc, const void *buffer,
int length)
{
- if(_ipcHelper == NULL)
+ if(_ipcHelper == nullptr)
return false;
return _ipcHelper->SendMessage(xproc, buffer, length);
}
@@ -47,9 +80,9 @@ SendIPCMessage (FastOS_UNIX_Process *xproc, const void *buffer,
bool FastOS_UNIX_Application::
SendParentIPCMessage (const void *data, size_t length)
{
- if(_ipcHelper == NULL)
+ if(_ipcHelper == nullptr)
return false;
- return _ipcHelper->SendMessage(NULL, data, length);
+ return _ipcHelper->SendMessage(nullptr, data, length);
}
@@ -62,7 +95,7 @@ bool FastOS_UNIX_Application::PreThreadInit ()
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- sigaction(SIGPIPE, &act, NULL);
+ sigaction(SIGPIPE, &act, nullptr);
if (useProcessStarter()) {
_processStarter = new FastOS_UNIX_ProcessStarter(this);
@@ -87,7 +120,7 @@ bool FastOS_UNIX_Application::Init ()
int ipcDescriptor = -1;
char *env = getenv("FASTOS_IPC_PARENT");
- if(env != NULL)
+ if(env != nullptr)
{
int commaCount=0;
int notDigitCount=0;
@@ -125,15 +158,15 @@ bool FastOS_UNIX_Application::Init ()
void FastOS_UNIX_Application::Cleanup ()
{
- if(_ipcHelper != NULL)
+ if(_ipcHelper != nullptr)
_ipcHelper->Exit();
- if (_processStarter != NULL) {
+ if (_processStarter != nullptr) {
if (_processListMutex) ProcessLock();
_processStarter->Stop();
if (_processListMutex) ProcessUnlock();
delete _processStarter;
- _processStarter = NULL;
+ _processStarter = nullptr;
}
FastOS_ApplicationInterface::Cleanup();
@@ -148,13 +181,13 @@ FastOS_UNIX_Application::GetProcessStarter ()
void FastOS_UNIX_Application::
AddToIPCComm (FastOS_UNIX_Process *process)
{
- if(_ipcHelper != NULL)
+ if(_ipcHelper != nullptr)
_ipcHelper->AddProcess(process);
}
void FastOS_UNIX_Application::
RemoveFromIPCComm (FastOS_UNIX_Process *process)
{
- if(_ipcHelper != NULL)
+ if(_ipcHelper != nullptr)
_ipcHelper->RemoveProcess(process);
}
diff --git a/fastos/src/vespa/fastos/unix_app.h b/fastos/src/vespa/fastos/unix_app.h
index db6669813cf..49a5950c433 100644
--- a/fastos/src/vespa/fastos/unix_app.h
+++ b/fastos/src/vespa/fastos/unix_app.h
@@ -9,8 +9,8 @@
#pragma once
-#include <vespa/fastos/types.h>
-#include <vespa/fastos/app.h>
+#include "types.h"
+#include "app.h"
class FastOS_UNIX_ProcessStarter;
class FastOS_UNIX_IPCHelper;
@@ -34,34 +34,10 @@ public:
FastOS_UNIX_Application ();
virtual ~FastOS_UNIX_Application();
- int GetOpt (const char *optionsString,
- const char* &optionArgument,
- int &optionIndex)
- {
- optind = optionIndex;
+ int GetOpt (const char *optionsString, const char* &optionArgument, int &optionIndex);
- int rc = getopt(_argc, _argv, optionsString);
- optionArgument = optarg;
- optionIndex = optind;
- return rc;
- }
-
- int GetOptLong(const char *optionsString,
- const char* &optionArgument,
- int &optionIndex,
- const struct option *longopts,
- int *longindex)
- {
- optind = optionIndex;
-
- int rc = getopt_long(_argc, _argv, optionsString,
- longopts,
- longindex);
-
- optionArgument = optarg;
- optionIndex = optind;
- return rc;
- }
+ int GetOptLong(const char *optionsString, const char* &optionArgument, int &optionIndex,
+ const struct option *longopts, int *longindex);
static unsigned int GetCurrentProcessId ();
diff --git a/fastos/src/vespa/fastos/unix_cond.cpp b/fastos/src/vespa/fastos/unix_cond.cpp
index 6704ba5ea33..5eb1f5b0218 100644
--- a/fastos/src/vespa/fastos/unix_cond.cpp
+++ b/fastos/src/vespa/fastos/unix_cond.cpp
@@ -1,12 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/cond.h>
+#include "cond.h"
+#include <sys/time.h>
+#include <cstdint>
FastOS_UNIX_Cond::FastOS_UNIX_Cond(void)
: FastOS_CondInterface(),
_cond()
{
- pthread_cond_init(&_cond, NULL);
+ pthread_cond_init(&_cond, nullptr);
}
FastOS_UNIX_Cond::~FastOS_UNIX_Cond(void)
@@ -23,11 +25,12 @@ FastOS_UNIX_Cond::Wait(void)
bool
FastOS_UNIX_Cond::TimedWait(int milliseconds)
{
+
struct timeval currentTime;
struct timespec absTime;
int error;
- gettimeofday(&currentTime, NULL);
+ gettimeofday(&currentTime, nullptr);
int64_t ns = (static_cast<int64_t>(currentTime.tv_sec) *
static_cast<int64_t>(1000 * 1000 * 1000) +
diff --git a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
index f34bc053870..f3d3aa35511 100644
--- a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
+++ b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
@@ -20,7 +20,7 @@ bool hasValidSuffix(const std::string & s)
void
FastOS_UNIX_DynamicLibrary::SetLibName(const char *libname)
{
- if (libname != NULL) {
+ if (libname != nullptr) {
_libname = libname;
if ( ! hasValidSuffix(_libname)) {
_libname.append(FASTOS_DYNLIB_SUFFIX);
@@ -56,16 +56,16 @@ FastOS_UNIX_DynamicLibrary::Close()
bool retcode = true;
if (IsOpen()) {
- retcode = (dlclose(_handle) == TRUE);
+ retcode = (dlclose(_handle) == 0);
if (retcode)
- _handle = NULL;
+ _handle = nullptr;
}
return retcode;
}
FastOS_UNIX_DynamicLibrary::FastOS_UNIX_DynamicLibrary(const char *libname) :
- _handle(NULL),
+ _handle(nullptr),
_libname("")
{
SetLibName(libname);
@@ -81,13 +81,13 @@ FastOS_UNIX_DynamicLibrary::Open(const char *libname)
{
if (! Close())
return false;
- if (libname != NULL) {
+ if (libname != nullptr) {
SetLibName(libname);
}
_handle = dlopen(_libname.c_str(), RTLD_NOW);
- if (_handle == NULL) {
+ if (_handle == nullptr) {
// Prepend "lib" if neccessary...
if (NormalizeLibName()) {
// ...try to open again if a change was made.
@@ -95,7 +95,7 @@ FastOS_UNIX_DynamicLibrary::Open(const char *libname)
}
}
- return (_handle != NULL);
+ return (_handle != nullptr);
}
void *
@@ -109,7 +109,7 @@ FastOS_UNIX_DynamicLibrary::GetLastErrorString() const
{
const char *errorString = dlerror();
std::string e;
- if (errorString != NULL) {
+ if (errorString != nullptr) {
e = errorString;
}
diff --git a/fastos/src/vespa/fastos/unix_dynamiclibrary.h b/fastos/src/vespa/fastos/unix_dynamiclibrary.h
index 13e86b1c8af..1c891ee5b6d 100644
--- a/fastos/src/vespa/fastos/unix_dynamiclibrary.h
+++ b/fastos/src/vespa/fastos/unix_dynamiclibrary.h
@@ -24,17 +24,17 @@ private:
std::string _libname;
public:
- FastOS_UNIX_DynamicLibrary(const char *libname = NULL);
+ FastOS_UNIX_DynamicLibrary(const char *libname = nullptr);
~FastOS_UNIX_DynamicLibrary();
void SetLibName(const char *libname);
bool NormalizeLibName(void);
bool Close() override;
- bool Open(const char *libname = NULL) override;
+ bool Open(const char *libname = nullptr) override;
void * GetSymbol(const char *symbol) const override;
std::string GetLastErrorString() const;
const char * GetLibName() const { return _libname.c_str(); }
- bool IsOpen() const override { return (_handle != NULL); }
+ bool IsOpen() const override { return (_handle != nullptr); }
};
diff --git a/fastos/src/vespa/fastos/unix_file.cpp b/fastos/src/vespa/fastos/unix_file.cpp
index c4b1448c625..8b01a5255de 100644
--- a/fastos/src/vespa/fastos/unix_file.cpp
+++ b/fastos/src/vespa/fastos/unix_file.cpp
@@ -7,9 +7,16 @@
* Implementation of FastOS_UNIX_File methods.
*****************************************************************************/
-#include <vespa/fastos/file.h>
-#include <sys/vfs.h>
+#include "file.h"
#include <sstream>
+#include <cassert>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/vfs.h>
bool
FastOS_UNIX_File::SetPosition(int64_t desiredPosition)
@@ -59,6 +66,8 @@ FastOS_UNIX_File::Stat(const char *filename, FastOS_StatInfo *statInfo)
return rc;
}
+bool FastOS_UNIX_File::SetCurrentDirectory (const char *pathName) { return (chdir(pathName) == 0); }
+
int FastOS_UNIX_File::GetMaximumFilenameLength (const char *pathName)
{
@@ -164,10 +173,6 @@ FastOS_UNIX_File::Open(unsigned int openFlags, const char *filename)
FILE *file;
switch(openFlags & FASTOS_FILE_OPEN_STDFLAGS) {
- case FASTOS_FILE_OPEN_STDIN:
- file = stdin;
- SetFileName("stdin");
- break;
case FASTOS_FILE_OPEN_STDOUT:
file = stdout;
@@ -380,10 +385,10 @@ FastOS_UNIX_File::TranslateError (const int osError)
case ENXIO: return ERR_NXIO; // Device not configured
}
- if (osError == FASTOS_ENFILE_VERIFIED)
+ if (osError == ENFILE)
return ERR_NFILE;
- if (osError == FASTOS_EMFILE_VERIFIED)
+ if (osError == EMFILE)
return ERR_MFILE;
return ERR_UNKNOWN;
diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h
index 8ac520ccd53..5702f511ca5 100644
--- a/fastos/src/vespa/fastos/unix_file.h
+++ b/fastos/src/vespa/fastos/unix_file.h
@@ -43,20 +43,19 @@ public:
static std::string getCurrentDirectory();
- static bool SetCurrentDirectory (const char *pathName) { return (chdir(pathName) == 0); }
+ static bool SetCurrentDirectory (const char *pathName);
static int GetMaximumFilenameLength (const char *pathName);
static int GetMaximumPathLength (const char *pathName);
- FastOS_UNIX_File(const char *filename=NULL)
+ FastOS_UNIX_File(const char *filename=nullptr)
: FastOS_FileInterface(filename),
- _mmapbase(NULL),
+ _mmapbase(nullptr),
_mmaplen(0),
_filedes(-1),
_mmapFlags(0),
_mmapEnabled(false)
{ }
- char *ToString();
bool Open(unsigned int openFlags, const char *filename) override;
bool Close() override;
bool IsOpened() const override { return _filedes >= 0; }
@@ -67,18 +66,18 @@ public:
}
void *MemoryMapPtr(int64_t position) const override {
- if (_mmapbase != NULL) {
+ if (_mmapbase != nullptr) {
if (position < int64_t(_mmaplen)) {
return static_cast<void *>(static_cast<char *>(_mmapbase) + position);
} else { // This is an indication that the file size has changed and a remap/reopen must be done.
- return NULL;
+ return nullptr;
}
} else {
- return NULL;
+ return nullptr;
}
}
- bool IsMemoryMapped() const override { return _mmapbase != NULL; }
+ bool IsMemoryMapped() const override { return _mmapbase != nullptr; }
bool SetPosition(int64_t desiredPosition) override;
int64_t GetPosition() override;
int64_t GetSize() override;
@@ -95,8 +94,7 @@ public:
static int64_t GetFreeDiskSpace (const char *path);
};
-
-
+#include <dirent.h>
/**
* This is the generic UNIX implementation of @ref FastOS_DirectoryScan.
*/
diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp
index d02bc4189ca..695d395674f 100644
--- a/fastos/src/vespa/fastos/unix_ipc.cpp
+++ b/fastos/src/vespa/fastos/unix_ipc.cpp
@@ -1,11 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/unix_ipc.h>
-
-#include <vespa/fastos/ringbuffer.h>
+#include "unix_ipc.h"
+#include "ringbuffer.h"
+#include <cassert>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
FastOS_UNIX_IPCHelper::
-FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app,
- int descriptor)
+FastOS_UNIX_IPCHelper (FastOS_ApplicationInterface *app, int descriptor)
: _lock(),
_exitFlag(false),
_app(app),
@@ -116,7 +118,7 @@ SetBlocking (int fileDescriptor, bool doBlock)
{
bool rc=false;
- int flags = fcntl(fileDescriptor, F_GETFL, NULL);
+ int flags = fcntl(fileDescriptor, F_GETFL, nullptr);
if (flags != -1)
{
if(doBlock)
@@ -132,7 +134,7 @@ void FastOS_UNIX_IPCHelper::
BuildPollCheck(bool isRead, int filedes,
FastOS_RingBuffer *buffer, bool *check)
{
- if(buffer == NULL ||
+ if(buffer == nullptr ||
filedes < 0 ||
buffer->GetCloseFlag()) {
*check = false;
@@ -152,7 +154,7 @@ void FastOS_UNIX_IPCHelper::
PerformAsyncIO(void)
{
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -185,7 +187,7 @@ void FastOS_UNIX_IPCHelper::
BuildPollChecks(void)
{
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -200,11 +202,11 @@ BuildPollChecks(void)
}
}
- if(_appParentIPCDescriptor._writeBuffer.get() != NULL)
+ if(_appParentIPCDescriptor._writeBuffer.get() != nullptr)
BuildPollCheck(false, _appParentIPCDescriptor._fd,
_appParentIPCDescriptor._writeBuffer.get(),
&_appParentIPCDescriptor._wantWrite);
- if(_appParentIPCDescriptor._readBuffer.get() != NULL)
+ if(_appParentIPCDescriptor._readBuffer.get() != nullptr)
BuildPollCheck(true, _appParentIPCDescriptor._fd,
_appParentIPCDescriptor._readBuffer.get(),
&_appParentIPCDescriptor._wantRead);
@@ -223,12 +225,12 @@ ResizePollArray(pollfd **fds, unsigned int *allocnfds)
else
newallocnfds = *allocnfds * 2;
newfds = static_cast<pollfd *>(malloc(newallocnfds * sizeof(pollfd)));
- assert(newfds != NULL);
+ assert(newfds != nullptr);
if (*allocnfds > 0)
memcpy(newfds, *fds, sizeof(pollfd) * *allocnfds);
- if (*fds != NULL)
+ if (*fds != nullptr)
free(*fds);
*fds = newfds;
@@ -259,7 +261,7 @@ BuildPollArray(pollfd **fds, unsigned int *nfds, unsigned int *allocnfds)
rfds->revents = 0;
rfds++;
pollIdx = 1;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -329,7 +331,7 @@ SavePollArray(pollfd *fds, unsigned int nfds)
{
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -394,7 +396,7 @@ RemoveClosingProcesses(void)
FastOS_ProcessInterface *node, *next;
- for(node = _app->GetProcessList(); node != NULL; node = next)
+ for(node = _app->GetProcessList(); node != nullptr; node = next)
{
int type;
@@ -428,7 +430,7 @@ RemoveClosingProcesses(void)
if(!stillBusy)
{
- if(xproc->_closing != NULL)
+ if(xproc->_closing != nullptr)
{
// We already have the process lock at this point,
// so modifying the list is safe.
@@ -466,14 +468,14 @@ Run(FastOS_ThreadInterface *thisThread, void *arg)
unsigned int nfds;
unsigned int allocnfds;
- fds = NULL;
+ fds = nullptr;
nfds = 0;
allocnfds = 0;
for(;;)
{
// Deliver messages to from child processes and parent.
_app->ProcessLock();
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
FastOS_UNIX_Process::DescriptorHandle &desc =
@@ -576,12 +578,12 @@ SendMessage (FastOS_UNIX_Process *xproc, const void *buffer,
FastOS_RingBuffer *ipcBuffer;
FastOS_UNIX_Process::DescriptorHandle &desc =
- xproc != NULL ?
+ xproc != nullptr ?
xproc->GetDescriptorHandle(FastOS_UNIX_Process::TYPE_IPC) :
_appParentIPCDescriptor;
ipcBuffer = desc._writeBuffer.get();
- if(ipcBuffer != NULL) {
+ if(ipcBuffer != nullptr) {
ipcBuffer->Lock();
if(ipcBuffer->GetWriteSpace() >= int((length + sizeof(int)))) {
@@ -651,7 +653,7 @@ void FastOS_UNIX_IPCHelper::RemoveProcess (FastOS_UNIX_Process *xproc)
void FastOS_UNIX_IPCHelper::DeliverMessages (FastOS_RingBuffer *buffer)
{
- if(buffer == NULL)
+ if(buffer == nullptr)
return;
buffer->Lock();
@@ -681,11 +683,11 @@ PipeData (FastOS_UNIX_Process *process,
{
FastOS_UNIX_Process::DescriptorHandle &desc = process->GetDescriptorHandle(type);
FastOS_RingBuffer *buffer = desc._readBuffer.get();
- if(buffer == NULL)
+ if(buffer == nullptr)
return;
FastOS_ProcessRedirectListener *listener = process->GetListener(type);
- if(listener == NULL)
+ if(listener == nullptr)
return;
buffer->Lock();
diff --git a/fastos/src/vespa/fastos/unix_mutex.cpp b/fastos/src/vespa/fastos/unix_mutex.cpp
index a41eb974604..535a39ce592 100644
--- a/fastos/src/vespa/fastos/unix_mutex.cpp
+++ b/fastos/src/vespa/fastos/unix_mutex.cpp
@@ -1,12 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/mutex.h>
+#include "mutex.h"
+#include <cassert>
FastOS_UNIX_Mutex::FastOS_UNIX_Mutex(void)
: FastOS_MutexInterface(),
_mutex()
{
- int error = pthread_mutex_init(&_mutex, NULL);
+ int error = pthread_mutex_init(&_mutex, nullptr);
assert(error == 0);
(void) error;
}
diff --git a/fastos/src/vespa/fastos/unix_mutex.h b/fastos/src/vespa/fastos/unix_mutex.h
index 4a1d466e405..30150bc1590 100644
--- a/fastos/src/vespa/fastos/unix_mutex.h
+++ b/fastos/src/vespa/fastos/unix_mutex.h
@@ -12,8 +12,8 @@
#pragma once
-#include <vespa/fastos/mutex.h>
-
+#include "mutex.h"
+#include <pthread.h>
class FastOS_UNIX_Mutex : public FastOS_MutexInterface
{
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index 6930dc0247e..df32cb935ff 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -1,9 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/app.h>
-#include <vespa/fastos/unix_ipc.h>
-#include <vespa/fastos/time.h>
+#include "process.h"
+#include "unix_ipc.h"
+#include "time.h"
+#include "ringbuffer.h"
#include <vector>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
#ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX
@@ -167,7 +172,7 @@ public:
static const char *
NextArgument (const char *p,
const char **endArg,
- int *length = NULL);
+ int *length = nullptr);
static int CountArguments (const char *commandLine);
@@ -259,10 +264,10 @@ FastOS_UNIX_RealProcess::FastOS_UNIX_RealProcess(int streamMask)
_runDir(),
_stdoutRedirName(),
_stderrRedirName(),
- _path(NULL),
+ _path(nullptr),
_pathProgBuf(),
- _prev(NULL),
- _next(NULL)
+ _prev(nullptr),
+ _next(nullptr)
{
_stdinDes[0] = _stdinDes[1] = -1;
_stdoutDes[0] = _stdoutDes[1] = -1;
@@ -281,15 +286,15 @@ FastOS_UNIX_RealProcess::~FastOS_UNIX_RealProcess(void)
void
FastOS_UNIX_RealProcess::PrepareExecVPE(const char *prog)
{
- const char *path = NULL;
+ const char *path = nullptr;
char defaultPath[] = ":/usr/ucb:/bin:/usr/bin";
- if (strchr(prog, '/') != NULL) {
+ if (strchr(prog, '/') != nullptr) {
path = "";
} else {
path = getenv("PATH");
- if (path == NULL) path = defaultPath;
+ if (path == nullptr) path = defaultPath;
}
_path = path;
_pathProgBuf.resize(strlen(prog) + 1 + strlen(path) + 1);
@@ -357,14 +362,14 @@ FastOS_UNIX_RealProcess::NextArgument (const char *p,
for(;;)
{
if (*p == '\0') {
- if (length != NULL)
+ if (length != nullptr)
*length = p - nextArg;
break;
}
if (quoteChar != '\0') {
if (*p == quoteChar) {
- if (length != NULL)
+ if (length != nullptr)
*length = p - nextArg;
p++;
break;
@@ -373,7 +378,7 @@ FastOS_UNIX_RealProcess::NextArgument (const char *p,
else
{
if (IsWhiteSpace(*p)) {
- if (length != NULL)
+ if (length != nullptr)
*length = p - nextArg;
break;
}
@@ -386,7 +391,7 @@ FastOS_UNIX_RealProcess::NextArgument (const char *p,
}
p++;
}
- return NULL;
+ return nullptr;
}
@@ -465,7 +470,7 @@ ForkAndExec(const char *command,
int numArguments = 0;
- char **execArgs = NULL;
+ char **execArgs = nullptr;
if (!IsUsingShell()) {
numArguments = CountArguments(command);
@@ -478,9 +483,9 @@ ForkAndExec(const char *command,
const char *arg = NextArgument(nextArg, &nextArg,
&length);
- if (arg == NULL) {
- // printf("ARG NULL\n");
- execArgs[i] = NULL;
+ if (arg == nullptr) {
+ // printf("ARG nullptr\n");
+ execArgs[i] = nullptr;
break;
}
// printf("argLen = %d\n", length);
@@ -492,7 +497,7 @@ ForkAndExec(const char *command,
PrepareExecVPE(execArgs[0]);
}
}
- if (process == NULL) {
+ if (process == nullptr) {
processStarter->CloseProxyDescs(IsStdinPiped() ? _stdinDes[0] : -1,
IsStdoutPiped() ? _stdoutDes[1] : -1,
IsStderrPiped() ? _stderrDes[1] : -1,
@@ -537,7 +542,7 @@ ForkAndExec(const char *command,
CloseDescriptor(_handshakeDes[0]);
_handshakeDes[0] = -1;
- if (process != NULL) {
+ if (process != nullptr) {
if (!process->GetKeepOpenFilesIfDirectChild()) {
int fdlimit = sysconf(_SC_OPEN_MAX);
// Close everything else
@@ -566,7 +571,7 @@ ForkAndExec(const char *command,
shExecArgs[0] = "sh";
shExecArgs[1] = "-c";
shExecArgs[2] = command;
- shExecArgs[3] = NULL;
+ shExecArgs[3] = nullptr;
execve("/bin/sh",
const_cast<char *const *>
(reinterpret_cast<const char *const *>
@@ -697,9 +702,9 @@ ForkAndExec(const char *command,
rc = true;
}
}
- if (execArgs != NULL) {
+ if (execArgs != nullptr) {
char **arg = execArgs;
- while (*arg != NULL) {
+ while (*arg != nullptr) {
delete [] *arg;
arg++;
}
@@ -790,14 +795,14 @@ FastOS_UNIX_Process (const char *cmdLine, bool pipeStdin,
_stdoutRedirName(),
_stderrRedirName(),
_killed(false),
- _closing(NULL)
+ _closing(nullptr)
{
_descriptor[TYPE_IPC]._readBuffer.reset(new FastOS_RingBuffer(bufferSize));
_descriptor[TYPE_IPC]._writeBuffer.reset(new FastOS_RingBuffer(bufferSize));
- if (stdoutListener != NULL)
+ if (stdoutListener != nullptr)
_descriptor[TYPE_STDOUT]._readBuffer.reset(new FastOS_RingBuffer(bufferSize));
- if (stderrListener != NULL)
+ if (stderrListener != nullptr)
_descriptor[TYPE_STDERR]._readBuffer.reset(new FastOS_RingBuffer(bufferSize));
_app->ProcessLock();
@@ -860,8 +865,8 @@ bool FastOS_UNIX_Process::CreateInternal (bool useShell)
{
return GetProcessStarter()->CreateProcess(this, useShell,
_pipeStdin,
- _stdoutListener != NULL,
- _stderrListener != NULL);
+ _stdoutListener != nullptr,
+ _stderrListener != nullptr);
}
bool FastOS_UNIX_Process::WriteStdin (const void *data, size_t length)
@@ -870,7 +875,7 @@ bool FastOS_UNIX_Process::WriteStdin (const void *data, size_t length)
DescriptorHandle &desc = GetDescriptorHandle(TYPE_STDIN);
if (desc._fd != -1) {
- if (data == NULL) {
+ if (data == nullptr) {
CloseDescriptor(TYPE_STDIN);
rc = true;
}
@@ -935,7 +940,7 @@ bool FastOS_UNIX_Process::InternalWait (int *returnCode,
bool FastOS_UNIX_Process::Wait (int *returnCode, int timeOutSeconds)
{
- return InternalWait(returnCode, timeOutSeconds, NULL);
+ return InternalWait(returnCode, timeOutSeconds, nullptr);
}
bool FastOS_UNIX_Process::PollWait (int *returnCode, bool *stillRunning)
@@ -1049,10 +1054,10 @@ void FastOS_UNIX_ProcessStarter::WriteInt (int fd, int integer,
void FastOS_UNIX_ProcessStarter::
AddChildProcess (FastOS_UNIX_RealProcess *node)
{
- node->_prev = NULL;
+ node->_prev = nullptr;
node->_next = _processList;
- if (_processList != NULL)
+ if (_processList != nullptr)
_processList->_prev = node;
_processList = node;
}
@@ -1067,11 +1072,11 @@ RemoveChildProcess (FastOS_UNIX_RealProcess *node)
if (node->_next) {
node->_next->_prev = node->_prev;
- node->_next = NULL;
+ node->_next = nullptr;
}
- if (node->_prev != NULL)
- node->_prev = NULL;
+ if (node->_prev != nullptr)
+ node->_prev = nullptr;
}
bool FastOS_UNIX_ProcessStarter::SendFileDescriptor (int fd)
@@ -1107,7 +1112,7 @@ bool FastOS_UNIX_ProcessStarter::SendFileDescriptor (int fd)
msg.msg_accrightslen = sizeof(int);
#endif
- msg.msg_name = NULL;
+ msg.msg_name = nullptr;
msg.msg_namelen = 0;
char dummyData = '\0';
@@ -1144,7 +1149,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoWait ()
FastOS_UNIX_RealProcess *process, *next;
for(process = FastOS_UNIX_ProcessStarter::_processList;
- process != NULL; process = next)
+ process != nullptr; process = next)
{
// Need to do this here since we are deleting entries
@@ -1199,7 +1204,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoDetachProcess ()
FastOS_UNIX_RealProcess *process, *next;
for(process = FastOS_UNIX_ProcessStarter::_processList;
- process != NULL; process = next) {
+ process != nullptr; process = next) {
// Need to do this here since we are deleting entries
next = process->_next;
@@ -1337,7 +1342,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoCreateProcess ()
pid_t processId = -1;
if (process->ForkAndExec(cmdLine,
environmentVariables,
- NULL,
+ nullptr,
this))
{
processId = process->GetProcessID();
@@ -1354,7 +1359,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoCreateProcess ()
if (!rc) delete process;
char **pe = environmentVariables;
- while(*pe != NULL) {
+ while(*pe != nullptr) {
delete [] *pe++;
}
delete [] environmentVariables;
@@ -1408,6 +1413,29 @@ bool FastOS_UNIX_ProcessStarter::CreateSocketPairs ()
return rc;
}
+FastOS_UNIX_ProcessStarter::FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app)
+ : _app(app),
+ _processList(nullptr),
+ _pid(-1),
+ _starterSocket(-1),
+ _mainSocket(-1),
+ _starterSocketDescr(-1),
+ _mainSocketDescr(-1),
+ _hasProxiedChildren(false),
+ _closedProxyProcessFiles(false),
+ _hasDetachedProcess(false),
+ _hasDirectChildren(false)
+{
+}
+
+FastOS_UNIX_ProcessStarter::~FastOS_UNIX_ProcessStarter ()
+{
+ if(_starterSocket != -1)
+ close(_starterSocket);
+ if(_mainSocket != -1)
+ close(_mainSocket);
+}
+
bool FastOS_UNIX_ProcessStarter::Start ()
{
bool rc = false;
@@ -1475,7 +1503,7 @@ int FastOS_UNIX_ProcessStarter::ReadFileDescriptor ()
msg.msg_accrightslen = sizeof(int);
#endif
- msg.msg_name = NULL;
+ msg.msg_name = nullptr;
msg.msg_namelen = 0;
char dummyData = '\0';
@@ -1493,7 +1521,7 @@ int FastOS_UNIX_ProcessStarter::ReadFileDescriptor ()
// printf("recvmsgrc = %d\n", recvmsgrc);
#ifndef FASTOS_HAVE_ACCRIGHTSLEN
- if ((cmptr = CMSG_FIRSTHDR(&msg)) != NULL &&
+ if ((cmptr = CMSG_FIRSTHDR(&msg)) != nullptr &&
cmptr->cmsg_len == CMSG_LEN(sizeof(int)))
{
if (cmptr->cmsg_level != SOL_SOCKET)
@@ -1566,7 +1594,7 @@ char ** FastOS_UNIX_ProcessStarter::ReceiveEnvironmentVariables ()
else
fillIndex++;
}
- myEnvironment[fillIndex] = NULL;
+ myEnvironment[fillIndex] = nullptr;
return myEnvironment;
}
@@ -1577,7 +1605,7 @@ void FastOS_UNIX_ProcessStarter::SendEnvironmentVariables ()
int numEnvVars = 0;
char **pe = environ;
- while(*pe++ != NULL)
+ while(*pe++ != nullptr)
numEnvVars++;
WriteInt(_mainSocket, numEnvVars);
@@ -1591,7 +1619,7 @@ void FastOS_UNIX_ProcessStarter::SendEnvironmentVariables ()
const char *envString = "";
if (!gotNull) {
envString = *pe++;
- if (envString == NULL) {
+ if (envString == nullptr) {
envString = "";
gotNull = true;
}
@@ -1646,7 +1674,7 @@ FastOS_UNIX_ProcessStarter::
CopyEnvironmentVariables(void)
{
char **env = environ;
- while (*env != NULL)
+ while (*env != nullptr)
env++;
int numEnvVars = env - environ;
char **newEnv = new char *[numEnvVars + 2];
@@ -1654,7 +1682,7 @@ CopyEnvironmentVariables(void)
int fillIdx = 1;
env = environ;
- while (*env != NULL) {
+ while (*env != nullptr) {
size_t len = strlen(*env);
if (len > 0 &&
strncmp(*env, "FASTOS_IPC_PARENT=", 18) != 0) {
@@ -1664,7 +1692,7 @@ CopyEnvironmentVariables(void)
}
env++;
}
- newEnv[fillIdx] = NULL;
+ newEnv[fillIdx] = nullptr;
return newEnv;
}
@@ -1674,7 +1702,7 @@ FastOS_UNIX_ProcessStarter::
FreeEnvironmentVariables(char **env)
{
char **p = env;
- while (*p != NULL) {
+ while (*p != nullptr) {
delete [] *p;
p++;
}
@@ -1701,15 +1729,15 @@ CreateProcess (FastOS_UNIX_Process *process,
FastOS_UNIX_RealProcess *rprocess =
new FastOS_UNIX_RealProcess(process->BuildStreamMask(useShell));
const char *runDir = process->GetRunDir();
- if (runDir != NULL) {
+ if (runDir != nullptr) {
rprocess->SetRunDir(runDir); // Handover
}
const char *stdoutRedirName = process->GetStdoutRedirName();
- if (stdoutRedirName != NULL) {
+ if (stdoutRedirName != nullptr) {
rprocess->SetStdoutRedirName(stdoutRedirName);
}
const char *stderrRedirName = process->GetStderrRedirName();
- if (stderrRedirName != NULL) {
+ if (stderrRedirName != nullptr) {
rprocess->SetStderrRedirName(stderrRedirName);
}
char **env = CopyEnvironmentVariables();
@@ -1758,7 +1786,7 @@ CreateProcess (FastOS_UNIX_Process *process,
SendEnvironmentVariables();
const char *runDir = process->GetRunDir();
- if (runDir != NULL) {
+ if (runDir != nullptr) {
int runDirLength = strlen(runDir) + 1;
WriteInt(_mainSocket, runDirLength);
WriteBytes(_mainSocket, runDir, runDirLength);
@@ -1766,7 +1794,7 @@ CreateProcess (FastOS_UNIX_Process *process,
WriteInt(_mainSocket, 0);
const char *stdoutRedirName = process->GetStdoutRedirName();
- if (stdoutRedirName != NULL) {
+ if (stdoutRedirName != nullptr) {
int stdoutRedirNameLength = strlen(stdoutRedirName) + 1;
WriteInt(_mainSocket, stdoutRedirNameLength);
WriteBytes(_mainSocket, stdoutRedirName, stdoutRedirNameLength);
@@ -1774,7 +1802,7 @@ CreateProcess (FastOS_UNIX_Process *process,
WriteInt(_mainSocket, 0);
const char *stderrRedirName = process->GetStderrRedirName();
- if (stderrRedirName != NULL) {
+ if (stderrRedirName != nullptr) {
int stderrRedirNameLength = strlen(stderrRedirName) + 1;
WriteInt(_mainSocket, stderrRedirNameLength);
WriteBytes(_mainSocket, stderrRedirName, stderrRedirNameLength);
@@ -1838,7 +1866,7 @@ FastOS_UNIX_ProcessStarter::PollReapDirectChildren(void)
FastOS_ProcessInterface *node;
for(node = _app->GetProcessList();
- node != NULL; node = node->_next)
+ node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc =
static_cast<FastOS_UNIX_Process *>(node);
@@ -1868,7 +1896,7 @@ FastOS_UNIX_ProcessStarter::PollReapProxiedChildren(void)
ReadBytes(_mainSocket, &returnCode, sizeof(int));
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc =
static_cast<FastOS_UNIX_Process *>(node);
@@ -1894,7 +1922,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
FastOS_Time startTime;
startTime.SetNow();
- if (pollStillRunning != NULL)
+ if (pollStillRunning != nullptr)
*pollStillRunning = true;
for (;;) {
@@ -1907,7 +1935,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
process->_app->ProcessUnlock();
if (process->GetDeathFlag()) {
- if (pollStillRunning != NULL)
+ if (pollStillRunning != nullptr)
*pollStillRunning = false;
break;
}
@@ -1915,7 +1943,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
// printf("wasn't dead yet (%d), sleeping\n",
// process->GetProcessId());
- if (pollStillRunning != NULL)
+ if (pollStillRunning != nullptr)
break;
if ((timeOutSeconds != -1) && !timeOutKillAttempted) {
@@ -1979,3 +2007,41 @@ bool FastOS_UNIX_ProcessStarter::Detach(FastOS_UNIX_Process *process)
process->_app->ProcessUnlock();
return rc;
}
+
+FastOS_UNIX_Process::DescriptorHandle::DescriptorHandle()
+ : _fd(-1),
+ _wantRead(false),
+ _wantWrite(false),
+ _canRead(false),
+ _canWrite(false),
+ _pollIdx(-1),
+ _readBuffer(),
+ _writeBuffer()
+{
+}
+FastOS_UNIX_Process::DescriptorHandle::~DescriptorHandle() { }
+void
+FastOS_UNIX_Process::DescriptorHandle::CloseHandle()
+{
+ _wantRead = false;
+ _wantWrite = false;
+ _canRead = false;
+ _canWrite = false;
+ _pollIdx = -1;
+ if (_fd != -1) {
+ close(_fd);
+ _fd = -1;
+ }
+ if (_readBuffer.get() != nullptr)
+ _readBuffer->Close();
+ if (_writeBuffer.get() != nullptr)
+ _writeBuffer->Close();
+}
+void
+FastOS_UNIX_Process::DescriptorHandle::CloseHandleDirectChild()
+{
+ if (_fd != -1) {
+ close(_fd);
+ _fd = -1;
+ }
+} \ No newline at end of file
diff --git a/fastos/src/vespa/fastos/unix_process.h b/fastos/src/vespa/fastos/unix_process.h
index 97a5b57c08d..16614deb1a2 100644
--- a/fastos/src/vespa/fastos/unix_process.h
+++ b/fastos/src/vespa/fastos/unix_process.h
@@ -8,15 +8,14 @@
#pragma once
-#include <vespa/fastos/process.h>
-#include <vespa/fastos/app.h>
+#include "process.h"
+#include "app.h"
#include <string>
#include <memory>
class FastOS_BoolCond;
class FastOS_UNIX_RealProcess;
-
-#include <vespa/fastos/ringbuffer.h>
+class FastOS_RingBuffer;
class FastOS_UNIX_Process : public FastOS_ProcessInterface
{
@@ -45,41 +44,10 @@ public:
int _pollIdx;
std::unique_ptr<FastOS_RingBuffer> _readBuffer;
std::unique_ptr<FastOS_RingBuffer> _writeBuffer;
- DescriptorHandle(void)
- : _fd(-1),
- _wantRead(false),
- _wantWrite(false),
- _canRead(false),
- _canWrite(false),
- _pollIdx(-1),
- _readBuffer(),
- _writeBuffer()
- {
- }
- ~DescriptorHandle() { }
- void CloseHandle(void)
- {
- _wantRead = false;
- _wantWrite = false;
- _canRead = false;
- _canWrite = false;
- _pollIdx = -1;
- if (_fd != -1) {
- close(_fd);
- _fd = -1;
- }
- if (_readBuffer.get() != NULL)
- _readBuffer->Close();
- if (_writeBuffer.get() != NULL)
- _writeBuffer->Close();
- }
- void CloseHandleDirectChild(void)
- {
- if (_fd != -1) {
- close(_fd);
- _fd = -1;
- }
- }
+ DescriptorHandle();
+ ~DescriptorHandle();
+ void CloseHandle();
+ void CloseHandleDirectChild();
};
private:
DescriptorHandle _descriptor[4];
@@ -95,8 +63,7 @@ private:
GetProcessStarter();
}
- bool InternalWait (int *returnCode, int timeOutSeconds,
- bool *pollStillRunning);
+ bool InternalWait (int *returnCode, int timeOutSeconds, bool *pollStillRunning);
public:
enum DescriptorType
{
@@ -119,32 +86,32 @@ public:
else if(type == TYPE_STDERR)
return _stderrListener;
- return NULL;
+ return nullptr;
}
void CloseListener (DescriptorType type)
{
if(type == TYPE_STDOUT)
{
- if(_stdoutListener != NULL)
+ if(_stdoutListener != nullptr)
{
- _stdoutListener->OnReceiveData(NULL, 0);
- _stdoutListener = NULL;
+ _stdoutListener->OnReceiveData(nullptr, 0);
+ _stdoutListener = nullptr;
}
}
else if(type == TYPE_STDERR)
{
- if(_stderrListener != NULL)
+ if(_stderrListener != nullptr)
{
- _stderrListener->OnReceiveData(NULL, 0);
- _stderrListener = NULL;
+ _stderrListener->OnReceiveData(nullptr, 0);
+ _stderrListener = nullptr;
}
}
}
FastOS_UNIX_Process (const char *cmdLine, bool pipeStdin = false,
- FastOS_ProcessRedirectListener *stdoutListener = NULL,
- FastOS_ProcessRedirectListener *stderrListener = NULL,
+ FastOS_ProcessRedirectListener *stdoutListener = nullptr,
+ FastOS_ProcessRedirectListener *stderrListener = nullptr,
int bufferSize = 65535);
~FastOS_UNIX_Process ();
bool CreateInternal (bool useShell);
@@ -298,28 +265,8 @@ protected:
void PollReapDirectChildren(void);
public:
- FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app)
- : _app(app),
- _processList(NULL),
- _pid(-1),
- _starterSocket(-1),
- _mainSocket(-1),
- _starterSocketDescr(-1),
- _mainSocketDescr(-1),
- _hasProxiedChildren(false),
- _closedProxyProcessFiles(false),
- _hasDetachedProcess(false),
- _hasDirectChildren(false)
- {
- }
-
- ~FastOS_UNIX_ProcessStarter ()
- {
- if(_starterSocket != -1)
- close(_starterSocket);
- if(_mainSocket != -1)
- close(_mainSocket);
- }
+ FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app);
+ ~FastOS_UNIX_ProcessStarter ();
bool Start ();
void Stop ();
diff --git a/fastos/src/vespa/fastos/unix_socket.cpp b/fastos/src/vespa/fastos/unix_socket.cpp
index ae72c39147d..ba1d2f50417 100644
--- a/fastos/src/vespa/fastos/unix_socket.cpp
+++ b/fastos/src/vespa/fastos/unix_socket.cpp
@@ -1,6 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/socket.h>
+#include "socket.h"
+#include <cassert>
+#include <cstring>
+#include <unistd.h>
+#include <fcntl.h>
FastOS_UNIX_Socket::~FastOS_UNIX_Socket()
{
@@ -25,7 +29,7 @@ bool FastOS_UNIX_Socket::Shutdown()
bool rc=true;
if (ValidHandle()) {
- if(_socketEvent != NULL) {
+ if(_socketEvent != nullptr) {
EnableWriteEvent(false);
}
rc = (0 == shutdown(_socketHandle, SHUT_WR));
@@ -39,7 +43,7 @@ bool FastOS_UNIX_Socket::SetSoBlocking (bool blockingEnabled)
bool rc=false;
if (CreateIfNoSocketYet()) {
- int flags = fcntl(_socketHandle, F_GETFL, NULL);
+ int flags = fcntl(_socketHandle, F_GETFL, nullptr);
if (flags >= 0) {
if (blockingEnabled) {
diff --git a/fastos/src/vespa/fastos/unix_socket.h b/fastos/src/vespa/fastos/unix_socket.h
index a4b5d738d32..a1f25a8d159 100644
--- a/fastos/src/vespa/fastos/unix_socket.h
+++ b/fastos/src/vespa/fastos/unix_socket.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/fastos/socket.h>
+#include "socket.h"
class FastOS_UNIX_Socket : public FastOS_SocketInterface
{
@@ -26,8 +26,8 @@ public:
ERR_INPROGRESS = EINPROGRESS,
ERR_WOULDBLOCK = EWOULDBLOCK,
ERR_ADDRNOTAVAIL = EADDRNOTAVAIL,
- ERR_MFILE = FASTOS_EMFILE_VERIFIED,
- ERR_NFILE = FASTOS_ENFILE_VERIFIED,
+ ERR_MFILE = EMFILE,
+ ERR_NFILE = ENFILE,
ERR_CONNRESET = ECONNRESET,
ERR_EAGAIN = EAGAIN, // Old style error codes
@@ -36,8 +36,8 @@ public:
ERR_EINPROGRESS = EINPROGRESS,
ERR_EWOULDBLOCK = EWOULDBLOCK,
ERR_EADDRNOTAVAIL = EADDRNOTAVAIL,
- ERR_EMFILE = FASTOS_EMFILE_VERIFIED,
- ERR_ENFILE = FASTOS_ENFILE_VERIFIED
+ ERR_EMFILE = EMFILE,
+ ERR_ENFILE = ENFILE
};
};
diff --git a/fastos/src/vespa/fastos/unix_thread.cpp b/fastos/src/vespa/fastos/unix_thread.cpp
index 3633d1cacc6..8ff1913b246 100644
--- a/fastos/src/vespa/fastos/unix_thread.cpp
+++ b/fastos/src/vespa/fastos/unix_thread.cpp
@@ -1,7 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/thread.h>
+#include "thread.h"
#include <atomic>
#include <thread>
+#include <unistd.h>
namespace {
std::atomic_size_t _G_nextCpuId(0);
@@ -10,11 +11,11 @@ namespace {
bool FastOS_UNIX_Thread::InitializeClass ()
{
- if (getenv("VESPA_PIN_THREAD_TO_CORE") != NULL) {
+ if (getenv("VESPA_PIN_THREAD_TO_CORE") != nullptr) {
_G_maxNumCpus = std::thread::hardware_concurrency();
fprintf(stderr, "Will pin threads to CPU. Using %ld cores\n", _G_maxNumCpus);
- if (getenv("VESPA_MAX_CORES") != NULL) {
- size_t maxCores = strtoul(getenv("VESPA_MAX_CORES"), NULL, 0);
+ if (getenv("VESPA_MAX_CORES") != nullptr) {
+ size_t maxCores = strtoul(getenv("VESPA_MAX_CORES"), nullptr, 0);
fprintf(stderr, "Will limit to %ld", maxCores);
if (maxCores < _G_maxNumCpus) {
_G_maxNumCpus = maxCores;
@@ -69,17 +70,29 @@ void FastOS_UNIX_Thread::PreEntry ()
{
}
-FastOS_UNIX_Thread::~FastOS_UNIX_Thread(void)
+FastOS_UNIX_Thread::~FastOS_UNIX_Thread()
{
void *value;
// Wait for thread library cleanup to complete.
if (_handleValid) {
- value = NULL;
+ value = nullptr;
pthread_join(_handle, &value);
}
}
+bool FastOS_UNIX_Thread::Sleep (int ms)
+{
+ bool rc=false;
+
+ if (ms > 0) {
+ usleep(ms*1000);
+ rc = true;
+ }
+
+ return rc;
+}
+
FastOS_ThreadId FastOS_UNIX_Thread::GetThreadId ()
{
return _handle;
@@ -90,8 +103,7 @@ FastOS_ThreadId FastOS_UNIX_Thread::GetCurrentThreadId ()
return pthread_self();
}
-bool FastOS_UNIX_Thread::CompareThreadIds (FastOS_ThreadId a,
- FastOS_ThreadId b)
+bool FastOS_UNIX_Thread::CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b)
{
return (pthread_equal(a, b) != 0);
}
diff --git a/fastos/src/vespa/fastos/unix_thread.h b/fastos/src/vespa/fastos/unix_thread.h
index 691a7909bbb..c6e0b040fc7 100644
--- a/fastos/src/vespa/fastos/unix_thread.h
+++ b/fastos/src/vespa/fastos/unix_thread.h
@@ -9,7 +9,7 @@
#pragma once
-#include <vespa/fastos/thread.h>
+#include "thread.h"
class FastOS_UNIX_Thread : public FastOS_ThreadInterface
{
@@ -36,21 +36,9 @@ public:
~FastOS_UNIX_Thread();
- static bool Sleep (int ms)
- {
- bool rc=false;
-
- if (ms > 0) {
- usleep(ms*1000);
- rc = true;
- }
-
- return rc;
- }
-
+ static bool Sleep (int ms);
FastOS_ThreadId GetThreadId () override;
- static bool CompareThreadIds (FastOS_ThreadId a,
- FastOS_ThreadId b);
+ static bool CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b);
static FastOS_ThreadId GetCurrentThreadId ();
};
diff --git a/fastos/src/vespa/fastos/unix_time.cpp b/fastos/src/vespa/fastos/unix_time.cpp
index 5961d875840..c6251f60d03 100644
--- a/fastos/src/vespa/fastos/unix_time.cpp
+++ b/fastos/src/vespa/fastos/unix_time.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "time.h"
-#include "types.h"
+#include <sys/time.h>
double
FastOS_UNIX_Time::MicroSecs() const
@@ -99,6 +99,6 @@ FastOS_UNIX_Time::SetSecs(double secs)
}
void FastOS_UNIX_Time::SetNow() {
- gettimeofday(&_time, NULL);
+ gettimeofday(&_time, nullptr);
}
diff --git a/fbench/src/fbench/client.cpp b/fbench/src/fbench/client.cpp
index 5c828fc4282..0200ea2d067 100644
--- a/fbench/src/fbench/client.cpp
+++ b/fbench/src/fbench/client.cpp
@@ -1,8 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "client.h"
#include <util/timer.h>
+#include <util/clientstatus.h>
#include <httpclient/httpclient.h>
#include <util/filereader.h>
-#include "client.h"
+#include <cassert>
+#include <cstring>
Client::Client(ClientArguments *args)
: _args(args),
diff --git a/fbench/src/fbench/client.h b/fbench/src/fbench/client.h
index 107b4997d93..1e0b750dbb2 100644
--- a/fbench/src/fbench/client.h
+++ b/fbench/src/fbench/client.h
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <util/clientstatus.h>
#include <fstream>
#include <atomic>
#include <thread>
@@ -150,6 +149,11 @@ private:
ClientArguments &operator=(const ClientArguments &);
};
+
+class Timer;
+class HTTPClient;
+class FileReader;
+class ClientStatus;
/**
* This class implements a single test client. The clients are run in
* separate threads to simulate several simultanious users. The
@@ -161,9 +165,9 @@ class Client
private:
std::unique_ptr<ClientArguments> _args;
std::unique_ptr<ClientStatus> _status;
- Timer::UP _reqTimer;
- Timer::UP _cycleTimer;
- Timer::UP _masterTimer;
+ std::unique_ptr<Timer> _reqTimer;
+ std::unique_ptr<Timer> _cycleTimer;
+ std::unique_ptr<Timer> _masterTimer;
std::unique_ptr<HTTPClient> _http;
std::unique_ptr<FileReader> _reader;
std::unique_ptr<std::ofstream> _output;
diff --git a/fbench/src/fbench/fbench.cpp b/fbench/src/fbench/fbench.cpp
index c840797fc4e..c98c3ead4fe 100644
--- a/fbench/src/fbench/fbench.cpp
+++ b/fbench/src/fbench/fbench.cpp
@@ -2,11 +2,12 @@
#include <util/timer.h>
#include <httpclient/httpclient.h>
#include <util/filereader.h>
+#include <util/clientstatus.h>
#include "client.h"
#include "fbench.h"
-#include <thread>
-
+#include <cstring>
#include <cmath>
+#include <csignal>
sig_atomic_t exitSignal = 0;
@@ -161,7 +162,7 @@ FBench::PrintSummary()
if (_keepAlive) {
printf("*** HTTP keep-alive statistics ***\n");
- printf("connection reuse count -- %" PRId64 "\n", status._reuseCnt);
+ printf("connection reuse count -- %zu\n", status._reuseCnt);
}
printf("***************** Benchmark Summary *****************\n");
printf("clients: %8ld\n", _clients.size());
diff --git a/fbench/src/filterfile/filterfile.cpp b/fbench/src/filterfile/filterfile.cpp
index 918d62215e6..ca93b70a046 100644
--- a/fbench/src/filterfile/filterfile.cpp
+++ b/fbench/src/filterfile/filterfile.cpp
@@ -2,7 +2,7 @@
#include <util/filereader.h>
#include <iostream>
#include <string.h>
-#include <assert.h>
+#include <cassert>
/**
* Extract query urls from web logs. The filterfile application reads
diff --git a/fbench/src/httpclient/httpclient.cpp b/fbench/src/httpclient/httpclient.cpp
index 56d8baa4264..c49ef5da12c 100644
--- a/fbench/src/httpclient/httpclient.cpp
+++ b/fbench/src/httpclient/httpclient.cpp
@@ -1,5 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "httpclient.h"
+#include <cassert>
+#include <cstring>
#define FETCH_BUFLEN 5120
#define FIXED_REQ_MAX 256
diff --git a/fbench/src/test/clientstatus.cpp b/fbench/src/test/clientstatus.cpp
index 751c578e4d3..c8b7bce1a34 100644
--- a/fbench/src/test/clientstatus.cpp
+++ b/fbench/src/test/clientstatus.cpp
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <util/timer.h>
-#include <util/filereader.h>
-#include <httpclient/httpclient.h>
+#include <util/clientstatus.h>
#include <fbench/client.h>
int
diff --git a/fbench/src/test/filereader.cpp b/fbench/src/test/filereader.cpp
index e85ef6c5821..d01c42fab6f 100644
--- a/fbench/src/test/filereader.cpp
+++ b/fbench/src/test/filereader.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <util/filereader.h>
#include <string.h>
-#include <assert.h>
+#include <cassert>
int
main(int argc, char **argv)
diff --git a/fbench/src/test/httpclient.cpp b/fbench/src/test/httpclient.cpp
index 31e3f8297c4..4201da68b97 100644
--- a/fbench/src/test/httpclient.cpp
+++ b/fbench/src/test/httpclient.cpp
@@ -49,6 +49,6 @@ main(int argc, char **argv)
} else {
printf("ERROR: could not fetch URL content.\n");
}
- printf("REUSE COUNT: %" PRIu64 "\n", client->GetReuseCount());
+ printf("REUSE COUNT: %zu\n", client->GetReuseCount());
return 0;
}
diff --git a/fbench/src/test/httpclient_splitstring.cpp b/fbench/src/test/httpclient_splitstring.cpp
index 655738170bd..d766b0f8f4b 100644
--- a/fbench/src/test/httpclient_splitstring.cpp
+++ b/fbench/src/test/httpclient_splitstring.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <httpclient/httpclient.h>
+#include <cstring>
class DebugHTTPClient : public HTTPClient
{
diff --git a/fnet/src/tests/examples/examples_test.cpp b/fnet/src/tests/examples/examples_test.cpp
index df5cceb624d..c823c52b995 100644
--- a/fnet/src/tests/examples/examples_test.cpp
+++ b/fnet/src/tests/examples/examples_test.cpp
@@ -4,6 +4,7 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/thread.h>
#include <atomic>
+#include <csignal>
// reserved in vespa/factory/doc/port-ranges.txt
static const int PORT0 = 18570;
diff --git a/fnet/src/vespa/fnet/iocomponent.cpp b/fnet/src/vespa/fnet/iocomponent.cpp
index 52c9cfd09b5..e5544ceff0e 100644
--- a/fnet/src/vespa/fnet/iocomponent.cpp
+++ b/fnet/src/vespa/fnet/iocomponent.cpp
@@ -2,7 +2,8 @@
#include "iocomponent.h"
#include "transport_thread.h"
-
+#include <cassert>
+#include <cstring>
FNET_IOComponent::FNET_IOComponent(FNET_TransportThread *owner,
int socket_fd,
diff --git a/fnet/src/vespa/fnet/packetqueue.cpp b/fnet/src/vespa/fnet/packetqueue.cpp
index df1938beb8e..b2ed08d4b04 100644
--- a/fnet/src/vespa/fnet/packetqueue.cpp
+++ b/fnet/src/vespa/fnet/packetqueue.cpp
@@ -3,6 +3,7 @@
#include "packetqueue.h"
#include "packet.h"
#include <vespa/fastos/time.h>
+#include <cassert>
void
FNET_PacketQueue_NoLock::ExpandBuf(uint32_t needentries)
diff --git a/fnet/src/vespa/fnet/transport_thread.cpp b/fnet/src/vespa/fnet/transport_thread.cpp
index 4a637b03532..6610d217294 100644
--- a/fnet/src/vespa/fnet/transport_thread.cpp
+++ b/fnet/src/vespa/fnet/transport_thread.cpp
@@ -10,6 +10,7 @@
#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/net/socket_spec.h>
#include <vespa/vespalib/net/server_socket.h>
+#include <csignal>
#include <vespa/log/log.h>
LOG_SETUP(".fnet");
diff --git a/fsa/src/libfsa/automaton-alternate.h b/fsa/src/libfsa/automaton-alternate.h
index 535b0f16014..1d64a08ee52 100644
--- a/fsa/src/libfsa/automaton-alternate.h
+++ b/fsa/src/libfsa/automaton-alternate.h
@@ -13,7 +13,7 @@
#include <list>
#include <string>
#include <vector>
-#include <assert.h>
+#include <cassert>
#include <sys/mman.h> // for mmap() etc
#include "blob.h"
diff --git a/fsa/src/vespa/fsa/automaton.h b/fsa/src/vespa/fsa/automaton.h
index 18d56cd4291..f1bcca87cf6 100644
--- a/fsa/src/vespa/fsa/automaton.h
+++ b/fsa/src/vespa/fsa/automaton.h
@@ -13,7 +13,7 @@
#include <map>
#include <list>
#include <string>
-#include <assert.h>
+#include <cassert>
#include "blob.h"
#include "fsa.h"
diff --git a/fsa/src/vespa/fsa/conceptnet.h b/fsa/src/vespa/fsa/conceptnet.h
index f082660ff18..d17b64bead5 100644
--- a/fsa/src/vespa/fsa/conceptnet.h
+++ b/fsa/src/vespa/fsa/conceptnet.h
@@ -10,7 +10,7 @@
#pragma once
-#include <assert.h>
+#include <cassert>
#include <stdlib.h>
#include "file.h" // for FileAccessMethod
#include "fsa.h"
diff --git a/fsa/src/vespa/fsa/unicode.cpp b/fsa/src/vespa/fsa/unicode.cpp
index d4e92d6ca23..870d16ced2c 100644
--- a/fsa/src/vespa/fsa/unicode.cpp
+++ b/fsa/src/vespa/fsa/unicode.cpp
@@ -5,7 +5,7 @@
#include "unicode.h"
-#include <assert.h>
+#include <cassert>
#include <cstdlib>
namespace fsa {
diff --git a/fsa/src/vespa/fsamanagers/mutex.cpp b/fsa/src/vespa/fsamanagers/mutex.cpp
index 01915b3c185..ba3e5b70c6f 100644
--- a/fsa/src/vespa/fsamanagers/mutex.cpp
+++ b/fsa/src/vespa/fsamanagers/mutex.cpp
@@ -15,7 +15,7 @@
#ifndef DISABLE_THREADS
#include <pthread.h>
#include <sched.h>
-#include <assert.h>
+#include <cassert>
#endif
#include "mutex.h"
diff --git a/fsa/src/vespa/fsamanagers/rwlock.cpp b/fsa/src/vespa/fsamanagers/rwlock.cpp
index 3e15d5fd9cf..ee322494968 100644
--- a/fsa/src/vespa/fsamanagers/rwlock.cpp
+++ b/fsa/src/vespa/fsamanagers/rwlock.cpp
@@ -15,7 +15,7 @@
#ifndef DISABLE_THREADS
#include <pthread.h>
#include <sched.h>
-#include <assert.h>
+#include <cassert>
#endif
#include "rwlock.h"
diff --git a/juniper/src/vespa/juniper/hashbase.h b/juniper/src/vespa/juniper/hashbase.h
index 0fe03514e48..d651e1d2705 100644
--- a/juniper/src/vespa/juniper/hashbase.h
+++ b/juniper/src/vespa/juniper/hashbase.h
@@ -2,7 +2,7 @@
#pragma once
#include <stdio.h>
-#include <assert.h>
+#include <cassert>
// Simple default order that everybody has - pointer order:
template <typename T>
diff --git a/logd/src/apps/logd/main.cpp b/logd/src/apps/logd/main.cpp
index 48450f323e9..caeaf83c7cc 100644
--- a/logd/src/apps/logd/main.cpp
+++ b/logd/src/apps/logd/main.cpp
@@ -1,16 +1,4 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <time.h>
-#include <sys/stat.h>
-
-#include <vespa/log/log.h>
-LOG_SETUP("logdemon");
-LOG_RCSID("$Id$");
#include <logd/errhandle.h>
#include <logd/sigterm.h>
@@ -18,8 +6,14 @@ LOG_RCSID("$Id$");
#include <logd/forward.h>
#include <logd/conf.h>
#include <logd/watch.h>
-#include <logd/conn.h>
#include <vespa/config/common/exceptions.h>
+#include <csignal>
+#include <unistd.h>
+
+#include <vespa/log/log.h>
+LOG_SETUP("logdemon");
+
+
using namespace logdemon;
using config::FileSpec;
diff --git a/logd/src/logd/service.cpp b/logd/src/logd/service.cpp
index 8e2237b1973..cd4304f5405 100644
--- a/logd/src/logd/service.cpp
+++ b/logd/src/logd/service.cpp
@@ -7,7 +7,7 @@
#include <unistd.h>
#include <time.h>
#include <sys/stat.h>
-#include <assert.h>
+#include <cassert>
#include <vespa/log/log.h>
#include <vespa/log/control-file.h>
diff --git a/logd/src/logd/watch.cpp b/logd/src/logd/watch.cpp
index 0ff6510bd25..0558d0b4548 100644
--- a/logd/src/logd/watch.cpp
+++ b/logd/src/logd/watch.cpp
@@ -9,9 +9,12 @@
#include "perform.h"
#include "cmdbuf.h"
#include <glob.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/time.h>
LOG_SETUP("");
-LOG_RCSID("$Id$");
namespace logdemon {
namespace {
@@ -283,7 +286,7 @@ Watcher::watchfile()
{
removeOldLogs(filename);
if (sb.st_size != offset) {
- LOG(warning, "logfile rotation incomplete after %d s (dropping %" PRIu64 " bytes)",
+ LOG(warning, "logfile rotation incomplete after %d s (dropping %lu bytes)",
rotTime, sb.st_size - offset);
} else {
LOG(debug, "logfile rotation complete after %d s", rotTime);
@@ -412,7 +415,7 @@ Watcher::removeOldLogs(const char *prefix)
if (totalsize > (_confsubscriber.getRemoveMegabytes()
* 1048576LL))
{
- LOG(info, "removing %s, total size (%" PRId64 ") too big",
+ LOG(info, "removing %s, total size (%ld) too big",
fname, static_cast<int64_t>(totalsize));
if (unlink(fname) != 0) {
LOG(warning, "cannot remove %s: %s",
diff --git a/logd/src/tests/forward/forward.cpp b/logd/src/tests/forward/forward.cpp
index 6a9a8668e9b..13e31cea464 100644
--- a/logd/src/tests/forward/forward.cpp
+++ b/logd/src/tests/forward/forward.cpp
@@ -3,6 +3,8 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <logd/forward.h>
#include <sstream>
+#include <fcntl.h>
+#include <unistd.h>
using ns_log::Logger;
using namespace logdemon;
diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp
index 044bf1ea56e..5cbaef2363f 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp
@@ -3,7 +3,7 @@
#include "environment.h"
#include <vespa/vespalib/util/random.h>
-#include <vespa/vespalib/util/vstringfmt.h>
+#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/config/subscription/configuri.h>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -85,12 +85,12 @@ Environment::calculatePathInDir(const Types::BucketId& id, Directory& dir)
vespalib::RandomGen randomizer(static_cast<uint32_t>(seed) ^ 0xba5eba11);
for (uint32_t i = 1; i <= (uint32_t)_config->dirLevels; ++i) {
- os << vespalib::make_vespa_string(
+ os << vespalib::make_string(
"%.4x/",
randomizer.nextUint32() % _config->dirSpread);
}
- os << vespalib::make_vespa_string("%.8" PRIx64 ".0", id.getId());
+ os << vespalib::make_string("%.8" PRIx64 ".0", id.getId());
return os.str();
}
diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/device.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/device.cpp
index 50286b4c033..cd1fcafb52c 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/device/device.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/device/device.cpp
@@ -2,10 +2,9 @@
#include "device.h"
#include "ioevent.h"
#include <sstream>
+#include <algorithm>
-namespace storage {
-
-namespace memfile {
+namespace storage::memfile {
Device::Device(DeviceManager& manager)
: _manager(manager)
@@ -54,6 +53,4 @@ Device::clearEvents()
_events.clear();
}
-} // memfile
-
-} // storage
+}
diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp
index 39530d4d8d1..5e1d835e3a2 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/device/mountpointlist.cpp
@@ -10,6 +10,7 @@
#include <vespa/vespalib/util/guard.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <fstream>
+#include <sys/stat.h>
#include <vespa/log/log.h>
LOG_SETUP(".persistence.mountpointlist");
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp
index ee908fb6c6f..c4f4e7e8bc1 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.cpp
@@ -5,6 +5,7 @@
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/exceptions.h>
#include <sstream>
+#include <cassert>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".persistence.memfile.bufferedfilewriter");
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h
index 2370665f3d6..993004c01f0 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/bufferedfilewriter.h
@@ -16,16 +16,15 @@
#pragma once
-#include <vespa/fastos/types.h>
#include <vector>
+#include <cstring>
+#include <cstdint>
namespace vespalib {
class File;
}
-namespace storage {
-
-namespace memfile {
+namespace storage::memfile {
class BufferedFileWriter {
public:
@@ -115,6 +114,3 @@ private:
};
}
-
-}
-
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/locationreadplanner.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/locationreadplanner.cpp
index 46964d9058d..381e5d17766 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/locationreadplanner.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/locationreadplanner.cpp
@@ -2,9 +2,9 @@
#include "locationreadplanner.h"
#include <vespa/memfilepersistence/memfile/memfileiointerface.h>
+#include <algorithm>
-namespace storage {
-namespace memfile {
+namespace storage::memfile {
LocationDiskIoPlanner::LocationDiskIoPlanner(
const MemFileIOInterface& io,
@@ -97,5 +97,4 @@ LocationDiskIoPlanner::print(std::ostream& out, bool verbose,
}
}
-} // memfile
-} // storage
+}
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_verifier.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_verifier.cpp
index be1793ca355..39eb68315d2 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_verifier.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_verifier.cpp
@@ -7,6 +7,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/hash_set.hpp>
#include <sstream>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".persistence.memfilev1.verifier");
diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp
index 6bf2821d7a9..71d6a6b6fcf 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfilemapper.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
#include "memfilemapper.h"
#include "memfile_v1_serializer.h"
#include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h>
@@ -8,6 +7,7 @@
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/storageframework/generic/clock/timer.h>
#include <sstream>
+#include <algorithm>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".persistence.memfile.mapper");
diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecompactor.cpp b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecompactor.cpp
index 3ee3b5fca09..7d84fd3dde5 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecompactor.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecompactor.cpp
@@ -3,12 +3,12 @@
#include "memfilecompactor.h"
#include "memfile.h"
#include <vespa/vespalib/stllike/hash_map.hpp>
-#include <vespa/log/log.h>
+#include <algorithm>
+#include <vespa/log/log.h>
LOG_SETUP(".persistence.memfile.compactor");
-namespace storage {
-namespace memfile {
+namespace storage::memfile {
struct DocumentVersionInfo {
document::DocumentId _id;
@@ -71,8 +71,7 @@ struct CompactSlotInfo : private Types {
auto matchesId = [&](const DocumentVersionInfo& doc) {
return (id == doc._id);
};
- auto existing = std::find_if(
- gidDocs.begin(), gidDocs.end(), matchesId);
+ auto existing = std::find_if(gidDocs.begin(), gidDocs.end(), matchesId);
if (existing == gidDocs.end()) { // (Very) common case
gidDocs.emplace_back(id, isTombstone(slot));
@@ -202,6 +201,4 @@ MemFileCompactor::alwaysCompact(const MemSlot& slot,
slotsToRemove.push_back(&slot);
}
-
-} // memfile
-} // storage
+}
diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp
index baba449adff..4372f0a67d3 100644
--- a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp
+++ b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdisktool.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
#include <vespa/document/util/stringutil.h>
#include <vespa/fnet/frt/frt.h>
#include <vespa/memfilepersistence/device/mountpointlist.h>
@@ -9,15 +8,15 @@
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/programoptions.h>
#include <vespa/vespalib/util/exceptions.h>
-#include <sstream>
+#include <csignal>
+#include <dirent.h>
#include <vespa/log/log.h>
LOG_SETUP(".vdsdiskapp");
using std::vector;
-namespace storage {
-namespace memfile {
+namespace storage::memfile {
using vespalib::getLastErrorString;
@@ -516,5 +515,4 @@ VdsDiskTool::run(int argc, const char * const * argv,
return 0;
}
-} // memfile
-} // storage
+}
diff --git a/metrics/src/vespa/metrics/jsonwriter.cpp b/metrics/src/vespa/metrics/jsonwriter.cpp
index d0b269a1521..8dd5e8fdbcb 100644
--- a/metrics/src/vespa/metrics/jsonwriter.cpp
+++ b/metrics/src/vespa/metrics/jsonwriter.cpp
@@ -1,13 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/metrics/jsonwriter.h>
+#include "jsonwriter.h"
-#include <vespa/metrics/countmetric.h>
-#include <vespa/metrics/valuemetric.h>
-#include <vespa/metrics/metricsnapshot.h>
-#include <vespa/vespalib/util/jsonstream.h>
+#include "countmetric.h"
+#include "valuemetric.h"
+#include "metricsnapshot.h"
-#include <algorithm>
#include <iterator>
+#include <cassert>
namespace metrics {
diff --git a/metrics/src/vespa/metrics/loadmetric.hpp b/metrics/src/vespa/metrics/loadmetric.hpp
index 781a26a718d..0a66f985867 100644
--- a/metrics/src/vespa/metrics/loadmetric.hpp
+++ b/metrics/src/vespa/metrics/loadmetric.hpp
@@ -4,6 +4,7 @@
#include "loadmetric.h"
#include "memoryconsumption.h"
#include <vespa/vespalib/stllike/hash_map.hpp>
+#include <cassert>
namespace metrics {
diff --git a/metrics/src/vespa/metrics/metric.cpp b/metrics/src/vespa/metrics/metric.cpp
index 42096031486..f6be5f79357 100644
--- a/metrics/src/vespa/metrics/metric.cpp
+++ b/metrics/src/vespa/metrics/metric.cpp
@@ -10,6 +10,8 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <iterator>
+#include <cassert>
+#include <algorithm>
namespace metrics {
diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h
index 7819dc5f012..1b97dcb7d27 100644
--- a/metrics/src/vespa/metrics/metric.h
+++ b/metrics/src/vespa/metrics/metric.h
@@ -4,7 +4,6 @@
#include <vespa/vespalib/util/printable.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/regexp.h>
-#include <assert.h>
namespace metrics {
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index c1bcc126623..5530e468007 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -14,6 +14,7 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <sstream>
+#include <algorithm>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".metrics.manager");
diff --git a/metrics/src/vespa/metrics/metricset.cpp b/metrics/src/vespa/metrics/metricset.cpp
index 0bc2f3363dc..6ac27ba38c9 100644
--- a/metrics/src/vespa/metrics/metricset.cpp
+++ b/metrics/src/vespa/metrics/metricset.cpp
@@ -6,6 +6,8 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <list>
+#include <cassert>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".metrics.metricsset");
@@ -74,6 +76,15 @@ MetricSet::getMetricInternal(const String& name) const
return 0;
}
+int64_t MetricSet::getLongValue(const stringref &) const {
+ assert(false);
+ return 0;
+}
+double MetricSet::getDoubleValue(const stringref &) const {
+ assert(false);
+ return 0;
+}
+
const Metric*
MetricSet::getMetric(const String& name) const
{
diff --git a/metrics/src/vespa/metrics/metricset.h b/metrics/src/vespa/metrics/metricset.h
index 5851cdea43c..e6f7cfc0deb 100644
--- a/metrics/src/vespa/metrics/metricset.h
+++ b/metrics/src/vespa/metrics/metricset.h
@@ -10,9 +10,7 @@
*/
#pragma once
-#include <map>
-#include <vespa/metrics/metric.h>
-#include <assert.h>
+#include "metric.h"
namespace metrics {
@@ -65,10 +63,8 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent, uint64_t secondsPassed) const override;
// These should never be called on metrics set.
- int64_t getLongValue(const stringref & id) const override
- { (void) id; assert(false); return 0; }
- double getDoubleValue(const stringref & id) const override
- { (void) id; assert(false); return 0; }
+ int64_t getLongValue(const stringref & id) const override;
+ double getDoubleValue(const stringref & id) const override;
const Metric* getMetric(const String& name) const;
Metric* getMetric(const String& name) {
diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp
index 78fbf6e57a2..0b6ad8f9acd 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.cpp
+++ b/metrics/src/vespa/metrics/metricsnapshot.cpp
@@ -113,8 +113,8 @@ MetricSnapshotSet::timeForAnotherSnapshot(time_t currentTime) {
if (currentTime >= lastTime + 2 * getPeriod()) {
LOG(warning, "Metric snapshot set %s was asked if it was time for "
"another snapshot, a whole period beyond when it "
- "should have been done (Last update was at time %"
- PRIu64 ", current time is %" PRIu64 " and period is %u). "
+ "should have been done (Last update was at time %lu"
+ ", current time is %lu and period is %u). "
"Clearing data and updating time to current time.",
getName().c_str(), lastTime, currentTime, getPeriod());
reset(currentTime);
diff --git a/metrics/src/vespa/metrics/summetric.hpp b/metrics/src/vespa/metrics/summetric.hpp
index 484d4f08169..761b369fb57 100644
--- a/metrics/src/vespa/metrics/summetric.hpp
+++ b/metrics/src/vespa/metrics/summetric.hpp
@@ -7,6 +7,8 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <ostream>
+#include <cassert>
+#include <algorithm>
namespace metrics {
@@ -216,8 +218,7 @@ template<typename AddendMetric>
void
SumMetric<AddendMetric>::removeMetricFromSum(const AddendMetric &metric)
{
- _metricsToSum.erase(remove(_metricsToSum.begin(), _metricsToSum.end(),
- &metric));
+ _metricsToSum.erase(std::remove(_metricsToSum.begin(), _metricsToSum.end(), &metric));
}
template<typename AddendMetric>
diff --git a/metrics/src/vespa/metrics/valuemetricvalues.h b/metrics/src/vespa/metrics/valuemetricvalues.h
index 6422ab1b263..391b9c9d588 100644
--- a/metrics/src/vespa/metrics/valuemetricvalues.h
+++ b/metrics/src/vespa/metrics/valuemetricvalues.h
@@ -14,6 +14,7 @@
#pragma once
#include "metricvalueset.h"
+#include <limits>
namespace metrics {
diff --git a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp
index e6d21a83c01..a0176fe88f2 100644
--- a/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp
+++ b/persistence/src/vespa/persistence/conformancetest/conformancetest.cpp
@@ -12,11 +12,12 @@
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/config-stor-distribution.h>
+#include <algorithm>
+#include <limits>
using document::BucketId;
-namespace storage {
-namespace spi {
+namespace storage::spi {
namespace {
@@ -2306,6 +2307,4 @@ void ConformanceTest::detectAndTestOptionalBehavior() {
}
-} // spi
-} // storage
-
+}
diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp
index 8977b505740..489af79d595 100644
--- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp
+++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp
@@ -10,6 +10,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
+#include <algorithm>
using std::binary_search;
using std::lower_bound;
diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h
index 0e2821036ea..19076f053eb 100644
--- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h
+++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h
@@ -15,6 +15,7 @@
#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <atomic>
+#include <map>
namespace document {
class FieldSet;
diff --git a/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp b/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp
index 19c1e8c7dd6..6f8600c7ca4 100644
--- a/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp
+++ b/persistence/src/vespa/persistence/spi/metricpersistenceprovider.cpp
@@ -1,9 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "metricpersistenceprovider.h"
+#include <cassert>
#include <vespa/log/log.h>
-
LOG_SETUP(".persistence.spi.metrics");
#define PRE_PROCESS(opIndex) \
diff --git a/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h b/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h
index 96a4e0aa62e..baa341e8d15 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/persistent_predicate_params.h
@@ -2,8 +2,9 @@
#pragma once
-namespace search {
-namespace attribute {
+#include <limits>
+
+namespace search::attribute {
/*
* Persistent parameters for predicate attributes.
@@ -33,5 +34,4 @@ public:
}
};
-} // namespace attribute
-} // namespace search
+}
diff --git a/searchcore/src/apps/fdispatch/fdispatch.cpp b/searchcore/src/apps/fdispatch/fdispatch.cpp
index cf70edb4875..21fa696330a 100644
--- a/searchcore/src/apps/fdispatch/fdispatch.cpp
+++ b/searchcore/src/apps/fdispatch/fdispatch.cpp
@@ -10,6 +10,7 @@
#include <vespa/vespalib/util/signalhandler.h>
#include <vespa/fastos/app.h>
#include <thread>
+#include <getopt.h>
#include <vespa/log/log.h>
LOG_SETUP("fdispatch");
diff --git a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp
index 4422d659908..a0f34072f06 100644
--- a/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp
+++ b/searchcore/src/apps/vespa-gen-testdocs/vespa-gen-testdocs.cpp
@@ -7,9 +7,10 @@
#include <vespa/fastlib/io/bufferedfile.h>
#include <vespa/fastos/app.h>
#include <iostream>
-#include <algorithm>
#include <sstream>
#include <openssl/sha.h>
+#include <cassert>
+#include <getopt.h>
#include <vespa/log/log.h>
LOG_SETUP("vespa-gen-testdocs");
diff --git a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp
index f7588a83236..9a351b56eda 100644
--- a/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp
+++ b/searchcore/src/apps/vespa-proton-cmd/vespa-proton-cmd.cpp
@@ -1,15 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/slobrok/sbmirror.h>
-#include <vespa/config-slobroks.h>
#include <vespa/config/common/configsystem.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/fnet/frt/frt.h>
#include <vespa/vespalib/util/host_name.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/fastos/app.h>
-#include <algorithm>
-#include <string>
+#include <sys/time.h>
#include <vespa/log/log.h>
LOG_SETUP("vespa-proton-cmd");
diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
index a37306a3d60..ecb39af61bc 100644
--- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
@@ -30,6 +30,7 @@ typedef search::attribute::BasicType AVBasicType;
typedef search::attribute::CollectionType AVCollectionType;
using searchcorespi::IFlushTarget;
using searchcorespi::FlushStats;
+using namespace std::literals;
typedef std::shared_ptr<Gate> GateSP;
@@ -165,7 +166,7 @@ UpdaterTask::run()
slowedDown = false;
}
if (needFlushToken > flushedToken + slowdownUpdateLim) {
- FastOS_Thread::Sleep(100);
+ std::this_thread::sleep_for(100ms);
if (!slowedDown) {
LOG(warning,
"Slowing down updates due to slow flushing (slow disk ?)");
@@ -511,7 +512,7 @@ Test::requireThatLastFlushTimeIsReported()
IFlushTarget::SP ft = am.getFlushable("a9");
EXPECT_EQUAL(stat._modifiedTime, ft->getLastFlushTime().time());
{ // updated flush time after nothing to flush
- FastOS_Thread::Sleep(8000);
+ std::this_thread::sleep_for(8000ms);
fastos::TimeStamp now = fastos::ClockSystem::now();
Executor::Task::UP task = ft->initFlush(200);
EXPECT_TRUE(task.get() == NULL);
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
index bc17a698536..c9761ee7e6e 100644
--- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
+++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
@@ -6,8 +6,6 @@
#include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h>
#include <vespa/searchlib/attribute/attributefilesavetarget.h>
#include <vespa/searchlib/fef/matchdatalayout.h>
-#include <vespa/searchlib/queryeval/blueprint.h>
-#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/queryeval/simpleresult.h>
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
@@ -45,11 +43,11 @@ using storage::spi::Timestamp;
using vespalib::GenerationHandler;
using vespalib::GenerationHolder;
using searchcorespi::IFlushTarget;
+using namespace std::literals;
namespace proton {
-namespace
-{
+namespace {
static constexpr uint32_t numBucketBits = UINT32_C(20);
static constexpr uint64_t timestampBias = UINT64_C(2000000000000);
@@ -666,7 +664,7 @@ TEST("requireThatStatsAreUpdated")
EXPECT_GREATER(lastAllocated, perGidUsed);
EXPECT_GREATER(lastUsed, perGidUsed);
- FastOS_Thread::Sleep(2200);
+ std::this_thread::sleep_for(2200ms);
addGid(dms, gid1, bucketId1, time1);
EXPECT_EQUAL(2u, dms.getStatus().getNumDocs());
EXPECT_EQUAL(2u, dms.getStatus().getNumValues());
diff --git a/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp b/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp
index 707b37eb3de..86f120aa403 100644
--- a/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp
+++ b/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp
@@ -5,8 +5,7 @@
#include <vespa/searchcorespi/index/diskindexcleaner.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/fastos/file.h>
-#include <string>
-#include <vector>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP("diskindexcleaner_test");
diff --git a/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp
index 9d2cb958d39..aa6cbd40126 100644
--- a/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp
+++ b/searchcore/src/tests/proton/reference/document_db_reference_registry/document_db_reference_registry_test.cpp
@@ -4,14 +4,14 @@
#include <vespa/searchcore/proton/reference/document_db_reference_registry.h>
#include <vespa/searchcore/proton/test/mock_document_db_reference.h>
#include <thread>
+#include <unistd.h>
+
#include <vespa/log/log.h>
LOG_SETUP("document_db_reference_registry_test");
-namespace proton
-{
+namespace proton {
-namespace
-{
+namespace {
std::mutex lock;
diff --git a/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp b/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp
index d9645e56606..248babad316 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/common/appcontext.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "appcontext.h"
+#include <cassert>
FastS_TimeKeeper::FastS_TimeKeeper()
: _clock(0.010),
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h
index 5984827459f..847fb525b95 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/search_path.h
@@ -5,6 +5,7 @@
#include <vespa/vespalib/stllike/string.h>
#include <set>
#include <vector>
+#include <limits>
namespace vespalib {
class asciistream;
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp
index 402d6986aa8..1fcffa92cce 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp
@@ -4,6 +4,7 @@
#include "attribute_directory.h"
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/fastos/file.h>
+#include <cassert>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp
index 73eefe620c2..06aca3381f7 100644
--- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp
@@ -2,6 +2,7 @@
#include "bucketdb.h"
#include <cassert>
+#include <algorithm>
using document::GlobalId;
using storage::spi::BucketChecksum;
diff --git a/searchcore/src/vespa/searchcore/proton/common/config_hash.hpp b/searchcore/src/vespa/searchcore/proton/common/config_hash.hpp
index 7578f0e33f4..84e5a632c09 100644
--- a/searchcore/src/vespa/searchcore/proton/common/config_hash.hpp
+++ b/searchcore/src/vespa/searchcore/proton/common/config_hash.hpp
@@ -4,7 +4,7 @@
#include "config_hash.h"
#include <vespa/vespalib/stllike/hash_map.hpp>
-#include <assert.h>
+#include <cassert>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp b/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp
index b2a12d8a9c0..3cecc8308ad 100644
--- a/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "monitored_refcount.h"
-#include <assert.h>
+#include <cassert>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp
index 3b0ff6d5616..0dae1818e02 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_gid_key_comparator.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "lid_gid_key_comparator.h"
+#include <limits>
namespace proton::documentmetastore {
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flush_all_strategy.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flush_all_strategy.cpp
index 39c0c2bd0e0..914b301b7e2 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flush_all_strategy.cpp
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flush_all_strategy.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "flush_all_strategy.h"
+#include <algorithm>
using search::SerialNum;
using searchcorespi::IFlushTarget;
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
index f703223bcbb..7f4698610c8 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
@@ -7,6 +7,7 @@
#include <vespa/searchcore/proton/common/doctypename.h>
#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <vespa/fastos/thread.h>
#include <set>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/prepare_restart_flush_strategy.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/prepare_restart_flush_strategy.cpp
index 2fd2b74eaa2..e9df78dbf4f 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/prepare_restart_flush_strategy.cpp
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/prepare_restart_flush_strategy.cpp
@@ -4,6 +4,7 @@
#include "flush_target_candidates.h"
#include "tls_stats_map.h"
#include <sstream>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".proton.flushengine.prepare_restart_flush_strategy");
diff --git a/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp b/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp
index 1826b3a8d98..88aea2bd86c 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/docid_range_scheduler.cpp
@@ -1,9 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "docid_range_scheduler.h"
+#include <cassert>
-namespace proton {
-namespace matching {
+namespace proton::matching {
namespace {
@@ -160,5 +160,4 @@ AdaptiveDocidRangeScheduler::share_range(size_t thread_id, DocidRange todo)
//-----------------------------------------------------------------------------
-} // namespace proton::matching
-} // namespace proton
+}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp b/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp
index 69da8d5bfed..3573c7ec7b8 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/handlerecorder.cpp
@@ -3,12 +3,11 @@
#include "handlerecorder.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <cassert>
-
+#include <algorithm>
using search::fef::TermFieldHandle;
-namespace proton {
-namespace matching {
+namespace proton::matching {
#ifdef __PIC__
#define TLS_LINKAGE __attribute__((visibility("hidden"), tls_model("initial-exec")))
@@ -79,5 +78,4 @@ void HandleRecorder::registerHandle(TermFieldHandle handle)
}
}
-} // namespace matching
-} // namespace proton
+}
diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp
index 8260c0209a9..0ef3b0e2aab 100644
--- a/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/document_iterator.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/select/node.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/stllike/hash_map.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".proton.persistenceengine.document_iterator");
diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp
index a70fb5b119d..e7b347c4c80 100644
--- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_handler.cpp
@@ -5,7 +5,7 @@
#include <vespa/searchlib/common/lambdatask.h>
#include <vespa/searchcorespi/index/i_thread_service.h>
#include <vespa/document/base/globalid.h>
-#include <assert.h>
+#include <cassert>
using search::makeLambdaTask;
diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_registrator.cpp b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_registrator.cpp
index 19ec153c741..3567a69e8a3 100644
--- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_registrator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_registrator.cpp
@@ -2,7 +2,7 @@
#include "gid_to_lid_change_registrator.h"
#include "i_gid_to_lid_change_listener.h"
-#include <assert.h>
+#include <cassert>
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp
index 28fee79005a..cc399727460 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp
@@ -2,6 +2,7 @@
#include "bootstrapconfigmanager.h"
#include "bootstrapconfig.h"
+#include <vespa/searchlib/common/tunefileinfo.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.bootstrapconfigmanager");
@@ -14,8 +15,7 @@ using vespa::config::search::core::ProtonConfig;
using cloud::config::filedistribution::FiledistributorrpcConfig;
using document::DocumenttypesConfig;
-namespace proton
-{
+namespace proton {
BootstrapConfigManager::BootstrapConfigManager(const vespalib::string & configId)
: _pendingConfigSnapshot(),
diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp
index 2de1b5fd83f..fb7d712db9d 100644
--- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp
@@ -3,7 +3,7 @@
#include "disk_mem_usage_sampler.h"
#include <vespa/vespalib/util/timer.h>
#include <vespa/searchlib/common/lambdatask.h>
-#include <cstdlib>
+#include <unistd.h>
using search::makeLambdaTask;
diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp
index 4927f831fc4..af8e16f657b 100644
--- a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp
@@ -2,8 +2,7 @@
#include "executor_thread_service.h"
#include <vespa/vespalib/util/closuretask.h>
-#include <vespa/vespalib/util/executor.h>
-#include <vespa/vespalib/util/sync.h>
+#include <vespa/fastos/thread.h>
using vespalib::makeClosure;
using vespalib::makeTask;
@@ -14,6 +13,13 @@ using vespalib::ThreadStackExecutorBase;
namespace proton {
+namespace internal {
+
+struct ThreadId {
+ FastOS_ThreadId _id;
+};
+}
+
namespace {
void
@@ -22,11 +28,11 @@ sampleThreadId(FastOS_ThreadId *threadId)
*threadId = FastOS_Thread::GetCurrentThreadId();
}
-FastOS_ThreadId
+std::unique_ptr<internal::ThreadId>
getThreadId(ThreadStackExecutorBase &executor)
{
- FastOS_ThreadId id;
- executor.execute(makeTask(makeClosure(&sampleThreadId, &id)));
+ std::unique_ptr<internal::ThreadId> id = std::make_unique<internal::ThreadId>();
+ executor.execute(makeTask(makeClosure(&sampleThreadId, &id->_id)));
executor.sync();
return id;
}
@@ -46,6 +52,8 @@ ExecutorThreadService::ExecutorThreadService(ThreadStackExecutorBase &executor)
{
}
+ExecutorThreadService::~ExecutorThreadService() {}
+
void
ExecutorThreadService::run(Runnable &runnable)
{
@@ -62,7 +70,7 @@ bool
ExecutorThreadService::isCurrentThread() const
{
FastOS_ThreadId currentThreadId = FastOS_Thread::GetCurrentThreadId();
- return FastOS_Thread::CompareThreadIds(_threadId, currentThreadId);
+ return FastOS_Thread::CompareThreadIds(_threadId->_id, currentThreadId);
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h
index ea4c51f8858..47e41fcd1db 100644
--- a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h
+++ b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h
@@ -6,6 +6,7 @@
namespace proton {
+namespace internal { class ThreadId; }
/**
* Implementation of IThreadService using an underlying thread stack executor
* with a single thread.
@@ -14,10 +15,11 @@ class ExecutorThreadService : public searchcorespi::index::IThreadService
{
private:
vespalib::ThreadStackExecutorBase &_executor;
- FastOS_ThreadId _threadId;
+ std::unique_ptr<internal::ThreadId> _threadId;
public:
ExecutorThreadService(vespalib::ThreadStackExecutorBase &executor);
+ ~ExecutorThreadService();
/**
* Implements IThreadService
diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
index a833b063567..3750ba03f50 100644
--- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
@@ -20,6 +20,7 @@
#include <vespa/searchlib/common/idestructorcallback.h>
#include <vespa/vespalib/util/closuretask.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <unistd.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.feedhandler");
diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp
index 17b41295a89..2bd2cb1eda1 100644
--- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp
@@ -14,6 +14,7 @@
#include <vespa/config/helper/configgetter.hpp>
#include <fstream>
#include <sstream>
+#include <fcntl.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.fileconfigmanager");
@@ -60,15 +61,11 @@ fsyncFile(const vespalib::string &fileName)
FastOS_File f;
f.OpenReadWrite(fileName.c_str());
if (!f.IsOpened()) {
- LOG(error,
- "Could not open file '%s' for fsync",
- fileName.c_str());
+ LOG(error, "Could not open file '%s' for fsync", fileName.c_str());
return;
}
if (!f.Sync()) {
- LOG(error,
- "Could not fsync file '%s'",
- fileName.c_str());
+ LOG(error, "Could not fsync file '%s'", fileName.c_str());
}
f.Close();
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/frozenbuckets.cpp b/searchcore/src/vespa/searchcore/proton/server/frozenbuckets.cpp
index ada3dd92656..c021d786216 100644
--- a/searchcore/src/vespa/searchcore/proton/server/frozenbuckets.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/frozenbuckets.cpp
@@ -4,14 +4,14 @@
#include "ibucketfreezelistener.h"
#include <vespa/searchcorespi/index/i_thread_service.h>
#include <vespa/vespalib/util/closuretask.h>
+#include <algorithm>
using document::BucketId;
using vespalib::makeClosure;
using vespalib::makeTask;
using vespalib::MonitorGuard;
-namespace proton
-{
+namespace proton {
FrozenBucketsMap::FrozenBucketsMap() :
_lock(),
diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
index 4dd44a7b2e2..2d56c7e37e9 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
@@ -4,6 +4,7 @@
#include <vespa/searchcore/proton/flushengine/tls_stats_map.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/hash_set.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.memoryflush");
diff --git a/searchcore/src/vespa/searchcore/proton/test/bucketdocuments.h b/searchcore/src/vespa/searchcore/proton/test/bucketdocuments.h
index 021d0f631d4..ce27cc7673b 100644
--- a/searchcore/src/vespa/searchcore/proton/test/bucketdocuments.h
+++ b/searchcore/src/vespa/searchcore/proton/test/bucketdocuments.h
@@ -3,10 +3,9 @@
#include "document.h"
#include <cassert>
+#include <algorithm>
-namespace proton {
-
-namespace test {
+namespace proton::test {
/**
* Collection of documents contained in the same bucket.
@@ -40,8 +39,4 @@ public:
}
};
-
-} // namespace test
-
-} // namespace proton
-
+}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp
index 8035925f9ec..47af497ec15 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexflushtarget.cpp
@@ -42,11 +42,8 @@ IndexFlushTarget::needUrgentFlush(void) const
{
bool urgent = _numFrozenMemoryIndexes > _maxFrozenMemoryIndexes;
SerialNum flushedSerial = _indexMaintainer.getFlushedSerialNum();
- LOG(debug,
- "Num frozen: %" PRIu32 " Urgent: %d, flushedSerial=%" PRIu64,
- _numFrozenMemoryIndexes,
- static_cast<int>(urgent),
- flushedSerial);
+ LOG(debug, "Num frozen: %u Urgent: %d, flushedSerial=%lu",
+ _numFrozenMemoryIndexes, static_cast<int>(urgent), flushedSerial);
return urgent;
}
diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp
index a1121769557..3dcfbbb31cc 100644
--- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp
+++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp
@@ -8,6 +8,7 @@
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/data/databuffer.h>
#include <vespa/fastos/app.h>
+#include <unistd.h>
#include <vespa/log/log.h>
LOG_SETUP("documentstore.benchmark");
diff --git a/searchlib/src/apps/uniform/uniform.cpp b/searchlib/src/apps/uniform/uniform.cpp
index a42af9f1ff3..b69c2ddfc56 100644
--- a/searchlib/src/apps/uniform/uniform.cpp
+++ b/searchlib/src/apps/uniform/uniform.cpp
@@ -2,6 +2,7 @@
#include <vespa/fastos/app.h>
#include <vespa/searchlib/bitcompression/compression.h>
+#include <vespa/log/log.h>
static uint64_t
diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
index 4694eb55176..c2fcba379fd 100644
--- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
+++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp
@@ -9,13 +9,12 @@
#include <vespa/searchlib/diskindex/docidmapper.h>
#include <vespa/searchlib/diskindex/wordnummapper.h>
#include <vespa/searchlib/diskindex/fieldreader.h>
-#include <vespa/searchlib/index/schemautil.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/fef/termfieldmatchdata.h>
-#include <vespa/searchlib/fef/termfieldmatchdataarray.h>
#include <vespa/fastos/app.h>
#include <iostream>
+#include <getopt.h>
#include <vespa/log/log.h>
LOG_SETUP("vespa-index-inspect");
diff --git a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp
index 00321093600..8eef498d85c 100644
--- a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp
+++ b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp
@@ -8,13 +8,12 @@
#include <vespa/searchlib/attribute/singlestringattribute.h>
#include <vespa/searchlib/attribute/multistringattribute.h>
#include <vespa/searchlib/attribute/attrvector.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/fastos/app.h>
#include <iostream>
#include <fstream>
#include "../attributesearcher.h"
#include "../attributeupdater.h"
-#include "../runnable.h"
+#include <sys/resource.h>
#include <vespa/log/log.h>
diff --git a/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp b/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp
index c6045208a1f..185b36ec414 100644
--- a/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp
+++ b/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp
@@ -1,10 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("expglomb_test");
#include <vespa/searchlib/bitcompression/compression.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vector>
+#include <algorithm>
+
+#include <vespa/log/log.h>
+LOG_SETUP("expglomb_test");
using search::bitcompression::DecodeContext64;
using search::bitcompression::DecodeContext64Base;
diff --git a/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp b/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp
index a7b0e90ea1f..0cbd4bd9473 100644
--- a/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp
+++ b/searchlib/src/tests/common/foregroundtaskexecutor/foregroundtaskexecutor_test.cpp
@@ -1,17 +1,16 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("foregroundtaskexecutor_test");
+
#include <vespa/searchlib/common/foregroundtaskexecutor.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <mutex>
#include <condition_variable>
+#include <unistd.h>
-namespace search
-{
+#include <vespa/log/log.h>
+LOG_SETUP("foregroundtaskexecutor_test");
-namespace common
-{
+namespace search::common {
class Fixture
@@ -117,7 +116,6 @@ TEST_F("require that task with different ids are serialized", Fixture)
}
-} // namespace common
-} // namespace search
+}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp b/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp
index 569bff0f6f3..7d158918715 100644
--- a/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp
+++ b/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp
@@ -1,18 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("sequencedtaskexecutor_test");
+
#include <vespa/searchlib/common/sequencedtaskexecutor.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <mutex>
#include <condition_variable>
+#include <unistd.h>
-namespace search
-{
+#include <vespa/log/log.h>
+LOG_SETUP("sequencedtaskexecutor_test");
-namespace common
-{
+namespace search::common {
class Fixture
@@ -236,7 +235,6 @@ TEST_F("require that executeLambda works", Fixture)
}
-} // namespace common
-} // namespace search
+}
TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp
index ba78f00ffca..37aa9cc3268 100644
--- a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp
+++ b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp
@@ -13,6 +13,8 @@
#include <vespa/vespalib/objects/objectpredicate.h>
#include <vespa/vespalib/objects/objectoperation.h>
#include <vespa/vespalib/util/rusage.h>
+#include <csignal>
+
#include <vespa/log/log.h>
LOG_SETUP("grouping_benchmark");
diff --git a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp
index 820386f41ce..c926d1c2831 100644
--- a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp
+++ b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp
@@ -1010,8 +1010,8 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>)
LOG(info,
"Before feature compaction: allocElems=%" PRIu64 ", usedElems=%" PRIu64
", deadElems=%" PRIu64 ", holdElems=%" PRIu64
- ", freeBuffers=%" PRIu32 ", activeBuffers=%" PRIu32
- ", holdBuffers=%" PRIu32,
+ ", freeBuffers=%u, activeBuffers=%u"
+ ", holdBuffers=%u",
beforeStats._allocElems,
beforeStats._usedElems,
beforeStats._deadElems,
@@ -1030,8 +1030,8 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>)
LOG(info,
"During feature compaction: allocElems=%" PRIu64 ", usedElems=%" PRIu64
", deadElems=%" PRIu64 ", holdElems=%" PRIu64
- ", freeBuffers=%" PRIu32 ", activeBuffers=%" PRIu32
- ", holdBuffers=%" PRIu32,
+ ", freeBuffers=%u, activeBuffers=%u"
+ ", holdBuffers=%u",
duringStats._allocElems,
duringStats._usedElems,
duringStats._deadElems,
@@ -1045,8 +1045,8 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>)
LOG(info,
"After feature compaction: allocElems=%" PRIu64 ", usedElems=%" PRIu64
", deadElems=%" PRIu64 ", holdElems=%" PRIu64
- ", freeBuffers=%" PRIu32 ", activeBuffers=%" PRIu32
- ", holdBuffers=%" PRIu32,
+ ", freeBuffers=%u, activeBuffers=%u"
+ ", holdBuffers=%u",
afterStats._allocElems,
afterStats._usedElems,
afterStats._deadElems,
@@ -1059,14 +1059,12 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>)
TermFieldMatchDataArray matchData;
matchData.add(&tfmd);
{
- PostingIterator itr(f._d.findFrozen("not", 0), featureStoreRef(f._d, 0),
- 0, matchData);
+ PostingIterator itr(f._d.findFrozen("not", 0), featureStoreRef(f._d, 0), 0, matchData);
itr.initFullRange();
EXPECT_TRUE(itr.isAtEnd());
}
{
- PostingIterator itr(f._d.findFrozen("a", 0), featureStoreRef(f._d, 0),
- 0, matchData);
+ PostingIterator itr(f._d.findFrozen("a", 0), featureStoreRef(f._d, 0), 0, matchData);
itr.initFullRange();
EXPECT_EQUAL(10u, itr.getDocId());
itr.unpack(10);
@@ -1083,33 +1081,27 @@ TEST_F("requireThatInversionIsWorking", DictionaryFixture<Fixture>)
EXPECT_TRUE(itr.isAtEnd());
}
{
- PostingIterator itr(f._d.findFrozen("x", 0), featureStoreRef(f._d, 0),
- 0, matchData);
+ PostingIterator itr(f._d.findFrozen("x", 0), featureStoreRef(f._d, 0), 0, matchData);
itr.initFullRange();
EXPECT_TRUE(itr.isAtEnd());
}
{
- PostingIterator itr(f._d.findFrozen("x", 1), featureStoreRef(f._d, 1),
- 1, matchData);
+ PostingIterator itr(f._d.findFrozen("x", 1), featureStoreRef(f._d, 1), 1, matchData);
itr.initFullRange();
EXPECT_EQUAL(30u, itr.getDocId());
itr.unpack(30);
- EXPECT_EQUAL("{6:2[e=0,w=1,l=6]}",
- toString(tfmd.getIterator(), true, true));
+ EXPECT_EQUAL("{6:2[e=0,w=1,l=6]}", toString(tfmd.getIterator(), true, true));
}
{
- PostingIterator itr(f._d.findFrozen("x", 2), featureStoreRef(f._d, 2),
- 2, matchData);
+ PostingIterator itr(f._d.findFrozen("x", 2), featureStoreRef(f._d, 2), 2, matchData);
itr.initFullRange();
EXPECT_EQUAL(30u, itr.getDocId());
itr.unpack(30);
// weight is hardcoded to 1 for new style il doc array field
- EXPECT_EQUAL("{2:1[e=0,w=1,l=2]}",
- toString(tfmd.getIterator(), true, true));
+ EXPECT_EQUAL("{2:1[e=0,w=1,l=2]}", toString(tfmd.getIterator(), true, true));
}
{
- PostingIterator itr(f._d.findFrozen("x", 3), featureStoreRef(f._d, 3),
- 3, matchData);
+ PostingIterator itr(f._d.findFrozen("x", 3), featureStoreRef(f._d, 3), 3, matchData);
itr.initFullRange();
EXPECT_EQUAL(30u, itr.getDocId());
itr.unpack(30);
diff --git a/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp b/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp
index 4938d40a21f..6f09dd5c924 100644
--- a/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp
+++ b/searchlib/src/tests/memoryindex/document_remover/document_remover_test.cpp
@@ -1,14 +1,15 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("document_remover_test");
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/searchlib/memoryindex/document_remover.h>
#include <vespa/searchlib/memoryindex/wordstore.h>
#include <vespa/searchlib/memoryindex/i_document_remove_listener.h>
#include <vespa/vespalib/test/insertion_operators.h>
-#include <map>
+#include <algorithm>
+
+#include <vespa/log/log.h>
+LOG_SETUP("document_remover_test");
using namespace search;
using namespace search::memoryindex;
diff --git a/searchlib/src/tests/postinglistbm/andstress.cpp b/searchlib/src/tests/postinglistbm/andstress.cpp
index 183cec6bbf1..bdf90fb7732 100644
--- a/searchlib/src/tests/postinglistbm/andstress.cpp
+++ b/searchlib/src/tests/postinglistbm/andstress.cpp
@@ -1,7 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP(".andstress");
#include "andstress.h"
#include <vector>
@@ -14,14 +12,17 @@ LOG_SETUP(".andstress");
#include <vespa/searchlib/test/fakedata/fakezcfilterocc.h>
#include <vespa/searchlib/test/fakedata/fakezcbfilterocc.h>
#include <vespa/searchlib/test/fakedata/fpfactory.h>
+#include <vespa/fastos/thread.h>
+
+#include <vespa/log/log.h>
+LOG_SETUP(".andstress");
using search::fef::TermFieldMatchData;
using search::fef::TermFieldMatchDataArray;
using search::queryeval::SearchIterator;
using namespace search::fakedata;
-namespace postinglistbm
-{
+namespace postinglistbm {
class AndStressWorker;
diff --git a/searchlib/src/tests/postinglistbm/andstress.h b/searchlib/src/tests/postinglistbm/andstress.h
index b752e602f5d..07e344f3549 100644
--- a/searchlib/src/tests/postinglistbm/andstress.h
+++ b/searchlib/src/tests/postinglistbm/andstress.h
@@ -1,23 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-
#include <vector>
-namespace search
-{
-class Rand48;
-
-namespace fakedata
-{
+#include <string>
-class FakeWordSet;
+namespace search {
+class Rand48;
-}
+namespace fakedata { class FakeWordSet; }
}
-namespace postinglistbm
-{
+namespace postinglistbm {
class AndStress
{
@@ -39,5 +33,4 @@ public:
bool unpack);
};
-} // namespace postinglistbm
-
+}
diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp
index 58341a3458e..3a20af3e00a 100644
--- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp
+++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp
@@ -13,6 +13,8 @@
#include <vespa/searchlib/index/docidandfeatures.h>
#include <vespa/fastos/app.h>
+#include <vespa/log/log.h>
+
using search::ResultSet;
using search::fef::TermFieldMatchData;
using search::fef::TermFieldMatchDataArray;
diff --git a/searchlib/src/tests/query/query-old-large.cpp b/searchlib/src/tests/query/query-old-large.cpp
index 8bdc65c12c1..f1ff391cc2c 100644
--- a/searchlib/src/tests/query/query-old-large.cpp
+++ b/searchlib/src/tests/query/query-old-large.cpp
@@ -4,7 +4,7 @@
#include <vespa/searchlib/query/tree/simplequery.h>
#include <vespa/searchlib/query/tree/stackdumpcreator.h>
#include <vespa/vespalib/testkit/test_kit.h>
-#include <limits>
+#include <sys/resource.h>
using namespace search;
using namespace search::query;
diff --git a/searchlib/src/tests/sort/uca.cpp b/searchlib/src/tests/sort/uca.cpp
index 3c55ac3dc31..579f3e7906e 100644
--- a/searchlib/src/tests/sort/uca.cpp
+++ b/searchlib/src/tests/sort/uca.cpp
@@ -1,17 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/searchlib/common/sort.h>
#include <vespa/searchlib/common/sortspec.h>
-#include <vespa/searchlib/common/converters.h>
#include <vespa/vespalib/util/array.h>
-#include <memory>
-#include <string>
-#include <vector>
-#include <stdexcept>
#include <unicode/ustring.h>
#include <unicode/coll.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <vespa/log/log.h>
LOG_SETUP("uca_stress");
using icu::Collator;
diff --git a/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp b/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp
index 33d0879220b..f6055376907 100644
--- a/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp
+++ b/searchlib/src/tests/util/ioerrorhandler/ioerrorhandler_test.cpp
@@ -13,6 +13,7 @@
#include <string>
#include <setjmp.h>
#include <dlfcn.h>
+#include <unistd.h>
#include <vespa/log/log.h>
LOG_SETUP("ioerrorhandler_test");
diff --git a/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp b/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp
index c4c6b616567..c86a1c86dbb 100644
--- a/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp
+++ b/searchlib/src/tests/util/sigbushandler/sigbushandler_test.cpp
@@ -1,16 +1,19 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("sigbushandler_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/searchlib/util/statefile.h>
#include <vespa/searchlib/util/sigbushandler.h>
-#include <atomic>
#include <iostream>
#include <fstream>
-#include <string>
#include <vespa/searchlib/test/statefile.h>
#include <vespa/searchlib/test/statestring.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include <vespa/log/log.h>
+LOG_SETUP("sigbushandler_test");
using namespace search::test::statefile;
using namespace search::test::statestring;
diff --git a/searchlib/src/tests/util/statefile/statefile_test.cpp b/searchlib/src/tests/util/statefile/statefile_test.cpp
index 6480455ab3e..a9f087c773b 100644
--- a/searchlib/src/tests/util/statefile/statefile_test.cpp
+++ b/searchlib/src/tests/util/statefile/statefile_test.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("statefile_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/searchlib/util/statefile.h>
@@ -9,15 +8,18 @@ LOG_SETUP("statefile_test");
#include <fstream>
#include <string>
#include <vespa/searchlib/test/statefile.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <vespa/log/log.h>
+LOG_SETUP("statefile_test");
using namespace search::test::statefile;
-namespace search
-{
+namespace search {
-namespace
-{
+namespace {
bool
hasFile(const char *name)
diff --git a/searchlib/src/vespa/searchlib/btree/btreetraits.h b/searchlib/src/vespa/searchlib/btree/btreetraits.h
index aaeb2b28021..efa7cb4de34 100644
--- a/searchlib/src/vespa/searchlib/btree/btreetraits.h
+++ b/searchlib/src/vespa/searchlib/btree/btreetraits.h
@@ -2,13 +2,9 @@
#pragma once
-#include <sys/types.h>
+#include <cstddef>
-namespace search
-{
-
-namespace btree
-{
+namespace search::btree {
template <size_t LS, size_t IS, size_t PS, bool BS>
struct BTreeTraits {
@@ -20,6 +16,4 @@ struct BTreeTraits {
typedef BTreeTraits<16, 16, 10, true> BTreeDefaultTraits;
-} // namespace search::btree
-} // namespace search
-
+}
diff --git a/searchlib/src/vespa/searchlib/common/address_space.cpp b/searchlib/src/vespa/searchlib/common/address_space.cpp
index a2dcaf024e5..af5e754e68f 100644
--- a/searchlib/src/vespa/searchlib/common/address_space.cpp
+++ b/searchlib/src/vespa/searchlib/common/address_space.cpp
@@ -2,7 +2,7 @@
#include "address_space.h"
#include <ostream>
-#include <assert.h>
+#include <cassert>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp
index 8018c4f8010..4931455da8d 100644
--- a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "allocatedbitvector.h"
+#include <cstring>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/allocatedbitvector.h b/searchlib/src/vespa/searchlib/common/allocatedbitvector.h
index bc9437f1b36..1f895eee93f 100644
--- a/searchlib/src/vespa/searchlib/common/allocatedbitvector.h
+++ b/searchlib/src/vespa/searchlib/common/allocatedbitvector.h
@@ -4,7 +4,7 @@
#pragma once
-#include <vespa/searchlib/common/bitvector.h>
+#include "bitvector.h"
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp
index 7d5aa8beeae..04909da8ea7 100644
--- a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp
+++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "bitvectorcache.h"
#include <vespa/vespalib/stllike/hash_map.hpp>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".searchlib.common.bitvectorcache");
diff --git a/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp b/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp
index f3697086147..10015bb658a 100644
--- a/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp
+++ b/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp
@@ -4,6 +4,7 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/guard.h>
#include <cassert>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".indexmetainfo");
diff --git a/searchlib/src/vespa/searchlib/common/location.cpp b/searchlib/src/vespa/searchlib/common/location.cpp
index 31af111b2bf..cda3973b311 100644
--- a/searchlib/src/vespa/searchlib/common/location.cpp
+++ b/searchlib/src/vespa/searchlib/common/location.cpp
@@ -3,6 +3,7 @@
// Copyright (C) 2003 Overture Services Norway AS
#include "location.h"
+#include <limits>
namespace search::common {
diff --git a/searchlib/src/vespa/searchlib/common/partialbitvector.cpp b/searchlib/src/vespa/searchlib/common/partialbitvector.cpp
index 462f78446b4..e57396c0dfa 100644
--- a/searchlib/src/vespa/searchlib/common/partialbitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/partialbitvector.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "partialbitvector.h"
+#include <cstring>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/partialbitvector.h b/searchlib/src/vespa/searchlib/common/partialbitvector.h
index d30f227304c..4cfd3e34383 100644
--- a/searchlib/src/vespa/searchlib/common/partialbitvector.h
+++ b/searchlib/src/vespa/searchlib/common/partialbitvector.h
@@ -4,7 +4,7 @@
#pragma once
-#include <vespa/searchlib/common/bitvector.h>
+#include "bitvector.h"
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/rankedhit.h b/searchlib/src/vespa/searchlib/common/rankedhit.h
index d1feb5e3282..bd66f884a08 100644
--- a/searchlib/src/vespa/searchlib/common/rankedhit.h
+++ b/searchlib/src/vespa/searchlib/common/rankedhit.h
@@ -5,8 +5,8 @@
#pragma once
#include "hitrank.h"
-#include <sys/types.h>
-#include <stdint.h>
+#include <cstdint>
+#include <cstddef>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/resultset.cpp b/searchlib/src/vespa/searchlib/common/resultset.cpp
index 9a4627a56ab..69f3b13d709 100644
--- a/searchlib/src/vespa/searchlib/common/resultset.cpp
+++ b/searchlib/src/vespa/searchlib/common/resultset.cpp
@@ -4,6 +4,7 @@
#include "resultset.h"
#include "bitvector.h"
+#include <cstring>
using vespalib::alloc::Alloc;
diff --git a/searchlib/src/vespa/searchlib/common/tunefileinfo.cpp b/searchlib/src/vespa/searchlib/common/tunefileinfo.cpp
index 2bf2fc751d3..f8325c3cd7d 100644
--- a/searchlib/src/vespa/searchlib/common/tunefileinfo.cpp
+++ b/searchlib/src/vespa/searchlib/common/tunefileinfo.cpp
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "tunefileinfo.h"
+#include "tunefileinfo.hpp"
namespace search {
diff --git a/searchlib/src/vespa/searchlib/common/tunefileinfo.h b/searchlib/src/vespa/searchlib/common/tunefileinfo.h
index 2dd27142dc6..223dcdbc7f1 100644
--- a/searchlib/src/vespa/searchlib/common/tunefileinfo.h
+++ b/searchlib/src/vespa/searchlib/common/tunefileinfo.h
@@ -2,9 +2,6 @@
#pragma once
-#include <sys/mman.h>
-#include <linux/mman.h>
-#include <fcntl.h>
#include <memory>
namespace search {
@@ -123,26 +120,7 @@ public:
template <typename TuneControlConfig, typename MMapConfig>
void
- setFromConfig(const enum TuneControlConfig::Io & tuneControlConfig, const MMapConfig & mmapFlags) {
- switch ( tuneControlConfig) {
- case TuneControlConfig::NORMAL: _tuneControl = NORMAL; break;
- case TuneControlConfig::DIRECTIO: _tuneControl = DIRECTIO; break;
- case TuneControlConfig::MMAP: _tuneControl = MMAP; break;
- default: _tuneControl = NORMAL; break;
- }
- for (size_t i(0), m(mmapFlags.options.size()); i < m; i++) {
- switch (mmapFlags.options[i]) {
- case MMapConfig::MLOCK: _mmapFlags |= MAP_LOCKED; break;
- case MMapConfig::POPULATE: _mmapFlags |= MAP_POPULATE; break;
- case MMapConfig::HUGETLB: _mmapFlags |= MAP_HUGETLB; break;
- }
- }
- switch (mmapFlags.advise) {
- case MMapConfig::NORMAL: setAdvise(POSIX_FADV_NORMAL); break;
- case MMapConfig::RANDOM: setAdvise(POSIX_FADV_RANDOM); break;
- case MMapConfig::SEQUENTIAL: setAdvise(POSIX_FADV_SEQUENTIAL); break;
- }
- }
+ setFromConfig(const enum TuneControlConfig::Io & tuneControlConfig, const MMapConfig & mmapFlags);
bool operator==(const TuneFileRandRead &rhs) const {
return (_tuneControl == rhs._tuneControl) && (_mmapFlags == rhs._mmapFlags);
diff --git a/searchlib/src/vespa/searchlib/common/tunefileinfo.hpp b/searchlib/src/vespa/searchlib/common/tunefileinfo.hpp
new file mode 100644
index 00000000000..22d89d904d2
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/common/tunefileinfo.hpp
@@ -0,0 +1,35 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "tunefileinfo.h"
+#include <sys/mman.h>
+#include <fcntl.h>
+
+namespace search {
+
+template <typename TuneControlConfig, typename MMapConfig>
+void
+TuneFileRandRead::setFromConfig(const enum TuneControlConfig::Io & tuneControlConfig, const MMapConfig & mmapFlags) {
+ switch ( tuneControlConfig) {
+ case TuneControlConfig::NORMAL: _tuneControl = NORMAL; break;
+ case TuneControlConfig::DIRECTIO: _tuneControl = DIRECTIO; break;
+ case TuneControlConfig::MMAP: _tuneControl = MMAP; break;
+ default: _tuneControl = NORMAL; break;
+ }
+ for (size_t i(0), m(mmapFlags.options.size()); i < m; i++) {
+ switch (mmapFlags.options[i]) {
+ case MMapConfig::MLOCK: _mmapFlags |= MAP_LOCKED; break;
+ case MMapConfig::POPULATE: _mmapFlags |= MAP_POPULATE; break;
+ case MMapConfig::HUGETLB: _mmapFlags |= MAP_HUGETLB; break;
+ }
+ }
+ switch (mmapFlags.advise) {
+ case MMapConfig::NORMAL: setAdvise(POSIX_FADV_NORMAL); break;
+ case MMapConfig::RANDOM: setAdvise(POSIX_FADV_RANDOM); break;
+ case MMapConfig::SEQUENTIAL: setAdvise(POSIX_FADV_SEQUENTIAL); break;
+ }
+}
+
+}
+
diff --git a/searchlib/src/vespa/searchlib/datastore/array_store.hpp b/searchlib/src/vespa/searchlib/datastore/array_store.hpp
index 8478c22903f..cd45df90899 100644
--- a/searchlib/src/vespa/searchlib/datastore/array_store.hpp
+++ b/searchlib/src/vespa/searchlib/datastore/array_store.hpp
@@ -5,6 +5,7 @@
#include "array_store.h"
#include "datastore.hpp"
#include <atomic>
+#include <algorithm>
namespace search::datastore {
diff --git a/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp b/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp
index 5eca3719002..6e77b267818 100644
--- a/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp
+++ b/searchlib/src/vespa/searchlib/datastore/buffer_type.cpp
@@ -2,9 +2,15 @@
#include "buffer_type.h"
#include <algorithm>
+#include <cassert>
namespace search::datastore {
+void
+BufferTypeBase::CleanContext::extraBytesCleaned(uint64_t value) {
+ assert(_extraBytes >= value);
+ _extraBytes -= value;
+}
BufferTypeBase::BufferTypeBase(uint32_t clusterSize,
uint32_t minClusters,
uint32_t maxClusters,
diff --git a/searchlib/src/vespa/searchlib/datastore/buffer_type.h b/searchlib/src/vespa/searchlib/datastore/buffer_type.h
index 92dcbcc9e8d..6fc5c4ab288 100644
--- a/searchlib/src/vespa/searchlib/datastore/buffer_type.h
+++ b/searchlib/src/vespa/searchlib/datastore/buffer_type.h
@@ -2,9 +2,8 @@
#pragma once
-#include <cassert>
#include <cstdint>
-#include <sys/types.h>
+#include <cstddef>
namespace search::datastore {
@@ -33,10 +32,7 @@ public:
uint64_t &_extraBytes;
public:
CleanContext(uint64_t &extraBytes) : _extraBytes(extraBytes) {}
- void extraBytesCleaned(uint64_t value) {
- assert(_extraBytes >= value);
- _extraBytes -= value;
- }
+ void extraBytesCleaned(uint64_t value);
};
BufferTypeBase(const BufferTypeBase &rhs) = delete;
diff --git a/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp b/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp
index d344c79d50e..ba0c8e05d77 100644
--- a/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp
+++ b/searchlib/src/vespa/searchlib/datastore/datastorebase.cpp
@@ -2,6 +2,7 @@
#include "datastore.h"
#include <vespa/vespalib/util/array.hpp>
+#include <limits>
using vespalib::GenerationHeldBase;
diff --git a/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp b/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp
index b8ac5822692..7e479cb2905 100644
--- a/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp
@@ -5,6 +5,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/data/fileheader.h>
#include <vespa/fastos/file.h>
+#include <arpa/inet.h>
#include <vespa/log/log.h>
LOG_SETUP(".diskindex.fileheader");
@@ -25,19 +26,7 @@ FileHeader::FileHeader()
{
}
-
-FileHeader::~FileHeader()
-{
-}
-
-
-static inline uint32_t
-bswap(uint32_t val)
-{
- __asm__("bswap %0" : "=r" (val) : "0" (val));
- return val;
-}
-
+FileHeader::~FileHeader() {}
bool
FileHeader::taste(const vespalib::string &name,
@@ -62,10 +51,8 @@ FileHeader::taste(const vespalib::string &name,
} catch (vespalib::IllegalHeaderException &e) {
if (e.getMessage() != "Failed to read header info." &&
e.getMessage() != "Failed to verify magic bits.") {
- LOG(error,
- "FileHeader::tastGeneric(\"%s\") exception: %s",
- name.c_str(),
- e.getMessage().c_str());
+ LOG(error, "FileHeader::tastGeneric(\"%s\") exception: %s",
+ name.c_str(), e.getMessage().c_str());
}
file.Close();
return false;
@@ -82,9 +69,7 @@ FileHeader::taste(const vespalib::string &name,
} else if (endian == "little") {
_bigEndian = false;
} else {
- LOG(error,
- "Bad endian: %s",
- endian.c_str());
+ LOG(error, "Bad endian: %s", endian.c_str());
return false;
}
}
@@ -92,33 +77,23 @@ FileHeader::taste(const vespalib::string &name,
if (header.hasTag("frozen")) {
_completed = header.getTag("frozen").asInteger() != 0;
} else {
- LOG(error,
- "FileHeader::taste(\"%s\"): Missing frozen tag",
- name.c_str());
+ LOG(error, "FileHeader::taste(\"%s\"): Missing frozen tag", name.c_str());
return false;
}
if (header.hasTag("fileBitSize")) {
_fileBitSize = header.getTag("fileBitSize").asInteger();
if (_completed && _fileBitSize < 8 * _headerLen) {
- LOG(error,
- "FileHeader::taste(\"%s\"): "
- "fleBitSize(%" PRIu64 ") < 8 * headerLen(%u)",
- name.c_str(),
- _fileBitSize, _headerLen);
+ LOG(error, "FileHeader::taste(\"%s\"): fleBitSize(%" PRIu64 ") < 8 * headerLen(%u)",
+ name.c_str(), _fileBitSize, _headerLen);
return false;
}
if (_completed && _fileBitSize > 8 * fileSize) {
- LOG(error,
- "FileHeader::taste(\"%s\"): "
- "fleBitSize(%" PRIu64 ") > 8 * fileSize(%" PRIu64 ")",
- name.c_str(),
- _fileBitSize, fileSize);
+ LOG(error, "FileHeader::taste(\"%s\"): fleBitSize(%" PRIu64 ") > 8 * fileSize(%" PRIu64 ")",
+ name.c_str(), _fileBitSize, fileSize);
abort();
}
} else if (!_allowNoFileBitSize) {
- LOG(error,
- "FileHeader::taste(\"%s\"): Missing fileBitSize tag",
- name.c_str());
+ LOG(error, "FileHeader::taste(\"%s\"): Missing fileBitSize tag", name.c_str());
return false;
}
for (uint32_t i = 0; ;++i) {
@@ -132,10 +107,8 @@ FileHeader::taste(const vespalib::string &name,
return true;
}
-
bool
-FileHeader::taste(const vespalib::string &name,
- const TuneFileSeqWrite &tuneFileWrite)
+FileHeader::taste(const vespalib::string &name, const TuneFileSeqWrite &tuneFileWrite)
{
TuneFileSeqRead tuneFileRead;
if (tuneFileWrite.getWantDirectIO())
@@ -143,10 +116,8 @@ FileHeader::taste(const vespalib::string &name,
return taste(name, tuneFileRead);
}
-
bool
-FileHeader::taste(const vespalib::string &name,
- const TuneFileRandRead &tuneFileSearch)
+FileHeader::taste(const vespalib::string &name, const TuneFileRandRead &tuneFileSearch)
{
TuneFileSeqRead tuneFileRead;
if (tuneFileSearch.getWantDirectIO())
diff --git a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
index d96f70e2cd3..0bc11dc30a6 100644
--- a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
+++ b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp
@@ -3,6 +3,7 @@
#include "wordnummapper.h"
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/fastlib/io/bufferedfile.h>
+#include <cassert>
namespace search::diskindex {
diff --git a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.h b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.h
index 1d47d3c0b5a..8141a16c137 100644
--- a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.h
+++ b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.h
@@ -4,6 +4,7 @@
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/vespalib/util/array.h>
#include <vespa/vespalib/stllike/string.h>
+#include <limits>
namespace search::diskindex {
diff --git a/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp b/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp
index 2b7b49aa955..3bb1481969a 100644
--- a/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp
@@ -4,9 +4,9 @@
#include <vespa/vespalib/util/closuretask.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/data/databuffer.h>
+#include <algorithm>
-namespace search {
-namespace docstore {
+namespace search::docstore {
using document::BucketId;
using vespalib::makeTask;
@@ -85,4 +85,3 @@ StoreByBucket::drain(IWrite & drainer)
}
}
-}
diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
index c68aa00994f..22a16947b67 100644
--- a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/data/databuffer.h>
#include <vespa/document/util/compressor.h>
+#include <algorithm>
namespace search::docstore {
diff --git a/searchlib/src/vespa/searchlib/features/array_parser.h b/searchlib/src/vespa/searchlib/features/array_parser.h
index 406138c2a18..53247eabe2c 100644
--- a/searchlib/src/vespa/searchlib/features/array_parser.h
+++ b/searchlib/src/vespa/searchlib/features/array_parser.h
@@ -4,8 +4,7 @@
#include <vespa/vespalib/stllike/string.h>
-namespace search {
-namespace features {
+namespace search::features {
/**
* Utility for parsing a string representation of an array with values (numeric or string)
@@ -45,5 +44,4 @@ public:
static void parsePartial(const vespalib::string &input, OutputType &output);
};
-} // namespace features
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/features/array_parser.hpp b/searchlib/src/vespa/searchlib/features/array_parser.hpp
index 7462427cf74..613fa9ec13e 100644
--- a/searchlib/src/vespa/searchlib/features/array_parser.hpp
+++ b/searchlib/src/vespa/searchlib/features/array_parser.hpp
@@ -7,9 +7,9 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vector>
+#include <algorithm>
-namespace search {
-namespace features {
+namespace search::features {
template <typename OutputType>
void
@@ -92,5 +92,4 @@ ArrayParser::parsePartial(const vespalib::string &input, OutputType &output)
template void
ArrayParser::parse(const vespalib::string &input, std::vector<int> &);
-} // namespace features
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/features/utils.h b/searchlib/src/vespa/searchlib/features/utils.h
index 501dff17b41..57f4c83f6a9 100644
--- a/searchlib/src/vespa/searchlib/features/utils.h
+++ b/searchlib/src/vespa/searchlib/features/utils.h
@@ -9,6 +9,7 @@
#include <vespa/searchlib/fef/itermfielddata.h>
#include <vespa/searchlib/common/feature.h>
#include <vespa/vespalib/util/string_hash.h>
+#include <limits>
namespace search::features::util {
diff --git a/searchlib/src/vespa/searchlib/fef/indexproperties.cpp b/searchlib/src/vespa/searchlib/fef/indexproperties.cpp
index 4e971bcc484..493b49be0b0 100644
--- a/searchlib/src/vespa/searchlib/fef/indexproperties.cpp
+++ b/searchlib/src/vespa/searchlib/fef/indexproperties.cpp
@@ -3,6 +3,7 @@
#include "indexproperties.h"
#include "properties.h"
#include <vespa/vespalib/locale/c.h>
+#include <limits>
namespace search::fef::indexproperties {
diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.cpp b/searchlib/src/vespa/searchlib/fef/rank_program.cpp
index 431ff798c83..fa4582d46b7 100644
--- a/searchlib/src/vespa/searchlib/fef/rank_program.cpp
+++ b/searchlib/src/vespa/searchlib/fef/rank_program.cpp
@@ -3,6 +3,7 @@
#include "rank_program.h"
#include "featureoverrider.h"
#include <vespa/vespalib/locale/c.h>
+#include <algorithm>
using vespalib::Stash;
diff --git a/searchlib/src/vespa/searchlib/fef/simpletermdata.h b/searchlib/src/vespa/searchlib/fef/simpletermdata.h
index 2126d1c69ba..ef2d91d6e68 100644
--- a/searchlib/src/vespa/searchlib/fef/simpletermdata.h
+++ b/searchlib/src/vespa/searchlib/fef/simpletermdata.h
@@ -7,7 +7,7 @@
#include "simpletermfielddata.h"
#include <vespa/searchlib/query/weight.h>
#include <vector>
-#include <assert.h>
+#include <cassert>
namespace search {
namespace fef {
diff --git a/searchlib/src/vespa/searchlib/fef/termfieldmatchdata.cpp b/searchlib/src/vespa/searchlib/fef/termfieldmatchdata.cpp
index 7cfc6afa72d..7ff5dcf8b6c 100644
--- a/searchlib/src/vespa/searchlib/fef/termfieldmatchdata.cpp
+++ b/searchlib/src/vespa/searchlib/fef/termfieldmatchdata.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "termfieldmatchdata.h"
+#include <limits>
namespace search::fef {
diff --git a/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp b/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp
index a382a2cd6ee..97cb829e30c 100644
--- a/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp
+++ b/searchlib/src/vespa/searchlib/fef/termmatchdatamerger.cpp
@@ -1,9 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "termmatchdatamerger.h"
+#include <algorithm>
-namespace search {
-namespace fef {
+namespace search::fef {
TermMatchDataMerger::TermMatchDataMerger(const Inputs &allinputs,
const TermFieldMatchDataArray &outputs)
@@ -70,5 +70,4 @@ TermMatchDataMerger::merge(uint32_t docid,
}
}
-} // namespace fef
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/index/dictionaryfile.h b/searchlib/src/vespa/searchlib/index/dictionaryfile.h
index 574f5bcf56b..2f673c258f3 100644
--- a/searchlib/src/vespa/searchlib/index/dictionaryfile.h
+++ b/searchlib/src/vespa/searchlib/index/dictionaryfile.h
@@ -5,6 +5,7 @@
#include "postinglisthandle.h"
#include "postinglistcountfile.h"
#include <vespa/searchlib/common/tunefileinfo.h>
+#include <limits>
class FastOS_FileInterface;
diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp
index 23a4069d565..48207391eb1 100644
--- a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp
+++ b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp
@@ -4,8 +4,7 @@
#include "simple_index.h"
#include <vespa/searchlib/common/rcuvector.hpp>
-namespace search {
-namespace predicate {
+namespace search::predicate {
namespace simpleindex {
bool log_enabled();
@@ -219,7 +218,7 @@ void SimpleIndex<Posting, Key, DocId>::logVector(
if (!simpleindex::log_enabled()) return;
auto msg = vespalib::make_string(
"%s vector for key '%016" PRIx64 "' with length %zu. Contains %zu documents "
- "(doc id limit %" PRIu32", committed doc id limit %" PRIu32 ", ratio %f, "
+ "(doc id limit %u, committed doc id limit %u, ratio %f, "
"vector count %zu)",
action, key, vector_length, document_count, _limit_provider.getDocIdLimit(),
_limit_provider.getCommittedDocIdLimit(), ratio, _vector_posting_lists.size());
@@ -312,5 +311,4 @@ MemoryUsage SimpleIndex<Posting, Key, DocId>::getMemoryUsage() const {
return combined;
};
-} // namespace predicate
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/query/queryterm.cpp b/searchlib/src/vespa/searchlib/query/queryterm.cpp
index 70cbcd37ee0..d47d942dc10 100644
--- a/searchlib/src/vespa/searchlib/query/queryterm.cpp
+++ b/searchlib/src/vespa/searchlib/query/queryterm.cpp
@@ -1,4 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
#include "queryterm.h"
#include "base.h"
#include <vespa/vespalib/objects/visit.h>
@@ -6,6 +7,7 @@
#include <vespa/vespalib/util/classname.h>
#include <vespa/vespalib/locale/c.h>
#include <cmath>
+#include <limits>
namespace {
diff --git a/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp b/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp
index 0a520034e7f..c9ab167868a 100644
--- a/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/predicate_search.cpp
@@ -3,6 +3,7 @@
#include "predicate_search.h"
#include <vespa/searchlib/fef/termfieldmatchdata.h>
#include <vespa/searchlib/fef/termfieldmatchdataarray.h>
+#include <algorithm>
using search::fef::TermFieldMatchData;
using search::fef::TermFieldMatchDataArray;
diff --git a/searchlib/src/vespa/searchlib/queryeval/unpackinfo.cpp b/searchlib/src/vespa/searchlib/queryeval/unpackinfo.cpp
index 3a92169d43e..f8af7700640 100644
--- a/searchlib/src/vespa/searchlib/queryeval/unpackinfo.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/unpackinfo.cpp
@@ -3,9 +3,9 @@
#include "unpackinfo.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <cassert>
+#include <algorithm>
-namespace search {
-namespace queryeval {
+namespace search::queryeval {
UnpackInfo::UnpackInfo()
: _size(0)
@@ -101,5 +101,4 @@ UnpackInfo::toString() const
return os.str();
}
-} // namespace queryeval
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp
index 0fd5d3d8acb..cfaf8108672 100644
--- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp
+++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp
@@ -2,10 +2,8 @@
#include "fakeegcompr64filterocc.h"
#include "fpfactory.h"
-#include <vespa/searchlib/bitcompression/compression.h>
-#include <vespa/searchlib/bitcompression/posocccompression.h>
#include <vespa/searchlib/queryeval/iterators.h>
-#include <vespa/searchlib/fef/termfieldmatchdataarray.h>
+#include <vespa/vespalib/util/stringfmt.h>
using search::fef::TermFieldMatchData;
using search::fef::TermFieldMatchDataPosition;
diff --git a/searchlib/src/vespa/searchlib/test/initrange.cpp b/searchlib/src/vespa/searchlib/test/initrange.cpp
index 7d125ea5cdd..2292a8e775e 100644
--- a/searchlib/src/vespa/searchlib/test/initrange.cpp
+++ b/searchlib/src/vespa/searchlib/test/initrange.cpp
@@ -3,9 +3,9 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/searchlib/queryeval/emptysearch.h>
#include <vespa/searchlib/queryeval/truesearch.h>
+#include <algorithm>
-namespace search {
-namespace test {
+namespace search::test {
using namespace search::queryeval;
using std::make_unique;
@@ -184,4 +184,3 @@ InitRangeVerifier::searchStrict(SearchIterator & it, Range range)
}
}
-}
diff --git a/searchlib/src/vespa/searchlib/util/comprbuffer.cpp b/searchlib/src/vespa/searchlib/util/comprbuffer.cpp
index 4f90d682988..8c7f97db022 100644
--- a/searchlib/src/vespa/searchlib/util/comprbuffer.cpp
+++ b/searchlib/src/vespa/searchlib/util/comprbuffer.cpp
@@ -3,6 +3,7 @@
#include "comprbuffer.h"
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/fastos/file.h>
+#include <cassert>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/util/dirtraverse.cpp b/searchlib/src/vespa/searchlib/util/dirtraverse.cpp
index cb2dc39964b..57c7eee164f 100644
--- a/searchlib/src/vespa/searchlib/util/dirtraverse.cpp
+++ b/searchlib/src/vespa/searchlib/util/dirtraverse.cpp
@@ -5,6 +5,7 @@
#include "dirtraverse.h"
#include <vespa/fastos/file.h>
#include <cassert>
+#include <cstring>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/util/filealign.cpp b/searchlib/src/vespa/searchlib/util/filealign.cpp
index 175287b1487..15bef611714 100644
--- a/searchlib/src/vespa/searchlib/util/filealign.cpp
+++ b/searchlib/src/vespa/searchlib/util/filealign.cpp
@@ -3,6 +3,7 @@
#include "filealign.h"
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/fastos/file.h>
+#include <cassert>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/util/fileutil.cpp b/searchlib/src/vespa/searchlib/util/fileutil.cpp
index 2ac25b5ceb2..c1d34f66b0b 100644
--- a/searchlib/src/vespa/searchlib/util/fileutil.cpp
+++ b/searchlib/src/vespa/searchlib/util/fileutil.cpp
@@ -4,6 +4,9 @@
#include "filesizecalculator.h"
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/guard.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
#include <vespa/log/log.h>
LOG_SETUP(".searchlib.util.fileutil");
diff --git a/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp b/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp
index d4de9202c4a..f044c2782b5 100644
--- a/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp
+++ b/searchlib/src/vespa/searchlib/util/ioerrorhandler.cpp
@@ -4,6 +4,7 @@
#include "statebuf.h"
#include "statefile.h"
#include <vespa/fastos/file.h>
+#include <unistd.h>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.cpp b/searchlib/src/vespa/searchlib/util/rawbuf.cpp
index 77fbd556b83..7a23614df73 100644
--- a/searchlib/src/vespa/searchlib/util/rawbuf.cpp
+++ b/searchlib/src/vespa/searchlib/util/rawbuf.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/util/compress.h>
#include <vespa/fastos/file.h>
#include <cassert>
+#include <cstring>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/util/stringenum.cpp b/searchlib/src/vespa/searchlib/util/stringenum.cpp
index 7e855c5b9f3..2a29754443a 100644
--- a/searchlib/src/vespa/searchlib/util/stringenum.cpp
+++ b/searchlib/src/vespa/searchlib/util/stringenum.cpp
@@ -4,6 +4,7 @@
#include "stringenum.h"
#include <vespa/fastlib/io/bufferedfile.h>
+#include <cassert>
#include <vespa/log/log.h>
LOG_SETUP(".seachlib.util.stringenum");
diff --git a/slobrok/src/apps/slobrok/slobrok.cpp b/slobrok/src/apps/slobrok/slobrok.cpp
index 688181865be..277cc2f3a87 100644
--- a/slobrok/src/apps/slobrok/slobrok.cpp
+++ b/slobrok/src/apps/slobrok/slobrok.cpp
@@ -4,6 +4,7 @@
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/fastos/app.h>
+#include <csignal>
#include <vespa/log/log.h>
LOG_SETUP("vespa-slobrok");
diff --git a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp
index 1331c070612..d222a26c496 100644
--- a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp
+++ b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp
@@ -4,6 +4,8 @@
#include <vespa/vespalib/util/optimized.h>
#include <vespa/vespalib/util/allocinarray.h>
#include <vespa/vespalib/util/array.hpp>
+#include <csignal>
+
#include <vespa/log/log.h>
LOG_SETUP("allocinarray_benchmark");
diff --git a/staging_vespalib/src/tests/array/sort_benchmark.cpp b/staging_vespalib/src/tests/array/sort_benchmark.cpp
index f3650273644..1914e3ead9e 100644
--- a/staging_vespalib/src/tests/array/sort_benchmark.cpp
+++ b/staging_vespalib/src/tests/array/sort_benchmark.cpp
@@ -2,6 +2,9 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/rusage.h>
#include <vespa/vespalib/util/array.hpp>
+#include <csignal>
+#include <algorithm>
+
#include <vespa/log/log.h>
LOG_SETUP("sort_benchmark");
diff --git a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
index 09ef33413e0..e6f7bd21750 100644
--- a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
+++ b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/shutdownguard.h>
+#include <unistd.h>
+#include <sys/wait.h>
using namespace vespalib;
diff --git a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp
index 3b09b672c57..c8a9590eb96 100644
--- a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp
+++ b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp
@@ -4,6 +4,9 @@
#include <vespa/vespalib/util/process_memory_stats.h>
#include <iostream>
#include <fstream>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
using namespace vespalib;
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
index 1e474155ff4..403e1408747 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
@@ -1,5 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
#include "clock.h"
+#include <cassert>
using namespace fastos;
diff --git a/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp b/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp
index da608447d35..645ffea380d 100644
--- a/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/shutdownguard.cpp
@@ -1,11 +1,23 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "shutdownguard.h"
+#include <unistd.h>
+#include <sys/time.h>
#include <vespa/log/log.h>
LOG_SETUP(".vespalib.shutdownguard");
namespace vespalib {
+namespace {
+enum { STACK_SIZE = (1u << 16) };
+
+uint64_t getTimeInMillis() {
+ struct timeval mytime;
+ gettimeofday(&mytime, 0);
+ uint64_t mult = 1000;
+ return (mytime.tv_sec * mult) + (mytime.tv_usec / mult);
+}
+}
void ShutdownGuard::Run(FastOS_ThreadInterface *, void *)
{
while (_dieAtTime > getTimeInMillis()) {
@@ -31,5 +43,4 @@ ShutdownGuard::~ShutdownGuard()
_pool.Close();
}
-
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/shutdownguard.h b/staging_vespalib/src/vespa/vespalib/util/shutdownguard.h
index 2eeb06e1a03..5a9aad5d4d4 100644
--- a/staging_vespalib/src/vespa/vespalib/util/shutdownguard.h
+++ b/staging_vespalib/src/vespa/vespalib/util/shutdownguard.h
@@ -2,6 +2,7 @@
#pragma once
#include <vespa/fastos/thread.h>
+#include <cstdint>
namespace vespalib {
@@ -14,15 +15,6 @@ namespace vespalib {
**/
class ShutdownGuard : public FastOS_Runnable
{
- enum { STACK_SIZE = (1u << 16) };
-
- static uint64_t getTimeInMillis() {
- struct timeval mytime;
- gettimeofday(&mytime, 0);
- uint64_t mult = 1000;
- return (mytime.tv_sec * mult) + (mytime.tv_usec / mult);
- }
-
FastOS_ThreadPool _pool;
volatile uint64_t _dieAtTime;
diff --git a/storage/src/tests/distributor/bucketdatabasetest.cpp b/storage/src/tests/distributor/bucketdatabasetest.cpp
index ecfdc127fc2..c269389dd04 100644
--- a/storage/src/tests/distributor/bucketdatabasetest.cpp
+++ b/storage/src/tests/distributor/bucketdatabasetest.cpp
@@ -2,9 +2,9 @@
#include "bucketdatabasetest.h"
#include <vespa/storageframework/defaultimplementation/clock/realclock.h>
#include <iomanip>
+#include <algorithm>
-namespace storage {
-namespace distributor {
+namespace storage::distributor {
using document::BucketId;
@@ -544,4 +544,3 @@ BucketDatabaseTest::testChildCount()
}
}
-} // storage
diff --git a/storage/src/tests/distributor/simplemaintenancescannertest.cpp b/storage/src/tests/distributor/simplemaintenancescannertest.cpp
index 6846774872e..17f25e4532a 100644
--- a/storage/src/tests/distributor/simplemaintenancescannertest.cpp
+++ b/storage/src/tests/distributor/simplemaintenancescannertest.cpp
@@ -6,10 +6,9 @@
#include <vespa/storage/bucketdb/mapbucketdatabase.h>
#include <tests/distributor/maintenancemocks.h>
#include <vespa/vespalib/text/stringtokenizer.h>
+#include <algorithm>
-namespace storage {
-
-namespace distributor {
+namespace storage::distributor {
using document::BucketId;
typedef MaintenancePriority Priority;
@@ -211,4 +210,3 @@ SimpleMaintenanceScannerTest::perNodeMaintenanceStatsAreTracked()
}
}
-}
diff --git a/storage/src/tests/persistence/splitbitdetectortest.cpp b/storage/src/tests/persistence/splitbitdetectortest.cpp
index a4c6425f290..60f76c2df60 100644
--- a/storage/src/tests/persistence/splitbitdetectortest.cpp
+++ b/storage/src/tests/persistence/splitbitdetectortest.cpp
@@ -7,6 +7,7 @@
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/bucket/bucketidfactory.h>
+#include <algorithm>
namespace storage {
diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp
index d8761f9e84e..a0553625c8c 100644
--- a/storage/src/tests/storageserver/documentapiconvertertest.cpp
+++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp
@@ -13,6 +13,7 @@
#include <vespa/document/bucket/bucketidfactory.h>
#include <vespa/config/subscription/configuri.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <climits>
using document::DataType;
using document::DocIdString;
diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.cpp b/storage/src/vespa/storage/bucketdb/bucketinfo.cpp
index ba39b7062c0..bbc59de410a 100644
--- a/storage/src/vespa/storage/bucketdb/bucketinfo.cpp
+++ b/storage/src/vespa/storage/bucketdb/bucketinfo.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "bucketinfo.h"
#include <vespa/storage/storageutil/utils.h>
+#include <algorithm>
namespace storage {
diff --git a/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp b/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp
index 4512c6ddf4f..84b90ceedec 100644
--- a/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp
+++ b/storage/src/vespa/storage/bucketdb/bucketmanagermetrics.cpp
@@ -2,6 +2,7 @@
#include "bucketmanagermetrics.h"
#include <vespa/vespalib/util/exceptions.h>
+#include <cassert>
namespace storage {
diff --git a/storage/src/vespa/storage/distributor/operations/external/visitororder.h b/storage/src/vespa/storage/distributor/operations/external/visitororder.h
index 88fd242a454..69aefb1ec33 100644
--- a/storage/src/vespa/storage/distributor/operations/external/visitororder.h
+++ b/storage/src/vespa/storage/distributor/operations/external/visitororder.h
@@ -1,8 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-namespace storage {
+#include <climits>
-namespace distributor {
+namespace storage::distributor {
struct VisitorOrder {
const document::OrderingSpecification& _ordering;
@@ -78,6 +78,4 @@ struct VisitorOrder {
}
-}
-
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
index f17792302d1..536c9d764be 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/joinoperation.cpp
@@ -2,7 +2,7 @@
#include "joinoperation.h"
#include <vespa/storageapi/message/bucketsplitting.h>
-
+#include <climits>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".distributor.operation.idealstate.join");
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergelimiter.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergelimiter.cpp
index e7d4d32e0e4..13931c73e3c 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergelimiter.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergelimiter.cpp
@@ -1,7 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/storage/distributor/operations/idealstate/mergelimiter.h>
+#include "mergelimiter.h"
#include <cassert>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".distributor.operations.merge.limiter");
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
index 88f3a238a78..5c69c4576f0 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/splitoperation.cpp
@@ -4,9 +4,9 @@
#include <vespa/storage/distributor/idealstatemanager.h>
#include <vespa/storage/common/bucketoperationlogger.h>
#include <vespa/storageapi/message/bucketsplitting.h>
+#include <climits>
#include <vespa/log/bufferedlogger.h>
-
LOG_SETUP(".distributor.operation.idealstate.split");
using namespace storage::distributor;
diff --git a/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h b/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h
index eb13fe3ac8d..2f4a3e0117a 100644
--- a/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h
+++ b/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h
@@ -5,9 +5,9 @@
#include "operationtargetresolver.h"
#include <vespa/storage/bucketdb/bucketdatabase.h>
#include <vespa/vdslib/distribution/idealnodecalculator.h>
+#include <algorithm>
-namespace storage {
-namespace distributor {
+namespace storage::distributor {
struct BucketInstance : public vespalib::AsciiPrintable {
document::BucketId _bucket;
@@ -106,5 +106,4 @@ public:
}
};
-} // distributor
-} // storage
+}
diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp
index ac08e176a97..2039c1b5177 100644
--- a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp
+++ b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp
@@ -5,6 +5,7 @@
#include <vespa/storageframework/defaultimplementation/clock/realclock.h>
#include <vespa/storage/common/bucketoperationlogger.h>
#include <vespa/vespalib/util/xmlstream.hpp>
+#include <climits>
#include <vespa/log/log.h>
LOG_SETUP(".pendingclusterstate");
diff --git a/storage/src/vespa/storage/frameworkimpl/memory/memorystatusviewer.cpp b/storage/src/vespa/storage/frameworkimpl/memory/memorystatusviewer.cpp
index 4143082623f..dd07a61f27b 100644
--- a/storage/src/vespa/storage/frameworkimpl/memory/memorystatusviewer.cpp
+++ b/storage/src/vespa/storage/frameworkimpl/memory/memorystatusviewer.cpp
@@ -6,7 +6,7 @@
#include <vespa/storage/storageutil/piechart.h>
#include <vespa/metrics/metricmanager.h>
#include <vespa/storageapi/messageapi/storagemessage.h>
-#include <sstream>
+#include <algorithm>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".memory.status.viewer");
diff --git a/storage/src/vespa/storage/persistence/bucketprocessor.cpp b/storage/src/vespa/storage/persistence/bucketprocessor.cpp
index fd9b51a90c7..c512cdd461a 100644
--- a/storage/src/vespa/storage/persistence/bucketprocessor.cpp
+++ b/storage/src/vespa/storage/persistence/bucketprocessor.cpp
@@ -3,6 +3,7 @@
#include "bucketprocessor.h"
#include <vespa/document/fieldset/fieldsets.h>
#include <vespa/vespalib/stllike/asciistream.h>
+#include <cassert>
namespace storage {
diff --git a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
index 24cf7059ff7..7735204c92b 100644
--- a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
@@ -3,6 +3,7 @@
#include "modifiedbucketchecker.h"
#include "filestormanager.h"
#include <vespa/config/common/exceptions.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".persistence.filestor.modifiedbucketchecker");
diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp
index d84dc59bf95..37fc36c820a 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.cpp
+++ b/storage/src/vespa/storage/persistence/mergehandler.cpp
@@ -8,8 +8,9 @@
#include <vespa/storage/common/bucketoperationlogger.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exceptions.h>
-#include <vespa/log/log.h>
+#include <algorithm>
+#include <vespa/log/log.h>
LOG_SETUP(".persistence.mergehandler");
namespace storage {
diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp
index 7dc717cabed..fa8231d5353 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.cpp
+++ b/storage/src/vespa/storage/persistence/persistencethread.cpp
@@ -11,6 +11,7 @@
#include <vespa/document/fieldset/fieldsetrepo.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/util/exceptions.h>
+#include <algorithm>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".persistence.thread");
diff --git a/storage/src/vespa/storage/persistence/splitbitdetector.cpp b/storage/src/vespa/storage/persistence/splitbitdetector.cpp
index d8bf01775c8..1133c470bb0 100644
--- a/storage/src/vespa/storage/persistence/splitbitdetector.cpp
+++ b/storage/src/vespa/storage/persistence/splitbitdetector.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/bucket/bucketidfactory.h>
#include <vespa/document/base/documentid.h>
#include <sstream>
+#include <cassert>
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".persistence.split.bitdetector");
diff --git a/storage/src/vespa/storage/storageserver/distributornode.h b/storage/src/vespa/storage/storageserver/distributornode.h
index 47b14470639..34f2dbb42a7 100644
--- a/storage/src/vespa/storage/storageserver/distributornode.h
+++ b/storage/src/vespa/storage/storageserver/distributornode.h
@@ -24,7 +24,7 @@ class DistributorNode
uint64_t _lastUniqueTimestampRequested;
uint32_t _uniqueTimestampCounter;
bool _manageActiveBucketCopies;
- StorageLink::UP _retrievedCommunicationManager;
+ std::unique_ptr<StorageLink> _retrievedCommunicationManager;
public:
typedef std::unique_ptr<DistributorNode> UP;
@@ -38,7 +38,7 @@ public:
DistributorNodeContext&,
ApplicationGenerationFetcher& generationFetcher,
NeedActiveState,
- StorageLink::UP communicationManager = StorageLink::UP());
+ std::unique_ptr<StorageLink> communicationManager);
~DistributorNode();
const lib::NodeType& getNodeType() const override { return lib::NodeType::DISTRIBUTOR; }
@@ -49,7 +49,7 @@ public:
private:
void initializeNodeSpecific() override;
- StorageLink::UP createChain() override;
+ std::unique_ptr<StorageLink> createChain() override;
api::Timestamp getUniqueTimestamp() override;
/**
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.cpp b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
index 85eb71f419e..d9a14fc7bb0 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.cpp
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
@@ -7,9 +7,9 @@
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <algorithm>
#include <vespa/log/log.h>
-
LOG_SETUP(".mergethrottler");
namespace storage {
diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.h b/storage/src/vespa/storage/storageserver/servicelayernode.h
index 4e0de3bbf24..848cc1d1475 100644
--- a/storage/src/vespa/storage/storageserver/servicelayernode.h
+++ b/storage/src/vespa/storage/storageserver/servicelayernode.h
@@ -11,6 +11,8 @@
#include "applicationgenerationfetcher.h"
#include "servicelayernodecontext.h"
#include "storagenode.h"
+#include <vespa/storage/visiting/visitormessagesessionfactory.h>
+#include <vespa/storage/common/visitorfactory.h>
#include <vespa/storage/bucketdb/minimumusedbitstracker.h>
#include <vespa/persistence/spi/persistenceprovider.h>
#include <vespa/config-stor-devices.h>
@@ -65,7 +67,7 @@ private:
void configure(std::unique_ptr<vespa::config::storage::StorDevicesConfig> config) override;
VisitorMessageSession::UP createSession(Visitor&, VisitorThread&) override;
documentapi::Priority::Value toDocumentPriority(uint8_t storagePriority) const override;
- StorageLink::UP createChain() override;
+ std::unique_ptr<StorageLink> createChain() override;
void removeConfigSubscriptions() override;
};
diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp
index ac386674032..27f98b478ce 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.cpp
+++ b/storage/src/vespa/storage/storageserver/storagenode.cpp
@@ -1,37 +1,22 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "storagenode.h"
-#include "bouncer.h"
-#include "bucketintegritychecker.h"
#include "communicationmanager.h"
-#include "mergethrottler.h"
-#include "opslogger.h"
#include "statemanager.h"
#include "statereporter.h"
#include "storagemetricsset.h"
+#include "storagenodecontext.h"
-#include <vespa/storage/bucketdb/bucketmanager.h>
-#include <vespa/storage/bucketdb/storagebucketdbinitializer.h>
-#include <vespa/storage/bucketmover/bucketmover.h>
-#include <vespa/storageframework/storageframework.h>
-#include <vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.h>
+#include <vespa/storage/frameworkimpl/memory/memorystatusviewer.h>
+#include <vespa/storage/frameworkimpl/status/statuswebserver.h>
+#include <vespa/storage/frameworkimpl/thread/deadlockdetector.h>
#include <vespa/storage/common/statusmetricconsumer.h>
-#include <vespa/storage/common/hostreporter/hostinfo.h>
-#include <vespa/storage/distributor/bucketdbupdater.h>
-#include <vespa/storage/distributor/distributor.h>
-#include <vespa/storage/distributor/pendingmessagetracker.h>
-#include <vespa/storage/persistence/filestorage/filestormanager.h>
-#include <vespa/storage/storageutil/functor.h>
-#include <vespa/storage/storageutil/log.h>
-#include <vespa/storage/visiting/visitormanager.h>
-#include <vespa/storage/visiting/messagebusvisitormessagesession.h>
-#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/metrics/metricmanager.h>
-#include <fstream>
-#include <sstream>
+#include <fcntl.h>
+#include <vespa/log/log.h>
LOG_SETUP(".node.server");
namespace storage {
diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h
index 530920b7578..4c4918e6977 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.h
+++ b/storage/src/vespa/storage/storageserver/storagenode.h
@@ -12,35 +12,23 @@
#pragma once
-#include "storagemetricsset.h"
-#include "storagenodecontext.h"
-#include "applicationgenerationfetcher.h"
-#include <vespa/document/bucket/bucketidfactory.h>
-#include <vespa/storage/config/config-stor-server.h>
-
-#include <vespa/config/helper/legacysubscriber.h>
-#include <vespa/document/bucket/bucketid.h>
-#include <vespa/document/config/config-documenttypes.h>
-#include <vespa/documentapi/loadtypes/loadtypeset.h>
-#include <vespa/metrics/metrics.h>
-#include <vespa/storage/bucketdb/storbucketdb.h>
+#include <vespa/storage/storageutil/resumeguard.h>
#include <vespa/storage/common/doneinitializehandler.h>
-#include <vespa/storage/common/storagelink.h>
-#include <vespa/storage/common/visitorfactory.h>
-#include <vespa/storage/config/config-stor-prioritymapping.h>
-#include <vespa/storageframework/defaultimplementation/clock/realclock.h>
-#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h>
-#include <vespa/storage/frameworkimpl/status/statuswebserver.h>
-#include <vespa/storage/frameworkimpl/thread/deadlockdetector.h>
-#include <vespa/storageframework/defaultimplementation/memory/memorymanager.h>
-#include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h>
-#include <vespa/storage/frameworkimpl/memory/memorystatusviewer.h>
#include <vespa/storageframework/generic/metric/metricupdatehook.h>
-#include <vespa/storage/visiting/visitormessagesessionfactory.h>
-#include <vespa/storage/storageutil/resumeguard.h>
+#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h>
+
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/ifetchercallback.h>
+#include <vespa/config/helper/configfetcher.h>
+
+#include <vespa/storage/config/config-stor-prioritymapping.h>
+#include <vespa/storage/config/config-stor-server.h>
+#include <vespa/document/config/config-documenttypes.h>
#include <vespa/config-upgrading.h>
#include <vespa/config-stor-distribution.h>
+namespace document { class DocumentTypeRepo; }
+
namespace storage {
class StatusMetricConsumer;
@@ -49,6 +37,17 @@ class CommunicationManager;
class FileStorManager;
class HostInfo;
class StateManager;
+class MemoryStatusViewer;
+class StatusWebServer;
+class StorageLink;
+class DeadLockDetector;
+class StorageMetricSet;
+class StorageNodeContext;
+class ApplicationGenerationFetcher;
+class StorageComponent;
+
+namespace lib { class NodeType; }
+
class StorageNode : private config::IFetcherCallback<vespa::config::content::core::StorServerConfig>,
private config::IFetcherCallback<vespa::config::content::StorDistributionConfig>,
@@ -82,7 +81,7 @@ public:
void updateMetrics(const MetricLockGuard & guard) override;
/** Updates the document type repo. */
- void setNewDocumentRepo(const document::DocumentTypeRepo::SP& repo);
+ void setNewDocumentRepo(const std::shared_ptr<document::DocumentTypeRepo>& repo);
/**
* Pauses the persistence processing. While the returned ResumeGuard
@@ -154,7 +153,7 @@ protected:
std::unique_ptr<vespa::config::content::StorDistributionConfig> _newDistributionConfig;
std::unique_ptr<vespa::config::content::core::StorPrioritymappingConfig> _newPriorityConfig;
std::unique_ptr<document::DocumenttypesConfig> _newDoctypesConfig;
- StorageComponent::UP _component;
+ std::unique_ptr<StorageComponent> _component;
config::ConfigUri _configUri;
CommunicationManager* _communicationManager;
@@ -170,7 +169,7 @@ protected:
void initialize();
virtual void subscribeToConfigs();
virtual void initializeNodeSpecific() = 0;
- virtual StorageLink::UP createChain() = 0;
+ virtual std::unique_ptr<StorageLink> createChain() = 0;
virtual void handleLiveConfigUpdate();
void shutdown();
virtual void removeConfigSubscriptions();
diff --git a/storage/src/vespa/storage/storageutil/resumeguard.h b/storage/src/vespa/storage/storageutil/resumeguard.h
index f6003000205..a6fdcbbe506 100644
--- a/storage/src/vespa/storage/storageutil/resumeguard.h
+++ b/storage/src/vespa/storage/storageutil/resumeguard.h
@@ -13,7 +13,7 @@ public:
};
ResumeGuard()
- : _cb(NULL)
+ : _cb(nullptr)
{}
ResumeGuard(Callback& cb)
@@ -21,7 +21,7 @@ public:
ResumeGuard(const ResumeGuard& other) {
_cb = other._cb;
- const_cast<ResumeGuard&>(other)._cb = NULL;
+ const_cast<ResumeGuard&>(other)._cb = nullptr;
}
~ResumeGuard() {
diff --git a/storage/src/vespa/storage/tools/generatedistributionbits.cpp b/storage/src/vespa/storage/tools/generatedistributionbits.cpp
index 7939f261a5c..73f11b39e67 100644
--- a/storage/src/vespa/storage/tools/generatedistributionbits.cpp
+++ b/storage/src/vespa/storage/tools/generatedistributionbits.cpp
@@ -8,6 +8,7 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <iomanip>
#include <iostream>
+#include <algorithm>
#include <vespa/config-stor-distribution.h>
namespace storage {
diff --git a/storage/src/vespa/storage/tools/throttlingsim.cpp b/storage/src/vespa/storage/tools/throttlingsim.cpp
index 26fa4f94875..cd3c0c1cea4 100644
--- a/storage/src/vespa/storage/tools/throttlingsim.cpp
+++ b/storage/src/vespa/storage/tools/throttlingsim.cpp
@@ -3,6 +3,7 @@
#include "throttlingsim.h"
#include <algorithm>
#include <vespa/vespalib/util/stringfmt.h>
+#include <unistd.h>
bool Receiver::enqueue(const Message& msg) {
vespalib::MonitorGuard lock(sync);
diff --git a/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h b/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h
index fb090fc2860..5515595a1c5 100644
--- a/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h
+++ b/storage/src/vespa/storage/visiting/visitormessagesessionfactory.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/storage/visiting/visitormessagesession.h>
+#include "visitormessagesession.h"
namespace storage {
diff --git a/storageapi/src/vespa/storageapi/message/batch.cpp b/storageapi/src/vespa/storageapi/message/batch.cpp
index cd757ac38e9..7de0ec098ac 100644
--- a/storageapi/src/vespa/storageapi/message/batch.cpp
+++ b/storageapi/src/vespa/storageapi/message/batch.cpp
@@ -3,6 +3,7 @@
#include "batch.h"
#include <vespa/document/bucket/bucketidfactory.h>
#include <ostream>
+#include <algorithm>
using namespace storage::api;
diff --git a/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp b/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp
index 5c82e737bb9..3cbc0a3ab03 100644
--- a/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp
+++ b/storageapi/src/vespa/storageapi/message/bucketsplitting.cpp
@@ -2,9 +2,9 @@
#include "bucketsplitting.h"
#include <ostream>
+#include <limits>
-namespace storage {
-namespace api {
+namespace storage::api {
IMPLEMENT_COMMAND(SplitBucketCommand, SplitBucketReply)
IMPLEMENT_REPLY(SplitBucketReply)
@@ -131,6 +131,4 @@ JoinBucketsReply::print(std::ostream& out, bool verbose,
}
}
-} // api
-} // storage
-
+}
diff --git a/storageapi/src/vespa/storageapi/message/visitor.cpp b/storageapi/src/vespa/storageapi/message/visitor.cpp
index 8da8f208f3d..851896f4d55 100644
--- a/storageapi/src/vespa/storageapi/message/visitor.cpp
+++ b/storageapi/src/vespa/storageapi/message/visitor.cpp
@@ -2,9 +2,9 @@
#include "visitor.h"
#include <vespa/vespalib/util/array.hpp>
+#include <climits>
-namespace storage {
-namespace api {
+namespace storage::api {
IMPLEMENT_COMMAND(CreateVisitorCommand, CreateVisitorReply)
IMPLEMENT_REPLY(CreateVisitorReply)
@@ -230,5 +230,4 @@ operator<<(std::ostream& out, const VisitorInfoCommand::BucketTimestampPair& pai
return out << pair.bucketId << " - " << pair.timestamp;
}
-} // api
-} // storage
+}
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
index 87659b55250..7319a1e7d57 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
@@ -31,9 +31,8 @@ namespace metrics {
}
-namespace storage {
-namespace framework {
-namespace defaultimplementation {
+
+namespace storage::framework::defaultimplementation {
struct ShutdownListener {
virtual ~ShutdownListener() {}
@@ -89,8 +88,4 @@ public:
};
-} // defaultimplementation
-} // framework
-} // storage
-
-
+}
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp
index 54da9be7e31..2351edd267c 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/memorystate.cpp
@@ -84,8 +84,8 @@ MemoryState::addToEntry(const MemoryAllocationType& type, uint64_t memory,
AllocationResult result, bool forcedAllocation,
uint64_t allocationCounts)
{
- LOG(spam, "Allocating memory %s - %" PRIu64 " bytes at priority %u. "
- "Count %" PRIu64 ".",
+ LOG(spam, "Allocating memory %s - %lu bytes at priority %u. "
+ "Count %lu.",
type.getName().c_str(), memory, priority, allocationCounts);
PriorityMap& map(_current._allocations[&type]);
Entry& e(map[priority]);
@@ -110,7 +110,7 @@ MemoryState::addToEntry(const MemoryAllocationType& type, uint64_t memory,
if (_current._usedWithoutCache
> _max._usedWithoutCache + _minJumpToUpdateMax)
{
- LOG(spam, "Updating max to current %" PRIu64 " bytes of memory used",
+ LOG(spam, "Updating max to current %lu bytes of memory used",
_current._usedWithoutCache);
_max = _current;
_max._timeTaken = _clock->getTimeInSeconds();
@@ -122,8 +122,8 @@ MemoryState::removeFromEntry(const MemoryAllocationType& type, uint64_t memory,
uint8_t priority,
uint64_t allocationCounts)
{
- LOG(spam, "Freeing memory %s - %" PRIu64 " bytes at priority %u. "
- "Count %" PRIu64 ".",
+ LOG(spam, "Freeing memory %s - %lu bytes at priority %u. "
+ "Count %lu.",
type.getName().c_str(), memory, priority, allocationCounts);
PriorityMap& map(_current._allocations[&type]);
Entry& e(map[priority]);
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp
index 681ee10df0f..51bb7ba5019 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/prioritymemorylogic.cpp
@@ -5,14 +5,12 @@
#include <vespa/log/log.h>
LOG_SETUP(".memory.logic.priority");
-namespace storage {
-namespace framework {
-namespace defaultimplementation {
+namespace storage::framework::defaultimplementation {
PriorityMemoryLogic::PriorityMemoryLogic(Clock& c, uint64_t maxMem)
: SimpleMemoryLogic(c, maxMem)
{
- LOG(debug, "Setup priority memory logic with max memory of %" PRIu64 " bytes", maxMem);
+ LOG(debug, "Setup priority memory logic with max memory of %lu bytes", maxMem);
}
float
@@ -29,6 +27,4 @@ PriorityMemoryLogic::print(std::ostream& out, bool verbose,
SimpleMemoryLogic::print(out, verbose, indent);
}
-} // defaultimplementation
-} // framework
-} // storage
+}
diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp
index 1fb4adc6618..b9ccb2d4d9f 100644
--- a/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp
+++ b/storageframework/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp
@@ -82,9 +82,9 @@ ThreadImpl::registerTick(CycleType cycleType, MilliSecTime time)
if (data._lastTickMs == 0) { return; }
if (previousTickMs > nowMs) {
- LOGBP(warning, "Thread is registering tick at time %" PRIu64 ", but "
- "last time it registered a tick, the time was %"
- PRIu64 ". Assuming clock has been adjusted backwards",
+ LOGBP(warning, "Thread is registering tick at time %lu, but "
+ "last time it registered a tick, the time was %lu"
+ ". Assuming clock has been adjusted backwards",
nowMs, previousTickMs);
return;
}
diff --git a/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h b/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h
index 7d0ae594e5f..7b05bbe8040 100644
--- a/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h
+++ b/storageframework/src/vespa/storageframework/generic/metric/metricregistrator.h
@@ -10,22 +10,24 @@
*/
#pragma once
-#include <vespa/vespalib/stllike/string.h>
+#include <vespa/storageframework/generic/clock/time.h>
#include <vespa/vespalib/util/sync.h>
-namespace storage {
-namespace framework {
+namespace metrics {
+ class Metric;
+}
+
+namespace storage::framework {
+
+class MetricUpdateHook;
struct MetricRegistrator {
virtual ~MetricRegistrator() {}
virtual void registerMetric(metrics::Metric&) = 0;
- virtual void registerUpdateHook(vespalib::stringref name,
- MetricUpdateHook& hook,
- SecondTime period) = 0;
+ virtual void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, SecondTime period) = 0;
virtual vespalib::MonitorGuard getMetricManagerLock() = 0;
};
-} // framework
-} // storage
+}
diff --git a/storageserver/src/apps/storaged/storage.cpp b/storageserver/src/apps/storaged/storage.cpp
index f1a22d93d41..1f3109381fd 100644
--- a/storageserver/src/apps/storaged/storage.cpp
+++ b/storageserver/src/apps/storaged/storage.cpp
@@ -11,7 +11,7 @@
* application, but as little as possible else.
*/
-#include <signal.h>
+#include <csignal>
#include <vespa/persistence/spi/exceptions.h>
#include <vespa/storage/storageutil/utils.h>
#include <vespa/storageserver/app/distributorprocess.h>
diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp
index d1ef15b7298..2564c500cbc 100644
--- a/storageserver/src/tests/storageservertest.cpp
+++ b/storageserver/src/tests/storageservertest.cpp
@@ -24,6 +24,8 @@
#include <vespa/storageserver/app/distributorprocess.h>
#include <vespa/storageserver/app/memfileservicelayerprocess.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <sys/time.h>
+
#include <vespa/log/log.h>
LOG_SETUP(".storageservertest");
diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp
index 05b61944a33..6ef391fa56a 100644
--- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp
+++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/storageserver/app/distributorprocess.h>
+#include "distributorprocess.h"
+#include <vespa/storage/common/storagelink.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/log/log.h>
@@ -49,12 +50,10 @@ DistributorProcess::updateConfig()
{
Process::updateConfig();
if (_distributorConfigHandler->isChanged()) {
- _node->handleConfigChange(
- *_distributorConfigHandler->getConfig());
+ _node->handleConfigChange(*_distributorConfigHandler->getConfig());
}
if (_visitDispatcherConfigHandler->isChanged()) {
- _node->handleConfigChange(
- *_visitDispatcherConfigHandler->getConfig());
+ _node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig());
}
}
@@ -76,11 +75,9 @@ DistributorProcess::configUpdated()
void
DistributorProcess::createNode()
{
- _node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag));
- _node->handleConfigChange(
- *_distributorConfigHandler->getConfig());
- _node->handleConfigChange(
- *_visitDispatcherConfigHandler->getConfig());
+ _node.reset(new DistributorNode(_configUri, _context, *this, _activeFlag, StorageLink::UP()));
+ _node->handleConfigChange(*_distributorConfigHandler->getConfig());
+ _node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig());
}
} // storage
diff --git a/storageserver/src/vespa/storageserver/app/process.cpp b/storageserver/src/vespa/storageserver/app/process.cpp
index ea8ae4da485..a604490ba85 100644
--- a/storageserver/src/vespa/storageserver/app/process.cpp
+++ b/storageserver/src/vespa/storageserver/app/process.cpp
@@ -2,6 +2,7 @@
#include "process.h"
#include <vespa/storage/storageserver/storagenode.h>
+#include <vespa/storage/storageserver/storagenodecontext.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/log/log.h>
@@ -19,11 +20,9 @@ Process::setupConfig(uint64_t subscribeTimeout)
{
_documentHandler = _configSubscriber.subscribe<document::DocumenttypesConfig>(_configUri.getConfigId(), subscribeTimeout);
if (!_configSubscriber.nextConfig()) {
- throw vespalib::TimeoutException(
- "Could not subscribe to document config within timeout");
+ throw vespalib::TimeoutException("Could not subscribe to document config within timeout");
}
- _repos.push_back(document::DocumentTypeRepo::SP(
- new document::DocumentTypeRepo(*_documentHandler->getConfig())));
+ _repos.push_back(std::make_shared<document::DocumentTypeRepo>(*_documentHandler->getConfig()));
getContext().getComponentRegister().setDocumentTypeRepo(_repos.back());
}
@@ -42,9 +41,7 @@ void
Process::updateConfig()
{
if (_documentHandler->isChanged()) {
- _repos.push_back(document::DocumentTypeRepo::SP(
- new document::DocumentTypeRepo(
- *_documentHandler->getConfig())));
+ _repos.push_back(std::make_shared<document::DocumentTypeRepo>(*_documentHandler->getConfig()));
getNode().setNewDocumentRepo(_repos.back());
}
}
diff --git a/streamingvisitors/src/vespa/searchvisitor/hitcollector.cpp b/streamingvisitors/src/vespa/searchvisitor/hitcollector.cpp
index dd09ed45b8b..a9b09cd7089 100644
--- a/streamingvisitors/src/vespa/searchvisitor/hitcollector.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/hitcollector.cpp
@@ -3,6 +3,7 @@
#include "hitcollector.h"
#include <vespa/searchlib/fef/feature_resolver.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".searchvisitor.hitcollector");
diff --git a/vdslib/src/tests/container/documentlisttest.cpp b/vdslib/src/tests/container/documentlisttest.cpp
index 17fc613c8ab..884241cc483 100644
--- a/vdslib/src/tests/container/documentlisttest.cpp
+++ b/vdslib/src/tests/container/documentlisttest.cpp
@@ -9,6 +9,8 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <cppunit/extensions/HelperMacros.h>
+#include <fcntl.h>
+#include <unistd.h>
using document::DocumentTypeRepo;
using document::readDocumenttypesConfig;
diff --git a/vdslib/src/vespa/vdslib/container/documentlist.cpp b/vdslib/src/vespa/vdslib/container/documentlist.cpp
index 477148f89c4..18f7e138260 100644
--- a/vdslib/src/vespa/vdslib/container/documentlist.cpp
+++ b/vdslib/src/vespa/vdslib/container/documentlist.cpp
@@ -6,6 +6,7 @@
#include <vespa/document/util/serializableexceptions.h>
#include <vespa/document/update/documentupdate.h>
#include <vespa/document/datatype/documenttype.h>
+#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".vdslib.container.documentlist");
diff --git a/vdslib/src/vespa/vdslib/container/documentsummary.cpp b/vdslib/src/vespa/vdslib/container/documentsummary.cpp
index 7fb75e8ca26..bc8a0473ab3 100644
--- a/vdslib/src/vespa/vdslib/container/documentsummary.cpp
+++ b/vdslib/src/vespa/vdslib/container/documentsummary.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "documentsummary.h"
+#include <algorithm>
namespace vdslib {
diff --git a/vdslib/src/vespa/vdslib/container/searchresult.cpp b/vdslib/src/vespa/vdslib/container/searchresult.cpp
index 0e2e0256547..73b19a2f8a2 100644
--- a/vdslib/src/vespa/vdslib/container/searchresult.cpp
+++ b/vdslib/src/vespa/vdslib/container/searchresult.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "searchresult.h"
+#include <algorithm>
namespace vdslib {
diff --git a/vdslib/src/vespa/vdslib/distribution/group.cpp b/vdslib/src/vespa/vdslib/distribution/group.cpp
index de2ca83b0aa..91e27715911 100644
--- a/vdslib/src/vespa/vdslib/distribution/group.cpp
+++ b/vdslib/src/vespa/vdslib/distribution/group.cpp
@@ -7,6 +7,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <ostream>
#include <cassert>
+#include <algorithm>
namespace storage::lib {
diff --git a/vdslib/src/vespa/vdslib/thread/taskscheduler.cpp b/vdslib/src/vespa/vdslib/thread/taskscheduler.cpp
index a0fc63da0be..08c7b80e406 100644
--- a/vdslib/src/vespa/vdslib/thread/taskscheduler.cpp
+++ b/vdslib/src/vespa/vdslib/thread/taskscheduler.cpp
@@ -3,6 +3,7 @@
#include "taskscheduler.h"
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
+#include <sys/time.h>
namespace vdslib {
diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp b/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp
index bc640370799..7406e17430d 100644
--- a/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp
+++ b/vespaclient/src/vespa/vespaclient/spoolmaster/application.cpp
@@ -5,6 +5,8 @@
#include <algorithm>
#include <dirent.h>
#include <unistd.h>
+#include <cstring>
+#include <sys/stat.h>
#include "application.h"
diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp
index dbec559e5da..99c91216d20 100644
--- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp
+++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp
@@ -13,6 +13,7 @@
#include <vespa/fastos/app.h>
#include <sstream>
#include <iostream>
+#include <sys/time.h>
#include <vespa/log/log.h>
LOG_SETUP("vdsstatetool");
diff --git a/vespalib/src/tests/alloc/allocate_and_core.cpp b/vespalib/src/tests/alloc/allocate_and_core.cpp
index faf44aa2669..7b72f35ac0e 100644
--- a/vespalib/src/tests/alloc/allocate_and_core.cpp
+++ b/vespalib/src/tests/alloc/allocate_and_core.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/alloc.h>
#include <string.h>
-#include <assert.h>
+#include <cassert>
using namespace vespalib::alloc;
diff --git a/vespalib/src/tests/exception_classes/mmap.cpp b/vespalib/src/tests/exception_classes/mmap.cpp
index 3ba286f2a35..2d4c4796473 100644
--- a/vespalib/src/tests/exception_classes/mmap.cpp
+++ b/vespalib/src/tests/exception_classes/mmap.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/alloc.h>
#include <vector>
-#include <assert.h>
+#include <cassert>
#include <string.h>
#include <sys/resource.h>
diff --git a/vespalib/src/tests/executor/stress_test.cpp b/vespalib/src/tests/executor/stress_test.cpp
index aa5d9d53955..5c7620afb14 100644
--- a/vespalib/src/tests/executor/stress_test.cpp
+++ b/vespalib/src/tests/executor/stress_test.cpp
@@ -2,12 +2,11 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/executor.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/locale/c.h>
-#include <cmath>
using namespace vespalib;
+using namespace std::literals;
uint32_t doStuff(uint32_t input) {
char buf[128];
@@ -131,7 +130,7 @@ Test::Main()
Executor::Task::UP t(new CPUTask(taskSize, result));
t = executor.execute(std::move(t));
while (t.get() != 0) {
- FastOS_Thread::Sleep(10);
+ std::this_thread::sleep_for(10ms);
t = executor.execute(std::move(t));
}
}
diff --git a/vespalib/src/tests/guard/guard_test.cpp b/vespalib/src/tests/guard/guard_test.cpp
index 358a56d44cb..a9d5d5f894c 100644
--- a/vespalib/src/tests/guard/guard_test.cpp
+++ b/vespalib/src/tests/guard/guard_test.cpp
@@ -1,8 +1,9 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/guard.h>
+#include <fcntl.h>
+#include <unistd.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/net/selector/selector_test.cpp b/vespalib/src/tests/net/selector/selector_test.cpp
index c91b3e0b054..964e37adf3b 100644
--- a/vespalib/src/tests/net/selector/selector_test.cpp
+++ b/vespalib/src/tests/net/selector/selector_test.cpp
@@ -6,6 +6,7 @@
#include <thread>
#include <functional>
#include <chrono>
+#include <fcntl.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/net/socket/socket_test.cpp b/vespalib/src/tests/net/socket/socket_test.cpp
index bfeb73f72fc..c7cb2a0b6d9 100644
--- a/vespalib/src/tests/net/socket/socket_test.cpp
+++ b/vespalib/src/tests/net/socket/socket_test.cpp
@@ -10,6 +10,8 @@
#include <thread>
#include <functional>
#include <chrono>
+#include <unistd.h>
+#include <sys/stat.h>
using namespace vespalib;
diff --git a/vespalib/src/tests/signalhandler/signalhandler_test.cpp b/vespalib/src/tests/signalhandler/signalhandler_test.cpp
index a83661e8697..b11cc5746d9 100644
--- a/vespalib/src/tests/signalhandler/signalhandler_test.cpp
+++ b/vespalib/src/tests/signalhandler/signalhandler_test.cpp
@@ -1,8 +1,11 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("signalhandler_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/signalhandler.h>
+#include <unistd.h>
+
+#include <vespa/log/log.h>
+LOG_SETUP("signalhandler_test");
using namespace vespalib;
diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp
index 0159a9c50ab..b405ac84797 100644
--- a/vespalib/src/tests/stllike/hash_test.cpp
+++ b/vespalib/src/tests/stllike/hash_test.cpp
@@ -5,6 +5,7 @@
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/stllike/hash_map_equal.hpp>
#include <cstddef>
+#include <algorithm>
using namespace vespalib;
using std::make_pair;
diff --git a/vespalib/src/tests/stllike/string_test.cpp b/vespalib/src/tests/stllike/string_test.cpp
index c3a0dc9cfd7..2973ffd1ef1 100644
--- a/vespalib/src/tests/stllike/string_test.cpp
+++ b/vespalib/src/tests/stllike/string_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/stllike/string.h>
+#include <algorithm>
using namespace vespalib;
diff --git a/vespalib/src/tests/text/utf8/utf8_test.cpp b/vespalib/src/tests/text/utf8/utf8_test.cpp
index 9110b44f646..a44c0a7560b 100644
--- a/vespalib/src/tests/text/utf8/utf8_test.cpp
+++ b/vespalib/src/tests/text/utf8/utf8_test.cpp
@@ -1,10 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("utf8_test");
+
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/text/utf8.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <vespa/log/log.h>
+LOG_SETUP("utf8_test");
#if 0
#include <vespa/fastlib/text/unicodeutil.h>
#endif
diff --git a/vespalib/src/tests/zcurve/zcurve_test.cpp b/vespalib/src/tests/zcurve/zcurve_test.cpp
index 89bc3fed051..67f6a622ff0 100644
--- a/vespalib/src/tests/zcurve/zcurve_test.cpp
+++ b/vespalib/src/tests/zcurve/zcurve_test.cpp
@@ -1,12 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/log/log.h>
-LOG_SETUP("zcurve_test");
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/geo/zcurve.h>
#include <algorithm>
#include <limits>
#include <map>
+#include <sys/time.h>
+
+#include <vespa/log/log.h>
+LOG_SETUP("zcurve_test");
namespace vespalib {
@@ -20,34 +22,26 @@ public:
{
}
- void
- testEncoding(void);
+ void testEncoding();
- void
- testDecoding(void);
+ void testDecoding();
- double
- ftime(void);
+ double ftime();
- static inline int64_t
- encodexy3(int32_t x, int32_t y);
+ static inline int64_t encodexy3(int32_t x, int32_t y);
#define BMLIMIT 0x1000000
template <bool decode>
- int64_t
- bm(void);
+ int64_t bm();
template <bool decode>
- int64_t
- bm2(void);
+ int64_t bm2();
template <bool decode>
- int64_t
- bm3(void);
+ int64_t bm3();
- int64_t
- bmcheck();
+ int64_t bmcheck();
int Main() override;
};
@@ -140,7 +134,7 @@ ZCurveTest::testDecoding(void)
double
-ZCurveTest::ftime(void)
+ZCurveTest::ftime()
{
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -183,7 +177,7 @@ ZCurveTest::encodexy3(int32_t x, int32_t y)
template <bool decode>
int64_t
-ZCurveTest::bm(void)
+ZCurveTest::bm()
{
int64_t res = 0;
double before = ftime();
@@ -265,7 +259,7 @@ ZCurveTest::bm2(void)
template <bool decode>
int64_t
-ZCurveTest::bm3(void)
+ZCurveTest::bm3()
{
int64_t res = 0;
double before = ftime();
@@ -305,7 +299,7 @@ ZCurveTest::bm3(void)
int64_t
-ZCurveTest::bmcheck(void)
+ZCurveTest::bmcheck()
{
int64_t res = 0;
double before = ftime();
@@ -348,7 +342,7 @@ ZCurveTest::bmcheck(void)
int
-ZCurveTest::Main(void)
+ZCurveTest::Main()
{
TEST_INIT("zcurve_test");
diff --git a/vespalib/src/vespa/vespalib/data/slime/inspector.cpp b/vespalib/src/vespa/vespalib/data/slime/inspector.cpp
index 46847c20754..1f5631accc6 100644
--- a/vespalib/src/vespa/vespalib/data/slime/inspector.cpp
+++ b/vespalib/src/vespa/vespalib/data/slime/inspector.cpp
@@ -3,7 +3,7 @@
#include "inspector.h"
#include "object_traverser.h"
#include "array_traverser.h"
-#include <assert.h>
+#include <cassert>
namespace vespalib {
namespace slime {
diff --git a/vespalib/src/vespa/vespalib/data/slime/strfmt.cpp b/vespalib/src/vespa/vespalib/data/slime/strfmt.cpp
index 7b16382dde3..487badfabf8 100644
--- a/vespalib/src/vespa/vespalib/data/slime/strfmt.cpp
+++ b/vespalib/src/vespa/vespalib/data/slime/strfmt.cpp
@@ -3,7 +3,7 @@
#include "strfmt.h"
#include <stdarg.h>
#include <stdio.h>
-#include <assert.h>
+#include <cassert>
namespace vespalib {
namespace slime {
diff --git a/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp b/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp
index f8df7cb5221..ee25652a3a8 100644
--- a/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp
+++ b/vespalib/src/vespa/vespalib/hwaccelrated/avxprivate.hpp
@@ -3,12 +3,9 @@
#pragma once
#include <vespa/fastos/dynamiclibrary.h>
+#include <cstring>
-namespace vespalib {
-
-namespace hwaccelrated {
-
-namespace avx {
+namespace vespalib::hwaccelrated::avx {
namespace {
@@ -80,5 +77,3 @@ T dotProductSelectAlignment(const T * af, const T * bf, size_t sz)
}
}
-}
-}
diff --git a/vespalib/src/vespa/vespalib/io/fileutil.cpp b/vespalib/src/vespa/vespalib/io/fileutil.cpp
index 3b092bd63f4..389218cea35 100644
--- a/vespalib/src/vespa/vespalib/io/fileutil.cpp
+++ b/vespalib/src/vespa/vespalib/io/fileutil.cpp
@@ -6,6 +6,9 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/fastos/file.h>
#include <ostream>
+#include <cassert>
+#include <unistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <vespa/log/log.h>
diff --git a/vespalib/src/vespa/vespalib/net/socket_handle.cpp b/vespalib/src/vespa/vespalib/net/socket_handle.cpp
index 5e1e8f0155b..36eae46031f 100644
--- a/vespalib/src/vespa/vespalib/net/socket_handle.cpp
+++ b/vespalib/src/vespa/vespalib/net/socket_handle.cpp
@@ -3,7 +3,7 @@
#include "socket_handle.h"
#include <sys/socket.h>
#include <errno.h>
-#include <assert.h>
+#include <cassert>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index 8d3ff1d77dc..7b895f3eb73 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <limits>
#include <stdexcept>
+#include <cassert>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/test/socket_options_verifier.h b/vespalib/src/vespa/vespalib/test/socket_options_verifier.h
index ace0adb9c8e..72694f643e2 100644
--- a/vespalib/src/vespa/vespalib/test/socket_options_verifier.h
+++ b/vespalib/src/vespa/vespalib/test/socket_options_verifier.h
@@ -3,9 +3,13 @@
#pragma once
#include <vespa/vespalib/testkit/test_kit.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <netinet/tcp.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
-namespace vespalib {
-namespace test {
+namespace vespalib::test {
namespace {
@@ -56,5 +60,4 @@ struct SocketOptionsVerifier {
}
};
-} // namespace vespalib::test
-} // namespace vespalib
+}
diff --git a/vespalib/src/vespa/vespalib/testkit/test_kit.h b/vespalib/src/vespa/vespalib/testkit/test_kit.h
index d9f8428c680..7e6b07d71df 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_kit.h
+++ b/vespalib/src/vespa/vespalib/testkit/test_kit.h
@@ -3,6 +3,7 @@
#pragma once
#include <memory>
+#include <cstring>
#include "test_macros.h"
#include "test_comparators.h"
#include "test_master.h"
diff --git a/vespalib/src/vespa/vespalib/testkit/test_master.cpp b/vespalib/src/vespa/vespalib/testkit/test_master.cpp
index 9ea5a8a1c6a..d5309845dfd 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_master.cpp
+++ b/vespalib/src/vespa/vespalib/testkit/test_master.cpp
@@ -2,6 +2,7 @@
#include "test_master.h"
#include <vespa/vespalib/util/barrier.h>
+#include <cstring>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp
index be443163b81..dff744a0a41 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.cpp
+++ b/vespalib/src/vespa/vespalib/util/alloc.cpp
@@ -9,6 +9,7 @@
#include <atomic>
#include <unordered_map>
#include <vespa/fastos/file.h>
+#include <unistd.h>
#include <vespa/log/log.h>
LOG_SETUP(".vespalib.alloc");
diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h
index 7b078025e82..2c3de92c58e 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.h
+++ b/vespalib/src/vespa/vespalib/util/alloc.h
@@ -1,14 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <sys/types.h>
-#include <algorithm>
#include <vespa/vespalib/util/optimized.h>
#include <memory>
-namespace vespalib {
-
-namespace alloc {
+namespace vespalib::alloc {
class MemoryAllocator {
public:
@@ -116,6 +112,8 @@ private:
}
+namespace vespalib {
+
inline size_t roundUp2inN(size_t minimum) {
return 2ul << Optimized::msbIdx(minimum - 1);
}
diff --git a/vespalib/src/vespa/vespalib/util/array.h b/vespalib/src/vespa/vespalib/util/array.h
index b766ed56844..23ce250642b 100644
--- a/vespalib/src/vespa/vespalib/util/array.h
+++ b/vespalib/src/vespa/vespalib/util/array.h
@@ -1,12 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <cstdint>
-#include <sys/types.h>
-#include <algorithm>
-#include <vespa/vespalib/util/alloc.h>
-#include <vespa/vespalib/util/optimized.h>
-#include <tr1/type_traits>
+#include "alloc.h"
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/array.hpp b/vespalib/src/vespa/vespalib/util/array.hpp
index 86626f15b7c..771251f1675 100644
--- a/vespalib/src/vespa/vespalib/util/array.hpp
+++ b/vespalib/src/vespa/vespalib/util/array.hpp
@@ -2,8 +2,9 @@
#pragma once
#include "array.h"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
+#include <tr1/type_traits>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/arrayqueue.hpp b/vespalib/src/vespa/vespalib/util/arrayqueue.hpp
index 85f4afabf9f..6c26fd3a0c4 100644
--- a/vespalib/src/vespa/vespalib/util/arrayqueue.hpp
+++ b/vespalib/src/vespa/vespalib/util/arrayqueue.hpp
@@ -5,7 +5,7 @@
#include <stdint.h>
#include <stdlib.h>
-#include <assert.h>
+#include <cassert>
#include <algorithm>
#include "traits.h"
diff --git a/vespalib/src/vespa/vespalib/util/backtrace.cpp b/vespalib/src/vespa/vespalib/util/backtrace.cpp
index 33c3cebe8a8..ee7f39597a6 100644
--- a/vespalib/src/vespa/vespalib/util/backtrace.cpp
+++ b/vespalib/src/vespa/vespalib/util/backtrace.cpp
@@ -7,7 +7,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/fastos/backtrace.h>
#include <execinfo.h>
-#include <signal.h>
+#include <csignal>
namespace {
diff --git a/vespalib/src/vespa/vespalib/util/compress.h b/vespalib/src/vespa/vespalib/util/compress.h
index 7480d4a8f89..f4190c999c3 100644
--- a/vespalib/src/vespa/vespalib/util/compress.h
+++ b/vespalib/src/vespa/vespalib/util/compress.h
@@ -2,12 +2,10 @@
#pragma once
-#include <stdint.h>
-#include <sys/types.h>
+#include <cstdint>
+#include <cstddef>
-namespace vespalib {
-
-namespace compress {
+namespace vespalib::compress {
class Integer {
public:
@@ -87,6 +85,3 @@ public:
};
}
-
-} // namespace vespalib
-
diff --git a/vespalib/src/vespa/vespalib/util/generationhandler.h b/vespalib/src/vespa/vespalib/util/generationhandler.h
index fbc6f1ae78a..d8af7f39c3e 100644
--- a/vespalib/src/vespa/vespalib/util/generationhandler.h
+++ b/vespalib/src/vespa/vespalib/util/generationhandler.h
@@ -4,7 +4,7 @@
#include <stdint.h>
#include <atomic>
-#include <assert.h>
+#include <cassert>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/linkedptr.h b/vespalib/src/vespa/vespalib/util/linkedptr.h
index ca464f48cbb..517208b9ef9 100644
--- a/vespalib/src/vespa/vespalib/util/linkedptr.h
+++ b/vespalib/src/vespa/vespalib/util/linkedptr.h
@@ -5,7 +5,7 @@
#include <algorithm>
#include <memory>
-#include <assert.h>
+#include <cassert>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/signalhandler.h b/vespalib/src/vespa/vespalib/util/signalhandler.h
index 7db23f72570..6b233b2e690 100644
--- a/vespalib/src/vespa/vespalib/util/signalhandler.h
+++ b/vespalib/src/vespa/vespalib/util/signalhandler.h
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <signal.h>
+#include <csignal>
#include <vector>
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/slaveproc.cpp b/vespalib/src/vespa/vespalib/util/slaveproc.cpp
index 76fa86ac5db..8b35fa3559b 100644
--- a/vespalib/src/vespa/vespalib/util/slaveproc.cpp
+++ b/vespalib/src/vespa/vespalib/util/slaveproc.cpp
@@ -3,6 +3,7 @@
#include <vespa/fastos/time.h>
#include "guard.h"
#include "slaveproc.h"
+#include <cstring>
#ifndef FASTOS_NO_THREADS
diff --git a/vespalib/src/vespa/vespalib/util/stringfmt.h b/vespalib/src/vespa/vespalib/util/stringfmt.h
index 625c9530a48..f806368adf5 100644
--- a/vespalib/src/vespa/vespalib/util/stringfmt.h
+++ b/vespalib/src/vespa/vespalib/util/stringfmt.h
@@ -7,6 +7,7 @@
#ifndef PRId64
#define PRId64 "ld"
#define PRIu64 "lu"
+ #define PRIx64 "lx"
#endif
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/sync.h b/vespalib/src/vespa/vespalib/util/sync.h
index 737cdbc3fed..ccadbfb8dfc 100644
--- a/vespalib/src/vespa/vespalib/util/sync.h
+++ b/vespalib/src/vespa/vespalib/util/sync.h
@@ -6,6 +6,8 @@
#include <vespa/fastos/mutex.h>
#include <vespa/fastos/cond.h>
#include <vespa/fastos/time.h>
+#include <cassert>
+
namespace vespalib {
diff --git a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
index e9f101f242e..76557762479 100644
--- a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
+++ b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
@@ -1,15 +1,29 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "threadstackexecutorbase.h"
+#include <vespa/fastos/thread.h>
namespace vespalib {
+namespace thread {
+
+struct ThreadInit : public FastOS_Runnable {
+ Runnable &worker;
+ ThreadStackExecutorBase::init_fun_t init_fun;
+
+ explicit ThreadInit(Runnable &worker_in, ThreadStackExecutorBase::init_fun_t init_fun_in)
+ : worker(worker_in), init_fun(std::move(init_fun_in)) {}
+
+ void Run(FastOS_ThreadInterface *, void *) override;
+};
+
void
-ThreadStackExecutorBase::ThreadInit::Run(FastOS_ThreadInterface *, void *)
-{
+ThreadInit::Run(FastOS_ThreadInterface *, void *) {
init_fun(worker);
}
+}
+
void
ThreadStackExecutorBase::BlockedThread::wait() const
{
@@ -115,7 +129,7 @@ ThreadStackExecutorBase::run()
ThreadStackExecutorBase::ThreadStackExecutorBase(uint32_t stackSize,
uint32_t taskLimit,
init_fun_t init_fun)
- : _pool(stackSize),
+ : _pool(std::make_unique<FastOS_ThreadPool>(stackSize)),
_monitor(),
_stats(),
_executorCompletion(),
@@ -125,7 +139,7 @@ ThreadStackExecutorBase::ThreadStackExecutorBase(uint32_t stackSize,
_taskCount(0),
_taskLimit(taskLimit),
_closed(false),
- _thread_init(std::make_unique<ThreadInit>(*this, std::move(init_fun)))
+ _thread_init(std::make_unique<thread::ThreadInit>(*this, std::move(init_fun)))
{
assert(taskLimit > 0);
}
@@ -135,7 +149,7 @@ ThreadStackExecutorBase::start(uint32_t threads)
{
assert(threads > 0);
for (uint32_t i = 0; i < threads; ++i) {
- FastOS_ThreadInterface *thread = _pool.NewThread(_thread_init.get());
+ FastOS_ThreadInterface *thread = _pool->NewThread(_thread_init.get());
assert(thread != 0);
(void)thread;
}
@@ -236,12 +250,12 @@ ThreadStackExecutorBase::cleanup()
{
shutdown().sync();
_executorCompletion.countDown();
- _pool.Close();
+ _pool->Close();
}
ThreadStackExecutorBase::~ThreadStackExecutorBase()
{
- assert(_pool.isClosed());
+ assert(_pool->isClosed());
assert(_taskCount == 0);
assert(_blocked.empty());
}
diff --git a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h
index a91114b055e..4ea27a2bcde 100644
--- a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h
+++ b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h
@@ -11,10 +11,13 @@
#include <memory>
#include <vector>
#include <functional>
-#include <vespa/fastos/thread.h>
+
+class FastOS_ThreadPool;
namespace vespalib {
+namespace thread { class ThreadInit; }
+
// Convenience macro used to create a function that can be used as an
// init function when creating an executor to inject a frame with the
// given name into the stack of all worker threads.
@@ -46,13 +49,6 @@ public:
using init_fun_t = std::function<int(Runnable&)>;
private:
- struct ThreadInit : public FastOS_Runnable {
- Runnable &worker;
- init_fun_t init_fun;
- explicit ThreadInit(Runnable &worker_in, init_fun_t init_fun_in)
- : worker(worker_in), init_fun(std::move(init_fun_in)) {}
- void Run(FastOS_ThreadInterface *, void *) override;
- };
struct TaggedTask {
Task::UP task;
@@ -102,18 +98,18 @@ private:
void unblock();
};
- FastOS_ThreadPool _pool;
- Monitor _monitor;
- Stats _stats;
- Gate _executorCompletion;
- ArrayQueue<TaggedTask> _tasks;
- ArrayQueue<Worker*> _workers;
- std::vector<BlockedThread*> _blocked;
- EventBarrier<BarrierCompletion> _barrier;
- uint32_t _taskCount;
- uint32_t _taskLimit;
- bool _closed;
- std::unique_ptr<ThreadInit> _thread_init;
+ std::unique_ptr<FastOS_ThreadPool> _pool;
+ Monitor _monitor;
+ Stats _stats;
+ Gate _executorCompletion;
+ ArrayQueue<TaggedTask> _tasks;
+ ArrayQueue<Worker*> _workers;
+ std::vector<BlockedThread*> _blocked;
+ EventBarrier<BarrierCompletion> _barrier;
+ uint32_t _taskCount;
+ uint32_t _taskLimit;
+ bool _closed;
+ std::unique_ptr<thread::ThreadInit> _thread_init;
void block_thread(const LockGuard &, BlockedThread &blocked_thread);
void unblock_threads(const MonitorGuard &);
diff --git a/vespalib/src/vespa/vespalib/util/valgrind.cpp b/vespalib/src/vespa/vespalib/util/valgrind.cpp
index d84855e8005..cbb6cc808fc 100644
--- a/vespalib/src/vespa/vespalib/util/valgrind.cpp
+++ b/vespalib/src/vespa/vespalib/util/valgrind.cpp
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/valgrind.h>
-#include <assert.h>
+#include <cassert>
#include <fcntl.h>
#include <unistd.h>
diff --git a/vespalib/src/vespa/vespalib/websocket/request.cpp b/vespalib/src/vespa/vespalib/websocket/request.cpp
index 733a8978ba6..98a6631bfcb 100644
--- a/vespalib/src/vespa/vespalib/websocket/request.cpp
+++ b/vespalib/src/vespa/vespalib/websocket/request.cpp
@@ -2,9 +2,9 @@
#include "request.h"
#include <cassert>
+#include <algorithm>
-namespace vespalib {
-namespace ws {
+namespace vespalib::ws {
namespace {
@@ -139,5 +139,4 @@ Request::is_ws_upgrade() const
has_connection_token("upgrade"));
}
-} // namespace vespalib::ws
-} // namespace vespalib
+}
diff --git a/vespalog/src/logger/runserver.cpp b/vespalog/src/logger/runserver.cpp
index ee8125c333a..7cbe3711889 100644
--- a/vespalog/src/logger/runserver.cpp
+++ b/vespalog/src/logger/runserver.cpp
@@ -6,7 +6,7 @@
#include <errno.h>
#include <unistd.h>
#include <time.h>
-#include <signal.h>
+#include <csignal>
#include <sys/select.h>
#include <sys/types.h>
diff --git a/vespalog/src/test/logtest.cpp b/vespalog/src/test/logtest.cpp
index b55c05ae93e..42b7bfc6ef9 100644
--- a/vespalog/src/test/logtest.cpp
+++ b/vespalog/src/test/logtest.cpp
@@ -2,7 +2,7 @@
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
-#include <signal.h>
+#include <csignal>
#include <vespa/log/log.h>
diff --git a/vespalog/src/test/simple/logtest.cpp b/vespalog/src/test/simple/logtest.cpp
index ff52eeff1bf..020c97dd1a8 100644
--- a/vespalog/src/test/simple/logtest.cpp
+++ b/vespalog/src/test/simple/logtest.cpp
@@ -2,7 +2,7 @@
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
-#include <signal.h>
+#include <csignal>
#include <vespa/log/log.h>
diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp
index b6fea71cb6c..dc469018a5f 100644
--- a/vespalog/src/test/threads/testthreads.cpp
+++ b/vespalog/src/test/threads/testthreads.cpp
@@ -4,6 +4,9 @@
#include <vespa/fastos/thread.h>
#include <vespa/log/bufferedlogger.h>
#include <iostream>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/stat.h>
using std::string;
diff --git a/vespalog/src/vespa-logfmt/logfilter.c b/vespalog/src/vespa-logfmt/logfilter.c
index cd8dcc86deb..2db108771ee 100644
--- a/vespalog/src/vespa-logfmt/logfilter.c
+++ b/vespalog/src/vespa-logfmt/logfilter.c
@@ -4,7 +4,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <signal.h>
+#include <csignal>
int main(int argc, char *argv[])
{
diff --git a/vespalog/src/vespa/log/log.cpp b/vespalog/src/vespa/log/log.cpp
index c44d490229b..a0977406dc0 100644
--- a/vespalog/src/vespa/log/log.cpp
+++ b/vespalog/src/vespa/log/log.cpp
@@ -13,6 +13,10 @@ LOG_SETUP_INDIRECT(".log", "$Id$");
#include "bufferedlogger.h"
#include <vespa/fastos/thread.h>
+#include <cassert>
+#include <cstdarg>
+#include <unistd.h>
+#include <sys/time.h>
namespace ns_log {
diff --git a/vespalog/src/vespa/log/log.h b/vespalog/src/vespa/log/log.h
index b78fcf4a72d..127baf14d55 100644
--- a/vespalog/src/vespa/log/log.h
+++ b/vespalog/src/vespa/log/log.h
@@ -300,3 +300,9 @@ extern void log_abort(const char *message,
#else
#define LOG_ASSERT(expr)
#endif // #ifndef NDEBUG
+
+#ifndef PRId64
+ #define PRId64 "ld"
+ #define PRIu64 "lu"
+ #define PRIx64 "lx"
+#endif
diff --git a/vespamalloc/src/tests/doubledelete/expectsignal.cpp b/vespamalloc/src/tests/doubledelete/expectsignal.cpp
index e65f0d67615..9ac93da014d 100644
--- a/vespamalloc/src/tests/doubledelete/expectsignal.cpp
+++ b/vespamalloc/src/tests/doubledelete/expectsignal.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/slaveproc.h>
+#include <sys/wait.h>
using namespace vespalib;
diff --git a/vespamalloc/src/tests/overwrite/expectsignal.cpp b/vespamalloc/src/tests/overwrite/expectsignal.cpp
index ec1ce893d2e..e78f1b7b181 100644
--- a/vespamalloc/src/tests/overwrite/expectsignal.cpp
+++ b/vespamalloc/src/tests/overwrite/expectsignal.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/slaveproc.h>
+#include <sys/wait.h>
using namespace vespalib;
diff --git a/vespamalloc/src/tests/test.cpp b/vespamalloc/src/tests/test.cpp
index 6499eaca7ea..899c37d0c0e 100644
--- a/vespamalloc/src/tests/test.cpp
+++ b/vespamalloc/src/tests/test.cpp
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/thread.h>
+#include <cstdlib>
+#include <cstdio>
namespace vespamalloc {
void info();
diff --git a/vespamalloc/src/tests/thread/racemanythreads.cpp b/vespamalloc/src/tests/thread/racemanythreads.cpp
index 692228ced9e..656a7ef487a 100644
--- a/vespamalloc/src/tests/thread/racemanythreads.cpp
+++ b/vespamalloc/src/tests/thread/racemanythreads.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
+#include <unistd.h>
using namespace vespalib;
diff --git a/vespamalloc/src/tests/thread/thread.cpp b/vespamalloc/src/tests/thread/thread.cpp
index b121f1e513b..04be3b38b3d 100644
--- a/vespamalloc/src/tests/thread/thread.cpp
+++ b/vespamalloc/src/tests/thread/thread.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <atomic>
+#include <unistd.h>
using namespace vespalib;
diff --git a/vespamalloc/src/vespamalloc/malloc/memorywatcher.h b/vespamalloc/src/vespamalloc/malloc/memorywatcher.h
index 05290bcda60..00240cadf12 100644
--- a/vespamalloc/src/vespamalloc/malloc/memorywatcher.h
+++ b/vespamalloc/src/vespamalloc/malloc/memorywatcher.h
@@ -2,7 +2,7 @@
#pragma once
#include <stdio.h>
-#include <signal.h>
+#include <csignal>
#include <limits.h>
#include <sys/stat.h>
#include <ctype.h>
diff --git a/vespamalloc/src/vespamalloc/util/traceutil.h b/vespamalloc/src/vespamalloc/util/traceutil.h
index 664ee970a89..513dfdf8c80 100644
--- a/vespamalloc/src/vespamalloc/util/traceutil.h
+++ b/vespamalloc/src/vespamalloc/util/traceutil.h
@@ -2,9 +2,9 @@
#pragma once
#include <dlfcn.h>
-#include <signal.h>
+#include <csignal>
#include <stdlib.h>
-#include <assert.h>
+#include <cassert>
#include <vector>
#include <vespamalloc/util/index.h>
#include <vespamalloc/util/callstack.h>